Skip to content

armgit / dify

Public Imported from GitHub
0

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.

fix(web): improve app deploy accessibility (#44378)

Wu Tianwei4f763a859d03
diff --git a/oxlint-suppressions.json b/oxlint-suppressions.json
index e812444d6d8..cde7b176ea2 100644
--- a/oxlint-suppressions.json
+++ b/oxlint-suppressions.json
@@ -273,16 +273,6 @@
"count": 1
}
},
- "web/app/components/app/deploy/shared/deployment-configuration/index.tsx": {
- "shadcn/no-restyle": {
- "count": 2
- }
- },
- "web/app/components/app/deploy/shared/version-selection/index.tsx": {
- "shadcn/no-restyle": {
- "count": 1
- }
- },
"web/app/components/app/log/filter.tsx": {
"react/only-export-components": {
"count": 1
@@ -1369,11 +1359,6 @@
"count": 5
}
},
- "web/app/components/header/account-setting/model-provider-page/model-selector/popup-item.tsx": {
- "jsx-a11y/no-static-element-interactions": {
- "count": 1
- }
- },
"web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-configs.tsx": {
"typescript/no-explicit-any": {
"count": 5
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index f6dbd575861..6f628c329b1 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1817,6 +1817,9 @@ importers:
agentation:
specifier: 'catalog:'
+ axe-core:
+ specifier: 4.13.0
+ version: 4.13.0
code-inspector-plugin:
specifier: 'catalog:'
version: 1.6.6([email protected])
@@ -17075,6 +17078,7 @@ time:
[email protected]: '2026-09-22T02:41:05.110Z'
[email protected]: '2026-09-06T01:59:54.024Z'
[email protected]: '2026-04-24T15:22:16.529Z'
+ [email protected]: '2026-08-05T16:53:07.262Z'
[email protected]: '2026-02-08T22:04:35.837Z'
[email protected]: '2026-09-22T23:44:24.160Z'
[email protected]: '2025-11-25T23:28:06.854Z'
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index 513015964de..21c760525c1 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -153,6 +153,7 @@ catalog:
agentation: 3.1.2
ahooks: 3.10.0
ajv: 8.20.0
+ axe-core: 4.13.0
bowser: 2.14.1
c12: 4.0.0-rc.2
chokidar: 5.0.0
diff --git a/web/app/components/app/deploy/__tests__/accessibility.browser.spec.tsx b/web/app/components/app/deploy/__tests__/accessibility.browser.spec.tsx
new file mode 100644
index 00000000000..7504b660601
--- /dev/null
+++ b/web/app/components/app/deploy/__tests__/accessibility.browser.spec.tsx
@@ -0,0 +1,694 @@
+import type {
+ EnvironmentDeployment,
+ GetWorkflowDeploymentOptionsResponse,
+} from '@dify/contracts/enterprise-app-deploy/types.gen'
+import {
+ DeploymentOperationStatus,
+ DeploymentOperationType,
+ EnvironmentStatus,
+ EnvVarValueType,
+ PluginCategory,
+ RuntimeState,
+} from '@dify/contracts/enterprise-app-deploy/types.gen'
+import axe from 'axe-core'
+import { createInstance } from 'i18next'
+import { NuqsTestingAdapter } from 'nuqs/adapters/testing'
+import { I18nextProvider } from 'react-i18next'
+import { page, userEvent } from 'vite-plus/test/browser'
+import { render } from 'vitest-browser-react'
+import agentV2 from '@/i18n/locales/en-US/agent-v-2.json'
+import appDebug from '@/i18n/locales/en-US/app-debug.json'
+import common from '@/i18n/locales/en-US/common.json'
+import deployments from '@/i18n/locales/en-US/deployments.json'
+import modelProvider from '@/i18n/locales/en-US/model-provider.json'
+import navigation from '@/i18n/locales/en-US/navigation.json'
+import plugin from '@/i18n/locales/en-US/plugin.json'
+import workflowHistory from '@/i18n/locales/en-US/workflow-history.json'
+import workflow from '@/i18n/locales/en-US/workflow.json'
+import { consoleQuery } from '@/service/console'
+import {
+ appWorkflowQueryOptions,
+ appWorkflowVersionsInfiniteQueryOptions,
+} from '@/service/workflow-queries'
+import {
+ createCatalogModelFixture,
+ createModelCatalogFixture,
+ seedModelProviderQueries,
+} from '@/test/console/model-provider'
+import {
+ createConsoleQueryClient,
+ createConsoleQueryWrapper,
+ seedAppDetail,
+} from '@/test/console/query-data'
+import { createAppDetailFixture } from '@/test/fixtures/app'
+import { createWorkflowResponseFixture } from '@/test/fixtures/workflow-response'
+import { AppACLPermission } from '@/utils/permission'
+import AppDeploy from '..'
+
+vi.mock('@/next/navigation', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('@/next/navigation')>()),
+ useParams: () => ({ appId: 'deploy-audit' }),
+}))
+
+vi.mock('react-i18next', (importOriginal) => importOriginal())
+
+const appId = 'deploy-audit'
+const environment = {
+ id: 'canary',
+ display_name: 'Canary',
+ description: '',
+ status: EnvironmentStatus.ENVIRONMENT_STATUS_READY,
+}
+const deployment: EnvironmentDeployment = {
+ environment,
+ access: { enable_api: true, enable_site: true },
+ deployment: {
+ current_version: { id: 'release-0', marked_name: 'Release 0', version: '1' },
+ runtimeState: RuntimeState.RUNTIME_STATE_RUNNING,
+ versions_behind: 1,
+ },
+}
+const options: GetWorkflowDeploymentOptionsResponse = {
+ credential_slots: [
+ {
+ provider_id: 'deepseek',
+ category: PluginCategory.PLUGIN_CATEGORY_MODEL,
+ workflow_as_tool_dependency: {
+ paths: [
+ {
+ workflows: [
+ {
+ app_id: 'source-workflow',
+ workflow_id: 'source-release',
+ name: 'Customer support workflow',
+ icon_type: 'emoji',
+ icon: '',
+ icon_background: '#FFFFFF',
+ },
+ ],
+ },
+ ],
+ },
+ candidates: ['Production key', 'Development key'].map((name) => ({
+ credential_id: name,
+ display_name: name,
+ provider_id: 'deepseek',
+ category: PluginCategory.PLUGIN_CATEGORY_MODEL,
+ from_enterprise: false,
+ })),
+ },
+ ],
+ environment_variable_groups: [
+ {
+ from_app: {
+ app_id: appId,
+ workflow_id: 'release-1',
+ name: 'Finance app',
+ icon_type: 'emoji',
+ icon: '',
+ icon_background: '#FFFFFF',
+ },
+ environment_variable_slots: [
+ {
+ key: 'PORT',
+ description: 'Server port',
+ value_type: EnvVarValueType.ENV_VAR_VALUE_TYPE_NUMBER,
+ has_configured_value: false,
+ has_last_deployed_value: false,
+ },
+ ],
+ },
+ ],
+}
+
+async function renderDeploy({
+ withLLM = false,
+ environmentDeployments = [deployment],
+}: {
+ withLLM?: boolean
+ environmentDeployments?: EnvironmentDeployment[]
+} = {}) {
+ if (withLLM) await import('@/app/components/workflow/llm-environment-variable-value-field')
+ document.documentElement.lang = 'en'
+ document.title = 'Deploy accessibility audit'
+ const i18n = createInstance()
+ await i18n.init({
+ lng: 'en-US',
+ resources: {
+ 'en-US': {
+ agentV2,
+ appDebug,
+ common,
+ deployments,
+ modelProvider,
+ navigation,
+ plugin,
+ workflow,
+ workflowHistory,
+ },
+ },
+ })
+ const client = createConsoleQueryClient()
+ if (withLLM) {
+ seedModelProviderQueries(client, [
+ createModelCatalogFixture({
+ provider: 'langgenius/openai/openai',
+ models: [
+ createCatalogModelFixture({
+ model: 'chat-model',
+ label: { en_US: 'Chat model' },
+ model_properties: { mode: 'chat' },
+ }),
+ ],
+ }),
+ ])
+ client.setQueryDefaults(
+ consoleQuery.workspaces.current.modelProviders.byProvider.models.parameterRules.get.key(),
+ {
+ initialData: {
+ data: [
+ {
+ name: 'instruction',
+ label: { en_US: 'System instruction' },
+ type: 'text',
+ default: '',
+ required: true,
+ },
+ ],
+ },
+ },
+ )
+ }
+ seedAppDetail(
+ client,
+ createAppDetailFixture({
+ id: appId,
+ mode: 'workflow',
+ maintainer: 'user-2',
+ enable_api: true,
+ enable_site: true,
+ permission_keys: [AppACLPermission.Deploy, AppACLPermission.AccessPointView],
+ }),
+ )
+ const published = createWorkflowResponseFixture({
+ id: 'release-1',
+ marked_name: 'Release 1',
+ marked_comment: 'Latest production workflow',
+ graph: { nodes: [{ id: 'start', data: { type: 'start' } }] },
+ })
+ client.setQueryData(appWorkflowQueryOptions(appId).queryKey, published)
+ client.setQueryData(appWorkflowVersionsInfiniteQueryOptions(appId).queryKey, {
+ pages: [{ items: [published], page: 1, limit: 10, has_more: false }],
+ pageParams: [1],
+ })
+ const params = { app_id: appId }
+ client.setQueryData(consoleQuery.apps.byAppId.server.get.queryKey({ input: { params } }), {
+ id: 'audit-mcp',
+ name: 'MCP',
+ server_code: 'audit',
+ description: '',
+ parameters: {},
+ status: 'inactive',
+ })
+ client.setQueryData(
+ consoleQuery.enterprise.appDeploy.deploymentService.listAppEnvironments.queryKey({
+ input: { params },
+ }),
+ {
+ data: [
+ {
+ ...environment,
+ in_use: environmentDeployments.some((row) => row.environment.id === environment.id),
+ },
+ { ...environment, id: 'dev', display_name: 'Dev', in_use: false },
+ ],
+ },
+ )
+ client.setQueryData(
+ consoleQuery.enterprise.appDeploy.deploymentService.listEnvironmentDeployments.queryKey({
+ input: { params },
+ }),
+ {
+ environment_deployments: environmentDeployments,
+ },
+ )
+ for (const workflowId of ['release-0', published.id]) {
+ client.setQueryData(
+ consoleQuery.enterprise.appDeploy.deploymentService.precheckWorkflowDeployment.queryKey({
+ input: { params: { ...params, workflow_id: workflowId } },
+ }),
+ { unsupported_nodes: [] },
+ )
+ for (const environmentId of ['canary', 'dev']) {
+ client.setQueryData(
+ consoleQuery.enterprise.appDeploy.deploymentService.getWorkflowDeploymentOptions.queryKey({
+ input: { params: { ...params, workflow_id: workflowId, environment_id: environmentId } },
+ }),
+ withLLM
+ ? {
+ ...options,
+ environment_variable_groups: [
+ {
+ ...options.environment_variable_groups[0]!,
+ environment_variable_slots: [
+ {
+ key: 'MODEL',
+ description: 'Chat model used by the workflow',
+ value_type: EnvVarValueType.ENV_VAR_VALUE_TYPE_LLM,
+ has_configured_value: true,
+ has_last_deployed_value: false,
+ configured_value: {
+ provider: 'langgenius/openai/openai',
+ name: 'chat-model',
+ mode: 'chat',
+ completion_params: {},
+ },
+ },
+ ],
+ },
+ ],
+ }
+ : options,
+ )
+ }
+ }
+ const { wrapper: Wrapper } = createConsoleQueryWrapper({ queryClient: client })
+ const screen = await render(
+ <Wrapper>
+ <NuqsTestingAdapter>
+ <I18nextProvider i18n={i18n}>
+ <main aria-label="Deploy" className="isolate h-dvh min-w-0 overflow-hidden">
+ <AppDeploy />
+ </main>
+ </I18nextProvider>
+ </NuqsTestingAdapter>
+ </Wrapper>,
+ )
+ await expect
+ .element(screen.getByRole('region', { name: 'Environments', exact: true }))
+ .toBeVisible()
+ return { ...screen, queryClient: client }
+}
+
+async function checkAccessibility(verifyFocusGuards?: (count: number) => Promise<void>) {
+ await Promise.all(
+ document
+ .getAnimations()
+ .filter(
+ (animation) =>
+ animation.playState === 'running' &&
+ Number.isFinite(animation.effect?.getComputedTiming().endTime),
+ )
+ .map((animation) => animation.finished.catch(() => undefined)),
+ )
+ const tags = ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'wcag22aa']
+ const results = await axe.run(document.body, { runOnly: { type: 'tag', values: tags } })
+ const verifiedNodes = new Set<axe.NodeResult>()
+ if (verifyFocusGuards) {
+ const guardNodes = results.violations
+ .filter(({ id }) => id === 'aria-hidden-focus')
+ .flatMap(({ nodes }) => nodes)
+ .filter(({ target }) => {
+ if (target.length !== 1 || typeof target[0] !== 'string') return false
+ const element = document.querySelector(target[0])
+ return (
+ element?.matches('span[data-base-ui-focus-guard][aria-hidden="true"]') &&
+ !element.childElementCount &&
+ !element.textContent?.trim()
+ )
+ })
+ expect(guardNodes.length).toBeGreaterThan(0)
+ await verifyFocusGuards(guardNodes.length)
+ // W3C ACT 6cfa84, Passed Example 4 permits sentinels that immediately redirect focus:
+ // https://www.w3.org/WAI/standards-guidelines/act/rules/6cfa84/#passed-example-4
+ // Keep every other aria-hidden-focus finding and every other axe rule in the assertion.
+ for (const node of guardNodes) verifiedNodes.add(node)
+ }
+ expect(
+ results.violations
+ .map(({ id, helpUrl, nodes }) => ({
+ id,
+ helpUrl,
+ nodes: nodes
+ .filter((node) => !verifiedNodes.has(node))
+ .map(({ target, failureSummary, html }) => ({ target, failureSummary, html })),
+ }))
+ .filter(({ nodes }) => nodes.length),
+ ).toEqual([])
+}
+
+async function checkMenuAccessibility(openMenu: () => Promise<void>) {
+ await openMenu()
+ await checkAccessibility(async (count) => {
+ for (let index = 0; index < count; index++) {
+ if (index > 0) {
+ await userEvent.keyboard('{Escape}')
+ await openMenu()
+ }
+ const guards = document.querySelectorAll<HTMLElement>(
+ 'span[data-base-ui-focus-guard][aria-hidden="true"]',
+ )
+ expect(guards.length).toBe(count)
+ guards[index]!.focus()
+ // Check after the next paint, before the ACT definition's one-second focusability limit.
+ await new Promise(requestAnimationFrame)
+ expect(document.activeElement?.matches('[data-base-ui-focus-guard]')).toBe(false)
+ expect(document.activeElement).not.toBe(document.body)
+ expect(document.activeElement?.closest('[aria-hidden="true"]')).toBeNull()
+ }
+ })
+ await userEvent.keyboard('{Escape}')
+}
+
+it('verifies every reported menu sentinel redirects focus and allows keyboard exit in both directions', async () => {
+ const screen = await renderDeploy()
+ const trigger = screen.getByRole('button', { name: 'Deploy', exact: true })
+ const openDeployMenu = async () => {
+ trigger.element().focus()
+ await userEvent.keyboard('{Enter}')
+ await expect.element(screen.getByRole('menuitem', { name: 'Dev', exact: true })).toHaveFocus()
+ }
+ await checkMenuAccessibility(openDeployMenu)
+ await openDeployMenu()
+ await userEvent.keyboard('{Shift>}{Tab}{/Shift}')
+ await expect.element(trigger).toHaveFocus()
+ await openDeployMenu()
+ await userEvent.keyboard('{Tab}')
+ await expect.element(screen.getByRole('button', { name: 'Release 0', exact: true })).toHaveFocus()
+
+ const more = screen.getByRole('button', { name: 'Canary · More actions', exact: true })
+ await checkMenuAccessibility(async () => {
+ more.element().focus()
+ await userEvent.keyboard('{Enter}')
+ await expect.element(screen.getByRole('menu')).toBeVisible()
+ })
+})
+
+afterEach(() => {
+ vi.restoreAllMocks()
+})
+
+it('keeps focus through the first lazy menu handoff and resets deployment drafts before a pointer reopen', async () => {
+ const screen = await renderDeploy()
+ await checkAccessibility()
+ const trigger = screen.getByRole('button', { name: 'Deploy', exact: true })
+ trigger.element().focus()
+ await userEvent.keyboard('{Enter}')
+ const dev = screen.getByRole('menuitem', { name: 'Dev', exact: true })
+ await expect.element(dev).toHaveFocus()
+ await userEvent.keyboard('{Tab}')
+ await expect.element(dev).not.toBeInTheDocument()
+ await expect.element(screen.getByRole('button', { name: 'Release 0', exact: true })).toHaveFocus()
+ trigger.element().focus()
+ await userEvent.keyboard('{Enter}')
+ await expect.element(dev).toHaveFocus()
+ await userEvent.keyboard('{Enter}')
+ const versions = screen.getByRole('dialog', { name: 'Deploy to Dev', exact: true })
+ await expect.element(dev).not.toBeInTheDocument()
+ await expect
+ .element(versions.getByRole('heading', { name: 'Deploy to Dev', exact: true }))
+ .toHaveFocus()
+ await checkAccessibility()
+ await versions.getByRole('button', { name: /Release 1/ }).click()
+ const configuration = screen.getByRole('dialog', { name: 'Deploy configuration', exact: true })
+ await expect
+ .element(configuration.getByRole('heading', { name: 'Deploy configuration', exact: true }))
+ .toHaveFocus()
+ await checkAccessibility()
+
+ await configuration.getByRole('button', { name: 'Deploy', exact: true }).click()
+ const credential = configuration.getByRole('combobox', { name: 'Deepseek', exact: true })
+ await expect.element(credential).toHaveFocus()
+ await expect.element(credential).toHaveAttribute('aria-invalid', 'true')
+ await checkAccessibility()
+ await credential.click()
+ await screen.getByRole('option', { name: 'Production key', exact: true }).click()
+ await configuration.getByRole('button', { name: 'Deploy', exact: true }).click()
+ const port = configuration.getByRole('spinbutton', { name: 'PORT', exact: true })
+ await expect.element(port).toHaveFocus()
+ await expect.element(port).toHaveAttribute('aria-invalid', 'true')
+ await checkAccessibility()
+ await port.fill('3000')
+ await userEvent.keyboard('{Escape}')
+ await expect.element(configuration).not.toBeInTheDocument()
+ await expect.element(trigger).toHaveFocus()
+
+ await trigger.click()
+ await dev.click()
+ await expect.element(dev).not.toBeInTheDocument()
+ await expect
+ .element(versions.getByRole('heading', { name: 'Deploy to Dev', exact: true }))
+ .toHaveFocus()
+ await versions.getByRole('button', { name: /Release 1/ }).click()
+ await expect.element(credential).toBeVisible()
+ await expect.element(port).toHaveValue(null)
+ await configuration.getByRole('button', { name: 'Deploy', exact: true }).click()
+ await expect.element(credential).toHaveAttribute('aria-invalid', 'true')
+ await expect.element(credential).toHaveFocus()
+ await configuration.getByRole('button', { name: 'Back', exact: true }).click()
+ await expect
+ .element(versions.getByRole('heading', { name: 'Deploy to Dev', exact: true }))
+ .toHaveFocus()
+ await userEvent.keyboard('{Escape}')
+ await expect.element(versions).not.toBeInTheDocument()
+ await expect.element(trigger).toHaveFocus()
+})
+
+it('uses the requested version and restores surviving triggers as redeploy and undeploy menu items unmount', async () => {
+ const screen = await renderDeploy()
+ const latest = screen.getByRole('button', { name: 'Deploy latest', exact: true })
+ await latest.click()
+ const configuration = screen.getByRole('dialog', { name: 'Deploy configuration', exact: true })
+ await expect.element(configuration.getByText('Release 1', { exact: true })).toBeVisible()
+ await configuration.getByRole('button', { name: 'Cancel', exact: true }).click()
+ await expect.element(configuration).not.toBeInTheDocument()
+ await expect.element(latest).toHaveFocus()
+ const more = screen.getByRole('button', { name: 'Canary · More actions', exact: true })
+ await more.click()
+ const redeploy = screen.getByRole('menuitem', { name: 'Redeploy', exact: true })
+ await redeploy.click()
+ await expect.element(configuration).toBeVisible()
+ await expect.element(configuration.getByText('Release 0', { exact: true })).toBeVisible()
+ await expect.element(redeploy).not.toBeInTheDocument()
+ await expect
+ .element(configuration.getByRole('heading', { name: 'Deploy configuration', exact: true }))
+ .toHaveFocus()
+ await userEvent.keyboard('{Escape}')
+ await expect.element(configuration).not.toBeInTheDocument()
+ await expect.element(more).toHaveFocus()
+ await userEvent.keyboard('{Enter}')
+ await expect
+ .element(screen.getByRole('menuitem', { name: 'Undeploy', exact: true }))
+ .toBeVisible()
+ await userEvent.keyboard('{End}')
+ const undeploy = screen.getByRole('menuitem', { name: 'Undeploy', exact: true })
+ await expect.element(undeploy).toHaveFocus()
+ await userEvent.keyboard(' ')
+ const confirmation = screen.getByRole('alertdialog')
+ await expect.element(confirmation).toBeVisible()
+ await expect.element(undeploy).not.toBeInTheDocument()
+ await checkAccessibility()
+ await confirmation.getByRole('button', { name: 'Cancel', exact: true }).click()
+ await expect.element(confirmation).not.toBeInTheDocument()
+ await expect.element(more).toHaveFocus()
+ await more.click()
+ await undeploy.click()
+ await expect.element(confirmation).toBeVisible()
+ await expect.element(undeploy).not.toBeInTheDocument()
+ await userEvent.keyboard('{Escape}')
+ await expect.element(confirmation).not.toBeInTheDocument()
+ await expect.element(more).toHaveFocus()
+})
+
+it('returns focus to the environment heading after a successful deployment removes the empty-state trigger', async () => {
+ const deployed: EnvironmentDeployment = {
+ ...deployment,
+ environment: { ...environment, id: 'dev', display_name: 'Dev' },
+ }
+ const deployRequests: Request[] = []
+ vi.spyOn(globalThis, 'fetch').mockImplementation(async (input, init) => {
+ const request = input instanceof Request ? input : new Request(input, init)
+ if (request.url.endsWith('/deployment:deploy')) {
+ deployRequests.push(request.clone())
+ return Response.json({
+ operation: {
+ id: 'deploy-dev',
+ status: DeploymentOperationStatus.DEPLOYMENT_OPERATION_STATUS_SUCCEEDED,
+ type: DeploymentOperationType.DEPLOYMENT_OPERATION_TYPE_DEPLOY,
+ },
+ })
+ }
+ if (request.url.endsWith('/environments'))
+ return Response.json({ data: [{ ...deployed.environment, in_use: true }] })
+ if (request.url.endsWith('/workflows/environment-deployments'))
+ return Response.json({ environment_deployments: [deployed] })
+ throw new Error(`Unexpected request: ${request.method} ${request.url}`)
+ })
+ const screen = await renderDeploy({ environmentDeployments: [] })
+ const emptyDeploy = screen.getByRole('button', { name: 'Deploy', exact: true }).nth(1)
+ await emptyDeploy.click()
+ await screen.getByRole('menuitem', { name: 'Dev', exact: true }).click()
+ const versions = screen.getByRole('dialog', { name: 'Deploy to Dev', exact: true })
+ await versions.getByRole('button', { name: /Release 1/ }).click()
+ const configuration = screen.getByRole('dialog', { name: 'Deploy configuration', exact: true })
+ await configuration.getByRole('combobox', { name: 'Deepseek', exact: true }).click()
+ await screen.getByRole('option', { name: 'Production key', exact: true }).click()
+ await configuration.getByRole('spinbutton', { name: 'PORT', exact: true }).fill('3000')
+ await configuration.getByRole('button', { name: 'Deploy', exact: true }).click()
+ await expect.element(configuration).not.toBeInTheDocument()
+ await expect.element(screen.getByRole('rowheader', { name: 'Dev', exact: true })).toBeVisible()
+ await expect
+ .element(screen.getByRole('heading', { name: 'Environments', exact: true }))
+ .toHaveFocus()
+ expect(deployRequests).toHaveLength(1)
+ expect(new URL(deployRequests[0]!.url).pathname).toContain('/environments/dev/deployment:deploy')
+})
+
+it('audits the LLM model picker and settings reachable from deploy without mounting workflow editors or media', async () => {
+ const screen = await renderDeploy({ withLLM: true })
+ await screen.getByRole('button', { name: 'Deploy', exact: true }).click()
+ await screen.getByRole('menuitem', { name: 'Dev', exact: true }).click()
+ const versions = screen.getByRole('dialog', { name: 'Deploy to Dev', exact: true })
+ await expect
+ .element(versions.getByRole('heading', { name: 'Deploy to Dev', exact: true }))
+ .toHaveFocus()
+ await versions.getByRole('button', { name: /Release 1/ }).click()
+ const configuration = screen.getByRole('dialog', { name: 'Deploy configuration', exact: true })
+ await expect.element(configuration.getByRole('button', { name: /^Chat model/ })).toBeDisabled()
+ await configuration.getByRole('combobox', { name: /MODEL/ }).click()
+ await screen.getByRole('option', { name: 'Custom value', exact: true }).click()
+ await configuration.getByRole('button', { name: 'Configure model', exact: true }).click()
+ const modelPicker = screen.getByRole('dialog', { name: 'Configure model', exact: true })
+ await expect
+ .element(modelPicker.getByRole('button', { name: 'Chat model', exact: true }))
+ .toBeVisible()
+ await checkAccessibility()
+ await modelPicker.getByRole('button', { name: 'Chat model', exact: true }).click()
+ await configuration.getByRole('button', { name: 'Model Settings', exact: true }).click()
+ const settings = screen.getByRole('dialog', { name: 'Model Settings', exact: true })
+ await expect
+ .element(settings.getByRole('textbox', { name: 'System instruction', exact: true }))
+ .toBeVisible()
+ await checkAccessibility()
+ expect(document.querySelector('audio, video, [contenteditable="true"]')).toBeNull()
+ await userEvent.keyboard('{Escape}')
+ await expect.element(settings).not.toBeInTheDocument()
+ await expect
+ .element(configuration.getByRole('button', { name: 'Model Settings', exact: true }))
+ .toHaveFocus()
+})
+
+it('opens the workflow source disclosure from the keyboard and restores focus within configuration', async () => {
+ const screen = await renderDeploy()
+ await screen.getByRole('button', { name: 'Deploy', exact: true }).click()
+ await screen.getByRole('menuitem', { name: 'Dev', exact: true }).click()
+ const versions = screen.getByRole('dialog', { name: 'Deploy to Dev', exact: true })
+ await expect
+ .element(versions.getByRole('heading', { name: 'Deploy to Dev', exact: true }))
+ .toHaveFocus()
+ await versions.getByRole('button', { name: /Release 1/ }).click()
+ const configuration = screen.getByRole('dialog', { name: 'Deploy configuration', exact: true })
+ const source = configuration.getByRole('button', { name: /Deepseek.*Customer support workflow/ })
+ await expect.element(source).toBeVisible()
+ source.element().focus()
+ await userEvent.keyboard('{Enter}')
+ const disclosure = screen.getByRole('dialog', { name: 'Deepseek', exact: true })
+ await expect
+ .element(disclosure.getByRole('link', { name: 'Customer support workflow', exact: true }))
+ .toHaveAttribute('href', '/app/source-workflow/workflow')
+ await checkAccessibility()
+ await userEvent.keyboard('{Escape}')
+ await expect.element(disclosure).not.toBeInTheDocument()
+ await expect.element(source).toHaveFocus()
+ await expect.element(configuration).toBeVisible()
+})
+
+it('reflows the built-in card at 320px and keeps table actions reachable in a short viewport', async () => {
+ await page.viewport(320, 256)
+ const screen = await renderDeploy()
+ const main = screen.getByRole('main', { name: 'Deploy', exact: true })
+ const builtIn = screen.getByRole('region', { name: 'Built-in Environment', exact: true })
+ await expect.element(builtIn).toBeVisible()
+ expect(main.element().scrollWidth).toBeLessThanOrEqual(320)
+ const more = screen.getByRole('button', { name: 'Canary · More actions', exact: true })
+ more.element().focus()
+ await expect.element(more).toHaveFocus()
+ const bounds = more.element().getBoundingClientRect()
+ expect(bounds.left).toBeGreaterThanOrEqual(0)
+ expect(bounds.right).toBeLessThanOrEqual(320)
+ expect(bounds.top).toBeGreaterThanOrEqual(0)
+ expect(bounds.bottom).toBeLessThanOrEqual(256)
+ await userEvent.keyboard('{Enter}')
+ await expect
+ .element(screen.getByRole('menuitem', { name: 'Redeploy', exact: true }))
+ .toBeVisible()
+ await screen.getByRole('menuitem', { name: 'Redeploy', exact: true }).click()
+ const configuration = screen.getByRole('dialog', { name: 'Deploy configuration', exact: true })
+ const cancel = configuration.getByRole('button', { name: 'Cancel', exact: true })
+ await expect.element(cancel).toBeVisible()
+ cancel.element().focus()
+ await expect.element(cancel).toHaveFocus()
+ const cancelBounds = cancel.element().getBoundingClientRect()
+ expect(cancelBounds.left).toBeGreaterThanOrEqual(0)
+ expect(cancelBounds.right).toBeLessThanOrEqual(320)
+ expect(cancelBounds.top).toBeGreaterThanOrEqual(0)
+ expect(cancelBounds.bottom).toBeLessThanOrEqual(256)
+ await userEvent.keyboard('{Enter}')
+ await expect.element(configuration).not.toBeInTheDocument()
+ await expect.element(more).toHaveFocus()
+})
+
+it('keeps focused configuration fields and actions fully visible in a short viewport', async () => {
+ await page.viewport(320, 240)
+ const screen = await renderDeploy()
+ await screen.getByRole('button', { name: 'Deploy latest', exact: true }).click()
+ const configuration = screen.getByRole('dialog', { name: 'Deploy configuration', exact: true })
+ await expect
+ .element(configuration.getByRole('heading', { name: 'Deploy configuration', exact: true }))
+ .toHaveFocus()
+
+ const controls = [
+ configuration.getByRole('button', { name: /Deepseek.*Customer support workflow/ }),
+ configuration.getByRole('combobox', { name: 'Deepseek', exact: true }),
+ configuration.getByRole('combobox', { name: /PORT/ }),
+ configuration.getByRole('spinbutton', { name: 'PORT', exact: true }),
+ configuration.getByRole('button', { name: 'Cancel', exact: true }),
+ ]
+
+ for (const control of controls) {
+ await userEvent.keyboard('{Tab}')
+ await expect.element(control).toHaveFocus()
+ const element = control.element()
+ const bounds = element.getBoundingClientRect()
+ let visibleTop = 0
+ let visibleBottom = window.innerHeight
+
+ // A focusable field can pass visibility checks while its scroll area clips the whole field.
+ for (let parent = element.parentElement; parent; parent = parent.parentElement) {
+ if (!['auto', 'hidden', 'scroll', 'clip'].includes(getComputedStyle(parent).overflowY))
+ continue
+ const parentBounds = parent.getBoundingClientRect()
+ visibleTop = Math.max(visibleTop, parentBounds.top + parent.clientTop)
+ visibleBottom = Math.min(
+ visibleBottom,
+ parentBounds.top + parent.clientTop + parent.clientHeight,
+ )
+ }
+
+ expect(bounds.height).toBeGreaterThan(0)
+ expect(bounds.left).toBeGreaterThanOrEqual(0)
+ expect(bounds.right).toBeLessThanOrEqual(window.innerWidth)
+ expect(bounds.top).toBeGreaterThanOrEqual(visibleTop)
+ expect(bounds.bottom).toBeLessThanOrEqual(visibleBottom)
+ }
+})
+
+it('keeps deployment status and version text readable in dark mode', async () => {
+ document.documentElement.dataset.theme = 'dark'
+ try {
+ await renderDeploy()
+ await checkAccessibility()
+ } finally {
+ document.documentElement.dataset.theme = 'light'
+ }
+})
diff --git a/web/app/components/app/deploy/__tests__/index.spec.tsx b/web/app/components/app/deploy/__tests__/index.spec.tsx
index 41ea78e11b2..41ad0497a2f 100644
--- a/web/app/components/app/deploy/__tests__/index.spec.tsx
+++ b/web/app/components/app/deploy/__tests__/index.spec.tsx
@@ -791,10 +791,6 @@ function environmentTableProps(
return {
appId: APP_ID,
canViewAccessPoint: true,
- onChangeVersion: vi.fn(),
- onDeployLatest: vi.fn(),
- onDeployToEnvironment: vi.fn(),
- onRedeploy: vi.fn(),
onUndeploy: vi.fn(),
...overrides,
}
@@ -825,6 +821,8 @@ vi.mock('react-i18next', async () => {
'deployments.status.RUNTIME_INSTANCE_STATUS_UNDEPLOYED': 'Not deployed',
'deployments.status.RUNTIME_INSTANCE_STATUS_UNDEPLOYING': 'Undeploying',
'deployments.status.RUNTIME_INSTANCE_STATUS_UNSPECIFIED': 'Unknown',
+ 'deployments.studio.activity.deploy': 'Deploy {{target}}',
+ 'deployments.studio.activity.deployFailed': 'Deploy {{target}} failed',
'deployments.studio.activity.deploySucceeded': 'Deploy {{target}} succeeded',
'deployments.studio.activity.meta': '{{name}} · {{time}}',
'deployments.studio.versionValue': 'Version value',
@@ -905,6 +903,97 @@ describe('AppDeploy', () => {
)
})
+ it('names the deployment table and identifies each environment as its row header', () => {
+ render(<AppDeploy />)
+
+ const table = within(screen.getByRole('table', { name: 'deployments.studio.environments' }))
+ expect(table.getByRole('rowheader', { name: 'Canary' })).toHaveAttribute('scope', 'row')
+ for (const header of table.getAllByRole('columnheader'))
+ expect(header).toHaveAttribute('scope', 'col')
+ })
+
+ it('keeps the environment name in the live status when deployment state changes', async () => {
+ const view = render(<AppDeploy />, {
+ environmentDeployments: [
+ environmentDeployment({
+ id: 'canary',
+ name: 'Canary',
+ runtimeState: RuntimeState.RUNTIME_STATE_RUNNING,
+ }),
+ ],
+ })
+ const status = within(screen.getByRole('row', { name: /Canary/ }))
+ .getAllByRole('status')
+ .find((region) => within(region).queryByText('Running'))
+ expect(status).toHaveTextContent('Canary: Running')
+ expect(status).toHaveAttribute('aria-atomic', 'true')
+
+ act(() => {
+ view.queryClient.setQueryData(appEnvironmentDeploymentsQueryOptions.queryKey, {
+ environment_deployments: [
+ environmentDeployment({
+ id: 'canary',
+ name: 'Canary',
+ runtimeState: RuntimeState.RUNTIME_STATE_ERROR,
+ }),
+ ],
+ })
+ })
+
+ await waitFor(() => expect(status).toHaveTextContent('Canary: Invalid'))
+ })
+
+ it('announces a failed deployment while the previous version stays running', async () => {
+ const row = environmentDeployment({
+ currentVersion: VERSIONS.beta,
+ id: 'canary',
+ latestOperation: deploymentOperation({
+ id: 'upgrade-canary',
+ status: DeploymentOperationStatus.DEPLOYMENT_OPERATION_STATUS_IN_PROGRESS,
+ targetVersion: VERSIONS.sprint42,
+ }),
+ name: 'Canary',
+ runtimeState: RuntimeState.RUNTIME_STATE_RUNNING,
+ })
+ const view = render(
+ <AppDeployStateBoundary appId={APP_ID}>
+ <EnvironmentTable {...environmentTableProps()} />
+ </AppDeployStateBoundary>,
+ { environmentDeployments: [row] },
+ )
+ const canary = within(screen.getByRole('row', { name: /Canary/ }))
+ const runtimeStatus = canary
+ .getAllByRole('status')
+ .find((region) => within(region).queryByText('Running'))
+ const activityStatus = canary
+ .getAllByRole('status')
+ .find((region) => within(region).queryByText('Deploy Sprint-42'))
+ expect(activityStatus).toHaveTextContent('Canary: Deploy Sprint-42')
+
+ act(() => {
+ view.queryClient.setQueryData(appEnvironmentDeploymentsQueryOptions.queryKey, {
+ environment_deployments: [
+ {
+ ...row,
+ deployment: {
+ ...row.deployment,
+ runtimeState: RuntimeState.RUNTIME_STATE_RUNNING,
+ latest_operation: deploymentOperation({
+ id: 'upgrade-canary',
+ status: DeploymentOperationStatus.DEPLOYMENT_OPERATION_STATUS_FAILED,
+ targetVersion: VERSIONS.sprint42,
+ }),
+ },
+ },
+ ],
+ })
+ })
+
+ await waitFor(() => expect(activityStatus).toHaveTextContent('Canary: Deploy Sprint-42 failed'))
+ expect(runtimeStatus).toHaveTextContent('Canary: Running')
+ expect(activityStatus).not.toHaveTextContent('activity time')
+ })
+
it.each(ACTION_MATRIX_CASES)(
'provides the designed row actions when $name',
({ actions, row }) => {
@@ -972,7 +1061,8 @@ describe('AppDeploy', () => {
name: 'deployments.studio.deployLatest',
})
expect(deployLatestButtons.length).toBeGreaterThan(0)
- for (const button of deployLatestButtons) expect(button).toBeDisabled()
+ for (const button of deployLatestButtons)
+ expect(button).toHaveAttribute('aria-disabled', 'true')
await user.click(within(alert).getByRole('button', { name: 'common.operation.retry' }))
@@ -988,7 +1078,7 @@ describe('AppDeploy', () => {
})
expect(
stagingRow.getByRole('button', { name: 'deployments.studio.deployLatest' }),
- ).toBeDisabled()
+ ).toHaveAttribute('aria-disabled', 'true')
expect(requestCount).toBe(2)
})
@@ -1143,7 +1233,7 @@ describe('AppDeploy', () => {
await user.click(screen.getByRole('button', { name: 'common.appMenus.deploy' }))
- expect(screen.getByRole('status')).toHaveTextContent(
+ expect(within(screen.getByRole('menu')).getByRole('status')).toHaveTextContent(
'deployments.deployDrawer.noNewEnvironmentAvailable',
)
expect(screen.queryByRole('menuitem')).not.toBeInTheDocument()
@@ -1276,6 +1366,7 @@ describe('AppDeploy', () => {
const portSource = rootVariables.getByRole('combobox', { name: /PORT/ })
expect(portSource).toHaveTextContent('Version value')
const portInput = rootVariables.getByRole('textbox', { name: 'PORT' })
+ expect(portInput).toHaveAccessibleDescription('Server port')
expect(portInput).toBeDisabled()
expect(portInput).toHaveAttribute('placeholder', '2')
expect(rootVariables.getByRole('textbox', { name: 'API_KEY' })).toHaveAttribute(
@@ -1405,9 +1496,17 @@ describe('AppDeploy', () => {
within(configurationDialog).getByRole('button', { name: 'common.appMenus.deploy' }),
)
expect(deploymentRequests).toHaveLength(0)
- expect(toast.error).toHaveBeenCalledWith('Finance APP · PORT: workflow.env.modal.valueRequired')
+ expect(customPortInput).toHaveAttribute('aria-invalid', 'true')
+ expect(customPortInput).toHaveAccessibleDescription(
+ 'Server port workflow.env.modal.valueRequired',
+ )
+ expect(customPortInput).toHaveFocus()
+ expect(
+ within(rootVariables.getByRole('group', { name: 'PORT' })).getByRole('alert'),
+ ).toHaveTextContent('workflow.env.modal.valueRequired')
await user.type(customPortInput, '3000')
+ expect(customPortInput).not.toHaveAttribute('aria-invalid', 'true')
await user.click(
within(configurationDialog).getByRole('button', { name: 'common.appMenus.deploy' }),
)
@@ -1421,7 +1520,7 @@ describe('AppDeploy', () => {
})
})
- it('shows a toast instead of submitting when a credential is missing', async () => {
+ it('identifies and focuses a missing credential instead of submitting', async () => {
const user = userEvent.setup()
const deploymentRequests: Request[] = []
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input, init) => {
@@ -1472,7 +1571,10 @@ describe('AppDeploy', () => {
await user.click(deployButton)
expect(deploymentRequests).toHaveLength(0)
- expect(toast.error).toHaveBeenCalledWith('Moonshot: deployments.deployDrawer.selectCredential')
+ const credential = within(configurationDialog).getByRole('combobox', { name: 'Moonshot' })
+ expect(credential).toHaveAttribute('aria-invalid', 'true')
+ expect(credential).toHaveAccessibleDescription('deployments.deployDrawer.selectCredential')
+ expect(credential).toHaveFocus()
})
it('deploys the selected workflow configuration and refreshes the deployment list', async () => {
@@ -1929,6 +2031,87 @@ describe('AppDeploy', () => {
).toBeInTheDocument()
})
+ it('preserves the deployment session when published and deployed versions refresh', async () => {
+ const user = userEvent.setup()
+ const requests: Request[] = []
+ vi.spyOn(globalThis, 'fetch').mockImplementation(async (input, init) => {
+ const request = input instanceof Request ? input : new Request(input, init)
+ if (!request.url.endsWith('/deployment:deploy'))
+ throw new Error(`Unexpected request: ${request.method} ${request.url}`)
+ requests.push(request.clone())
+ return Response.json({ message: 'Deployment failed' }, { status: 502 })
+ })
+ const row = environmentDeployment({
+ currentVersion: VERSIONS.version02,
+ id: 'pre-release',
+ name: 'Pre-release',
+ runtimeState: RuntimeState.RUNTIME_STATE_RUNNING,
+ versionsBehind: 1,
+ })
+ const view = render(<AppDeploy />, { environmentDeployments: [row] })
+ const environmentRow = screen.getByRole('row', { name: /Pre-release/ })
+ const builtIn = screen.getByRole('region', { name: 'deployments.studio.builtInTitle' })
+ await user.click(
+ within(environmentRow).getByRole('button', { name: 'deployments.studio.deployLatest' }),
+ )
+ const dialog = await screen.findByRole('dialog', {
+ name: 'deployments.studio.deployConfiguration',
+ })
+ const configuration = within(dialog)
+ await user.click(configuration.getByRole('combobox', { name: 'Moonshot' }))
+ await user.click(await screen.findByRole('option', { name: 'Development key' }))
+ const variables = within(configuration.getByRole('group', { name: 'Finance APP' }))
+ await user.click(variables.getByRole('combobox', { name: /PORT/ }))
+ await user.click(
+ await screen.findByRole('option', {
+ name: 'deployments.deployDrawer.envVarSource.literal',
+ }),
+ )
+ const port = variables.getByRole('spinbutton', { name: 'PORT' })
+ await user.type(port, '3000')
+
+ act(() => {
+ view.queryClient.setQueryData(appEnvironmentDeploymentsQueryOptions.queryKey, {
+ environment_deployments: [
+ environmentDeployment({
+ currentVersion: workflowVersion('Release 7', 'workflow-version-7'),
+ id: 'pre-release',
+ name: 'Pre-release',
+ runtimeState: RuntimeState.RUNTIME_STATE_RUNNING,
+ versionsBehind: 0,
+ }),
+ ],
+ })
+ view.queryClient.setQueryData(latestPublishedWorkflowQuery.queryKey, {
+ ...mockBuiltInEnvironment.publishedWorkflow,
+ id: 'workflow-version-8',
+ marked_name: 'Release 8',
+ })
+ })
+ await waitFor(() => {
+ expect(environmentRow).toHaveTextContent('deployments.studio.changeVersion')
+ expect(builtIn).toHaveTextContent('Release 8')
+ })
+ expect(dialog).toBeInTheDocument()
+ expect(configuration.getByText('Release 7')).toBeInTheDocument()
+ expect(configuration.getByRole('combobox', { name: 'Moonshot' })).toHaveTextContent(
+ 'Development key',
+ )
+ expect(variables.getByRole('spinbutton', { name: 'PORT' })).toHaveValue(3000)
+ expect(port).toHaveFocus()
+ await user.click(configuration.getByRole('button', { name: 'common.appMenus.deploy' }))
+ await waitFor(() => expect(requests).toHaveLength(1))
+ expect(new URL(requests[0]!.url).pathname).toContain(
+ '/workflows/workflow-version-7/environments/pre-release/deployment:deploy',
+ )
+ const body = await requests[0]!.json()
+ expect(body.environment_variable_groups[0].environment_variables).toContainEqual({
+ key: 'PORT',
+ value: 3000,
+ value_source: EnvVarValueSource.ENV_VAR_VALUE_SOURCE_CUSTOM,
+ })
+ })
+
it('keeps deployment configuration and entered values open after an outside press', async () => {
const user = userEvent.setup()
render(<AppDeploy />)
@@ -2065,80 +2248,91 @@ describe('AppDeploy', () => {
expect(screen.getByRole('menuitem', { name: /Testing/ })).toBeInTheDocument()
})
- it('shows loading and retries after the environment deployment list fails', async () => {
- const user = userEvent.setup()
- const deploymentRequests: Request[] = []
- let resolveInitialRequest: ((response: Response) => void) | undefined
- vi.spyOn(globalThis, 'fetch').mockImplementation((input, init) => {
- const request = input instanceof Request ? input : new Request(input, init)
- if (
- !new URL(request.url).pathname.endsWith(
- '/enterprise/app-deploy/apps/app-1/workflows/environment-deployments',
+ it.each(['HTTP', 'network'] as const)(
+ 'announces an environment deployment list %s failure and recovers after retry',
+ async (failure) => {
+ const user = userEvent.setup()
+ const deploymentRequests: Request[] = []
+ let failInitialRequest: (() => void) | undefined
+ vi.spyOn(globalThis, 'fetch').mockImplementation((input, init) => {
+ const request = input instanceof Request ? input : new Request(input, init)
+ if (
+ !new URL(request.url).pathname.endsWith(
+ '/enterprise/app-deploy/apps/app-1/workflows/environment-deployments',
+ )
+ )
+ throw new Error(`Unexpected request: ${request.method} ${request.url}`)
+
+ deploymentRequests.push(request.clone())
+ if (deploymentRequests.length === 1) {
+ return new Promise((resolve, reject) => {
+ failInitialRequest = () => {
+ if (failure === 'network') {
+ reject(new TypeError('Failed to fetch'))
+ return
+ }
+ resolve(
+ new Response(JSON.stringify({ message: 'Failed to load deployments' }), {
+ headers: { 'Content-Type': 'application/json' },
+ status: 500,
+ }),
+ )
+ }
+ })
+ }
+
+ return Promise.resolve(
+ new Response(
+ JSON.stringify({
+ environment_deployments: APP_ENVIRONMENT_DEPLOYMENTS,
+ }),
+ {
+ headers: { 'Content-Type': 'application/json' },
+ status: 200,
+ },
+ ),
)
+ })
+ const queryClient = createConsoleQueryClient()
+ queryClient.setQueryData(appEnvironmentsQueryOptions.queryKey, {
+ data: APP_ENVIRONMENTS,
+ })
+ queryClient.setQueryData(
+ latestPublishedWorkflowQuery.queryKey,
+ mockBuiltInEnvironment.publishedWorkflow,
)
- throw new Error(`Unexpected request: ${request.method} ${request.url}`)
-
- deploymentRequests.push(request.clone())
- if (deploymentRequests.length === 1) {
- return new Promise((resolve) => {
- resolveInitialRequest = resolve
- })
- }
- return Promise.resolve(
- new Response(
- JSON.stringify({
- environment_deployments: APP_ENVIRONMENT_DEPLOYMENTS,
- }),
- {
- headers: { 'Content-Type': 'application/json' },
- status: 200,
- },
- ),
+ renderWithConsoleQuery(
+ <AppDeployStateBoundary appId={APP_ID}>
+ <EnvironmentTable {...environmentTableProps()} />
+ </AppDeployStateBoundary>,
+ { queryClient },
)
- })
- const queryClient = createConsoleQueryClient()
- queryClient.setQueryData(appEnvironmentsQueryOptions.queryKey, {
- data: APP_ENVIRONMENTS,
- })
- queryClient.setQueryData(
- latestPublishedWorkflowQuery.queryKey,
- mockBuiltInEnvironment.publishedWorkflow,
- )
- renderWithConsoleQuery(
- <AppDeployStateBoundary appId={APP_ID}>
- <EnvironmentTable {...environmentTableProps()} />
- </AppDeployStateBoundary>,
- { queryClient },
- )
+ expect(screen.getByRole('progressbar', { name: /loading/ })).toBeInTheDocument()
+ expect(screen.queryByRole('table')).not.toBeInTheDocument()
+ await waitFor(() => {
+ expect(deploymentRequests).toHaveLength(1)
+ })
- expect(screen.getByRole('progressbar', { name: /loading/ })).toBeInTheDocument()
- expect(screen.queryByRole('table')).not.toBeInTheDocument()
- await waitFor(() => {
- expect(deploymentRequests).toHaveLength(1)
- })
+ failInitialRequest?.()
- resolveInitialRequest?.(
- new Response(JSON.stringify({ message: 'Failed to load deployments' }), {
- headers: { 'Content-Type': 'application/json' },
- status: 500,
- }),
- )
-
- const retryButton = await screen.findByRole('button', {
- name: 'common.operation.retry',
- })
- expect(screen.getByRole('heading', { name: 'common.errorBoundary.title' })).toBeInTheDocument()
- expect(screen.getByText('deployments.common.loadFailed')).toBeInTheDocument()
- expect(screen.queryByText('deployments.list.emptyTitle')).not.toBeInTheDocument()
- expect(screen.queryByRole('table')).not.toBeInTheDocument()
+ const alert = await screen.findByRole('alert')
+ expect(alert).toHaveTextContent('common.errorBoundary.title')
+ expect(alert).toHaveTextContent('deployments.common.loadFailed')
+ const retryButton = screen.getByRole('button', {
+ name: 'common.operation.retry',
+ })
+ expect(screen.queryByText('deployments.list.emptyTitle')).not.toBeInTheDocument()
+ expect(screen.queryByRole('table')).not.toBeInTheDocument()
- await user.click(retryButton)
+ await user.click(retryButton)
- expect(await screen.findByRole('cell', { name: /Staging/ })).toBeInTheDocument()
- expect(deploymentRequests).toHaveLength(2)
- })
+ expect(await screen.findByRole('rowheader', { name: /Staging/ })).toBeInTheDocument()
+ expect(screen.queryByRole('alert')).not.toBeInTheDocument()
+ expect(deploymentRequests).toHaveLength(2)
+ },
+ )
it('exposes only the first action and moves every remaining action into More', async () => {
const user = userEvent.setup()
@@ -2185,7 +2379,7 @@ describe('AppDeploy', () => {
stagingRow.getByRole('button', {
name: 'deployments.studio.deployLatest',
}),
- ).toBeDisabled()
+ ).toHaveAttribute('aria-disabled', 'true')
await user.click(
stagingRow.getByRole('button', {
@@ -2235,6 +2429,49 @@ describe('AppDeploy', () => {
expect(onUndeploy).not.toHaveBeenCalled()
})
+ it('keeps undeploy confirmation open while pending and allows retry after failure', async () => {
+ const user = userEvent.setup()
+ let rejectUndeploy: ((error: Error) => void) | undefined
+ const onUndeploy = vi
+ .fn<(deployment: EnvironmentDeployment) => Promise<void>>()
+ .mockImplementationOnce(
+ () =>
+ new Promise<void>((_resolve, reject) => {
+ rejectUndeploy = reject
+ }),
+ )
+ .mockResolvedValueOnce(undefined)
+ render(
+ <AppDeployStateBoundary appId={APP_ID}>
+ <EnvironmentTable {...environmentTableProps({ onUndeploy })} />
+ </AppDeployStateBoundary>,
+ )
+
+ await user.click(
+ screen.getByRole('button', {
+ name: 'Canary · deployments.deployTab.moreActions',
+ }),
+ )
+ await user.click(screen.getByRole('menuitem', { name: 'deployments.deployTab.undeploy' }))
+ const dialog = await screen.findByRole('alertdialog', {
+ name: 'Undeploy Sprint-42 from Canary',
+ })
+ const confirm = within(dialog).getByRole('button', { name: 'Undeploy' })
+ const cancel = within(dialog).getByRole('button', { name: 'Cancel' })
+ await user.click(confirm)
+ expect(onUndeploy).toHaveBeenCalledWith(APP_ENVIRONMENT_DEPLOYMENTS[1])
+ expect(cancel).toBeDisabled()
+ await user.keyboard('{Escape}')
+ expect(dialog).toBeInTheDocument()
+
+ await act(async () => rejectUndeploy?.(new Error('Undeploy failed')))
+ await waitFor(() => expect(cancel).toBeEnabled())
+ expect(dialog).toBeInTheDocument()
+ await user.click(confirm)
+ await waitFor(() => expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument())
+ expect(onUndeploy).toHaveBeenCalledTimes(2)
+ })
+
it('shows the version description from the deployment contract on hover', async () => {
const user = userEvent.setup()
render(<AppDeploy />)
diff --git a/web/app/components/app/deploy/built-in-environment-card/index.tsx b/web/app/components/app/deploy/built-in-environment-card/index.tsx
index ca83bbecce1..1bc0ddc1e9c 100644
--- a/web/app/components/app/deploy/built-in-environment-card/index.tsx
+++ b/web/app/components/app/deploy/built-in-environment-card/index.tsx
@@ -17,7 +17,9 @@ import { VersionLabel } from '../shared/version-label'
import { ACCESS_POINT_ORDER, getAccessPointHref } from '../utils/access-point'
function Divider() {
- return <div className="i-custom-vender-deploy-line-5 h-10 w-3" />
+ return (
+ <div aria-hidden className="i-custom-vender-deploy-line-5 hidden h-10 w-3 shrink-0 lg:block" />
+ )
}
export const BuiltInEnvironmentCard = memo(
@@ -71,17 +73,17 @@ export const BuiltInEnvironmentCard = memo(
<span aria-hidden className="i-ri-instance-line size-5 text-text-secondary" />
</div>
{/* Info */}
- <div className="flex items-center gap-10">
- <div className="flex flex-col gap-1">
+ <div className="flex flex-wrap items-center gap-x-10 gap-y-4">
+ <div className="flex min-w-0 flex-col gap-1">
<h2 id="built-in-environment-title" className="system-md-semibold text-text-primary">
{t(($) => $['studio.builtInTitle'])}
</h2>
- <p className="truncate system-xs-regular text-text-tertiary">
+ <p className="system-xs-regular wrap-break-word text-text-tertiary">
{t(($) => $['studio.builtInDescription'])}
</p>
</div>
<Divider />
- <div className="flex flex-col gap-1">
+ <div className="flex min-w-0 flex-col gap-1">
<div className="system-2xs-medium-uppercase text-text-tertiary">
{t(($) => $['studio.liveVersion'])}
</div>
@@ -110,9 +112,9 @@ export const BuiltInEnvironmentCard = memo(
</div>
</div>
{/* Status and updated time */}
- <div className="flex items-center justify-between gap-4 px-4 py-2.5">
+ <div className="flex flex-wrap items-center justify-between gap-x-4 gap-y-2 px-4 py-2.5">
<RuntimeStateIndicator runtimeState={RuntimeState.RUNTIME_STATE_RUNNING} />
- <p className="truncate system-xs-regular text-text-tertiary">
+ <p className="system-xs-regular wrap-break-word text-text-tertiary">
{publishedWorkflow
? t(($) => $['studio.updatedAtBy'], {
name: updatedBy,
diff --git a/web/app/components/app/deploy/deployment-dialog/index.tsx b/web/app/components/app/deploy/deployment-dialog/index.tsx
index 771fa2f71db..adb613b3ddd 100644
--- a/web/app/components/app/deploy/deployment-dialog/index.tsx
+++ b/web/app/components/app/deploy/deployment-dialog/index.tsx
@@ -1,41 +1,49 @@
'use client'
+import type { DialogContentProps } from '@langgenius/dify-ui/dialog'
+import type { RefObject } from 'react'
import type { DeploymentDialogRequest } from '../types'
import type { DeploymentVersion } from '../utils/version'
import { cn } from '@langgenius/dify-ui/cn'
-import { Dialog, DialogContent } from '@langgenius/dify-ui/dialog'
-import { useState } from 'react'
+import { DialogContent } from '@langgenius/dify-ui/dialog'
+import { useLayoutEffect, useRef, useState } from 'react'
import { DeploymentConfiguration } from '../shared/deployment-configuration'
import { VersionSelection } from '../shared/version-selection'
-type DeploymentDialogProps = {
+type DeploymentDialogContentProps = {
appId: string
- request?: DeploymentDialogRequest
+ request: DeploymentDialogRequest
onClose: () => void
-}
+} & Pick<DialogContentProps, 'finalFocus'>
function DeploymentDialogSession({
appId,
request,
+ titleRef,
onClose,
-}: {
- appId: string
- request: DeploymentDialogRequest
- onClose: () => void
+}: Omit<DeploymentDialogContentProps, 'finalFocus'> & {
+ titleRef: RefObject<HTMLHeadingElement | null>
}) {
const [selectedVersion, setSelectedVersion] = useState<DeploymentVersion | undefined>(() =>
'initialVersion' in request ? request.initialVersion : undefined,
)
+ const previousVersionRef = useRef(selectedVersion)
+ useLayoutEffect(() => {
+ // DialogContent owns opening focus; only move it when the wizard changes steps.
+ if (previousVersionRef.current !== selectedVersion) titleRef.current?.focus()
+ previousVersionRef.current = selectedVersion
+ }, [selectedVersion, titleRef])
return (
- <DialogContent
+ <div
className={cn(
- 'max-h-[min(44rem,calc(100dvh-32px))] overflow-hidden',
- !selectedVersion && 'h-[min(44rem,calc(100dvh-32px))]',
+ 'flex flex-col',
+ selectedVersion ? 'shrink-0' : 'h-[min(44rem,calc(100dvh-32px))] min-h-0 flex-1',
)}
>
{selectedVersion ? (
<DeploymentConfiguration
+ titleRef={titleRef}
appId={appId}
key={selectedVersion.id}
request={request}
@@ -44,29 +52,30 @@ function DeploymentDialogSession({
onClose={onClose}
/>
) : (
- <VersionSelection appId={appId} request={request} onSelect={setSelectedVersion} />
+ <VersionSelection
+ titleRef={titleRef}
+ appId={appId}
+ request={request}
+ onSelect={setSelectedVersion}
+ />
)}
- </DialogContent>
+ </div>
)
}
-export function DeploymentDialog({ appId, request, onClose }: DeploymentDialogProps) {
+export function DeploymentDialogContent({
+ finalFocus,
+ ...sessionProps
+}: DeploymentDialogContentProps) {
+ const titleRef = useRef<HTMLHeadingElement | null>(null)
+
return (
- <Dialog
- open={Boolean(request)}
- disablePointerDismissal
- onOpenChange={(open) => !open && onClose()}
+ <DialogContent
+ initialFocus={titleRef}
+ finalFocus={finalFocus}
+ className="max-h-[min(44rem,calc(100dvh-32px))]"
>
- {request && (
- <DeploymentDialogSession
- appId={appId}
- key={`${request.kind}-${request.environmentId}-${request.currentVersionId ?? 'none'}-${
- 'initialVersion' in request ? request.initialVersion.name : 'none'
- }`}
- request={request}
- onClose={onClose}
- />
- )}
- </Dialog>
+ <DeploymentDialogSession {...sessionProps} titleRef={titleRef} />
+ </DialogContent>
)
}
diff --git a/web/app/components/app/deploy/environment-table/__tests__/activity-cell.spec.tsx b/web/app/components/app/deploy/environment-table/__tests__/activity-cell.spec.tsx
new file mode 100644
index 00000000000..fefb9d2e098
--- /dev/null
+++ b/web/app/components/app/deploy/environment-table/__tests__/activity-cell.spec.tsx
@@ -0,0 +1,110 @@
+import type { EnvironmentDeploymentOperation } from '@dify/contracts/enterprise-app-deploy/types.gen'
+import {
+ DeploymentOperationStatus,
+ DeploymentOperationType,
+ OperatorType,
+} from '@dify/contracts/enterprise-app-deploy/types.gen'
+import { render, screen } from '@testing-library/react'
+import { ActivityCell } from '../activity-cell'
+
+vi.mock('react-i18next', async () => {
+ const { createReactI18nextMock } = await import('@/test/i18n-mock')
+ return createReactI18nextMock({
+ 'deployments.studio.activity.deploy': 'Deploy {{target}}',
+ 'deployments.studio.activity.deployFailed': 'Deploy {{target}} failed',
+ 'deployments.studio.activity.deploySucceeded': 'Deploy {{target}} succeeded',
+ 'deployments.studio.activity.meta': 'by {{name}} · {{time}}',
+ 'deployments.deployTab.undeploy': 'Undeploy',
+ 'deployments.status.RUNTIME_INSTANCE_STATUS_UNDEPLOYING': 'Undeploying',
+ 'workflow.tracing.status.failed': 'Failed',
+ 'workflow.tracing.status.succeeded': 'Success',
+ })
+})
+
+const { formatTimeFromNow } = vi.hoisted(() => ({ formatTimeFromNow: vi.fn() }))
+
+vi.mock('@/hooks/use-format-time-from-now', () => ({
+ useFormatTimeFromNow: () => ({ formatTimeFromNow }),
+}))
+
+const activity: EnvironmentDeploymentOperation = {
+ activity_at: 1_800_000_000,
+ id: 'deploy-release-1',
+ operator: { display_name: 'Evan', id: 'operator-1', type: OperatorType.OPERATOR_TYPE_ACCOUNT },
+ status: DeploymentOperationStatus.DEPLOYMENT_OPERATION_STATUS_IN_PROGRESS,
+ target_version: { id: 'release-1', marked_name: 'Release 1', version: '1' },
+ type: DeploymentOperationType.DEPLOYMENT_OPERATION_TYPE_DEPLOY,
+}
+
+describe('ActivityCell announcements', () => {
+ beforeEach(() => {
+ formatTimeFromNow.mockReturnValue('just now')
+ })
+
+ it.each([
+ [DeploymentOperationStatus.DEPLOYMENT_OPERATION_STATUS_SUCCEEDED, 'succeeded'],
+ [DeploymentOperationStatus.DEPLOYMENT_OPERATION_STATUS_FAILED, 'failed'],
+ ] as const)('announces deployment result %s with its environment', (status, result) => {
+ const { rerender } = render(<ActivityCell activity={activity} environmentName="Canary" />)
+ const announcement = screen.getByRole('status')
+ expect(announcement).toHaveTextContent('Canary: Deploy Release 1')
+
+ rerender(<ActivityCell activity={{ ...activity, status }} environmentName="Canary" />)
+
+ expect(screen.getByRole('status')).toHaveTextContent(`Canary: Deploy Release 1 ${result}`)
+ })
+
+ it.each([
+ [DeploymentOperationStatus.DEPLOYMENT_OPERATION_STATUS_SUCCEEDED, 'Success'],
+ [DeploymentOperationStatus.DEPLOYMENT_OPERATION_STATUS_FAILED, 'Failed'],
+ ] as const)('announces undeployment result %s with its environment', (status, result) => {
+ const undeploy = {
+ ...activity,
+ type: DeploymentOperationType.DEPLOYMENT_OPERATION_TYPE_UNDEPLOY,
+ }
+ const { rerender } = render(<ActivityCell activity={undeploy} environmentName="Canary" />)
+ expect(screen.getByRole('status')).toHaveTextContent('Canary: Undeploying')
+
+ rerender(<ActivityCell activity={{ ...undeploy, status }} environmentName="Canary" />)
+
+ expect(screen.getByRole('status')).toHaveTextContent(`Canary: Undeploy · ${result}`)
+ })
+
+ it('does not announce an unspecified undeployment as in progress', () => {
+ render(
+ <ActivityCell
+ activity={{
+ ...activity,
+ type: DeploymentOperationType.DEPLOYMENT_OPERATION_TYPE_UNDEPLOY,
+ status: DeploymentOperationStatus.DEPLOYMENT_OPERATION_STATUS_UNSPECIFIED,
+ }}
+ environmentName="Canary"
+ />,
+ )
+
+ expect(screen.getByRole('status').textContent).toBe('Canary: Undeploy')
+ })
+
+ it('keeps the live region mounted when the first activity arrives', () => {
+ const { rerender } = render(<ActivityCell environmentName="Canary" />)
+ const announcement = screen.getByRole('status')
+
+ rerender(<ActivityCell activity={activity} environmentName="Canary" />)
+
+ expect(screen.getByRole('status')).toBe(announcement)
+ expect(announcement).toHaveTextContent('Canary: Deploy Release 1')
+ })
+
+ it('keeps relative time updates outside the live region', () => {
+ const { rerender } = render(<ActivityCell activity={activity} environmentName="Canary" />)
+ expect(screen.getByText('by Evan · just now')).toBeInTheDocument()
+ expect(screen.getByRole('status')).not.toHaveTextContent('just now')
+
+ formatTimeFromNow.mockReturnValue('one minute ago')
+ rerender(<ActivityCell activity={activity} environmentName="Canary" />)
+
+ expect(screen.getByText('by Evan · one minute ago')).toBeInTheDocument()
+ expect(screen.getByRole('status')).toHaveTextContent('Canary: Deploy Release 1')
+ expect(screen.getByRole('status')).not.toHaveTextContent('one minute ago')
+ })
+})
diff --git a/web/app/components/app/deploy/environment-table/activity-cell.tsx b/web/app/components/app/deploy/environment-table/activity-cell.tsx
index ce125b132a7..cbfbb2b264a 100644
--- a/web/app/components/app/deploy/environment-table/activity-cell.tsx
+++ b/web/app/components/app/deploy/environment-table/activity-cell.tsx
@@ -1,4 +1,5 @@
import type { EnvironmentDeploymentOperation } from '@dify/contracts/enterprise-app-deploy/types.gen'
+import type { TFunction } from 'i18next'
import {
DeploymentOperationStatus,
DeploymentOperationType,
@@ -10,11 +11,19 @@ import { useFormatTimeFromNow } from '@/hooks/use-format-time-from-now'
function activityLabel(
activity: EnvironmentDeploymentOperation,
- t: ReturnType<typeof useTranslation<'deployments'>>['t'],
+ t: TFunction<['deployments', 'workflow', 'workflowHistory']>,
defaultVersionName: string,
) {
- if (activity.type === DeploymentOperationType.DEPLOYMENT_OPERATION_TYPE_UNDEPLOY)
- return t(($) => $['deployTab.undeploy'])
+ if (activity.type === DeploymentOperationType.DEPLOYMENT_OPERATION_TYPE_UNDEPLOY) {
+ const action = t(($) => $['deployTab.undeploy'])
+ if (activity.status === DeploymentOperationStatus.DEPLOYMENT_OPERATION_STATUS_FAILED)
+ return `${action} · ${t(($) => $['tracing.status.failed'], { ns: 'workflow' })}`
+ if (activity.status === DeploymentOperationStatus.DEPLOYMENT_OPERATION_STATUS_SUCCEEDED)
+ return `${action} · ${t(($) => $['tracing.status.succeeded'], { ns: 'workflow' })}`
+ if (activity.status === DeploymentOperationStatus.DEPLOYMENT_OPERATION_STATUS_IN_PROGRESS)
+ return t(($) => $['status.RUNTIME_INSTANCE_STATUS_UNDEPLOYING'])
+ return action
+ }
const target = getWorkflowVersionName(activity.target_version, defaultVersionName)
if (activity.status === DeploymentOperationStatus.DEPLOYMENT_OPERATION_STATUS_FAILED)
@@ -24,47 +33,64 @@ function activityLabel(
return t(($) => $['studio.activity.deploy'], { target })
}
-export function ActivityCell({ activity }: { activity?: EnvironmentDeploymentOperation }) {
- const { t } = useTranslation(['deployments'])
- const { t: tWorkflow } = useTranslation(['workflowHistory'])
+export function ActivityCell({
+ activity,
+ environmentName,
+}: {
+ activity?: EnvironmentDeploymentOperation
+ environmentName: string
+}) {
+ const { t } = useTranslation(['deployments', 'workflow', 'workflowHistory'])
const { formatTimeFromNow } = useFormatTimeFromNow()
- if (!activity) return <span className="text-text-quaternary">--</span>
- const failed = activity.status === DeploymentOperationStatus.DEPLOYMENT_OPERATION_STATUS_FAILED
+ const failed = activity?.status === DeploymentOperationStatus.DEPLOYMENT_OPERATION_STATUS_FAILED
const inProgress =
- activity.status === DeploymentOperationStatus.DEPLOYMENT_OPERATION_STATUS_IN_PROGRESS
+ activity?.status === DeploymentOperationStatus.DEPLOYMENT_OPERATION_STATUS_IN_PROGRESS
return (
<div className="flex min-w-0 flex-col gap-0.5">
- <div
- className={cn(
- 'flex min-w-0 items-center gap-1 truncate system-xs-medium',
- failed ? 'text-text-warning' : 'text-text-secondary',
+ <div role="status" aria-atomic="true">
+ {activity ? (
+ <div
+ key={activity.id}
+ className={cn(
+ 'flex min-w-0 items-center gap-1 system-xs-medium',
+ failed ? 'text-util-colors-orange-orange-700' : 'text-text-secondary',
+ )}
+ >
+ <span className="sr-only">{environmentName}: </span>
+ {inProgress && (
+ <span
+ aria-hidden
+ className="i-ri-loader-2-line size-3 shrink-0 animate-spin motion-reduce:animate-none"
+ />
+ )}
+ {failed && (
+ <span
+ aria-hidden
+ className="i-ri-error-warning-fill size-3 shrink-0 text-text-warning"
+ />
+ )}
+ <span className="min-w-0 wrap-anywhere">
+ {activityLabel(
+ activity,
+ t,
+ t(($) => $['versionHistory.defaultName'], { ns: 'workflowHistory' }),
+ )}
+ </span>
+ </div>
+ ) : (
+ <span className="text-text-quaternary">--</span>
)}
- >
- {inProgress && (
- <span
- aria-hidden
- className="i-ri-loader-2-line size-3 shrink-0 animate-spin motion-reduce:animate-none"
- />
- )}
- {failed && (
- <span aria-hidden className="i-ri-error-warning-fill size-3 shrink-0 text-text-warning" />
- )}
- <span className="truncate">
- {activityLabel(
- activity,
- t,
- tWorkflow(($) => $['versionHistory.defaultName'], { ns: 'workflowHistory' }),
- )}
- </span>
- </div>
- <div className="truncate system-xs-regular text-text-tertiary">
- {t(($) => $['studio.activity.meta'], {
- name: activity.operator.display_name,
- time: formatTimeFromNow(activity.activity_at * 1000),
- })}
</div>
+ {activity && (
+ <div className="system-xs-regular wrap-anywhere text-text-tertiary">
+ {t(($) => $['studio.activity.meta'], {
+ name: activity.operator.display_name,
+ time: formatTimeFromNow(activity.activity_at * 1000),
+ })}
+ </div>
+ )}
</div>
)
}
diff --git a/web/app/components/app/deploy/environment-table/deploy-menu/index.tsx b/web/app/components/app/deploy/environment-table/deploy-menu/index.tsx
index f8836788893..115d091d0f5 100644
--- a/web/app/components/app/deploy/environment-table/deploy-menu/index.tsx
+++ b/web/app/components/app/deploy/environment-table/deploy-menu/index.tsx
@@ -1,6 +1,6 @@
'use client'
-import type { AppEnvironment } from '@dify/contracts/enterprise-app-deploy/types.gen'
+import type { OpenDeploymentDialog } from '../../types'
import { Button } from '@langgenius/dify-ui/button'
import {
DropdownMenu,
@@ -11,6 +11,7 @@ import {
DropdownMenuTrigger,
} from '@langgenius/dify-ui/dropdown-menu'
import { useAtomValue } from 'jotai'
+import { useRef } from 'react'
import { useTranslation } from 'react-i18next'
import { LoadingPlaceholder } from '@/app/components/base/loading-placeholder'
import {
@@ -23,12 +24,12 @@ import {
type EnvironmentDeployMenuProps = {
appearance?: 'empty' | 'header'
- onSelectEnvironment: (environment: AppEnvironment) => void
+ onOpenDeployment: OpenDeploymentDialog
}
export function EnvironmentDeployMenu({
appearance = 'header',
- onSelectEnvironment,
+ onOpenDeployment,
}: EnvironmentDeployMenuProps) {
const { t } = useTranslation(['deployments'])
const { t: tCommon } = useTranslation(['common'])
@@ -39,12 +40,17 @@ export function EnvironmentDeployMenu({
const refetchEnvironments = useAtomValue(appEnvironmentsRefetchAtom)
const isEmptyState = appearance === 'empty'
const label = tCommon(($) => $['appMenus.deploy'])
+ const triggerRef = useRef<HTMLButtonElement | null>(null)
return (
<DropdownMenu modal={false}>
<DropdownMenuTrigger
render={
- <Button variant={isEmptyState ? 'secondary' : 'primary'} className="gap-0 px-2">
+ <Button
+ ref={triggerRef}
+ variant={isEmptyState ? 'secondary' : 'primary'}
+ className="gap-0 px-2"
+ >
<span aria-hidden className="i-ri-add-line size-4" />
<span className="pl-1.5">{label}</span>
<span aria-hidden className="i-ri-arrow-down-s-line size-4" />
@@ -95,7 +101,16 @@ export function EnvironmentDeployMenu({
<DropdownMenuItem
key={environment.id}
className="mx-0 gap-2 py-1.5"
- onClick={() => onSelectEnvironment(environment)}
+ onClick={() => {
+ onOpenDeployment(
+ {
+ environment: environment.display_name,
+ environmentId: environment.id,
+ kind: 'deploy',
+ },
+ triggerRef.current,
+ )
+ }}
>
<span
aria-hidden
diff --git a/web/app/components/app/deploy/environment-table/empty-state/index.tsx b/web/app/components/app/deploy/environment-table/empty-state/index.tsx
index c6e6d205105..02915f1f6f2 100644
--- a/web/app/components/app/deploy/environment-table/empty-state/index.tsx
+++ b/web/app/components/app/deploy/environment-table/empty-state/index.tsx
@@ -1,6 +1,6 @@
'use client'
-import type { AppEnvironment } from '@dify/contracts/enterprise-app-deploy/types.gen'
+import type { OpenDeploymentDialog } from '../../types'
import { Button } from '@langgenius/dify-ui/button'
import { useTranslation } from 'react-i18next'
import { EnvironmentDeployMenu } from '../deploy-menu'
@@ -9,7 +9,7 @@ import { EmptyTableSkeleton } from './skeleton'
type EnvironmentTableEmptyProps =
| {
state: 'empty'
- onSelectEnvironment: (environment: AppEnvironment) => void
+ onOpenDeployment: OpenDeploymentDialog
}
| {
state: 'error'
@@ -36,7 +36,10 @@ export function EnvironmentTableEmpty(props: EnvironmentTableEmptyProps) {
<span aria-hidden className="i-ri-instance-line size-6 text-text-tertiary" />
</div>
</div>
- <div className="flex w-full flex-col items-center gap-2">
+ <div
+ role={isError ? 'alert' : undefined}
+ className="flex w-full flex-col items-center gap-2"
+ >
<h3 className="system-md-medium text-text-secondary">{title}</h3>
<p className="system-sm-regular text-text-tertiary">{description}</p>
</div>
@@ -46,10 +49,7 @@ export function EnvironmentTableEmpty(props: EnvironmentTableEmptyProps) {
{tCommon(($) => $['operation.retry'])}
</Button>
) : (
- <EnvironmentDeployMenu
- appearance="empty"
- onSelectEnvironment={props.onSelectEnvironment}
- />
+ <EnvironmentDeployMenu appearance="empty" onOpenDeployment={props.onOpenDeployment} />
)}
</div>
</div>
diff --git a/web/app/components/app/deploy/environment-table/index.tsx b/web/app/components/app/deploy/environment-table/index.tsx
index 2d4b98d2ddf..c3f600d4236 100644
--- a/web/app/components/app/deploy/environment-table/index.tsx
+++ b/web/app/components/app/deploy/environment-table/index.tsx
@@ -1,17 +1,18 @@
'use client'
-import type {
- AppEnvironment,
- EnvironmentDeployment,
-} from '@dify/contracts/enterprise-app-deploy/types.gen'
-import type { DeploymentVersion } from '../utils/version'
-import type { UndeployHandler } from './types'
+import type { EnvironmentDeployment } from '@dify/contracts/enterprise-app-deploy/types.gen'
+import type { DeploymentDialogRequest, OpenDeploymentDialog } from '../types'
+import type { OpenUndeployDialog, UndeployHandler } from './types'
+import { AlertDialog } from '@langgenius/dify-ui/alert-dialog'
import { Button } from '@langgenius/dify-ui/button'
import { cn } from '@langgenius/dify-ui/cn'
+import { Dialog } from '@langgenius/dify-ui/dialog'
import { useAtomValue } from 'jotai'
-import { memo } from 'react'
+import dynamic from 'next/dynamic'
+import { memo, useCallback, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { LoadingPlaceholder } from '@/app/components/base/loading-placeholder'
+import { getWorkflowVersionName } from '@/app/components/workflow/utils/version'
import {
appEnvironmentDeploymentsAtom,
appEnvironmentDeploymentsIsErrorAtom,
@@ -27,14 +28,15 @@ import {
import { EnvironmentDeployMenu } from './deploy-menu'
import { EnvironmentTableEmpty } from './empty-state'
import { EnvironmentRow } from './row'
+import { UndeployConfirmDialogContent } from './undeploy-confirm-dialog'
+
+const DeploymentDialogContent = dynamic(() =>
+ import('../deployment-dialog').then((module) => module.DeploymentDialogContent),
+)
type EnvironmentTableProps = {
appId: string
canViewAccessPoint: boolean
- onChangeVersion: (deployment: EnvironmentDeployment) => void
- onDeployLatest: (deployment: EnvironmentDeployment, version: DeploymentVersion) => void
- onDeployToEnvironment: (environment: AppEnvironment) => void
- onRedeploy: (deployment: EnvironmentDeployment) => void
onUndeploy: UndeployHandler
}
@@ -57,22 +59,40 @@ function EnvironmentTableHeader() {
return (
<thead>
<tr className="sticky top-0 z-10 h-7 bg-background-section-burn">
- <th className="rounded-l-lg pr-2 pl-3 text-left system-xs-medium-uppercase text-text-tertiary">
+ <th
+ scope="col"
+ className="rounded-l-lg pr-2 pl-3 text-left system-xs-medium-uppercase text-text-tertiary"
+ >
{t(($) => $['deployTab.col.environment'])}
</th>
- <th className="pr-2 pl-3 text-left system-xs-medium-uppercase text-text-tertiary">
+ <th
+ scope="col"
+ className="pr-2 pl-3 text-left system-xs-medium-uppercase text-text-tertiary"
+ >
{t(($) => $['studio.liveVersion'])}
</th>
- <th className="pr-2 pl-3 text-left system-xs-medium-uppercase text-text-tertiary">
+ <th
+ scope="col"
+ className="pr-2 pl-3 text-left system-xs-medium-uppercase text-text-tertiary"
+ >
{t(($) => $['deployTab.col.status'])}
</th>
- <th className="pr-2 pl-3 text-left system-xs-medium-uppercase text-text-tertiary">
+ <th
+ scope="col"
+ className="pr-2 pl-3 text-left system-xs-medium-uppercase text-text-tertiary"
+ >
{t(($) => $['studio.lastActivity'])}
</th>
- <th className="pr-2 pl-3 text-left system-xs-medium-uppercase text-text-tertiary">
+ <th
+ scope="col"
+ className="pr-2 pl-3 text-left system-xs-medium-uppercase text-text-tertiary"
+ >
{t(($) => $['studio.accessPoints'])}
</th>
- <th className="rounded-r-lg pr-2 pl-3 text-left system-xs-medium-uppercase text-text-tertiary">
+ <th
+ scope="col"
+ className="rounded-r-lg pr-2 pl-3 text-left system-xs-medium-uppercase text-text-tertiary"
+ >
{t(($) => $['deployTab.col.actions'])}
</th>
</tr>
@@ -81,17 +101,30 @@ function EnvironmentTableHeader() {
}
export const EnvironmentTable = memo(
- ({
- appId,
- canViewAccessPoint,
- onChangeVersion,
- onDeployLatest,
- onDeployToEnvironment,
- onRedeploy,
- onUndeploy,
- }: EnvironmentTableProps) => {
+ ({ appId, canViewAccessPoint, onUndeploy }: EnvironmentTableProps) => {
const { t } = useTranslation(['deployments'])
const { t: tCommon } = useTranslation(['common'])
+ const { t: tWorkflow } = useTranslation(['workflowHistory'])
+ const environmentsTitleRef = useRef<HTMLHeadingElement | null>(null)
+ const [deploymentSession, setDeploymentSession] = useState<{
+ open: boolean
+ request: DeploymentDialogRequest
+ returnFocusElement: HTMLElement | null
+ }>()
+ const [undeploySession, setUndeploySession] = useState<{
+ open: boolean
+ deployment: EnvironmentDeployment
+ returnFocusElement: HTMLElement | null
+ }>()
+ const openDeployment = useCallback<OpenDeploymentDialog>((request, returnFocusElement) => {
+ setDeploymentSession({ open: true, request, returnFocusElement })
+ }, [])
+ const openUndeploy = useCallback<OpenUndeployDialog>((deployment, returnFocusElement) => {
+ setUndeploySession({ open: true, deployment, returnFocusElement })
+ }, [])
+ const closeDeployment = () =>
+ setDeploymentSession((session) => session && { ...session, open: false })
+ const [isUndeploying, setIsUndeploying] = useState(false)
const deployments = useAtomValue(appEnvironmentDeploymentsAtom) ?? []
const isLoading = useAtomValue(appEnvironmentDeploymentsIsLoadingAtom)
const isError = useAtomValue(appEnvironmentDeploymentsIsErrorAtom)
@@ -107,98 +140,171 @@ export const EnvironmentTable = memo(
const showErrorState = isError && deployments.length === 0
const showEmptyState = !isLoading && !isError && deployments.length === 0
+ const handleUndeploy = async (deployment: EnvironmentDeployment) => {
+ if (isUndeploying) return
+
+ setIsUndeploying(true)
+ try {
+ await onUndeploy(deployment)
+ setUndeploySession((session) => session && { ...session, open: false })
+ } catch {
+ // The request layer reports the error; keep the dialog open so the user can retry.
+ } finally {
+ setIsUndeploying(false)
+ }
+ }
+
return (
- <section
- aria-labelledby="deploy-environments-title"
- aria-busy={showLoadingState || isRetrying || latestVersionIsRetrying}
- className="flex min-h-0 grow flex-col gap-3"
- >
- <div className="flex shrink-0 items-center justify-between">
- <div className="flex min-w-0 items-center gap-2">
- <h2
- id="deploy-environments-title"
- className="truncate system-md-semibold text-text-primary"
- >
- {t(($) => $['studio.environments'])}
- </h2>
- {usage && (
- <>
- <span aria-hidden className="system-xs-regular text-text-quaternary">
- ·
- </span>
- <span className="truncate system-xs-regular text-text-tertiary">
- {t(($) => $['studio.environmentsInUse'], usage)}
- </span>
- </>
- )}
+ <>
+ <section
+ aria-labelledby="deploy-environments-title"
+ aria-busy={showLoadingState || isRetrying || latestVersionIsRetrying}
+ className="flex min-h-60 min-w-0 grow flex-col gap-3"
+ >
+ <div className="flex shrink-0 flex-wrap items-center justify-between gap-2">
+ <div className="flex min-w-0 flex-wrap items-center gap-2">
+ <h2
+ ref={environmentsTitleRef}
+ id="deploy-environments-title"
+ tabIndex={-1}
+ className="truncate system-md-semibold text-text-primary"
+ >
+ {t(($) => $['studio.environments'])}
+ </h2>
+ {usage && (
+ <>
+ <span aria-hidden className="system-xs-regular text-text-quaternary">
+ ·
+ </span>
+ <span className="truncate system-xs-regular text-text-tertiary">
+ {t(($) => $['studio.environmentsInUse'], usage)}
+ </span>
+ </>
+ )}
+ </div>
+ <EnvironmentDeployMenu onOpenDeployment={openDeployment} />
</div>
- <EnvironmentDeployMenu onSelectEnvironment={onDeployToEnvironment} />
- </div>
- {latestVersionIsError && (
+ {latestVersionIsError && (
+ <div
+ role="alert"
+ className="flex shrink-0 items-center gap-2 rounded-xl border border-state-destructive-border bg-state-destructive-hover-alt p-3"
+ >
+ <span
+ aria-hidden
+ className="i-ri-error-warning-fill size-4 shrink-0 text-text-destructive"
+ />
+ <p className="grow system-sm-medium text-text-destructive">
+ {t(($) => $['studio.latestVersionLoadFailed'])}
+ </p>
+ <Button
+ size="small"
+ variant="secondary"
+ loading={latestVersionIsRetrying}
+ onClick={() => void refetchLatestVersion()}
+ className="gap-1 px-2"
+ >
+ <span aria-hidden className="i-ri-reset-left-line size-3" />
+ <span>{tCommon(($) => $['operation.retry'])}</span>
+ </Button>
+ </div>
+ )}
+
<div
- role="alert"
- className="flex shrink-0 items-center gap-2 rounded-xl border border-state-destructive-border bg-state-destructive-hover-alt p-3"
+ className={cn(
+ 'min-h-0 w-full grow overflow-y-auto',
+ deployments.length > 0 ? 'overflow-x-auto' : 'overflow-x-hidden',
+ )}
>
- <span
- aria-hidden
- className="i-ri-error-warning-fill size-4 shrink-0 text-text-destructive"
- />
- <p className="grow system-sm-medium text-text-destructive">
- {t(($) => $['studio.latestVersionLoadFailed'])}
- </p>
- <Button
- size="small"
- variant="secondary"
- loading={latestVersionIsRetrying}
- onClick={() => void refetchLatestVersion()}
- className="gap-1 px-2"
- >
- <span aria-hidden className="i-ri-reset-left-line size-3" />
- <span>{tCommon(($) => $['operation.retry'])}</span>
- </Button>
+ {showLoadingState ? (
+ <LoadingPlaceholder className="h-full" />
+ ) : showErrorState ? (
+ <EnvironmentTableEmpty
+ state="error"
+ isRetrying={isRetrying}
+ onRetry={() => void refetchDeployments()}
+ />
+ ) : showEmptyState ? (
+ <EnvironmentTableEmpty state="empty" onOpenDeployment={openDeployment} />
+ ) : (
+ <table
+ aria-labelledby="deploy-environments-title"
+ className="w-full min-w-260 table-fixed border-separate border-spacing-0"
+ >
+ <EnvironmentTableColumns />
+ <EnvironmentTableHeader />
+ <tbody>
+ {deployments.map((row) => (
+ <EnvironmentRow
+ key={row.environment.id}
+ appId={appId}
+ canViewAccessPoint={canViewAccessPoint}
+ latestVersion={deployableLatestVersion}
+ row={row}
+ onOpenDeployment={openDeployment}
+ onOpenUndeploy={openUndeploy}
+ />
+ ))}
+ </tbody>
+ </table>
+ )}
</div>
- )}
-
- <div
- className={cn(
- 'min-h-0 w-full grow overflow-y-auto',
- deployments.length > 0 ? 'overflow-x-auto' : 'overflow-x-hidden',
+ </section>
+ <Dialog
+ open={deploymentSession?.open ?? false}
+ disablePointerDismissal
+ onOpenChange={(open) => {
+ if (!open) closeDeployment()
+ }}
+ onOpenChangeComplete={(open) => {
+ if (!open) setDeploymentSession((session) => (session?.open ? session : undefined))
+ }}
+ >
+ {deploymentSession && (
+ <DeploymentDialogContent
+ appId={appId}
+ request={deploymentSession.request}
+ onClose={closeDeployment}
+ finalFocus={() =>
+ deploymentSession.returnFocusElement?.isConnected
+ ? deploymentSession.returnFocusElement
+ : environmentsTitleRef.current
+ }
+ />
)}
+ </Dialog>
+ <AlertDialog
+ open={undeploySession?.open ?? false}
+ onOpenChange={(open, eventDetails) => {
+ if (open) return
+ if (isUndeploying) {
+ eventDetails.cancel()
+ return
+ }
+ setUndeploySession((session) => session && { ...session, open: false })
+ }}
+ onOpenChangeComplete={(open) => {
+ if (!open) setUndeploySession((session) => (session?.open ? session : undefined))
+ }}
>
- {showLoadingState ? (
- <LoadingPlaceholder className="h-full" />
- ) : showErrorState ? (
- <EnvironmentTableEmpty
- state="error"
- isRetrying={isRetrying}
- onRetry={() => void refetchDeployments()}
+ {undeploySession && (
+ <UndeployConfirmDialogContent
+ finalFocus={() =>
+ undeploySession.returnFocusElement?.isConnected
+ ? undeploySession.returnFocusElement
+ : environmentsTitleRef.current
+ }
+ environmentName={undeploySession.deployment.environment.display_name}
+ isPending={isUndeploying}
+ versionName={getWorkflowVersionName(
+ undeploySession.deployment.deployment?.current_version,
+ tWorkflow(($) => $['versionHistory.defaultName']),
+ )}
+ onConfirm={() => void handleUndeploy(undeploySession.deployment)}
/>
- ) : showEmptyState ? (
- <EnvironmentTableEmpty state="empty" onSelectEnvironment={onDeployToEnvironment} />
- ) : (
- <table className="w-full min-w-260 table-fixed border-separate border-spacing-0">
- <EnvironmentTableColumns />
- <EnvironmentTableHeader />
- <tbody>
- {deployments.map((row) => (
- <EnvironmentRow
- key={row.environment.id}
- appId={appId}
- canViewAccessPoint={canViewAccessPoint}
- latestVersion={deployableLatestVersion}
- row={row}
- onChangeVersion={onChangeVersion}
- onDeployLatest={onDeployLatest}
- onRedeploy={onRedeploy}
- onUndeploy={onUndeploy}
- />
- ))}
- </tbody>
- </table>
)}
- </div>
- </section>
+ </AlertDialog>
+ </>
)
},
)
diff --git a/web/app/components/app/deploy/environment-table/row-actions.tsx b/web/app/components/app/deploy/environment-table/row-actions.tsx
index 8bcc7b6e738..8a10a56721c 100644
--- a/web/app/components/app/deploy/environment-table/row-actions.tsx
+++ b/web/app/components/app/deploy/environment-table/row-actions.tsx
@@ -1,7 +1,8 @@
import type { EnvironmentDeployment } from '@dify/contracts/enterprise-app-deploy/types.gen'
+import type { DeploymentDialogRequest, OpenDeploymentDialog } from '../types'
import type { EnvironmentDeploymentAction } from '../utils/environment-deployment'
import type { DeploymentVersion } from '../utils/version'
-import type { UndeployHandler } from './types'
+import type { OpenUndeployDialog } from './types'
import { Button } from '@langgenius/dify-ui/button'
import { cn } from '@langgenius/dify-ui/cn'
import {
@@ -12,12 +13,11 @@ import {
DropdownMenuTrigger,
} from '@langgenius/dify-ui/dropdown-menu'
import { IconButton } from '@langgenius/dify-ui/icon-button'
-import { Fragment, useCallback, useState } from 'react'
+import { Fragment, useRef } from 'react'
import { useTranslation } from 'react-i18next'
import { getWorkflowVersionName } from '@/app/components/workflow/utils/version'
-import { toast } from '@/app/notifications'
import { getEnvironmentDeploymentActions } from '../utils/environment-deployment'
-import { UndeployConfirmDialog } from './undeploy-confirm-dialog'
+import { toDeploymentVersion } from '../utils/version'
function rowActionLabel(
action: EnvironmentDeploymentAction,
@@ -53,147 +53,138 @@ const ROW_ACTION_ICON_CLASS_NAMES: Record<EnvironmentDeploymentAction['kind'], s
undeploy: 'i-ri-logout-circle-r-line',
}
+function deploymentDialogRequest(
+ action: EnvironmentDeploymentAction,
+ row: EnvironmentDeployment,
+ latestVersion: DeploymentVersion | undefined,
+ defaultVersionName: string,
+): DeploymentDialogRequest | undefined {
+ const request = {
+ currentVersionId: row.deployment?.current_version?.id,
+ environment: row.environment.display_name,
+ environmentId: row.environment.id,
+ }
+
+ switch (action.kind) {
+ case 'changeVersion':
+ return { ...request, kind: 'changeVersion' }
+ case 'deployLatest':
+ return latestVersion
+ ? { ...request, initialVersion: latestVersion, kind: 'deployLatest' }
+ : undefined
+ case 'redeploy':
+ case 'retry': {
+ const version =
+ row.deployment?.latest_operation?.target_version ?? row.deployment?.current_version
+ return version
+ ? {
+ ...request,
+ initialVersion: toDeploymentVersion(version, defaultVersionName),
+ kind: 'redeploy',
+ }
+ : { ...request, kind: 'changeVersion' }
+ }
+ case 'undeploy':
+ return undefined
+ }
+}
+
export function EnvironmentRowActions({
latestVersion,
row,
- onChangeVersion,
- onDeployLatest,
- onRedeploy,
- onUndeploy,
+ onOpenDeployment,
+ onOpenUndeploy,
}: {
latestVersion?: DeploymentVersion
row: EnvironmentDeployment
- onChangeVersion: (deployment: EnvironmentDeployment) => void
- onDeployLatest: (deployment: EnvironmentDeployment, version: DeploymentVersion) => void
- onRedeploy: (deployment: EnvironmentDeployment) => void
- onUndeploy: UndeployHandler
+ onOpenDeployment: OpenDeploymentDialog
+ onOpenUndeploy: OpenUndeployDialog
}) {
const { t } = useTranslation(['deployments'])
const { t: tWorkflow } = useTranslation(['workflowHistory'])
const defaultVersionName = tWorkflow(($) => $['versionHistory.defaultName'], {
ns: 'workflowHistory',
})
- const currentVersionName = getWorkflowVersionName(
- row.deployment?.current_version,
- defaultVersionName,
- )
- const [showUndeployConfirm, setShowUndeployConfirm] = useState(false)
- const [isUndeploying, setIsUndeploying] = useState(false)
+ const primaryTriggerRef = useRef<HTMLButtonElement | null>(null)
+ const menuTriggerRef = useRef<HTMLButtonElement | null>(null)
const actions = getEnvironmentDeploymentActions(row, {
deployLatestDisabled: !latestVersion,
})
+ const handleAction = (
+ action: EnvironmentDeploymentAction,
+ returnFocusElement: HTMLElement | null,
+ ) => {
+ if (action.kind === 'undeploy') {
+ onOpenUndeploy(row, returnFocusElement)
+ return
+ }
+ const request = deploymentDialogRequest(action, row, latestVersion, defaultVersionName)
+ if (request) onOpenDeployment(request, returnFocusElement)
+ }
const primaryAction = actions[0]
const moreActions = actions.slice(1)
- const handleAction = useCallback(
- (action: EnvironmentDeploymentAction) => {
- if (action.disabled) return
-
- switch (action.kind) {
- case 'changeVersion':
- onChangeVersion(row)
- break
- case 'deployLatest': {
- if (!latestVersion) {
- toast.error(t(($) => $['studio.latestVersionLoadFailed']))
- return
- }
-
- onDeployLatest(row, latestVersion)
- break
- }
- case 'redeploy':
- case 'retry':
- onRedeploy(row)
- break
- case 'undeploy':
- setShowUndeployConfirm(true)
- break
- }
- },
- [latestVersion, onChangeVersion, onDeployLatest, onRedeploy, row, t],
- )
-
- const handleUndeploy = useCallback(async () => {
- if (isUndeploying) return
-
- setIsUndeploying(true)
- try {
- await onUndeploy(row)
- setShowUndeployConfirm(false)
- } catch {
- // The request layer reports the error; keep the dialog open so the user can retry.
- } finally {
- setIsUndeploying(false)
- }
- }, [isUndeploying, onUndeploy, row])
-
if (!primaryAction) return null
return (
- <>
- <div className="flex items-center justify-end gap-1">
- <Button
- size="small"
- variant="secondary"
- disabled={primaryAction.disabled}
- onClick={() => handleAction(primaryAction)}
- className="min-w-0 gap-1 px-2"
- >
- <span
- aria-hidden
- className={cn(ROW_ACTION_ICON_CLASS_NAMES[primaryAction.kind], 'size-3.5 shrink-0')}
- />
- <span className="truncate">
- {rowActionLabel(primaryAction, row, t, defaultVersionName)}
- </span>
- </Button>
- <DropdownMenu modal={false}>
- <DropdownMenuTrigger
- render={
- <IconButton
- size="md"
- variant="secondary"
- aria-label={`${row.environment.display_name} · ${t(($) => $['deployTab.moreActions'])}`}
- className="shrink-0"
+ <div className="flex items-center justify-end gap-1">
+ <Button
+ ref={primaryTriggerRef}
+ size="small"
+ variant="secondary"
+ disabled={primaryAction.disabled}
+ focusableWhenDisabled
+ className="min-w-0 gap-1 px-2"
+ onClick={() => handleAction(primaryAction, primaryTriggerRef.current)}
+ >
+ <span
+ aria-hidden
+ className={cn(ROW_ACTION_ICON_CLASS_NAMES[primaryAction.kind], 'size-3.5 shrink-0')}
+ />
+ <span className="truncate">
+ {rowActionLabel(primaryAction, row, t, defaultVersionName)}
+ </span>
+ </Button>
+ <DropdownMenu modal={false}>
+ <DropdownMenuTrigger
+ render={
+ <IconButton
+ ref={menuTriggerRef}
+ size="md"
+ variant="secondary"
+ aria-label={`${row.environment.display_name} · ${t(($) => $['deployTab.moreActions'])}`}
+ className="shrink-0"
+ >
+ <span aria-hidden className="i-ri-more-fill size-4" />
+ </IconButton>
+ }
+ />
+ <DropdownMenuContent placement="bottom-end" sideOffset={4} className="w-50">
+ {moreActions.map((action, index) => (
+ <Fragment key={action.kind}>
+ {action.kind === 'undeploy' && index > 0 && <DropdownMenuSeparator />}
+ <DropdownMenuItem
+ disabled={action.disabled}
+ className="gap-2 px-2"
+ onClick={() => {
+ handleAction(action, menuTriggerRef.current)
+ }}
>
- <span aria-hidden className="i-ri-more-fill size-4" />
- </IconButton>
- }
- />
- <DropdownMenuContent placement="bottom-end" sideOffset={4} className="w-50">
- {moreActions.map((action, index) => (
- <Fragment key={action.kind}>
- {action.kind === 'undeploy' && index > 0 && <DropdownMenuSeparator />}
- <DropdownMenuItem
- disabled={action.disabled}
- className="gap-2 px-2"
- onClick={() => handleAction(action)}
- >
- <span
- aria-hidden
- className={cn(
- ROW_ACTION_ICON_CLASS_NAMES[action.kind],
- 'size-4 shrink-0 text-text-secondary',
- )}
- />
- <span className="min-w-0 flex-1 truncate system-md-regular text-text-secondary">
- {rowActionLabel(action, row, t, defaultVersionName)}
- </span>
- </DropdownMenuItem>
- </Fragment>
- ))}
- </DropdownMenuContent>
- </DropdownMenu>
- </div>
- <UndeployConfirmDialog
- environmentName={row.environment.display_name}
- isPending={isUndeploying}
- open={showUndeployConfirm}
- versionName={currentVersionName}
- onConfirm={handleUndeploy}
- onOpenChange={setShowUndeployConfirm}
- />
- </>
+ <span
+ aria-hidden
+ className={cn(
+ ROW_ACTION_ICON_CLASS_NAMES[action.kind],
+ 'size-4 shrink-0 text-text-secondary',
+ )}
+ />
+ <span className="min-w-0 flex-1 truncate system-md-regular text-text-secondary">
+ {rowActionLabel(action, row, t, defaultVersionName)}
+ </span>
+ </DropdownMenuItem>
+ </Fragment>
+ ))}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
)
}
diff --git a/web/app/components/app/deploy/environment-table/row.tsx b/web/app/components/app/deploy/environment-table/row.tsx
index f0bf850a87e..627e0d70ff0 100644
--- a/web/app/components/app/deploy/environment-table/row.tsx
+++ b/web/app/components/app/deploy/environment-table/row.tsx
@@ -1,7 +1,8 @@
import type { EnvironmentDeployment } from '@dify/contracts/enterprise-app-deploy/types.gen'
+import type { OpenDeploymentDialog } from '../types'
import type { AccessPoint } from '../utils/access-point'
import type { DeploymentVersion } from '../utils/version'
-import type { UndeployHandler } from './types'
+import type { OpenUndeployDialog } from './types'
import { RuntimeState } from '@dify/contracts/enterprise-app-deploy/types.gen'
import { memo } from 'react'
import { AccessPointIcon } from '../shared/access-point-icon'
@@ -17,19 +18,15 @@ export const EnvironmentRow = memo(
canViewAccessPoint,
latestVersion,
row,
- onChangeVersion,
- onDeployLatest,
- onRedeploy,
- onUndeploy,
+ onOpenDeployment,
+ onOpenUndeploy,
}: {
appId: string
canViewAccessPoint: boolean
latestVersion?: DeploymentVersion
row: EnvironmentDeployment
- onChangeVersion: (deployment: EnvironmentDeployment) => void
- onDeployLatest: (deployment: EnvironmentDeployment, version: DeploymentVersion) => void
- onRedeploy: (deployment: EnvironmentDeployment) => void
- onUndeploy: UndeployHandler
+ onOpenDeployment: OpenDeploymentDialog
+ onOpenUndeploy: OpenUndeployDialog
}) => {
const runtimeState = row.deployment
? row.deployment.runtimeState
@@ -43,16 +40,16 @@ export const EnvironmentRow = memo(
return (
<tr className="h-14 border-b border-divider-subtle hover:bg-state-base-hover">
- <td className="border-b border-divider-subtle pr-2 pl-3">
+ <th scope="row" className="border-b border-divider-subtle pr-2 pl-3 text-left font-normal">
<div className="flex min-w-0 items-center gap-2.5">
<span className="flex size-6 shrink-0 items-center justify-center rounded-md border-[0.5px] border-divider-regular bg-components-panel-bg text-text-secondary">
<span aria-hidden className="i-ri-instance-line size-3.5" />
</span>
- <span className="truncate system-md-medium text-text-secondary">
+ <span className="min-w-0 system-md-medium wrap-anywhere text-text-secondary">
{row.environment.display_name}
</span>
</div>
- </td>
+ </th>
<td className="border-b border-divider-subtle pr-2 pl-3">
<VersionLabel
version={row.deployment?.current_version}
@@ -60,10 +57,16 @@ export const EnvironmentRow = memo(
/>
</td>
<td className="border-b border-divider-subtle px-2">
- <RuntimeStateIndicator runtimeState={runtimeState} />
+ <span role="status" aria-atomic="true">
+ <span className="sr-only">{row.environment.display_name}: </span>
+ <RuntimeStateIndicator runtimeState={runtimeState} />
+ </span>
</td>
<td className="border-b border-divider-subtle pr-2 pl-3">
- <ActivityCell activity={row.deployment?.latest_operation} />
+ <ActivityCell
+ activity={row.deployment?.latest_operation}
+ environmentName={row.environment.display_name}
+ />
</td>
<td className="border-b border-divider-subtle pr-2 pl-3">
<div className="flex items-center gap-1">
@@ -85,10 +88,8 @@ export const EnvironmentRow = memo(
<EnvironmentRowActions
latestVersion={latestVersion}
row={row}
- onChangeVersion={onChangeVersion}
- onDeployLatest={onDeployLatest}
- onRedeploy={onRedeploy}
- onUndeploy={onUndeploy}
+ onOpenDeployment={onOpenDeployment}
+ onOpenUndeploy={onOpenUndeploy}
/>
</td>
</tr>
diff --git a/web/app/components/app/deploy/environment-table/types.ts b/web/app/components/app/deploy/environment-table/types.ts
index 2df7dfe882b..50f74814a01 100644
--- a/web/app/components/app/deploy/environment-table/types.ts
+++ b/web/app/components/app/deploy/environment-table/types.ts
@@ -1,3 +1,8 @@
import type { EnvironmentDeployment } from '@dify/contracts/enterprise-app-deploy/types.gen'
export type UndeployHandler = (deployment: EnvironmentDeployment) => Promise<void> | void
+
+export type OpenUndeployDialog = (
+ deployment: EnvironmentDeployment,
+ returnFocusElement: HTMLElement | null,
+) => void
diff --git a/web/app/components/app/deploy/environment-table/undeploy-confirm-dialog/index.tsx b/web/app/components/app/deploy/environment-table/undeploy-confirm-dialog/index.tsx
index ffb653331b0..b34a4298307 100644
--- a/web/app/components/app/deploy/environment-table/undeploy-confirm-dialog/index.tsx
+++ b/web/app/components/app/deploy/environment-table/undeploy-confirm-dialog/index.tsx
@@ -1,7 +1,7 @@
'use client'
+import type { AlertDialogContentProps } from '@langgenius/dify-ui/alert-dialog'
import {
- AlertDialog,
AlertDialogCancelButton,
AlertDialogConfirmButton,
AlertDialogContent,
@@ -12,54 +12,43 @@ import {
} from '@langgenius/dify-ui/alert-dialog'
import { useTranslation } from 'react-i18next'
-type UndeployConfirmDialogProps = {
+type UndeployConfirmDialogContentProps = {
+ finalFocus: AlertDialogContentProps['finalFocus']
environmentName: string
isPending?: boolean
- open: boolean
versionName: string
onConfirm: () => void
- onOpenChange: (open: boolean) => void
}
-export function UndeployConfirmDialog({
+export function UndeployConfirmDialogContent({
+ finalFocus,
environmentName,
isPending = false,
- open,
versionName,
onConfirm,
- onOpenChange,
-}: UndeployConfirmDialogProps) {
+}: UndeployConfirmDialogContentProps) {
const { t } = useTranslation(['deployments'])
const { t: tCommon } = useTranslation(['common'])
return (
- <AlertDialog
- open={open}
- onOpenChange={(nextOpen) => {
- if (!isPending) onOpenChange(nextOpen)
- }}
- >
- <AlertDialogContent>
- <AlertDialogHeader>
- <AlertDialogTitle>
- {t(($) => $['studio.undeployConfirmTitle'], {
- envName: environmentName,
- versionName,
- })}
- </AlertDialogTitle>
- <AlertDialogDescription>
- {t(($) => $['studio.undeployConfirmDesc'])}
- </AlertDialogDescription>
- </AlertDialogHeader>
- <AlertDialogFooter>
- <AlertDialogCancelButton disabled={isPending}>
- {tCommon(($) => $['operation.cancel'])}
- </AlertDialogCancelButton>
- <AlertDialogConfirmButton loading={isPending} onClick={onConfirm}>
- {t(($) => $['deployTab.confirmUndeploy'])}
- </AlertDialogConfirmButton>
- </AlertDialogFooter>
- </AlertDialogContent>
- </AlertDialog>
+ <AlertDialogContent finalFocus={finalFocus}>
+ <AlertDialogHeader>
+ <AlertDialogTitle>
+ {t(($) => $['studio.undeployConfirmTitle'], {
+ envName: environmentName,
+ versionName,
+ })}
+ </AlertDialogTitle>
+ <AlertDialogDescription>{t(($) => $['studio.undeployConfirmDesc'])}</AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogFooter>
+ <AlertDialogCancelButton disabled={isPending}>
+ {tCommon(($) => $['operation.cancel'])}
+ </AlertDialogCancelButton>
+ <AlertDialogConfirmButton loading={isPending} onClick={onConfirm}>
+ {t(($) => $['deployTab.confirmUndeploy'])}
+ </AlertDialogConfirmButton>
+ </AlertDialogFooter>
+ </AlertDialogContent>
)
}
diff --git a/web/app/components/app/deploy/index.tsx b/web/app/components/app/deploy/index.tsx
index e16ef1488bb..77b295ea7c9 100644
--- a/web/app/components/app/deploy/index.tsx
+++ b/web/app/components/app/deploy/index.tsx
@@ -1,15 +1,7 @@
'use client'
-import type {
- AppEnvironment,
- EnvironmentDeployment,
-} from '@dify/contracts/enterprise-app-deploy/types.gen'
-import type { DeploymentDialogRequest } from './types'
-import type { DeploymentVersion } from './utils/version'
import { useSuspenseQuery } from '@tanstack/react-query'
import { useAtomValue } from 'jotai'
-import dynamic from 'next/dynamic'
-import { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { useLocale } from '#i18n'
import { getEnterpriseDocUrl } from '@/context/i18n'
@@ -24,11 +16,6 @@ import { EnvironmentTable } from './environment-table'
import { useRefreshAppEnvironmentsAfterDeploymentPolling } from './hooks/use-refresh-app-environments-after-deployment-polling'
import { useUndeployWorkflow } from './hooks/use-undeploy-workflow'
import { AppDeployStateBoundary } from './state'
-import { toDeploymentVersion } from './utils/version'
-
-const DeploymentDialog = dynamic(() =>
- import('./deployment-dialog').then((module) => module.DeploymentDialog),
-)
function AppDeployContent({
appId,
@@ -39,116 +26,42 @@ function AppDeployContent({
}) {
const { t } = useTranslation(['deployments'])
const { t: tCommon } = useTranslation(['common'])
- const { t: tWorkflow } = useTranslation(['workflow', 'workflowHistory'])
const locale = useLocale()
const docLanguage = getDocLanguage(locale)
const deployOverviewDocUrl = getEnterpriseDocUrl('/use/deploy/overview', docLanguage)
- const [deploymentRequest, setDeploymentRequest] = useState<DeploymentDialogRequest>()
useRefreshAppEnvironmentsAfterDeploymentPolling(appId)
const undeployWorkflow = useUndeployWorkflow(appId)
- const handleDeployToEnvironment = useCallback((environment: AppEnvironment) => {
- setDeploymentRequest({
- environment: environment.display_name,
- environmentId: environment.id,
- kind: 'deploy',
- })
- }, [])
- const handleChangeVersion = useCallback((deployment: EnvironmentDeployment) => {
- setDeploymentRequest({
- currentVersionId: deployment.deployment?.current_version?.id,
- environment: deployment.environment.display_name,
- environmentId: deployment.environment.id,
- kind: 'changeVersion',
- })
- }, [])
- const handleDeployLatest = useCallback(
- (deployment: EnvironmentDeployment, latestVersion: DeploymentVersion) => {
- setDeploymentRequest({
- currentVersionId: deployment.deployment?.current_version?.id,
- environment: deployment.environment.display_name,
- environmentId: deployment.environment.id,
- initialVersion: latestVersion,
- kind: 'deployLatest',
- })
- },
- [],
- )
- const handleRedeploy = useCallback(
- (deployment: EnvironmentDeployment) => {
- const deploymentState = deployment.deployment
- const version =
- deploymentState?.latest_operation?.target_version ?? deploymentState?.current_version
- const environment = deployment.environment.display_name
- const environmentId = deployment.environment.id
-
- if (!version) {
- setDeploymentRequest({
- environment,
- environmentId,
- kind: 'changeVersion',
- })
- return
- }
-
- setDeploymentRequest({
- currentVersionId: deploymentState?.current_version?.id,
- environment,
- environmentId,
- initialVersion: toDeploymentVersion(
- version,
- tWorkflow(($) => $['versionHistory.defaultName'], { ns: 'workflowHistory' }),
- ),
- kind: 'redeploy',
- })
- },
- [tWorkflow],
- )
- const handleCloseDeploymentDialog = useCallback(() => setDeploymentRequest(undefined), [])
-
return (
- <>
- <div className="flex h-full flex-col bg-components-panel-bg">
- <header className="flex shrink-0 flex-col gap-y-0.5 px-6 pt-3 pb-2">
- <div className="flex h-6 items-center">
- <h1 className="title-xl-semi-bold text-text-primary">
- {tCommon(($) => $['appMenus.deploy'])}
- </h1>
- </div>
- <p className="flex items-center gap-x-1 system-xs-regular text-text-tertiary">
- <span>{t(($) => $['studio.description'])}</span>
- <a
- href={deployOverviewDocUrl}
- target="_blank"
- rel="noreferrer"
- className="inline-flex items-center text-text-accent hover:underline focus-visible:ring-1 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"
- >
- {tCommon(($) => $['operation.learnMore'])}
- </a>
- </p>
- </header>
-
- <div className="flex min-h-0 grow flex-col gap-4 px-6 py-2">
- <BuiltInEnvironmentCard canViewAccessPoint={canViewAccessPoint} />
- <EnvironmentTable
- appId={appId}
- canViewAccessPoint={canViewAccessPoint}
- onDeployToEnvironment={handleDeployToEnvironment}
- onChangeVersion={handleChangeVersion}
- onDeployLatest={handleDeployLatest}
- onRedeploy={handleRedeploy}
- onUndeploy={undeployWorkflow}
- />
+ <div className="flex h-full min-w-0 flex-col overflow-y-auto bg-components-panel-bg">
+ <header className="flex shrink-0 flex-col gap-y-0.5 px-6 pt-3 pb-2">
+ <div className="flex h-6 items-center">
+ <h1 className="title-xl-semi-bold text-text-primary">
+ {tCommon(($) => $['appMenus.deploy'])}
+ </h1>
</div>
- </div>
- {deploymentRequest && (
- <DeploymentDialog
+ <p className="flex flex-wrap items-center gap-x-1 system-xs-regular text-text-tertiary">
+ <span>{t(($) => $['studio.description'])}</span>
+ <a
+ href={deployOverviewDocUrl}
+ target="_blank"
+ rel="noreferrer"
+ className="inline-flex items-center text-text-accent hover:underline focus-visible:ring-1 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"
+ >
+ {tCommon(($) => $['operation.learnMore'])}
+ </a>
+ </p>
+ </header>
+
+ <div className="flex min-h-0 grow flex-col gap-4 px-6 py-2 max-md:min-h-max">
+ <BuiltInEnvironmentCard canViewAccessPoint={canViewAccessPoint} />
+ <EnvironmentTable
appId={appId}
- request={deploymentRequest}
- onClose={handleCloseDeploymentDialog}
+ canViewAccessPoint={canViewAccessPoint}
+ onUndeploy={undeployWorkflow}
/>
- )}
- </>
+ </div>
+ </div>
)
}
diff --git a/web/app/components/app/deploy/shared/access-point-icon.tsx b/web/app/components/app/deploy/shared/access-point-icon.tsx
index 200c331ea47..946dcee0999 100644
--- a/web/app/components/app/deploy/shared/access-point-icon.tsx
+++ b/web/app/components/app/deploy/shared/access-point-icon.tsx
@@ -43,7 +43,7 @@ export function AccessPointIcon({
const linkHref = active ? href : undefined
const navigable = Boolean(linkHref)
const triggerClassName = cn(
- 'flex size-5 shrink-0 items-center justify-center rounded-md border border-divider-regular text-text-secondary shadow-xs outline-hidden focus-visible:ring-2 focus-visible:ring-state-accent-solid',
+ 'flex size-6 shrink-0 items-center justify-center rounded-md border border-divider-regular text-text-secondary shadow-xs outline-hidden focus-visible:ring-2 focus-visible:ring-state-accent-solid',
active ? 'opacity-100' : 'opacity-30',
navigable ? 'cursor-pointer hover:bg-state-base-hover' : 'cursor-not-allowed',
)
diff --git a/web/app/components/app/deploy/shared/deployment-configuration/content.tsx b/web/app/components/app/deploy/shared/deployment-configuration/content.tsx
index 875fce1a311..8fe2b8eaefc 100644
--- a/web/app/components/app/deploy/shared/deployment-configuration/content.tsx
+++ b/web/app/components/app/deploy/shared/deployment-configuration/content.tsx
@@ -4,6 +4,7 @@ import type { DeploymentDialogRequest } from '../../types'
import type { DeploymentVersion } from '../../utils/version'
import type { DeploymentConfigurationQueryState } from './use-deployment-configuration-queries'
import type { DeploymentConfigurationValuesController } from './use-deployment-configuration-values'
+import type { DeploymentFieldError } from './utils/field-id'
import { cn } from '@langgenius/dify-ui/cn'
import { useTranslation } from 'react-i18next'
import { LoadingPlaceholder } from '@/app/components/base/loading-placeholder'
@@ -35,12 +36,16 @@ function ConfigurationError({ messages }: { messages: string[] }) {
export function DeploymentConfigurationContent({
compact = false,
configurationValues,
+ fieldError,
+ onConfigurationChange,
queryState,
request,
version,
}: {
compact?: boolean
configurationValues: DeploymentConfigurationValuesController
+ fieldError?: DeploymentFieldError
+ onConfigurationChange: () => void
queryState: DeploymentConfigurationQueryState
request: DeploymentDialogRequest
version: DeploymentVersion
@@ -130,15 +135,23 @@ export function DeploymentConfigurationContent({
<CredentialsSection
credentialSlots={deploymentOptions?.credential_slots ?? []}
credentials={credentials}
+ fieldError={fieldError}
horizontalPaddingClassName={horizontalPaddingClassName}
- onChange={setCredential}
+ onChange={(key, value) => {
+ setCredential(key, value)
+ onConfigurationChange()
+ }}
/>
<EnvironmentVariablesSection
environmentVariableGroups={deploymentOptions?.environment_variable_groups ?? []}
+ fieldError={fieldError}
getEnvironmentVariableSelection={getEnvironmentVariableSelection}
hasCredentialSlots={hasCredentialSlots}
horizontalPaddingClassName={horizontalPaddingClassName}
- setEnvironmentVariableSelection={setEnvironmentVariableSelection}
+ setEnvironmentVariableSelection={(workflowId, key, value) => {
+ setEnvironmentVariableSelection(workflowId, key, value)
+ onConfigurationChange()
+ }}
/>
</>
)}
diff --git a/web/app/components/app/deploy/shared/deployment-configuration/credential-field.tsx b/web/app/components/app/deploy/shared/deployment-configuration/credential-field.tsx
index b6249caedcf..04b25a3b616 100644
--- a/web/app/components/app/deploy/shared/deployment-configuration/credential-field.tsx
+++ b/web/app/components/app/deploy/shared/deployment-configuration/credential-field.tsx
@@ -7,6 +7,7 @@ import {
SelectGroupLabel,
SelectItem,
SelectItemText,
+ SelectLabel,
SelectTrigger,
} from '@langgenius/dify-ui/select'
import { StatusDot } from '@langgenius/dify-ui/status-dot'
@@ -14,15 +15,18 @@ import { useTranslation } from 'react-i18next'
import useGetIcon from '@/app/components/plugins/install-plugin/base/use-get-icon'
import useTheme from '@/hooks/use-theme'
import { Theme } from '@/types/app'
+import { credentialFieldId } from './utils/field-id'
import { credentialProviderName } from './utils/workflow-deployment-input'
import { WorkflowDependencyPreview } from './workflow-source-popover'
export function CredentialField({
+ error,
slot,
paths = [],
value,
onChange,
}: {
+ error?: string
slot: CredentialSlot
paths?: WorkflowPath[]
value?: string
@@ -33,6 +37,8 @@ export function CredentialField({
const { getIconUrl } = useGetIcon()
const { theme } = useTheme()
const selectedOption = slot.candidates.find((candidate) => candidate.credential_id === value)
+ const inputId = credentialFieldId(slot)
+ const errorId = `${inputId}-error`
const name = credentialProviderName(slot.provider_id)
const iconFileName =
theme === Theme.dark ? slot.icon_dark || slot.icon : slot.icon || slot.icon_dark
@@ -45,36 +51,43 @@ export function CredentialField({
: ''
return (
- <div className="flex flex-col gap-1">
- <div className="flex min-w-0 items-center justify-between gap-2 py-0.5">
- <div className="flex min-w-0 flex-1 items-center gap-1">
- <span className="size-5 shrink-0 overflow-hidden rounded-md border-[0.5px] border-components-panel-border-subtle bg-background-default-dodge">
- {iconSrc ? (
- <img alt="" src={iconSrc} className="size-full object-contain" />
- ) : (
- <span
- aria-hidden
- className="i-ri-plug-2-line flex size-full items-center justify-center text-text-tertiary"
- />
+ <Select
+ value={value ?? null}
+ onValueChange={(nextValue) => {
+ if (nextValue) onChange(nextValue)
+ }}
+ >
+ <div className="flex min-w-0 flex-col gap-1">
+ <div className="flex min-w-0 items-center justify-between gap-2 py-0.5">
+ <div className="flex min-w-0 flex-1 items-center gap-1">
+ <span className="size-5 shrink-0 overflow-hidden rounded-md border-[0.5px] border-components-panel-border-subtle bg-background-default-dodge">
+ {iconSrc ? (
+ <img alt="" src={iconSrc} className="size-full object-contain" />
+ ) : (
+ <span
+ aria-hidden
+ className="i-ri-plug-2-line flex size-full items-center justify-center text-text-tertiary"
+ />
+ )}
+ </span>
+ <SelectLabel className="min-w-0 system-sm-medium wrap-anywhere text-text-primary">
+ {name}
+ </SelectLabel>
+ {category && (
+ <span className="shrink-0 system-xs-regular text-text-tertiary">{category}</span>
)}
- </span>
- <span className="truncate system-sm-medium text-text-primary">{name}</span>
- {category && (
- <span className="shrink-0 system-xs-regular text-text-tertiary">{category}</span>
- )}
+ </div>
+ <WorkflowDependencyPreview subjectName={name} paths={paths} />
</div>
- <WorkflowDependencyPreview subjectName={name} paths={paths} />
- </div>
- <Select
- value={value ?? null}
- onValueChange={(nextValue) => {
- if (nextValue) onChange(nextValue)
- }}
- >
- <SelectTrigger aria-label={name} className="pl-2">
+ <SelectTrigger
+ id={inputId}
+ aria-invalid={Boolean(error)}
+ aria-describedby={error ? errorId : undefined}
+ className="pl-2"
+ >
<span className="flex min-w-0 items-center gap-1.5">
<StatusDot />
- <span className="truncate">
+ <span className="truncate text-text-secondary">
{selectedOption?.display_name ??
(slot.candidates.length === 0
? t(($) => $['deployDrawer.noCredentialCandidates'])
@@ -117,7 +130,12 @@ export function CredentialField({
</SelectGroup>
)}
</SelectContent>
- </Select>
- </div>
+ {error && (
+ <p id={errorId} role="alert" className="system-xs-regular text-text-destructive">
+ {error}
+ </p>
+ )}
+ </div>
+ </Select>
)
}
diff --git a/web/app/components/app/deploy/shared/deployment-configuration/credentials-section.tsx b/web/app/components/app/deploy/shared/deployment-configuration/credentials-section.tsx
index 830cffeb958..82f13eff786 100644
--- a/web/app/components/app/deploy/shared/deployment-configuration/credentials-section.tsx
+++ b/web/app/components/app/deploy/shared/deployment-configuration/credentials-section.tsx
@@ -1,20 +1,24 @@
import type { CredentialSlot } from '@dify/contracts/enterprise-app-deploy/types.gen'
import type { DeploymentConfigurationValuesController } from './use-deployment-configuration-values'
+import type { DeploymentFieldError } from './utils/field-id'
import { cn } from '@langgenius/dify-ui/cn'
import { memo } from 'react'
import { useTranslation } from 'react-i18next'
import { CredentialField } from './credential-field'
import { SectionHeading } from './section-heading'
+import { credentialFieldId } from './utils/field-id'
import { credentialSlotKey, defaultCredentialId } from './utils/workflow-deployment-input'
const CredentialConfigurationField = memo(
({
+ error,
onChange,
paths,
slot,
slotKey,
value,
}: {
+ error?: string
onChange: DeploymentConfigurationValuesController['setCredential']
paths?: NonNullable<CredentialSlot['workflow_as_tool_dependency']>['paths']
slot: CredentialSlot
@@ -23,6 +27,7 @@ const CredentialConfigurationField = memo(
}) => {
return (
<CredentialField
+ error={error}
paths={paths}
slot={slot}
value={value}
@@ -37,11 +42,13 @@ export const CredentialsSection = memo(
({
credentialSlots,
credentials,
+ fieldError,
horizontalPaddingClassName,
onChange,
}: {
credentialSlots: CredentialSlot[]
credentials: DeploymentConfigurationValuesController['credentials']
+ fieldError?: DeploymentFieldError
horizontalPaddingClassName: string
onChange: DeploymentConfigurationValuesController['setCredential']
}) => {
@@ -65,6 +72,9 @@ export const CredentialsSection = memo(
return (
<CredentialConfigurationField
+ error={
+ fieldError?.fieldId === credentialFieldId(slot) ? fieldError.message : undefined
+ }
key={slotKey}
slot={slot}
slotKey={slotKey}
@@ -90,6 +100,9 @@ export const CredentialsSection = memo(
return (
<CredentialConfigurationField
+ error={
+ fieldError?.fieldId === credentialFieldId(slot) ? fieldError.message : undefined
+ }
key={slotKey}
paths={slot.workflow_as_tool_dependency?.paths}
slot={slot}
diff --git a/web/app/components/app/deploy/shared/deployment-configuration/environment-variable-field.tsx b/web/app/components/app/deploy/shared/deployment-configuration/environment-variable-field.tsx
index 15b204d8a18..0fe106e3919 100644
--- a/web/app/components/app/deploy/shared/deployment-configuration/environment-variable-field.tsx
+++ b/web/app/components/app/deploy/shared/deployment-configuration/environment-variable-field.tsx
@@ -23,6 +23,7 @@ import dynamic from 'next/dynamic'
import { memo, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { isLLMEnvironmentVariableValue } from '@/app/components/workflow/llm-environment-variable'
+import { environmentVariableFieldId } from './utils/field-id'
import { resolveEnvironmentVariableSelection } from './utils/workflow-deployment-input'
const LLMEnvironmentVariableValueField = dynamic(
@@ -50,11 +51,13 @@ function displayEnvironmentVariableValue(value: unknown) {
export const EnvironmentVariableField = memo(
({
+ error,
slot,
workflowId,
getInitialSelection,
onChange,
}: {
+ error?: string
slot: EnvironmentVariableSlot
workflowId: string
getInitialSelection: (
@@ -93,8 +96,12 @@ export const EnvironmentVariableField = memo(
: slot.value_type === EnvVarValueType.ENV_VAR_VALUE_TYPE_SECRET
? t(($) => $['deployDrawer.envVarType.secret'])
: t(($) => $['deployDrawer.envVarType.string'])
- const inputId = `deployment-env-${encodeURIComponent(workflowId)}-${encodeURIComponent(slot.key)}`
+ const inputId = environmentVariableFieldId(workflowId, slot.key)
const labelId = `${inputId}-label`
+ const descriptionId = `${inputId}-description`
+ const errorId = `${inputId}-error`
+ const describedBy =
+ [slot.description && descriptionId, error && errorId].filter(Boolean).join(' ') || undefined
const editable = source === EnvVarValueSourceEnum.ENV_VAR_VALUE_SOURCE_CUSTOM
const inputType =
editable && slot.value_type === EnvVarValueType.ENV_VAR_VALUE_TYPE_SECRET
@@ -136,7 +143,8 @@ export const EnvironmentVariableField = memo(
}
return (
- <div className="flex flex-col gap-1">
+ <fieldset className="flex min-w-0 flex-col gap-1">
+ <legend className="sr-only">{slot.key}</legend>
<div className="flex min-w-0 items-center gap-2">
<div className="flex min-w-0 grow items-center gap-1">
<span
@@ -148,7 +156,11 @@ export const EnvironmentVariableField = memo(
{slot.key}
</span>
) : (
- <label htmlFor={inputId} className="truncate system-sm-medium text-text-primary">
+ <label
+ id={labelId}
+ htmlFor={inputId}
+ className="truncate system-sm-medium text-text-primary"
+ >
{slot.key}
</label>
)}
@@ -189,7 +201,14 @@ export const EnvironmentVariableField = memo(
</Select>
</div>
{isLLM ? (
- <div role="group" aria-labelledby={labelId} className="flex w-full min-w-0">
+ <div
+ id={inputId}
+ tabIndex={-1}
+ role="group"
+ aria-labelledby={labelId}
+ aria-describedby={describedBy}
+ className="flex w-full min-w-0 outline-hidden focus-visible:ring-2 focus-visible:ring-state-accent-solid"
+ >
<LLMEnvironmentVariableValueField
disabled={!editable}
requiredMode={requiredLLMMode}
@@ -205,6 +224,9 @@ export const EnvironmentVariableField = memo(
) : (
<Input
id={inputId}
+ aria-describedby={describedBy}
+ aria-invalid={Boolean(error)}
+ step={inputType === 'number' ? 'any' : undefined}
type={inputType}
value={editable && typeof customValue === 'string' ? customValue : ''}
placeholder={placeholder}
@@ -219,9 +241,16 @@ export const EnvironmentVariableField = memo(
/>
)}
{slot.description && (
- <p className="system-xs-regular text-text-tertiary">{slot.description}</p>
+ <p id={descriptionId} className="system-xs-regular text-text-tertiary">
+ {slot.description}
+ </p>
+ )}
+ {error && (
+ <p id={errorId} role="alert" className="system-xs-regular text-text-destructive">
+ {error}
+ </p>
)}
- </div>
+ </fieldset>
)
},
)
diff --git a/web/app/components/app/deploy/shared/deployment-configuration/environment-variables-section.tsx b/web/app/components/app/deploy/shared/deployment-configuration/environment-variables-section.tsx
index c6559db0fd1..54f3864193e 100644
--- a/web/app/components/app/deploy/shared/deployment-configuration/environment-variables-section.tsx
+++ b/web/app/components/app/deploy/shared/deployment-configuration/environment-variables-section.tsx
@@ -1,18 +1,22 @@
import type { EnvironmentVariableGroup } from '@dify/contracts/enterprise-app-deploy/types.gen'
import type { DeploymentConfigurationValuesController } from './use-deployment-configuration-values'
+import type { DeploymentFieldError } from './utils/field-id'
import { cn } from '@langgenius/dify-ui/cn'
import { memo } from 'react'
import { useTranslation } from 'react-i18next'
import { EnvironmentVariableField } from './environment-variable-field'
import { SectionHeading } from './section-heading'
+import { environmentVariableFieldId } from './utils/field-id'
import { SubworkflowSourceTitle, WorkflowReferenceIcon } from './workflow-source-popover'
function EnvironmentVariableGroupFields({
group,
+ fieldError,
getEnvironmentVariableSelection,
setEnvironmentVariableSelection,
}: {
group: EnvironmentVariableGroup
+ fieldError?: DeploymentFieldError
getEnvironmentVariableSelection: DeploymentConfigurationValuesController['getEnvironmentVariableSelection']
setEnvironmentVariableSelection: DeploymentConfigurationValuesController['setEnvironmentVariableSelection']
}) {
@@ -38,6 +42,11 @@ function EnvironmentVariableGroupFields({
<div className="flex min-w-0 flex-1 flex-col gap-4">
{group.environment_variable_slots.map((slot) => (
<EnvironmentVariableField
+ error={
+ fieldError?.fieldId === environmentVariableFieldId(owner.workflow_id, slot.key)
+ ? fieldError.message
+ : undefined
+ }
key={`${owner.workflow_id}:${slot.key}:${slot.has_configured_value}:${slot.has_last_deployed_value}`}
slot={slot}
workflowId={owner.workflow_id}
@@ -54,12 +63,14 @@ function EnvironmentVariableGroupFields({
export const EnvironmentVariablesSection = memo(
({
environmentVariableGroups,
+ fieldError,
getEnvironmentVariableSelection,
hasCredentialSlots,
horizontalPaddingClassName,
setEnvironmentVariableSelection,
}: {
environmentVariableGroups: EnvironmentVariableGroup[]
+ fieldError?: DeploymentFieldError
getEnvironmentVariableSelection: DeploymentConfigurationValuesController['getEnvironmentVariableSelection']
hasCredentialSlots: boolean
horizontalPaddingClassName: string
@@ -90,6 +101,7 @@ export const EnvironmentVariablesSection = memo(
return (
<EnvironmentVariableGroupFields
+ fieldError={fieldError}
key={owner.workflow_id}
group={group}
getEnvironmentVariableSelection={getEnvironmentVariableSelection}
diff --git a/web/app/components/app/deploy/shared/deployment-configuration/index.tsx b/web/app/components/app/deploy/shared/deployment-configuration/index.tsx
index 704cde9058c..5edd2920ecb 100644
--- a/web/app/components/app/deploy/shared/deployment-configuration/index.tsx
+++ b/web/app/components/app/deploy/shared/deployment-configuration/index.tsx
@@ -1,4 +1,5 @@
'use client'
+import type { RefObject } from 'react'
import type { DeploymentDialogRequest } from '../../types'
import type { DeploymentVersion } from '../../utils/version'
import { Button } from '@langgenius/dify-ui/button'
@@ -13,6 +14,7 @@ import { useDeploymentConfigurationValues } from './use-deployment-configuration
export function DeploymentConfiguration({
appId,
+ titleRef,
disabled = false,
embedded = false,
invalidateAppEnvironmentsOnSuccess = true,
@@ -23,6 +25,7 @@ export function DeploymentConfiguration({
onDeploymentStarted,
}: {
appId?: string
+ titleRef?: RefObject<HTMLHeadingElement | null>
disabled?: boolean
embedded?: boolean
invalidateAppEnvironmentsOnSuccess?: boolean
@@ -40,20 +43,21 @@ export function DeploymentConfiguration({
environmentId: request.environmentId,
workflowId: version.id,
})
- const { canDeploy, handleSubmit, isDeploying } = useDeploymentConfigurationForm({
- appId,
- configurationValues,
- disabled,
- environmentId: request.environmentId,
- invalidateAppEnvironmentsOnSuccess,
- queryState,
- workflowId: version.id,
- onClose,
- onDeploymentStarted,
- })
+ const { canDeploy, clearFieldError, fieldError, formRef, handleSubmit, isDeploying } =
+ useDeploymentConfigurationForm({
+ appId,
+ configurationValues,
+ disabled,
+ environmentId: request.environmentId,
+ invalidateAppEnvironmentsOnSuccess,
+ queryState,
+ workflowId: version.id,
+ onClose,
+ onDeploymentStarted,
+ })
return (
- <form className="flex min-h-0 flex-1 flex-col" onSubmit={handleSubmit}>
+ <form ref={formRef} className="flex min-h-0 flex-1 flex-col" onSubmit={handleSubmit}>
{!embedded && (
<DialogClose
render={
@@ -86,15 +90,19 @@ export function DeploymentConfiguration({
{t(($) => $['studio.deployConfiguration'])}
</h2>
) : (
- <DialogTitle className="mt-0.5 px-1">
- {t(($) => $['studio.deployConfiguration'])}
- </DialogTitle>
+ <div className="mt-0.5 px-1">
+ <DialogTitle ref={titleRef} tabIndex={-1}>
+ {t(($) => $['studio.deployConfiguration'])}
+ </DialogTitle>
+ </div>
)}
</header>
<DeploymentConfigurationContent
compact={embedded}
configurationValues={configurationValues}
+ fieldError={fieldError}
+ onConfigurationChange={clearFieldError}
queryState={queryState}
request={request}
version={version}
@@ -106,9 +114,15 @@ export function DeploymentConfiguration({
embedded ? 'px-4 pt-2 pb-4' : 'px-6 pt-5 pb-6',
)}
>
- <Button type="button" variant="secondary" onClick={onClose}>
- {tCommon(($) => $['operation.cancel'])}
- </Button>
+ {embedded ? (
+ <Button type="button" variant="secondary" onClick={onClose}>
+ {tCommon(($) => $['operation.cancel'])}
+ </Button>
+ ) : (
+ <DialogClose render={<Button type="button" variant="secondary" />}>
+ {tCommon(($) => $['operation.cancel'])}
+ </DialogClose>
+ )}
<Button type="submit" variant="primary" disabled={!canDeploy} loading={isDeploying}>
{tCommon(($) => $['appMenus.deploy'])}
</Button>
diff --git a/web/app/components/app/deploy/shared/deployment-configuration/use-deployment-configuration-form.ts b/web/app/components/app/deploy/shared/deployment-configuration/use-deployment-configuration-form.ts
index 42755f5439b..d5a20c628d3 100644
--- a/web/app/components/app/deploy/shared/deployment-configuration/use-deployment-configuration-form.ts
+++ b/web/app/components/app/deploy/shared/deployment-configuration/use-deployment-configuration-form.ts
@@ -3,11 +3,13 @@
import type { FormEventHandler } from 'react'
import type { DeploymentConfigurationQueryState } from './use-deployment-configuration-queries'
import type { DeploymentConfigurationValuesController } from './use-deployment-configuration-values'
+import type { DeploymentFieldError } from './utils/field-id'
+import { useLayoutEffect, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { toast } from '@/app/notifications'
import { useDeployWorkflow } from '../../hooks/use-deploy-workflow'
+import { credentialFieldId, environmentVariableFieldId } from './utils/field-id'
import {
- credentialProviderName,
findInvalidDeploymentCredential,
findInvalidDeploymentEnvironmentVariable,
hasValidDeploymentEnvironmentVariables,
@@ -38,6 +40,12 @@ export function useDeploymentConfigurationForm({
const { t: tCommon } = useTranslation(['common'])
const { t: tDeployments } = useTranslation(['deployments'])
const { t: tWorkflow } = useTranslation(['workflow'])
+ const [fieldError, setFieldError] = useState<DeploymentFieldError>()
+ const formRef = useRef<HTMLFormElement | null>(null)
+ useLayoutEffect(() => {
+ if (fieldError)
+ formRef.current?.querySelector<HTMLElement>(`[id="${fieldError.fieldId}"]`)?.focus()
+ }, [fieldError])
const deployMutation = useDeployWorkflow({
appId,
invalidateAppEnvironmentsOnSuccess,
@@ -58,13 +66,13 @@ export function useDeploymentConfigurationForm({
values.credentials,
)
if (invalidCredential) {
- toast.error(
- `${credentialProviderName(invalidCredential.provider_id)}: ${
+ setFieldError({
+ fieldId: credentialFieldId(invalidCredential),
+ message:
invalidCredential.candidates.length === 0
? tDeployments(($) => $['deployDrawer.noCredentialCandidates'])
- : tDeployments(($) => $['deployDrawer.selectCredential'])
- }`,
- )
+ : tDeployments(($) => $['deployDrawer.selectCredential']),
+ })
return
}
@@ -73,11 +81,13 @@ export function useDeploymentConfigurationForm({
values,
)
if (invalidEnvironmentVariable) {
- toast.error(
- `${invalidEnvironmentVariable.owner.name} · ${invalidEnvironmentVariable.slot.key}: ${tWorkflow(
- ($) => $['env.modal.valueRequired'],
- )}`,
- )
+ setFieldError({
+ fieldId: environmentVariableFieldId(
+ invalidEnvironmentVariable.owner.workflow_id,
+ invalidEnvironmentVariable.slot.key,
+ ),
+ message: tWorkflow(($) => $['env.modal.valueRequired']),
+ })
return
}
@@ -104,6 +114,9 @@ export function useDeploymentConfigurationForm({
return {
canDeploy,
+ clearFieldError: () => setFieldError(undefined),
+ fieldError,
+ formRef,
handleSubmit,
isDeploying: deployMutation.isPending,
}
diff --git a/web/app/components/app/deploy/shared/deployment-configuration/utils/field-id.ts b/web/app/components/app/deploy/shared/deployment-configuration/utils/field-id.ts
new file mode 100644
index 00000000000..eb85bf36e0f
--- /dev/null
+++ b/web/app/components/app/deploy/shared/deployment-configuration/utils/field-id.ts
@@ -0,0 +1,15 @@
+import type { CredentialSlot } from '@dify/contracts/enterprise-app-deploy/types.gen'
+import { credentialSlotKey } from './workflow-deployment-input'
+
+export function credentialFieldId(slot: CredentialSlot) {
+ return `deployment-credential-${encodeURIComponent(credentialSlotKey(slot))}`
+}
+
+export function environmentVariableFieldId(workflowId: string, key: string) {
+ return `deployment-env-${encodeURIComponent(JSON.stringify([workflowId, key]))}`
+}
+
+export type DeploymentFieldError = {
+ fieldId: string
+ message: string
+}
diff --git a/web/app/components/app/deploy/shared/deployment-configuration/workflow-source-popover.tsx b/web/app/components/app/deploy/shared/deployment-configuration/workflow-source-popover.tsx
index 72f3e57e832..e410e37e6f6 100644
--- a/web/app/components/app/deploy/shared/deployment-configuration/workflow-source-popover.tsx
+++ b/web/app/components/app/deploy/shared/deployment-configuration/workflow-source-popover.tsx
@@ -105,7 +105,7 @@ export function WorkflowDependencyPreview({
render={
<button
type="button"
- className="group/source flex min-w-0 shrink-0 cursor-help items-center gap-1 rounded-sm"
+ className="group/source flex min-h-6 min-w-0 shrink-0 cursor-help items-center gap-1 rounded-sm outline-hidden focus-visible:ring-2 focus-visible:ring-state-accent-solid"
>
<span className="sr-only">{subjectName}: </span>
<span className="shrink-0 system-xs-regular text-text-tertiary">
@@ -143,7 +143,7 @@ export function SubworkflowSourceTitle({ source }: { source: WorkflowAsToolSourc
render={
<button
type="button"
- className="group/source max-w-full min-w-0 cursor-help truncate rounded-sm border-b border-dotted border-text-quaternary text-start system-sm-semibold text-text-primary hover:text-text-secondary data-popup-open:text-text-secondary"
+ className="group/source min-h-6 max-w-full min-w-0 cursor-help truncate rounded-sm border-b border-dotted border-text-quaternary text-start system-sm-semibold text-text-primary outline-hidden hover:text-text-secondary focus-visible:ring-2 focus-visible:ring-state-accent-solid data-popup-open:text-text-secondary"
>
{workflow.name}
</button>
diff --git a/web/app/components/app/deploy/shared/runtime-state.tsx b/web/app/components/app/deploy/shared/runtime-state.tsx
index c1a364d7364..d8fb9716826 100644
--- a/web/app/components/app/deploy/shared/runtime-state.tsx
+++ b/web/app/components/app/deploy/shared/runtime-state.tsx
@@ -14,11 +14,11 @@ type RuntimeStateIndicatorProps = {
const RUNTIME_STATE_TEXT_CLASS_NAMES: Record<RuntimeStateValue, string> = {
[RuntimeState.RUNTIME_STATE_UNSPECIFIED]: 'text-text-tertiary',
[RuntimeState.RUNTIME_STATE_UNDEPLOYED]: 'text-text-tertiary',
- [RuntimeState.RUNTIME_STATE_RUNNING]: 'text-util-colors-green-green-600',
- [RuntimeState.RUNTIME_STATE_STARTING]: 'text-util-colors-blue-light-blue-light-600',
- [RuntimeState.RUNTIME_STATE_STOPPING]: 'text-util-colors-blue-light-blue-light-600',
- [RuntimeState.RUNTIME_STATE_ERROR]: 'text-util-colors-red-red-600',
- [RuntimeState.RUNTIME_STATE_UNKNOWN]: 'text-text-warning',
+ [RuntimeState.RUNTIME_STATE_RUNNING]: 'text-util-colors-green-green-700',
+ [RuntimeState.RUNTIME_STATE_STARTING]: 'text-util-colors-blue-light-blue-light-700',
+ [RuntimeState.RUNTIME_STATE_STOPPING]: 'text-util-colors-blue-light-blue-light-700',
+ [RuntimeState.RUNTIME_STATE_ERROR]: 'text-util-colors-red-red-700',
+ [RuntimeState.RUNTIME_STATE_UNKNOWN]: 'text-util-colors-orange-orange-700',
}
const RUNTIME_STATE_DOT: Partial<Record<RuntimeStateValue, StatusDotStatus>> = {
diff --git a/web/app/components/app/deploy/shared/version-label.tsx b/web/app/components/app/deploy/shared/version-label.tsx
index 002d8557640..bdad078a3ca 100644
--- a/web/app/components/app/deploy/shared/version-label.tsx
+++ b/web/app/components/app/deploy/shared/version-label.tsx
@@ -49,7 +49,7 @@ export function VersionLabel({
render={
<button
type="button"
- className="min-w-0 cursor-help truncate border-b border-dotted border-text-quaternary system-md-medium text-text-secondary"
+ className="min-h-6 min-w-0 cursor-help truncate rounded-sm border-b border-dotted border-text-quaternary system-md-medium text-text-secondary outline-hidden focus-visible:ring-2 focus-visible:ring-state-accent-solid"
>
{name}
</button>
@@ -93,7 +93,7 @@ export function VersionLabel({
<button
type="button"
aria-label={versionsBehindLabel}
- className="inline-flex h-4.5 shrink-0 cursor-default items-center rounded-[5px] border border-util-colors-orange-orange-500 px-1 system-2xs-medium text-util-colors-orange-orange-600 outline-hidden focus-visible:ring-1 focus-visible:ring-state-accent-solid"
+ className="inline-flex min-h-6 min-w-6 shrink-0 cursor-default items-center justify-center rounded-[5px] border border-util-colors-orange-orange-500 px-1 system-2xs-medium text-util-colors-orange-orange-700 outline-hidden focus-visible:ring-2 focus-visible:ring-state-accent-solid"
>
<span aria-hidden className="i-ri-arrow-up-line size-3" />
{behind}
diff --git a/web/app/components/app/deploy/shared/version-selection/index.tsx b/web/app/components/app/deploy/shared/version-selection/index.tsx
index 86fce5d74e2..ffbb7de0f52 100644
--- a/web/app/components/app/deploy/shared/version-selection/index.tsx
+++ b/web/app/components/app/deploy/shared/version-selection/index.tsx
@@ -1,4 +1,5 @@
'use client'
+import type { RefObject } from 'react'
import type { DeploymentDialogRequest } from '../../types'
import type { DeploymentVersion } from '../../utils/version'
import { Button } from '@langgenius/dify-ui/button'
@@ -13,10 +14,12 @@ function versionSelectionTitle(request: DeploymentDialogRequest, deployTo: strin
export function VersionSelection({
appId,
+ titleRef,
request,
onSelect,
}: {
appId: string
+ titleRef: RefObject<HTMLHeadingElement | null>
request: DeploymentDialogRequest
onSelect: (version: DeploymentVersion) => void
}) {
@@ -43,10 +46,12 @@ export function VersionSelection({
}
/>
<header className="shrink-0 px-6 pt-6 pr-14 pb-3">
- <DialogTitle>{title}</DialogTitle>
- <DialogDescription className="mt-1">
- {t(($) => $['studio.chooseVersionToDeploy'])}
- </DialogDescription>
+ <DialogTitle ref={titleRef} tabIndex={-1}>
+ {title}
+ </DialogTitle>
+ <div className="mt-1">
+ <DialogDescription>{t(($) => $['studio.chooseVersionToDeploy'])}</DialogDescription>
+ </div>
</header>
<VersionList
className="px-4 pt-2 pb-4"
diff --git a/web/app/components/app/deploy/types.ts b/web/app/components/app/deploy/types.ts
index e60ec089656..943f3cc9b8d 100644
--- a/web/app/components/app/deploy/types.ts
+++ b/web/app/components/app/deploy/types.ts
@@ -16,3 +16,8 @@ type ConfigurationRequest = {
}
export type DeploymentDialogRequest = ConfigurationRequest | VersionSelectionRequest
+
+export type OpenDeploymentDialog = (
+ request: DeploymentDialogRequest,
+ returnFocusElement: HTMLElement | null,
+) => void
diff --git a/web/app/components/header/account-setting/__tests__/settings-modal.spec.tsx b/web/app/components/header/account-setting/__tests__/settings-modal.spec.tsx
index 48f680f127c..3245a2a320f 100644
--- a/web/app/components/header/account-setting/__tests__/settings-modal.spec.tsx
+++ b/web/app/components/header/account-setting/__tests__/settings-modal.spec.tsx
@@ -117,7 +117,11 @@ function renderSettings(
return { ...rendered, onUrlUpdate }
}
-const findSettings = () => screen.findByRole('dialog', { name: 'navigation.settings.settings' })
+const findSettings = async () => {
+ // The settings surface is lazy; finish loading it before starting the DOM query timeout.
+ await act(async () => vi.dynamicImportSettled())
+ return screen.findByRole('dialog', { name: 'navigation.settings.settings' })
+}
const expectMembers = () =>
screen.findByRole('columnheader', { name: 'workspaceMembers.members.name' })
diff --git a/web/app/components/header/account-setting/model-provider-page/model-selector/model-selector-trigger.tsx b/web/app/components/header/account-setting/model-provider-page/model-selector/model-selector-trigger.tsx
index 03a0eb91b8d..97e83274f53 100644
--- a/web/app/components/header/account-setting/model-provider-page/model-selector/model-selector-trigger.tsx
+++ b/web/app/components/header/account-setting/model-provider-page/model-selector/model-selector-trigger.tsx
@@ -128,6 +128,7 @@ function ModelSelectorTrigger({
className={cn(
'group/model-selector-trigger flex w-full min-w-0 items-center border-0 bg-components-input-bg-normal text-left text-components-input-text-filled transition-colors',
'hover:bg-state-base-hover-alt focus-visible:bg-state-base-hover-alt data-popup-open:bg-state-base-hover-alt',
+ 'focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden',
'disabled:cursor-not-allowed disabled:text-components-input-text-filled-disabled motion-reduce:transition-none',
'data-[size=small]:h-6 data-[size=small]:gap-px data-[size=small]:rounded-md data-[size=small]:p-0.5',
'data-[size=medium]:h-8 data-[size=medium]:gap-0.5 data-[size=medium]:rounded-lg data-[size=medium]:p-1',
@@ -200,7 +201,7 @@ function ModelSelectorTrigger({
</span>
)}
{isEmpty && (
- <span className="grow truncate text-[13px] text-components-input-text-placeholder">
+ <span className="grow truncate text-[13px] text-text-secondary group-disabled/model-selector-trigger:text-components-input-text-placeholder">
{t(($) => $['detailPanel.configureModel'], { ns: 'plugin' })}
</span>
)}
diff --git a/web/app/components/header/account-setting/model-provider-page/model-selector/popup-item.tsx b/web/app/components/header/account-setting/model-provider-page/model-selector/popup-item.tsx
index 219ef05144b..4a9587b6d9c 100644
--- a/web/app/components/header/account-setting/model-provider-page/model-selector/popup-item.tsx
+++ b/web/app/components/header/account-setting/model-provider-page/model-selector/popup-item.tsx
@@ -264,7 +264,7 @@ function PopupItem({
</>
)
const row = needsConfiguration ? (
- <div className={rowClassName} onPointerDown={onPreviewCardClose}>
+ <div className={rowClassName}>
{rowContent}
{canCreateCredential && (
<Button
@@ -284,7 +284,6 @@ function PopupItem({
aria-current={isSelected ? 'true' : undefined}
disabled={!isSelectable}
className={cn(rowClassName, 'w-[calc(100%-0.5rem)] justify-start')}
- onPointerDown={onPreviewCardClose}
onClick={() => onSelect(model.provider, modelItem)}
>
{rowContent}
@@ -294,6 +293,7 @@ function PopupItem({
return (
<li key={modelItem.model}>
<PreviewCardTrigger
+ onPointerDown={onPreviewCardClose}
delay={150}
closeDelay={150}
handle={previewCardHandle}
diff --git a/web/package.json b/web/package.json
index 485a2a25aa9..fc7d675aa3d 100644
--- a/web/package.json
+++ b/web/package.json
@@ -178,6 +178,7 @@
"@vitest/browser-playwright": "catalog:",
"@vitest/coverage-v8": "catalog:",
"agentation": "catalog:",
+ "axe-core": "catalog:",
"code-inspector-plugin": "catalog:",
"happy-dom": "catalog:",
"i18next-resources-for-ts": "catalog:",