mirror of
https://github.com/stablyai/orca.git
synced 2026-11-03 02:27:43 +00:00
fix(plugins): keep Try it and Switch back toasts up for 10s (#35650)
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
// Why: sonner's 4s default hides Try it / Switch back before users reach them; hover still pauses.
|
||||
export const PLUGIN_ACTION_TOAST_DURATION_MS = 10_000
|
||||
@@ -105,6 +105,7 @@ it('fills both slots from a light and dark pair, plus icon and terminal themes',
|
||||
})
|
||||
expect(settings.terminalPluginPalettes).toHaveLength(2)
|
||||
expect(toast.success).toHaveBeenCalledWith('Now using Ember', {
|
||||
duration: 10_000,
|
||||
action: { label: 'Switch back', onClick: expect.any(Function) }
|
||||
})
|
||||
})
|
||||
|
||||
@@ -7,6 +7,7 @@ import { resolveDocumentTheme } from '@/lib/document-theme'
|
||||
import { pluginAppThemeSlotUpdate } from '../../../../../shared/plugin-theme-settings'
|
||||
import { withTerminalPluginPalettes } from '@/lib/terminal-plugin-palettes'
|
||||
import { useAppStore } from '@/store'
|
||||
import { PLUGIN_ACTION_TOAST_DURATION_MS } from './plugin-action-toast'
|
||||
import { usePluginIconThemeStore } from '@/store/plugin-icon-themes'
|
||||
import { usePluginThemeStore, usePluginTerminalThemeStore } from '@/store/plugin-themes'
|
||||
|
||||
@@ -136,6 +137,7 @@ export async function applyPluginThemesNow(pluginKey: string): Promise<boolean>
|
||||
value0: label
|
||||
}),
|
||||
{
|
||||
duration: PLUGIN_ACTION_TOAST_DURATION_MS,
|
||||
action: {
|
||||
label: translate('auto.components.settings.pluginThemeApply.switchBack', 'Switch back'),
|
||||
onClick: () => void useAppStore.getState().updateSettings(previous)
|
||||
|
||||
@@ -120,6 +120,18 @@ describe('usePluginInstallAction', () => {
|
||||
expect(toast.success).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('keeps the Try it toast up long enough to click', async () => {
|
||||
const { hook } = setup()
|
||||
await act(async () => hook.current?.install(listing))
|
||||
expect(toast.success).toHaveBeenCalledWith(
|
||||
expect.any(String),
|
||||
expect.objectContaining({
|
||||
duration: 10_000,
|
||||
action: expect.objectContaining({ label: 'Try it' })
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it('approves exactly the fingerprint the page showed for a plugin that runs code', async () => {
|
||||
const { hook } = setup()
|
||||
const codeListing = {
|
||||
|
||||
@@ -7,6 +7,7 @@ import type {
|
||||
import { pluginExecutionProfile } from '../../../../../shared/plugins/contributions/plugin-execution-profile'
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import { pluginInstallErrorMessage } from '../presentation/plugin-error-presentation'
|
||||
import { PLUGIN_ACTION_TOAST_DURATION_MS } from './plugin-action-toast'
|
||||
import { applyPluginThemesNow } from './plugin-theme-apply'
|
||||
import type { PluginPagePreview } from './use-plugin-catalog'
|
||||
import { previewMatchesListing } from './use-plugin-page-model'
|
||||
@@ -166,6 +167,7 @@ export function usePluginInstallAction({
|
||||
{ value0: preview.manifest.name }
|
||||
),
|
||||
{
|
||||
duration: PLUGIN_ACTION_TOAST_DURATION_MS,
|
||||
action: {
|
||||
label: translate('auto.components.settings.pluginInstallAction.tryIt', 'Try it'),
|
||||
onClick: () => onTryPlugin(pluginKey)
|
||||
|
||||
Reference in New Issue
Block a user