Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
refactor(web): scope auto-update settings drafts to the popup (#43518)
yyh411395a342bb
diff --git a/web/app/components/header/account-setting/__tests__/update-setting-dialog-form.spec.tsx b/web/app/components/header/account-setting/__tests__/update-setting-dialog-form.spec.tsxindex 8d486af6454..ad58fd96260 100644--- a/web/app/components/header/account-setting/__tests__/update-setting-dialog-form.spec.tsx+++ b/web/app/components/header/account-setting/__tests__/update-setting-dialog-form.spec.tsx@@ -1,4 +1,6 @@import type { SettingsDestination } from '@/app/components/header/account-setting/query-params'+import { Dialog } from '@langgenius/dify-ui/dialog'+import { QueryClient, QueryClientProvider } from '@tanstack/react-query'import { fireEvent, render, screen } from '@testing-library/react'import userEvent from '@testing-library/user-event'import * as React from 'react'@@ -7,7 +9,8 @@ import {AUTO_UPDATE_STRATEGY,} from '@/app/components/plugins/reference-setting-modal/auto-update-setting/types'import { PluginCategoryEnum } from '@/app/components/plugins/types'-import UpdateSettingDialogForm from '../update-setting-dialog-form'+import { userProfileQueryOptions } from '@/features/account-profile/client'+import { UpdateSettingDialogForm } from '../update-setting-dialog-form'const mockSetSettingsDestination = vi.fn()let mockSettingsDestination: SettingsDestination | null = null@@ -56,6 +59,22 @@ vi.mock(}),)+function renderForm(ui: React.ReactElement) {+ const client = new QueryClient({ defaultOptions: { queries: { staleTime: Infinity } } })+ client.setQueryData(userProfileQueryOptions().queryKey, {+ profile: {+ id: 'user-1',+ name: 'Test User',+ email: '[email protected]',+ avatar_url: null,+ is_password_set: false,+ timezone: 'UTC',+ },+ meta: { currentVersion: null, currentEnv: null },+ })+ return render(<QueryClientProvider client={client}>{ui}</QueryClientProvider>)+}+describe('UpdateSettingDialogForm', () => {beforeEach(() => {vi.clearAllMocks()@@ -64,28 +83,23 @@ describe('UpdateSettingDialogForm', () => {it('should focus update time from its label and keep the timezone action separate', async () => {const user = userEvent.setup()- const onRequestClose = vi.fn()+ const onOpenChange = vi.fn()- render(- <UpdateSettingDialogForm- autoUpgrade={{- strategy_setting: AUTO_UPDATE_STRATEGY.fixOnly,- upgrade_time_of_day: 0,- upgrade_mode: AUTO_UPDATE_MODE.update_all,- exclude_plugins: [],- include_plugins: [],- }}- category={PluginCategoryEnum.tool}- plugins={[]}- scopeOptions={[{ value: AUTO_UPDATE_MODE.update_all, label: 'All' }]}- strategyOptions={[{ value: AUTO_UPDATE_STRATEGY.fixOnly, label: 'Fix only' }]}- timezone="UTC"- updateTimeValue="00:00"- onAutoUpgradeChange={vi.fn()}- onPluginsChange={vi.fn()}- onRequestClose={onRequestClose}- onUpdateTimeChange={vi.fn()}- />,+ renderForm(+ <Dialog defaultOpen onOpenChange={onOpenChange}>+ <UpdateSettingDialogForm+ initialAutoUpgrade={{+ strategy_setting: AUTO_UPDATE_STRATEGY.fixOnly,+ upgrade_time_of_day: 0,+ upgrade_mode: AUTO_UPDATE_MODE.update_all,+ exclude_plugins: [],+ include_plugins: [],+ }}+ category={PluginCategoryEnum.tool}+ isSavePending={false}+ onSave={vi.fn()}+ />+ </Dialog>,)expect(@@ -98,33 +112,28 @@ describe('UpdateSettingDialogForm', () => {expect(screen.queryByRole('dialog')).not.toBeInTheDocument()await user.click(screen.getByText('autoUpdate.changeTimezone'))- expect(onRequestClose).toHaveBeenCalledTimes(1)+ expect(onOpenChange).toHaveBeenCalledExactlyOnceWith(false, expect.anything())expect(mockSetSettingsDestination).toHaveBeenCalledWith('preferences')})it('should replace the current destination when timezone link is clicked inside settings', () => {mockSettingsDestination = 'provider'- render(- <UpdateSettingDialogForm- autoUpgrade={{- strategy_setting: AUTO_UPDATE_STRATEGY.fixOnly,- upgrade_time_of_day: 0,- upgrade_mode: AUTO_UPDATE_MODE.update_all,- exclude_plugins: [],- include_plugins: [],- }}- category={PluginCategoryEnum.tool}- plugins={[]}- scopeOptions={[{ value: AUTO_UPDATE_MODE.update_all, label: 'All' }]}- strategyOptions={[{ value: AUTO_UPDATE_STRATEGY.fixOnly, label: 'Fix only' }]}- timezone="UTC"- updateTimeValue="00:00"- onAutoUpgradeChange={vi.fn()}- onPluginsChange={vi.fn()}- onRequestClose={vi.fn()}- onUpdateTimeChange={vi.fn()}- />,+ renderForm(+ <Dialog>+ <UpdateSettingDialogForm+ initialAutoUpgrade={{+ strategy_setting: AUTO_UPDATE_STRATEGY.fixOnly,+ upgrade_time_of_day: 0,+ upgrade_mode: AUTO_UPDATE_MODE.update_all,+ exclude_plugins: [],+ include_plugins: [],+ }}+ category={PluginCategoryEnum.tool}+ isSavePending={false}+ onSave={vi.fn()}+ />+ </Dialog>,)fireEvent.click(screen.getByText('autoUpdate.changeTimezone'))diff --git a/web/app/components/header/account-setting/__tests__/update-setting-dialog.browser.spec.tsx b/web/app/components/header/account-setting/__tests__/update-setting-dialog.browser.spec.tsxnew file mode 100644index 00000000000..d854e706a32--- /dev/null+++ b/web/app/components/header/account-setting/__tests__/update-setting-dialog.browser.spec.tsx@@ -0,0 +1,176 @@+import type { AutoUpdateConfig } from '@/app/components/plugins/reference-setting-modal/auto-update-setting/types'+import { QueryClient, QueryClientProvider } from '@tanstack/react-query'+import { NuqsTestingAdapter } from 'nuqs/adapters/testing'+import { userEvent } from 'vite-plus/test/browser'+import { render } from 'vitest-browser-react'+import {+ AUTO_UPDATE_MODE,+ AUTO_UPDATE_STRATEGY,+} from '@/app/components/plugins/reference-setting-modal/auto-update-setting/types'+import { PluginCategoryEnum } from '@/app/components/plugins/types'+import { userProfileQueryOptions } from '@/features/account-profile/client'+import { UpdateSettingDialog } from '../update-setting-dialog'++const { getSettings, saveSettings } = vi.hoisted(() => ({+ getSettings: vi.fn(),+ saveSettings: vi.fn(),+}))++vi.mock('@/service/base', () => ({+ get: getSettings,+ post: saveSettings,+ request: vi.fn(),+ getPublic: vi.fn(),+ getMarketplace: vi.fn(),+ postPublic: vi.fn(),+ postMarketplace: vi.fn(),+ put: vi.fn(),+ del: vi.fn(),+ delPublic: vi.fn(),+ patch: vi.fn(),+ patchPublic: vi.fn(),+ upload: vi.fn(),+ ssePost: vi.fn(),+ sseGet: vi.fn(),+ sseGeneratorPost: vi.fn(),+ handleStream: vi.fn(),+ buildSigninUrlWithRedirect: vi.fn(),+ isWebAppSigninPath: vi.fn(),+ buildWebAppSigninUrlWithRedirect: vi.fn(),+}))++const savedConfig: AutoUpdateConfig = {+ strategy_setting: AUTO_UPDATE_STRATEGY.disabled,+ upgrade_time_of_day: 0,+ upgrade_mode: AUTO_UPDATE_MODE.update_all,+ include_plugins: [],+ exclude_plugins: [],+}++async function renderSettings() {+ const queryClient = new QueryClient({+ defaultOptions: {+ queries: { retry: false, staleTime: Infinity },+ mutations: { retry: false },+ },+ })+ queryClient.setQueryData(userProfileQueryOptions().queryKey, {+ profile: {+ id: 'user-1',+ name: 'Test User',+ email: '[email protected]',+ avatar: '',+ avatar_url: null,+ is_password_set: false,+ timezone: 'UTC',+ },+ meta: { currentVersion: null, currentEnv: null },+ })+ return render(+ <QueryClientProvider client={queryClient}>+ <NuqsTestingAdapter>+ <UpdateSettingDialog category={PluginCategoryEnum.model} />+ </NuqsTestingAdapter>+ </QueryClientProvider>,+ )+}++beforeEach(() => {+ vi.clearAllMocks()+ vi.stubGlobal('BASE_UI_ANIMATIONS_DISABLED', false)+ getSettings.mockImplementation(async (url: string) => {+ if (url !== '/workspaces/current/plugin/auto-upgrade/fetch')+ throw new Error(`Unexpected request: ${url}`)+ return { category: PluginCategoryEnum.model, auto_upgrade: savedConfig }+ })+})++afterEach(() => vi.unstubAllGlobals())++it('discards cancelled and escaped drafts without changing the trigger badge and restores focus', async () => {+ const screen = await renderSettings()+ const trigger = screen.getByRole('button', { name: /^plugin\.autoUpdate\.autoUpdate / })+ await expect+ .element(trigger)+ .toHaveTextContent('plugin.autoUpdate.autoUpdateplugin.autoUpdate.strategy.disabled.name')+ const triggerElement = trigger.element()+ const dialog = screen.getByRole('dialog', { name: 'plugin.autoUpdate.autoUpdateSettings' })++ for (const dismissal of ['Cancel', 'Escape']) {+ await trigger.click()+ await expect+ .element(screen.getByRole('radio', { name: 'plugin.autoUpdate.strategy.disabled.name' }))+ .toBeChecked()+ await screen.getByRole('radio', { name: 'plugin.autoUpdate.strategy.latest.name' }).click()+ await expect+ .element(triggerElement)+ .toHaveTextContent('plugin.autoUpdate.autoUpdateplugin.autoUpdate.strategy.disabled.name')+ await expect+ .element(triggerElement)+ .not.toHaveTextContent('plugin.autoUpdate.autoUpdateplugin.autoUpdate.strategy.latest.name')+ if (dismissal === 'Cancel')+ await screen.getByRole('button', { name: 'common.operation.cancel' }).click()+ else await userEvent.keyboard('{Escape}')+ await expect.element(dialog).not.toBeInTheDocument()+ await expect.element(trigger).toHaveFocus()+ }+ await trigger.click()+ await expect+ .element(screen.getByRole('radio', { name: 'plugin.autoUpdate.strategy.disabled.name' }))+ .toBeChecked()+ expect(saveSettings).not.toHaveBeenCalled()+})++it('closes an optimistic save immediately, blocks another pending save and restores rolled-back settings on reopening', async () => {+ let rejectSave!: (error: Error) => void+ saveSettings.mockReturnValue(+ new Promise((_, reject) => {+ rejectSave = reject+ }),+ )+ const screen = await renderSettings()+ const trigger = screen.getByRole('button', { name: /^plugin\.autoUpdate\.autoUpdate / })+ await expect+ .element(trigger)+ .toHaveTextContent('plugin.autoUpdate.autoUpdateplugin.autoUpdate.strategy.disabled.name')+ const triggerElement = trigger.element()+ const dialog = screen.getByRole('dialog', { name: 'plugin.autoUpdate.autoUpdateSettings' })+ await trigger.click()+ await screen.getByRole('radio', { name: 'plugin.autoUpdate.strategy.latest.name' }).click()+ await screen.getByRole('button', { name: 'common.operation.save' }).click()+ await expect.element(dialog).not.toBeInTheDocument()+ await expect.element(trigger).toHaveFocus()+ await expect+ .element(trigger)+ .toHaveTextContent('plugin.autoUpdate.autoUpdateplugin.autoUpdate.strategy.latest.name')+ await expect.poll(() => saveSettings.mock.calls.length).toBe(1)+ expect(saveSettings).toHaveBeenCalledWith('/workspaces/current/plugin/auto-upgrade/change', {+ body: {+ category: PluginCategoryEnum.model,+ auto_upgrade: { ...savedConfig, strategy_setting: AUTO_UPDATE_STRATEGY.latest },+ },+ })++ await trigger.click()+ const save = screen.getByRole('button', { name: 'common.operation.save' })+ await expect.element(save).toBeDisabled()+ expect(saveSettings).toHaveBeenCalledOnce()+ await expect.element(dialog).toBeVisible()++ rejectSave(new Error('Save failed'))+ await expect+ .element(triggerElement)+ .toHaveTextContent('plugin.autoUpdate.autoUpdateplugin.autoUpdate.strategy.disabled.name')+ await expect.element(save).toBeEnabled()+ await expect+ .element(screen.getByRole('radio', { name: 'plugin.autoUpdate.strategy.latest.name' }))+ .toBeChecked()+ await screen.getByRole('button', { name: 'common.operation.cancel' }).click()+ await expect.element(dialog).not.toBeInTheDocument()+ await trigger.click()+ await expect+ .element(screen.getByRole('radio', { name: 'plugin.autoUpdate.strategy.disabled.name' }))+ .toBeChecked()+ await userEvent.keyboard('{Escape}')+ await expect.element(trigger).toHaveFocus()+})diff --git a/web/app/components/header/account-setting/__tests__/update-setting-dialog.spec.tsx b/web/app/components/header/account-setting/__tests__/update-setting-dialog.spec.tsxnew file mode 100644index 00000000000..635cb2a67d8--- /dev/null+++ b/web/app/components/header/account-setting/__tests__/update-setting-dialog.spec.tsx@@ -0,0 +1,178 @@+import type { AutoUpdateConfig } from '@/app/components/plugins/reference-setting-modal/auto-update-setting/types'+import { QueryClient, QueryClientProvider } from '@tanstack/react-query'+import { act, render, screen, waitFor } from '@testing-library/react'+import userEvent from '@testing-library/user-event'+import { NuqsTestingAdapter } from 'nuqs/adapters/testing'+import {+ AUTO_UPDATE_MODE,+ AUTO_UPDATE_STRATEGY,+} from '@/app/components/plugins/reference-setting-modal/auto-update-setting/types'+import { PluginCategoryEnum } from '@/app/components/plugins/types'+import { toast } from '@/app/notifications'+import { userProfileQueryOptions } from '@/features/account-profile/client'+import { UpdateSettingDialog } from '../update-setting-dialog'++const { getSettings, saveSettings } = vi.hoisted(() => ({+ getSettings: vi.fn(),+ saveSettings: vi.fn(),+}))++vi.mock('@/service/base', async (importOriginal) => ({+ ...(await importOriginal<typeof import('@/service/base')>()),+ get: getSettings,+ post: saveSettings,+}))++const savedConfig: AutoUpdateConfig = {+ strategy_setting: AUTO_UPDATE_STRATEGY.disabled,+ upgrade_time_of_day: 0,+ upgrade_mode: AUTO_UPDATE_MODE.update_all,+ include_plugins: [],+ exclude_plugins: [],+}++function deferred<T>() {+ let resolve!: (value: T | PromiseLike<T>) => void+ let reject!: (reason: unknown) => void+ const promise = new Promise<T>((resolvePromise, rejectPromise) => {+ resolve = resolvePromise+ reject = rejectPromise+ })+ return { promise, resolve, reject }+}++function renderSettings(category = PluginCategoryEnum.model) {+ const client = new QueryClient({+ defaultOptions: { queries: { retry: false, staleTime: Infinity }, mutations: { retry: false } },+ })+ client.setQueryData(userProfileQueryOptions().queryKey, {+ profile: {+ id: 'user-1',+ name: 'Test User',+ email: '[email protected]',+ avatar_url: null,+ is_password_set: false,+ timezone: 'UTC',+ },+ meta: { currentVersion: null, currentEnv: null },+ })+ const renderCategory = (currentCategory: PluginCategoryEnum) => (+ <QueryClientProvider client={client}>+ <NuqsTestingAdapter>+ <UpdateSettingDialog category={currentCategory} />+ </NuqsTestingAdapter>+ </QueryClientProvider>+ )+ const view = render(renderCategory(category))+ return {+ ...view,+ client,+ changeCategory: (next: PluginCategoryEnum) => view.rerender(renderCategory(next)),+ }+}++const settingsTrigger = () =>+ screen.getByRole('button', { name: /^plugin\.autoUpdate\.autoUpdate / })+const strategy = (value: 'disabled' | 'fixOnly' | 'latest') =>+ screen.getByRole('radio', { name: `plugin.autoUpdate.strategy.${value}.name` })++beforeEach(() => {+ vi.clearAllMocks()+ getSettings.mockImplementation(+ async (_url, { params }: { params: { category: PluginCategoryEnum } }) => ({+ category: params.category,+ auto_upgrade: savedConfig,+ }),+ )+})++it('starts a draft when settings arrive and preserves it across a background refresh', async () => {+ const initialSettings = deferred<{+ category: PluginCategoryEnum+ auto_upgrade: AutoUpdateConfig+ }>()+ getSettings.mockReturnValueOnce(initialSettings.promise)+ const user = userEvent.setup()+ const { client } = renderSettings()+ const trigger = screen.getByRole('button', { name: 'plugin.autoUpdate.autoUpdate' })+ await user.click(trigger)+ expect(screen.getByRole('status')).toHaveTextContent('common.loading')+ expect(screen.queryByRole('button', { name: 'common.operation.save' })).not.toBeInTheDocument()+ initialSettings.resolve({ category: PluginCategoryEnum.model, auto_upgrade: savedConfig })+ await waitFor(() => expect(strategy('disabled')).toBeChecked())+ await user.click(strategy('latest'))+ getSettings.mockResolvedValue({+ category: PluginCategoryEnum.model,+ auto_upgrade: { ...savedConfig, strategy_setting: AUTO_UPDATE_STRATEGY.fixOnly },+ })+ await act(async () => {+ await client.refetchQueries({ predicate: (query) => query.queryKey.includes('autoUpgrade') })+ })+ expect(strategy('latest')).toBeChecked()+ await waitFor(() => expect(trigger).toHaveTextContent('plugin.autoUpdate.strategy.fixOnly.name'))+ await user.click(screen.getByRole('button', { name: 'common.operation.cancel' }))+ await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument())+ await user.click(settingsTrigger())+ expect(strategy('fixOnly')).toBeChecked()+})++it('keeps an earlier category rollback separate from the current category session', async () => {+ const pendingSave = deferred<void>()+ saveSettings.mockReturnValue(pendingSave.promise)+ const user = userEvent.setup()+ const { changeCategory } = renderSettings()+ await waitFor(() =>+ expect(settingsTrigger()).toHaveTextContent('plugin.autoUpdate.strategy.disabled.name'),+ )+ await user.click(settingsTrigger())+ await user.click(strategy('latest'))+ await user.click(screen.getByRole('button', { name: 'common.operation.save' }))+ await waitFor(() => expect(saveSettings).toHaveBeenCalledOnce())+ expect(saveSettings).toHaveBeenCalledWith('/workspaces/current/plugin/auto-upgrade/change', {+ body: {+ category: PluginCategoryEnum.model,+ auto_upgrade: { ...savedConfig, strategy_setting: AUTO_UPDATE_STRATEGY.latest },+ },+ })+ getSettings.mockImplementation(+ async (_url, { params }: { params: { category: PluginCategoryEnum } }) => ({+ category: params.category,+ auto_upgrade: { ...savedConfig, strategy_setting: AUTO_UPDATE_STRATEGY.fixOnly },+ }),+ )+ changeCategory(PluginCategoryEnum.tool)+ await waitFor(() =>+ expect(settingsTrigger()).toHaveTextContent('plugin.autoUpdate.strategy.fixOnly.name'),+ )+ await user.click(settingsTrigger())+ expect(strategy('fixOnly')).toBeChecked()+ await act(async () => {+ pendingSave.reject(new Error('Save failed'))+ })+ expect(strategy('fixOnly')).toBeChecked()+ await user.click(screen.getByRole('button', { name: 'common.operation.cancel' }))+ await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument())+ expect(settingsTrigger()).toHaveTextContent('plugin.autoUpdate.strategy.fixOnly.name')+ changeCategory(PluginCategoryEnum.model)+ await waitFor(() =>+ expect(settingsTrigger()).toHaveTextContent('plugin.autoUpdate.strategy.disabled.name'),+ )+})++it('reports success after the submitted form has closed', async () => {+ const pendingSave = deferred<void>()+ saveSettings.mockReturnValue(pendingSave.promise)+ const success = vi.spyOn(toast, 'success')+ const user = userEvent.setup()+ renderSettings()+ await waitFor(() => expect(settingsTrigger()).toBeInTheDocument())+ await user.click(settingsTrigger())+ await user.click(strategy('latest'))+ await user.click(screen.getByRole('button', { name: 'common.operation.save' }))+ await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument())+ expect(success).not.toHaveBeenCalled()+ await act(async () => {+ pendingSave.resolve()+ })+ await waitFor(() => expect(success).toHaveBeenCalledWith('common.api.actionSuccess'))+})diff --git a/web/app/components/header/account-setting/data-source-page-new/__tests__/index.spec.tsx b/web/app/components/header/account-setting/data-source-page-new/__tests__/index.spec.tsxindex 19347cd866c..865b2c8c9af 100644--- a/web/app/components/header/account-setting/data-source-page-new/__tests__/index.spec.tsx+++ b/web/app/components/header/account-setting/data-source-page-new/__tests__/index.spec.tsx@@ -88,7 +88,7 @@ vi.mock('@/app/components/plugins/plugin-page/use-reference-setting', () => ({}))vi.mock('@/app/components/header/account-setting/update-setting-dialog', () => ({- default: () => (+ UpdateSettingDialog: () => (<button type="button" aria-label="plugin.autoUpdate.autoUpdate">plugin.autoUpdate.autoUpdate</button>diff --git a/web/app/components/header/account-setting/data-source-page-new/index.tsx b/web/app/components/header/account-setting/data-source-page-new/index.tsxindex 6109a728f50..b9e6db7d53b 100644--- a/web/app/components/header/account-setting/data-source-page-new/index.tsx+++ b/web/app/components/header/account-setting/data-source-page-new/index.tsx@@ -13,7 +13,7 @@ import { useRenderI18nObject } from '@/hooks/use-i18n'import { consoleQuery } from '@/service/console'import { useGetDataSourceListAuth, useInvalidDataSourceListAuth } from '@/service/use-datasource'import { useInstalledPluginList, useInvalidateInstalledPluginList } from '@/service/use-plugins'-import UpdateSettingDialog from '../update-setting-dialog'+import { UpdateSettingDialog } from '../update-setting-dialog'import Card from './card'import InstallFromMarketplace from './install-from-marketplace'diff --git a/web/app/components/header/account-setting/model-provider-page/index.tsx b/web/app/components/header/account-setting/model-provider-page/index.tsxindex 4f07ce2e0d9..3694a112988 100644--- a/web/app/components/header/account-setting/model-provider-page/index.tsx+++ b/web/app/components/header/account-setting/model-provider-page/index.tsx@@ -14,7 +14,7 @@ import { usePluginSettingsAccess } from '@/app/components/plugins/plugin-page/usimport { PluginCategoryEnum } from '@/app/components/plugins/types'import { systemFeaturesQueryOptions } from '@/features/system-features/client'import { consoleQuery } from '@/service/console'-import UpdateSettingDialog from '../update-setting-dialog'+import { UpdateSettingDialog } from '../update-setting-dialog'import { ModelTypeEnum } from './declarations'import { useDefaultModel } from './hooks'import ModelProviderPageBody from './model-provider-page-body'diff --git a/web/app/components/header/account-setting/update-setting-dialog-form.tsx b/web/app/components/header/account-setting/update-setting-dialog-form.tsxindex ffe748289f6..a16c9782432 100644--- a/web/app/components/header/account-setting/update-setting-dialog-form.tsx+++ b/web/app/components/header/account-setting/update-setting-dialog-form.tsx@@ -1,8 +1,11 @@import type { ReactNode } from 'react'import type { AutoUpdateConfig } from '@/app/components/plugins/reference-setting-modal/auto-update-setting/types'import type { PluginCategoryEnum } from '@/app/components/plugins/types'+import { Button } from '@langgenius/dify-ui/button'import { cn } from '@langgenius/dify-ui/cn'+import { DialogClose } from '@langgenius/dify-ui/dialog'import { RadioGroup } from '@langgenius/dify-ui/radio-group'+import { useSuspenseQuery } from '@tanstack/react-query'import { useQueryState } from 'nuqs'import { useState } from 'react'import { Trans, useTranslation } from 'react-i18next'@@ -22,73 +25,110 @@ import {AUTO_UPDATE_MODE,AUTO_UPDATE_STRATEGY,} from '@/app/components/plugins/reference-setting-modal/auto-update-setting/types'+import {+ convertLocalSecondsToUTCDaySeconds,+ convertUTCDaySecondsToLocalSeconds,+} from '@/app/components/plugins/reference-setting-modal/auto-update-setting/utils'+import { userProfileQueryOptions } from '@/features/account-profile/client'import { convertTimezoneToOffsetStr } from '@/utils/timezone'import UpdateSettingOptionCard from './update-setting-option-card'-type Option<Value extends string> = {- value: Value- label: string-}-type UpdateSettingDialogFormProps = {- autoUpgrade: AutoUpdateConfig+ initialAutoUpgrade: AutoUpdateConfigcategory: PluginCategoryEnum- plugins: string[]- scopeOptions: Option<AUTO_UPDATE_MODE>[]- strategyOptions: Option<AUTO_UPDATE_STRATEGY>[]- timezone: string- updateTimeValue: string- onAutoUpgradeChange: (payload: Partial<AutoUpdateConfig>) => void- onPluginsChange: (newPlugins: string[]) => void- onRequestClose: () => void- onUpdateTimeChange: (value: string | null) => void+ isSavePending: boolean+ onSave: (autoUpgrade: AutoUpdateConfig) => void}const updateSettingFormLabelClassName ='flex min-h-6 w-full items-center system-sm-medium text-text-secondary'-function SettingTimeZone({- children,- onRequestClose,-}: {- children?: ReactNode- onRequestClose: () => void-}) {+function SettingTimeZone({ children }: { children?: ReactNode }) {const [settingsDestination, setSettingsDestination] = useQueryState(settingsQueryParamName,settingsQueryParser,)return (- <button- type="button"+ <DialogCloseclassName="cursor-pointer border-none bg-transparent p-0 text-left body-xs-regular text-text-accent focus-visible:ring-1 focus-visible:ring-components-input-border-active focus-visible:outline-hidden"onClick={() => {- onRequestClose()if (settingsDestination)setSettingsDestination('preferences', { history: 'replace', shallow: true })else setSettingsDestination('preferences')}}>{children}- </button>+ </DialogClose>)}-const UpdateSettingDialogForm = ({- autoUpgrade,+export function UpdateSettingDialogForm({+ initialAutoUpgrade,category,- plugins,- scopeOptions,- strategyOptions,- timezone,- updateTimeValue,- onAutoUpgradeChange,- onPluginsChange,- onRequestClose,- onUpdateTimeChange,-}: UpdateSettingDialogFormProps) => {- const { t } = useTranslation(['plugin'])+ isSavePending,+ onSave,+}: UpdateSettingDialogFormProps) {+ const { t } = useTranslation(['plugin', 'common'])+ const { data: timezone } = useSuspenseQuery({+ ...userProfileQueryOptions(),+ select: (data) => data.profile.timezone || 'UTC',+ })+ const [autoUpgrade, setAutoUpgrade] = useState(initialAutoUpgrade)+ const onAutoUpgradeChange = (payload: Partial<AutoUpdateConfig>) => {+ setAutoUpgrade((current) => ({ ...current, ...payload }))+ }+ const plugins =+ autoUpgrade.upgrade_mode === AUTO_UPDATE_MODE.partial+ ? autoUpgrade.include_plugins+ : autoUpgrade.upgrade_mode === AUTO_UPDATE_MODE.exclude+ ? autoUpgrade.exclude_plugins+ : []+ const onPluginsChange = (newPlugins: string[]) => {+ if (autoUpgrade.upgrade_mode === AUTO_UPDATE_MODE.partial)+ onAutoUpgradeChange({ include_plugins: newPlugins })+ else if (autoUpgrade.upgrade_mode === AUTO_UPDATE_MODE.exclude)+ onAutoUpgradeChange({ exclude_plugins: newPlugins })+ }+ const localSeconds = convertUTCDaySecondsToLocalSeconds(autoUpgrade.upgrade_time_of_day, timezone)+ const updateTimeValue = `${String(Math.floor(localSeconds / 3600)).padStart(2, '0')}:${String(Math.floor((localSeconds % 3600) / 60)).padStart(2, '0')}`+ const onUpdateTimeChange = (value: string | null) => {+ const [hour, minute] = (value ?? '00:00').split(':').map(Number)+ onAutoUpgradeChange({+ upgrade_time_of_day: convertLocalSecondsToUTCDaySeconds(+ hour! * 3600 + minute! * 60,+ timezone,+ ),+ })+ }+ const strategyOptions = [+ {+ value: AUTO_UPDATE_STRATEGY.disabled,+ label: t(($) => $['autoUpdate.strategy.disabled.name'], { ns: 'plugin' }),+ },+ {+ value: AUTO_UPDATE_STRATEGY.fixOnly,+ label: t(($) => $['autoUpdate.strategy.fixOnly.name'], { ns: 'plugin' }),+ },+ {+ value: AUTO_UPDATE_STRATEGY.latest,+ label: t(($) => $['autoUpdate.strategy.latest.name'], { ns: 'plugin' }),+ },+ ]+ const scopeOptions = [+ {+ value: AUTO_UPDATE_MODE.update_all,+ label: t(($) => $['autoUpdate.scopeMode.all'], { ns: 'plugin' }),+ },+ {+ value: AUTO_UPDATE_MODE.exclude,+ label: t(($) => $['autoUpdate.scopeMode.exclude'], { ns: 'plugin' }),+ },+ {+ value: AUTO_UPDATE_MODE.partial,+ label: t(($) => $['autoUpdate.upgradeMode.partial'], { ns: 'plugin' }),+ },+ ]const [previewStrategy, setPreviewStrategy] = useState<AUTO_UPDATE_STRATEGY>()const displayedStrategy = previewStrategy ?? autoUpgrade.strategy_settingconst getStrategyDescription = (strategy: AUTO_UPDATE_STRATEGY) => {@@ -106,106 +146,121 @@ const UpdateSettingDialogForm = ({const strategyDescription = getStrategyDescription(displayedStrategy)return (- <div className="flex w-full flex-col gap-4 px-6 py-3">- <div className="flex w-full flex-col items-start gap-1">+ <form+ onSubmit={(event) => {+ event.preventDefault()+ onSave(autoUpgrade)+ }}+ >+ <div className="flex w-full flex-col gap-4 px-6 py-3"><div className="flex w-full flex-col items-start gap-1">- <div className={updateSettingFormLabelClassName}>- {t(($) => $['autoUpdate.autoUpdate'], { ns: 'plugin' })}- </div>- <RadioGroup<AUTO_UPDATE_STRATEGY>- aria-label={t(($) => $['autoUpdate.autoUpdate'], { ns: 'plugin' })}- className="flex w-full gap-2"- value={autoUpgrade.strategy_setting}- onValueChange={(strategy_setting) => onAutoUpgradeChange({ strategy_setting })}- >- {strategyOptions.map((option) => (- <UpdateSettingOptionCard<AUTO_UPDATE_STRATEGY>- key={option.value}- value={option.value}- label={option.label}- onFocus={() => setPreviewStrategy(option.value)}- onBlur={() => setPreviewStrategy(undefined)}- onMouseEnter={() => setPreviewStrategy(option.value)}- onMouseLeave={() => setPreviewStrategy(undefined)}- />- ))}- </RadioGroup>- <div className="w-full body-xs-regular text-text-tertiary">{strategyDescription}</div>- </div>- </div>- {autoUpgrade.strategy_setting !== AUTO_UPDATE_STRATEGY.disabled && (- <>- <div className="h-px w-full bg-divider-subtle" /><div className="flex w-full flex-col items-start gap-1">- <TimePicker- timeZone={timezone}- value={updateTimeValue || null}- onValueChange={onUpdateTimeChange}- minuteStep={15}+ <div className={updateSettingFormLabelClassName}>+ {t(($) => $['autoUpdate.autoUpdate'], { ns: 'plugin' })}+ </div>+ <RadioGroup<AUTO_UPDATE_STRATEGY>+ aria-label={t(($) => $['autoUpdate.autoUpdate'], { ns: 'plugin' })}+ className="flex w-full gap-2"+ value={autoUpgrade.strategy_setting}+ onValueChange={(strategy_setting) => onAutoUpgradeChange({ strategy_setting })}>- <div className="flex w-full items-center gap-2">- <TimePickerLabel className={cn(updateSettingFormLabelClassName, 'min-w-0 flex-1')}>- {t(($) => $['autoUpdate.updateTime'], { ns: 'plugin' })}- </TimePickerLabel>- <div className="body-xs-regular text-text-tertiary">- <Trans- i18nKey={($) => $['autoUpdate.changeTimezone']}- ns="plugin"- components={{- setTimezone: <SettingTimeZone onRequestClose={onRequestClose} />,- }}- />- </div>- </div>- <TimePickerTrigger className="w-full px-2">- <span aria-hidden="true" className="i-ri-time-line size-4 text-text-tertiary" />- <TimePickerValue className="flex min-w-0 flex-1 items-center justify-between gap-1">- {(displayValue) => (- <>- <span>{displayValue}</span>- <span className="text-text-tertiary">- {convertTimezoneToOffsetStr(timezone)}- </span>- </>- )}- </TimePickerValue>- </TimePickerTrigger>- <TimePickerContent />- </TimePicker>+ {strategyOptions.map((option) => (+ <UpdateSettingOptionCard<AUTO_UPDATE_STRATEGY>+ key={option.value}+ value={option.value}+ label={option.label}+ onFocus={() => setPreviewStrategy(option.value)}+ onBlur={() => setPreviewStrategy(undefined)}+ onMouseEnter={() => setPreviewStrategy(option.value)}+ onMouseLeave={() => setPreviewStrategy(undefined)}+ />+ ))}+ </RadioGroup>+ <div className="w-full body-xs-regular text-text-tertiary">{strategyDescription}</div></div>- <div className="flex w-full flex-col items-start gap-2">- <div className="flex h-15 w-full flex-col items-start gap-1">- <div className={updateSettingFormLabelClassName}>- {t(($) => $['autoUpdate.scope'], { ns: 'plugin' })}- </div>- <RadioGroup<AUTO_UPDATE_MODE>- aria-label={t(($) => $['autoUpdate.scope'], { ns: 'plugin' })}- className="flex w-full gap-2"- value={autoUpgrade.upgrade_mode}- onValueChange={(upgrade_mode) => onAutoUpgradeChange({ upgrade_mode })}+ </div>+ {autoUpgrade.strategy_setting !== AUTO_UPDATE_STRATEGY.disabled && (+ <>+ <div className="h-px w-full bg-divider-subtle" />+ <div className="flex w-full flex-col items-start gap-1">+ <TimePicker+ timeZone={timezone}+ value={updateTimeValue}+ onValueChange={onUpdateTimeChange}+ minuteStep={15}>- {scopeOptions.map((option) => (- <UpdateSettingOptionCard<AUTO_UPDATE_MODE>- key={option.value}- value={option.value}- label={option.label}- />- ))}- </RadioGroup>+ <div className="flex w-full items-center gap-2">+ <TimePickerLabel+ className={cn(updateSettingFormLabelClassName, 'min-w-0 flex-1')}+ >+ {t(($) => $['autoUpdate.updateTime'], { ns: 'plugin' })}+ </TimePickerLabel>+ <div className="body-xs-regular text-text-tertiary">+ <Trans+ i18nKey={($) => $['autoUpdate.changeTimezone']}+ ns="plugin"+ components={{+ setTimezone: <SettingTimeZone />,+ }}+ />+ </div>+ </div>+ <TimePickerTrigger className="w-full px-2">+ <span aria-hidden="true" className="i-ri-time-line size-4 text-text-tertiary" />+ <TimePickerValue className="flex min-w-0 flex-1 items-center justify-between gap-1">+ {(displayValue) => (+ <>+ <span>{displayValue}</span>+ <span className="text-text-tertiary">+ {convertTimezoneToOffsetStr(timezone)}+ </span>+ </>+ )}+ </TimePickerValue>+ </TimePickerTrigger>+ <TimePickerContent />+ </TimePicker></div>- {autoUpgrade.upgrade_mode !== AUTO_UPDATE_MODE.update_all && (- <PluginsPicker- value={plugins}- onChange={onPluginsChange}- updateMode={autoUpgrade.upgrade_mode}- integrationCategory={category}- />- )}- </div>- </>- )}- </div>+ <div className="flex w-full flex-col items-start gap-2">+ <div className="flex h-15 w-full flex-col items-start gap-1">+ <div className={updateSettingFormLabelClassName}>+ {t(($) => $['autoUpdate.scope'], { ns: 'plugin' })}+ </div>+ <RadioGroup<AUTO_UPDATE_MODE>+ aria-label={t(($) => $['autoUpdate.scope'], { ns: 'plugin' })}+ className="flex w-full gap-2"+ value={autoUpgrade.upgrade_mode}+ onValueChange={(upgrade_mode) => onAutoUpgradeChange({ upgrade_mode })}+ >+ {scopeOptions.map((option) => (+ <UpdateSettingOptionCard<AUTO_UPDATE_MODE>+ key={option.value}+ value={option.value}+ label={option.label}+ />+ ))}+ </RadioGroup>+ </div>+ {autoUpgrade.upgrade_mode !== AUTO_UPDATE_MODE.update_all && (+ <PluginsPicker+ value={plugins}+ onChange={onPluginsChange}+ updateMode={autoUpgrade.upgrade_mode}+ integrationCategory={category}+ />+ )}+ </div>+ </>+ )}+ </div>+ <div className="flex h-19 items-center justify-end gap-2 px-6 pt-5 pb-6">+ <DialogClose render={<Button variant="secondary" className="min-w-18" />}>+ {t(($) => $['operation.cancel'], { ns: 'common' })}+ </DialogClose>+ <Button type="submit" variant="primary" className="min-w-18" disabled={isSavePending}>+ {t(($) => $['operation.save'], { ns: 'common' })}+ </Button>+ </div>+ </form>)}--export default UpdateSettingDialogFormdiff --git a/web/app/components/header/account-setting/update-setting-dialog.tsx b/web/app/components/header/account-setting/update-setting-dialog.tsxindex 487d3491636..85a8e9f93ba 100644--- a/web/app/components/header/account-setting/update-setting-dialog.tsx+++ b/web/app/components/header/account-setting/update-setting-dialog.tsx@@ -1,4 +1,5 @@'use client'+import type { DialogActions } from '@langgenius/dify-ui/dialog'import type { AutoUpdateConfig } from '@/app/components/plugins/reference-setting-modal/auto-update-setting/types'import type { PluginCategoryEnum } from '@/app/components/plugins/types'import { Button } from '@langgenius/dify-ui/button'@@ -10,36 +11,23 @@ import {DialogTrigger,} from '@langgenius/dify-ui/dialog'import { IconButton } from '@langgenius/dify-ui/icon-button'-import { useSuspenseQuery } from '@tanstack/react-query'-import { useCallback, useMemo, useState } from 'react'+import { useRef } from 'react'import { useTranslation } from 'react-i18next'-import {- AUTO_UPDATE_MODE,- AUTO_UPDATE_STRATEGY,-} from '@/app/components/plugins/reference-setting-modal/auto-update-setting/types'-import {- convertLocalSecondsToUTCDaySeconds,- convertUTCDaySecondsToLocalSeconds,-} from '@/app/components/plugins/reference-setting-modal/auto-update-setting/utils'+import { AUTO_UPDATE_STRATEGY } from '@/app/components/plugins/reference-setting-modal/auto-update-setting/types'import { toast } from '@/app/notifications'-import { userProfileQueryOptions } from '@/features/account-profile/client'import {useMutationPluginAutoUpgradeSettings,usePluginAutoUpgradeSettings,} from '@/service/use-plugins'-import UpdateSettingDialogForm from './update-setting-dialog-form'+import { UpdateSettingDialogForm } from './update-setting-dialog-form'type Props = {category: PluginCategoryEnum- disabled?: boolean}-const UpdateSettingDialog = ({ category, disabled = false }: Props) => {+export function UpdateSettingDialog({ category }: Props) {+ const actionsRef = useRef<DialogActions>(null)const { t } = useTranslation(['common', 'plugin'])- const { data: timezone } = useSuspenseQuery({- ...userProfileQueryOptions(),- select: (data) => data.profile.timezone || 'UTC',- })const {data: autoUpgradeSetting,error,@@ -54,150 +42,33 @@ const UpdateSettingDialog = ({ category, disabled = false }: Props) => {},})const savedAutoUpgrade = autoUpgradeSetting?.auto_upgrade- const [isOpen, setIsOpen] = useState(false)- const [draftAutoUpgrade, setDraftAutoUpgrade] = useState<AutoUpdateConfig>()const isSettingsLoading = !savedAutoUpgrade && !error && (isLoading || isFetching)- const autoUpgrade = draftAutoUpgrade ?? savedAutoUpgrade- const hasSettings = !!autoUpgrade- const getStrategyLabel = useCallback(- (strategy: AUTO_UPDATE_STRATEGY) => {- switch (strategy) {- case AUTO_UPDATE_STRATEGY.disabled:- return t(($) => $['autoUpdate.strategy.disabled.name'], { ns: 'plugin' })- case AUTO_UPDATE_STRATEGY.fixOnly:- return t(($) => $['autoUpdate.strategy.fixOnly.name'], { ns: 'plugin' })- case AUTO_UPDATE_STRATEGY.latest:- return t(($) => $['autoUpdate.strategy.latest.name'], { ns: 'plugin' })- default:- return ''- }- },- [t],- )- const selectedStrategyLabel = autoUpgrade ? getStrategyLabel(autoUpgrade.strategy_setting) : ''- const plugins = useMemo(() => {- if (!autoUpgrade) return []-- switch (autoUpgrade.upgrade_mode) {- case AUTO_UPDATE_MODE.partial:- return autoUpgrade.include_plugins- case AUTO_UPDATE_MODE.exclude:- return autoUpgrade.exclude_plugins+ const getStrategyLabel = (strategy: AUTO_UPDATE_STRATEGY) => {+ switch (strategy) {+ case AUTO_UPDATE_STRATEGY.disabled:+ return t(($) => $['autoUpdate.strategy.disabled.name'], { ns: 'plugin' })+ case AUTO_UPDATE_STRATEGY.fixOnly:+ return t(($) => $['autoUpdate.strategy.fixOnly.name'], { ns: 'plugin' })+ case AUTO_UPDATE_STRATEGY.latest:+ return t(($) => $['autoUpdate.strategy.latest.name'], { ns: 'plugin' })default:- return []+ return ''}- }, [autoUpgrade])- const localSeconds = autoUpgrade- ? convertUTCDaySecondsToLocalSeconds(autoUpgrade.upgrade_time_of_day, timezone)- : 0- const updateTimeValue = autoUpgrade- ? `${String(Math.floor(localSeconds / 3600)).padStart(2, '0')}:${String(Math.floor((localSeconds % 3600) / 60)).padStart(2, '0')}`- : ''- const strategyOptions = useMemo(- () => [- {- value: AUTO_UPDATE_STRATEGY.disabled,- label: getStrategyLabel(AUTO_UPDATE_STRATEGY.disabled),- },- {- value: AUTO_UPDATE_STRATEGY.fixOnly,- label: getStrategyLabel(AUTO_UPDATE_STRATEGY.fixOnly),- },- {- value: AUTO_UPDATE_STRATEGY.latest,- label: getStrategyLabel(AUTO_UPDATE_STRATEGY.latest),- },- ],- [getStrategyLabel],- )- const scopeOptions = useMemo(- () => [- {- value: AUTO_UPDATE_MODE.update_all,- label: t(($) => $['autoUpdate.scopeMode.all'], { ns: 'plugin' }),- },- {- value: AUTO_UPDATE_MODE.exclude,- label: t(($) => $['autoUpdate.scopeMode.exclude'], { ns: 'plugin' }),- },- {- value: AUTO_UPDATE_MODE.partial,- label: t(($) => $['autoUpdate.upgradeMode.partial'], { ns: 'plugin' }),- },- ],- [t],- )-- const updateAutoUpgrade = useCallback(- (payload: Partial<AutoUpdateConfig>) => {- setDraftAutoUpgrade((currentAutoUpgrade) => {- const baseAutoUpgrade = currentAutoUpgrade ?? savedAutoUpgrade- if (!baseAutoUpgrade) return undefined-- return {- ...baseAutoUpgrade,- ...payload,- }- })- },- [savedAutoUpgrade],- )-- const handlePluginsChange = useCallback(- (newPlugins: string[]) => {- if (!autoUpgrade) return-- if (autoUpgrade.upgrade_mode === AUTO_UPDATE_MODE.partial) {- updateAutoUpgrade({- include_plugins: newPlugins,- })- } else if (autoUpgrade.upgrade_mode === AUTO_UPDATE_MODE.exclude) {- updateAutoUpgrade({- exclude_plugins: newPlugins,- })- }- },- [autoUpgrade, updateAutoUpgrade],- )- const handleUpdateTimeChange = (value: string | null) => {- const [hour, minute] = (value ?? '00:00').split(':').map(Number)- updateAutoUpgrade({- upgrade_time_of_day: convertLocalSecondsToUTCDaySeconds(- hour! * 3600 + minute! * 60,- timezone,- ),- })}- const handleOpenChange = useCallback(- (open: boolean) => {- if (disabled) {- setIsOpen(false)- return- }-- setIsOpen(open)- if (open) setDraftAutoUpgrade(savedAutoUpgrade)- else setDraftAutoUpgrade(undefined)- },- [disabled, savedAutoUpgrade],- )- const handleCancel = useCallback(() => {- setDraftAutoUpgrade(undefined)- setIsOpen(false)- }, [])- const handleSave = useCallback(() => {- if (!autoUpgrade) return+ const selectedStrategyLabel = savedAutoUpgrade+ ? getStrategyLabel(savedAutoUpgrade.strategy_setting)+ : ''+ const handleSave = (autoUpgrade: AutoUpdateConfig) => {saveAutoUpgrade(autoUpgrade)- setDraftAutoUpgrade(undefined)- setIsOpen(false)- }, [autoUpgrade, saveAutoUpgrade])+ actionsRef.current?.close()+ }return (- <Dialog open={isOpen} onOpenChange={handleOpenChange}>+ <Dialog actionsRef={actionsRef}><DialogTriggerrender={- <Button variant="secondary" className="h-8 system-sm-medium" disabled={disabled}>+ <Button variant="secondary" className="h-8 system-sm-medium"><span aria-hidden className="i-custom-vender-system-auto-update-line size-4" /><span>{t(($) => $['autoUpdate.autoUpdate'], { ns: 'plugin' })}</span>{selectedStrategyLabel && (@@ -208,75 +79,49 @@ const UpdateSettingDialog = ({ category, disabled = false }: Props) => {</Button>}/>- {!disabled && (- <DialogContent className="flex w-120 max-w-[calc(100vw-32px)] flex-col overflow-hidden! rounded-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg p-0! text-left align-middle shadow-xl">- <div className="relative flex w-full items-start gap-2 px-6 pt-6 pr-14 pb-3">- <DialogTitle className="min-w-0 flex-1 title-2xl-semi-bold text-text-primary">- {t(($) => $['autoUpdate.autoUpdateSettings'], { ns: 'plugin' })}- </DialogTitle>- <DialogClose- render={- <IconButton- aria-label={t(($) => $['operation.close'], { ns: 'common' })}- size="lg"- className="absolute top-5 right-5"- >- <span aria-hidden className="i-ri-close-line size-4" />- </IconButton>- }+ <DialogContent className="flex w-120 max-w-[calc(100vw-32px)] flex-col overflow-hidden! rounded-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg p-0! text-left align-middle shadow-xl">+ <div className="relative flex w-full items-start gap-2 px-6 pt-6 pr-14 pb-3">+ <DialogTitle className="min-w-0 flex-1 title-2xl-semi-bold text-text-primary">+ {t(($) => $['autoUpdate.autoUpdateSettings'], { ns: 'plugin' })}+ </DialogTitle>+ <DialogClose+ render={+ <IconButton+ aria-label={t(($) => $['operation.close'], { ns: 'common' })}+ size="lg"+ className="absolute top-5 right-5"+ >+ <span aria-hidden className="i-ri-close-line size-4" />+ </IconButton>+ }+ />+ </div>+ {isSettingsLoading && (+ <div+ role="status"+ className="flex min-h-65 items-center justify-center gap-2 px-6 py-6 system-sm-regular text-text-tertiary"+ >+ <span+ aria-hidden+ className="i-ri-loader-2-line size-4 animate-spin motion-reduce:animate-none"/>+ <span>{t(($) => $.loading, { ns: 'common' })}</span>+ </div>+ )}+ {!isSettingsLoading && !savedAutoUpgrade && (+ <div className="flex min-h-65 items-center justify-center px-6 py-6 text-center system-sm-regular text-text-tertiary">+ {t(($) => $['api.actionFailed'], { ns: 'common' })}</div>- {isSettingsLoading && (- <div- role="status"- className="flex min-h-65 items-center justify-center gap-2 px-6 py-6 system-sm-regular text-text-tertiary"- >- <span- aria-hidden- className="i-ri-loader-2-line size-4 animate-spin motion-reduce:animate-none"- />- <span>{t(($) => $.loading, { ns: 'common' })}</span>- </div>- )}- {!isSettingsLoading && !hasSettings && (- <div className="flex min-h-65 items-center justify-center px-6 py-6 text-center system-sm-regular text-text-tertiary">- {t(($) => $['api.actionFailed'], { ns: 'common' })}- </div>- )}- {!isSettingsLoading && hasSettings && autoUpgrade && (- <>- <UpdateSettingDialogForm- autoUpgrade={autoUpgrade}- category={category}- plugins={plugins}- scopeOptions={scopeOptions}- strategyOptions={strategyOptions}- timezone={timezone}- updateTimeValue={updateTimeValue}- onAutoUpgradeChange={updateAutoUpgrade}- onPluginsChange={handlePluginsChange}- onRequestClose={handleCancel}- onUpdateTimeChange={handleUpdateTimeChange}- />- <div className="flex h-19 items-center justify-end gap-2 px-6 pt-5 pb-6">- <Button variant="secondary" className="min-w-18" onClick={handleCancel}>- {t(($) => $['operation.cancel'], { ns: 'common' })}- </Button>- <Button- variant="primary"- className="min-w-18"- onClick={handleSave}- disabled={isSavePending}- >- {t(($) => $['operation.save'], { ns: 'common' })}- </Button>- </div>- </>- )}- </DialogContent>- )}+ )}+ {savedAutoUpgrade && (+ <UpdateSettingDialogForm+ initialAutoUpgrade={savedAutoUpgrade}+ category={category}+ isSavePending={isSavePending}+ onSave={handleSave}+ />+ )}+ </DialogContent></Dialog>)}--export default UpdateSettingDialogdiff --git a/web/app/components/integrations/__tests__/page.spec.tsx b/web/app/components/integrations/__tests__/page.spec.tsxindex 60ebba87491..afb2a07a690 100644--- a/web/app/components/integrations/__tests__/page.spec.tsx+++ b/web/app/components/integrations/__tests__/page.spec.tsx@@ -122,7 +122,7 @@ vi.mock('@/app/components/plugins/reference-setting-modal', () => ({}))vi.mock('@/app/components/header/account-setting/update-setting-dialog', () => ({- default: () => (+ UpdateSettingDialog: () => (<button type="button" aria-label="plugin.autoUpdate.autoUpdate">plugin.autoUpdate.autoUpdate</button>diff --git a/web/app/components/integrations/__tests__/tool-provider-list.spec.tsx b/web/app/components/integrations/__tests__/tool-provider-list.spec.tsxindex 5c17883944b..2f1830cd2d2 100644--- a/web/app/components/integrations/__tests__/tool-provider-list.spec.tsx+++ b/web/app/components/integrations/__tests__/tool-provider-list.spec.tsx@@ -162,7 +162,7 @@ vi.mock('@/app/components/plugins/plugin-page/use-reference-setting', () => ({}))vi.mock('@/app/components/header/account-setting/update-setting-dialog', () => ({- default: () => (+ UpdateSettingDialog: () => (<button type="button" aria-label="plugin.autoUpdate.autoUpdate">plugin.autoUpdate.autoUpdate</button>diff --git a/web/app/components/integrations/index.tsx b/web/app/components/integrations/index.tsxindex d1380e71874..97236a3d090 100644--- a/web/app/components/integrations/index.tsx+++ b/web/app/components/integrations/index.tsx@@ -27,7 +27,7 @@ import {} from '@langgenius/dify-ui/scroll-area'import { useEffect, useId, useState, useSyncExternalStore } from 'react'import { useTranslation } from 'react-i18next'-import UpdateSettingDialog from '@/app/components/header/account-setting/update-setting-dialog'+import { UpdateSettingDialog } from '@/app/components/header/account-setting/update-setting-dialog'import {buildIntegrationPath,buildMarketplaceUrlPathByIntegrationSection,diff --git a/web/app/components/integrations/tool-provider-toolbar.tsx b/web/app/components/integrations/tool-provider-toolbar.tsxindex a1e215ce0dc..82fea8ddc28 100644--- a/web/app/components/integrations/tool-provider-toolbar.tsx+++ b/web/app/components/integrations/tool-provider-toolbar.tsx@@ -5,7 +5,7 @@ import { cn } from '@langgenius/dify-ui/cn'import { useTranslation } from 'react-i18next'import { SearchInput } from '@/app/components/base/search-input'import TabSliderNew from '@/app/components/base/tab-slider-new'-import UpdateSettingDialog from '@/app/components/header/account-setting/update-setting-dialog'+import { UpdateSettingDialog } from '@/app/components/header/account-setting/update-setting-dialog'import { PluginCategoryEnum } from '@/app/components/plugins/types'import LabelFilter from '@/app/components/tools/labels/filter'diff --git a/web/service/use-plugins.ts b/web/service/use-plugins.tsindex a0db919c587..2847fbbcea9 100644--- a/web/service/use-plugins.ts+++ b/web/service/use-plugins.ts@@ -1233,20 +1233,19 @@ export const useMutationPluginAutoUpgradeSettings = ({queryClient.getQueryData<PluginAutoUpgradeSettingsResponse>(queryKey)const hadPreviousAutoUpgrade = previousAutoUpgrade !== undefined- queryClient.setQueryData(pluginAutoUpgradeSettingsQueryKey(category), {+ queryClient.setQueryData(queryKey, {category,auto_upgrade: payload,} satisfies PluginAutoUpgradeSettingsResponse)- return { previousAutoUpgrade, hadPreviousAutoUpgrade }+ return { queryKey, previousAutoUpgrade, hadPreviousAutoUpgrade }},onError: (_error, _payload, context) => {- if (context?.hadPreviousAutoUpgrade)- queryClient.setQueryData(- pluginAutoUpgradeSettingsQueryKey(category),- context.previousAutoUpgrade,- )- else queryClient.removeQueries({ queryKey: pluginAutoUpgradeSettingsQueryKey(category) })+ // Roll back the category this save started for; the caller may have moved to another one.+ if (!context) return+ if (context.hadPreviousAutoUpgrade)+ queryClient.setQueryData(context.queryKey, context.previousAutoUpgrade)+ else queryClient.removeQueries({ queryKey: context.queryKey })},onSuccess: () => {onSuccess?.()