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.

refactor(dify-ui): scroll dialog bodies and give AlertDialog a body (#44248)

yyh1a79410ab1d4
diff --git a/lint.config.ts b/lint.config.ts
index fbb2bad8498..23f7fb2628d 100644
--- a/lint.config.ts
+++ b/lint.config.ts
@@ -31,39 +31,17 @@ export const stylingContractRules = {
},
{
pattern: '^(Dialog|AlertDialog)Content$',
- // A fixed-height surface may stop scrolling itself (`overflow-hidden`) and hand its
- // remaining height to content that scrolls (`flex flex-col`).
- allow: [
- 'w-*',
- 'min-w-*',
- 'max-w-*',
- 'h-*',
- 'min-h-*',
- 'max-h-*',
- 'flex',
- 'flex-col',
- 'overflow-hidden',
- ],
- deny: [
- 'flex-1',
- 'flex-auto',
- 'flex-initial',
- 'flex-none',
- 'flex-row',
- 'flex-row-reverse',
- 'flex-col-reverse',
- 'flex-wrap',
- 'flex-nowrap',
- ],
+ allow: ['w-*', 'min-w-*', 'max-w-*', 'h-*', 'min-h-*', 'max-h-*', 'overflow-hidden'],
+ deny: ['max-w-none', 'max-h-none', 'w-screen', 'h-screen'],
message:
- '"{{className}}" is outside the {{component}} styling contract. The surface owns position, chrome and scrolling, and its parts own spacing; callers may only size it. Compose DialogPortal, DialogBackdrop and DialogPopup for a custom surface.',
+ '"{{className}}" is outside the {{component}} styling contract. The surface owns position, chrome and scrolling, and its parts own spacing; callers may only size it within the viewport. Compose DialogPortal, DialogBackdrop and DialogPopup for a custom surface.',
},
{
pattern: '^DialogPopup$',
allow: ['*'],
deny: ['top-1/2', 'left-1/2', '-translate-x-1/2', '-translate-y-1/2'],
message:
- '"{{className}}" recreates the DialogContent centering. Use DialogContent for a centered dialog; DialogPopup is for a surface that places itself.',
+ '"{{className}}" recreates the DialogContent centering. Use DialogContent for a centered dialog; DialogPopup is the bare dialog element for a surface that places and dresses itself.',
},
{
pattern: '^(Dialog|AlertDialog)(Title|Description)$',
@@ -84,10 +62,11 @@ export const stylingContractRules = {
'"{{className}}" is outside the DialogFooter styling contract. The footer owns its spacing and alignment; callers may stack full-width actions.',
},
{
- pattern: '^DialogBody$',
+ pattern: '^(Dialog|AlertDialog)Body$',
allow: ['layout', 'gap-*', 'space-x-*', 'space-y-*'],
+ deny: ['flex-1', 'flex-auto', 'flex-initial', 'flex-none', 'overflow-*'],
message:
- '"{{className}}" is outside the DialogBody styling contract. The body owns the content gutter; callers may lay out its content.',
+ '"{{className}}" is outside the {{component}} styling contract. The body owns the content gutter and scrolls between the header and footer; callers may lay out its content.',
},
],
},
diff --git a/oxlint-suppressions.json b/oxlint-suppressions.json
index 995e07092cc..f6326871a7b 100644
--- a/oxlint-suppressions.json
+++ b/oxlint-suppressions.json
@@ -55,11 +55,6 @@
"count": 2
}
},
- "web/app/account/(commonLayout)/delete-account/index.tsx": {
- "shadcn/no-restyle": {
- "count": 3
- }
- },
"web/app/components/app/annotation/add-annotation-modal/edit-item/index.tsx": {
"jsx-a11y/click-events-have-key-events": {
"count": 1
@@ -1627,11 +1622,6 @@
"count": 2
}
},
- "web/app/components/plugins/install-plugin/install-from-marketplace/index.tsx": {
- "shadcn/no-restyle": {
- "count": 2
- }
- },
"web/app/components/plugins/marketplace/home/home-trending.tsx": {
"jsx-a11y/no-static-element-interactions": {
"count": 1
diff --git a/packages/dify-ui/docs/overlays.md b/packages/dify-ui/docs/overlays.md
index 4eeee126179..0c2bb7a3d47 100644
--- a/packages/dify-ui/docs/overlays.md
+++ b/packages/dify-ui/docs/overlays.md
@@ -61,10 +61,15 @@ clipped, `display: none` or unmounted, and the shared positioner class turns tha
## Primitive semantics
-- Use `Dialog` for modal content that needs focus containment and scroll locking.
+- Use `Dialog` for modal content that needs focus containment and scroll locking. `DialogContent`
+ is the centered modal surface: compose `DialogHeader`, `DialogBody` and `DialogFooter` in it, and
+ `DialogBody` scrolls between the other two. A wrapper between the surface and its parts, such as
+ a form, keeps the flex chain with `contents`. `DialogPopup` is the bare dialog element for a
+ surface that places and dresses itself.
- Use `AlertDialog` only for a destructive or must-confirm decision requiring an explicit answer.
It blocks outside-press dismissal but still closes on Escape; cancel that close in
- `onOpenChange` when the answer must be explicit.
+ `onOpenChange` when the answer must be explicit. `AlertDialogHeader` holds the title and
+ description; anything the user fills in or reviews before answering goes in `AlertDialogBody`.
- Use `Drawer` for side-panel interactions that follow the drawer model.
- Use `DropdownMenu` for button-triggered action lists and `ContextMenu` for context actions.
A long action list filters with `DropdownMenuFilterProvider`; choosing a value is
diff --git a/packages/dify-ui/src/alert-dialog/index.stories.tsx b/packages/dify-ui/src/alert-dialog/index.stories.tsx
index e0cf7d15aa1..598121a91a4 100644
--- a/packages/dify-ui/src/alert-dialog/index.stories.tsx
+++ b/packages/dify-ui/src/alert-dialog/index.stories.tsx
@@ -1,8 +1,10 @@
import type { Meta, StoryObj } from '@storybook/react-vite'
+import type { AlertDialogActions } from '.'
import * as React from 'react'
import { expect, waitFor, within } from 'storybook/test'
import {
AlertDialog,
+ AlertDialogBody,
AlertDialogCancelButton,
AlertDialogConfirmButton,
AlertDialogContent,
@@ -11,11 +13,12 @@ import {
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
+ createAlertDialogHandle,
} from '.'
import { Button } from '../button'
-
-const triggerButtonClassName =
- 'rounded-lg border border-divider-subtle bg-components-button-secondary-bg px-3 py-1.5 text-sm text-text-secondary shadow-xs hover:bg-state-base-hover'
+import { Field, FieldLabel } from '../field'
+import { Form } from '../form'
+import { Input } from '../input'
const meta = {
title: 'Base/UI/AlertDialog',
@@ -24,8 +27,11 @@ const meta = {
layout: 'centered',
docs: {
description: {
- component:
- 'Compound alert dialog built on Base UI AlertDialog. Use it for destructive or high-risk confirmations that require an explicit user decision. Compose `AlertDialogTitle` and `AlertDialogDescription` in `AlertDialogHeader`, and the actions in `AlertDialogFooter` with `AlertDialogCancelButton` and `AlertDialogConfirmButton`.',
+ component: [
+ 'Compound alert dialog built on Base UI AlertDialog. Use it for a destructive or must-confirm decision that needs an explicit answer: an outside press does not dismiss it, only Escape, `AlertDialogCancelButton` or your confirm action do. Compose `AlertDialogTitle` and `AlertDialogDescription` in `AlertDialogHeader`, anything the user fills in or reviews before answering in `AlertDialogBody`, and the actions in `AlertDialogFooter`.',
+ '',
+ '`AlertDialogCancelButton` closes on its own. `AlertDialogConfirmButton` is a primary destructive button that only runs your handler; close it afterwards through `actionsRef`, a handle, or controlled `open`. Pass `tone="default"` when the confirmation is not destructive.',
+ ].join('\n'),
},
},
},
@@ -38,7 +44,7 @@ type Story = StoryObj<typeof meta>
export const Default: Story = {
render: () => (
<AlertDialog>
- <AlertDialogTrigger render={<button type="button" className={triggerButtonClassName} />}>
+ <AlertDialogTrigger render={<Button variant="secondary" tone="destructive" />}>
Delete project
</AlertDialogTrigger>
<AlertDialogContent>
@@ -60,122 +66,154 @@ export const Default: Story = {
const body = within(canvasElement.ownerDocument.body)
await userEvent.click(canvas.getByRole('button', { name: 'Delete project' }))
-
- const dialog = body.getByRole('alertdialog', { name: 'Delete project?' })
+ const dialog = await body.findByRole('alertdialog', { name: 'Delete project?' })
await waitFor(async () => {
await expect(dialog).toBeVisible()
})
- await userEvent.click(body.getByRole('button', { name: 'Delete' }))
- await expect(dialog).toBeVisible()
+ await userEvent.click(canvasElement.ownerDocument.body)
+ await expect(dialog).toHaveAttribute('data-open')
- await userEvent.click(body.getByRole('button', { name: 'Cancel' }))
+ await userEvent.click(within(dialog).getByRole('button', { name: 'Cancel' }))
await waitFor(async () => {
- await expect(
- body.queryByRole('alertdialog', { name: 'Delete project?' }),
- ).not.toBeInTheDocument()
+ await expect(body.queryByRole('alertdialog')).not.toBeInTheDocument()
})
+ await expect(canvas.getByRole('button', { name: 'Delete project' })).toHaveFocus()
},
}
-export const NonDestructive: Story = {
- render: () => (
- <AlertDialog>
- <AlertDialogTrigger render={<button type="button" className={triggerButtonClassName} />}>
- Publish changes
+function TypeToConfirmDemo() {
+ const [value, setValue] = React.useState('')
+ const actionsRef = React.useRef<AlertDialogActions>(null)
+
+ return (
+ <AlertDialog actionsRef={actionsRef}>
+ <AlertDialogTrigger render={<Button variant="secondary" tone="destructive" />}>
+ Delete workspace
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
- <AlertDialogTitle>Publish the latest draft?</AlertDialogTitle>
+ <AlertDialogTitle>Delete this workspace?</AlertDialogTitle>
<AlertDialogDescription>
- Collaborators will immediately see the new workflow. You can still revert from version
- history.
+ Deleting the workspace is irreversible. Members lose access and every app in it is
+ permanently removed.
</AlertDialogDescription>
</AlertDialogHeader>
- <AlertDialogFooter>
- <AlertDialogCancelButton variant="secondary">Not now</AlertDialogCancelButton>
- <AlertDialogConfirmButton tone="default">Publish</AlertDialogConfirmButton>
- </AlertDialogFooter>
+ <Form className="contents" onFormSubmit={() => actionsRef.current?.close()}>
+ <AlertDialogBody>
+ <Field name="confirm">
+ <FieldLabel>To confirm, type Acme in the box below:</FieldLabel>
+ <Input placeholder="Enter workspace name..." value={value} onValueChange={setValue} />
+ </Field>
+ </AlertDialogBody>
+ <AlertDialogFooter>
+ <AlertDialogCancelButton variant="secondary">Cancel</AlertDialogCancelButton>
+ <AlertDialogConfirmButton type="submit" disabled={value !== 'Acme'}>
+ Delete
+ </AlertDialogConfirmButton>
+ </AlertDialogFooter>
+ </Form>
</AlertDialogContent>
</AlertDialog>
- ),
+ )
}
-export const LongObjectName: Story = {
- render: () => (
- <AlertDialog>
- <AlertDialogTrigger render={<button type="button" className={triggerButtonClassName} />}>
- Delete knowledge base
- </AlertDialogTrigger>
+export const TypeToConfirm: Story = {
+ parameters: {
+ docs: {
+ description: {
+ story:
+ 'The field sits in `AlertDialogBody` and receives initial focus. The confirm is the form submit, disabled until the typed name matches, so Enter cannot confirm early; `onFormSubmit` closes through `actionsRef`.',
+ },
+ },
+ },
+ render: () => <TypeToConfirmDemo />,
+ play: async ({ canvas, canvasElement, userEvent }) => {
+ const body = within(canvasElement.ownerDocument.body)
+
+ await userEvent.click(canvas.getByRole('button', { name: 'Delete workspace' }))
+ const dialog = await body.findByRole('alertdialog', { name: 'Delete this workspace?' })
+ const input = within(dialog).getByRole('textbox', { name: /To confirm/ })
+ await waitFor(async () => {
+ await expect(input).toHaveFocus()
+ })
+ const confirmButton = within(dialog).getByRole('button', { name: 'Delete' })
+ await expect(confirmButton).toBeDisabled()
+
+ await userEvent.type(input, 'Acm')
+ await userEvent.keyboard('{Enter}')
+ await expect(confirmButton).toBeDisabled()
+ await expect(dialog).toHaveAttribute('data-open')
+
+ await userEvent.type(input, 'e')
+ await waitFor(async () => {
+ await expect(confirmButton).toBeEnabled()
+ })
+
+ await userEvent.keyboard('{Enter}')
+ await waitFor(async () => {
+ await expect(body.queryByRole('alertdialog')).not.toBeInTheDocument()
+ })
+ },
+}
+
+function NonDestructiveDemo() {
+ const actionsRef = React.useRef<AlertDialogActions>(null)
+
+ return (
+ <AlertDialog actionsRef={actionsRef}>
+ <AlertDialogTrigger render={<Button variant="primary" />}>Publish changes</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
- <AlertDialogTitle>
- Delete “Customer support escalation playbook for enterprise accounts (2026 Q3)”?
- </AlertDialogTitle>
+ <AlertDialogTitle>Publish the latest draft?</AlertDialogTitle>
<AlertDialogDescription>
- {
- 'Documents, segments, and retrieval settings will be removed.\nApps that use this knowledge base will stop retrieving from it.'
- }
+ Collaborators will immediately see the new workflow. You can still revert from version
+ history.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
- <AlertDialogCancelButton>Cancel</AlertDialogCancelButton>
- <AlertDialogConfirmButton>Delete</AlertDialogConfirmButton>
+ <AlertDialogCancelButton variant="secondary">Not now</AlertDialogCancelButton>
+ <AlertDialogConfirmButton tone="default" onClick={() => actionsRef.current?.close()}>
+ Publish
+ </AlertDialogConfirmButton>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
- ),
+ )
}
-function ControlledDemo() {
- const [open, setOpen] = React.useState(false)
- const [count, setCount] = React.useState(0)
+export const NonDestructive: Story = {
+ parameters: {
+ docs: {
+ description: {
+ story:
+ 'A must-confirm decision that is not destructive keeps the alert semantics and uses `tone="default"` on the confirm.',
+ },
+ },
+ },
+ render: () => <NonDestructiveDemo />,
+ play: async ({ canvas, canvasElement, userEvent }) => {
+ const body = within(canvasElement.ownerDocument.body)
- return (
- <div className="flex flex-col items-center gap-3">
- <Button variant="secondary" onClick={() => setOpen(true)}>
- Open controlled dialog
- </Button>
- <span className="text-xs text-text-tertiary">
- Confirmed
- {count} times
- </span>
- <AlertDialog open={open} onOpenChange={setOpen}>
- <AlertDialogContent>
- <AlertDialogHeader>
- <AlertDialogTitle>Revoke API token?</AlertDialogTitle>
- <AlertDialogDescription>
- Any integration using this token will immediately stop working. You can issue a new
- token afterwards.
- </AlertDialogDescription>
- </AlertDialogHeader>
- <AlertDialogFooter>
- <AlertDialogCancelButton variant="secondary">Keep token</AlertDialogCancelButton>
- <AlertDialogConfirmButton
- onClick={() => {
- setCount((prev) => prev + 1)
- setOpen(false)
- }}
- >
- Revoke
- </AlertDialogConfirmButton>
- </AlertDialogFooter>
- </AlertDialogContent>
- </AlertDialog>
- </div>
- )
-}
+ await userEvent.click(canvas.getByRole('button', { name: 'Publish changes' }))
+ const dialog = await body.findByRole('alertdialog', { name: 'Publish the latest draft?' })
+ await waitFor(async () => {
+ await expect(dialog).toBeVisible()
+ })
-export const Controlled: Story = {
- render: () => <ControlledDemo />,
+ await userEvent.click(within(dialog).getByRole('button', { name: 'Publish' }))
+ await waitFor(async () => {
+ await expect(body.queryByRole('alertdialog')).not.toBeInTheDocument()
+ })
+ },
}
-function LoadingConfirmDemo() {
- const [pending, setPending] = React.useState(false)
+function PendingConfirmDemo() {
const [open, setOpen] = React.useState(false)
+ const [pending, setPending] = React.useState(false)
const confirmLabelId = React.useId()
- const handleConfirm = () => {
+ function archive() {
setPending(true)
window.setTimeout(() => {
setPending(false)
@@ -184,8 +222,17 @@ function LoadingConfirmDemo() {
}
return (
- <AlertDialog open={open} onOpenChange={setOpen}>
- <AlertDialogTrigger render={<button type="button" className={triggerButtonClassName} />}>
+ <AlertDialog
+ open={open}
+ onOpenChange={(nextOpen, details) => {
+ if (!nextOpen && pending) {
+ details.cancel()
+ return
+ }
+ setOpen(nextOpen)
+ }}
+ >
+ <AlertDialogTrigger render={<Button variant="secondary" />}>
Archive workspace
</AlertDialogTrigger>
<AlertDialogContent>
@@ -204,7 +251,7 @@ function LoadingConfirmDemo() {
tone="default"
loading={pending}
aria-labelledby={confirmLabelId}
- onClick={handleConfirm}
+ onClick={archive}
>
<span id={confirmLabelId}>{pending ? 'Archiving…' : 'Archive'}</span>
</AlertDialogConfirmButton>
@@ -214,18 +261,150 @@ function LoadingConfirmDemo() {
)
}
-export const LoadingConfirm: Story = {
- render: () => <LoadingConfirmDemo />,
+export const PendingConfirm: Story = {
+ parameters: {
+ docs: {
+ description: {
+ story:
+ 'While the confirm is `loading`, Cancel is disabled and `onOpenChange` cancels Escape; the dialog closes itself once the action settles.',
+ },
+ },
+ },
+ render: () => <PendingConfirmDemo />,
play: async ({ canvas, canvasElement, userEvent }) => {
const body = within(canvasElement.ownerDocument.body)
await userEvent.click(canvas.getByRole('button', { name: 'Archive workspace' }))
- const confirmButton = body.getByRole('button', { name: 'Archive' })
+ const dialog = await body.findByRole('alertdialog', { name: 'Archive this workspace?' })
+ await waitFor(async () => {
+ await expect(dialog).toBeVisible()
+ })
+ const confirmButton = within(dialog).getByRole('button', { name: 'Archive' })
await userEvent.click(confirmButton)
-
- await expect(confirmButton).toHaveAccessibleName('Archiving…')
- await expect(confirmButton).toHaveAttribute('aria-disabled', 'true')
- await expect(confirmButton).not.toHaveAttribute('aria-busy')
+ await waitFor(async () => {
+ await expect(confirmButton).toHaveAccessibleName('Archiving…')
+ })
await expect(confirmButton).toHaveFocus()
+
+ await userEvent.keyboard('{Escape}')
+ await expect(dialog).toHaveAttribute('data-open')
+
+ await waitFor(
+ async () => {
+ await expect(body.queryByRole('alertdialog')).not.toBeInTheDocument()
+ },
+ { timeout: 3000 },
+ )
+ },
+}
+
+type ApiKeyPayload = {
+ name: string
+}
+
+const apiKeys = [
+ { name: 'Production' },
+ { name: 'Staging' },
+] as const satisfies readonly ApiKeyPayload[]
+
+function DetachedTriggersDemo() {
+ const [dialogHandle] = React.useState(() => createAlertDialogHandle<ApiKeyPayload>())
+
+ return (
+ <React.Fragment>
+ <ul className="flex w-96 flex-col divide-y divide-divider-subtle">
+ {apiKeys.map((apiKey) => (
+ <li key={apiKey.name} className="flex items-center justify-between gap-4 py-2">
+ <span className="system-sm-medium text-text-primary">{apiKey.name}</span>
+ <AlertDialogTrigger
+ handle={dialogHandle}
+ payload={apiKey}
+ render={<Button size="small" variant="ghost" tone="destructive" />}
+ >
+ Delete {apiKey.name}
+ </AlertDialogTrigger>
+ </li>
+ ))}
+ </ul>
+ <AlertDialog handle={dialogHandle}>
+ {({ payload }) => (
+ <AlertDialogContent>
+ <AlertDialogHeader>
+ <AlertDialogTitle>Delete the {payload?.name} key?</AlertDialogTitle>
+ <AlertDialogDescription>
+ Requests signed with this key will start failing immediately.
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogFooter>
+ <AlertDialogCancelButton variant="secondary">Cancel</AlertDialogCancelButton>
+ <AlertDialogConfirmButton onClick={() => dialogHandle.close()}>
+ Delete
+ </AlertDialogConfirmButton>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ )}
+ </AlertDialog>
+ </React.Fragment>
+ )
+}
+
+export const DetachedTriggers: Story = {
+ parameters: {
+ docs: {
+ description: {
+ story:
+ 'One alert dialog serves every row: each Delete is an `AlertDialogTrigger` bound to a `createAlertDialogHandle` with its row as `payload`.',
+ },
+ },
+ },
+ render: () => <DetachedTriggersDemo />,
+ play: async ({ canvas, canvasElement, userEvent }) => {
+ const body = within(canvasElement.ownerDocument.body)
+
+ await userEvent.click(canvas.getByRole('button', { name: 'Delete Staging' }))
+ const dialog = await body.findByRole('alertdialog', { name: 'Delete the Staging key?' })
+ await waitFor(async () => {
+ await expect(dialog).toBeVisible()
+ })
+
+ await userEvent.click(within(dialog).getByRole('button', { name: 'Delete' }))
+ await waitFor(async () => {
+ await expect(body.queryByRole('alertdialog')).not.toBeInTheDocument()
+ })
+ await expect(canvas.getByRole('button', { name: 'Delete Staging' })).toHaveFocus()
+ },
+}
+
+export const LongObjectName: Story = {
+ parameters: {
+ docs: {
+ description: {
+ story:
+ 'A user-named object wraps in the title, and a description with a line break keeps it.',
+ },
+ },
},
+ render: () => (
+ <AlertDialog>
+ <AlertDialogTrigger render={<Button variant="secondary" tone="destructive" />}>
+ Delete knowledge base
+ </AlertDialogTrigger>
+ <AlertDialogContent>
+ <AlertDialogHeader>
+ <AlertDialogTitle>
+ Delete “Customer support escalation playbook for enterprise accounts (2026 Q3)”?
+ </AlertDialogTitle>
+ <AlertDialogDescription>
+ {
+ 'Documents, segments, and retrieval settings will be removed.\nApps that use this knowledge base will stop retrieving from it.'
+ }
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogFooter>
+ <AlertDialogCancelButton variant="secondary">Cancel</AlertDialogCancelButton>
+ <AlertDialogConfirmButton>Delete</AlertDialogConfirmButton>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
+ ),
}
diff --git a/packages/dify-ui/src/alert-dialog/index.tsx b/packages/dify-ui/src/alert-dialog/index.tsx
index 065c95e6032..cbff1702729 100644
--- a/packages/dify-ui/src/alert-dialog/index.tsx
+++ b/packages/dify-ui/src/alert-dialog/index.tsx
@@ -6,7 +6,13 @@ import { AlertDialog as BaseAlertDialog } from '@base-ui/react/alert-dialog'
import { Button } from '../button'
import { cn } from '../cn'
import { focusRingClassName } from '../internal/focus'
-import { modalBackdropClassName, modalPopupAnimationClassName } from '../internal/overlay'
+import {
+ modalBackdropClassName,
+ modalPopupAnimationClassName,
+ modalStackClassName,
+ modalSurfaceClassName,
+ modalTitleClassName,
+} from '../internal/overlay'
import { resolveClassName } from '../internal/resolve-class-name'
const AlertDialog = BaseAlertDialog.Root
@@ -59,8 +65,9 @@ function AlertDialogContent({
<BaseAlertDialog.Popup
className={(state) =>
cn(
- // Radius, border and surface match DialogPopup; change both together.
- 'fixed top-1/2 left-1/2 max-h-[calc(100dvh-2rem)] w-120 max-w-[calc(100vw-2rem)] -translate-x-1/2 -translate-y-1/2 overflow-y-auto overscroll-contain rounded-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-lg',
+ 'fixed top-1/2 left-1/2 flex max-h-[calc(100dvh-2rem)] w-120 max-w-[calc(100vw-2rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-y-auto overscroll-none',
+ modalSurfaceClassName,
+ modalStackClassName,
modalPopupAnimationClassName,
resolveClassName(className, state),
)
@@ -76,7 +83,7 @@ function AlertDialogContent({
type AlertDialogHeaderProps = React.ComponentProps<'div'>
function AlertDialogHeader({ className, ...props }: AlertDialogHeaderProps) {
- return <div className={cn('flex flex-col gap-2 px-6 pt-6 pb-4', className)} {...props} />
+ return <div className={cn('flex shrink-0 flex-col gap-2 px-6 pt-6 pb-4', className)} {...props} />
}
type AlertDialogTitleProps = BaseAlertDialog.Title.Props
@@ -84,13 +91,7 @@ type AlertDialogTitleProps = BaseAlertDialog.Title.Props
function AlertDialogTitle({ className, ...props }: AlertDialogTitleProps) {
return (
<BaseAlertDialog.Title
- className={(state) =>
- cn(
- // Same look as DialogTitle; change both together.
- 'title-2xl-semi-bold wrap-break-word text-text-primary',
- resolveClassName(className, state),
- )
- }
+ className={(state) => cn(modalTitleClassName, resolveClassName(className, state))}
{...props}
/>
)
@@ -112,14 +113,17 @@ function AlertDialogDescription({ className, ...props }: AlertDialogDescriptionP
)
}
+type AlertDialogBodyProps = React.ComponentProps<'div'>
+
+function AlertDialogBody({ className, ...props }: AlertDialogBodyProps) {
+ return <div className={cn('px-6', className)} {...props} />
+}
+
type AlertDialogFooterProps = React.ComponentProps<'div'>
function AlertDialogFooter({ className, ...props }: AlertDialogFooterProps) {
return (
- <div
- className={cn('flex items-start justify-end gap-2 self-stretch p-6', className)}
- {...props}
- />
+ <div className={cn('flex shrink-0 items-center justify-end gap-2 p-6', className)} {...props} />
)
}
@@ -164,6 +168,7 @@ function AlertDialogConfirmButton({
export {
AlertDialog,
+ AlertDialogBody,
AlertDialogCancelButton,
AlertDialogConfirmButton,
AlertDialogContent,
@@ -177,6 +182,7 @@ export {
export type {
AlertDialogActions,
+ AlertDialogBodyProps,
AlertDialogCancelButtonProps,
AlertDialogChangeEventDetails,
AlertDialogChangeEventReason,
diff --git a/packages/dify-ui/src/dialog/index.stories.tsx b/packages/dify-ui/src/dialog/index.stories.tsx
index 3b21614f780..f3956e0bbf3 100644
--- a/packages/dify-ui/src/dialog/index.stories.tsx
+++ b/packages/dify-ui/src/dialog/index.stories.tsx
@@ -1,4 +1,5 @@
import type { Meta, StoryObj } from '@storybook/react-vite'
+import type { DialogActions } from '.'
import * as React from 'react'
import { expect, waitFor, within } from 'storybook/test'
import {
@@ -18,18 +19,21 @@ import {
DialogTrigger,
DialogViewport,
} from '.'
+import {
+ AlertDialog,
+ AlertDialogCancelButton,
+ AlertDialogConfirmButton,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogTitle,
+} from '../alert-dialog'
import { Button } from '../button'
-import { Field, FieldDescription, FieldError, FieldLabel } from '../field'
+import { Field, FieldError, FieldLabel } from '../field'
import { Form } from '../form'
-import { IconButton } from '../icon-button'
import { Input } from '../input'
-import {
- ScrollArea,
- ScrollAreaContent,
- ScrollAreaScrollbar,
- ScrollAreaThumb,
- ScrollAreaViewport,
-} from '../scroll-area'
+import { Textarea } from '../textarea'
const meta = {
title: 'Base/UI/Dialog',
@@ -38,8 +42,11 @@ const meta = {
layout: 'centered',
docs: {
description: {
- component:
- 'Compound modal dialog built on Base UI Dialog. Use it for focused flows that interrupt the user, such as editing settings, confirming non-destructive actions, or collecting short-form input. Compose `DialogHeader`, `DialogBody` and `DialogFooter` inside `DialogContent`; the parts own the spacing, so call sites only arrange their content. `DialogCloseButton` is the header close icon; `DialogClose` stays unstyled for visible actions such as Cancel.',
+ component: [
+ 'Compound modal dialog built on Base UI Dialog. Use it for focused flows that interrupt the user, such as editing settings, collecting short-form input, or inspecting a record. `DialogContent` is the centered modal surface: compose `DialogHeader`, `DialogBody` and `DialogFooter` in it and the parts own the spacing, so a call site only arranges its content. `DialogBody` scrolls between the header and footer when the surface reaches the viewport.',
+ '',
+ 'Open state is uncontrolled by default; pass `open` and `onOpenChange` to close after an async action or to veto a close through `eventDetails.cancel()`. `DialogCloseButton` is the optional header close icon; `DialogClose` stays unstyled and composes a visible action such as Cancel. `DialogPopup` is the bare dialog element for a surface that places and dresses itself, composed with `DialogPortal`, `DialogBackdrop` and `DialogViewport`.',
+ ].join('\n'),
},
},
},
@@ -49,48 +56,53 @@ const meta = {
export default meta
type Story = StoryObj<typeof meta>
-const releaseNoteItems = Array.from({ length: 24 }, (_, index) => ({
+const panelClassName =
+ 'rounded-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-xl'
+
+const releaseNotes = Array.from({ length: 24 }, (_, index) => ({
id: `improvement-${index + 1}`,
title: `Improvement #${index + 1}`,
body: 'Refined a workflow behavior so long content naturally overflows and scrolls inside the dialog.',
}))
-function ReleaseNoteSections() {
+function ReleaseNoteList() {
return (
- <DialogBody className="flex flex-col gap-3">
- {releaseNoteItems.map((item) => (
- <section
- key={item.id}
+ <ol className="flex flex-col gap-3">
+ {releaseNotes.map((note) => (
+ <li
+ key={note.id}
className="rounded-lg bg-background-default-subtle px-3 py-2 system-sm-regular text-text-secondary"
>
- <h3 className="system-sm-medium text-text-primary">{item.title}</h3>
- <p>{item.body}</p>
- </section>
+ <h3 className="system-sm-medium text-text-primary">{note.title}</h3>
+ <p>{note.body}</p>
+ </li>
))}
- </DialogBody>
+ </ol>
)
}
export const Default: Story = {
render: () => (
<Dialog>
- <DialogTrigger render={<Button />}>Open dialog</DialogTrigger>
+ <DialogTrigger render={<Button />}>Start onboarding</DialogTrigger>
<DialogContent>
<DialogHeader>
- <DialogTitle>Invite collaborators</DialogTitle>
+ <DialogTitle>Welcome to Dify</DialogTitle>
<DialogDescription>
- Add teammates by email to share this workspace. They will receive an invitation link.
+ Setup takes about a minute and prepares your default models, datasets and API keys.
</DialogDescription>
<DialogCloseButton aria-label="Close dialog" />
</DialogHeader>
<DialogBody>
- <Field name="email">
- <FieldLabel>Email address</FieldLabel>
- <Input type="email" placeholder="[email protected]" />
- </Field>
+ <ol className="list-inside list-decimal space-y-1 system-sm-regular text-text-secondary">
+ <li>Connect a model provider</li>
+ <li>Import your first knowledge base</li>
+ <li>Create an API key for your app</li>
+ </ol>
</DialogBody>
<DialogFooter>
- <Button variant="primary">Send invite</Button>
+ <DialogClose render={<Button />}>Skip for now</DialogClose>
+ <Button variant="primary">Start setup</Button>
</DialogFooter>
</DialogContent>
</Dialog>
@@ -98,164 +110,45 @@ export const Default: Story = {
play: async ({ canvas, canvasElement, userEvent }) => {
const body = within(canvasElement.ownerDocument.body)
- await userEvent.click(canvas.getByRole('button', { name: 'Open dialog' }))
-
- const dialog = body.getByRole('dialog', { name: 'Invite collaborators' })
+ await userEvent.click(canvas.getByRole('button', { name: 'Start onboarding' }))
+ const dialog = await body.findByRole('dialog', { name: 'Welcome to Dify' })
await waitFor(async () => {
await expect(dialog).toBeVisible()
})
- await expect(body.getByRole('textbox', { name: 'Email address' })).toBeVisible()
+ await expect(dialog).toHaveAccessibleDescription(/Setup takes about a minute/)
- await userEvent.click(body.getByRole('button', { name: 'Close dialog' }))
+ await userEvent.click(body.getByRole('button', { name: 'Skip for now' }))
await waitFor(async () => {
- await expect(
- body.queryByRole('dialog', { name: 'Invite collaborators' }),
- ).not.toBeInTheDocument()
+ await expect(body.queryByRole('dialog')).not.toBeInTheDocument()
})
+ await expect(canvas.getByRole('button', { name: 'Start onboarding' })).toHaveFocus()
},
}
-export const WithoutCloseButton: Story = {
- render: () => (
- <Dialog>
- <DialogTrigger render={<Button />}>Start onboarding</DialogTrigger>
- <DialogContent>
- <DialogHeader>
- <DialogTitle>Welcome to Dify</DialogTitle>
- <DialogDescription>
- Let's get your workspace ready. This takes about a minute and sets up your default
- models, datasets, and API keys.
- </DialogDescription>
- </DialogHeader>
- <DialogFooter>
- <DialogClose render={<Button />}>Skip for now</DialogClose>
- <Button variant="primary">Start setup</Button>
- </DialogFooter>
- </DialogContent>
- </Dialog>
- ),
-}
-
-function ControlledDemo() {
- const [open, setOpen] = React.useState(false)
-
- return (
- <div className="flex flex-col items-center gap-3">
- <Button variant="secondary" onClick={() => setOpen(true)}>
- Open controlled dialog
- </Button>
- <span className="text-xs text-text-tertiary">State: {open ? 'open' : 'closed'}</span>
- <Dialog open={open} onOpenChange={setOpen}>
- <DialogContent>
- <DialogHeader>
- <DialogTitle>Rename workspace</DialogTitle>
- <DialogDescription>
- The workspace URL will stay the same, but the display name updates everywhere.
- </DialogDescription>
- <DialogCloseButton aria-label="Close dialog" />
- </DialogHeader>
- <DialogBody>
- <Field name="name">
- <FieldLabel>Workspace name</FieldLabel>
- <Input type="text" defaultValue="Acme Workspace" />
- </Field>
- </DialogBody>
- <DialogFooter>
- <Button onClick={() => setOpen(false)}>Cancel</Button>
- <Button variant="primary" onClick={() => setOpen(false)}>
- Save
- </Button>
- </DialogFooter>
- </DialogContent>
- </Dialog>
- </div>
- )
-}
-
-export const Controlled: Story = {
- render: () => <ControlledDemo />,
-}
-
-type WorkspaceDialogPayload = {
- name: string
- memberCount: number
-}
-
-const workspaceDialogPayloads = [
- { name: 'Design', memberCount: 8 },
- { name: 'Engineering', memberCount: 24 },
-] as const satisfies readonly WorkspaceDialogPayload[]
-
-function DetachedTriggersDemo() {
- const [dialogHandle] = React.useState(() => createDialogHandle<WorkspaceDialogPayload>())
-
- return (
- <div className="flex flex-col items-center gap-3">
- <div className="flex gap-2">
- {workspaceDialogPayloads.map((payload) => (
- <DialogTrigger
- key={payload.name}
- handle={dialogHandle}
- payload={payload}
- render={<Button variant="secondary" />}
- >
- Edit {payload.name}
- </DialogTrigger>
- ))}
- </div>
-
- <Dialog handle={dialogHandle}>
- {({ payload }) => (
- <DialogContent>
- <DialogHeader>
- <DialogTitle>{payload ? `Edit ${payload.name}` : 'Edit workspace'}</DialogTitle>
- <DialogDescription>
- {payload
- ? `${payload.memberCount} members currently have access to this workspace.`
- : 'Choose a workspace to edit.'}
- </DialogDescription>
- <DialogCloseButton aria-label="Close dialog" />
- </DialogHeader>
- <DialogFooter>
- <DialogClose render={<Button variant="primary" />}>Done</DialogClose>
- </DialogFooter>
- </DialogContent>
- )}
- </Dialog>
- </div>
- )
-}
-
-export const DetachedTriggers: Story = {
- render: () => <DetachedTriggersDemo />,
-}
-
type ApiExtensionFormValues = {
name: string
endpoint: string
- apiKey: string
}
function FormDialogDemo() {
- const [open, setOpen] = React.useState(false)
+ const actionsRef = React.useRef<DialogActions>(null)
const nameInputRef = React.useRef<HTMLInputElement>(null)
return (
- <Dialog open={open} onOpenChange={setOpen} disablePointerDismissal>
- <DialogTrigger render={<Button />}>Configure API extension</DialogTrigger>
- <DialogContent
- initialFocus={nameInputRef}
- className="w-160"
- backdropProps={{ forceRender: true }}
- >
+ <Dialog actionsRef={actionsRef} disablePointerDismissal>
+ <DialogTrigger render={<Button />}>Add API extension</DialogTrigger>
+ <DialogContent initialFocus={nameInputRef}>
<DialogHeader>
- <DialogTitle>Configure API extension</DialogTitle>
+ <DialogTitle>Add API extension</DialogTitle>
<DialogDescription>
- Save the endpoint and credentials used by this workspace integration.
+ Save the endpoint this workspace calls for external data tools.
</DialogDescription>
<DialogCloseButton aria-label="Close dialog" />
</DialogHeader>
- <Form<ApiExtensionFormValues> onFormSubmit={() => setOpen(false)}>
+ <Form<ApiExtensionFormValues>
+ className="contents"
+ onFormSubmit={() => actionsRef.current?.close()}
+ >
<DialogBody className="flex flex-col gap-4">
<Field name="name">
<FieldLabel>Name</FieldLabel>
@@ -265,33 +158,9 @@ function FormDialogDemo() {
<Field name="endpoint">
<FieldLabel>Endpoint</FieldLabel>
<Input type="url" required placeholder="https://api.example.com" />
- <FieldDescription>
- <a
- href="https://docs.dify.ai/use-dify/workspace/api-extension/api-extension"
- target="_blank"
- rel="noopener noreferrer"
- className="inline-flex w-fit items-center text-text-accent underline decoration-text-accent/60 decoration-1 underline-offset-2 outline-hidden hover:decoration-text-accent focus-visible:rounded-xs focus-visible:no-underline focus-visible:ring-2 focus-visible:ring-state-accent-solid"
- >
- View API extension docs
- </a>
- </FieldDescription>
<FieldError match="valueMissing">Endpoint is required.</FieldError>
<FieldError match="typeMismatch">Enter a valid URL.</FieldError>
</Field>
- <Field
- name="apiKey"
- validate={(value) => {
- if (typeof value === 'string' && value.length > 0 && value.length < 5)
- return 'API key must be at least 5 characters.'
-
- return null
- }}
- >
- <FieldLabel>API key</FieldLabel>
- <Input required placeholder="sk-..." />
- <FieldError match="valueMissing">API key is required.</FieldError>
- <FieldError match="customError" />
- </Field>
</DialogBody>
<DialogFooter>
<DialogClose render={<Button />}>Cancel</DialogClose>
@@ -306,148 +175,404 @@ function FormDialogDemo() {
}
export const FormDialog: Story = {
+ parameters: {
+ docs: {
+ description: {
+ story:
+ '`initialFocus` lands on the first field, `disablePointerDismissal` keeps typed input safe from a stray outside click, and the confirming action is the form submit: Enter or the submit button runs `onFormSubmit`, which closes through `actionsRef`.',
+ },
+ },
+ },
render: () => <FormDialogDemo />,
play: async ({ canvas, canvasElement, userEvent }) => {
const body = within(canvasElement.ownerDocument.body)
- await userEvent.click(canvas.getByRole('button', { name: 'Configure API extension' }))
+ await userEvent.click(canvas.getByRole('button', { name: 'Add API extension' }))
+ const nameInput = await body.findByRole('textbox', { name: 'Name' })
+ await waitFor(async () => {
+ await expect(nameInput).toHaveFocus()
+ })
+
+ await userEvent.type(nameInput, 'Production API')
+ await userEvent.click(canvasElement.ownerDocument.body)
+ await expect(body.getByRole('dialog', { name: 'Add API extension' })).toHaveAttribute(
+ 'data-open',
+ )
+ await expect(nameInput).toHaveValue('Production API')
+ await userEvent.type(body.getByRole('textbox', { name: 'Endpoint' }), 'https://api.example.com')
+ await userEvent.keyboard('{Enter}')
await waitFor(async () => {
- await expect(body.getByRole('textbox', { name: 'Name' })).toHaveFocus()
+ await expect(body.queryByRole('dialog')).not.toBeInTheDocument()
})
},
}
-function OutsideScrollingContentDemo() {
- const [open, setOpen] = React.useState(false)
- const popupRef = React.useRef<HTMLDivElement>(null)
+export const ScrollingBody: Story = {
+ parameters: {
+ docs: {
+ description: {
+ story:
+ 'Long content scrolls inside `DialogBody` while the header and footer stay put; the surface is capped at the viewport height.',
+ },
+ },
+ },
+ render: () => (
+ <Dialog>
+ <DialogTrigger render={<Button />}>Review release notes</DialogTrigger>
+ <DialogContent>
+ <DialogHeader>
+ <DialogTitle>Release notes</DialogTitle>
+ <DialogDescription>Highlights from the latest workspace update.</DialogDescription>
+ <DialogCloseButton aria-label="Close dialog" />
+ </DialogHeader>
+ <DialogBody role="region" aria-label="Release notes" tabIndex={0}>
+ <ReleaseNoteList />
+ </DialogBody>
+ <DialogFooter>
+ <DialogClose render={<Button />}>Close</DialogClose>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ ),
+ play: async ({ canvas, canvasElement, userEvent }) => {
+ const body = within(canvasElement.ownerDocument.body)
- return (
- <Dialog open={open} onOpenChange={setOpen}>
- <DialogTrigger render={<Button />}>Review long release notes</DialogTrigger>
+ await userEvent.click(canvas.getByRole('button', { name: 'Review release notes' }))
+ const dialog = await body.findByRole('dialog', { name: 'Release notes' })
+ const region = within(dialog).getByRole('region', { name: 'Release notes' })
+ await waitFor(async () => {
+ await expect(region.scrollHeight).toBeGreaterThan(region.clientHeight)
+ })
+ await expect(dialog.scrollHeight).toBe(dialog.clientHeight)
+
+ region.scrollTop = region.scrollHeight
+ await expect(region.scrollTop).toBeGreaterThan(0)
+ await expect(dialog.scrollTop).toBe(0)
+ },
+}
+
+export const ViewportScrolling: Story = {
+ parameters: {
+ docs: {
+ description: {
+ story:
+ 'The popup keeps its natural height and `DialogViewport` scrolls instead; `DialogPopup` dresses itself because the centered `DialogContent` surface is not used.',
+ },
+ },
+ },
+ render: () => (
+ <Dialog>
+ <DialogTrigger render={<Button />}>Read the full changelog</DialogTrigger>
<DialogPortal>
- <DialogBackdrop className="duration-600 ease-[cubic-bezier(0.22,1,0.36,1)] data-ending-style:duration-350 data-ending-style:ease-[cubic-bezier(0.375,0.015,0.545,0.455)]" />
- <DialogViewport className="group/dialog">
- <ScrollArea className="h-full group-data-ending-style/dialog:pointer-events-none">
- <ScrollAreaViewport
- aria-label="Scrollable dialog viewport"
- role="region"
- className="overscroll-contain group-data-ending-style/dialog:pointer-events-none"
- >
- <ScrollAreaContent className="flex min-h-full items-center justify-center px-4 py-16">
- <DialogPopup
- ref={popupRef}
- initialFocus={popupRef}
- className="relative mx-auto flex w-120 max-w-[calc(100vw-2rem)] flex-col overflow-hidden outline-hidden transition-[translate] duration-700 ease-[cubic-bezier(0.45,1.005,0,1.005)] data-ending-style:translate-y-[max(100dvh,100%)] data-ending-style:scale-100 data-ending-style:opacity-100 data-ending-style:duration-350 data-ending-style:ease-[cubic-bezier(0.375,0.015,0.545,0.455)] data-starting-style:translate-y-[100dvh] data-starting-style:scale-100 data-starting-style:opacity-100"
- >
- <DialogHeader>
- <DialogTitle>Long release notes</DialogTitle>
- <DialogDescription>
- This layout lets the outer dialog viewport scroll while the popup keeps its
- natural height.
- </DialogDescription>
- <DialogCloseButton aria-label="Close dialog" />
- </DialogHeader>
- <ReleaseNoteSections />
- <DialogFooter>
- <DialogClose render={<Button />}>Close</DialogClose>
- </DialogFooter>
- </DialogPopup>
- </ScrollAreaContent>
- </ScrollAreaViewport>
- <ScrollAreaScrollbar>
- <ScrollAreaThumb />
- </ScrollAreaScrollbar>
- </ScrollArea>
+ <DialogBackdrop />
+ <DialogViewport className="overflow-y-auto">
+ <DialogPopup className={`${panelClassName} mx-auto my-16 w-120 max-w-[calc(100vw-2rem)]`}>
+ <DialogHeader>
+ <DialogTitle>Changelog</DialogTitle>
+ <DialogDescription>
+ Every improvement shipped since the last release.
+ </DialogDescription>
+ <DialogCloseButton aria-label="Close dialog" />
+ </DialogHeader>
+ <DialogBody>
+ <ReleaseNoteList />
+ </DialogBody>
+ <DialogFooter>
+ <DialogClose render={<Button />}>Close</DialogClose>
+ </DialogFooter>
+ </DialogPopup>
</DialogViewport>
</DialogPortal>
</Dialog>
- )
-}
+ ),
+ play: async ({ canvas, canvasElement, userEvent }) => {
+ const body = within(canvasElement.ownerDocument.body)
-export const OutsideScrollingContent: Story = {
- render: () => <OutsideScrollingContentDemo />,
+ await userEvent.click(canvas.getByRole('button', { name: 'Read the full changelog' }))
+ const dialog = await body.findByRole('dialog', { name: 'Changelog' })
+ const viewport = dialog.parentElement as HTMLElement
+ await waitFor(async () => {
+ await expect(viewport.scrollHeight).toBeGreaterThan(viewport.clientHeight)
+ })
+ await expect(dialog.scrollHeight).toBe(dialog.clientHeight)
+ await expect(dialog.getBoundingClientRect().top).toBeGreaterThan(0)
+
+ viewport.scrollTop = viewport.scrollHeight
+ await waitFor(async () => {
+ await expect(dialog.getBoundingClientRect().top).toBeLessThan(0)
+ })
+ await expect(dialog.scrollTop).toBe(0)
+ },
}
-export const OutsidePopupElements: Story = {
+const traceRows = [
+ ['LLM', '1.84s', '812 tokens'],
+ ['Knowledge retrieval', '0.42s', '6 chunks'],
+ ['Code', '0.08s', 'ok'],
+ ['Answer', '0.01s', 'ok'],
+] as const
+
+export const SidePanel: Story = {
+ parameters: {
+ docs: {
+ description: {
+ story:
+ 'A run-detail panel docked to the viewport edge, the way the log panels in web are built: `DialogPopup` places and dresses itself over a transparent `DialogBackdrop`.',
+ },
+ },
+ },
render: () => (
<Dialog>
- <DialogTrigger render={<Button />}>Open uncontained dialog</DialogTrigger>
+ <DialogTrigger render={<Button />}>View run detail</DialogTrigger>
<DialogPortal>
- <DialogBackdrop className="min-h-dvh" />
- <DialogViewport className="grid place-items-center px-4 py-12 xl:py-6">
- <DialogPopup className="group/popup pointer-events-none relative flex h-full w-full max-w-280 justify-center border-0 bg-transparent shadow-none transition-opacity data-ending-style:scale-100 data-ending-style:opacity-0 data-starting-style:scale-100 data-starting-style:opacity-0">
- <DialogClose
- render={
- <IconButton
- aria-label="Close"
- size="lg"
- className="pointer-events-auto absolute -top-10 right-0 z-10 flex items-center justify-center border-[0.5px] border-components-button-secondary-border bg-components-button-secondary-bg text-text-tertiary shadow-xs outline-hidden hover:bg-components-button-secondary-bg-hover hover:text-text-secondary focus-visible:ring-2 focus-visible:ring-state-accent-solid xl:top-0"
- >
- <span aria-hidden className="i-ri-close-line size-4" />
- </IconButton>
- }
- />
- <div className="pointer-events-auto flex h-full w-full max-w-280 flex-col overflow-hidden rounded-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg p-6 shadow-xl transition-[scale] duration-500 ease-[cubic-bezier(0.22,1,0.36,1)] group-data-starting-style/popup:scale-105">
- <div className="grid gap-2">
- <DialogTitle className="text-lg leading-7 font-semibold text-text-primary">
- Knowledge review
- </DialogTitle>
- <DialogDescription className="text-sm leading-5 text-text-secondary">
- The close button is visually outside this panel but remains inside the popup for
- focus order and screen reader context.
- </DialogDescription>
- </div>
- <div className="mt-6 grid flex-1 place-items-center rounded-xl bg-background-default-subtle text-sm text-text-tertiary">
- Panel content
- </div>
- </div>
- </DialogPopup>
- </DialogViewport>
+ <DialogBackdrop className="bg-transparent" />
+ <DialogPopup
+ className={`${panelClassName} fixed inset-e-2 top-16 bottom-4 flex w-120 max-w-[calc(100vw-1rem)] flex-col overflow-hidden`}
+ >
+ <DialogHeader>
+ <DialogTitle>Run detail</DialogTitle>
+ <DialogDescription>Node executions for the selected message.</DialogDescription>
+ <DialogCloseButton aria-label="Close panel" />
+ </DialogHeader>
+ <DialogBody>
+ <table className="w-full system-sm-regular text-text-secondary">
+ <thead className="system-xs-medium-uppercase text-text-tertiary">
+ <tr>
+ <th scope="col" className="pb-2 text-start">
+ Node
+ </th>
+ <th scope="col" className="pb-2 text-start">
+ Elapsed
+ </th>
+ <th scope="col" className="pb-2 text-start">
+ Output
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ {traceRows.map(([node, elapsed, output]) => (
+ <tr key={node} className="border-t border-divider-subtle">
+ <td className="py-2 text-text-primary">{node}</td>
+ <td className="py-2">{elapsed}</td>
+ <td className="py-2">{output}</td>
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ </DialogBody>
+ </DialogPopup>
</DialogPortal>
</Dialog>
),
+ play: async ({ canvas, canvasElement, userEvent }) => {
+ const body = within(canvasElement.ownerDocument.body)
+ const trigger = canvas.getByRole('button', { name: 'View run detail' })
+
+ await userEvent.click(trigger)
+ const dialog = await body.findByRole('dialog', { name: 'Run detail' })
+ await waitFor(async () => {
+ await expect(dialog).toBeVisible()
+ })
+ await expect(trigger).toBeVisible()
+
+ await userEvent.keyboard('{Escape}')
+ await waitFor(async () => {
+ await expect(body.queryByRole('dialog')).not.toBeInTheDocument()
+ })
+ await expect(trigger).toHaveFocus()
+ },
}
-function InsideScrollingContentDemo() {
- const [open, setOpen] = React.useState(false)
+type ApiKeyPayload = {
+ name: string
+ lastUsed: string
+}
+
+const apiKeys = [
+ { name: 'Production', lastUsed: '2 minutes ago' },
+ { name: 'Staging', lastUsed: '3 days ago' },
+] as const satisfies readonly ApiKeyPayload[]
+
+function DetachedTriggersDemo() {
+ const [dialogHandle] = React.useState(() => createDialogHandle<ApiKeyPayload>())
return (
- <Dialog open={open} onOpenChange={setOpen}>
- <DialogTrigger render={<Button />}>Review release notes</DialogTrigger>
- <DialogPortal>
- <DialogBackdrop />
- <DialogViewport className="flex items-center justify-center overflow-hidden p-4">
- <DialogPopup className="relative flex h-[min(44rem,calc(100dvh-2rem))] min-h-0 w-120 max-w-[calc(100vw-2rem)] flex-col overflow-hidden">
+ <React.Fragment>
+ <ul className="flex w-96 flex-col divide-y divide-divider-subtle">
+ {apiKeys.map((apiKey) => (
+ <li key={apiKey.name} className="flex items-center justify-between gap-4 py-2">
+ <span className="system-sm-medium text-text-primary">{apiKey.name}</span>
+ <DialogTrigger
+ handle={dialogHandle}
+ payload={apiKey}
+ render={<Button size="small" variant="secondary" />}
+ >
+ Edit {apiKey.name}
+ </DialogTrigger>
+ </li>
+ ))}
+ </ul>
+ <Dialog handle={dialogHandle}>
+ {({ payload }) => (
+ <DialogContent>
<DialogHeader>
- <DialogTitle>Release notes</DialogTitle>
- <DialogDescription>Highlights from the latest workspace update.</DialogDescription>
+ <DialogTitle>Edit {payload?.name} key</DialogTitle>
+ <DialogDescription>Last used {payload?.lastUsed}.</DialogDescription>
<DialogCloseButton aria-label="Close dialog" />
</DialogHeader>
- <ScrollArea className="flex min-h-0 flex-auto overflow-hidden">
- <ScrollAreaViewport
- aria-label="Release note improvements"
- role="region"
- className="overscroll-contain"
- >
- <ScrollAreaContent>
- <ReleaseNoteSections />
- </ScrollAreaContent>
- </ScrollAreaViewport>
- <ScrollAreaScrollbar>
- <ScrollAreaThumb />
- </ScrollAreaScrollbar>
- </ScrollArea>
+ <DialogBody>
+ <Field name="name">
+ <FieldLabel>Key name</FieldLabel>
+ <Input defaultValue={payload?.name} />
+ </Field>
+ </DialogBody>
<DialogFooter>
- <DialogClose render={<Button />}>Close</DialogClose>
+ <DialogClose render={<Button />}>Cancel</DialogClose>
+ <Button variant="primary" onClick={() => dialogHandle.close()}>
+ Save
+ </Button>
</DialogFooter>
- </DialogPopup>
- </DialogViewport>
- </DialogPortal>
+ </DialogContent>
+ )}
+ </Dialog>
+ </React.Fragment>
+ )
+}
+
+export const DetachedTriggers: Story = {
+ parameters: {
+ docs: {
+ description: {
+ story:
+ 'One dialog serves a list of rows: each row is a `DialogTrigger` bound to a `createDialogHandle` with its row as `payload`, and the root renders from that payload.',
+ },
+ },
+ },
+ render: () => <DetachedTriggersDemo />,
+ play: async ({ canvas, canvasElement, userEvent }) => {
+ const body = within(canvasElement.ownerDocument.body)
+
+ await userEvent.click(canvas.getByRole('button', { name: 'Edit Staging' }))
+ const dialog = await body.findByRole('dialog', { name: 'Edit Staging key' })
+ await waitFor(async () => {
+ await expect(dialog).toBeVisible()
+ })
+ await expect(within(dialog).getByRole('textbox', { name: 'Key name' })).toHaveValue('Staging')
+
+ await userEvent.click(within(dialog).getByRole('button', { name: 'Save' }))
+ await waitFor(async () => {
+ await expect(body.queryByRole('dialog')).not.toBeInTheDocument()
+ })
+ await expect(canvas.getByRole('button', { name: 'Edit Staging' })).toHaveFocus()
+ },
+}
+
+function UnsavedChangesDemo() {
+ const [open, setOpen] = React.useState(false)
+ const [confirmOpen, setConfirmOpen] = React.useState(false)
+ const [saved, setSaved] = React.useState('')
+ const [draft, setDraft] = React.useState('')
+
+ return (
+ <Dialog
+ open={open}
+ onOpenChange={(nextOpen, details) => {
+ if (!nextOpen && draft !== saved) {
+ details.cancel()
+ setConfirmOpen(true)
+ return
+ }
+ setOpen(nextOpen)
+ }}
+ >
+ <DialogTrigger render={<Button />}>Edit description</DialogTrigger>
+ <DialogContent>
+ <DialogHeader>
+ <DialogTitle>Edit description</DialogTitle>
+ <DialogDescription>Shown on the app card and in the explore page.</DialogDescription>
+ <DialogCloseButton aria-label="Close dialog" />
+ </DialogHeader>
+ <DialogBody>
+ <Field name="description">
+ <FieldLabel>Description</FieldLabel>
+ <Textarea value={draft} onValueChange={setDraft} placeholder="What does this app do?" />
+ </Field>
+ </DialogBody>
+ <DialogFooter>
+ <DialogClose render={<Button />}>Cancel</DialogClose>
+ <Button
+ variant="primary"
+ onClick={() => {
+ setSaved(draft)
+ setOpen(false)
+ }}
+ >
+ Save
+ </Button>
+ </DialogFooter>
+ <AlertDialog open={confirmOpen} onOpenChange={setConfirmOpen}>
+ <AlertDialogContent>
+ <AlertDialogHeader>
+ <AlertDialogTitle>Discard unsaved changes?</AlertDialogTitle>
+ <AlertDialogDescription>
+ Your edits to the description will be lost.
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogFooter>
+ <AlertDialogCancelButton variant="secondary">Keep editing</AlertDialogCancelButton>
+ <AlertDialogConfirmButton
+ onClick={() => {
+ setConfirmOpen(false)
+ setDraft(saved)
+ setOpen(false)
+ }}
+ >
+ Discard
+ </AlertDialogConfirmButton>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
+ </DialogContent>
</Dialog>
)
}
-export const InsideScrollingContent: Story = {
- render: () => <InsideScrollingContentDemo />,
+export const UnsavedChanges: Story = {
+ parameters: {
+ docs: {
+ description: {
+ story:
+ 'Closing a dirty dialog is vetoed with `eventDetails.cancel()` in `onOpenChange`, and a nested `AlertDialog` asks before the edits are discarded; the parent surface steps back and dims while the alert is open.',
+ },
+ },
+ },
+ render: () => <UnsavedChangesDemo />,
+ play: async ({ canvas, canvasElement, userEvent }) => {
+ const body = within(canvasElement.ownerDocument.body)
+
+ await userEvent.click(canvas.getByRole('button', { name: 'Edit description' }))
+ const dialog = await body.findByRole('dialog', { name: 'Edit description' })
+ const description = within(dialog).getByRole('textbox', { name: 'Description' })
+ await userEvent.type(description, 'Answers support tickets')
+
+ await userEvent.keyboard('{Escape}')
+ const alert = await body.findByRole('alertdialog', { name: 'Discard unsaved changes?' })
+ await waitFor(async () => {
+ await expect(alert).toBeVisible()
+ })
+ await expect(dialog).toHaveAttribute('data-nested-dialog-open')
+
+ await userEvent.click(within(alert).getByRole('button', { name: 'Keep editing' }))
+ await waitFor(async () => {
+ await expect(body.queryByRole('alertdialog')).not.toBeInTheDocument()
+ })
+ await expect(description).toHaveValue('Answers support tickets')
+
+ await userEvent.keyboard('{Escape}')
+ await userEvent.click(await body.findByRole('button', { name: 'Discard' }))
+ await waitFor(async () => {
+ await expect(body.queryByRole('dialog')).not.toBeInTheDocument()
+ })
+ },
}
diff --git a/packages/dify-ui/src/dialog/index.tsx b/packages/dify-ui/src/dialog/index.tsx
index 0207d70a8ed..85bc58b2235 100644
--- a/packages/dify-ui/src/dialog/index.tsx
+++ b/packages/dify-ui/src/dialog/index.tsx
@@ -5,7 +5,13 @@ import { Dialog as BaseDialog } from '@base-ui/react/dialog'
import { cn } from '../cn'
import { IconButton } from '../icon-button'
import { focusRingClassName } from '../internal/focus'
-import { modalBackdropClassName, modalPopupAnimationClassName } from '../internal/overlay'
+import {
+ modalBackdropClassName,
+ modalPopupAnimationClassName,
+ modalStackClassName,
+ modalSurfaceClassName,
+ modalTitleClassName,
+} from '../internal/overlay'
import { resolveClassName } from '../internal/resolve-class-name'
const Dialog = BaseDialog.Root
@@ -34,13 +40,7 @@ type DialogTitleProps = BaseDialog.Title.Props
function DialogTitle({ className, ...props }: DialogTitleProps) {
return (
<BaseDialog.Title
- className={(state) =>
- cn(
- // Same look as AlertDialogTitle; change both together.
- 'title-2xl-semi-bold wrap-break-word text-text-primary',
- resolveClassName(className, state),
- )
- }
+ className={(state) => cn(modalTitleClassName, resolveClassName(className, state))}
{...props}
/>
)
@@ -92,12 +92,7 @@ function DialogPopup({ className, ...props }: DialogPopupProps) {
return (
<BaseDialog.Popup
className={(state) =>
- cn(
- // Radius, border and surface match AlertDialogContent; change both together.
- 'rounded-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-xl',
- modalPopupAnimationClassName,
- resolveClassName(className, state),
- )
+ cn('relative', modalPopupAnimationClassName, resolveClassName(className, state))
}
{...props}
/>
@@ -116,7 +111,9 @@ function DialogContent({ children, className, backdropProps, ...props }: DialogC
<DialogPopup
className={(state) =>
cn(
- 'fixed top-1/2 left-1/2 max-h-[80dvh] w-120 max-w-[calc(100vw-2rem)] -translate-x-1/2 -translate-y-1/2 overflow-y-auto overscroll-contain',
+ 'fixed top-1/2 left-1/2 flex max-h-[calc(100dvh-2rem)] w-120 max-w-[calc(100vw-2rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-y-auto overscroll-none',
+ modalSurfaceClassName,
+ modalStackClassName,
resolveClassName(className, state),
)
}
@@ -134,7 +131,7 @@ function DialogHeader({ className, ...props }: DialogHeaderProps) {
return (
<div
className={cn(
- 'sticky top-0 z-1 flex flex-col gap-1 bg-components-panel-bg ps-6 pe-14 pt-6 pb-3',
+ 'flex shrink-0 flex-col gap-1 px-6 pt-6 pb-3 has-data-dialog-close:pe-14',
className,
)}
{...props}
@@ -151,7 +148,12 @@ function DialogCloseButton({ 'aria-label': ariaLabel, ...props }: DialogCloseBut
<BaseDialog.Close
{...props}
render={
- <IconButton aria-label={ariaLabel} size="lg" className="absolute inset-e-5 top-5">
+ <IconButton
+ data-dialog-close=""
+ aria-label={ariaLabel}
+ size="lg"
+ className="absolute inset-e-5 top-5"
+ >
<span aria-hidden className="i-ri-close-line size-4.5" />
</IconButton>
}
@@ -162,7 +164,15 @@ function DialogCloseButton({ 'aria-label': ariaLabel, ...props }: DialogCloseBut
type DialogBodyProps = React.ComponentProps<'div'>
function DialogBody({ className, ...props }: DialogBodyProps) {
- return <div className={cn('px-6 py-3', className)} {...props} />
+ return (
+ <div
+ className={cn(
+ 'relative min-h-0 flex-1 overflow-x-hidden overflow-y-auto px-6 py-3',
+ className,
+ )}
+ {...props}
+ />
+ )
}
type DialogFooterProps = React.ComponentProps<'div'>
@@ -170,10 +180,7 @@ type DialogFooterProps = React.ComponentProps<'div'>
function DialogFooter({ className, ...props }: DialogFooterProps) {
return (
<div
- className={cn(
- 'sticky bottom-0 flex items-center justify-end gap-2 bg-components-panel-bg px-6 pt-5 pb-6',
- className,
- )}
+ className={cn('flex shrink-0 items-center justify-end gap-2 px-6 pt-5 pb-6', className)}
{...props}
/>
)
diff --git a/packages/dify-ui/src/internal/overlay.ts b/packages/dify-ui/src/internal/overlay.ts
index 124465dfd2f..6aee9bd704e 100644
--- a/packages/dify-ui/src/internal/overlay.ts
+++ b/packages/dify-ui/src/internal/overlay.ts
@@ -15,5 +15,11 @@ export const hintPopupClassName =
'max-w-75 rounded-lg border-[0.5px] border-components-panel-border bg-components-tooltip-bg p-1.5 text-start system-xs-medium wrap-break-word text-text-secondary shadow-[0px_12px_16px_-4px_var(--color-shadow-shadow-5),0px_4px_6px_-2px_var(--color-shadow-shadow-1)] backdrop-blur-[5px] origin-(--transform-origin) transition-opacity data-ending-style:opacity-0 data-instant:transition-none data-starting-style:opacity-0 motion-reduce:transition-none'
export const modalBackdropClassName =
'absolute inset-0 bg-background-overlay transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 motion-reduce:transition-none'
+export const modalSurfaceClassName =
+ 'rounded-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-xl'
+export const modalTitleClassName = 'title-2xl-semi-bold wrap-break-word text-text-primary'
+// A parent surface steps back while a dialog opens on top of it; Base UI sets `--nested-dialogs`.
+export const modalStackClassName =
+ 'scale-[calc(1-0.05*var(--nested-dialogs,0))] after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] after:bg-text-primary/5 after:opacity-0 after:transition-opacity after:duration-150 data-nested-dialog-open:after:opacity-100'
export const modalPopupAnimationClassName =
'transition-[transform,scale,opacity] duration-150 data-ending-style:scale-95 data-ending-style:opacity-0 data-starting-style:scale-95 data-starting-style:opacity-0 motion-reduce:transition-none'
diff --git a/web/app/account/(commonLayout)/account-page/change-password-dialog.tsx b/web/app/account/(commonLayout)/account-page/change-password-dialog.tsx
index 9f56bac51c8..2d7e27ed0da 100644
--- a/web/app/account/(commonLayout)/account-page/change-password-dialog.tsx
+++ b/web/app/account/(commonLayout)/account-page/change-password-dialog.tsx
@@ -107,7 +107,7 @@ function ChangePasswordForm({
}
return (
- <Form<ChangePasswordFormValues> onFormSubmit={handleSubmit}>
+ <Form<ChangePasswordFormValues> className="contents" onFormSubmit={handleSubmit}>
<DialogHeader>
<DialogTitle>
{isPasswordSet
diff --git a/web/app/account/(commonLayout)/account-page/edit-account-name-dialog.tsx b/web/app/account/(commonLayout)/account-page/edit-account-name-dialog.tsx
index a5745d9a205..231c788a089 100644
--- a/web/app/account/(commonLayout)/account-page/edit-account-name-dialog.tsx
+++ b/web/app/account/(commonLayout)/account-page/edit-account-name-dialog.tsx
@@ -33,6 +33,7 @@ function EditAccountNameForm({ name, isPending, onSave }: EditAccountNameFormPro
return (
<form
+ className="contents"
onSubmit={(event) => {
event.preventDefault()
if (!isPending && draftName) void onSave(draftName)
diff --git a/web/app/account/(commonLayout)/account-page/email-change-modal.tsx b/web/app/account/(commonLayout)/account-page/email-change-modal.tsx
index d452fb5701b..bd13727e736 100644
--- a/web/app/account/(commonLayout)/account-page/email-change-modal.tsx
+++ b/web/app/account/(commonLayout)/account-page/email-change-modal.tsx
@@ -197,6 +197,7 @@ const EmailChangeModal = ({ onClose, email }: Props) => {
<Dialog open onOpenChange={(open) => !open && onClose()}>
<DialogContent className="w-105">
<form
+ className="contents"
onSubmit={(event) => {
event.preventDefault()
if (step === STEP.start) void sendCodeToOriginEmail()
@@ -231,10 +232,10 @@ const EmailChangeModal = ({ onClose, email }: Props) => {
</div>
</DialogBody>
<DialogFooter className="flex-col items-stretch">
- <Button className="w-full!" variant="primary" type="submit">
+ <Button variant="primary" type="submit">
{t(($) => $['account.changeEmail.sendVerifyCode'], { ns: 'accountSettings' })}
</Button>
- <Button className="w-full!" onClick={onClose}>
+ <Button onClick={onClose}>
{t(($) => $['operation.cancel'], { ns: 'common' })}
</Button>
</DialogFooter>
@@ -278,15 +279,10 @@ const EmailChangeModal = ({ onClose, email }: Props) => {
</Field>
</DialogBody>
<DialogFooter className="flex-col items-stretch">
- <Button
- disabled={code.length !== 6}
- className="w-full!"
- variant="primary"
- type="submit"
- >
+ <Button disabled={code.length !== 6} variant="primary" type="submit">
{t(($) => $['account.changeEmail.continue'], { ns: 'accountSettings' })}
</Button>
- <Button className="w-full!" onClick={onClose}>
+ <Button onClick={onClose}>
{t(($) => $['operation.cancel'], { ns: 'common' })}
</Button>
<div className="flex items-center gap-1 system-xs-regular text-text-tertiary">
@@ -357,15 +353,10 @@ const EmailChangeModal = ({ onClose, email }: Props) => {
</Field>
</DialogBody>
<DialogFooter className="flex-col items-stretch">
- <Button
- disabled={isSendCodeDisabled}
- className="w-full!"
- variant="primary"
- type="submit"
- >
+ <Button disabled={isSendCodeDisabled} variant="primary" type="submit">
{t(($) => $['account.changeEmail.sendVerifyCode'], { ns: 'accountSettings' })}
</Button>
- <Button className="w-full!" onClick={onClose}>
+ <Button onClick={onClose}>
{t(($) => $['operation.cancel'], { ns: 'common' })}
</Button>
</DialogFooter>
@@ -409,18 +400,13 @@ const EmailChangeModal = ({ onClose, email }: Props) => {
</Field>
</DialogBody>
<DialogFooter className="flex-col items-stretch">
- <Button
- disabled={code.length !== 6}
- className="w-full!"
- variant="primary"
- type="submit"
- >
+ <Button disabled={code.length !== 6} variant="primary" type="submit">
{t(($) => $['account.changeEmail.changeTo'], {
ns: 'accountSettings',
email: mail,
})}
</Button>
- <Button className="w-full!" onClick={onClose}>
+ <Button onClick={onClose}>
{t(($) => $['operation.cancel'], { ns: 'common' })}
</Button>
<div className="flex items-center gap-1 system-xs-regular text-text-tertiary">
diff --git a/web/app/account/(commonLayout)/delete-account/components/check-email.tsx b/web/app/account/(commonLayout)/delete-account/components/check-email.tsx
index 62d5820eb92..a4d9b607958 100644
--- a/web/app/account/(commonLayout)/delete-account/components/check-email.tsx
+++ b/web/app/account/(commonLayout)/delete-account/components/check-email.tsx
@@ -1,5 +1,6 @@
'use client'
import { Button } from '@langgenius/dify-ui/button'
+import { DialogBody, DialogFooter } from '@langgenius/dify-ui/dialog'
import { Field, FieldLabel } from '@langgenius/dify-ui/field'
import { Form } from '@langgenius/dify-ui/form'
import { Input } from '@langgenius/dify-ui/input'
@@ -39,45 +40,47 @@ export default function CheckEmail(props: DeleteAccountProps) {
return (
<Form
+ className="contents"
onFormSubmit={() => {
void handleConfirm()
}}
>
- <div className="py-1 body-md-medium text-text-destructive">
- {t(($) => $['account.deleteTip'], { ns: 'accountSettings' })}
- </div>
- <div className="pt-1 pb-2 body-md-regular text-text-secondary">
- {t(($) => $['account.deletePrivacyLinkTip'], { ns: 'accountSettings' })}
- <Link href="https://dify.ai/privacy" className="text-text-accent">
- {t(($) => $['account.deletePrivacyLink'], { ns: 'accountSettings' })}
- </Link>
- </div>
- <Field name="email" className="mt-3">
- <FieldLabel className="system-sm-semibold">
- {t(($) => $['account.deleteLabel'], { ns: 'accountSettings' })}
- </FieldLabel>
- <Input
- placeholder={
- t(($) => $['account.deletePlaceholder'], { ns: 'accountSettings' }) as string
- }
- value={userInputEmail}
- onValueChange={setUserInputEmail}
- />
- </Field>
- <div className="mt-3 flex w-full flex-col gap-2">
+ <DialogBody>
+ <div className="py-1 body-md-medium text-text-destructive">
+ {t(($) => $['account.deleteTip'], { ns: 'accountSettings' })}
+ </div>
+ <div className="pt-1 pb-2 body-md-regular text-text-secondary">
+ {t(($) => $['account.deletePrivacyLinkTip'], { ns: 'accountSettings' })}
+ <Link href="https://dify.ai/privacy" className="text-text-accent">
+ {t(($) => $['account.deletePrivacyLink'], { ns: 'accountSettings' })}
+ </Link>
+ </div>
+ <Field name="email" className="mt-3">
+ <FieldLabel className="system-sm-semibold">
+ {t(($) => $['account.deleteLabel'], { ns: 'accountSettings' })}
+ </FieldLabel>
+ <Input
+ placeholder={
+ t(($) => $['account.deletePlaceholder'], { ns: 'accountSettings' }) as string
+ }
+ value={userInputEmail}
+ onValueChange={setUserInputEmail}
+ />
+ </Field>
+ </DialogBody>
+ <DialogFooter className="flex-col items-stretch">
<Button
type="submit"
- className="w-full"
disabled={userInputEmail !== userProfileEmail}
loading={isSendingEmail}
variant="primary"
>
{t(($) => $['account.sendVerificationButton'], { ns: 'accountSettings' })}
</Button>
- <Button type="button" className="w-full" onClick={props.onCancel}>
+ <Button type="button" onClick={props.onCancel}>
{t(($) => $['operation.cancel'], { ns: 'common' })}
</Button>
- </div>
+ </DialogFooter>
</Form>
)
}
diff --git a/web/app/account/(commonLayout)/delete-account/components/feed-back.tsx b/web/app/account/(commonLayout)/delete-account/components/feed-back.tsx
index 92b0df12353..d0894e95184 100644
--- a/web/app/account/(commonLayout)/delete-account/components/feed-back.tsx
+++ b/web/app/account/(commonLayout)/delete-account/components/feed-back.tsx
@@ -69,7 +69,6 @@ export default function FeedBack(props: DeleteAccountProps) {
}}
>
<DialogContent
- className="max-w-120"
backdropProps={{ className: 'bg-background-overlay-backdrop backdrop-blur-[6px]' }}
>
<DialogHeader>
@@ -78,6 +77,7 @@ export default function FeedBack(props: DeleteAccountProps) {
</DialogTitle>
</DialogHeader>
<Form<FeedbackFormValues>
+ className="contents"
onFormSubmit={({ feedback }) => {
void handleSubmit(feedback)
}}
@@ -96,10 +96,10 @@ export default function FeedBack(props: DeleteAccountProps) {
</Field>
</DialogBody>
<DialogFooter className="flex-col items-stretch">
- <Button type="submit" className="w-full" loading={isPending} variant="primary">
+ <Button type="submit" loading={isPending} variant="primary">
{t(($) => $['operation.submit'], { ns: 'common' })}
</Button>
- <Button type="button" className="w-full" onClick={handleSkip}>
+ <Button type="button" onClick={handleSkip}>
{t(($) => $['operation.skip'], { ns: 'common' })}
</Button>
</DialogFooter>
diff --git a/web/app/account/(commonLayout)/delete-account/components/verify-email.tsx b/web/app/account/(commonLayout)/delete-account/components/verify-email.tsx
index cf32a7d1e80..46550e9257f 100644
--- a/web/app/account/(commonLayout)/delete-account/components/verify-email.tsx
+++ b/web/app/account/(commonLayout)/delete-account/components/verify-email.tsx
@@ -1,5 +1,6 @@
'use client'
import { Button } from '@langgenius/dify-ui/button'
+import { DialogBody, DialogFooter } from '@langgenius/dify-ui/dialog'
import { Field, FieldError, FieldLabel } from '@langgenius/dify-ui/field'
import { Form } from '@langgenius/dify-ui/form'
import { Input } from '@langgenius/dify-ui/input'
@@ -39,56 +40,53 @@ export default function VerifyEmail(props: DeleteAccountProps) {
)
return (
<Form<VerifyEmailFormValues>
+ className="contents"
onFormSubmit={({ verificationCode }) => {
void handleConfirm(verificationCode)
}}
>
- <div className="pt-1 body-md-medium text-text-destructive">
- {t(($) => $['account.deleteTip'], { ns: 'accountSettings' })}
- </div>
- <div className="pt-1 pb-2 body-md-regular text-text-secondary">
- {t(($) => $['account.deletePrivacyLinkTip'], { ns: 'accountSettings' })}
- <Link href="https://dify.ai/privacy" className="text-text-accent">
- {t(($) => $['account.deletePrivacyLink'], { ns: 'accountSettings' })}
- </Link>
- </div>
- <Field name="verificationCode" className="mt-3">
- <FieldLabel className="system-sm-semibold">
- {t(($) => $['account.verificationLabel'], { ns: 'accountSettings' })}
- </FieldLabel>
- <Input
- autoComplete="one-time-code"
- inputMode="numeric"
- required
- pattern="[0-9]{6}"
- minLength={6}
- maxLength={6}
- placeholder={
- t(($) => $['account.verificationPlaceholder'], { ns: 'accountSettings' }) as string
- }
- />
- <FieldError match="valueMissing">
- {t(($) => $['account.verificationPlaceholder'], { ns: 'accountSettings' })}
- </FieldError>
- <FieldError match="patternMismatch">
- {t(($) => $['account.verificationPlaceholder'], { ns: 'accountSettings' })}
- </FieldError>
- </Field>
- <div className="mt-3 flex w-full flex-col gap-2">
- <Button
- type="submit"
- className="w-full"
- loading={isDeleting}
- variant="primary"
- tone="destructive"
- >
+ <DialogBody>
+ <div className="pt-1 body-md-medium text-text-destructive">
+ {t(($) => $['account.deleteTip'], { ns: 'accountSettings' })}
+ </div>
+ <div className="pt-1 pb-2 body-md-regular text-text-secondary">
+ {t(($) => $['account.deletePrivacyLinkTip'], { ns: 'accountSettings' })}
+ <Link href="https://dify.ai/privacy" className="text-text-accent">
+ {t(($) => $['account.deletePrivacyLink'], { ns: 'accountSettings' })}
+ </Link>
+ </div>
+ <Field name="verificationCode" className="mt-3">
+ <FieldLabel className="system-sm-semibold">
+ {t(($) => $['account.verificationLabel'], { ns: 'accountSettings' })}
+ </FieldLabel>
+ <Input
+ autoComplete="one-time-code"
+ inputMode="numeric"
+ required
+ pattern="[0-9]{6}"
+ minLength={6}
+ maxLength={6}
+ placeholder={
+ t(($) => $['account.verificationPlaceholder'], { ns: 'accountSettings' }) as string
+ }
+ />
+ <FieldError match="valueMissing">
+ {t(($) => $['account.verificationPlaceholder'], { ns: 'accountSettings' })}
+ </FieldError>
+ <FieldError match="patternMismatch">
+ {t(($) => $['account.verificationPlaceholder'], { ns: 'accountSettings' })}
+ </FieldError>
+ </Field>
+ </DialogBody>
+ <DialogFooter className="flex-col items-stretch">
+ <Button type="submit" loading={isDeleting} variant="primary" tone="destructive">
{t(($) => $['account.permanentlyDeleteButton'], { ns: 'accountSettings' })}
</Button>
- <Button className="w-full" onClick={props.onCancel}>
+ <Button onClick={props.onCancel}>
{t(($) => $['operation.cancel'], { ns: 'common' })}
</Button>
<Countdown onResend={sendEmail} />
- </div>
+ </DialogFooter>
</Form>
)
}
diff --git a/web/app/account/(commonLayout)/delete-account/index.tsx b/web/app/account/(commonLayout)/delete-account/index.tsx
index 984b3f4430f..e75521c128f 100644
--- a/web/app/account/(commonLayout)/delete-account/index.tsx
+++ b/web/app/account/(commonLayout)/delete-account/index.tsx
@@ -1,5 +1,5 @@
'use client'
-import { Dialog, DialogContent, DialogTitle } from '@langgenius/dify-ui/dialog'
+import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@langgenius/dify-ui/dialog'
import { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { COUNT_DOWN_TIME_MS, useSetCountdownLeftTime } from '@/app/components/signin/storage'
@@ -38,12 +38,11 @@ export default function DeleteAccount(props: DeleteAccountProps) {
}}
>
<DialogContent
- className="max-w-120 overflow-hidden p-6"
backdropProps={{ className: 'bg-background-overlay-backdrop backdrop-blur-[6px]' }}
>
- <DialogTitle className="pr-8 pb-3">
- {t(($) => $['account.delete'], { ns: 'accountSettings' })}
- </DialogTitle>
+ <DialogHeader>
+ <DialogTitle>{t(($) => $['account.delete'], { ns: 'accountSettings' })}</DialogTitle>
+ </DialogHeader>
{!showVerifyEmail && (
<CheckEmail onCancel={props.onCancel} onConfirm={handleEmailCheckSuccess} />
)}
diff --git a/web/app/components/api-key/api-key-dialog-content.tsx b/web/app/components/api-key/api-key-dialog-content.tsx
index 68c9467ea8a..90b9449ad24 100644
--- a/web/app/components/api-key/api-key-dialog-content.tsx
+++ b/web/app/components/api-key/api-key-dialog-content.tsx
@@ -28,7 +28,7 @@ export function ApiKeyDialogContent({
}: ApiKeyDialogContentProps) {
const { t } = useTranslation(['appApi', 'common'])
return (
- <DialogContent finalFocus={finalFocus} className="flex w-200 flex-col overflow-hidden">
+ <DialogContent finalFocus={finalFocus} className="w-200">
<DialogHeader>
<DialogTitle>{t(($) => $['apiKeyModal.apiSecretKey'])}</DialogTitle>
<DialogDescription>
diff --git a/web/app/components/api-key/dataset-scope-dialog.tsx b/web/app/components/api-key/dataset-scope-dialog.tsx
index 4fb659b9311..55aa28e5321 100644
--- a/web/app/components/api-key/dataset-scope-dialog.tsx
+++ b/web/app/components/api-key/dataset-scope-dialog.tsx
@@ -114,6 +114,7 @@ function DatasetScopeContent({
return (
<form
+ className="contents"
onSubmit={(event) => {
event.preventDefault()
handleConfirm()
diff --git a/web/app/components/app-sidebar/app-info/__tests__/app-info-identity.spec.tsx b/web/app/components/app-sidebar/app-info/__tests__/app-info-identity.spec.tsx
index bf12b53652a..33d169b8752 100644
--- a/web/app/components/app-sidebar/app-info/__tests__/app-info-identity.spec.tsx
+++ b/web/app/components/app-sidebar/app-info/__tests__/app-info-identity.spec.tsx
@@ -47,19 +47,10 @@ vi.mock('../app-info-modals', () => ({
default: ({
appDetail,
activeModal,
- secretEnvList,
- setSecretEnvList,
}: {
appDetail: { name: string }
activeModal: string | null
- secretEnvList: unknown[]
- setSecretEnvList: (list: unknown[]) => void
- }) => (
- <div>
- <p>{`${appDetail.name}: ${activeModal ?? 'closed'}; secrets: ${secretEnvList.length}`}</p>
- <button onClick={() => setSecretEnvList([{}])}>Add secret</button>
- </div>
- ),
+ }) => <p>{`${appDetail.name}: ${activeModal ?? 'closed'}`}</p>,
}))
describe('AppInfoView identity in the app detail sidebar', () => {
@@ -82,8 +73,7 @@ describe('AppInfoView identity in the app detail sidebar', () => {
})
await user.click(screen.getByRole('button', { name: 'Open First app' }))
- await user.click(screen.getByRole('button', { name: 'Add secret' }))
- expect(screen.getByText('First app: edit; secrets: 1')).toBeInTheDocument()
+ expect(screen.getByText('First app: edit')).toBeInTheDocument()
screen.getByRole('button', { name: 'Open First app' }).focus()
currentApp = createAppDetailFixture({ name: 'Renamed app' })
@@ -91,7 +81,7 @@ describe('AppInfoView identity in the app detail sidebar', () => {
seed()
})
view.rerender(<AppDetailSection />)
- expect(screen.getByText('Renamed app: edit; secrets: 1')).toBeInTheDocument()
+ expect(screen.getByText('Renamed app: edit')).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Open Renamed app' })).toHaveFocus()
currentApp = createAppDetailFixture({ id: 'app-2', name: 'Second app' })
@@ -99,6 +89,6 @@ describe('AppInfoView identity in the app detail sidebar', () => {
seed()
view.rerender(<AppDetailSection />)
expect(screen.getByRole('button', { name: 'Open Second app' })).toBeInTheDocument()
- expect(screen.getByText('Second app: closed; secrets: 0')).toBeInTheDocument()
+ expect(screen.getByText('Second app: closed')).toBeInTheDocument()
})
})
diff --git a/web/app/components/app-sidebar/app-info/__tests__/app-info-modals.spec.tsx b/web/app/components/app-sidebar/app-info/__tests__/app-info-modals.spec.tsx
index 4b79b467b23..31ac25d58ee 100644
--- a/web/app/components/app-sidebar/app-info/__tests__/app-info-modals.spec.tsx
+++ b/web/app/components/app-sidebar/app-info/__tests__/app-info-modals.spec.tsx
@@ -1,365 +1,315 @@
-import type { AppDetailWithSite } from '@dify/contracts/api/console/apps/types.gen'
-import { act, fireEvent, render, screen, waitFor } from '@testing-library/react'
+import type { AppInfoOperation } from '../app-info-modals'
+import { act, fireEvent, screen, waitFor, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
-import * as React from 'react'
+import { useState } from 'react'
+import { consoleQuery } from '@/service/console'
+import { createConsoleQueryClient, renderWithConsoleQuery } from '@/test/console/query-data'
+import { mockEmojiData } from '@/test/emoji-picker'
import { createAppDetailFixture } from '@/test/fixtures/app'
import AppInfoModals from '../app-info-modals'
-
-vi.mock('next/dynamic', () => ({
- default: (loader: () => Promise<{ default: React.ComponentType }>) => {
- const LazyComp = React.lazy(loader)
- return function DynamicWrapper(props: Record<string, unknown>) {
- return React.createElement(
- React.Suspense,
- { fallback: null },
- React.createElement(LazyComp, props),
- )
- }
- },
-}))
-
-vi.mock('@/app/components/app/switch-app-modal', () => ({
- default: ({ show, onClose }: { show: boolean; onClose: () => void }) =>
- show ? (
- <div data-testid="switch-modal">
- <button type="button" onClick={onClose}>
- Close Switch
- </button>
- </div>
- ) : null,
+import { AppMetadataDialog } from '../app-metadata-dialog'
+import { DeleteAppDialog } from '../delete-app-dialog'
+import { ExportAppDialog } from '../export-app-dialog'
+
+const service = vi.hoisted(() => ({
+ request: vi.fn(),
+ replace: vi.fn(),
+ exportWorkflow: vi.fn(),
+ exportApp: vi.fn(),
+ notify: vi.fn(),
}))
-
-vi.mock('@/app/components/explore/create-app-modal', () => ({
- default: ({
- show,
- onHide,
- isEditModal,
- }: {
- show: boolean
- onHide: () => void
- isEditModal?: boolean
- }) =>
- show ? (
- <div data-testid={isEditModal ? 'edit-modal' : 'create-modal'}>
- <button type="button" onClick={onHide}>
- Close Edit
- </button>
- </div>
- ) : null,
+vi.mock('@/next/navigation', () => ({ useRouter: () => ({ replace: service.replace }) }))
+vi.mock('@/app/notifications', () => ({
+ toast: { error: service.notify, success: service.notify },
}))
-
-vi.mock('@/app/components/app/duplicate-modal', () => ({
- default: ({ show, onHide }: { show: boolean; onHide: () => void }) =>
- show ? (
- <div data-testid="duplicate-modal">
- <button type="button" onClick={onHide}>
- Close Dup
- </button>
- </div>
- ) : null,
+vi.mock('@/app/components/app/use-export-app-dsl', () => ({
+ useExportWorkflowAppDsl: () => ({
+ exportWorkflowAppDsl: service.exportWorkflow,
+ isExporting: false,
+ }),
+ useExportAppDsl: () => ({ exportAppDsl: service.exportApp, isExporting: false }),
}))
-
-vi.mock('@/app/components/workflow/update-dsl-modal', () => ({
- default: ({ onCancel, onBackup }: { onCancel: () => void; onBackup: () => void }) => (
- <div data-testid="import-dsl-modal">
- <button type="button" onClick={onCancel}>
- Cancel Import
- </button>
- <button type="button" onClick={onBackup}>
- Backup
- </button>
- </div>
- ),
-}))
-
-vi.mock('@/app/components/app/export-confirm-modal', () => ({
- AppExportConfirmContent: ({
- onConfirm,
- onClose,
- }: {
- onConfirm: (include?: boolean) => void
- onClose: () => void
- }) => (
- <div data-testid="dsl-export-confirm-modal">
- <button type="button" onClick={() => onConfirm(true)}>
- Export Include
- </button>
- <button type="button" onClick={onClose}>
- Close Export
- </button>
- </div>
- ),
- default: ({
- onConfirm,
- onClose,
- }: {
- onConfirm: (include?: boolean) => void
- onClose: () => void
- }) => (
- <div data-testid="dsl-export-confirm-modal">
- <button type="button" onClick={() => onConfirm(true)}>
- Export Include
- </button>
- <button type="button" onClick={onClose}>
- Close Export
- </button>
- </div>
- ),
+vi.mock('@/service/base', () => ({ request: (...args: unknown[]) => service.request(...args) }))
+vi.mock('@/app/components/workflow/collaboration/core/websocket-manager', () => ({
+ webSocketClient: { getSocket: () => null },
}))
-const createAppDetail = (overrides: Partial<AppDetailWithSite> = {}) =>
- createAppDetailFixture({
- id: 'app-1',
- name: 'Test App',
- mode: 'chat' as const,
- icon: '🤖',
- icon_type: 'emoji',
- icon_background: '#FFEAD5',
- icon_url: '',
- description: '',
- use_icon_as_answer_icon: false,
- max_active_requests: null,
- ...overrides,
- })
-
-const defaultProps = {
- appDetail: createAppDetail(),
- closeModal: vi.fn(),
- secretEnvList: [] as never[],
- setSecretEnvList: vi.fn(),
- onEdit: vi.fn(),
- onCopy: vi.fn(),
- onExport: vi.fn(async () => true),
- isExporting: false,
- exportCheck: vi.fn(),
- handleConfirmExport: vi.fn(async () => {}),
- onConfirmDelete: vi.fn(),
+const app = createAppDetailFixture({
+ name: 'Test app',
+ description: 'Saved description',
+ mode: 'workflow',
+ icon_type: 'emoji',
+ icon: '🚀',
+ icon_background: '#FFEAD5',
+ permission_keys: ['app.acl.view_layout'],
+})
+function MetadataEntry({ operation = 'edit' }: { operation?: 'edit' | 'duplicate' }) {
+ const [open, setOpen] = useState(true)
+ return (
+ <>
+ <button onClick={() => setOpen(true)}>Reopen</button>
+ <AppMetadataDialog appDetail={app} operation={operation} open={open} onOpenChange={setOpen} />
+ </>
+ )
}
-
-describe('AppInfoModals', () => {
- beforeAll(async () => {
- await new Promise((resolve) => setTimeout(resolve, 0))
- })
-
- beforeEach(() => {
- vi.clearAllMocks()
+function DeleteEntry() {
+ const [open, setOpen] = useState(true)
+ return <DeleteAppDialog appDetail={app} open={open} onOpenChange={setOpen} />
+}
+function ExportEntry() {
+ const [open, setOpen] = useState(true)
+ return <ExportAppDialog appDetail={app} open={open} onOpenChange={setOpen} />
+}
+const render = (ui: React.ReactElement) =>
+ renderWithConsoleQuery(ui, {
+ queryClient: createConsoleQueryClient(),
+ systemFeatures: { deployment_edition: 'COMMUNITY', rbac_enabled: false },
})
- it('should render nothing when activeModal is null', async () => {
- await act(async () => {
- render(<AppInfoModals {...defaultProps} activeModal={null} />)
- })
- expect(screen.queryByTestId('switch-modal')).not.toBeInTheDocument()
- expect(screen.queryByText('app.deleteAppConfirmTitle')).not.toBeInTheDocument()
- })
+beforeEach(() => {
+ service.replace.mockReset()
+ service.request.mockReset()
+ service.exportApp.mockReset()
+ service.exportWorkflow.mockReset()
+})
- it('should render SwitchAppModal when activeModal is switch', async () => {
- await act(async () => {
- render(<AppInfoModals {...defaultProps} activeModal="switch" />)
- })
- await waitFor(() => {
- expect(screen.getByTestId('switch-modal')).toBeInTheDocument()
- })
- })
+it('keeps the edit draft on failure, guards pending dismissal and closes only after a successful save', async () => {
+ const user = userEvent.setup()
+ let reject: (error: Error) => void = () => {}
+ service.request.mockImplementationOnce(
+ () =>
+ new Promise((_resolve, rejectRequest) => {
+ reject = rejectRequest
+ }),
+ )
+ render(<MetadataEntry />)
+ const name = await screen.findByRole('textbox', { name: 'app.newApp.captionName' })
+ await user.clear(name)
+ await user.type(name, 'Retried name')
+ await user.click(screen.getByRole('button', { name: 'common.operation.save' }))
+ await waitFor(() => expect(service.request).toHaveBeenCalledTimes(1))
+ expect(name).toHaveAttribute('readonly')
+ await user.keyboard('{Escape}')
+ expect(screen.getByRole('dialog')).toBeInTheDocument()
+ await act(async () => reject(new Error('Unavailable')))
+ await waitFor(() => expect(name).not.toHaveAttribute('readonly'))
+ expect(name).toHaveValue('Retried name')
+ service.request.mockResolvedValueOnce(Response.json({ ...app, name: 'Retried name' }))
+ await user.click(screen.getByRole('button', { name: 'common.operation.save' }))
+ await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument())
+})
- it('should render CreateAppModal in edit mode when activeModal is edit', async () => {
- await act(async () => {
- render(<AppInfoModals {...defaultProps} activeModal="edit" />)
- })
- await waitFor(() => {
- expect(screen.getByTestId('edit-modal')).toBeInTheDocument()
- })
- })
+it('keeps the edit draft after an outside press and still allows explicit cancellation', async () => {
+ const user = userEvent.setup()
+ render(<MetadataEntry />)
+ const name = await screen.findByRole('textbox', { name: 'app.newApp.captionName' })
+ await user.clear(name)
+ await user.type(name, 'Unsaved draft')
+ await user.click(document.body)
+ expect(screen.getByRole('dialog')).toBeInTheDocument()
+ expect(name).toHaveValue('Unsaved draft')
+ expect(service.request).not.toHaveBeenCalled()
+ await user.click(screen.getByRole('button', { name: 'common.operation.cancel' }))
+ await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument())
+})
- it('should render DuplicateAppModal when activeModal is duplicate', async () => {
- await act(async () => {
- render(<AppInfoModals {...defaultProps} activeModal="duplicate" />)
- })
- await waitFor(() => {
- expect(screen.getByTestId('duplicate-modal')).toBeInTheDocument()
- })
- })
+it('discards a cancelled draft and initializes the next edit session from saved data', async () => {
+ const user = userEvent.setup()
+ render(<MetadataEntry />)
+ const name = await screen.findByRole('textbox', { name: 'app.newApp.captionName' })
+ await user.clear(name)
+ await user.type(name, 'Discarded')
+ await user.click(screen.getByRole('button', { name: 'common.operation.cancel' }))
+ await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument())
+ await user.click(screen.getByRole('button', { name: 'Reopen' }))
+ expect(await screen.findByRole('textbox', { name: 'app.newApp.captionName' })).toHaveValue(
+ app.name,
+ )
+})
- it('should render delete alert dialog when activeModal is delete', async () => {
- await act(async () => {
- render(<AppInfoModals {...defaultProps} activeModal="delete" />)
- })
- await waitFor(() => {
- expect(screen.getByText('app.deleteAppConfirmTitle')).toBeInTheDocument()
- expect(screen.getByRole('textbox')).toBeInTheDocument()
- })
- })
+it('keeps the duplicate name after a failed copy', async () => {
+ const user = userEvent.setup()
+ service.request.mockRejectedValueOnce(new Error('Unavailable'))
+ render(<MetadataEntry operation="duplicate" />)
+ const name = await screen.findByRole('textbox', { name: 'app.newApp.captionName' })
+ await user.clear(name)
+ await user.type(name, 'Copy draft{Enter}')
+ await waitFor(() => expect(service.request).toHaveBeenCalledTimes(1))
+ await waitFor(() => expect(name).not.toHaveAttribute('readonly'))
+ expect(name).toHaveValue('Copy draft')
+ expect(screen.getByRole('dialog')).toBeInTheDocument()
+})
- it('should name the delete confirmation input with its visible label', async () => {
- await act(async () => {
- render(<AppInfoModals {...defaultProps} activeModal="delete" />)
- })
+it('retains deletion confirmation after failure and prevents repeated submission while pending', async () => {
+ const user = userEvent.setup()
+ let reject: (error: Error) => void = () => {}
+ service.request.mockImplementationOnce(
+ () =>
+ new Promise((_resolve, rejectRequest) => {
+ reject = rejectRequest
+ }),
+ )
+ render(<DeleteEntry />)
+ await user.click(screen.getByRole('button', { name: 'common.operation.fill' }))
+ await user.click(screen.getByRole('button', { name: 'common.operation.confirm' }))
+ await waitFor(() => expect(service.request).toHaveBeenCalledTimes(1))
+ await user.keyboard('{Escape}')
+ expect(screen.getByRole('alertdialog')).toBeInTheDocument()
+ await act(async () => reject(new Error('Unavailable')))
+ await waitFor(() =>
+ expect(screen.getByRole('button', { name: 'common.operation.cancel' })).not.toBeDisabled(),
+ )
+ expect(screen.getByRole('textbox')).toHaveValue(app.name)
+ expect(service.replace).not.toHaveBeenCalled()
+})
- expect(
- await screen.findByRole('textbox', { name: /app\.deleteAppConfirmInputLabel/ }),
- ).toBeInTheDocument()
+it('submits the secret choice and keeps the export confirmation open after a failed download', async () => {
+ const user = userEvent.setup()
+ service.exportWorkflow.mockResolvedValue({
+ status: 'confirmation-required',
+ secretEnvList: [{ name: 'API_TOKEN', value: 'masked', value_type: 'secret' }],
})
+ service.exportApp.mockResolvedValue({ status: 'failed' })
+ render(<ExportEntry />)
+ await user.click(screen.getByRole('button', { name: 'common.operation.confirm' }))
+ const dialog = await screen.findByRole('alertdialog', { name: 'app.exportSecret.title' })
+ await user.click(within(dialog).getByRole('checkbox'))
+ await user.click(within(dialog).getByRole('button', { name: 'app.exportSecret.title' }))
+ await waitFor(() =>
+ expect(service.exportApp).toHaveBeenCalledWith({
+ appId: app.id,
+ appName: app.name,
+ includeSecret: true,
+ }),
+ )
+ expect(dialog).toBeInTheDocument()
+})
- it('should render UpdateDSLModal when activeModal is importDSL', async () => {
- await act(async () => {
- render(<AppInfoModals {...defaultProps} activeModal="importDSL" />)
- })
- await waitFor(() => {
- expect(screen.getByTestId('import-dsl-modal')).toBeInTheDocument()
- })
- })
+function OperationsEntry({ operation }: { operation: AppInfoOperation }) {
+ const [activeModal, setActiveModal] = useState<AppInfoOperation | null>(null)
+ return (
+ <>
+ <button onClick={() => setActiveModal(operation)}>Open operation</button>
+ <AppInfoModals
+ appDetail={app}
+ activeModal={activeModal}
+ onOpenChange={(open) => {
+ if (!open) setActiveModal(null)
+ }}
+ exportOpen={false}
+ onExportOpenChange={() => {}}
+ />
+ </>
+ )
+}
- it('should render export warning alert dialog when activeModal is exportWarning', async () => {
- await act(async () => {
- render(<AppInfoModals {...defaultProps} activeModal="exportWarning" />)
- })
- await waitFor(() => {
- expect(screen.getByText('workflow.sidebar.exportWarning')).toBeInTheDocument()
- })
- })
+it.each(['edit', 'duplicate', 'switch', 'delete', 'importDSL'] as const)(
+ 'animates the first %s opening and focuses its input control',
+ async (operation) => {
+ render(<OperationsEntry operation={operation} />)
+ fireEvent.click(screen.getByRole('button', { name: 'Open operation' }))
+ const dialog = screen.getByRole(operation === 'delete' ? 'alertdialog' : 'dialog')
+ expect(dialog).toHaveAttribute('data-starting-style')
+ const target =
+ operation === 'importDSL'
+ ? within(dialog).getByRole('button', { name: 'app.dslUploader.browse' })
+ : within(dialog).getByRole(
+ 'textbox',
+ operation === 'delete'
+ ? {}
+ : { name: operation === 'switch' ? 'app.switchLabel' : 'app.newApp.captionName' },
+ )
+ await waitFor(() => expect(target).toHaveFocus())
+ },
+)
+
+it('preserves the selected import file while opening and cancelling its nested backup dialog', async () => {
+ const user = userEvent.setup()
+ render(<OperationsEntry operation="importDSL" />)
+ await user.click(screen.getByRole('button', { name: 'Open operation' }))
+ const input = document.querySelector<HTMLInputElement>('input[type="file"]')!
+ await user.upload(input, new File(['workflow: {}'], 'draft.yaml', { type: 'application/yaml' }))
+ await user.click(screen.getByRole('button', { name: 'workflow.common.backupCurrentDraft' }))
+ expect(screen.getByRole('alertdialog')).toBeInTheDocument()
+ await user.keyboard('{Escape}')
+ await waitFor(() => expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument())
+ expect(screen.getByText('draft.yaml')).toBeInTheDocument()
+ expect(screen.getByRole('button', { name: 'workflow.common.backupCurrentDraft' })).toHaveFocus()
+ await user.click(screen.getByRole('button', { name: 'app.newApp.Cancel' }))
+ await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument())
+ await user.click(screen.getByRole('button', { name: 'Open operation' }))
+ expect(screen.queryByText('draft.yaml')).not.toBeInTheDocument()
+ expect(screen.getByRole('button', { name: 'workflow.common.overwriteAndImport' })).toBeDisabled()
+})
- it('should render AppExportConfirmModal when secretEnvList is not empty', async () => {
- await act(async () => {
- render(
- <AppInfoModals
- {...defaultProps}
- activeModal={null}
- secretEnvList={[
- {
- id: 'env-1',
- key: 'SECRET',
- value: '',
- value_type: 'secret',
- name: 'Secret',
- } as never,
- ]}
- />,
- )
- })
- await waitFor(() => {
- expect(screen.getByTestId('dsl-export-confirm-modal')).toBeInTheDocument()
- })
+it('validates the edit form and submits current values after choosing an icon', async () => {
+ const user = userEvent.setup()
+ service.request.mockResolvedValueOnce(Response.json(app))
+ render(<MetadataEntry />)
+ const name = await screen.findByRole('textbox', { name: 'app.newApp.captionName' })
+ await user.clear(name)
+ await user.keyboard('{Enter}')
+ expect(service.request).not.toHaveBeenCalled()
+ await user.type(name, 'Edited name')
+ await user.click(screen.getByRole('button', { name: 'app.iconPicker.title' }))
+ await user.click(await screen.findByRole('radio', { name: 'app.iconPicker.color.green' }))
+ await user.click(screen.getByRole('button', { name: /iconPicker\.ok/ }))
+ await waitFor(() =>
+ expect(screen.queryByPlaceholderText('app.iconPicker.search')).not.toBeInTheDocument(),
+ )
+ expect(service.request).not.toHaveBeenCalled()
+ await user.click(name)
+ await user.keyboard('{Enter}')
+ await waitFor(() => expect(service.request).toHaveBeenCalledTimes(1))
+ const request = service.request.mock.calls.at(0)?.[2]?.request
+ expect(request).toBeInstanceOf(Request)
+ const payload = await request.json()
+ expect(payload).toMatchObject({
+ name: 'Edited name',
+ description: 'Saved description',
+ icon_background: '#F3FEE7',
})
+ expect(payload.max_active_requests).not.toBeNull()
+ await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument())
+})
- it('should not render AppExportConfirmModal when secretEnvList is empty', async () => {
- await act(async () => {
- render(<AppInfoModals {...defaultProps} activeModal={null} />)
- })
- expect(screen.queryByTestId('dsl-export-confirm-modal')).not.toBeInTheDocument()
- })
+mockEmojiData()
- it('should call closeModal when cancel on delete modal', async () => {
+it.each(['duplicate', 'delete'] as const)(
+ 'preserves shared cache invalidation after a successful %s',
+ async (operation) => {
const user = userEvent.setup()
- await act(async () => {
- render(<AppInfoModals {...defaultProps} activeModal="delete" />)
- })
-
- await waitFor(() =>
- expect(screen.getByRole('button', { name: 'common.operation.cancel' })).toBeInTheDocument(),
+ const queryClient = createConsoleQueryClient()
+ const invalidate = vi.spyOn(queryClient, 'invalidateQueries')
+ service.request.mockResolvedValueOnce(
+ Response.json(operation === 'duplicate' ? app : { result: 'success' }),
+ )
+ renderWithConsoleQuery(
+ operation === 'duplicate' ? <MetadataEntry operation="duplicate" /> : <DeleteEntry />,
+ {
+ queryClient,
+ systemFeatures: { deployment_edition: 'COMMUNITY', rbac_enabled: false },
+ },
+ )
+ if (operation === 'delete')
+ await user.click(screen.getByRole('button', { name: 'common.operation.fill' }))
+ await user.click(
+ screen.getByRole('button', {
+ name: operation === 'delete' ? 'common.operation.confirm' : 'app.duplicate',
+ }),
)
- await user.click(screen.getByRole('button', { name: 'common.operation.cancel' }))
-
- expect(defaultProps.closeModal).toHaveBeenCalledTimes(1)
- })
-
- it('should clear the delete confirmation input when delete modal is cancelled', async () => {
- const user = userEvent.setup()
- await act(async () => {
- render(<AppInfoModals {...defaultProps} activeModal="delete" />)
- })
-
- const input = await screen.findByRole('textbox')
- await user.type(input, 'wrong-name')
- await user.click(screen.getByRole('button', { name: 'common.operation.cancel' }))
-
- expect(defaultProps.closeModal).toHaveBeenCalledTimes(1)
- expect(input).toHaveValue('')
- })
-
- it('should not confirm delete when the form is submitted with unmatched input', async () => {
- await act(async () => {
- render(<AppInfoModals {...defaultProps} activeModal="delete" />)
- })
-
- const form = document.querySelector('form')
- expect(form).toBeTruthy()
-
- fireEvent.submit(form!)
-
- expect(defaultProps.onConfirmDelete).not.toHaveBeenCalled()
- })
-
- it('should call onConfirmDelete when confirm on delete modal', async () => {
- const user = userEvent.setup()
- await act(async () => {
- render(<AppInfoModals {...defaultProps} activeModal="delete" />)
- })
-
- await user.type(screen.getByRole('textbox'), 'Test App')
- await user.click(screen.getByRole('button', { name: 'common.operation.confirm' }))
-
- expect(defaultProps.onConfirmDelete).toHaveBeenCalledTimes(1)
- })
-
- it('should call handleConfirmExport when confirm on export warning', async () => {
- const user = userEvent.setup()
- await act(async () => {
- render(<AppInfoModals {...defaultProps} activeModal="exportWarning" />)
- })
-
await waitFor(() =>
- expect(screen.getByRole('button', { name: 'common.operation.confirm' })).toBeInTheDocument(),
+ expect(service.replace).toHaveBeenCalledWith(
+ operation === 'delete' ? '/apps' : `/app/${app.id}/workflow`,
+ ),
)
- await user.click(screen.getByRole('button', { name: 'common.operation.confirm' }))
-
- expect(defaultProps.handleConfirmExport).toHaveBeenCalledTimes(1)
- })
-
- it('should show the export warning confirmation as pending during export', async () => {
- await act(async () => {
- render(<AppInfoModals {...defaultProps} activeModal="exportWarning" isExporting />)
- })
-
- expect(
- await screen.findByRole('button', { name: 'common.operation.exporting' }),
- ).toBeInTheDocument()
- })
-
- it('should call exportCheck when backup on importDSL modal', async () => {
- const user = userEvent.setup()
- await act(async () => {
- render(<AppInfoModals {...defaultProps} activeModal="importDSL" />)
- })
-
- await waitFor(() => expect(screen.getByText('Backup')).toBeInTheDocument())
- await user.click(screen.getByText('Backup'))
-
- expect(defaultProps.exportCheck).toHaveBeenCalledTimes(1)
- })
-
- it('should call setSecretEnvList with empty array when closing AppExportConfirmModal', async () => {
- const user = userEvent.setup()
- await act(async () => {
- render(
- <AppInfoModals
- {...defaultProps}
- activeModal={null}
- secretEnvList={[
- {
- id: 'env-1',
- key: 'SECRET',
- value: '',
- value_type: 'secret',
- name: 'Secret',
- } as never,
- ]}
- />,
- )
- })
-
- await waitFor(() => expect(screen.getByText('Close Export')).toBeInTheDocument())
- await user.click(screen.getByText('Close Export'))
-
- expect(defaultProps.setSecretEnvList).toHaveBeenCalledWith([])
- })
-})
+ for (const queryKey of [
+ consoleQuery.apps.get.key(),
+ consoleQuery.apps.starred.get.key(),
+ consoleQuery.apps.recent.get.key(),
+ consoleQuery.features.get.key(),
+ ]) {
+ expect(invalidate).toHaveBeenCalledWith({ queryKey })
+ }
+ },
+)
diff --git a/web/app/components/app-sidebar/app-info/__tests__/use-app-info-actions.spec.ts b/web/app/components/app-sidebar/app-info/__tests__/use-app-info-actions.spec.ts
deleted file mode 100644
index 013ba7ae1a2..00000000000
--- a/web/app/components/app-sidebar/app-info/__tests__/use-app-info-actions.spec.ts
+++ /dev/null
@@ -1,511 +0,0 @@
-import type { AppDetailWithSite } from '@dify/contracts/api/console/apps/types.gen'
-import { act, waitFor } from '@testing-library/react'
-import { consoleQuery } from '@/service/console'
-import { createConsoleQueryClient, renderHookWithConsoleQuery } from '@/test/console/query-data'
-import { createAppDetailFixture } from '@/test/fixtures/app'
-import { getRedirection } from '@/utils/app-redirection'
-import { useAppInfoActions } from '../use-app-info-actions'
-
-const toastMocks = vi.hoisted(() => {
- const call = vi.fn()
- return {
- call,
- api: vi.fn((message: unknown, options?: Record<string, unknown>) =>
- call({ message, ...options }),
- ),
- dismiss: vi.fn(),
- update: vi.fn(),
- promise: vi.fn(),
- }
-})
-const mockReplace = vi.fn()
-const mockUpdateAppInfo = vi.fn()
-const mockCopyApp = vi.fn()
-const mockExportAppDsl = vi.fn()
-const mockExportState = { isExporting: false }
-const mockExportWorkflowAppDsl = vi.fn()
-const mockWorkflowExportState = { isExporting: false }
-const mockDeleteApp = vi.fn()
-const mockFetchAppDetail = vi.fn()
-const mockMarkAppDeletionStarted = vi.fn()
-const mockMarkAppDeletionSucceeded = vi.fn()
-const mockMarkAppDeletionFailed = vi.fn()
-const mockGetSocket = vi.fn()
-const mockOnAppMetaUpdate = vi.fn()
-
-let mockAppDetail: AppDetailWithSite
-
-const appDetailQueryKey = consoleQuery.apps.byAppId.get.queryKey({
- input: { params: { app_id: 'app-1' } },
-})
-const appListQueryKeys = [
- consoleQuery.apps.get.key(),
- consoleQuery.apps.starred.get.key(),
- consoleQuery.apps.recent.get.key(),
-]
-
-const renderActions = () => {
- const queryClient = createConsoleQueryClient()
- if (mockAppDetail) queryClient.setQueryData(appDetailQueryKey, mockAppDetail)
- for (const queryKey of appListQueryKeys) queryClient.setQueryData(queryKey, { data: [] })
- return renderHookWithConsoleQuery(
- () =>
- useAppInfoActions({
- appId: mockAppDetail.id,
- appName: mockAppDetail.name,
- appMode: mockAppDetail.mode,
- }),
- {
- queryClient,
- systemFeatures: { rbac_enabled: true },
- },
- )
-}
-
-vi.mock('@/next/navigation', () => ({
- useRouter: () => ({ replace: mockReplace }),
-}))
-
-vi.mock('@/app/components/app/use-export-app-dsl', () => ({
- useExportAppDsl: () => ({
- exportAppDsl: mockExportAppDsl,
- isExporting: mockExportState.isExporting,
- }),
- useExportWorkflowAppDsl: () => ({
- exportWorkflowAppDsl: mockExportWorkflowAppDsl,
- isExporting: mockWorkflowExportState.isExporting,
- }),
-}))
-
-vi.mock('@/app/notifications', () => ({
- toast: Object.assign(toastMocks.api, {
- success: vi.fn((message, options) => toastMocks.call({ type: 'success', message, ...options })),
- error: vi.fn((message, options) => toastMocks.call({ type: 'error', message, ...options })),
- warning: vi.fn((message, options) => toastMocks.call({ type: 'warning', message, ...options })),
- info: vi.fn((message, options) => toastMocks.call({ type: 'info', message, ...options })),
- dismiss: toastMocks.dismiss,
- update: toastMocks.update,
- promise: toastMocks.promise,
- }),
-}))
-
-vi.mock('@/service/base', async (importOriginal) => ({
- ...(await importOriginal<typeof import('@/service/base')>()),
- request: async (url: string, _init: RequestInit, { request }: { request: Request }) => {
- if (request.method === 'GET') return Response.json(await mockFetchAppDetail(url))
- if (request.method === 'PUT')
- return Response.json(await mockUpdateAppInfo(url, await request.json()))
- if (request.method === 'POST' && new URL(url).pathname.endsWith('/copy'))
- return Response.json(await mockCopyApp(url, await request.json()))
- if (request.method === 'DELETE') {
- await mockDeleteApp(url)
- return new Response(null, { status: 204 })
- }
- throw new Error(`Unexpected request: ${request.method} ${url}`)
- },
-}))
-
-vi.mock('@/service/app-deletion', () => ({
- markAppDeletionStarted: (...args: unknown[]) => mockMarkAppDeletionStarted(...args),
- markAppDeletionSucceeded: (...args: unknown[]) => mockMarkAppDeletionSucceeded(...args),
- markAppDeletionFailed: (...args: unknown[]) => mockMarkAppDeletionFailed(...args),
-}))
-
-vi.mock('@/utils/app-redirection', () => ({
- getRedirection: vi.fn(),
-}))
-
-vi.mock('@/app/components/workflow/collaboration/core/websocket-manager', () => ({
- webSocketClient: {
- getSocket: (...args: unknown[]) => mockGetSocket(...args),
- },
-}))
-
-vi.mock('@/app/components/workflow/collaboration/core/collaboration-manager', () => ({
- collaborationManager: {
- onAppMetaUpdate: (...args: unknown[]) => mockOnAppMetaUpdate(...args),
- },
-}))
-
-describe('useAppInfoActions', () => {
- beforeEach(() => {
- vi.clearAllMocks()
- mockExportState.isExporting = false
- mockExportAppDsl.mockResolvedValue({ status: 'downloaded' })
- mockWorkflowExportState.isExporting = false
- mockExportWorkflowAppDsl.mockResolvedValue({ status: 'downloaded' })
- mockOnAppMetaUpdate.mockReturnValue(() => {})
- mockGetSocket.mockReturnValue(null)
- mockAppDetail = createAppDetailFixture({
- id: 'app-1',
- name: 'Test App',
- mode: 'chat' as const,
- icon: '🤖',
- icon_type: 'emoji',
- icon_background: '#FFEAD5',
- })
- })
-
- describe('Initial state', () => {
- it('should return initial state correctly', () => {
- const { result } = renderActions()
- expect(result.current.activeModal).toBeNull()
- expect(result.current.secretEnvList).toEqual([])
- })
- })
-
- describe('Modal management', () => {
- it('should open modal', () => {
- const { result } = renderActions()
-
- act(() => {
- result.current.openModal('edit')
- })
-
- expect(result.current.activeModal).toBe('edit')
- })
-
- it('should close modal', () => {
- const { result } = renderActions()
-
- act(() => {
- result.current.openModal('delete')
- })
-
- act(() => {
- result.current.closeModal()
- })
-
- expect(result.current.activeModal).toBeNull()
- })
- })
-
- describe('onEdit', () => {
- it('should update app info and close modal on success', async () => {
- const updatedApp = createAppDetailFixture({
- ...mockAppDetail,
- name: 'Updated',
- max_active_requests: null,
- })
- mockUpdateAppInfo.mockResolvedValue(updatedApp)
-
- const { result, queryClient } = renderActions()
-
- await act(async () => {
- await result.current.onEdit({
- name: 'Updated',
- icon_type: 'emoji',
- icon: '🤖',
- icon_background: '#fff',
- description: '',
- use_icon_as_answer_icon: false,
- })
- })
-
- expect(mockUpdateAppInfo).toHaveBeenCalledWith(expect.stringContaining('/apps/app-1'), {
- name: 'Updated',
- icon_type: 'emoji',
- icon: '🤖',
- icon_background: '#fff',
- description: '',
- use_icon_as_answer_icon: false,
- })
- expect(queryClient.getQueryData(appDetailQueryKey)).toEqual(updatedApp)
- for (const queryKey of appListQueryKeys)
- expect(queryClient.getQueryState(queryKey)?.isInvalidated).toBe(true)
- })
-
- it('should emit app_meta_update after successful edit when collaboration socket exists', async () => {
- const updatedApp = createAppDetailFixture({ ...mockAppDetail, name: 'Updated' })
- const socket = { emit: vi.fn() }
- mockUpdateAppInfo.mockResolvedValue(updatedApp)
- mockGetSocket.mockReturnValue(socket)
-
- const { result } = renderActions()
-
- await act(async () => {
- await result.current.onEdit({
- name: 'Updated',
- icon_type: 'emoji',
- icon: '🤖',
- icon_background: '#fff',
- description: '',
- use_icon_as_answer_icon: false,
- })
- })
- await waitFor(() => expect(socket.emit).toHaveBeenCalled())
-
- expect(mockGetSocket).toHaveBeenCalledWith('app-1')
- expect(socket.emit).toHaveBeenCalledWith(
- 'collaboration_event',
- expect.objectContaining({
- type: 'app_meta_update',
- }),
- )
- })
-
- it('should notify error on edit failure', async () => {
- mockUpdateAppInfo.mockRejectedValue(new Error('fail'))
-
- const { result } = renderActions()
-
- await act(async () => {
- await result.current.onEdit({
- name: 'Updated',
- icon_type: 'emoji',
- icon: '🤖',
- icon_background: '#fff',
- description: '',
- use_icon_as_answer_icon: false,
- })
- })
-
- expect(toastMocks.call).toHaveBeenCalledWith({ type: 'error', message: 'app.editFailed' })
- })
- })
-
- describe('onCopy', () => {
- it.each(['completed', 'pending'] as const)(
- 'should redirect only when the copy is completed (%s)',
- async (status) => {
- const newApp = createAppDetailFixture({ id: 'app-2', name: 'Copy' })
- mockCopyApp.mockResolvedValue(
- status === 'completed'
- ? newApp
- : {
- id: 'import-1',
- status: 'pending',
- current_dsl_version: '1.0.0',
- },
- )
-
- const { result } = renderActions()
-
- await act(async () => {
- await result.current.onCopy({
- name: 'Copy',
- icon_type: 'emoji',
- icon: '🤖',
- icon_background: '#fff',
- })
- })
-
- expect(mockCopyApp).toHaveBeenCalledWith(expect.stringContaining('/apps/app-1/copy'), {
- name: 'Copy',
- icon_type: 'emoji',
- icon: '🤖',
- icon_background: '#fff',
- })
- if (status === 'completed') {
- expect(toastMocks.call).toHaveBeenCalledWith({
- type: 'success',
- message: 'app.newApp.appCreated',
- })
- expect(getRedirection).toHaveBeenCalledWith(newApp, mockReplace, { isRbacEnabled: true })
- } else {
- expect(toastMocks.call).toHaveBeenCalledWith({
- type: 'error',
- message: 'app.newApp.appCreateFailed',
- })
- expect(getRedirection).not.toHaveBeenCalled()
- }
- },
- )
-
- it('should notify error on copy failure', async () => {
- mockCopyApp.mockRejectedValue(new Error('fail'))
-
- const { result } = renderActions()
-
- await act(async () => {
- await result.current.onCopy({
- name: 'Copy',
- icon_type: 'emoji',
- icon: '🤖',
- icon_background: '#fff',
- })
- })
-
- expect(toastMocks.call).toHaveBeenCalledWith({
- type: 'error',
- message: 'app.newApp.appCreateFailed',
- })
- })
- })
-
- describe('onExport', () => {
- it('should export the app DSL', async () => {
- const { result } = renderActions()
-
- await act(async () => {
- await result.current.onExport(false)
- })
-
- expect(mockExportAppDsl).toHaveBeenCalledWith({
- appId: 'app-1',
- appName: 'Test App',
- includeSecret: false,
- })
- })
- })
-
- it('preserves the export failure result for the confirmation dialog', async () => {
- mockExportAppDsl.mockResolvedValue({ status: 'failed' })
- const { result } = renderActions()
- await act(async () => {
- await expect(result.current.onExport(true)).resolves.toBe(false)
- })
- })
-
- describe('exportCheck', () => {
- it('should call onExport directly for non-workflow modes', async () => {
- const { result } = renderActions()
-
- await act(async () => {
- await result.current.exportCheck()
- })
-
- expect(mockExportAppDsl).toHaveBeenCalled()
- })
-
- it('should open export warning modal for workflow mode', async () => {
- mockAppDetail = createAppDetailFixture({ ...mockAppDetail, mode: 'workflow' as const })
-
- const { result } = renderActions()
-
- await act(async () => {
- await result.current.exportCheck()
- })
-
- expect(result.current.activeModal).toBe('exportWarning')
- })
-
- it('should open export warning modal for advanced_chat mode', async () => {
- mockAppDetail = createAppDetailFixture({ ...mockAppDetail, mode: 'advanced-chat' as const })
-
- const { result } = renderActions()
-
- await act(async () => {
- await result.current.exportCheck()
- })
-
- expect(result.current.activeModal).toBe('exportWarning')
- })
- })
-
- describe('handleConfirmExport', () => {
- it('keeps the warning open after failure so the user can retry', async () => {
- mockAppDetail = createAppDetailFixture({ ...mockAppDetail, mode: 'workflow' as const })
- mockExportWorkflowAppDsl
- .mockResolvedValueOnce({ status: 'failed' })
- .mockResolvedValueOnce({ status: 'downloaded' })
- const { result } = renderActions()
- await act(async () => {
- await result.current.exportCheck()
- })
- await act(async () => {
- await result.current.handleConfirmExport()
- })
- expect(result.current.activeModal).toBe('exportWarning')
- await act(async () => {
- await result.current.handleConfirmExport()
- })
- expect(result.current.activeModal).toBeNull()
- })
-
- it('should export directly when no secret env variables', async () => {
- mockAppDetail = createAppDetailFixture({ ...mockAppDetail, mode: 'workflow' as const })
- const { result } = renderActions()
-
- await act(async () => {
- await result.current.handleConfirmExport()
- })
-
- expect(mockExportWorkflowAppDsl).toHaveBeenCalledWith({
- appId: 'app-1',
- appName: 'Test App',
- })
- })
-
- it('should set secret env list when secret variables exist', async () => {
- mockAppDetail = createAppDetailFixture({ ...mockAppDetail, mode: 'workflow' as const })
- const secretVars = [{ value_type: 'secret', name: 'API_KEY', value: 'secret' }]
- mockExportWorkflowAppDsl.mockResolvedValue({
- status: 'confirmation-required',
- secretEnvList: secretVars,
- })
-
- const { result } = renderActions()
-
- await act(async () => {
- await result.current.handleConfirmExport()
- })
-
- expect(result.current.secretEnvList).toEqual(secretVars)
- })
- })
-
- describe('onConfirmDelete', () => {
- it('should delete app and redirect on success', async () => {
- mockDeleteApp.mockResolvedValue({})
-
- const { result } = renderActions()
-
- await act(async () => {
- await result.current.onConfirmDelete()
- })
-
- expect(mockDeleteApp).toHaveBeenCalledWith(expect.stringContaining('/apps/app-1'))
- expect(mockMarkAppDeletionStarted).toHaveBeenCalledWith('app-1')
- expect(mockMarkAppDeletionSucceeded).toHaveBeenCalledWith('app-1')
- expect(mockMarkAppDeletionFailed).not.toHaveBeenCalled()
- expect(toastMocks.call).toHaveBeenCalledWith({ type: 'success', message: 'app.appDeleted' })
- expect(mockReplace).toHaveBeenCalledWith('/apps')
- })
-
- it('should notify error on delete failure', async () => {
- mockDeleteApp.mockRejectedValue({ message: 'cannot delete' })
-
- const { result } = renderActions()
-
- await act(async () => {
- await result.current.onConfirmDelete()
- })
-
- expect(mockMarkAppDeletionStarted).toHaveBeenCalledWith('app-1')
- expect(mockMarkAppDeletionFailed).toHaveBeenCalledWith('app-1')
- expect(mockMarkAppDeletionSucceeded).not.toHaveBeenCalled()
- expect(toastMocks.call).toHaveBeenCalledWith({
- type: 'error',
- message: expect.stringContaining('app.appDeleteFailed'),
- })
- })
- })
-
- describe('collaboration app meta updates', () => {
- it('should refresh app detail when receiving app_meta_update', async () => {
- const updated = createAppDetailFixture({ ...mockAppDetail, name: 'Remote Updated' })
- const unsubscribe = vi.fn()
- let onUpdate: (() => Promise<void>) | undefined
-
- mockOnAppMetaUpdate.mockImplementation((callback: () => Promise<void>) => {
- onUpdate = callback
- return unsubscribe
- })
- mockFetchAppDetail.mockResolvedValue(updated)
-
- const { unmount, queryClient } = renderActions()
- await waitFor(() => expect(onUpdate).toBeDefined())
-
- await act(async () => {
- await onUpdate?.()
- })
-
- expect(mockFetchAppDetail).toHaveBeenCalledWith(expect.stringContaining('/apps/app-1'))
- expect(queryClient.getQueryData(appDetailQueryKey)).toEqual(updated)
-
- unmount()
- expect(unsubscribe).toHaveBeenCalled()
- })
- })
-})
diff --git a/web/app/components/app-sidebar/app-info/app-info-modals.tsx b/web/app/components/app-sidebar/app-info/app-info-modals.tsx
index 91db4c5a4d2..c669956a67e 100644
--- a/web/app/components/app-sidebar/app-info/app-info-modals.tsx
+++ b/web/app/components/app-sidebar/app-info/app-info-modals.tsx
@@ -1,250 +1,83 @@
-import type {
- AppDetailWithSite,
- EnvironmentVariableItemResponse,
-} from '@dify/contracts/api/console/apps/types.gen'
-import type { AppInfoModalType } from './use-app-info-actions'
-import type { DuplicateAppModalProps } from '@/app/components/app/duplicate-modal'
-import type { CreateAppModalProps } from '@/app/components/explore/create-app-modal'
-import {
- AlertDialog,
- AlertDialogCancelButton,
- AlertDialogConfirmButton,
- AlertDialogContent,
- AlertDialogDescription,
- AlertDialogFooter,
- AlertDialogHeader,
- AlertDialogTitle,
-} from '@langgenius/dify-ui/alert-dialog'
-import { Button } from '@langgenius/dify-ui/button'
-import { Field, FieldLabel } from '@langgenius/dify-ui/field'
-import { InputGroup, InputGroupAddon, InputGroupInput } from '@langgenius/dify-ui/input-group'
-import dynamic from 'next/dynamic'
-import * as React from 'react'
-import { useCallback, useState } from 'react'
-import { Trans, useTranslation } from 'react-i18next'
-import { AppExportConfirmContent } from '@/app/components/app/export-confirm-modal'
+import type { AppDetailWithSite } from '@dify/contracts/api/console/apps/types.gen'
+import type { AlertDialogProps } from '@langgenius/dify-ui/alert-dialog'
+import type { DialogProps } from '@langgenius/dify-ui/dialog'
+import { useState } from 'react'
+import SwitchAppModal from '@/app/components/app/switch-app-modal'
+import UpdateDSLModal from '@/app/components/workflow/update-dsl-modal'
+import { AppMetadataDialog } from './app-metadata-dialog'
+import { DeleteAppDialog } from './delete-app-dialog'
+import { ExportAppDialog } from './export-app-dialog'
-const SwitchAppModal = dynamic(() => import('@/app/components/app/switch-app-modal'), {
- ssr: false,
-})
-const CreateAppModal = dynamic(() => import('@/app/components/explore/create-app-modal'), {
- ssr: false,
-})
-const DuplicateAppModal = dynamic(() => import('@/app/components/app/duplicate-modal'), {
- ssr: false,
-})
-const UpdateDSLModal = dynamic(() => import('@/app/components/workflow/update-dsl-modal'), {
- ssr: false,
-})
+export type AppInfoOperation = 'edit' | 'duplicate' | 'delete' | 'switch' | 'importDSL'
type AppInfoModalsProps = {
appDetail: AppDetailWithSite
- activeModal: AppInfoModalType
- closeModal: () => void
- secretEnvList: EnvironmentVariableItemResponse[]
- setSecretEnvList: (list: EnvironmentVariableItemResponse[]) => void
- onEdit: CreateAppModalProps['onConfirm']
- onCopy: DuplicateAppModalProps['onConfirm']
- onExport: (include?: boolean) => Promise<boolean>
- isExporting: boolean
- exportCheck: () => void
- handleConfirmExport: () => Promise<void>
- onConfirmDelete: () => void
+ activeModal: AppInfoOperation | null
+ onOpenChange: DialogProps['onOpenChange']
+ exportOpen: AlertDialogProps['open']
+ onExportOpenChange: AlertDialogProps['onOpenChange']
}
-const AppInfoModals = ({
+export default function AppInfoModals({
appDetail,
activeModal,
- closeModal,
- secretEnvList,
- setSecretEnvList,
- onEdit,
- onCopy,
- onExport,
- isExporting,
- exportCheck,
- handleConfirmExport,
- onConfirmDelete,
-}: AppInfoModalsProps) => {
- const { t } = useTranslation(['app', 'common', 'workflow'])
- const [confirmDeleteInput, setConfirmDeleteInput] = useState('')
- const exportConfirmLabelId = React.useId()
- const isDeleteConfirmDisabled = confirmDeleteInput !== appDetail.name
- const exportDialogMode =
- secretEnvList.length > 0 ? 'secret' : activeModal === 'exportWarning' ? 'warning' : null
- const isExportDialogOpen = exportDialogMode !== null
-
- const handleDeleteDialogClose = () => {
- setConfirmDeleteInput('')
- closeModal()
- }
-
- const handleExportDialogClose = useCallback(() => {
- if (exportDialogMode === 'secret') {
- setSecretEnvList([])
- return
- }
-
- closeModal()
- }, [closeModal, exportDialogMode, setSecretEnvList])
-
- const handleExportDialogOpenChange = useCallback(
- (open: boolean) => {
- if (open || isExporting) return
-
- handleExportDialogClose()
- },
- [handleExportDialogClose, isExporting],
- )
-
+ onOpenChange,
+ exportOpen,
+ onExportOpenChange,
+}: AppInfoModalsProps) {
return (
<>
- {activeModal === 'switch' && (
- <SwitchAppModal show sourceApp={appDetail} onClose={closeModal} />
- )}
- {activeModal === 'edit' && (
- <CreateAppModal
- isEditModal
- appName={appDetail.name}
- appIconType={appDetail.icon_type}
- appIcon={appDetail.icon}
- appIconBackground={appDetail.icon_background}
- appIconUrl={appDetail.icon_url}
- appDescription={appDetail.description}
- appMode={appDetail.mode}
- appUseIconAsAnswerIcon={appDetail.use_icon_as_answer_icon}
- max_active_requests={appDetail.max_active_requests ?? null}
- show
- onConfirm={onEdit}
- onHide={closeModal}
- />
- )}
- {activeModal === 'duplicate' && (
- <DuplicateAppModal
- appName={appDetail.name}
- icon_type={appDetail.icon_type}
- icon={appDetail.icon}
- icon_background={appDetail.icon_background}
- icon_url={appDetail.icon_url}
- show
- onConfirm={onCopy}
- onHide={closeModal}
- />
- )}
- <AlertDialog
+ <AppMetadataDialog
+ appDetail={appDetail}
+ operation="edit"
+ open={activeModal === 'edit'}
+ onOpenChange={onOpenChange}
+ />
+ <AppMetadataDialog
+ appDetail={appDetail}
+ operation="duplicate"
+ open={activeModal === 'duplicate'}
+ onOpenChange={onOpenChange}
+ />
+ <SwitchAppModal
+ sourceApp={appDetail}
+ open={activeModal === 'switch'}
+ onOpenChange={onOpenChange}
+ />
+ <DeleteAppDialog
+ appDetail={appDetail}
open={activeModal === 'delete'}
- onOpenChange={(open) => !open && handleDeleteDialogClose()}
- >
- <AlertDialogContent>
- <form
- onSubmit={(e) => {
- e.preventDefault()
- if (isDeleteConfirmDisabled) return
- onConfirmDelete()
- }}
- >
- <AlertDialogHeader>
- <AlertDialogTitle>
- {t(($) => $.deleteAppConfirmTitle, { ns: 'app' })}
- </AlertDialogTitle>
- <AlertDialogDescription>
- {t(($) => $.deleteAppConfirmContent, { ns: 'app' })}
- </AlertDialogDescription>
- <Field name="confirm-app-name">
- <FieldLabel>
- <Trans
- i18nKey={($) => $.deleteAppConfirmInputLabel}
- ns="app"
- values={{ appName: appDetail.name }}
- components={{
- appName: (
- <span className="system-sm-semibold text-text-primary" translate="no" />
- ),
- }}
- />
- </FieldLabel>
- <InputGroup>
- <InputGroupInput
- type="text"
- autoComplete="off"
- spellCheck={false}
- placeholder={t(($) => $.deleteAppConfirmInputPlaceholder, { ns: 'app' })}
- value={confirmDeleteInput}
- onValueChange={setConfirmDeleteInput}
- />
- <InputGroupAddon align="inline-end">
- <Button
- variant="tertiary"
- size="small"
- onClick={() => setConfirmDeleteInput(appDetail.name)}
- >
- {t(($) => $['operation.fill'], { ns: 'common' })}
- </Button>
- </InputGroupAddon>
- </InputGroup>
- </Field>
- </AlertDialogHeader>
- <AlertDialogFooter>
- <AlertDialogCancelButton type="button">
- {t(($) => $['operation.cancel'], { ns: 'common' })}
- </AlertDialogCancelButton>
- <AlertDialogConfirmButton type="submit" disabled={isDeleteConfirmDisabled}>
- {t(($) => $['operation.confirm'], { ns: 'common' })}
- </AlertDialogConfirmButton>
- </AlertDialogFooter>
- </form>
- </AlertDialogContent>
- </AlertDialog>
- {activeModal === 'importDSL' && (
- <UpdateDSLModal
- appId={appDetail.id}
- appMode={appDetail.mode}
- onCancel={closeModal}
- onBackup={exportCheck}
- />
- )}
- <AlertDialog open={isExportDialogOpen} onOpenChange={handleExportDialogOpenChange}>
- {exportDialogMode === 'secret' ? (
- <AppExportConfirmContent
- envList={secretEnvList}
- onConfirm={onExport}
- onClose={() => setSecretEnvList([])}
- isExporting={isExporting}
- />
- ) : (
- exportDialogMode === 'warning' && (
- <AlertDialogContent>
- <AlertDialogHeader>
- <AlertDialogTitle>
- {t(($) => $['sidebar.exportWarning'], { ns: 'workflow' })}
- </AlertDialogTitle>
- <AlertDialogDescription>
- {t(($) => $['sidebar.exportWarningDesc'], { ns: 'workflow' })}
- </AlertDialogDescription>
- </AlertDialogHeader>
- <AlertDialogFooter>
- <AlertDialogCancelButton>
- {t(($) => $['operation.cancel'], { ns: 'common' })}
- </AlertDialogCancelButton>
- <AlertDialogConfirmButton
- tone="default"
- loading={isExporting}
- aria-labelledby={exportConfirmLabelId}
- onClick={handleConfirmExport}
- >
- <span id={exportConfirmLabelId}>
- {isExporting
- ? t(($) => $['operation.exporting'], { ns: 'common' })
- : t(($) => $['operation.confirm'], { ns: 'common' })}
- </span>
- </AlertDialogConfirmButton>
- </AlertDialogFooter>
- </AlertDialogContent>
- )
- )}
- </AlertDialog>
+ onOpenChange={onOpenChange}
+ />
+ <ImportAppDialog
+ appDetail={appDetail}
+ open={activeModal === 'importDSL'}
+ onOpenChange={onOpenChange}
+ />
+ <ExportAppDialog appDetail={appDetail} open={exportOpen} onOpenChange={onExportOpenChange} />
</>
)
}
-export default React.memo(AppInfoModals)
+function ImportAppDialog({
+ appDetail,
+ open,
+ onOpenChange,
+}: {
+ appDetail: AppDetailWithSite
+ open: DialogProps['open']
+ onOpenChange: DialogProps['onOpenChange']
+}) {
+ const [backupOpen, setBackupOpen] = useState(false)
+ return (
+ <UpdateDSLModal
+ appId={appDetail.id}
+ appMode={appDetail.mode}
+ open={open}
+ onOpenChange={onOpenChange}
+ onBackup={() => setBackupOpen(true)}
+ >
+ <ExportAppDialog appDetail={appDetail} open={backupOpen} onOpenChange={setBackupOpen} />
+ </UpdateDSLModal>
+ )
+}
diff --git a/web/app/components/app-sidebar/app-info/app-info-trigger.tsx b/web/app/components/app-sidebar/app-info/app-info-trigger.tsx
index c30ef4cbdb9..d295922489b 100644
--- a/web/app/components/app-sidebar/app-info/app-info-trigger.tsx
+++ b/web/app/components/app-sidebar/app-info/app-info-trigger.tsx
@@ -1,6 +1,6 @@
import type { AppDetailWithSite } from '@dify/contracts/api/console/apps/types.gen'
+import type { AppInfoOperation } from './app-info-modals'
import type { Operation } from './app-operations'
-import type { AppInfoModalType } from './use-app-info-actions'
import { useSuspenseQuery } from '@tanstack/react-query'
import { useAtomValue } from 'jotai'
import * as React from 'react'
@@ -14,7 +14,7 @@ import { getAppModeLabel } from './app-mode-labels'
type AppInfoTriggerProps = {
appDetail: AppDetailWithSite
expand: boolean
- openModal: (modal: Exclude<AppInfoModalType, null>) => void
+ openModal: (modal: AppInfoOperation) => void
isExporting: boolean
exportCheck: () => void
}
diff --git a/web/app/components/app-sidebar/app-info/app-metadata-dialog.tsx b/web/app/components/app-sidebar/app-info/app-metadata-dialog.tsx
new file mode 100644
index 00000000000..e5949d00c64
--- /dev/null
+++ b/web/app/components/app-sidebar/app-info/app-metadata-dialog.tsx
@@ -0,0 +1,291 @@
+import type {
+ AppDetailWithSite,
+ UpdateAppPayload,
+} from '@dify/contracts/api/console/apps/types.gen'
+import type { DialogActions, DialogProps } from '@langgenius/dify-ui/dialog'
+import type { IconPickerInputValue, IconPickerValue } from '@/app/components/base/icon-picker'
+import { Button } from '@langgenius/dify-ui/button'
+import {
+ Dialog,
+ DialogBody,
+ DialogClose,
+ DialogCloseButton,
+ DialogContent,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from '@langgenius/dify-ui/dialog'
+import { Field, FieldDescription, FieldError, FieldLabel } from '@langgenius/dify-ui/field'
+import { Form } from '@langgenius/dify-ui/form'
+import { Input } from '@langgenius/dify-ui/input'
+import { Switch } from '@langgenius/dify-ui/switch'
+import { Textarea } from '@langgenius/dify-ui/textarea'
+import { useMutation, useQuery, useQueryClient, useSuspenseQuery } from '@tanstack/react-query'
+import { useRef, useState } from 'react'
+import { useTranslation } from 'react-i18next'
+import {
+ IconPicker,
+ IconPickerContent,
+ IconPickerIcon,
+ IconPickerTrigger,
+} from '@/app/components/base/icon-picker'
+import AppsFull from '@/app/components/billing/apps-full-in-dialog'
+import { toast } from '@/app/notifications'
+import { systemFeaturesQueryOptions } from '@/features/system-features/client'
+import { useRouter } from '@/next/navigation'
+import { consoleQuery } from '@/service/console'
+import { getRedirection } from '@/utils/app-redirection'
+import { updateCachedAppMetadata } from './metadata'
+
+type AppMetadataDialogProps = Pick<DialogProps, 'open' | 'onOpenChange'> & {
+ appDetail: AppDetailWithSite
+ operation: 'edit' | 'duplicate'
+}
+
+export function AppMetadataDialog({
+ appDetail,
+ operation,
+ open,
+ onOpenChange,
+}: AppMetadataDialogProps) {
+ const actionsRef = useRef<DialogActions>(null)
+ const { t } = useTranslation(['app'])
+ const nameInputRef = useRef<HTMLInputElement>(null)
+ const queryClient = useQueryClient()
+ const { replace } = useRouter()
+ const { data: features } = useSuspenseQuery(systemFeaturesQueryOptions())
+ const edit = useMutation(
+ consoleQuery.apps.byAppId.put.mutationOptions({
+ onSuccess: (app) => {
+ queryClient.setQueryData(
+ consoleQuery.apps.byAppId.get.queryKey({ input: { params: { app_id: appDetail.id } } }),
+ (cached) => updateCachedAppMetadata(cached, app),
+ )
+ void queryClient.invalidateQueries({ queryKey: consoleQuery.apps.get.key() })
+ void queryClient.invalidateQueries({ queryKey: consoleQuery.apps.starred.get.key() })
+ void queryClient.invalidateQueries({ queryKey: consoleQuery.apps.recent.get.key() })
+ actionsRef.current?.close()
+ void import('@/app/components/workflow/collaboration/core/websocket-manager')
+ .then(({ webSocketClient }) => {
+ webSocketClient.getSocket(appDetail.id)?.emit('collaboration_event', {
+ type: 'app_meta_update',
+ data: { timestamp: Date.now() },
+ timestamp: Date.now(),
+ })
+ })
+ .catch(() => {})
+ },
+ onError: () => toast.error(t(($) => $.editFailed, { ns: 'app' })),
+ }),
+ )
+ const copy = useMutation(
+ consoleQuery.apps.byAppId.copy.post.mutationOptions({
+ onError: () => toast.error(t(($) => $['newApp.appCreateFailed'], { ns: 'app' })),
+ }),
+ )
+ const isPending = edit.isPending || copy.isPending
+ const submit = (body: UpdateAppPayload) => {
+ if (isPending) return
+ if (operation === 'edit') edit.mutate({ params: { app_id: appDetail.id }, body })
+ else
+ copy.mutate(
+ {
+ params: { app_id: appDetail.id },
+ body: {
+ name: body.name,
+ icon_type: body.icon_type,
+ icon: body.icon,
+ icon_background: body.icon_background,
+ },
+ },
+ {
+ onSuccess: (app) => {
+ if (!('mode' in app)) {
+ toast.error(t(($) => $['newApp.appCreateFailed'], { ns: 'app' }))
+ return
+ }
+ actionsRef.current?.close()
+ toast.success(t(($) => $['newApp.appCreated'], { ns: 'app' }))
+ getRedirection(app, replace, { isRbacEnabled: features.rbac_enabled })
+ },
+ },
+ )
+ }
+ return (
+ <Dialog
+ actionsRef={actionsRef}
+ open={open}
+ disablePointerDismissal={operation === 'edit'}
+ onOpenChange={(nextOpen, details) => {
+ if (!nextOpen && isPending && details.reason !== 'imperative-action') details.cancel()
+ else onOpenChange?.(nextOpen, details)
+ }}
+ >
+ <DialogContent initialFocus={nameInputRef}>
+ <AppMetadataForm
+ nameInputRef={nameInputRef}
+ appDetail={appDetail}
+ operation={operation}
+ isPending={isPending}
+ onSubmit={submit}
+ />
+ </DialogContent>
+ </Dialog>
+ )
+}
+
+type AppMetadataFormProps = Pick<AppMetadataDialogProps, 'appDetail' | 'operation'> & {
+ nameInputRef: React.RefObject<HTMLInputElement | null>
+ isPending: boolean
+ onSubmit: (body: UpdateAppPayload) => void
+}
+
+function AppMetadataForm({
+ appDetail,
+ operation,
+ nameInputRef,
+ isPending,
+ onSubmit,
+}: AppMetadataFormProps) {
+ const { t } = useTranslation(['app', 'common', 'explore'])
+ const formRef = useRef<HTMLFormElement>(null)
+ const [source] = useState(appDetail)
+ const [selectedIcon, setSelectedIcon] = useState<IconPickerValue | null>(null)
+ const { data: features } = useSuspenseQuery(systemFeaturesQueryOptions())
+ const isEdit = operation === 'edit'
+ const { data: quota } = useQuery(
+ consoleQuery.features.get.queryOptions({
+ enabled: !isEdit && features.deployment_edition === 'CLOUD',
+ select: (data) => data.apps,
+ }),
+ )
+ const quotaUnavailable = !isEdit && features.deployment_edition === 'CLOUD' && !quota
+ const isFull = !isEdit && !!quota && quota.limit > 0 && quota.size >= quota.limit
+ const icon: IconPickerInputValue | undefined =
+ selectedIcon ??
+ (source.icon_type === 'image' && source.icon
+ ? { type: 'image', fileId: source.icon, url: source.icon_url ?? '' }
+ : source.icon_type === 'emoji' && source.icon
+ ? { type: 'emoji', icon: source.icon, background: source.icon_background }
+ : source.icon_type === 'link' && source.icon
+ ? { type: 'link', url: source.icon }
+ : undefined)
+ return (
+ <Form
+ className="contents"
+ ref={formRef}
+ onFormSubmit={(values, details) => {
+ if (details.event.target !== formRef.current) return
+ const name = String(values.name ?? '')
+ if (isPending || quotaUnavailable || isFull || !name.trim()) return
+ const body: UpdateAppPayload = {
+ name,
+ icon_type: selectedIcon?.type ?? source.icon_type,
+ icon: selectedIcon
+ ? selectedIcon.type === 'emoji'
+ ? selectedIcon.icon
+ : selectedIcon.fileId
+ : source.icon,
+ icon_background: selectedIcon
+ ? selectedIcon.type === 'emoji'
+ ? selectedIcon.background
+ : undefined
+ : source.icon_background,
+ }
+ if (isEdit) {
+ body.description = String(values.description ?? '')
+ body.use_icon_as_answer_icon =
+ typeof values.use_icon_as_answer_icon === 'boolean'
+ ? values.use_icon_as_answer_icon
+ : source.use_icon_as_answer_icon
+ if (values.max_active_requests !== '' && values.max_active_requests !== undefined)
+ body.max_active_requests = Number(values.max_active_requests)
+ }
+ onSubmit(body)
+ }}
+ >
+ <DialogHeader>
+ <DialogTitle>
+ {isEdit
+ ? t(($) => $.editAppTitle, { ns: 'app' })
+ : t(($) => $.duplicateTitle, { ns: 'app' })}
+ </DialogTitle>
+ <DialogCloseButton
+ disabled={isPending}
+ aria-label={t(($) => $['operation.close'], { ns: 'common' })}
+ />
+ </DialogHeader>
+ <DialogBody className="flex flex-col gap-4">
+ <IconPicker value={icon} onValueChange={setSelectedIcon}>
+ <Field
+ name="name"
+ validate={(value) =>
+ typeof value === 'string' && !value.trim()
+ ? t(($) => $['appCustomize.nameRequired'], { ns: 'explore' })
+ : null
+ }
+ >
+ <FieldLabel>{t(($) => $['newApp.captionName'], { ns: 'app' })}</FieldLabel>
+ <div className="flex items-center gap-2">
+ <IconPickerTrigger
+ disabled={isPending}
+ aria-label={t(($) => $['iconPicker.title'], { ns: 'app' })}
+ >
+ <IconPickerIcon size="large" />
+ </IconPickerTrigger>
+ <Input ref={nameInputRef} defaultValue={source.name} readOnly={isPending} required />
+ </div>
+ <FieldError />
+ </Field>
+ <IconPickerContent />
+ </IconPicker>
+ {isEdit && (
+ <>
+ <Field name="description">
+ <FieldLabel>{t(($) => $['newApp.captionDescription'], { ns: 'app' })}</FieldLabel>
+ <Textarea defaultValue={source.description} readOnly={isPending} />
+ </Field>
+ {(source.mode === 'chat' ||
+ source.mode === 'advanced-chat' ||
+ source.mode === 'agent-chat') && (
+ <Field name="use_icon_as_answer_icon">
+ <FieldLabel>{t(($) => $['answerIcon.title'], { ns: 'app' })}</FieldLabel>
+ <Switch defaultChecked={source.use_icon_as_answer_icon} disabled={isPending} />
+ <FieldDescription>
+ {t(($) => $['answerIcon.descriptionInExplore'], { ns: 'app' })}
+ </FieldDescription>
+ </Field>
+ )}
+ <Field name="max_active_requests">
+ <FieldLabel>{t(($) => $.maxActiveRequests, { ns: 'app' })}</FieldLabel>
+ <Input
+ type="number"
+ min={0}
+ defaultValue={source.max_active_requests ?? ''}
+ readOnly={isPending}
+ />
+ <FieldDescription>{t(($) => $.maxActiveRequestsTip, { ns: 'app' })}</FieldDescription>
+ <FieldError />
+ </Field>
+ </>
+ )}
+ {isFull && <AppsFull loc="app-duplicate-create" />}
+ </DialogBody>
+ <DialogFooter>
+ <DialogClose disabled={isPending} render={<Button type="button" />}>
+ {t(($) => $['operation.cancel'], { ns: 'common' })}
+ </DialogClose>
+ <Button
+ type="submit"
+ variant="primary"
+ loading={isPending}
+ disabled={quotaUnavailable || isFull}
+ >
+ {isEdit
+ ? t(($) => $['operation.save'], { ns: 'common' })
+ : t(($) => $.duplicate, { ns: 'app' })}
+ </Button>
+ </DialogFooter>
+ </Form>
+ )
+}
diff --git a/web/app/components/app-sidebar/app-info/delete-app-dialog.tsx b/web/app/components/app-sidebar/app-info/delete-app-dialog.tsx
new file mode 100644
index 00000000000..4b7268346ea
--- /dev/null
+++ b/web/app/components/app-sidebar/app-info/delete-app-dialog.tsx
@@ -0,0 +1,164 @@
+import type { AppDetailWithSite } from '@dify/contracts/api/console/apps/types.gen'
+import type { AlertDialogActions, AlertDialogProps } from '@langgenius/dify-ui/alert-dialog'
+import {
+ AlertDialog,
+ AlertDialogBody,
+ AlertDialogCancelButton,
+ AlertDialogConfirmButton,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogTitle,
+} from '@langgenius/dify-ui/alert-dialog'
+import { Button } from '@langgenius/dify-ui/button'
+import { Field, FieldLabel } from '@langgenius/dify-ui/field'
+import { InputGroup, InputGroupAddon, InputGroupInput } from '@langgenius/dify-ui/input-group'
+import { useMutation } from '@tanstack/react-query'
+import { useRef, useState } from 'react'
+import { Trans, useTranslation } from 'react-i18next'
+import { toast } from '@/app/notifications'
+import { useRouter } from '@/next/navigation'
+import {
+ markAppDeletionFailed,
+ markAppDeletionStarted,
+ markAppDeletionSucceeded,
+} from '@/service/app-deletion'
+import { consoleQuery } from '@/service/console'
+
+export function DeleteAppDialog({
+ appDetail,
+ open,
+ onOpenChange,
+}: Pick<AlertDialogProps, 'open' | 'onOpenChange'> & {
+ appDetail: AppDetailWithSite
+}) {
+ const actionsRef = useRef<AlertDialogActions>(null)
+ const { t } = useTranslation(['app'])
+ const confirmationRef = useRef<HTMLInputElement>(null)
+ const { replace } = useRouter()
+ const deletion = useMutation(
+ consoleQuery.apps.byAppId.delete.mutationOptions({
+ onMutate: () => markAppDeletionStarted(appDetail.id),
+ onError: (error) => {
+ markAppDeletionFailed(appDetail.id)
+ toast.error(
+ `${t(($) => $.appDeleteFailed, { ns: 'app' })}${error instanceof Error ? `: ${error.message}` : ''}`,
+ )
+ },
+ }),
+ )
+ return (
+ <AlertDialog
+ actionsRef={actionsRef}
+ open={open}
+ onOpenChange={(nextOpen, details) => {
+ if (!nextOpen && deletion.isPending && details.reason !== 'imperative-action')
+ details.cancel()
+ else onOpenChange?.(nextOpen, details)
+ }}
+ >
+ <AlertDialogContent initialFocus={confirmationRef}>
+ <DeleteAppForm
+ confirmationRef={confirmationRef}
+ appName={appDetail.name}
+ isPending={deletion.isPending}
+ onSubmit={() => {
+ if (!deletion.isPending)
+ deletion.mutate(
+ { params: { app_id: appDetail.id } },
+ {
+ onSuccess: () => {
+ markAppDeletionSucceeded(appDetail.id)
+ actionsRef.current?.close()
+ toast.success(t(($) => $.appDeleted, { ns: 'app' }))
+ replace('/apps')
+ },
+ },
+ )
+ }}
+ />
+ </AlertDialogContent>
+ </AlertDialog>
+ )
+}
+
+function DeleteAppForm({
+ confirmationRef,
+ appName,
+ isPending,
+ onSubmit,
+}: {
+ confirmationRef: React.RefObject<HTMLInputElement | null>
+ appName: string
+ isPending: boolean
+ onSubmit: () => void
+}) {
+ const { t } = useTranslation(['app', 'common'])
+ const [name] = useState(appName)
+ const [confirmation, setConfirmation] = useState('')
+ return (
+ <form
+ className="contents"
+ onSubmit={(event) => {
+ event.preventDefault()
+ if (!isPending && confirmation === name) onSubmit()
+ }}
+ >
+ <AlertDialogHeader>
+ <AlertDialogTitle>{t(($) => $.deleteAppConfirmTitle, { ns: 'app' })}</AlertDialogTitle>
+ <AlertDialogDescription>
+ {t(($) => $.deleteAppConfirmContent, { ns: 'app' })}
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogBody>
+ <Field name="confirm-app-name">
+ <FieldLabel>
+ <Trans
+ i18nKey={($) => $.deleteAppConfirmInputLabel}
+ ns="app"
+ values={{ appName: name }}
+ components={{
+ appName: <span className="system-sm-semibold text-text-primary" translate="no" />,
+ }}
+ />
+ </FieldLabel>
+ <InputGroup>
+ <InputGroupInput
+ ref={confirmationRef}
+ autoComplete="off"
+ spellCheck={false}
+ value={confirmation}
+ onValueChange={setConfirmation}
+ readOnly={isPending}
+ placeholder={t(($) => $.deleteAppConfirmInputPlaceholder, { ns: 'app' })}
+ />
+ <InputGroupAddon align="inline-end">
+ <Button
+ type="button"
+ variant="tertiary"
+ size="small"
+ disabled={isPending}
+ onClick={() => setConfirmation(name)}
+ >
+ {t(($) => $['operation.fill'], { ns: 'common' })}
+ </Button>
+ </InputGroupAddon>
+ </InputGroup>
+ </Field>
+ </AlertDialogBody>
+ <AlertDialogFooter>
+ <AlertDialogCancelButton type="button" disabled={isPending}>
+ {t(($) => $['operation.cancel'], { ns: 'common' })}
+ </AlertDialogCancelButton>
+ <AlertDialogConfirmButton
+ type="submit"
+ loading={isPending}
+ disabled={confirmation !== name}
+ >
+ {t(($) => $['operation.confirm'], { ns: 'common' })}
+ </AlertDialogConfirmButton>
+ </AlertDialogFooter>
+ </form>
+ )
+}
diff --git a/web/app/components/app-sidebar/app-info/export-app-dialog.tsx b/web/app/components/app-sidebar/app-info/export-app-dialog.tsx
new file mode 100644
index 00000000000..011ad0e7106
--- /dev/null
+++ b/web/app/components/app-sidebar/app-info/export-app-dialog.tsx
@@ -0,0 +1,190 @@
+import type {
+ AppDetailWithSite,
+ EnvironmentVariableItemResponse,
+} from '@dify/contracts/api/console/apps/types.gen'
+import type { AlertDialogActions, AlertDialogProps } from '@langgenius/dify-ui/alert-dialog'
+import {
+ AlertDialog,
+ AlertDialogBody,
+ AlertDialogCancelButton,
+ AlertDialogConfirmButton,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogTitle,
+} from '@langgenius/dify-ui/alert-dialog'
+import { Checkbox } from '@langgenius/dify-ui/checkbox'
+import { Field, FieldLabel } from '@langgenius/dify-ui/field'
+import { Form } from '@langgenius/dify-ui/form'
+import { useId, useRef, useState } from 'react'
+import { useTranslation } from 'react-i18next'
+import { useExportAppDsl, useExportWorkflowAppDsl } from '@/app/components/app/use-export-app-dsl'
+
+type ExportAppDialogProps = Pick<AlertDialogProps, 'open' | 'onOpenChange'> & {
+ appDetail: AppDetailWithSite
+}
+
+export function ExportAppDialog({ appDetail, open, onOpenChange }: ExportAppDialogProps) {
+ const actionsRef = useRef<AlertDialogActions>(null)
+ const confirmLabelId = useId()
+ const { t } = useTranslation(['workflow', 'common'])
+ const [secrets, setSecrets] = useState<EnvironmentVariableItemResponse[]>([])
+ const { exportWorkflowAppDsl, isExporting: isChecking } = useExportWorkflowAppDsl()
+ const { exportAppDsl, isExporting } = useExportAppDsl()
+ const isPending = isChecking || isExporting
+ const check = async () => {
+ if (isPending) return
+ const result = await exportWorkflowAppDsl({ appId: appDetail.id, appName: appDetail.name })
+ if (result.status === 'confirmation-required') setSecrets(result.secretEnvList)
+ else if (result.status === 'downloaded') actionsRef.current?.close()
+ }
+ const download = async (includeSecret: boolean) => {
+ if (isPending) return
+ const result = await exportAppDsl({
+ appId: appDetail.id,
+ appName: appDetail.name,
+ includeSecret,
+ })
+ if (result.status === 'downloaded') actionsRef.current?.close()
+ }
+ return (
+ <AlertDialog
+ actionsRef={actionsRef}
+ open={open}
+ onOpenChange={(nextOpen, details) => {
+ if (!nextOpen && isPending && details.reason !== 'imperative-action') details.cancel()
+ else onOpenChange?.(nextOpen, details)
+ }}
+ onOpenChangeComplete={(nextOpen) => {
+ if (!nextOpen) setSecrets([])
+ }}
+ >
+ <AlertDialogContent backdropProps={{ forceRender: true }}>
+ {secrets.length > 0 ? (
+ <ExportSecretsForm
+ secrets={secrets}
+ isPending={isPending}
+ onSubmit={(includeSecret) => {
+ void download(includeSecret)
+ }}
+ />
+ ) : (
+ <>
+ <AlertDialogHeader>
+ <AlertDialogTitle>
+ {t(($) => $['sidebar.exportWarning'], { ns: 'workflow' })}
+ </AlertDialogTitle>
+ <AlertDialogDescription>
+ {t(($) => $['sidebar.exportWarningDesc'], { ns: 'workflow' })}
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogFooter>
+ <AlertDialogCancelButton disabled={isPending}>
+ {t(($) => $['operation.cancel'], { ns: 'common' })}
+ </AlertDialogCancelButton>
+ <AlertDialogConfirmButton
+ tone="default"
+ loading={isPending}
+ aria-labelledby={confirmLabelId}
+ onClick={() => {
+ void check()
+ }}
+ >
+ <span id={confirmLabelId}>
+ {isPending
+ ? t(($) => $['operation.exporting'], { ns: 'common' })
+ : t(($) => $['operation.confirm'], { ns: 'common' })}
+ </span>
+ </AlertDialogConfirmButton>
+ </AlertDialogFooter>
+ </>
+ )}
+ </AlertDialogContent>
+ </AlertDialog>
+ )
+}
+
+function ExportSecretsForm({
+ secrets,
+ isPending,
+ onSubmit,
+}: {
+ secrets: EnvironmentVariableItemResponse[]
+ isPending: boolean
+ onSubmit: (includeSecret: boolean) => void
+}) {
+ const { t } = useTranslation(['app', 'workflow', 'common'])
+ const submitLabelId = useId()
+ const [includeSecret, setIncludeSecret] = useState(false)
+ return (
+ <Form
+ className="contents"
+ onFormSubmit={() => {
+ if (!isPending) onSubmit(includeSecret)
+ }}
+ >
+ <AlertDialogHeader>
+ <AlertDialogTitle>{t(($) => $['exportSecret.title'], { ns: 'app' })}</AlertDialogTitle>
+ <AlertDialogDescription>
+ {t(($) => $['exportSecret.description'], { ns: 'app' })}
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogBody>
+ <table className="w-full table-fixed border-separate border-spacing-0 rounded-lg border border-divider-regular shadow-xs">
+ <thead>
+ <tr>
+ <th className="border-r border-b border-divider-regular p-2 text-left">
+ {t(($) => $['env.export.name'], { ns: 'workflow' })}
+ </th>
+ <th className="border-b border-divider-regular p-2 text-left">
+ {t(($) => $['env.export.value'], { ns: 'workflow' })}
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ {secrets.map((secret) => (
+ <tr key={secret.name}>
+ <td className="border-r border-divider-regular p-2 wrap-anywhere">{secret.name}</td>
+ <td className="p-2 wrap-anywhere">
+ {typeof secret.value === 'object'
+ ? JSON.stringify(secret.value)
+ : String(secret.value)}
+ </td>
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ <Field name="include_secret" className="mt-4">
+ <FieldLabel className="flex items-center gap-2">
+ <Checkbox
+ checked={includeSecret}
+ onCheckedChange={setIncludeSecret}
+ disabled={isPending}
+ />
+ {t(($) => $['env.export.checkbox'], { ns: 'workflow' })}
+ </FieldLabel>
+ </Field>
+ </AlertDialogBody>
+ <AlertDialogFooter>
+ <AlertDialogCancelButton type="button" disabled={isPending}>
+ {t(($) => $['operation.cancel'], { ns: 'common' })}
+ </AlertDialogCancelButton>
+ <AlertDialogConfirmButton
+ type="submit"
+ tone="default"
+ loading={isPending}
+ aria-labelledby={submitLabelId}
+ >
+ <span id={submitLabelId}>
+ {isPending
+ ? t(($) => $['operation.exporting'], { ns: 'common' })
+ : includeSecret
+ ? t(($) => $['exportSecret.title'], { ns: 'app' })
+ : t(($) => $.exportApp, { ns: 'app' })}
+ </span>
+ </AlertDialogConfirmButton>
+ </AlertDialogFooter>
+ </Form>
+ )
+}
diff --git a/web/app/components/app-sidebar/app-info/index.tsx b/web/app/components/app-sidebar/app-info/index.tsx
index 45e7e31b586..bfb4dee67e4 100644
--- a/web/app/components/app-sidebar/app-info/index.tsx
+++ b/web/app/components/app-sidebar/app-info/index.tsx
@@ -1,51 +1,76 @@
import type { AppDetailWithSite } from '@dify/contracts/api/console/apps/types.gen'
+import type { AppInfoOperation } from './app-info-modals'
+import { useQueryClient } from '@tanstack/react-query'
+import { useEffect, useState } from 'react'
+import { useExportAppDsl } from '@/app/components/app/use-export-app-dsl'
+import { consoleClient, consoleQuery } from '@/service/console'
import AppInfoModals from './app-info-modals'
import AppInfoTrigger from './app-info-trigger'
-import { useAppInfoActions } from './use-app-info-actions'
+import { updateCachedAppMetadata } from './metadata'
-type AppInfoViewProps = {
- appDetail: AppDetailWithSite
- expand: boolean
-}
+type AppInfoViewProps = { appDetail: AppDetailWithSite; expand: boolean }
+
+export function AppInfoView({ appDetail, expand }: AppInfoViewProps) {
+ const appId = appDetail.id
+ const queryClient = useQueryClient()
+ const [activeModal, setActiveModal] = useState<AppInfoOperation | null>(null)
+ const [exportOpen, setExportOpen] = useState(false)
+ const { exportAppDsl, isExporting } = useExportAppDsl()
+ useEffect(() => {
+ let unsubscribe: (() => void) | null = null
+ let disposed = false
+
+ void import('@/app/components/workflow/collaboration/core/collaboration-manager')
+ .then(({ collaborationManager }) => {
+ if (disposed) return
-export const AppInfoView = ({ appDetail, expand }: AppInfoViewProps) => {
- const {
- activeModal,
- openModal,
- closeModal,
- secretEnvList,
- setSecretEnvList,
- onEdit,
- onCopy,
- onExport,
- isExporting,
- exportCheck,
- handleConfirmExport,
- onConfirmDelete,
- } = useAppInfoActions({ appId: appDetail.id, appName: appDetail.name, appMode: appDetail.mode })
+ unsubscribe = collaborationManager.onAppMetaUpdate(async () => {
+ try {
+ const res = await consoleClient.apps.byAppId.get({ params: { app_id: appId } })
+ if (disposed) return
+ queryClient.setQueryData(
+ consoleQuery.apps.byAppId.get.queryKey({
+ input: { params: { app_id: appId } },
+ }),
+ (cachedApp) => updateCachedAppMetadata(cachedApp, res),
+ )
+ void queryClient.invalidateQueries({ queryKey: consoleQuery.apps.get.key() })
+ void queryClient.invalidateQueries({ queryKey: consoleQuery.apps.starred.get.key() })
+ void queryClient.invalidateQueries({ queryKey: consoleQuery.apps.recent.get.key() })
+ } catch (error) {
+ console.error('failed to refresh app detail from collaboration update:', error)
+ }
+ })
+ })
+ .catch(() => {})
+
+ return () => {
+ disposed = true
+ unsubscribe?.()
+ }
+ }, [appId, queryClient])
return (
<>
<AppInfoTrigger
appDetail={appDetail}
expand={expand}
- openModal={openModal}
+ openModal={setActiveModal}
isExporting={isExporting}
- exportCheck={exportCheck}
+ exportCheck={() => {
+ if (appDetail.mode === 'workflow' || appDetail.mode === 'advanced-chat')
+ setExportOpen(true)
+ else if (!isExporting) void exportAppDsl({ appId, appName: appDetail.name })
+ }}
/>
<AppInfoModals
appDetail={appDetail}
activeModal={activeModal}
- closeModal={closeModal}
- secretEnvList={secretEnvList}
- setSecretEnvList={setSecretEnvList}
- onEdit={onEdit}
- onCopy={onCopy}
- onExport={onExport}
- isExporting={isExporting}
- exportCheck={exportCheck}
- handleConfirmExport={handleConfirmExport}
- onConfirmDelete={onConfirmDelete}
+ onOpenChange={(open) => {
+ if (!open) setActiveModal(null)
+ }}
+ exportOpen={exportOpen}
+ onExportOpenChange={setExportOpen}
/>
</>
)
diff --git a/web/app/components/app-sidebar/app-info/metadata.ts b/web/app/components/app-sidebar/app-info/metadata.ts
new file mode 100644
index 00000000000..c05bb92f94a
--- /dev/null
+++ b/web/app/components/app-sidebar/app-info/metadata.ts
@@ -0,0 +1,31 @@
+import type { AppDetailWithSite } from '@dify/contracts/api/console/apps/types.gen'
+
+type AppMetadata = Pick<
+ AppDetailWithSite,
+ | 'description'
+ | 'icon'
+ | 'icon_background'
+ | 'icon_type'
+ | 'icon_url'
+ | 'max_active_requests'
+ | 'name'
+ | 'updated_at'
+ | 'use_icon_as_answer_icon'
+>
+
+export function updateCachedAppMetadata(cached: AppDetailWithSite | undefined, app: AppMetadata) {
+ if (!cached) return cached
+ return {
+ ...cached,
+ description: app.description,
+ icon: app.icon,
+ icon_background: app.icon_background,
+ icon_type: app.icon_type,
+ icon_url: app.icon_url,
+ name: app.name,
+ updated_at: app.updated_at,
+ use_icon_as_answer_icon: app.use_icon_as_answer_icon,
+ max_active_requests:
+ app.max_active_requests === undefined ? cached.max_active_requests : app.max_active_requests,
+ }
+}
diff --git a/web/app/components/app-sidebar/app-info/use-app-info-actions.ts b/web/app/components/app-sidebar/app-info/use-app-info-actions.ts
deleted file mode 100644
index 39629dde37f..00000000000
--- a/web/app/components/app-sidebar/app-info/use-app-info-actions.ts
+++ /dev/null
@@ -1,288 +0,0 @@
-import type {
- AppDetailWithSite,
- EnvironmentVariableItemResponse,
-} from '@dify/contracts/api/console/apps/types.gen'
-import type { DuplicateAppModalProps } from '@/app/components/app/duplicate-modal'
-import type { CreateAppModalProps } from '@/app/components/explore/create-app-modal'
-import { useMutation, useQueryClient, useSuspenseQuery } from '@tanstack/react-query'
-import { useCallback, useEffect, useState } from 'react'
-import { useTranslation } from 'react-i18next'
-import { useExportAppDsl, useExportWorkflowAppDsl } from '@/app/components/app/use-export-app-dsl'
-import { toast } from '@/app/notifications'
-import { systemFeaturesQueryOptions } from '@/features/system-features/client'
-import { useRouter } from '@/next/navigation'
-import {
- markAppDeletionFailed,
- markAppDeletionStarted,
- markAppDeletionSucceeded,
-} from '@/service/app-deletion'
-import { consoleClient, consoleQuery } from '@/service/console'
-import { getRedirection } from '@/utils/app-redirection'
-
-export type AppInfoModalType =
- | 'edit'
- | 'duplicate'
- | 'delete'
- | 'switch'
- | 'importDSL'
- | 'exportWarning'
- | null
-
-type AppMetadata = Pick<
- AppDetailWithSite,
- | 'description'
- | 'icon'
- | 'icon_background'
- | 'icon_type'
- | 'icon_url'
- | 'max_active_requests'
- | 'name'
- | 'updated_at'
- | 'use_icon_as_answer_icon'
->
-
-const updateCachedAppMetadata = (cachedApp: AppDetailWithSite | undefined, app: AppMetadata) => {
- if (!cachedApp) return cachedApp
-
- return {
- ...cachedApp,
- description: app.description,
- icon: app.icon,
- icon_background: app.icon_background,
- icon_type: app.icon_type,
- icon_url: app.icon_url,
- max_active_requests:
- app.max_active_requests === undefined
- ? cachedApp.max_active_requests
- : app.max_active_requests,
- name: app.name,
- updated_at: app.updated_at,
- use_icon_as_answer_icon: app.use_icon_as_answer_icon,
- }
-}
-
-export function useAppInfoActions({
- appId,
- appName,
- appMode,
-}: {
- appId: string
- appName: string
- appMode: AppDetailWithSite['mode']
-}) {
- const { t } = useTranslation(['app'])
- const { replace } = useRouter()
- const queryClient = useQueryClient()
- const { mutateAsync: copyApp } = useMutation(
- consoleQuery.apps.byAppId.copy.post.mutationOptions(),
- )
- const { mutateAsync: deleteApp } = useMutation(consoleQuery.apps.byAppId.delete.mutationOptions())
- const { exportAppDsl, isExporting: isAppDslExporting } = useExportAppDsl()
- const { exportWorkflowAppDsl, isExporting: isWorkflowAppDslExporting } = useExportWorkflowAppDsl()
- const isExporting = isAppDslExporting || isWorkflowAppDslExporting
- const { data: systemFeatures } = useSuspenseQuery(systemFeaturesQueryOptions())
- const isRbacEnabled = systemFeatures.rbac_enabled
-
- const [activeModal, setActiveModal] = useState<AppInfoModalType>(null)
- const [secretEnvList, setSecretEnvList] = useState<EnvironmentVariableItemResponse[]>([])
-
- const openModal = useCallback(
- (modal: Exclude<AppInfoModalType, null>) => {
- setActiveModal(modal)
- },
- [setActiveModal],
- )
-
- const closeModal = useCallback(() => {
- setActiveModal(null)
- }, [setActiveModal])
-
- const emitAppMetaUpdate = useCallback(() => {
- void import('@/app/components/workflow/collaboration/core/websocket-manager')
- .then(({ webSocketClient }) => {
- const socket = webSocketClient.getSocket(appId)
- if (!socket) return
- socket.emit('collaboration_event', {
- type: 'app_meta_update',
- data: { timestamp: Date.now() },
- timestamp: Date.now(),
- })
- })
- .catch(() => {})
- }, [appId])
-
- useEffect(() => {
- let unsubscribe: (() => void) | null = null
- let disposed = false
-
- void import('@/app/components/workflow/collaboration/core/collaboration-manager')
- .then(({ collaborationManager }) => {
- if (disposed) return
-
- unsubscribe = collaborationManager.onAppMetaUpdate(async () => {
- try {
- const res = await consoleClient.apps.byAppId.get({ params: { app_id: appId } })
- if (disposed) return
- queryClient.setQueryData(
- consoleQuery.apps.byAppId.get.queryKey({
- input: { params: { app_id: appId } },
- }),
- (cachedApp) => updateCachedAppMetadata(cachedApp, res),
- )
- void queryClient.invalidateQueries({ queryKey: consoleQuery.apps.get.key() })
- void queryClient.invalidateQueries({ queryKey: consoleQuery.apps.starred.get.key() })
- void queryClient.invalidateQueries({ queryKey: consoleQuery.apps.recent.get.key() })
- } catch (error) {
- console.error('failed to refresh app detail from collaboration update:', error)
- }
- })
- })
- .catch(() => {})
-
- return () => {
- disposed = true
- unsubscribe?.()
- }
- }, [appId, queryClient])
-
- const onEdit: CreateAppModalProps['onConfirm'] = useCallback(
- async ({
- name,
- icon_type,
- icon,
- icon_background,
- description,
- use_icon_as_answer_icon,
- max_active_requests,
- }) => {
- try {
- const app = await consoleClient.apps.byAppId.put({
- params: { app_id: appId },
- body: {
- name,
- icon_type,
- icon,
- icon_background,
- description,
- use_icon_as_answer_icon,
- max_active_requests,
- },
- })
- closeModal()
- queryClient.setQueryData(
- consoleQuery.apps.byAppId.get.queryKey({
- input: { params: { app_id: appId } },
- }),
- (cachedApp) => updateCachedAppMetadata(cachedApp, app),
- )
- void queryClient.invalidateQueries({ queryKey: consoleQuery.apps.get.key() })
- void queryClient.invalidateQueries({ queryKey: consoleQuery.apps.starred.get.key() })
- void queryClient.invalidateQueries({ queryKey: consoleQuery.apps.recent.get.key() })
- emitAppMetaUpdate()
- } catch {
- toast(
- t(($) => $.editFailed, { ns: 'app' }),
- { type: 'error' },
- )
- }
- },
- [appId, closeModal, t, emitAppMetaUpdate, queryClient],
- )
-
- const onCopy: DuplicateAppModalProps['onConfirm'] = useCallback(
- async ({ name, icon_type, icon, icon_background }) => {
- try {
- const newApp = await copyApp({
- params: { app_id: appId },
- body: { name, icon_type, icon, icon_background },
- })
- if (!('mode' in newApp)) {
- toast(
- t(($) => $['newApp.appCreateFailed'], { ns: 'app' }),
- { type: 'error' },
- )
- return
- }
- closeModal()
- toast(
- t(($) => $['newApp.appCreated'], { ns: 'app' }),
- { type: 'success' },
- )
- getRedirection(newApp, replace, { isRbacEnabled })
- } catch {
- toast(
- t(($) => $['newApp.appCreateFailed'], { ns: 'app' }),
- { type: 'error' },
- )
- }
- },
- [appId, closeModal, copyApp, isRbacEnabled, replace, t],
- )
-
- const onExport = useCallback(
- async (include = false) => {
- const result = await exportAppDsl({
- appId,
- appName,
- includeSecret: include,
- })
- return result.status === 'downloaded'
- },
- [appId, appName, exportAppDsl],
- )
-
- const exportCheck = useCallback(async () => {
- if (isExporting) return
- if (appMode !== 'workflow' && appMode !== 'advanced-chat') {
- onExport()
- return
- }
- setActiveModal('exportWarning')
- }, [appMode, isExporting, onExport, setActiveModal])
-
- const handleConfirmExport = useCallback(async () => {
- if (isExporting) return
- const result = await exportWorkflowAppDsl({
- appId,
- appName,
- })
- if (result.status === 'failed') return
- if (result.status === 'confirmation-required') setSecretEnvList(result.secretEnvList)
- closeModal()
- }, [appId, appName, closeModal, exportWorkflowAppDsl, isExporting, setSecretEnvList])
-
- const onConfirmDelete = useCallback(async () => {
- markAppDeletionStarted(appId)
- try {
- await deleteApp({ params: { app_id: appId } })
- markAppDeletionSucceeded(appId)
- toast(
- t(($) => $.appDeleted, { ns: 'app' }),
- { type: 'success' },
- )
- replace('/apps')
- } catch (e: unknown) {
- markAppDeletionFailed(appId)
- toast(
- `${t(($) => $.appDeleteFailed, { ns: 'app' })}${e instanceof Error && e.message ? `: ${e.message}` : ''}`,
- { type: 'error' },
- )
- }
- closeModal()
- }, [appId, closeModal, deleteApp, replace, t])
-
- return {
- activeModal,
- openModal,
- closeModal,
- secretEnvList,
- setSecretEnvList,
- onEdit,
- onCopy,
- onExport,
- isExporting,
- exportCheck,
- handleConfirmExport,
- onConfirmDelete,
- }
-}
diff --git a/web/app/components/app/app-access-control/access-control-dialog.tsx b/web/app/components/app/app-access-control/access-control-dialog.tsx
index 6c451abb604..08efc189092 100644
--- a/web/app/components/app/app-access-control/access-control-dialog.tsx
+++ b/web/app/components/app/app-access-control/access-control-dialog.tsx
@@ -20,12 +20,7 @@ const AccessControlDialog = ({ className, children, show, onClose }: DialogProps
return (
<Dialog open={show} disablePointerDismissal onOpenChange={(open) => !open && close()}>
- <DialogContent
- className={cn(
- 'max-h-[calc(100dvh-2rem)] min-h-80.75 w-150 max-w-none transition-all',
- className,
- )}
- >
+ <DialogContent className={cn('min-h-80.75 w-150 transition-all', className)}>
<DialogClose
render={
<IconButton
diff --git a/web/app/components/app/configuration/config-var/config-modal/__tests__/index.spec.tsx b/web/app/components/app/configuration/config-var/config-modal/__tests__/index.spec.tsx
index 4df00653274..041d08665e0 100644
--- a/web/app/components/app/configuration/config-var/config-modal/__tests__/index.spec.tsx
+++ b/web/app/components/app/configuration/config-var/config-modal/__tests__/index.spec.tsx
@@ -624,7 +624,7 @@ describe('ConfigModal', () => {
const scrollArea = screen.getByTestId('config-modal-scroll-area')
expect(dialog).toHaveClass('overflow-y-auto')
- expect(scrollArea).toHaveClass('overflow-x-hidden')
+ expect(scrollArea).toHaveClass('overflow-y-auto')
})
it('should block save when the label is missing', () => {
diff --git a/web/app/components/app/configuration/config-var/config-modal/index.tsx b/web/app/components/app/configuration/config-var/config-modal/index.tsx
index ec709a25dc7..c25a0b19289 100644
--- a/web/app/components/app/configuration/config-var/config-modal/index.tsx
+++ b/web/app/components/app/configuration/config-var/config-modal/index.tsx
@@ -209,9 +209,10 @@ const ConfigModal: FC<IConfigModalProps> = ({
if (!open) onClose()
}}
>
- <DialogContent className="max-h-[calc(100dvh-2rem)]">
+ <DialogContent>
<form
noValidate
+ className="contents"
onSubmit={(event) => {
event.preventDefault()
handleConfirm()
@@ -229,7 +230,7 @@ const ConfigModal: FC<IConfigModalProps> = ({
ref={modalRef}
tabIndex={-1}
data-testid="config-modal-scroll-area"
- className="min-w-0 overflow-x-hidden"
+ className="min-w-0"
>
<ConfigModalFormFields
checkboxDefaultSelectValue={checkboxDefaultSelectValue}
diff --git a/web/app/components/app/configuration/config/agent/agent-setting/index.tsx b/web/app/components/app/configuration/config/agent/agent-setting/index.tsx
index 4901aa479ff..8d3e41ecba1 100644
--- a/web/app/components/app/configuration/config/agent/agent-setting/index.tsx
+++ b/web/app/components/app/configuration/config/agent/agent-setting/index.tsx
@@ -48,7 +48,7 @@ export function AgentSettingDialog({ disabled, onSave, ...props }: Props) {
</DialogTrigger>
<DialogPortal>
<DialogBackdrop />
- <DialogPopup className="fixed top-2 right-2 bottom-2 flex w-160 max-w-[calc(100vw-1rem)] flex-col overflow-hidden overscroll-contain rounded-xl">
+ <DialogPopup className="fixed top-2 right-2 bottom-2 flex w-160 max-w-[calc(100vw-1rem)] flex-col overflow-hidden overscroll-contain rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-xl">
<AgentSettingsForm
{...props}
onSave={(payload) => {
diff --git a/web/app/components/app/configuration/config/automatic/get-automatic-res.tsx b/web/app/components/app/configuration/config/automatic/get-automatic-res.tsx
index f56e78c6692..9cc17ba6080 100644
--- a/web/app/components/app/configuration/config/automatic/get-automatic-res.tsx
+++ b/web/app/components/app/configuration/config/automatic/get-automatic-res.tsx
@@ -268,7 +268,7 @@ const GetAutomaticRes: FC<IGetAutomaticResProps> = ({
if (!open) onClose()
}}
>
- <DialogContent className="max-h-[calc(100dvh-2rem)] w-285 xl:h-[min(680px,calc(100dvh-2rem))] xl:overflow-hidden">
+ <DialogContent className="w-285 xl:h-[min(680px,calc(100dvh-2rem))] xl:overflow-hidden">
<div className="flex min-h-0 flex-col xl:h-full xl:flex-row">
<div className="min-w-0 border-divider-regular p-6 xl:h-full xl:flex-1 xl:overflow-y-auto xl:border-r">
<div className="mb-5">
diff --git a/web/app/components/app/configuration/config/code-generator/get-code-generator-res.tsx b/web/app/components/app/configuration/config/code-generator/get-code-generator-res.tsx
index 391c7d41123..add1b46f4dc 100644
--- a/web/app/components/app/configuration/config/code-generator/get-code-generator-res.tsx
+++ b/web/app/components/app/configuration/config/code-generator/get-code-generator-res.tsx
@@ -189,7 +189,7 @@ export const GetCodeGeneratorResModal: FC<IGetCodeGeneratorResProps> = ({
if (!open) onClose()
}}
>
- <DialogContent className="h-[min(680px,calc(100dvh-2rem))] max-h-none w-full min-w-285 overflow-hidden">
+ <DialogContent className="h-[min(680px,calc(100dvh-2rem))] w-full min-w-285 overflow-hidden">
<div className="relative flex h-full min-h-0 flex-wrap">
<div className="h-full w-142.5 shrink-0 overflow-y-auto border-r border-divider-regular p-6">
<div className="mb-5">
diff --git a/web/app/components/app/configuration/tools/external-data-tool-modal.tsx b/web/app/components/app/configuration/tools/external-data-tool-modal.tsx
index bc8c3087ffb..271b8302ae9 100644
--- a/web/app/components/app/configuration/tools/external-data-tool-modal.tsx
+++ b/web/app/components/app/configuration/tools/external-data-tool-modal.tsx
@@ -128,7 +128,7 @@ const ExternalDataToolModal: FC<ExternalDataToolModalProps> = ({
return (
<Dialog open onOpenChange={noop}>
- <DialogContent className="w-160 max-w-none">
+ <DialogContent className="w-160">
<DialogHeader>
<DialogTitle>
{`${action} ${t(($) => $['variableConfig.apiBasedVar'], { ns: 'appDebug' })}`}
diff --git a/web/app/components/app/create-app-dialog-shell.tsx b/web/app/components/app/create-app-dialog-shell.tsx
index 0b9fd636c2a..27e90f73bd8 100644
--- a/web/app/components/app/create-app-dialog-shell.tsx
+++ b/web/app/components/app/create-app-dialog-shell.tsx
@@ -34,7 +34,7 @@ export function CreateAppDialogShell({
>
<DialogPortal>
<DialogBackdrop className="bg-background-overlay-backdrop backdrop-blur-[6px]" />
- <DialogPopup className="fixed top-0 left-0 h-screen w-screen overflow-hidden overscroll-contain rounded-none border-none bg-transparent p-4 shadow-none">
+ <DialogPopup className="fixed top-0 left-0 h-screen w-screen overflow-hidden overscroll-contain p-4">
<div className="size-full rounded-2xl border border-effects-highlight bg-background-default-subtle">
<div className={cn('relative h-full overflow-hidden', contentClassName)}>
<DialogTitle className="sr-only">{title}</DialogTitle>
diff --git a/web/app/components/app/create-from-dsl-modal/__tests__/index.spec.tsx b/web/app/components/app/create-from-dsl-modal/__tests__/index.spec.tsx
index e294cab8005..6cb55146ee1 100644
--- a/web/app/components/app/create-from-dsl-modal/__tests__/index.spec.tsx
+++ b/web/app/components/app/create-from-dsl-modal/__tests__/index.spec.tsx
@@ -833,6 +833,24 @@ describe('CreateFromDSLModal', () => {
})
})
+ it('validates and submits the URL with Enter inside the dialog form', async () => {
+ const user = userEvent.setup()
+ mockImportDSL.mockResolvedValue({ id: 'import-enter', status: DSLImportStatus.FAILED })
+ render(<CreateFromDSLModal show onClose={vi.fn()} activeTab={CreateFromDSLModalTab.FROM_URL} />)
+ const input = screen.getByRole('textbox', { name: /importFromDSLUrl/ })
+ await user.click(input)
+ await user.keyboard('{Enter}')
+ expect(input).toHaveAttribute('aria-invalid', 'true')
+ expect(mockImportDSL).not.toHaveBeenCalled()
+ await user.type(input, 'https://example.com/app.yml{Enter}')
+ await waitFor(() =>
+ expect(mockImportDSL).toHaveBeenCalledExactlyOnceWith({
+ mode: DSLImportMode.YAML_URL,
+ yaml_url: 'https://example.com/app.yml',
+ }),
+ )
+ })
+
it('submits a URL through the keyboard shortcut', async () => {
const handleClose = vi.fn()
mockImportDSL.mockResolvedValue({
diff --git a/web/app/components/app/create-from-dsl-modal/dsl-confirm-modal.tsx b/web/app/components/app/create-from-dsl-modal/dsl-confirm-modal.tsx
index ddc528947af..66ca9e5110c 100644
--- a/web/app/components/app/create-from-dsl-modal/dsl-confirm-modal.tsx
+++ b/web/app/components/app/create-from-dsl-modal/dsl-confirm-modal.tsx
@@ -61,6 +61,7 @@ function DSLConfirmModal({
{t(($) => $['newApp.Cancel'], { ns: 'app' })}
</AlertDialogCancelButton>
<AlertDialogConfirmButton
+ tone="default"
onClick={onConfirm}
disabled={confirmDisabled}
loading={confirmLoading}
diff --git a/web/app/components/app/create-from-dsl-modal/index.tsx b/web/app/components/app/create-from-dsl-modal/index.tsx
index efd49e05066..8874a0fc9b2 100644
--- a/web/app/components/app/create-from-dsl-modal/index.tsx
+++ b/web/app/components/app/create-from-dsl-modal/index.tsx
@@ -5,6 +5,7 @@ import type { Hotkey } from '@tanstack/react-hotkeys'
import { Button } from '@langgenius/dify-ui/button'
import {
Dialog,
+ DialogBody,
DialogCloseButton,
DialogContent,
DialogFooter,
@@ -296,7 +297,32 @@ function CreateFromDSLModal({
if (!open && !isImporting && !pendingImport) onClose()
}}
>
- <DialogContent initialFocus={browseButtonRef}>
+ <DialogContent
+ initialFocus={browseButtonRef}
+ render={
+ <Form<ImportFormValues>
+ onFormSubmit={handleSubmit}
+ onKeyDown={(event) => {
+ if (
+ !show ||
+ createDisabled ||
+ isImporting ||
+ !!pendingImport ||
+ event.defaultPrevented ||
+ event.nativeEvent.isComposing ||
+ !(event.target instanceof Node) ||
+ !event.currentTarget.contains(event.target) ||
+ !matchesKeyboardEvent(event.nativeEvent, CREATE_FROM_DSL_HOTKEY)
+ )
+ return
+ event.preventDefault()
+ event.stopPropagation()
+ if (event.repeat) return
+ event.currentTarget.requestSubmit()
+ }}
+ />
+ }
+ >
<DialogHeader>
<DialogTitle>{t(($) => $.importApp, { ns: 'app' })}</DialogTitle>
<DialogCloseButton
@@ -304,100 +330,73 @@ function CreateFromDSLModal({
disabled={isImporting}
/>
</DialogHeader>
- <Form<ImportFormValues>
- onFormSubmit={handleSubmit}
- onKeyDown={(event) => {
- if (
- !show ||
- createDisabled ||
- isImporting ||
- !!pendingImport ||
- event.defaultPrevented ||
- event.nativeEvent.isComposing ||
- !(event.target instanceof Node) ||
- !event.currentTarget.contains(event.target) ||
- !matchesKeyboardEvent(event.nativeEvent, CREATE_FROM_DSL_HOTKEY)
- )
- return
- event.preventDefault()
- event.stopPropagation()
- if (event.repeat) return
- event.currentTarget.requestSubmit()
- }}
- >
- <Tabs value={currentTab} onValueChange={handleTabChange}>
- <TabsList className="h-9 gap-6 border-b border-divider-subtle px-6">
- <TabsTab
- value={CreateFromDSLModalTab.FROM_FILE}
- className="h-full pt-0 pb-0"
- disabled={isImporting}
- >
- {t(($) => $.importFromFile, { ns: 'app' })}
- </TabsTab>
- <TabsTab
- value={CreateFromDSLModalTab.FROM_URL}
- className="h-full pt-0 pb-0"
- disabled={isImporting}
- >
- {t(($) => $.importFromDSLUrl, { ns: 'app' })}
- </TabsTab>
- </TabsList>
- <TabsPanel
+ <Tabs className="contents" value={currentTab} onValueChange={handleTabChange}>
+ <TabsList className="h-9 shrink-0 gap-6 border-b border-divider-subtle px-6">
+ <TabsTab
value={CreateFromDSLModalTab.FROM_FILE}
- tabIndex={-1}
- className="px-6 py-4"
+ className="h-full pt-0 pb-0"
+ disabled={isImporting}
>
- <Uploader
- importType="app"
- browseButtonRef={browseButtonRef}
- className="mt-0"
- file={currentFile}
- updateFile={setCurrentFile}
+ {t(($) => $.importFromFile, { ns: 'app' })}
+ </TabsTab>
+ <TabsTab
+ value={CreateFromDSLModalTab.FROM_URL}
+ className="h-full pt-0 pb-0"
+ disabled={isImporting}
+ >
+ {t(($) => $.importFromDSLUrl, { ns: 'app' })}
+ </TabsTab>
+ </TabsList>
+ <TabsPanel
+ value={CreateFromDSLModalTab.FROM_FILE}
+ tabIndex={-1}
+ render={<DialogBody />}
+ >
+ <Uploader
+ importType="app"
+ browseButtonRef={browseButtonRef}
+ className="mt-0"
+ file={currentFile}
+ updateFile={setCurrentFile}
+ disabled={isImporting}
+ />
+ </TabsPanel>
+ <TabsPanel value={CreateFromDSLModalTab.FROM_URL} tabIndex={-1} render={<DialogBody />}>
+ <Field name="dslUrl">
+ <FieldLabel>{t(($) => $.importFromDSLUrl, { ns: 'app' })}</FieldLabel>
+ <Input
+ type="url"
+ inputMode="url"
+ autoComplete="off"
+ required
disabled={isImporting}
+ placeholder={t(($) => $.importAppUrlPlaceholder, { ns: 'app' }) || ''}
+ defaultValue={dslUrl}
/>
- </TabsPanel>
- <TabsPanel value={CreateFromDSLModalTab.FROM_URL} tabIndex={-1} className="px-6 py-4">
- <Field name="dslUrl">
- <FieldLabel>{t(($) => $.importFromDSLUrl, { ns: 'app' })}</FieldLabel>
- <Input
- type="url"
- inputMode="url"
- autoComplete="off"
- required
- disabled={isImporting}
- placeholder={t(($) => $.importAppUrlPlaceholder, { ns: 'app' }) || ''}
- defaultValue={dslUrl}
- />
- <FieldError />
- </Field>
- </TabsPanel>
- </Tabs>
- {isAppsFull && (
- <div className="px-6">
- <AppsFull className="mt-0" loc="app-create-dsl" />
- </div>
- )}
- <DialogFooter>
- <Button disabled={isImporting} onClick={onClose}>
- {t(($) => $['newApp.Cancel'], { ns: 'app' })}
- </Button>
- <Button
- type="submit"
- disabled={createDisabled}
- loading={isImporting}
- variant="primary"
- >
- <span>{t(($) => $['operation.create'], { ns: 'common' })}</span>
- <KbdGroup>
- {formatForDisplay(CREATE_FROM_DSL_HOTKEY, { parts: true }).map((key) => (
- <Kbd key={key} color="white">
- {key}
- </Kbd>
- ))}
- </KbdGroup>
- </Button>
- </DialogFooter>
- </Form>
+ <FieldError />
+ </Field>
+ </TabsPanel>
+ </Tabs>
+ {isAppsFull && (
+ <div className="px-6">
+ <AppsFull className="mt-0" loc="app-create-dsl" />
+ </div>
+ )}
+ <DialogFooter>
+ <Button disabled={isImporting} onClick={onClose}>
+ {t(($) => $['newApp.Cancel'], { ns: 'app' })}
+ </Button>
+ <Button type="submit" disabled={createDisabled} loading={isImporting} variant="primary">
+ <span>{t(($) => $['operation.create'], { ns: 'common' })}</span>
+ <KbdGroup>
+ {formatForDisplay(CREATE_FROM_DSL_HOTKEY, { parts: true }).map((key) => (
+ <Kbd key={key} color="white">
+ {key}
+ </Kbd>
+ ))}
+ </KbdGroup>
+ </Button>
+ </DialogFooter>
</DialogContent>
</Dialog>
{pendingImport && (
diff --git a/web/app/components/app/deploy/deployment-dialog/index.tsx b/web/app/components/app/deploy/deployment-dialog/index.tsx
index 63e70709000..771fa2f71db 100644
--- a/web/app/components/app/deploy/deployment-dialog/index.tsx
+++ b/web/app/components/app/deploy/deployment-dialog/index.tsx
@@ -30,7 +30,7 @@ function DeploymentDialogSession({
return (
<DialogContent
className={cn(
- 'flex max-h-[min(44rem,calc(100dvh-32px))] min-h-0 max-w-[calc(100vw-32px)] flex-col overflow-hidden',
+ 'max-h-[min(44rem,calc(100dvh-32px))] overflow-hidden',
!selectedVersion && 'h-[min(44rem,calc(100dvh-32px))]',
)}
>
diff --git a/web/app/components/app/duplicate-modal/index.tsx b/web/app/components/app/duplicate-modal/index.tsx
index e4eeb699f82..0c0c9aeece6 100644
--- a/web/app/components/app/duplicate-modal/index.tsx
+++ b/web/app/components/app/duplicate-modal/index.tsx
@@ -118,6 +118,7 @@ const DuplicateAppModal = ({
<DialogCloseButton aria-label={t(($) => $['operation.close'], { ns: 'common' })} />
</DialogHeader>
<form
+ className="contents"
onSubmit={(event) => {
event.preventDefault()
submit()
diff --git a/web/app/components/app/export-confirm-modal.tsx b/web/app/components/app/export-confirm-modal.tsx
index 1641ebc8e52..057eb405532 100644
--- a/web/app/components/app/export-confirm-modal.tsx
+++ b/web/app/components/app/export-confirm-modal.tsx
@@ -2,6 +2,7 @@
import type { EnvironmentVariableItemResponse } from '@dify/contracts/api/console/apps/types.gen'
import {
AlertDialog,
+ AlertDialogBody,
AlertDialogCancelButton,
AlertDialogConfirmButton,
AlertDialogContent,
@@ -23,7 +24,7 @@ type AppExportConfirmModalProps = {
onClose: () => void
}
-export const AppExportConfirmContent = ({
+const AppExportConfirmContent = ({
envList,
onConfirm,
onClose,
@@ -48,7 +49,7 @@ export const AppExportConfirmContent = ({
{t(($) => $['exportSecret.description'], { ns: 'app' })}
</AlertDialogDescription>
</AlertDialogHeader>
- <div className="px-6">
+ <AlertDialogBody>
<div className="relative">
<table className="w-full border-separate border-spacing-0 rounded-lg border border-divider-regular shadow-xs">
<thead className="system-xs-medium-uppercase text-text-tertiary">
@@ -118,7 +119,7 @@ export const AppExportConfirmContent = ({
{t(($) => $['env.export.checkbox'], { ns: 'workflow' })}
</span>
</label>
- </div>
+ </AlertDialogBody>
<AlertDialogFooter>
<AlertDialogCancelButton disabled={isExporting}>
{t(($) => $['operation.cancel'], { ns: 'common' })}
diff --git a/web/app/components/app/overview/customize/index.tsx b/web/app/components/app/overview/customize/index.tsx
index 019c699289d..1c20fa27e5c 100644
--- a/web/app/components/app/overview/customize/index.tsx
+++ b/web/app/components/app/overview/customize/index.tsx
@@ -77,7 +77,7 @@ export function CustomizeDialog({
<span aria-hidden className="i-custom-vender-deploy-code-block size-4" />
{triggerLabel ?? t(($) => $['overview.appInfo.customize.entry'], { ns: 'appOverview' })}
</DialogTrigger>
- <DialogContent className="max-h-[calc(100dvh-2rem)] w-160">
+ <DialogContent className="w-160">
<DialogHeader>
<DialogTitle>
{t(($) => $[`${prefixCustomize}.title`], { ns: 'appOverview' })}
diff --git a/web/app/components/app/overview/embedded/index.tsx b/web/app/components/app/overview/embedded/index.tsx
index d64f8d7dcc0..bb1a97546b7 100644
--- a/web/app/components/app/overview/embedded/index.tsx
+++ b/web/app/components/app/overview/embedded/index.tsx
@@ -368,7 +368,7 @@ export function EmbeddedDialogContent({
const { t } = useTranslation(['appOverview', 'common'])
return (
- <DialogContent className="max-h-[calc(100dvh-2rem)] w-160">
+ <DialogContent className="w-160">
<DialogHeader>
<DialogTitle>{t(($) => $[`${prefixEmbedded}.title`], { ns: 'appOverview' })}</DialogTitle>
<DialogDescription>
diff --git a/web/app/components/app/overview/settings/index.tsx b/web/app/components/app/overview/settings/index.tsx
index e0e55630d8a..62236ea4694 100644
--- a/web/app/components/app/overview/settings/index.tsx
+++ b/web/app/components/app/overview/settings/index.tsx
@@ -26,13 +26,6 @@ import { Fieldset, FieldsetLegend } from '@langgenius/dify-ui/fieldset'
import { Form } from '@langgenius/dify-ui/form'
import { Input } from '@langgenius/dify-ui/input'
import { InputGroup, InputGroupAddon, InputGroupInput } from '@langgenius/dify-ui/input-group'
-import {
- ScrollArea,
- ScrollAreaContent,
- ScrollAreaScrollbar,
- ScrollAreaThumb,
- ScrollAreaViewport,
-} from '@langgenius/dify-ui/scroll-area'
import {
Select,
SelectContent,
@@ -301,7 +294,7 @@ function SettingsForm({
}
return (
- <Form className="flex min-h-0 flex-col" onFormSubmit={handleFormSubmit}>
+ <Form className="contents" onFormSubmit={handleFormSubmit}>
{canDeploy && (
<div className="px-6 py-2">
<div
@@ -328,322 +321,305 @@ function SettingsForm({
</div>
</div>
)}
- <ScrollArea className="flex min-h-0 flex-col overflow-hidden">
- <ScrollAreaViewport className="overscroll-contain">
- <ScrollAreaContent style={{ minWidth: 0 }}>
- <DialogBody className="flex flex-col gap-y-5">
- <div className="flex gap-4">
- <Field name="title" className="grow">
- <FieldLabel>
- {t(($) => $[`${prefixSettings}.webName`], { ns: 'appOverview' })}
- </FieldLabel>
- <Input
- readOnly={pending}
- required
- value={inputInfo.title}
- onValueChange={(value) => setInputInfo((item) => ({ ...item, title: value }))}
- placeholder={t(($) => $.appNamePlaceholder, { ns: 'app' })}
- />
- <FieldError match="valueMissing">
- {t(($) => $['newApp.nameNotEmpty'], { ns: 'app' })}
- </FieldError>
- </Field>
- <IconPicker
- value={
- appIcon ??
- (appInfo.site.icon_type === 'emoji' && appInfo.site.icon
- ? {
- type: 'emoji',
- icon: appInfo.site.icon,
- background: appInfo.site.icon_background,
- }
- : undefined)
+ <DialogBody className="flex flex-col gap-y-5">
+ <div className="flex gap-4">
+ <Field name="title" className="grow">
+ <FieldLabel>
+ {t(($) => $[`${prefixSettings}.webName`], { ns: 'appOverview' })}
+ </FieldLabel>
+ <Input
+ readOnly={pending}
+ required
+ value={inputInfo.title}
+ onValueChange={(value) => setInputInfo((item) => ({ ...item, title: value }))}
+ placeholder={t(($) => $.appNamePlaceholder, { ns: 'app' })}
+ />
+ <FieldError match="valueMissing">
+ {t(($) => $['newApp.nameNotEmpty'], { ns: 'app' })}
+ </FieldError>
+ </Field>
+ <IconPicker
+ value={
+ appIcon ??
+ (appInfo.site.icon_type === 'emoji' && appInfo.site.icon
+ ? {
+ type: 'emoji',
+ icon: appInfo.site.icon,
+ background: appInfo.site.icon_background,
}
- onValueChange={setAppIcon}
- >
- <IconPickerTrigger
- disabled={pending}
- aria-label={t(($) => $['iconPicker.title'], { ns: 'app' })}
- className="shrink-0 self-center rounded-2xl"
- >
- <IconPickerIcon size="xxl" />
- </IconPickerTrigger>
- <IconPickerContent />
- </IconPicker>
- </div>
+ : undefined)
+ }
+ onValueChange={setAppIcon}
+ >
+ <IconPickerTrigger
+ disabled={pending}
+ aria-label={t(($) => $['iconPicker.title'], { ns: 'app' })}
+ className="shrink-0 self-center rounded-2xl"
+ >
+ <IconPickerIcon size="xxl" />
+ </IconPickerTrigger>
+ <IconPickerContent />
+ </IconPicker>
+ </div>
- <Field name="description">
+ <Field name="description">
+ <FieldLabel>{t(($) => $[`${prefixSettings}.webDesc`], { ns: 'appOverview' })}</FieldLabel>
+ <Textarea
+ readOnly={pending}
+ value={inputInfo.desc}
+ onValueChange={(value) => setInputInfo((item) => ({ ...item, desc: value }))}
+ placeholder={t(($) => $[`${prefixSettings}.webDescPlaceholder`], {
+ ns: 'appOverview',
+ })}
+ />
+ <FieldDescription>
+ {t(($) => $[`${prefixSettings}.webDescTip`], { ns: 'appOverview' })}
+ </FieldDescription>
+ </Field>
+ <Separator />
+
+ {isChat && (
+ <Field name="use_icon_as_answer_icon">
+ <div className="flex items-center justify-between gap-3">
+ <FieldLabel>{t(($) => $['answerIcon.title'], { ns: 'app' })}</FieldLabel>
+ <Switch
+ readOnly={pending}
+ checked={inputInfo.use_icon_as_answer_icon}
+ onCheckedChange={(v) =>
+ setInputInfo((item) => ({ ...item, use_icon_as_answer_icon: v }))
+ }
+ />
+ </div>
+ <FieldDescription>
+ {t(($) => $['answerIcon.description'], { ns: 'app' })}
+ </FieldDescription>
+ </Field>
+ )}
+ <Field name="default_language" className="flex items-center justify-between gap-3">
+ <Select<Language>
+ readOnly={pending}
+ value={selectedLanguage?.value ?? null}
+ onValueChange={(value) => {
+ if (value !== null) setLanguage(value)
+ }}
+ >
+ <SelectLabel>
+ {t(($) => $[`${prefixSettings}.language`], { ns: 'appOverview' })}
+ </SelectLabel>
+ <SelectTrigger className="w-50">
+ {selectedLanguage?.name ?? t(($) => $['placeholder.select'], { ns: 'common' })}
+ </SelectTrigger>
+ <SelectContent>
+ {LANGUAGE_OPTIONS.map((item) => (
+ <SelectItem key={item.value} value={item.value}>
+ <SelectItemText>{item.name}</SelectItemText>
+ <SelectItemIndicator />
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </Field>
+ {isChat && (
+ <div className="grid gap-1">
+ <Field
+ name="chat_color_theme"
+ className="items-start gap-x-3 sm:grid-cols-[minmax(0,1fr)_12.5rem]"
+ >
+ <div>
<FieldLabel>
- {t(($) => $[`${prefixSettings}.webDesc`], { ns: 'appOverview' })}
+ {t(($) => $[`${prefixSettings}.chatColorTheme`], { ns: 'appOverview' })}
</FieldLabel>
- <Textarea
- readOnly={pending}
- value={inputInfo.desc}
- onValueChange={(value) => setInputInfo((item) => ({ ...item, desc: value }))}
- placeholder={t(($) => $[`${prefixSettings}.webDescPlaceholder`], {
- ns: 'appOverview',
- })}
- />
<FieldDescription>
- {t(($) => $[`${prefixSettings}.webDescTip`], { ns: 'appOverview' })}
+ {t(($) => $[`${prefixSettings}.chatColorThemeDesc`], { ns: 'appOverview' })}
</FieldDescription>
- </Field>
- <Separator />
-
- {isChat && (
- <Field name="use_icon_as_answer_icon">
- <div className="flex items-center justify-between gap-3">
- <FieldLabel>{t(($) => $['answerIcon.title'], { ns: 'app' })}</FieldLabel>
- <Switch
- readOnly={pending}
- checked={inputInfo.use_icon_as_answer_icon}
- onCheckedChange={(v) =>
- setInputInfo((item) => ({ ...item, use_icon_as_answer_icon: v }))
- }
- />
- </div>
- <FieldDescription>
- {t(($) => $['answerIcon.description'], { ns: 'app' })}
- </FieldDescription>
- </Field>
- )}
- <Field name="default_language" className="flex items-center justify-between gap-3">
- <Select<Language>
- readOnly={pending}
- value={selectedLanguage?.value ?? null}
- onValueChange={(value) => {
- if (value !== null) setLanguage(value)
- }}
- >
- <SelectLabel>
- {t(($) => $[`${prefixSettings}.language`], { ns: 'appOverview' })}
- </SelectLabel>
- <SelectTrigger className="w-50">
- {selectedLanguage?.name ?? t(($) => $['placeholder.select'], { ns: 'common' })}
- </SelectTrigger>
- <SelectContent>
- {LANGUAGE_OPTIONS.map((item) => (
- <SelectItem key={item.value} value={item.value}>
- <SelectItemText>{item.name}</SelectItemText>
- <SelectItemIndicator />
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- </Field>
- {isChat && (
- <div className="grid gap-1">
- <Field
- name="chat_color_theme"
- className="items-start gap-x-3 sm:grid-cols-[minmax(0,1fr)_12.5rem]"
- >
- <div>
- <FieldLabel>
- {t(($) => $[`${prefixSettings}.chatColorTheme`], { ns: 'appOverview' })}
- </FieldLabel>
- <FieldDescription>
- {t(($) => $[`${prefixSettings}.chatColorThemeDesc`], { ns: 'appOverview' })}
- </FieldDescription>
- </div>
- <Input
- readOnly={pending}
- pattern="#[A-Fa-f0-9]{6}"
- value={inputInfo.chatColorTheme}
- onValueChange={(value) =>
- setInputInfo((item) => ({ ...item, chatColorTheme: value }))
- }
- placeholder="E.g #A020F0"
- />
- <FieldError match="patternMismatch" className="sm:col-start-2">
- {t(($) => $[`${prefixSettings}.invalidHexMessage`], { ns: 'appOverview' })}
- </FieldError>
- </Field>
- <Field
- name="chat_color_theme_inverted"
- className="ml-auto flex w-50 items-center justify-between gap-2"
- >
- <FieldLabel>
- {t(($) => $[`${prefixSettings}.chatColorThemeInverted`], {
- ns: 'appOverview',
- })}
- </FieldLabel>
- <Switch
- readOnly={pending}
- checked={inputInfo.chatColorThemeInverted}
- onCheckedChange={(value) =>
- setInputInfo((item) => ({ ...item, chatColorThemeInverted: value }))
- }
- />
- </Field>
- </div>
- )}
+ </div>
+ <Input
+ readOnly={pending}
+ pattern="#[A-Fa-f0-9]{6}"
+ value={inputInfo.chatColorTheme}
+ onValueChange={(value) =>
+ setInputInfo((item) => ({ ...item, chatColorTheme: value }))
+ }
+ placeholder="E.g #A020F0"
+ />
+ <FieldError match="patternMismatch" className="sm:col-start-2">
+ {t(($) => $[`${prefixSettings}.invalidHexMessage`], { ns: 'appOverview' })}
+ </FieldError>
+ </Field>
+ <Field
+ name="chat_color_theme_inverted"
+ className="ml-auto flex w-50 items-center justify-between gap-2"
+ >
+ <FieldLabel>
+ {t(($) => $[`${prefixSettings}.chatColorThemeInverted`], {
+ ns: 'appOverview',
+ })}
+ </FieldLabel>
+ <Switch
+ readOnly={pending}
+ checked={inputInfo.chatColorThemeInverted}
+ onCheckedChange={(value) =>
+ setInputInfo((item) => ({ ...item, chatColorThemeInverted: value }))
+ }
+ />
+ </Field>
+ </div>
+ )}
- <Field name="show_workflow_steps">
- <div className="flex items-center justify-between gap-3">
- <FieldLabel>
- {t(($) => $[`${prefixSettings}.workflow.subTitle`], { ns: 'appOverview' })}
- </FieldLabel>
+ <Field name="show_workflow_steps">
+ <div className="flex items-center justify-between gap-3">
+ <FieldLabel>
+ {t(($) => $[`${prefixSettings}.workflow.subTitle`], { ns: 'appOverview' })}
+ </FieldLabel>
+ <Switch
+ readOnly={pending}
+ disabled={!(appInfo.mode === 'workflow' || appInfo.mode === 'advanced-chat')}
+ checked={inputInfo.show_workflow_steps}
+ onCheckedChange={(v) => setInputInfo((item) => ({ ...item, show_workflow_steps: v }))}
+ />
+ </div>
+ <FieldDescription>
+ {t(($) => $[`${prefixSettings}.workflow.showDesc`], { ns: 'appOverview' })}
+ </FieldDescription>
+ </Field>
+ <Separator />
+ {INPUT_PLACEHOLDER_SUPPORTED_MODES.includes(appInfo.mode) && (
+ <Field name="input_placeholder" disabled={!canCustomizePlaceholder}>
+ <div className="flex items-center gap-1">
+ <FieldLabel>
+ {t(($) => $[`${prefixSettings}.more.inputPlaceholder`], {
+ ns: 'appOverview',
+ })}
+ </FieldLabel>
+ {showUpgrade && <SettingsUpgradeButton />}
+ </div>
+ <FieldDescription>
+ {t(($) => $[`${prefixSettings}.more.inputPlaceholderTip`], {
+ ns: 'appOverview',
+ })}
+ </FieldDescription>
+ {showUpgrade ? (
+ <Tooltip>
+ <TooltipTrigger render={inputPlaceholderField} />
+ <TooltipContent className="w-45">
+ {t(($) => $[`${prefixSettings}.more.inputPlaceholderTooltip`], {
+ ns: 'appOverview',
+ })}
+ </TooltipContent>
+ </Tooltip>
+ ) : (
+ inputPlaceholderField
+ )}
+ {canCustomizePlaceholder && (
+ <FieldDescription className="text-right">
+ {`${inputInfo.inputPlaceholder.length} / ${INPUT_PLACEHOLDER_MAX_LENGTH}`}
+ </FieldDescription>
+ )}
+ </Field>
+ )}
+ <Fieldset className="grid gap-1">
+ <Field name="copyright_enabled" disabled={webappCopyrightEnabled !== true}>
+ <div className="flex items-center gap-1">
+ <FieldsetLegend id={copyrightLegendId} className="mb-0">
+ {t(($) => $[`${prefixSettings}.more.copyright`], { ns: 'appOverview' })}
+ </FieldsetLegend>
+ {showUpgrade && <SettingsUpgradeButton />}
+ <Tooltip>
+ <TooltipTrigger render={<div className="ml-auto" />}>
<Switch
readOnly={pending}
- disabled={!(appInfo.mode === 'workflow' || appInfo.mode === 'advanced-chat')}
- checked={inputInfo.show_workflow_steps}
- onCheckedChange={(v) =>
- setInputInfo((item) => ({ ...item, show_workflow_steps: v }))
+ aria-labelledby={copyrightLegendId}
+ checked={inputInfo.copyrightSwitchValue}
+ onCheckedChange={(value) =>
+ setInputInfo((item) => ({ ...item, copyrightSwitchValue: value }))
}
/>
- </div>
- <FieldDescription>
- {t(($) => $[`${prefixSettings}.workflow.showDesc`], { ns: 'appOverview' })}
- </FieldDescription>
- </Field>
- <Separator />
- {INPUT_PLACEHOLDER_SUPPORTED_MODES.includes(appInfo.mode) && (
- <Field name="input_placeholder" disabled={!canCustomizePlaceholder}>
- <div className="flex items-center gap-1">
- <FieldLabel>
- {t(($) => $[`${prefixSettings}.more.inputPlaceholder`], {
- ns: 'appOverview',
- })}
- </FieldLabel>
- {showUpgrade && <SettingsUpgradeButton />}
- </div>
- <FieldDescription>
- {t(($) => $[`${prefixSettings}.more.inputPlaceholderTip`], {
+ </TooltipTrigger>
+ {webappCopyrightEnabled === false && (
+ <TooltipContent className="w-45">
+ {t(($) => $[`${prefixSettings}.more.copyrightTooltip`], {
ns: 'appOverview',
})}
- </FieldDescription>
- {showUpgrade ? (
- <Tooltip>
- <TooltipTrigger render={inputPlaceholderField} />
- <TooltipContent className="w-45">
- {t(($) => $[`${prefixSettings}.more.inputPlaceholderTooltip`], {
- ns: 'appOverview',
- })}
- </TooltipContent>
- </Tooltip>
- ) : (
- inputPlaceholderField
- )}
- {canCustomizePlaceholder && (
- <FieldDescription className="text-right">
- {`${inputInfo.inputPlaceholder.length} / ${INPUT_PLACEHOLDER_MAX_LENGTH}`}
- </FieldDescription>
- )}
- </Field>
- )}
- <Fieldset className="grid gap-1">
- <Field name="copyright_enabled" disabled={webappCopyrightEnabled !== true}>
- <div className="flex items-center gap-1">
- <FieldsetLegend id={copyrightLegendId} className="mb-0">
- {t(($) => $[`${prefixSettings}.more.copyright`], { ns: 'appOverview' })}
- </FieldsetLegend>
- {showUpgrade && <SettingsUpgradeButton />}
- <Tooltip>
- <TooltipTrigger render={<div className="ml-auto" />}>
- <Switch
- readOnly={pending}
- aria-labelledby={copyrightLegendId}
- checked={inputInfo.copyrightSwitchValue}
- onCheckedChange={(value) =>
- setInputInfo((item) => ({ ...item, copyrightSwitchValue: value }))
- }
- />
- </TooltipTrigger>
- {webappCopyrightEnabled === false && (
- <TooltipContent className="w-45">
- {t(($) => $[`${prefixSettings}.more.copyrightTooltip`], {
- ns: 'appOverview',
- })}
- </TooltipContent>
- )}
- </Tooltip>
- </div>
- <FieldDescription id={copyrightDescriptionId}>
- {t(($) => $[`${prefixSettings}.more.copyrightTip`], { ns: 'appOverview' })}
- </FieldDescription>
- </Field>
- {inputInfo.copyrightSwitchValue && (
- <Field name="copyright" disabled={webappCopyrightEnabled !== true}>
- <Input
- readOnly={pending}
- aria-labelledby={copyrightLegendId}
- aria-describedby={copyrightDescriptionId}
- value={inputInfo.copyright}
- onValueChange={(value) =>
- setInputInfo((item) => ({ ...item, copyright: value }))
- }
- placeholder={t(($) => $[`${prefixSettings}.more.copyRightPlaceholder`], {
- ns: 'appOverview',
- })}
- />
- </Field>
+ </TooltipContent>
)}
- </Fieldset>
- <Field
- name="privacy_policy"
- validate={(value) => {
- if (typeof value === 'string' && value && !/^https?:\/\//.test(value))
- return t(($) => $[`${prefixSettings}.invalidPrivacyPolicy`], {
- ns: 'appOverview',
- })
- }}
- >
- <FieldLabel>
- {t(($) => $[`${prefixSettings}.more.privacyPolicy`], { ns: 'appOverview' })}
- </FieldLabel>
- <FieldDescription>
- <Trans
- i18nKey={($) => $[`${prefixSettings}.more.privacyPolicyTip`]}
- ns="appOverview"
- components={{
- privacyPolicyLink: (
- <Link
- href="https://dify.ai/privacy"
- target="_blank"
- rel="noopener noreferrer"
- className="text-text-accent"
- />
- ),
- }}
+ </Tooltip>
+ </div>
+ <FieldDescription id={copyrightDescriptionId}>
+ {t(($) => $[`${prefixSettings}.more.copyrightTip`], { ns: 'appOverview' })}
+ </FieldDescription>
+ </Field>
+ {inputInfo.copyrightSwitchValue && (
+ <Field name="copyright" disabled={webappCopyrightEnabled !== true}>
+ <Input
+ readOnly={pending}
+ aria-labelledby={copyrightLegendId}
+ aria-describedby={copyrightDescriptionId}
+ value={inputInfo.copyright}
+ onValueChange={(value) => setInputInfo((item) => ({ ...item, copyright: value }))}
+ placeholder={t(($) => $[`${prefixSettings}.more.copyRightPlaceholder`], {
+ ns: 'appOverview',
+ })}
+ />
+ </Field>
+ )}
+ </Fieldset>
+ <Field
+ name="privacy_policy"
+ validate={(value) => {
+ if (typeof value === 'string' && value && !/^https?:\/\//.test(value))
+ return t(($) => $[`${prefixSettings}.invalidPrivacyPolicy`], {
+ ns: 'appOverview',
+ })
+ }}
+ >
+ <FieldLabel>
+ {t(($) => $[`${prefixSettings}.more.privacyPolicy`], { ns: 'appOverview' })}
+ </FieldLabel>
+ <FieldDescription>
+ <Trans
+ i18nKey={($) => $[`${prefixSettings}.more.privacyPolicyTip`]}
+ ns="appOverview"
+ components={{
+ privacyPolicyLink: (
+ <Link
+ href="https://dify.ai/privacy"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="text-text-accent"
/>
- </FieldDescription>
- <Input
- readOnly={pending}
- value={inputInfo.privacyPolicy}
- onValueChange={(value) =>
- setInputInfo((item) => ({ ...item, privacyPolicy: value }))
- }
- placeholder={t(($) => $[`${prefixSettings}.more.privacyPolicyPlaceholder`], {
- ns: 'appOverview',
- })}
- />
- <FieldError />
- </Field>
- <Field name="custom_disclaimer">
- <FieldLabel>
- {t(($) => $[`${prefixSettings}.more.customDisclaimer`], { ns: 'appOverview' })}
- </FieldLabel>
- <FieldDescription>
- {t(($) => $[`${prefixSettings}.more.customDisclaimerTip`], { ns: 'appOverview' })}
- </FieldDescription>
- <Textarea
- readOnly={pending}
- value={inputInfo.customDisclaimer}
- onValueChange={(value) =>
- setInputInfo((item) => ({ ...item, customDisclaimer: value }))
- }
- placeholder={t(($) => $[`${prefixSettings}.more.customDisclaimerPlaceholder`], {
- ns: 'appOverview',
- })}
- />
- </Field>
- </DialogBody>
- </ScrollAreaContent>
- </ScrollAreaViewport>
- <ScrollAreaScrollbar>
- <ScrollAreaThumb />
- </ScrollAreaScrollbar>
- </ScrollArea>
+ ),
+ }}
+ />
+ </FieldDescription>
+ <Input
+ readOnly={pending}
+ value={inputInfo.privacyPolicy}
+ onValueChange={(value) => setInputInfo((item) => ({ ...item, privacyPolicy: value }))}
+ placeholder={t(($) => $[`${prefixSettings}.more.privacyPolicyPlaceholder`], {
+ ns: 'appOverview',
+ })}
+ />
+ <FieldError />
+ </Field>
+ <Field name="custom_disclaimer">
+ <FieldLabel>
+ {t(($) => $[`${prefixSettings}.more.customDisclaimer`], { ns: 'appOverview' })}
+ </FieldLabel>
+ <FieldDescription>
+ {t(($) => $[`${prefixSettings}.more.customDisclaimerTip`], { ns: 'appOverview' })}
+ </FieldDescription>
+ <Textarea
+ readOnly={pending}
+ value={inputInfo.customDisclaimer}
+ onValueChange={(value) =>
+ setInputInfo((item) => ({ ...item, customDisclaimer: value }))
+ }
+ placeholder={t(($) => $[`${prefixSettings}.more.customDisclaimerPlaceholder`], {
+ ns: 'appOverview',
+ })}
+ />
+ </Field>
+ </DialogBody>
<DialogFooter>
<DialogClose disabled={pending} render={<Button />}>
@@ -702,7 +678,7 @@ export function SettingsDialog({
}}
>
<DialogTrigger render={trigger} />
- <DialogContent className="flex max-h-[calc(100dvh-2rem)] w-130 flex-col overflow-hidden">
+ <DialogContent className="w-130">
<DialogHeader>
<DialogTitle>{t(($) => $[`${prefixSettings}.title`], { ns: 'appOverview' })}</DialogTitle>
<DialogDescription>
diff --git a/web/app/components/app/overview/workflow-launch-dialog/index.tsx b/web/app/components/app/overview/workflow-launch-dialog/index.tsx
index e0042646d02..010864f8a2c 100644
--- a/web/app/components/app/overview/workflow-launch-dialog/index.tsx
+++ b/web/app/components/app/overview/workflow-launch-dialog/index.tsx
@@ -61,7 +61,7 @@ function WorkflowLaunchForm({
}
return (
- <form onSubmit={handleSubmit}>
+ <form className="contents" onSubmit={handleSubmit}>
<DialogBody className="space-y-4">
<WorkflowHiddenInputFields
hiddenVariables={hiddenVariables}
diff --git a/web/app/components/app/switch-app-modal/__tests__/index.spec.tsx b/web/app/components/app/switch-app-modal/__tests__/index.spec.tsx
index e0642948ec4..1148db4111e 100644
--- a/web/app/components/app/switch-app-modal/__tests__/index.spec.tsx
+++ b/web/app/components/app/switch-app-modal/__tests__/index.spec.tsx
@@ -1,6 +1,6 @@
import type { AppPartial } from '@dify/contracts/api/console/apps/types.gen'
import type { ReactElement } from 'react'
-import { screen, waitFor } from '@testing-library/react'
+import { act, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import * as React from 'react'
import { renderWithConsoleQuery } from '@/test/console/query-data'
@@ -115,17 +115,17 @@ vi.mock('@/app/notifications', () => ({
}))
const renderComponent = (overrides: Partial<React.ComponentProps<typeof SwitchAppModal>> = {}) => {
- const onClose = vi.fn()
+ const onOpenChange = vi.fn()
const appDetail = createMockApp()
const utils = render(
- <SwitchAppModal show sourceApp={appDetail} onClose={onClose} {...overrides} />,
+ <SwitchAppModal open sourceApp={appDetail} onOpenChange={onOpenChange} {...overrides} />,
)
return {
...utils,
notify: toastMocks.notify,
- onClose,
+ onOpenChange,
appDetail,
}
}
@@ -182,7 +182,7 @@ describe('SwitchAppModal', () => {
it('should not render modal content when show is false', () => {
// Arrange
- renderComponent({ show: false })
+ renderComponent({ open: false })
// Assert
expect(screen.queryByText('app.switch')).not.toBeInTheDocument()
@@ -191,17 +191,22 @@ describe('SwitchAppModal', () => {
// Prop-driven UI states such as disabling actions.
describe('Props', () => {
- it('should disable the start button when name is empty', async () => {
+ it('should validate blank names and submit the current field value with Enter', async () => {
const user = userEvent.setup()
- // Arrange
renderComponent()
-
- // Act
const nameInput = screen.getByDisplayValue('Demo App(copy)')
await user.clear(nameInput)
-
- // Assert
- expect(screen.getByRole('button', { name: 'app.switchStart' })).toBeDisabled()
+ await user.type(nameInput, ' {Enter}')
+ expect(await screen.findByText('explore.appCustomize.nameRequired')).toBeVisible()
+ expect(mockConvertToWorkflow).not.toHaveBeenCalled()
+ mockConvertToWorkflow.mockResolvedValue({ new_app_id: 'converted-app' })
+ await user.clear(nameInput)
+ await user.type(nameInput, 'Renamed workflow{Enter}')
+ await waitFor(() =>
+ expect(mockConvertToWorkflow).toHaveBeenCalledWith(
+ expect.objectContaining({ body: expect.objectContaining({ name: 'Renamed workflow' }) }),
+ ),
+ )
})
it('should render the apps full warning when plan limits are reached', () => {
@@ -222,31 +227,31 @@ describe('SwitchAppModal', () => {
// User interactions that trigger navigation and API calls.
describe('Interactions', () => {
- it('should call onClose when cancel is clicked', async () => {
+ it('should call onOpenChange when cancel is clicked', async () => {
const user = userEvent.setup()
// Arrange
- const { onClose } = renderComponent()
+ const { onOpenChange } = renderComponent()
// Act
await user.click(screen.getByRole('button', { name: 'app.newApp.Cancel' }))
// Assert
- expect(onClose).toHaveBeenCalledTimes(1)
+ expect(onOpenChange).toHaveBeenCalledTimes(1)
})
- it('should call onClose when close button is clicked', async () => {
+ it('should call onOpenChange when close button is clicked', async () => {
const user = userEvent.setup()
- const { onClose } = renderComponent()
+ const { onOpenChange } = renderComponent()
await user.click(screen.getByRole('button', { name: /operation\.close$/ }))
- expect(onClose).toHaveBeenCalledTimes(1)
+ expect(onOpenChange).toHaveBeenCalledTimes(1)
})
it('should switch app and navigate with push when keeping original', async () => {
const user = userEvent.setup()
// Arrange
- const { appDetail, onClose } = renderComponent()
+ const { appDetail, onOpenChange } = renderComponent()
mockConvertToWorkflow.mockResolvedValueOnce({
new_app_id: 'new-app-001',
permission_keys: ['app.acl.view_layout'],
@@ -266,7 +271,7 @@ describe('SwitchAppModal', () => {
icon_background: '#FFEAD5',
},
})
- expect(onClose).toHaveBeenCalledTimes(1)
+ expect(onOpenChange).toHaveBeenCalledTimes(1)
expect(mockPush).toHaveBeenCalledWith('/app/new-app-001/workflow')
expect(mockReplace).not.toHaveBeenCalled()
})
@@ -364,10 +369,42 @@ describe('SwitchAppModal', () => {
expect(mockPush).not.toHaveBeenCalled()
})
+ it('keeps conversion pending until original deletion settles and navigates to the created app if deletion fails', async () => {
+ const user = userEvent.setup()
+ const { onOpenChange, notify } = renderComponent()
+ mockConvertToWorkflow.mockResolvedValueOnce({
+ new_app_id: 'converted-app',
+ permission_keys: ['app.acl.view_layout'],
+ })
+ let rejectDeletion: (error: Error) => void = () => {}
+ mockDeleteOriginalApp.mockImplementationOnce(
+ () =>
+ new Promise((_resolve, reject) => {
+ rejectDeletion = reject
+ }),
+ )
+ await user.click(screen.getByRole('checkbox'))
+ await user.click(screen.getByRole('button', { name: 'common.operation.confirm' }))
+ await user.click(screen.getByRole('button', { name: 'app.switchStart' }))
+ await waitFor(() => expect(mockDeleteOriginalApp).toHaveBeenCalledTimes(1))
+ await user.keyboard('{Escape}')
+ expect(onOpenChange).not.toHaveBeenCalled()
+ expect(screen.getByRole('button', { name: 'app.switchStart' })).toHaveAttribute(
+ 'aria-disabled',
+ 'true',
+ )
+ await user.click(screen.getByRole('button', { name: 'app.switchStart' }))
+ expect(mockConvertToWorkflow).toHaveBeenCalledTimes(1)
+ await act(async () => rejectDeletion(new Error('Failed to delete original')))
+ await waitFor(() => expect(mockPush).toHaveBeenCalledWith('/app/converted-app/workflow'))
+ expect(notify).toHaveBeenCalledWith({ type: 'error', message: 'app.appDeleteFailed' })
+ expect(mockConvertToWorkflow).toHaveBeenCalledTimes(1)
+ })
+
it('should notify error when switch app fails', async () => {
const user = userEvent.setup()
// Arrange
- const { notify, onClose } = renderComponent()
+ const { notify, onOpenChange } = renderComponent()
mockConvertToWorkflow.mockRejectedValueOnce(new Error('fail'))
// Act
@@ -380,7 +417,7 @@ describe('SwitchAppModal', () => {
message: 'app.newApp.appCreateFailed',
})
})
- expect(onClose).not.toHaveBeenCalled()
+ expect(onOpenChange).not.toHaveBeenCalled()
})
})
})
diff --git a/web/app/components/app/switch-app-modal/index.tsx b/web/app/components/app/switch-app-modal/index.tsx
index e03af7de6c3..e1e325afee7 100644
--- a/web/app/components/app/switch-app-modal/index.tsx
+++ b/web/app/components/app/switch-app-modal/index.tsx
@@ -1,6 +1,10 @@
'use client'
-import type { AppPartial } from '@dify/contracts/api/console/apps/types.gen'
+import type {
+ AppPartial,
+ ConvertToWorkflowPayload,
+} from '@dify/contracts/api/console/apps/types.gen'
+import type { DialogActions, DialogProps } from '@langgenius/dify-ui/dialog'
import { zIconType } from '@dify/contracts/api/console/apps/zod.gen'
import {
AlertDialog,
@@ -17,6 +21,7 @@ import { Checkbox } from '@langgenius/dify-ui/checkbox'
import {
Dialog,
DialogBody,
+ DialogClose,
DialogCloseButton,
DialogContent,
DialogDescription,
@@ -24,9 +29,11 @@ import {
DialogHeader,
DialogTitle,
} from '@langgenius/dify-ui/dialog'
+import { Field, FieldError, FieldLabel } from '@langgenius/dify-ui/field'
+import { Form } from '@langgenius/dify-ui/form'
import { Input } from '@langgenius/dify-ui/input'
import { useMutation, useQuery, useSuspenseQuery } from '@tanstack/react-query'
-import { useId, useState } from 'react'
+import { useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import {
IconPicker,
@@ -41,21 +48,92 @@ import { useRouter } from '@/next/navigation'
import { consoleQuery } from '@/service/console'
import { getRedirection } from '@/utils/app-redirection'
-type SwitchAppModalProps = {
- show: boolean
+type SwitchAppModalProps = Pick<DialogProps, 'open' | 'onOpenChange'> & {
sourceApp: Pick<
AppPartial,
'icon' | 'icon_background' | 'icon_type' | 'icon_url' | 'id' | 'mode' | 'name'
>
- onClose: () => void
}
-const SwitchAppModal = ({ show, sourceApp, onClose }: SwitchAppModalProps) => {
+const SwitchAppModal = ({ open, sourceApp, onOpenChange }: SwitchAppModalProps) => {
+ const nameInputRef = useRef<HTMLInputElement>(null)
+ const actionsRef = useRef<DialogActions>(null)
+ const { t } = useTranslation(['app'])
const { push, replace } = useRouter()
- const nameInputId = useId()
- const { t } = useTranslation(['app', 'common'])
const { data: systemFeatures } = useSuspenseQuery(systemFeaturesQueryOptions())
- const isRbacEnabled = systemFeatures.rbac_enabled
+ const conversion = useMutation(consoleQuery.apps.byAppId.convertToWorkflow.post.mutationOptions())
+ const deletion = useMutation(consoleQuery.apps.byAppId.delete.mutationOptions())
+ const isPending = conversion.isPending || deletion.isPending
+ const submit = (body: ConvertToWorkflowPayload, removeOriginal: boolean) => {
+ if (isPending) return
+ conversion.mutate(
+ { params: { app_id: sourceApp.id }, body },
+ {
+ onError: () => toast.error(t(($) => $['newApp.appCreateFailed'], { ns: 'app' })),
+ onSuccess: ({ new_app_id, permission_keys }) => {
+ const finish = (removed: boolean) => {
+ actionsRef.current?.close()
+ getRedirection(
+ {
+ id: new_app_id,
+ mode: sourceApp.mode === 'completion' ? 'workflow' : 'advanced-chat',
+ permission_keys,
+ },
+ removed ? replace : push,
+ { isRbacEnabled: systemFeatures.rbac_enabled },
+ )
+ }
+ if (removeOriginal) {
+ deletion.mutate(
+ { params: { app_id: sourceApp.id } },
+ {
+ onSuccess: () => finish(true),
+ onError: () => {
+ toast.error(t(($) => $.appDeleteFailed, { ns: 'app' }))
+ finish(false)
+ },
+ },
+ )
+ } else finish(false)
+ },
+ },
+ )
+ }
+ return (
+ <Dialog
+ actionsRef={actionsRef}
+ open={open}
+ disablePointerDismissal
+ onOpenChange={(nextOpen, details) => {
+ if (!nextOpen && isPending && details.reason !== 'imperative-action') details.cancel()
+ else onOpenChange?.(nextOpen, details)
+ }}
+ >
+ <DialogContent initialFocus={nameInputRef} className="w-150 max-w-150">
+ <SwitchAppSession
+ nameInputRef={nameInputRef}
+ sourceApp={sourceApp}
+ onSubmit={submit}
+ isPending={isPending}
+ />
+ </DialogContent>
+ </Dialog>
+ )
+}
+
+function SwitchAppSession({
+ nameInputRef,
+ sourceApp,
+ onSubmit,
+ isPending,
+}: Pick<SwitchAppModalProps, 'sourceApp'> & {
+ nameInputRef: React.RefObject<HTMLInputElement | null>
+ onSubmit: (body: ConvertToWorkflowPayload, removeOriginal: boolean) => void
+ isPending: boolean
+}) {
+ const formRef = useRef<HTMLFormElement>(null)
+ const { t } = useTranslation(['app', 'common', 'explore'])
+ const { data: systemFeatures } = useSuspenseQuery(systemFeaturesQueryOptions())
const deploymentEdition = systemFeatures.deployment_edition
const { data: appQuota } = useQuery(
@@ -83,45 +161,19 @@ const SwitchAppModal = ({ show, sourceApp, onClose }: SwitchAppModalProps) => {
},
)
- const [name, setName] = useState(`${sourceApp.name}(copy)`)
const [removeOriginal, setRemoveOriginal] = useState<boolean>(false)
const [showConfirmDelete, setShowConfirmDelete] = useState(false)
- const { mutateAsync: convertToWorkflow } = useMutation(
- consoleQuery.apps.byAppId.convertToWorkflow.post.mutationOptions(),
- )
- const { mutateAsync: deleteOriginalApp } = useMutation(
- consoleQuery.apps.byAppId.delete.mutationOptions(),
- )
-
- const goStart = async () => {
- if (isAppQuotaUnavailable || isAppsFull) return
- try {
- const { new_app_id: newAppID, permission_keys } = await convertToWorkflow({
- params: { app_id: sourceApp.id },
- body: {
- name,
- icon_type: appIcon.type,
- icon: appIcon.type === 'emoji' ? appIcon.icon : appIcon.fileId,
- icon_background: appIcon.type === 'emoji' ? appIcon.background : undefined,
- },
- })
- onClose()
- if (removeOriginal)
- await deleteOriginalApp({
- params: { app_id: sourceApp.id },
- })
- getRedirection(
- {
- id: newAppID,
- mode: sourceApp.mode === 'completion' ? 'workflow' : 'advanced-chat',
- permission_keys,
- },
- removeOriginal ? replace : push,
- { isRbacEnabled },
- )
- } catch {
- toast.error(t(($) => $['newApp.appCreateFailed'], { ns: 'app' }))
- }
+ const submit = (name: string) => {
+ if (isPending || isAppQuotaUnavailable || isAppsFull || !name.trim()) return
+ onSubmit(
+ {
+ name,
+ icon_type: appIcon.type,
+ icon: appIcon.type === 'emoji' ? appIcon.icon : appIcon.fileId,
+ icon_background: appIcon.type === 'emoji' ? appIcon.background : undefined,
+ },
+ removeOriginal,
+ )
}
const handleConfirmDeleteOpenChange = (open: boolean) => {
@@ -133,87 +185,102 @@ const SwitchAppModal = ({ show, sourceApp, onClose }: SwitchAppModalProps) => {
return (
<>
- <Dialog
- open={show}
- disablePointerDismissal
- onOpenChange={(open) => {
- if (!open && !showConfirmDelete) onClose()
+ <Form
+ ref={formRef}
+ className="contents"
+ onFormSubmit={(values, details) => {
+ if (details.event.target === formRef.current) submit(String(values.name ?? ''))
}}
>
- <DialogContent className="w-150 max-w-150">
- <DialogHeader>
- <div className="mb-2 h-12 w-12 rounded-xl border-[0.5px] border-divider-regular bg-background-default-burn p-3 shadow-xl">
- <span
- aria-hidden
- className="i-custom-vender-solid-alertsAndFeedback-alert-triangle size-6 text-[rgb(247,144,9)]"
- />
- </div>
- <DialogTitle>{t(($) => $.switch, { ns: 'app' })}</DialogTitle>
- <DialogDescription>
- <span>{t(($) => $.switchTipStart, { ns: 'app' })}</span>
- <span className="font-medium text-text-secondary">
- {t(($) => $.switchTip, { ns: 'app' })}
- </span>
- <span>{t(($) => $.switchTipEnd, { ns: 'app' })}</span>
- </DialogDescription>
- <DialogCloseButton aria-label={t(($) => $['operation.close'], { ns: 'common' })} />
- </DialogHeader>
- <DialogBody>
- <label
- htmlFor={nameInputId}
- className="block py-2 text-sm leading-5 font-medium text-text-primary"
+ <DialogHeader>
+ <div className="mb-2 h-12 w-12 rounded-xl border-[0.5px] border-divider-regular bg-background-default-burn p-3 shadow-xl">
+ <span
+ aria-hidden
+ className="i-custom-vender-solid-alertsAndFeedback-alert-triangle size-6 text-[rgb(247,144,9)]"
+ />
+ </div>
+ <DialogTitle>{t(($) => $.switch, { ns: 'app' })}</DialogTitle>
+ <DialogDescription>
+ <span>{t(($) => $.switchTipStart, { ns: 'app' })}</span>
+ <span className="font-medium text-text-secondary">
+ {t(($) => $.switchTip, { ns: 'app' })}
+ </span>
+ <span>{t(($) => $.switchTipEnd, { ns: 'app' })}</span>
+ </DialogDescription>
+ <DialogCloseButton
+ disabled={isPending}
+ aria-label={t(($) => $['operation.close'], { ns: 'common' })}
+ />
+ </DialogHeader>
+ <DialogBody>
+ <IconPicker value={appIcon} onValueChange={setAppIcon}>
+ <Field
+ name="name"
+ validate={(value) =>
+ typeof value === 'string' && !value.trim()
+ ? t(($) => $['appCustomize.nameRequired'], { ns: 'explore' })
+ : null
+ }
>
- {t(($) => $.switchLabel, { ns: 'app' })}
- </label>
- <div className="flex items-center justify-between space-x-2">
- <IconPicker value={appIcon} onValueChange={setAppIcon}>
+ <FieldLabel className="block py-2 text-sm leading-5 font-medium text-text-primary">
+ {t(($) => $.switchLabel, { ns: 'app' })}
+ </FieldLabel>
+ <div className="flex items-center justify-between space-x-2">
<IconPickerTrigger
+ disabled={isPending}
aria-label={t(($) => $['iconPicker.title'], { ns: 'app' })}
className="shrink-0 cursor-pointer rounded-[10px]"
>
<IconPickerIcon size="large" />
</IconPickerTrigger>
- <IconPickerContent />
- </IconPicker>
- <Input
- id={nameInputId}
- value={name}
- onChange={(e) => setName(e.target.value)}
- placeholder={t(($) => $['newApp.appNamePlaceholder'], { ns: 'app' }) || ''}
- className="h-10 grow"
- />
- </div>
- {isAppsFull && <AppsFull className="mt-4" loc="app-switch" />}
- </DialogBody>
- <DialogFooter>
- <div className="me-auto flex items-center">
- <label className="flex cursor-pointer items-center">
- <Checkbox
- className="shrink-0"
- checked={removeOriginal}
- onCheckedChange={(checked) => {
- setRemoveOriginal(checked)
- if (checked) setShowConfirmDelete(true)
- }}
+ <Input
+ ref={nameInputRef}
+ required
+ readOnly={isPending}
+ defaultValue={`${sourceApp.name}(copy)`}
+ placeholder={t(($) => $['newApp.appNamePlaceholder'], { ns: 'app' }) || ''}
+ className="h-10 grow"
/>
- <span className="ml-2 text-left text-sm/5 text-text-secondary">
- {t(($) => $.removeOriginal, { ns: 'app' })}
- </span>
- </label>
- </div>
- <Button onClick={onClose}>{t(($) => $['newApp.Cancel'], { ns: 'app' })}</Button>
- <Button
- className="inset-ring-red-700"
- disabled={isAppQuotaUnavailable || isAppsFull || !name}
- variant="primary"
- tone="destructive"
- onClick={goStart}
- >
- {t(($) => $.switchStart, { ns: 'app' })}
- </Button>
- </DialogFooter>
- </DialogContent>
- </Dialog>
+ </div>
+ <FieldError />
+ </Field>
+ <IconPickerContent />
+ </IconPicker>
+ {isAppsFull && <AppsFull className="mt-4" loc="app-switch" />}
+ </DialogBody>
+ <DialogFooter>
+ <div className="me-auto flex items-center">
+ <label className="flex cursor-pointer items-center">
+ <Checkbox
+ name="remove_original"
+ className="shrink-0"
+ disabled={isPending}
+ checked={removeOriginal}
+ onCheckedChange={(checked) => {
+ setRemoveOriginal(checked)
+ if (checked) setShowConfirmDelete(true)
+ }}
+ />
+ <span className="ml-2 text-left text-sm/5 text-text-secondary">
+ {t(($) => $.removeOriginal, { ns: 'app' })}
+ </span>
+ </label>
+ </div>
+ <DialogClose disabled={isPending} render={<Button type="button" />}>
+ {t(($) => $['newApp.Cancel'], { ns: 'app' })}
+ </DialogClose>
+ <Button
+ className="inset-ring-red-700"
+ type="submit"
+ loading={isPending}
+ disabled={isAppQuotaUnavailable || isAppsFull}
+ variant="primary"
+ tone="destructive"
+ >
+ {t(($) => $.switchStart, { ns: 'app' })}
+ </Button>
+ </DialogFooter>
+ </Form>
<AlertDialog open={showConfirmDelete} onOpenChange={handleConfirmDeleteOpenChange}>
<AlertDialogContent>
<AlertDialogHeader>
diff --git a/web/app/components/apps/__tests__/app-card.spec.tsx b/web/app/components/apps/__tests__/app-card.spec.tsx
index a82dc8039c6..341d0ef87b1 100644
--- a/web/app/components/apps/__tests__/app-card.spec.tsx
+++ b/web/app/components/apps/__tests__/app-card.spec.tsx
@@ -311,19 +311,19 @@ vi.mock('next/dynamic', () => ({
}
if (fnString.includes('switch-app-modal')) {
return function MockSwitchAppModal({
- show,
- onClose,
+ open,
+ onOpenChange,
}: {
- show: boolean
- onClose: () => void
+ open: boolean
+ onOpenChange: (open: boolean) => void
}) {
- if (!show) return null
+ if (!open) return null
return React.createElement(
'div',
{ 'data-testid': 'switch-modal' },
React.createElement(
'button',
- { onClick: onClose, 'data-testid': 'close-switch-modal' },
+ { onClick: () => onOpenChange(false), 'data-testid': 'close-switch-modal' },
'Close',
),
)
diff --git a/web/app/components/apps/app-card/interactions.tsx b/web/app/components/apps/app-card/interactions.tsx
index e1d5de1599d..831b755d161 100644
--- a/web/app/components/apps/app-card/interactions.tsx
+++ b/web/app/components/apps/app-card/interactions.tsx
@@ -673,7 +673,13 @@ export function AppCardInteractions({
/>
)}
{activeDialog === 'switch' && (
- <SwitchAppModal show sourceApp={app} onClose={() => setActiveDialog(null)} />
+ <SwitchAppModal
+ open
+ sourceApp={app}
+ onOpenChange={(open) => {
+ if (!open) setActiveDialog(null)
+ }}
+ />
)}
<AlertDialog open={activeDialog === 'delete'} onOpenChange={onDeleteDialogOpenChange}>
<AlertDialogContent>
diff --git a/web/app/components/base/agent-log-modal/index.tsx b/web/app/components/base/agent-log-modal/index.tsx
index 0015242d5a9..384b8b01a3a 100644
--- a/web/app/components/base/agent-log-modal/index.tsx
+++ b/web/app/components/base/agent-log-modal/index.tsx
@@ -63,13 +63,10 @@ const AgentLogModal: FC<AgentLogModalProps> = ({
>
<DialogPortal>
<DialogBackdrop className="bg-transparent!" />
- <DialogPopup className="fixed top-16 bottom-4 left-[max(8px,calc(100vw-1136px))] flex w-120 max-w-[calc(100vw-16px)] flex-col overflow-hidden overscroll-contain rounded-xl py-3">
- <DialogTitle
- // oxlint-disable-next-line shadcn/no-restyle -- Side panel keeps its compact header row.
- className="shrink-0 px-4 py-1"
- >
- {t(($) => $['runDetail.workflowTitle'], { ns: 'appLog' })}
- </DialogTitle>
+ <DialogPopup className="fixed top-16 bottom-4 left-[max(8px,calc(100vw-1136px))] flex w-120 max-w-[calc(100vw-16px)] flex-col overflow-hidden overscroll-contain rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg py-3 shadow-xl">
+ <div className="shrink-0 px-4 py-1">
+ <DialogTitle>{t(($) => $['runDetail.workflowTitle'], { ns: 'appLog' })}</DialogTitle>
+ </div>
<button
type="button"
aria-label={t(($) => $['operation.close'], { ns: 'common' })}
diff --git a/web/app/components/base/chat/chat-with-history/header-in-mobile.tsx b/web/app/components/base/chat/chat-with-history/header-in-mobile.tsx
index 28defa55ab5..7991ac93ecb 100644
--- a/web/app/components/base/chat/chat-with-history/header-in-mobile.tsx
+++ b/web/app/components/base/chat/chat-with-history/header-in-mobile.tsx
@@ -130,7 +130,7 @@ const HeaderInMobile = () => {
<DialogPortal>
<DialogBackdrop />
<DialogViewport className="flex p-1">
- <DialogPopup className="flex h-full w-[calc(100vw-40px)] flex-col rounded-xl backdrop-blur-xs">
+ <DialogPopup className="flex h-full w-[calc(100vw-40px)] flex-col rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-xl backdrop-blur-xs">
<DialogTitle className="sr-only">
{appData?.site.title || t(($) => $['sidebar.expandSidebar'], { ns: 'layout' })}
</DialogTitle>
@@ -155,21 +155,19 @@ const HeaderInMobile = () => {
<DialogPortal>
<DialogBackdrop />
<DialogViewport className="flex justify-end p-1">
- <DialogPopup className="flex h-full w-[calc(100vw-40px)] flex-col rounded-xl backdrop-blur-xs">
+ <DialogPopup className="flex h-full w-[calc(100vw-40px)] flex-col rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-xl backdrop-blur-xs">
<div className="flex items-center gap-3 rounded-t-2xl border-b border-divider-subtle px-4 py-3">
<div
aria-hidden="true"
className="i-custom-public-other-message-3-fill size-6 shrink-0"
/>
- <DialogTitle
- // oxlint-disable-next-line shadcn/no-restyle -- Title shares the mobile sheet header row with its icon.
- className="grow"
- >
- {t(($) => $['chat.chatSettingsTitle'], { ns: 'share' })}
- </DialogTitle>
+ <DialogTitle>{t(($) => $['chat.chatSettingsTitle'], { ns: 'share' })}</DialogTitle>
<DialogClose
render={
- <IconButton aria-label={t(($) => $['operation.close'], { ns: 'common' })}>
+ <IconButton
+ className="ms-auto"
+ aria-label={t(($) => $['operation.close'], { ns: 'common' })}
+ >
<span aria-hidden="true" className="i-ri-close-line size-4" />
</IconButton>
}
diff --git a/web/app/components/base/chat/chat-with-history/sidebar/rename-modal.tsx b/web/app/components/base/chat/chat-with-history/sidebar/rename-modal.tsx
index 1bb5abab7f8..4594398e330 100644
--- a/web/app/components/base/chat/chat-with-history/sidebar/rename-modal.tsx
+++ b/web/app/components/base/chat/chat-with-history/sidebar/rename-modal.tsx
@@ -37,6 +37,7 @@ const RenameModal: FC<IRenameModalProps> = ({ isShow, saveLoading, name, onClose
<DialogTitle>{t(($) => $['chat.renameConversation'], { ns: 'common' })}</DialogTitle>
</DialogHeader>
<Form
+ className="contents"
onFormSubmit={() => {
if (!saveLoading) onSave(tempName)
}}
diff --git a/web/app/components/base/chat/chat/answer/operation.tsx b/web/app/components/base/chat/chat/answer/operation.tsx
index fd0cd68860d..ed910d5032f 100644
--- a/web/app/components/base/chat/chat/answer/operation.tsx
+++ b/web/app/components/base/chat/chat/answer/operation.tsx
@@ -92,6 +92,7 @@ function FeedbackForm({ isSubmitting, onSubmit }: FeedbackFormProps) {
const feedbackTextareaId = useId()
return (
<form
+ className="contents"
onSubmit={(event) => {
event.preventDefault()
const content = new FormData(event.currentTarget).get('feedback-content')
diff --git a/web/app/components/base/encrypted-bottom/index.tsx b/web/app/components/base/encrypted-bottom/index.tsx
index 8e21de2876c..f1142553fa9 100644
--- a/web/app/components/base/encrypted-bottom/index.tsx
+++ b/web/app/components/base/encrypted-bottom/index.tsx
@@ -1,4 +1,3 @@
-import type { ReactNode } from 'react'
import { useTranslation } from 'react-i18next'
import Link from '@/next/link'
@@ -26,12 +25,3 @@ export const EncryptedBottom = ({ front, back }: EncryptedBottomProps) => {
</p>
)
}
-
-type EncryptedFooterProps = Readonly<{
- children: ReactNode
-}>
-
-// Keeps the notice pinned under the actions while the dialog body scrolls.
-export const EncryptedFooter = ({ children }: EncryptedFooterProps) => (
- <div className="sticky bottom-0 bg-components-panel-bg">{children}</div>
-)
diff --git a/web/app/components/base/features/new-feature-panel/annotation-reply/config-param-modal.tsx b/web/app/components/base/features/new-feature-panel/annotation-reply/config-param-modal.tsx
index f4c00a1fb3c..d6e6c382d81 100644
--- a/web/app/components/base/features/new-feature-panel/annotation-reply/config-param-modal.tsx
+++ b/web/app/components/base/features/new-feature-panel/annotation-reply/config-param-modal.tsx
@@ -92,7 +92,7 @@ const ConfigParamModal: FC<Props> = ({
if (!open) onHide()
}}
>
- <DialogContent className="w-160 max-w-none">
+ <DialogContent className="w-160">
<DialogHeader>
<DialogTitle>
{t(($) => $[`initSetup.${isInit ? 'title' : 'configTitle'}`], { ns: 'appAnnotation' })}
diff --git a/web/app/components/base/features/new-feature-panel/conversation-opener/modal.tsx b/web/app/components/base/features/new-feature-panel/conversation-opener/modal.tsx
index 6213050c094..4a555edfb0a 100644
--- a/web/app/components/base/features/new-feature-panel/conversation-opener/modal.tsx
+++ b/web/app/components/base/features/new-feature-panel/conversation-opener/modal.tsx
@@ -274,7 +274,7 @@ const OpeningSettingModal = ({
return (
<Dialog open onOpenChange={(open) => !open && onCancel()} disablePointerDismissal>
- <DialogContent className="w-160 max-w-none">
+ <DialogContent className="w-160">
<DialogHeader>
<DialogTitle>
{t(($) => $['feature.conversationOpener.title'], { ns: 'appDebug' })}
diff --git a/web/app/components/base/features/new-feature-panel/follow-up-setting-modal.tsx b/web/app/components/base/features/new-feature-panel/follow-up-setting-modal.tsx
index cefeab65c51..0b56afedb9f 100644
--- a/web/app/components/base/features/new-feature-panel/follow-up-setting-modal.tsx
+++ b/web/app/components/base/features/new-feature-panel/follow-up-setting-modal.tsx
@@ -88,7 +88,7 @@ export function FollowUpSettingsDialog({ data, onSave, disabled }: FollowUpSetti
{t(($) => $['operation.settings'], { ns: 'common' })}
</DialogTrigger>
</div>
- <DialogContent className="w-160 max-w-none">
+ <DialogContent className="w-160">
<FollowUpSettingsForm
data={data}
onSave={(value) => {
@@ -160,6 +160,7 @@ function FollowUpSettingsForm({ data, onSave }: Omit<FollowUpSettingsDialogProps
return (
<form
+ className="contents"
onSubmit={(event) => {
event.preventDefault()
if (!isCustomPromptInvalid) handleSave()
diff --git a/web/app/components/base/features/new-feature-panel/moderation/moderation-setting-modal.tsx b/web/app/components/base/features/new-feature-panel/moderation/moderation-setting-modal.tsx
index c0906239013..b719d1339fb 100644
--- a/web/app/components/base/features/new-feature-panel/moderation/moderation-setting-modal.tsx
+++ b/web/app/components/base/features/new-feature-panel/moderation/moderation-setting-modal.tsx
@@ -317,8 +317,9 @@ const ModerationSettingModal: FC<ModerationSettingModalProps> = ({ data, onCance
return (
<Dialog open onOpenChange={(open) => !open && onCancel()} disablePointerDismissal>
- <DialogContent className="w-150 max-w-none">
+ <DialogContent className="w-150">
<form
+ className="contents"
onSubmit={(event) => {
// Portalled child forms still bubble submit events through the React tree.
if (event.target !== event.currentTarget) return
diff --git a/web/app/components/base/file-uploader/file-preview-content.tsx b/web/app/components/base/file-uploader/file-preview-content.tsx
index 7aedc10483a..636019a43a3 100644
--- a/web/app/components/base/file-uploader/file-preview-content.tsx
+++ b/web/app/components/base/file-uploader/file-preview-content.tsx
@@ -51,7 +51,7 @@ function FilePreviewPopup({ file, kind }: FilePreviewContentProps) {
ref={popupRef}
initialFocus={closeRef}
className={cn(
- 'fixed inset-0 flex h-dvh w-screen items-center justify-center overflow-hidden rounded-none border-none bg-black/80 p-8 shadow-none',
+ 'fixed inset-0 flex h-dvh w-screen items-center justify-center overflow-hidden bg-black/80 p-8',
kind === 'pdf' && 'max-sm:p-0',
)}
>
diff --git a/web/app/components/base/icon-picker/index.tsx b/web/app/components/base/icon-picker/index.tsx
index d74f0c82863..c4706d57b65 100644
--- a/web/app/components/base/icon-picker/index.tsx
+++ b/web/app/components/base/icon-picker/index.tsx
@@ -111,7 +111,7 @@ export function IconPickerContent({ enableImageUpload }: IconPickerContentProps)
initialFocus={(interaction) =>
interaction === 'touch' ? popupRef.current : (focusTargetRef.current ?? true)
}
- className="flex max-h-[calc(100dvh-2rem)] w-80.5 flex-col overflow-hidden"
+ className="w-80.5 overflow-hidden"
>
<DialogTitle className="sr-only">
{t(($) => $['iconPicker.title'], { ns: 'app' })}
diff --git a/web/app/components/base/image-uploader/image-preview.tsx b/web/app/components/base/image-uploader/image-preview.tsx
index f4dc00a6313..52a1e19690a 100644
--- a/web/app/components/base/image-uploader/image-preview.tsx
+++ b/web/app/components/base/image-uploader/image-preview.tsx
@@ -210,7 +210,7 @@ function ImagePreviewContent({ url, title, onCancel, onPrev, onNext }: ImagePrev
<DialogPopup
ref={previewRef}
aria-label={title.trim() || t(($) => $['common.preview'], { ns: 'workflow' })}
- className="image-preview-container fixed inset-0! top-0! left-0! flex h-dvh! max-h-none! w-screen! max-w-none! translate-0! items-center justify-center overflow-hidden! rounded-none! border-none! bg-black/80 p-8! shadow-none!"
+ className="image-preview-container fixed inset-0 flex h-dvh w-screen items-center justify-center overflow-hidden bg-black/80 p-8"
>
<div
data-testid="image-preview-container"
diff --git a/web/app/components/base/message-log-modal/index.tsx b/web/app/components/base/message-log-modal/index.tsx
index e81bb66b151..9f0b529c505 100644
--- a/web/app/components/base/message-log-modal/index.tsx
+++ b/web/app/components/base/message-log-modal/index.tsx
@@ -46,12 +46,9 @@ const MessageLogModal: FC<MessageLogModalProps> = ({
const activeTab = isRunActiveTab(defaultTab) ? defaultTab : 'DETAIL'
const modalContent = (
<>
- <DialogTitle
- // oxlint-disable-next-line shadcn/no-restyle -- Side panel keeps its compact header row.
- className="shrink-0 px-4 py-1"
- >
- {t(($) => $['runDetail.title'], { ns: 'appLog' })}
- </DialogTitle>
+ <div className="shrink-0 px-4 py-1">
+ <DialogTitle>{t(($) => $['runDetail.title'], { ns: 'appLog' })}</DialogTitle>
+ </div>
<button
type="button"
aria-label={t(($) => $['operation.close'], { ns: 'common' })}
@@ -79,7 +76,7 @@ const MessageLogModal: FC<MessageLogModalProps> = ({
>
<DialogPortal>
<DialogBackdrop className="bg-transparent" />
- <DialogPopup className="fixed top-16 bottom-4 left-[max(8px,calc(100vw-1136px))] flex w-120 max-w-[calc(100vw-16px)] flex-col overflow-hidden overscroll-contain rounded-xl pt-3">
+ <DialogPopup className="fixed top-16 bottom-4 left-[max(8px,calc(100vw-1136px))] flex w-120 max-w-[calc(100vw-16px)] flex-col overflow-hidden overscroll-contain rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg pt-3 shadow-xl">
{modalContent}
</DialogPopup>
</DialogPortal>
diff --git a/web/app/components/base/prompt-editor/plugins/hitl-input-block/component-ui.tsx b/web/app/components/base/prompt-editor/plugins/hitl-input-block/component-ui.tsx
index 8527873a06a..86b76af5f88 100644
--- a/web/app/components/base/prompt-editor/plugins/hitl-input-block/component-ui.tsx
+++ b/web/app/components/base/prompt-editor/plugins/hitl-input-block/component-ui.tsx
@@ -189,7 +189,7 @@ const HITLInputComponentUI: FC<HITLInputComponentUIProps> = ({
if (!open) hideEditModal()
}}
>
- <DialogContent className="w-full max-w-93 overflow-hidden">
+ <DialogContent className="w-93">
<InputField
nodeId={nodeId}
isEdit
diff --git a/web/app/components/billing/annotation-full/modal.tsx b/web/app/components/billing/annotation-full/modal.tsx
index 7643e3eb9fb..4b72bab0d4b 100644
--- a/web/app/components/billing/annotation-full/modal.tsx
+++ b/web/app/components/billing/annotation-full/modal.tsx
@@ -24,7 +24,7 @@ const AnnotationFullModal: FC<Props> = ({ show, onHide }) => {
if (!open) onHide()
}}
>
- <DialogContent className="w-full overflow-hidden">
+ <DialogContent className="w-full">
<DialogClose
render={
<IconButton
diff --git a/web/app/components/billing/pricing/dialog-content.tsx b/web/app/components/billing/pricing/dialog-content.tsx
index 435b08d966c..969155cc589 100644
--- a/web/app/components/billing/pricing/dialog-content.tsx
+++ b/web/app/components/billing/pricing/dialog-content.tsx
@@ -20,7 +20,7 @@ export function PricingDialogContent() {
return (
<>
<DialogBackdrop className="transition-none" />
- <DialogPopup className="fixed inset-0 size-full max-h-none max-w-none overflow-hidden rounded-none border-none bg-saas-background p-0 shadow-none transition-none data-ending-style:scale-100 data-ending-style:opacity-100 data-starting-style:scale-100 data-starting-style:opacity-100">
+ <DialogPopup className="fixed inset-0 size-full overflow-hidden bg-saas-background transition-none data-ending-style:scale-100 data-ending-style:opacity-100 data-starting-style:scale-100 data-starting-style:opacity-100">
<DialogClose
render={
<IconButton
diff --git a/web/app/components/datasets/common/image-previewer/index.tsx b/web/app/components/datasets/common/image-previewer/index.tsx
index bcc468be1c6..8d8dd5f92b7 100644
--- a/web/app/components/datasets/common/image-previewer/index.tsx
+++ b/web/app/components/datasets/common/image-previewer/index.tsx
@@ -160,7 +160,7 @@ function ImagePreviewerContent({ images, initialIndex = 0, onClose }: ImagePrevi
<DialogPopup
ref={previewRef}
aria-label={currentImage!.name.trim() || t(($) => $['common.preview'], { ns: 'workflow' })}
- className="image-previewer fixed inset-0! top-0! left-0! flex h-dvh! max-h-none! w-screen! max-w-none! translate-x-0! translate-y-0! items-center justify-center overflow-hidden! rounded-none! border-none! bg-background-overlay-fullscreen p-5! pb-4! shadow-none! backdrop-blur-[6px]"
+ className="image-previewer fixed inset-0 flex h-dvh w-screen items-center justify-center overflow-hidden bg-background-overlay-fullscreen p-5 pb-4 backdrop-blur-[6px]"
>
<div className="absolute top-6 right-6 z-10 flex cursor-pointer flex-col items-center gap-y-1">
<IconButton
diff --git a/web/app/components/datasets/create-from-pipeline/create-options/create-from-dsl-modal/dsl-confirm-modal.tsx b/web/app/components/datasets/create-from-pipeline/create-options/create-from-dsl-modal/dsl-confirm-modal.tsx
index 63816312b4b..408d518b4ed 100644
--- a/web/app/components/datasets/create-from-pipeline/create-options/create-from-dsl-modal/dsl-confirm-modal.tsx
+++ b/web/app/components/datasets/create-from-pipeline/create-options/create-from-dsl-modal/dsl-confirm-modal.tsx
@@ -57,7 +57,7 @@ const DSLConfirmModal = ({
<AlertDialogCancelButton>
{t(($) => $['newApp.Cancel'], { ns: 'app' })}
</AlertDialogCancelButton>
- <AlertDialogConfirmButton onClick={onConfirm} disabled={confirmDisabled}>
+ <AlertDialogConfirmButton tone="default" onClick={onConfirm} disabled={confirmDisabled}>
{t(($) => $['newApp.Confirm'], { ns: 'app' })}
</AlertDialogConfirmButton>
</AlertDialogFooter>
diff --git a/web/app/components/datasets/create-from-pipeline/create-options/create-from-dsl-modal/index.tsx b/web/app/components/datasets/create-from-pipeline/create-options/create-from-dsl-modal/index.tsx
index 5d073fe00e1..a57429c26f4 100644
--- a/web/app/components/datasets/create-from-pipeline/create-options/create-from-dsl-modal/index.tsx
+++ b/web/app/components/datasets/create-from-pipeline/create-options/create-from-dsl-modal/index.tsx
@@ -66,18 +66,20 @@ const CreateFromDSLModal = ({
<DialogCloseButton aria-label={t(($) => $['operation.close'], { ns: 'common' })} />
</DialogHeader>
<form
+ className="contents"
onSubmit={(event) => {
event.preventDefault()
handleCreateApp()
}}
>
<Tabs
+ className="contents"
value={currentTab}
onValueChange={(value) => {
if (value !== null) setCurrentTab(value as CreateFromDSLModalTab)
}}
>
- <TabsList className="h-9 gap-6 border-b border-divider-subtle px-6">
+ <TabsList className="h-9 shrink-0 gap-6 border-b border-divider-subtle px-6">
<TabsTab value={CreateFromDSLModalTab.FROM_FILE} className="h-full py-0">
{t(($) => $.importFromDSLFile, { ns: 'app' })}
</TabsTab>
diff --git a/web/app/components/datasets/create-from-pipeline/list/template-card/edit-pipeline-info.tsx b/web/app/components/datasets/create-from-pipeline/list/template-card/edit-pipeline-info.tsx
index d9c0baceddd..9ef50f09cf0 100644
--- a/web/app/components/datasets/create-from-pipeline/list/template-card/edit-pipeline-info.tsx
+++ b/web/app/components/datasets/create-from-pipeline/list/template-card/edit-pipeline-info.tsx
@@ -94,6 +94,7 @@ const EditPipelineInfo = ({ onClose, pipeline }: EditPipelineInfoProps) => {
return (
<form
+ className="contents"
onSubmit={(event) => {
event.preventDefault()
void handleSave()
diff --git a/web/app/components/datasets/create/empty-dataset-creation-modal/index.tsx b/web/app/components/datasets/create/empty-dataset-creation-modal/index.tsx
index f2e9099bbdd..550032351c3 100644
--- a/web/app/components/datasets/create/empty-dataset-creation-modal/index.tsx
+++ b/web/app/components/datasets/create/empty-dataset-creation-modal/index.tsx
@@ -79,7 +79,7 @@ const EmptyDatasetCreationModal = ({ show = false, onHide }: IProps) => {
</DialogDescription>
<DialogCloseButton aria-label={t(($) => $['operation.close'], { ns: 'common' })} />
</DialogHeader>
- <Form onFormSubmit={() => void submit()}>
+ <Form className="contents" onFormSubmit={() => void submit()}>
<DialogBody>
<Field name="datasetName">
<FieldLabel className={s.label}>
diff --git a/web/app/components/datasets/documents/components/rename-modal.tsx b/web/app/components/datasets/documents/components/rename-modal.tsx
index 455c8a23afc..87e2bc8d25c 100644
--- a/web/app/components/datasets/documents/components/rename-modal.tsx
+++ b/web/app/components/datasets/documents/components/rename-modal.tsx
@@ -64,7 +64,7 @@ const RenameModal: FC<Props> = ({ documentId, datasetId, name, onClose, onSaved
<DialogHeader>
<DialogTitle>{t(($) => $['list.table.rename'], { ns: 'datasetDocuments' })}</DialogTitle>
</DialogHeader>
- <Form onFormSubmit={() => void handleSave()}>
+ <Form className="contents" onFormSubmit={() => void handleSave()}>
<DialogBody>
<Field name="documentName">
<FieldLabel className="text-sm leading-5.25 font-medium text-text-primary">
diff --git a/web/app/components/datasets/external-api/external-api-modal/index.tsx b/web/app/components/datasets/external-api/external-api-modal/index.tsx
index f79fbb4cde0..c7030acbc07 100644
--- a/web/app/components/datasets/external-api/external-api-modal/index.tsx
+++ b/web/app/components/datasets/external-api/external-api-modal/index.tsx
@@ -25,7 +25,7 @@ import { Popover, PopoverContent, PopoverTrigger } from '@langgenius/dify-ui/pop
import { RiBook2Line, RiInformation2Line } from '@remixicon/react'
import { memo, useId, useState } from 'react'
import { useTranslation } from 'react-i18next'
-import { EncryptedBottom, EncryptedFooter } from '@/app/components/base/encrypted-bottom'
+import { EncryptedBottom } from '@/app/components/base/encrypted-bottom'
import { toast } from '@/app/notifications'
import { createExternalAPI } from '@/service/datasets'
import Form from './Form'
@@ -145,7 +145,7 @@ const AddExternalAPIModal: FC<AddExternalAPIModalProps> = ({
if (!open) onCancel()
}}
>
- <DialogContent className="max-h-[calc(100dvh-2rem)] max-w-none">
+ <DialogContent>
<DialogHeader>
<DialogTitle>
{isEditMode
@@ -210,26 +210,24 @@ const AddExternalAPIModal: FC<AddExternalAPIModalProps> = ({
formSchemas={formSchemas}
/>
</DialogBody>
- <EncryptedFooter>
- <DialogFooter>
- <Button type="button" variant="secondary" onClick={onCancel}>
- {t(($) => $['externalAPIForm.cancel'], { ns: 'dataset' })}
- </Button>
- <Button
- form={formId}
- type="submit"
- variant="primary"
- loading={loading}
- disabled={hasEmptyInputs}
- >
- {t(($) => $['externalAPIForm.save'], { ns: 'dataset' })}
- </Button>
- </DialogFooter>
- <EncryptedBottom
- front={t(($) => $['externalAPIForm.encrypted.front'], { ns: 'dataset' })}
- back={t(($) => $['externalAPIForm.encrypted.end'], { ns: 'dataset' })}
- />
- </EncryptedFooter>
+ <DialogFooter>
+ <Button type="button" variant="secondary" onClick={onCancel}>
+ {t(($) => $['externalAPIForm.cancel'], { ns: 'dataset' })}
+ </Button>
+ <Button
+ form={formId}
+ type="submit"
+ variant="primary"
+ loading={loading}
+ disabled={hasEmptyInputs}
+ >
+ {t(($) => $['externalAPIForm.save'], { ns: 'dataset' })}
+ </Button>
+ </DialogFooter>
+ <EncryptedBottom
+ front={t(($) => $['externalAPIForm.encrypted.front'], { ns: 'dataset' })}
+ back={t(($) => $['externalAPIForm.encrypted.end'], { ns: 'dataset' })}
+ />
<AlertDialog
open={showConfirm && (datasetBindings?.length ?? 0) > 0}
onOpenChange={(open) => !open && setShowConfirm(false)}
diff --git a/web/app/components/datasets/hit-testing/components/result-item-external.tsx b/web/app/components/datasets/hit-testing/components/result-item-external.tsx
index 94577c4e714..6c50a6a13ee 100644
--- a/web/app/components/datasets/hit-testing/components/result-item-external.tsx
+++ b/web/app/components/datasets/hit-testing/components/result-item-external.tsx
@@ -50,7 +50,7 @@ export const ResultItemExternal = memo(({ payload, positionId }: ResultItemExter
</span>
<ResultItemFooter docType={FileAppearanceTypeEnum.custom} docTitle={title} />
</DialogTrigger>
- <DialogContent className="max-h-[calc(100dvh-2rem)] w-full min-w-0">
+ <DialogContent className="w-full">
<DialogHeader>
<DialogTitle>{t(($) => $.chunkDetail, { ns: 'datasetHitTesting' })}</DialogTitle>
<DialogCloseButton aria-label={t(($) => $['operation.close'], { ns: 'common' })} />
diff --git a/web/app/components/datasets/rename-modal/index.tsx b/web/app/components/datasets/rename-modal/index.tsx
index 0bde6b408b5..63dae8e74ab 100644
--- a/web/app/components/datasets/rename-modal/index.tsx
+++ b/web/app/components/datasets/rename-modal/index.tsx
@@ -109,6 +109,7 @@ const RenameDatasetModal = ({ show, dataset, onSuccess, onClose }: RenameDataset
>
<DialogContent className="w-130">
<form
+ className="contents"
onSubmit={(event) => {
event.preventDefault()
onConfirm()
diff --git a/web/app/components/goto-anything/index.tsx b/web/app/components/goto-anything/index.tsx
index 59124eb043c..043552bc0f0 100644
--- a/web/app/components/goto-anything/index.tsx
+++ b/web/app/components/goto-anything/index.tsx
@@ -430,10 +430,7 @@ export function GotoAnything() {
handle={gotoAnythingDialogHandle}
onOpenChangeComplete={handleDialogOpenChangeComplete}
>
- <DialogContent
- initialFocus={inputRef}
- className="flex max-h-[calc(100dvh-2rem)] w-160 flex-col overflow-hidden"
- >
+ <DialogContent initialFocus={inputRef} className="w-160">
<div
aria-hidden
className="pointer-events-none absolute inset-x-0 top-0 h-64 bg-[url('/marketplace/hero-gradient-noise.svg')] bg-cover bg-center opacity-18 dark:opacity-28"
diff --git a/web/app/components/header/account-setting/access-rules-page/permission-set-modal/index.tsx b/web/app/components/header/account-setting/access-rules-page/permission-set-modal/index.tsx
index dbc2232ec5d..b33a7cb5c4f 100644
--- a/web/app/components/header/account-setting/access-rules-page/permission-set-modal/index.tsx
+++ b/web/app/components/header/account-setting/access-rules-page/permission-set-modal/index.tsx
@@ -80,7 +80,7 @@ const PermissionSetModalBody = ({
}
return (
- <DialogContent className="flex h-[85vh] w-140 flex-col" backdropProps={{ forceRender: true }}>
+ <DialogContent className="h-[85vh] w-140" backdropProps={{ forceRender: true }}>
<form
className="contents"
onSubmit={(event) => {
@@ -102,7 +102,7 @@ const PermissionSetModalBody = ({
<DialogCloseButton aria-label={t(($) => $['operation.close'], { ns: 'common' })} />
</DialogHeader>
- <DialogBody className="flex min-h-0 flex-1 flex-col gap-5 overflow-y-hidden">
+ <DialogBody className="flex flex-col gap-5">
<div className="flex shrink-0 flex-col gap-1">
<label htmlFor="permission-set-name" className="system-sm-medium text-text-secondary">
{t(($) => $['permissionSet.nameLabel'], { ns: 'permission' })}
diff --git a/web/app/components/header/account-setting/api-based-extension-page/modal.tsx b/web/app/components/header/account-setting/api-based-extension-page/modal.tsx
index 01c56e54451..5e56c35e7ca 100644
--- a/web/app/components/header/account-setting/api-based-extension-page/modal.tsx
+++ b/web/app/components/header/account-setting/api-based-extension-page/modal.tsx
@@ -102,7 +102,7 @@ export function ApiBasedExtensionModal(props: ApiBasedExtensionModalProps) {
</DialogTitle>
<DialogCloseButton aria-label={t(($) => $['operation.close'], { ns: 'common' })} />
</DialogHeader>
- <Form<ApiBasedExtensionPayload> onFormSubmit={handleSubmit}>
+ <Form<ApiBasedExtensionPayload> className="contents" onFormSubmit={handleSubmit}>
<DialogBody className="grid gap-4">
<Field name="name">
<FieldLabel>{nameLabel}</FieldLabel>
diff --git a/web/app/components/header/account-setting/members-page/assign-roles-modal/index.tsx b/web/app/components/header/account-setting/members-page/assign-roles-modal/index.tsx
index fc1f3b260e6..0f1c643f90d 100644
--- a/web/app/components/header/account-setting/members-page/assign-roles-modal/index.tsx
+++ b/web/app/components/header/account-setting/members-page/assign-roles-modal/index.tsx
@@ -56,7 +56,7 @@ const AssignRolesModalBody = ({
}
return (
- <DialogContent className="flex h-121 flex-col" backdropProps={{ forceRender: true }}>
+ <DialogContent className="h-121" backdropProps={{ forceRender: true }}>
<DialogHeader>
<DialogTitle>{title}</DialogTitle>
<DialogDescription>{description}</DialogDescription>
diff --git a/web/app/components/header/account-setting/members-page/edit-workspace-modal/index.tsx b/web/app/components/header/account-setting/members-page/edit-workspace-modal/index.tsx
index 956146399f0..ec492c268e5 100644
--- a/web/app/components/header/account-setting/members-page/edit-workspace-modal/index.tsx
+++ b/web/app/components/header/account-setting/members-page/edit-workspace-modal/index.tsx
@@ -66,6 +66,7 @@ const EditWorkspaceModal = ({ onCancel }: IEditWorkspaceModalProps) => {
>
<DialogContent backdropProps={{ forceRender: true }}>
<form
+ className="contents"
onSubmit={(e) => {
e.preventDefault()
void changeWorkspaceInfo()
diff --git a/web/app/components/header/account-setting/members-page/invite-modal/index.tsx b/web/app/components/header/account-setting/members-page/invite-modal/index.tsx
index 09b9a9ef549..51039897e79 100644
--- a/web/app/components/header/account-setting/members-page/invite-modal/index.tsx
+++ b/web/app/components/header/account-setting/members-page/invite-modal/index.tsx
@@ -107,6 +107,7 @@ function InviteForm({
return (
<Form<InviteFormValues>
+ className="contents"
ref={ref}
aria-label={t(($) => $['members.inviteTeamMember'], { ns: 'workspaceMembers' })}
errors={fieldErrors}
diff --git a/web/app/components/header/account-setting/members-page/member-details-modal/index.tsx b/web/app/components/header/account-setting/members-page/member-details-modal/index.tsx
index 2d0414f6569..f1990063543 100644
--- a/web/app/components/header/account-setting/members-page/member-details-modal/index.tsx
+++ b/web/app/components/header/account-setting/members-page/member-details-modal/index.tsx
@@ -119,11 +119,7 @@ const MemberDetailsModal = ({
if (!next) onClose()
}}
>
- <DialogContent
- // oxlint-disable-next-line shadcn/no-restyle -- Keeps content that reaches past the edge unclipped, as before.
- className="w-110 overflow-visible"
- backdropProps={{ forceRender: true }}
- >
+ <DialogContent className="w-110" backdropProps={{ forceRender: true }}>
<DialogHeader>
<DialogTitle>
{t(($) => $['members.memberDetails.title'], {
@@ -143,11 +139,9 @@ const MemberDetailsModal = ({
<div className="truncate system-md-semibold text-text-primary">{member.name}</div>
<div className="truncate system-xs-regular text-text-tertiary">{member.email}</div>
</div>
- </DialogBody>
- <div className="border-t border-divider-subtle" />
+ <div className="-mx-6 my-3 border-t border-divider-subtle" />
- <DialogBody>
<div className="flex items-center justify-between">
<div className="flex items-center gap-1.5 system-sm-semibold text-text-secondary">
<span>{assignedRolesLabel}</span>
diff --git a/web/app/components/header/account-setting/members-page/transfer-ownership-modal/index.tsx b/web/app/components/header/account-setting/members-page/transfer-ownership-modal/index.tsx
index e2b3a6f20ed..0bf919cfca9 100644
--- a/web/app/components/header/account-setting/members-page/transfer-ownership-modal/index.tsx
+++ b/web/app/components/header/account-setting/members-page/transfer-ownership-modal/index.tsx
@@ -158,12 +158,10 @@ const TransferOwnershipModal = ({ onClose, show }: Props) => {
</div>
</DialogBody>
<DialogFooter className="flex-col items-stretch">
- <Button className="w-full!" variant="primary" onClick={sendCodeToOriginEmail}>
+ <Button variant="primary" onClick={sendCodeToOriginEmail}>
{t(($) => $['members.transferModal.sendVerifyCode'], { ns: 'workspaceMembers' })}
</Button>
- <Button className="w-full!" onClick={onClose}>
- {t(($) => $['operation.cancel'], { ns: 'common' })}
- </Button>
+ <Button onClick={onClose}>{t(($) => $['operation.cancel'], { ns: 'common' })}</Button>
</DialogFooter>
</>
)}
@@ -216,15 +214,12 @@ const TransferOwnershipModal = ({ onClose, show }: Props) => {
<DialogFooter className="flex-col items-stretch">
<Button
disabled={code.length !== 6}
- className="w-full!"
variant="primary"
onClick={handleVerifyOriginEmail}
>
{t(($) => $['members.transferModal.continue'], { ns: 'workspaceMembers' })}
</Button>
- <Button className="w-full!" onClick={onClose}>
- {t(($) => $['operation.cancel'], { ns: 'common' })}
- </Button>
+ <Button onClick={onClose}>{t(($) => $['operation.cancel'], { ns: 'common' })}</Button>
<div className="flex items-center gap-1 system-xs-regular text-text-tertiary">
<span>
{t(($) => $['members.transferModal.resendTip'], { ns: 'workspaceMembers' })}
@@ -284,16 +279,13 @@ const TransferOwnershipModal = ({ onClose, show }: Props) => {
<DialogFooter className="flex-col items-stretch">
<Button
disabled={!newOwner || isTransfer}
- className="w-full!"
variant="primary"
tone="destructive"
onClick={handleTransfer}
>
{t(($) => $['members.transferModal.transfer'], { ns: 'workspaceMembers' })}
</Button>
- <Button className="w-full!" onClick={onClose}>
- {t(($) => $['operation.cancel'], { ns: 'common' })}
- </Button>
+ <Button onClick={onClose}>{t(($) => $['operation.cancel'], { ns: 'common' })}</Button>
</DialogFooter>
</>
)}
diff --git a/web/app/components/header/account-setting/menu-dialog.tsx b/web/app/components/header/account-setting/menu-dialog.tsx
index 7449eb3bacd..372ee73b315 100644
--- a/web/app/components/header/account-setting/menu-dialog.tsx
+++ b/web/app/components/header/account-setting/menu-dialog.tsx
@@ -30,7 +30,7 @@ const MenuDialog = ({ children, title, onClose }: MenuDialogProps) => {
<DialogPortal>
<DialogBackdrop className="bg-transparent" />
<DialogViewport>
- <DialogPopup className="pointer-events-none relative isolate h-full w-full scale-100 overflow-visible rounded-none border-none bg-transparent shadow-none transition-opacity data-ending-style:scale-100 data-starting-style:scale-100">
+ <DialogPopup className="pointer-events-none isolate h-full w-full scale-100 transition-opacity data-ending-style:scale-100 data-starting-style:scale-100">
<DialogTitle className="sr-only">{title}</DialogTitle>
<div className="pointer-events-auto absolute top-6 right-6 z-10 flex shrink-0 flex-col items-center">
<DialogClose
diff --git a/web/app/components/header/account-setting/model-provider-page/model-modal/index.tsx b/web/app/components/header/account-setting/model-provider-page/model-modal/index.tsx
index 6ac568f5872..9d25891ed7e 100644
--- a/web/app/components/header/account-setting/model-provider-page/model-modal/index.tsx
+++ b/web/app/components/header/account-setting/model-provider-page/model-modal/index.tsx
@@ -29,7 +29,7 @@ import {
import { memo, useCallback, useMemo, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import Badge from '@/app/components/base/badge'
-import { EncryptedBottom, EncryptedFooter } from '@/app/components/base/encrypted-bottom'
+import { EncryptedBottom } from '@/app/components/base/encrypted-bottom'
import AuthForm from '@/app/components/base/form/form-scenarios/auth'
import { LoadingPlaceholder } from '@/app/components/base/loading-placeholder'
import {
@@ -314,7 +314,7 @@ const ModelModal: FC<ModelModalProps> = ({
return (
<Dialog open onOpenChange={handleOpenChange}>
- <DialogContent backdropProps={{ forceRender: true }} className="w-160 max-w-160">
+ <DialogContent backdropProps={{ forceRender: true }} className="w-160">
<DialogHeader>
{modalTitle}
{modalDesc}
@@ -382,52 +382,50 @@ const ModelModal: FC<ModelModalProps> = ({
/>
)}
</DialogBody>
- <EncryptedFooter>
- <DialogFooter>
- {provider.help && (provider.help.title || provider.help.url) && (
- <a
- href={provider.help?.url[language] || provider.help?.url.en_US}
- target="_blank"
- rel="noopener noreferrer"
- className="me-auto inline-block align-middle system-xs-regular text-text-accent"
- onClick={(e) => !provider.help?.url && e.preventDefault()}
- >
- {provider.help.title?.[language] ||
- provider.help.url[language] ||
- provider.help.title?.en_US ||
- provider.help.url.en_US}
- <span
- aria-hidden
- className="-mt-0.5 ml-1 i-custom-vender-line-general-link-external-02 inline-block h-3 w-3 align-middle"
- />
- </a>
- )}
- {isEditMode && (
- <Button
- variant="primary"
- tone="destructive"
- onClick={() => openConfirmDelete(credential, model)}
- >
- {t(($) => $['operation.remove'], { ns: 'common' })}
- </Button>
- )}
- <Button onClick={onCancel}>{t(($) => $['operation.cancel'], { ns: 'common' })}</Button>
+ <DialogFooter>
+ {provider.help && (provider.help.title || provider.help.url) && (
+ <a
+ href={provider.help?.url[language] || provider.help?.url.en_US}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="me-auto inline-block align-middle system-xs-regular text-text-accent"
+ onClick={(e) => !provider.help?.url && e.preventDefault()}
+ >
+ {provider.help.title?.[language] ||
+ provider.help.url[language] ||
+ provider.help.title?.en_US ||
+ provider.help.url.en_US}
+ <span
+ aria-hidden
+ className="-mt-0.5 ml-1 i-custom-vender-line-general-link-external-02 inline-block h-3 w-3 align-middle"
+ />
+ </a>
+ )}
+ {isEditMode && (
<Button
variant="primary"
- onClick={handleSave}
- disabled={isLoading || doingAction || !canSaveCredentialChange}
+ tone="destructive"
+ onClick={() => openConfirmDelete(credential, model)}
>
- {saveButtonText}
+ {t(($) => $['operation.remove'], { ns: 'common' })}
</Button>
- </DialogFooter>
- {(mode === ModelModalModeEnum.configCustomModel ||
- mode === ModelModalModeEnum.configProviderCredential) && (
- <EncryptedBottom
- front={t(($) => $['modelProvider.encrypted.front'], { ns: 'modelProvider' })}
- back={t(($) => $['modelProvider.encrypted.back'], { ns: 'modelProvider' })}
- />
)}
- </EncryptedFooter>
+ <Button onClick={onCancel}>{t(($) => $['operation.cancel'], { ns: 'common' })}</Button>
+ <Button
+ variant="primary"
+ onClick={handleSave}
+ disabled={isLoading || doingAction || !canSaveCredentialChange}
+ >
+ {saveButtonText}
+ </Button>
+ </DialogFooter>
+ {(mode === ModelModalModeEnum.configCustomModel ||
+ mode === ModelModalModeEnum.configProviderCredential) && (
+ <EncryptedBottom
+ front={t(($) => $['modelProvider.encrypted.front'], { ns: 'modelProvider' })}
+ back={t(($) => $['modelProvider.encrypted.back'], { ns: 'modelProvider' })}
+ />
+ )}
</DialogContent>
<AlertDialog open={!!deleteCredentialId} onOpenChange={handleConfirmOpenChange}>
<AlertDialogContent backdropProps={{ forceRender: true }}>
diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-list.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-list.tsx
index 92b8e2802f1..8fea0ff62f2 100644
--- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-list.tsx
+++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-list.tsx
@@ -28,7 +28,7 @@ const ModelLoadBalancingLoadingDialog = ({
return (
<Dialog open onOpenChange={(open) => !open && onClose?.()}>
- <DialogContent className="w-160 max-w-none">
+ <DialogContent className="w-160">
<DialogHeader>
<DialogTitle>
{t(($) => $['modelProvider.auth.configModel'], { ns: 'modelProvider' })}
diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal.tsx
index ed654331410..2014c38e953 100644
--- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal.tsx
+++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal.tsx
@@ -289,7 +289,7 @@ const ModelLoadBalancingModal = ({
if (!open) onClose?.()
}}
>
- <DialogContent className="w-160 max-w-none">
+ <DialogContent className="w-160">
<DialogHeader>
<DialogTitle>
{draftConfig?.enabled
diff --git a/web/app/components/header/account-setting/permissions-page/role-modal/index.tsx b/web/app/components/header/account-setting/permissions-page/role-modal/index.tsx
index 066ef7af69d..eed312e5e54 100644
--- a/web/app/components/header/account-setting/permissions-page/role-modal/index.tsx
+++ b/web/app/components/header/account-setting/permissions-page/role-modal/index.tsx
@@ -66,7 +66,7 @@ const RoleModal = ({ mode, open, role, onClose, onSubmit }: RoleModalProps) => {
if (!nextOpen) onClose()
}}
>
- <DialogContent className="flex h-[85vh] w-140 flex-col" backdropProps={{ forceRender: true }}>
+ <DialogContent className="h-[85vh] w-140" backdropProps={{ forceRender: true }}>
<DialogHeader>
<DialogTitle>{t(($) => $[`role.modal.${mode}.title`], { ns: 'permission' })}</DialogTitle>
<DialogDescription>
@@ -74,7 +74,7 @@ const RoleModal = ({ mode, open, role, onClose, onSubmit }: RoleModalProps) => {
</DialogDescription>
<DialogCloseButton aria-label={t(($) => $['operation.close'], { ns: 'common' })} />
</DialogHeader>
- <DialogBody className="flex min-h-0 flex-1 flex-col gap-5 overflow-y-hidden">
+ <DialogBody className="flex flex-col gap-5">
<div className="flex shrink-0 flex-col gap-1">
<label htmlFor="role-name" className="system-sm-medium text-text-secondary">
{t(($) => $['role.modal.nameLabel'], { ns: 'permission' })}
diff --git a/web/app/components/header/account-setting/resource-access-token-page/token-dialog.tsx b/web/app/components/header/account-setting/resource-access-token-page/token-dialog.tsx
index d916172b354..a9006a307e6 100644
--- a/web/app/components/header/account-setting/resource-access-token-page/token-dialog.tsx
+++ b/web/app/components/header/account-setting/resource-access-token-page/token-dialog.tsx
@@ -159,7 +159,7 @@ export default function ResourceAccessTokenDialog({
</DialogFooter>
</>
) : (
- <form onSubmit={handleSubmit}>
+ <form className="contents" onSubmit={handleSubmit}>
<DialogBody className="grid gap-5">
<Field name="name">
<FieldLabel>{nameLabel}</FieldLabel>
diff --git a/web/app/components/header/account-setting/workflow-log-archives-page/index.tsx b/web/app/components/header/account-setting/workflow-log-archives-page/index.tsx
index e7538a5e298..13b661723ac 100644
--- a/web/app/components/header/account-setting/workflow-log-archives-page/index.tsx
+++ b/web/app/components/header/account-setting/workflow-log-archives-page/index.tsx
@@ -7,6 +7,7 @@ import type {
} from '@dify/contracts/api/console/workflow-run-archives/types.gen'
import {
AlertDialog,
+ AlertDialogBody,
AlertDialogCancelButton,
AlertDialogConfirmButton,
AlertDialogContent,
@@ -531,12 +532,14 @@ function WorkflowArchiveMonthRow({ archive }: { archive: WorkflowRunArchiveMonth
<AlertDialogDescription>
{t(($) => $['archives.delete.description'], { ns: 'appLog' })}
</AlertDialogDescription>
- {deleteArchiveMutation.isError && (
+ </AlertDialogHeader>
+ {deleteArchiveMutation.isError && (
+ <AlertDialogBody>
<div role="alert" className="system-sm-regular text-text-destructive">
{t(($) => $['archives.delete.requestFailed'], { ns: 'appLog' })}
</div>
- )}
- </AlertDialogHeader>
+ </AlertDialogBody>
+ )}
<AlertDialogFooter>
<AlertDialogCancelButton disabled={deleteArchiveMutation.isPending}>
{t(($) => $['operation.cancel'], { ns: 'common' })}
diff --git a/web/app/components/plugins/install-plugin/install-from-github/index.tsx b/web/app/components/plugins/install-plugin/install-from-github/index.tsx
index 348d30bea6f..fb55a90ddf1 100644
--- a/web/app/components/plugins/install-plugin/install-from-github/index.tsx
+++ b/web/app/components/plugins/install-plugin/install-from-github/index.tsx
@@ -220,7 +220,7 @@ const InstallFromGitHub: React.FC<InstallFromGitHubProps> = ({
onCancel={onClose}
/>
) : state.step === InstallStepFromGitHub.setUrl ? (
- <Form onFormSubmit={handleUrlSubmit}>
+ <Form className="contents" onFormSubmit={handleUrlSubmit}>
<DialogBody>
<Field name="repoUrl" className="gap-4">
<FieldLabel className="flex w-full flex-col items-start justify-center p-0 text-text-secondary">
diff --git a/web/app/components/plugins/install-plugin/install-from-marketplace/index.tsx b/web/app/components/plugins/install-plugin/install-from-marketplace/index.tsx
index 76a913e2294..757e59b841b 100644
--- a/web/app/components/plugins/install-plugin/install-from-marketplace/index.tsx
+++ b/web/app/components/plugins/install-plugin/install-from-marketplace/index.tsx
@@ -87,14 +87,10 @@ const InstallFromMarketplace: React.FC<InstallFromMarketplaceProps> = ({
>
<DialogContent
backdropProps={{ forceRender: true }}
- className={cn(
- 'w-140 overflow-hidden',
- modalClassName,
- 'flex max-h-[calc(100dvh-48px)] flex-col items-start',
- )}
+ className={cn('max-h-[calc(100dvh-48px)] w-140', modalClassName)}
>
<div className="flex shrink-0 items-start gap-2 self-stretch pt-6 pr-14 pb-3 pl-6">
- <DialogTitle className="self-stretch">{getTitle()}</DialogTitle>
+ <DialogTitle>{getTitle()}</DialogTitle>
</div>
{isBundle ? (
<ReadyToInstallBundle
diff --git a/web/app/components/plugins/marketplace/detail-dialog/frame.tsx b/web/app/components/plugins/marketplace/detail-dialog/frame.tsx
index cf62ce30b91..03ed7e3244c 100644
--- a/web/app/components/plugins/marketplace/detail-dialog/frame.tsx
+++ b/web/app/components/plugins/marketplace/detail-dialog/frame.tsx
@@ -84,7 +84,7 @@ export default function MarketplaceDetailDialogFrame({
an invisible cross-origin frame. */}
<DialogContent
initialFocus={closeButtonRef}
- className="h-[min(800px,calc(100dvh-48px))] max-h-none w-[min(1200px,calc(100vw-48px))] overflow-hidden"
+ className="h-[min(800px,calc(100dvh-48px))] w-[min(1200px,calc(100vw-48px))] overflow-hidden"
>
<DialogTitle className="sr-only">{title}</DialogTitle>
<div
diff --git a/web/app/components/plugins/plugin-auth/authorize/api-key-modal.tsx b/web/app/components/plugins/plugin-auth/authorize/api-key-modal.tsx
index 45d2c9c903b..286d18053e3 100644
--- a/web/app/components/plugins/plugin-auth/authorize/api-key-modal.tsx
+++ b/web/app/components/plugins/plugin-auth/authorize/api-key-modal.tsx
@@ -14,7 +14,7 @@ import {
} from '@langgenius/dify-ui/dialog'
import { memo, useCallback, useMemo, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
-import { EncryptedBottom, EncryptedFooter } from '@/app/components/base/encrypted-bottom'
+import { EncryptedBottom } from '@/app/components/base/encrypted-bottom'
import AuthForm from '@/app/components/base/form/form-scenarios/auth'
import { FormTypeEnum } from '@/app/components/base/form/types'
import { LoadingPlaceholder } from '@/app/components/base/loading-placeholder'
@@ -193,25 +193,23 @@ const ApiKeyModal = ({
</div>
)}
</DialogBody>
- <EncryptedFooter>
- <DialogFooter>
- {editValues && (
- <>
- <Button variant="primary" onClick={onRemove} disabled={isDisabled}>
- {t(($) => $['operation.remove'], { ns: 'common' })}
- </Button>
- <div className="mx-1 h-4 w-px bg-divider-regular"></div>
- </>
- )}
- <Button onClick={() => handleOpenChange(false)} disabled={isDisabled}>
- {t(($) => $['operation.cancel'], { ns: 'common' })}
- </Button>
- <Button variant="primary" onClick={handleConfirm} disabled={isDisabled}>
- {t(($) => $['operation.save'], { ns: 'common' })}
- </Button>
- </DialogFooter>
- <EncryptedBottom />
- </EncryptedFooter>
+ <DialogFooter>
+ {editValues && (
+ <>
+ <Button variant="primary" onClick={onRemove} disabled={isDisabled}>
+ {t(($) => $['operation.remove'], { ns: 'common' })}
+ </Button>
+ <div className="mx-1 h-4 w-px bg-divider-regular"></div>
+ </>
+ )}
+ <Button onClick={() => handleOpenChange(false)} disabled={isDisabled}>
+ {t(($) => $['operation.cancel'], { ns: 'common' })}
+ </Button>
+ <Button variant="primary" onClick={handleConfirm} disabled={isDisabled}>
+ {t(($) => $['operation.save'], { ns: 'common' })}
+ </Button>
+ </DialogFooter>
+ <EncryptedBottom />
</DialogContent>
</Dialog>
)
diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/common-modal.tsx b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/common-modal.tsx
index c1537cc0cdf..93d4a856a1e 100644
--- a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/common-modal.tsx
+++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/common-modal.tsx
@@ -12,7 +12,7 @@ import {
DialogTitle,
} from '@langgenius/dify-ui/dialog'
import { useTranslation } from 'react-i18next'
-import { EncryptedBottom, EncryptedFooter } from '@/app/components/base/encrypted-bottom'
+import { EncryptedBottom } from '@/app/components/base/encrypted-bottom'
import { SupportedCreationMethods } from '@/app/components/plugins/types'
import { ConfigurationStepContent, MultiSteps, VerifyStepContent } from './components/modal-steps'
import {
@@ -111,22 +111,20 @@ function CommonCreateModalContent({ onClose, createType, builder }: Omit<Props,
)}
</DialogBody>
- <EncryptedFooter>
- <DialogFooter>
- <Button disabled={isDisabled} onClick={onClose}>
- {t(($) => $['operation.cancel'], { ns: 'common' })}
- </Button>
- <Button
- variant="primary"
- disabled={isDisabled}
- data-testid="modal-confirm"
- onClick={handleConfirm}
- >
- {confirmButtonText}
- </Button>
- </DialogFooter>
- {isVerifyStep && <EncryptedBottom />}
- </EncryptedFooter>
+ <DialogFooter>
+ <Button disabled={isDisabled} onClick={onClose}>
+ {t(($) => $['operation.cancel'], { ns: 'common' })}
+ </Button>
+ <Button
+ variant="primary"
+ disabled={isDisabled}
+ data-testid="modal-confirm"
+ onClick={handleConfirm}
+ >
+ {confirmButtonText}
+ </Button>
+ </DialogFooter>
+ {isVerifyStep && <EncryptedBottom />}
</>
)
}
diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/delete-confirm.tsx b/web/app/components/plugins/plugin-detail-panel/subscription-list/delete-confirm.tsx
index 66dd6b0a277..0ea94f92e01 100644
--- a/web/app/components/plugins/plugin-detail-panel/subscription-list/delete-confirm.tsx
+++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/delete-confirm.tsx
@@ -1,5 +1,6 @@
import {
AlertDialog,
+ AlertDialogBody,
AlertDialogCancelButton,
AlertDialogConfirmButton,
AlertDialogContent,
@@ -65,6 +66,7 @@ export const DeleteConfirm = (props: Props) => {
<AlertDialog open={isShow} onOpenChange={handleOpenChange}>
<AlertDialogContent backdropProps={{ forceRender: true }}>
<form
+ className="contents"
onSubmit={(event) => {
event.preventDefault()
onConfirm()
@@ -82,7 +84,9 @@ export const DeleteConfirm = (props: Props) => {
})
: t(($) => $[`${tPrefix}.content`], { ns: 'pluginTrigger' })}
</AlertDialogDescription>
- {workflowsInUse > 0 && (
+ </AlertDialogHeader>
+ {workflowsInUse > 0 && (
+ <AlertDialogBody>
<Field name="confirmation">
<FieldLabel>
{t(($) => $[`${tPrefix}.confirmInputTip`], {
@@ -99,8 +103,8 @@ export const DeleteConfirm = (props: Props) => {
})}
/>
</Field>
- )}
- </AlertDialogHeader>
+ </AlertDialogBody>
+ )}
<AlertDialogFooter>
<AlertDialogCancelButton disabled={isDeleting}>
{t(($) => $['operation.cancel'], { ns: 'common' })}
diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/apikey-edit-modal.tsx b/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/apikey-edit-modal.tsx
index 5b78e1cce7e..bbe5f309a31 100644
--- a/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/apikey-edit-modal.tsx
+++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/edit/apikey-edit-modal.tsx
@@ -15,7 +15,7 @@ import {
import { isEqual } from 'es-toolkit/predicate'
import { useMemo, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
-import { EncryptedBottom, EncryptedFooter } from '@/app/components/base/encrypted-bottom'
+import { EncryptedBottom } from '@/app/components/base/encrypted-bottom'
import { BaseForm } from '@/app/components/base/form/components/base'
import { FormTypeEnum } from '@/app/components/base/form/types'
import { ReadmeEntrance } from '@/app/components/plugins/readme-panel/entrance'
@@ -372,25 +372,23 @@ export const ApiKeyEditModal = ({ onClose, subscription, pluginDetail }: Props)
</div>
)}
</DialogBody>
- <EncryptedFooter>
- <DialogFooter>
- {currentStep === EditStep.EditConfiguration && (
- <>
- <Button variant="secondary" onClick={handleBack} disabled={isDisabled}>
- {t(($) => $['modal.common.back'], { ns: 'pluginTrigger' })}
- </Button>
- <div className="mx-1 h-4 w-px bg-divider-regular"></div>
- </>
- )}
- <Button onClick={onClose} disabled={isDisabled}>
- {t(($) => $['operation.cancel'], { ns: 'common' })}
- </Button>
- <Button variant="primary" onClick={handleConfirm} disabled={isDisabled}>
- {confirmButtonText}
- </Button>
- </DialogFooter>
- {currentStep === EditStep.EditCredentials && <EncryptedBottom />}
- </EncryptedFooter>
+ <DialogFooter>
+ {currentStep === EditStep.EditConfiguration && (
+ <>
+ <Button variant="secondary" onClick={handleBack} disabled={isDisabled}>
+ {t(($) => $['modal.common.back'], { ns: 'pluginTrigger' })}
+ </Button>
+ <div className="mx-1 h-4 w-px bg-divider-regular"></div>
+ </>
+ )}
+ <Button onClick={onClose} disabled={isDisabled}>
+ {t(($) => $['operation.cancel'], { ns: 'common' })}
+ </Button>
+ <Button variant="primary" onClick={handleConfirm} disabled={isDisabled}>
+ {confirmButtonText}
+ </Button>
+ </DialogFooter>
+ {currentStep === EditStep.EditCredentials && <EncryptedBottom />}
</DialogContent>
</Dialog>
)
diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/schema-dialog.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/schema-dialog.tsx
index bb1767334f5..079722d2180 100644
--- a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/schema-dialog.tsx
+++ b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/schema-dialog.tsx
@@ -3,6 +3,7 @@ import type { Field } from '@/app/components/workflow/nodes/llm/types'
import { Button } from '@langgenius/dify-ui/button'
import {
Dialog,
+ DialogBody,
DialogCloseButton,
DialogContent,
DialogHeader,
@@ -63,20 +64,20 @@ export function SchemaDialog({ schema, rootName, compact = false }: SchemaDialog
return (
<Dialog>
{entry}
- <DialogContent className="flex max-h-[calc(100dvh-2rem)] w-240 min-w-0 flex-col overflow-hidden">
+ <DialogContent className="w-240">
<DialogHeader>
<DialogTitle>
{t(($) => $['nodes.agent.parameterSchema'], { ns: 'workflowAgent' })}
</DialogTitle>
<DialogCloseButton aria-label={t(($) => $['operation.close'], { ns: 'common' })} />
</DialogHeader>
- <div className="min-h-0 overflow-y-auto px-6 pt-2 pb-6">
+ <DialogBody>
<MittProvider>
<VisualEditorContextProvider>
<SchemaPreview schema={schema} rootName={rootName} />
</VisualEditorContextProvider>
</MittProvider>
- </div>
+ </DialogBody>
</DialogContent>
</Dialog>
)
diff --git a/web/app/components/plugins/plugin-mutation-model/index.tsx b/web/app/components/plugins/plugin-mutation-model/index.tsx
index 2ea80fe3ce9..18cfc9d9904 100644
--- a/web/app/components/plugins/plugin-mutation-model/index.tsx
+++ b/web/app/components/plugins/plugin-mutation-model/index.tsx
@@ -50,7 +50,7 @@ const PluginMutationModal: FC<Props> = ({
if (!open) onCancel()
}}
>
- <DialogContent className="w-full min-w-140">
+ <DialogContent className="w-140">
<DialogHeader>
<DialogTitle>{modelTitle}</DialogTitle>
<DialogCloseButton aria-label={t(($) => $['operation.close'], { ns: 'common' })} />
diff --git a/web/app/components/plugins/readme-panel/dialog.tsx b/web/app/components/plugins/readme-panel/dialog.tsx
index a7ab7e1c4a8..b852e948460 100644
--- a/web/app/components/plugins/readme-panel/dialog.tsx
+++ b/web/app/components/plugins/readme-panel/dialog.tsx
@@ -17,7 +17,7 @@ export function ReadmeDialog({ detail, open, onOpenChange, triggerId }: ReadmeDi
return (
<Dialog open={open} onOpenChange={onOpenChange} triggerId={triggerId}>
- <DialogContent className="h-[calc(100dvh-16px)] w-full max-w-200 overflow-hidden">
+ <DialogContent className="h-[calc(100dvh-16px)] w-200 overflow-hidden">
<ReadmePanelContent
detail={detail}
title={
diff --git a/web/app/components/rag-pipeline/components/export-confirm-modal.tsx b/web/app/components/rag-pipeline/components/export-confirm-modal.tsx
index 8dc33f2cfaa..f76f51b3fb2 100644
--- a/web/app/components/rag-pipeline/components/export-confirm-modal.tsx
+++ b/web/app/components/rag-pipeline/components/export-confirm-modal.tsx
@@ -2,6 +2,7 @@
import type { EnvironmentVariableItemResponse } from '@dify/contracts/api/console/apps/types.gen'
import {
AlertDialog,
+ AlertDialogBody,
AlertDialogCancelButton,
AlertDialogConfirmButton,
AlertDialogContent,
@@ -44,7 +45,7 @@ const PipelineExportConfirmContent = ({
<AlertDialogHeader>
<AlertDialogTitle>{t(($) => $['env.export.title'], { ns: 'workflow' })}</AlertDialogTitle>
</AlertDialogHeader>
- <div className="px-6">
+ <AlertDialogBody>
<div className="relative">
<table className="w-full border-separate border-spacing-0 rounded-lg border border-divider-regular shadow-xs">
<thead className="system-xs-medium-uppercase text-text-tertiary">
@@ -114,7 +115,7 @@ const PipelineExportConfirmContent = ({
{t(($) => $['env.export.checkbox'], { ns: 'workflow' })}
</span>
</label>
- </div>
+ </AlertDialogBody>
<AlertDialogFooter>
<AlertDialogCancelButton disabled={isExporting}>
{t(($) => $['operation.cancel'], { ns: 'common' })}
diff --git a/web/app/components/rag-pipeline/components/publish-as-knowledge-pipeline-modal.tsx b/web/app/components/rag-pipeline/components/publish-as-knowledge-pipeline-modal.tsx
index 8202e61b60a..9e9b0b0a504 100644
--- a/web/app/components/rag-pipeline/components/publish-as-knowledge-pipeline-modal.tsx
+++ b/web/app/components/rag-pipeline/components/publish-as-knowledge-pipeline-modal.tsx
@@ -76,6 +76,7 @@ const PublishAsKnowledgePipelineModal = ({
>
<DialogContent className="w-120">
<form
+ className="contents"
onSubmit={(event) => {
event.preventDefault()
handleConfirm()
diff --git a/web/app/components/rag-pipeline/components/rag-pipeline-header/publisher/popup.tsx b/web/app/components/rag-pipeline/components/rag-pipeline-header/publisher/popup.tsx
index b5eef9b07ff..46ad9fa7dfe 100644
--- a/web/app/components/rag-pipeline/components/rag-pipeline-header/publisher/popup.tsx
+++ b/web/app/components/rag-pipeline/components/rag-pipeline-header/publisher/popup.tsx
@@ -373,7 +373,11 @@ export function Popup({
<AlertDialogCancelButton>
{t(($) => $['operation.cancel'], { ns: 'common' })}
</AlertDialogCancelButton>
- <AlertDialogConfirmButton disabled={publishing} onClick={() => void handlePublish()}>
+ <AlertDialogConfirmButton
+ tone="default"
+ disabled={publishing}
+ onClick={() => void handlePublish()}
+ >
{t(($) => $['operation.confirm'], { ns: 'common' })}
</AlertDialogConfirmButton>
</AlertDialogFooter>
diff --git a/web/app/components/rag-pipeline/components/version-mismatch-modal.tsx b/web/app/components/rag-pipeline/components/version-mismatch-modal.tsx
index 09a5924f310..03c6b7aa28f 100644
--- a/web/app/components/rag-pipeline/components/version-mismatch-modal.tsx
+++ b/web/app/components/rag-pipeline/components/version-mismatch-modal.tsx
@@ -59,7 +59,7 @@ const VersionMismatchModal = ({
<AlertDialogCancelButton>
{t(($) => $['newApp.Cancel'], { ns: 'app' })}
</AlertDialogCancelButton>
- <AlertDialogConfirmButton onClick={onConfirm}>
+ <AlertDialogConfirmButton tone="default" onClick={onConfirm}>
{t(($) => $['newApp.Confirm'], { ns: 'app' })}
</AlertDialogConfirmButton>
</AlertDialogFooter>
diff --git a/web/app/components/snippets/import-snippet-dsl-dialog.tsx b/web/app/components/snippets/import-snippet-dsl-dialog.tsx
index bbf9c45496b..c8c9e200d1a 100644
--- a/web/app/components/snippets/import-snippet-dsl-dialog.tsx
+++ b/web/app/components/snippets/import-snippet-dsl-dialog.tsx
@@ -103,7 +103,7 @@ function SnippetDSLConfirmDialog({
<AlertDialogCancelButton>
{t(($) => $['operation.cancel'], { ns: 'common' })}
</AlertDialogCancelButton>
- <AlertDialogConfirmButton onClick={onConfirm} disabled={confirmDisabled}>
+ <AlertDialogConfirmButton tone="default" onClick={onConfirm} disabled={confirmDisabled}>
{t(($) => $['operation.confirm'], { ns: 'common' })}
</AlertDialogConfirmButton>
</AlertDialogFooter>
@@ -242,10 +242,10 @@ function ImportSnippetDSLDialog({ isOpen, onClose }: ImportSnippetDSLDialogProps
<DialogTitle>{t(($) => $.importDialogTitle, { ns: 'snippet' })}</DialogTitle>
<DialogCloseButton aria-label={t(($) => $['operation.close'], { ns: 'common' })} />
</DialogHeader>
- <Tabs value={currentTab} onValueChange={handleTabChange}>
+ <Tabs className="contents" value={currentTab} onValueChange={handleTabChange}>
<TabsList
aria-label={t(($) => $.importDialogTitle, { ns: 'snippet' })}
- className="h-9 gap-6 border-b border-divider-subtle px-6"
+ className="h-9 shrink-0 gap-6 border-b border-divider-subtle px-6"
>
<TabsTab
value={ImportSnippetDSLDialogTab.FromFile}
@@ -262,26 +262,30 @@ function ImportSnippetDSLDialog({ isOpen, onClose }: ImportSnippetDSLDialogProps
{t(($) => $.importFromDSLUrl, { ns: 'snippet' })}
</TabsTab>
</TabsList>
- <TabsPanel value={ImportSnippetDSLDialogTab.FromFile} tabIndex={-1}>
- <DialogBody>
- <Uploader className="mt-0" file={currentFile} updateFile={handleFileChange} />
- </DialogBody>
+ <TabsPanel
+ value={ImportSnippetDSLDialogTab.FromFile}
+ tabIndex={-1}
+ render={<DialogBody />}
+ >
+ <Uploader className="mt-0" file={currentFile} updateFile={handleFileChange} />
</TabsPanel>
- <TabsPanel value={ImportSnippetDSLDialogTab.FromUrl} tabIndex={-1}>
- <DialogBody>
- <label
- htmlFor={dslUrlInputId}
- className="mb-1 block system-md-semibold text-text-secondary"
- >
- DSL URL
- </label>
- <Input
- id={dslUrlInputId}
- placeholder={t(($) => $.importFromDSLUrlPlaceholder, { ns: 'snippet' }) || ''}
- value={dslUrl}
- onChange={(event) => setDslUrl(event.target.value)}
- />
- </DialogBody>
+ <TabsPanel
+ value={ImportSnippetDSLDialogTab.FromUrl}
+ tabIndex={-1}
+ render={<DialogBody />}
+ >
+ <label
+ htmlFor={dslUrlInputId}
+ className="mb-1 block system-md-semibold text-text-secondary"
+ >
+ DSL URL
+ </label>
+ <Input
+ id={dslUrlInputId}
+ placeholder={t(($) => $.importFromDSLUrlPlaceholder, { ns: 'snippet' }) || ''}
+ value={dslUrl}
+ onChange={(event) => setDslUrl(event.target.value)}
+ />
</TabsPanel>
</Tabs>
<DialogFooter>
diff --git a/web/app/components/tools/mcp/detail/content.tsx b/web/app/components/tools/mcp/detail/content.tsx
index edddd682384..7a186901d8f 100644
--- a/web/app/components/tools/mcp/detail/content.tsx
+++ b/web/app/components/tools/mcp/detail/content.tsx
@@ -317,7 +317,7 @@ const MCPDetailContent: FC<Props> = ({
<AlertDialogCancelButton>
{t(($) => $['operation.cancel'], { ns: 'common' })}
</AlertDialogCancelButton>
- <AlertDialogConfirmButton onClick={handleUpdateTools}>
+ <AlertDialogConfirmButton tone="default" onClick={handleUpdateTools}>
{t(($) => $['operation.confirm'], { ns: 'common' })}
</AlertDialogConfirmButton>
</AlertDialogFooter>
diff --git a/web/app/components/tools/mcp/mcp-server-modal.tsx b/web/app/components/tools/mcp/mcp-server-modal.tsx
index 22e46e47f90..f20b004e0b4 100644
--- a/web/app/components/tools/mcp/mcp-server-modal.tsx
+++ b/web/app/components/tools/mcp/mcp-server-modal.tsx
@@ -108,7 +108,7 @@ const MCPServerModal = ({ appID, latestParams = [], data, show, onHide, appInfo
if (!open) onHide()
}}
>
- <DialogContent className="max-h-[calc(100dvh-2rem)] w-130">
+ <DialogContent className="w-130">
<DialogHeader>
<DialogTitle>
{!data
diff --git a/web/app/components/workflow-app/components/__tests__/workflow-children.spec.tsx b/web/app/components/workflow-app/components/__tests__/workflow-children.spec.tsx
index fe86a71c061..39c99c08715 100644
--- a/web/app/components/workflow-app/components/__tests__/workflow-children.spec.tsx
+++ b/web/app/components/workflow-app/components/__tests__/workflow-children.spec.tsx
@@ -196,16 +196,16 @@ vi.mock('@/app/components/workflow/features', () => ({
vi.mock('@/app/components/workflow/update-dsl-modal', () => ({
default: ({
- onCancel,
+ onOpenChange,
onBackup,
onImport,
}: {
- onCancel: () => void
+ onOpenChange: (open: boolean) => void
onBackup: () => void
onImport: () => void
}) => (
<div data-testid="update-dsl-modal">
- <button type="button" onClick={onCancel}>
+ <button type="button" onClick={() => onOpenChange(false)}>
cancel-import-dsl
</button>
<button type="button" onClick={onBackup}>
diff --git a/web/app/components/workflow-app/components/workflow-children.tsx b/web/app/components/workflow-app/components/workflow-children.tsx
index 2b5f9b390e4..002d8ab35c8 100644
--- a/web/app/components/workflow-app/components/workflow-children.tsx
+++ b/web/app/components/workflow-app/components/workflow-children.tsx
@@ -181,7 +181,8 @@ const WorkflowChildren = () => {
<UpdateDSLModal
appId={appId}
appMode={isChatflow ? 'advanced-chat' : 'workflow'}
- onCancel={() => setShowImportDSLModal(false)}
+ open
+ onOpenChange={(open) => setShowImportDSLModal(open)}
onBackup={exportCheck!}
onImport={handlePaneContextmenuCancel}
/>
diff --git a/web/app/components/workflow/__tests__/update-dsl-modal.spec.tsx b/web/app/components/workflow/__tests__/update-dsl-modal.spec.tsx
index 950b7a0f029..9226d683705 100644
--- a/web/app/components/workflow/__tests__/update-dsl-modal.spec.tsx
+++ b/web/app/components/workflow/__tests__/update-dsl-modal.spec.tsx
@@ -91,7 +91,8 @@ describe('UpdateDSLModal', () => {
const defaultProps = {
appId: 'app-1',
appMode: 'workflow' as const,
- onCancel: vi.fn(),
+ open: true,
+ onOpenChange: vi.fn(),
onBackup: vi.fn(),
onImport: vi.fn(),
}
@@ -145,7 +146,7 @@ describe('UpdateDSLModal', () => {
fireEvent.change(screen.getByTestId('dsl-file-input'), { target: { files: [file] } })
fireEvent.click(screen.getByRole('button', { name: 'workflow.common.overwriteAndImport' }))
await waitFor(() => expect(mockImportDSL).toHaveBeenCalledWith({ file, app_id: 'app-1' }))
- await waitFor(() => expect(defaultProps.onCancel).toHaveBeenCalled())
+ await waitFor(() => expect(defaultProps.onOpenChange).toHaveBeenCalled())
})
it('should keep import disabled until a file is selected', () => {
@@ -165,21 +166,21 @@ describe('UpdateDSLModal', () => {
})
it('should call cancel handler when the import dialog requests close', () => {
- const onCancel = vi.fn()
- renderModal({ ...defaultProps, onCancel })
+ const onOpenChange = vi.fn()
+ renderModal({ ...defaultProps, onOpenChange })
fireEvent.keyDown(document, { key: 'Escape', code: 'Escape' })
- expect(onCancel).toHaveBeenCalledTimes(1)
+ expect(onOpenChange).toHaveBeenCalledTimes(1)
})
it('should call cancel handler when the close button is clicked', () => {
- const onCancel = vi.fn()
- renderModal({ ...defaultProps, onCancel })
+ const onOpenChange = vi.fn()
+ renderModal({ ...defaultProps, onOpenChange })
fireEvent.click(screen.getByRole('button', { name: 'common.operation.close' }))
- expect(onCancel).toHaveBeenCalledTimes(1)
+ expect(onOpenChange).toHaveBeenCalledTimes(1)
})
it('should import a valid file and emit workflow update payload', async () => {
@@ -207,7 +208,7 @@ describe('UpdateDSLModal', () => {
)
expect(mockEmitWorkflowUpdate).toHaveBeenCalledWith('app-1')
expect(defaultProps.onImport).toHaveBeenCalledTimes(1)
- expect(defaultProps.onCancel).toHaveBeenCalledTimes(1)
+ expect(defaultProps.onOpenChange).toHaveBeenCalledTimes(1)
})
it('commits the imported graph to collaboration before updating the canvas or other clients', async () => {
@@ -231,7 +232,7 @@ describe('UpdateDSLModal', () => {
})
fireEvent.click(screen.getByRole('button', { name: 'workflow.common.overwriteAndImport' }))
- await waitFor(() => expect(defaultProps.onCancel).toHaveBeenCalledTimes(1))
+ await waitFor(() => expect(defaultProps.onOpenChange).toHaveBeenCalledTimes(1))
const [appId, nodes, edges] = mockReplaceGraphFromCommittedDraft.mock.calls[0]!
expect(appId).toBe('app-1')
expect(nodes).toEqual([expect.objectContaining({ id: 'imported-start' })])
@@ -259,7 +260,7 @@ describe('UpdateDSLModal', () => {
})
fireEvent.click(screen.getByRole('button', { name: 'workflow.common.overwriteAndImport' }))
- await waitFor(() => expect(defaultProps.onCancel).toHaveBeenCalledTimes(1))
+ await waitFor(() => expect(defaultProps.onOpenChange).toHaveBeenCalledTimes(1))
expect(mockReplaceGraphFromCommittedDraft).not.toHaveBeenCalled()
expect(mockEmit).toHaveBeenCalledWith(expect.objectContaining({ type: 'WORKFLOW_DATA_UPDATE' }))
})
@@ -276,7 +277,7 @@ describe('UpdateDSLModal', () => {
await waitFor(() => expect(reload).toHaveBeenCalledTimes(1))
expect(mockEmit).not.toHaveBeenCalled()
- expect(defaultProps.onCancel).not.toHaveBeenCalled()
+ expect(defaultProps.onOpenChange).not.toHaveBeenCalled()
reload.mockRestore()
})
@@ -403,7 +404,7 @@ describe('UpdateDSLModal', () => {
})
})
- it('should close the owner when cancelling a pending import', async () => {
+ it('returns to the selected file when cancelling version confirmation', async () => {
mockImportDSL.mockResolvedValue({
id: 'import-5',
status: DSLImportStatus.PENDING,
@@ -432,11 +433,15 @@ describe('UpdateDSLModal', () => {
fireEvent.click(screen.getByRole('button', { name: 'app.newApp.Cancel' }))
await waitFor(() => {
- expect(defaultProps.onCancel).toHaveBeenCalledTimes(1)
+ expect(screen.queryByRole('button', { name: 'app.newApp.Confirm' })).not.toBeInTheDocument()
})
+ expect(defaultProps.onOpenChange).not.toHaveBeenCalled()
+ expect(
+ screen.getByRole('button', { name: 'workflow.common.overwriteAndImport' }),
+ ).not.toBeDisabled()
})
- it('should close the pending modal when dialog requests close', async () => {
+ it('returns to the selected file when escaping version confirmation', async () => {
mockImportDSL.mockResolvedValue({
id: 'import-8',
status: DSLImportStatus.PENDING,
@@ -458,8 +463,12 @@ describe('UpdateDSLModal', () => {
fireEvent.keyDown(document, { key: 'Escape', code: 'Escape' })
await waitFor(() => {
- expect(defaultProps.onCancel).toHaveBeenCalledTimes(1)
+ expect(screen.queryByRole('button', { name: 'app.newApp.Confirm' })).not.toBeInTheDocument()
})
+ expect(defaultProps.onOpenChange).not.toHaveBeenCalled()
+ expect(
+ screen.getByRole('button', { name: 'workflow.common.overwriteAndImport' }),
+ ).not.toBeDisabled()
})
it('keeps a successful import successful when refreshing the draft fails', async () => {
@@ -476,7 +485,7 @@ describe('UpdateDSLModal', () => {
}),
)
expect(toast.success).toHaveBeenCalledWith('workflow.common.importSuccess', undefined)
- expect(defaultProps.onCancel).not.toHaveBeenCalled()
+ expect(defaultProps.onOpenChange).not.toHaveBeenCalled()
expect(mockEmitWorkflowUpdate).toHaveBeenCalledWith('app-1')
expect(mockReplaceGraphFromCommittedDraft).not.toHaveBeenCalled()
expect(mockHandleCheckPluginDependencies).not.toHaveBeenCalled()
@@ -501,12 +510,12 @@ describe('UpdateDSLModal', () => {
await user.click(submit)
await user.keyboard('{Escape}')
expect(mockImportDSL).toHaveBeenCalledTimes(1)
- expect(defaultProps.onCancel).not.toHaveBeenCalled()
+ expect(defaultProps.onOpenChange).not.toHaveBeenCalled()
await act(async () =>
resolveDraft({ graph: { nodes: [], edges: [], viewport: {} }, features: {} }),
)
- await waitFor(() => expect(defaultProps.onCancel).toHaveBeenCalledTimes(1))
+ await waitFor(() => expect(defaultProps.onOpenChange).toHaveBeenCalledTimes(1))
expect(mockEmit).toHaveBeenCalled()
})
@@ -528,14 +537,14 @@ describe('UpdateDSLModal', () => {
await user.click(confirm)
await user.keyboard('{Escape}')
expect(mockImportDSLConfirm).toHaveBeenCalledTimes(1)
- expect(defaultProps.onCancel).not.toHaveBeenCalled()
+ expect(defaultProps.onOpenChange).not.toHaveBeenCalled()
await act(async () => resolveRequest({ status: DSLImportStatus.FAILED, error: 'Retry import' }))
await waitFor(() => expect(confirm).not.toHaveAttribute('aria-disabled', 'true'))
await user.click(confirm)
await waitFor(() => expect(mockImportDSLConfirm).toHaveBeenCalledTimes(2))
expect(mockImportDSLConfirm).toHaveBeenLastCalledWith({ import_id: 'pending-1' })
- await waitFor(() => expect(defaultProps.onCancel).toHaveBeenCalledTimes(1))
+ await waitFor(() => expect(defaultProps.onOpenChange).toHaveBeenCalledTimes(1))
})
it('imports the submitted file snapshot even when selection changes while reading', async () => {
diff --git a/web/app/components/workflow/nodes/agent-v2/components/agent-roster-field.tsx b/web/app/components/workflow/nodes/agent-v2/components/agent-roster-field.tsx
index 9720e0adfea..2d19ecab758 100644
--- a/web/app/components/workflow/nodes/agent-v2/components/agent-roster-field.tsx
+++ b/web/app/components/workflow/nodes/agent-v2/components/agent-roster-field.tsx
@@ -306,7 +306,7 @@ function AgentRosterInlineConfigureDialog({
return (
<Dialog open={open} onOpenChange={onOpenChange} disablePointerDismissal>
<DialogTrigger render={trigger} />
- <DialogContent className="h-[min(760px,calc(100dvh-32px))] w-[min(1120px,calc(100vw-32px))] max-w-none overflow-hidden">
+ <DialogContent className="h-[min(760px,calc(100dvh-32px))] w-[min(1120px,calc(100vw-32px))] overflow-hidden">
<DialogTitle className="sr-only">{agent.name}</DialogTitle>
<DialogDescription className="sr-only">
{t(($) => $[`${i18nPrefix}.roster.inlineSetup.description`], { ns: 'workflowAgent' })}
diff --git a/web/app/components/workflow/nodes/agent-v2/components/save-inline-agent-to-roster-dialog.tsx b/web/app/components/workflow/nodes/agent-v2/components/save-inline-agent-to-roster-dialog.tsx
index bf4e2caece3..db256792193 100644
--- a/web/app/components/workflow/nodes/agent-v2/components/save-inline-agent-to-roster-dialog.tsx
+++ b/web/app/components/workflow/nodes/agent-v2/components/save-inline-agent-to-roster-dialog.tsx
@@ -75,7 +75,10 @@ function SaveInlineAgentToRosterFormSession({
</DialogDescription>
<DialogCloseButton aria-label={tCommon(($) => $['operation.close'])} disabled={pending} />
</DialogHeader>
- <Form<AgentFormValues> onFormSubmit={(formValues) => onSubmit(formValues, agentIcon)}>
+ <Form<AgentFormValues>
+ className="contents"
+ onFormSubmit={(formValues) => onSubmit(formValues, agentIcon)}
+ >
<AgentFormFields
ref={nameInputRef}
defaultValues={initialValues.fields}
@@ -172,7 +175,7 @@ export function SaveInlineAgentToRosterDialog({
return (
<>
<Dialog open={open} onOpenChange={handleOpenChange} disablePointerDismissal>
- <DialogContent initialFocus={nameInputRef} className="max-h-[calc(100dvh-2rem)] w-130">
+ <DialogContent initialFocus={nameInputRef} className="w-130">
<SaveInlineAgentToRosterFormSession
initialAgent={initialAgent}
nameInputRef={nameInputRef}
diff --git a/web/app/components/workflow/nodes/http/components/authorization/index.tsx b/web/app/components/workflow/nodes/http/components/authorization/index.tsx
index 75a24ce9194..39df9867579 100644
--- a/web/app/components/workflow/nodes/http/components/authorization/index.tsx
+++ b/web/app/components/workflow/nodes/http/components/authorization/index.tsx
@@ -151,6 +151,7 @@ function AuthorizationForm({
</DialogHeader>
<form
+ className="contents"
onSubmit={(event) => {
event.preventDefault()
onChange(tempPayload)
diff --git a/web/app/components/workflow/nodes/http/components/curl-import-dialog.tsx b/web/app/components/workflow/nodes/http/components/curl-import-dialog.tsx
index c273ac4cec9..c89cbdb36c6 100644
--- a/web/app/components/workflow/nodes/http/components/curl-import-dialog.tsx
+++ b/web/app/components/workflow/nodes/http/components/curl-import-dialog.tsx
@@ -29,6 +29,7 @@ function CurlImportForm({ onImport }: Pick<CurlImportDialogProps, 'onImport'>) {
return (
<form
+ className="contents"
onSubmit={(event) => {
event.preventDefault()
const command = new FormData(event.currentTarget).get('curl')
@@ -46,10 +47,10 @@ function CurlImportForm({ onImport }: Pick<CurlImportDialogProps, 'onImport'>) {
/>
</DialogBody>
<DialogFooter>
- <DialogClose render={<Button className="w-23.75!" />}>
+ <DialogClose render={<Button className="min-w-24" />}>
{t(($) => $['operation.cancel'], { ns: 'common' })}
</DialogClose>
- <Button type="submit" className="w-23.75!" variant="primary">
+ <Button type="submit" className="min-w-24" variant="primary">
{t(($) => $['operation.save'], { ns: 'common' })}
</Button>
</DialogFooter>
@@ -83,7 +84,7 @@ export function CurlImportDialog({ readOnly, onImport }: CurlImportDialogProps)
/>
{label}
</DialogTrigger>
- <DialogContent className="w-100 max-w-100">
+ <DialogContent className="w-100">
<DialogHeader>
<DialogTitle>
{t(($) => $['nodes.http.curl.title'], { ns: 'workflowIntegrations' })}
diff --git a/web/app/components/workflow/nodes/parameter-extractor/components/extract-parameter/update.tsx b/web/app/components/workflow/nodes/parameter-extractor/components/extract-parameter/update.tsx
index aa91e5c5e69..8fe651b15ee 100644
--- a/web/app/components/workflow/nodes/parameter-extractor/components/extract-parameter/update.tsx
+++ b/web/app/components/workflow/nodes/parameter-extractor/components/extract-parameter/update.tsx
@@ -80,7 +80,7 @@ export function ParameterDialog(props: Props) {
</IconButton>
}
/>
- <DialogContent className="w-100 max-w-100">
+ <DialogContent className="w-100">
<DialogHeader>
<DialogTitle>{triggerLabel}</DialogTitle>
</DialogHeader>
@@ -161,6 +161,7 @@ function ParameterForm({ type, payload, onSave, onSaved }: Props & { onSaved: ()
return (
<form
+ className="contents"
onSubmit={(event) => {
event.preventDefault()
event.stopPropagation()
@@ -250,10 +251,10 @@ function ParameterForm({ type, payload, onSave, onSaved }: Props & { onSaved: ()
</Field>
</DialogBody>
<DialogFooter>
- <DialogClose render={<Button className="w-23.75!" />}>
+ <DialogClose render={<Button className="min-w-24" />}>
{t(($) => $['operation.cancel'], { ns: 'common' })}
</DialogClose>
- <Button type="submit" className="w-23.75!" variant="primary">
+ <Button type="submit" className="min-w-24" variant="primary">
{isAdd
? t(($) => $['operation.add'], { ns: 'common' })
: t(($) => $['operation.save'], { ns: 'common' })}
diff --git a/web/app/components/workflow/panel/debug-and-preview/conversation-variable-modal.tsx b/web/app/components/workflow/panel/debug-and-preview/conversation-variable-modal.tsx
index f43e0cf9ff1..ba256ff2df7 100644
--- a/web/app/components/workflow/panel/debug-and-preview/conversation-variable-modal.tsx
+++ b/web/app/components/workflow/panel/debug-and-preview/conversation-variable-modal.tsx
@@ -72,7 +72,7 @@ const ConversationVariableModal = ({ conversationID, onHide }: Props) => {
return (
<Dialog open>
- <DialogContent className="h-[min(640px,calc(100dvh-2rem))] max-h-none w-230 overflow-hidden">
+ <DialogContent className="h-[min(640px,calc(100dvh-2rem))] w-230 overflow-hidden">
<button
type="button"
aria-label={t(($) => $['operation.close'], { ns: 'common' })}
diff --git a/web/app/components/workflow/update-dsl-modal.tsx b/web/app/components/workflow/update-dsl-modal.tsx
index 3d1a7e2f682..2bd28ee7e90 100644
--- a/web/app/components/workflow/update-dsl-modal.tsx
+++ b/web/app/components/workflow/update-dsl-modal.tsx
@@ -1,11 +1,13 @@
'use client'
import type { AppDetailWithSite, Import } from '@dify/contracts/api/console/apps/types.gen'
-import type { MouseEventHandler } from 'react'
+import type { DialogActions, DialogProps } from '@langgenius/dify-ui/dialog'
+import type { ReactNode } from 'react'
import { Button } from '@langgenius/dify-ui/button'
import {
Dialog,
DialogBody,
+ DialogClose,
DialogCloseButton,
DialogContent,
DialogFooter,
@@ -14,7 +16,7 @@ import {
} from '@langgenius/dify-ui/dialog'
import { RiAlertFill, RiFileDownloadLine } from '@remixicon/react'
import { useMutation } from '@tanstack/react-query'
-import { memo, useCallback, useState } from 'react'
+import { memo, useCallback, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import DSLImportWarningDescription from '@/app/components/app/create-from-dsl-modal/dsl-import-warning-description'
import { Uploader } from '@/app/components/app/create-from-dsl-modal/uploader'
@@ -35,17 +37,26 @@ import {
} from './update-dsl-modal.helpers'
import { initialEdges, initialNodes } from './utils'
-type UpdateDSLModalProps = {
+type UpdateDSLModalProps = Pick<DialogProps, 'open' | 'onOpenChange'> & {
+ children?: ReactNode
appId: string
appMode: AppDetailWithSite['mode']
- onCancel: () => void
onBackup: () => void
onImport?: () => void
}
-const UpdateDSLModal = ({ appId, appMode, onCancel, onBackup, onImport }: UpdateDSLModalProps) => {
+function UpdateDSLModal({
+ open,
+ onOpenChange,
+ children,
+ appId,
+ appMode,
+ onBackup,
+ onImport,
+}: UpdateDSLModalProps) {
+ const browseButtonRef = useRef<HTMLButtonElement>(null)
+ const actionsRef = useRef<DialogActions>(null)
const { t } = useTranslation(['workflow', 'app', 'common'])
- const [currentFile, setCurrentFile] = useState<File>()
const { eventEmitter } = useEventEmitterContextContext()
const { handleCheckPluginDependencies } = usePluginDependencies()
@@ -115,9 +126,9 @@ const UpdateDSLModal = ({ appId, appMode, onCancel, onBackup, onImport }: Update
onImport?.()
// Dependency checks own their feedback after the import has already succeeded.
await handleCheckPluginDependencies(appId)
- onCancel()
+ actionsRef.current?.close()
},
- [handleCheckPluginDependencies, handleWorkflowUpdate, onCancel, onImport, t],
+ [handleCheckPluginDependencies, handleWorkflowUpdate, onImport, t],
)
const handleImportResponse = async (response: Import) => {
@@ -180,12 +191,7 @@ const UpdateDSLModal = ({ appId, appMode, onCancel, onBackup, onImport }: Update
const pendingImport = importMutation.data?.status === 'pending' ? importMutation.data : undefined
const isImporting = importMutation.isPending || confirmImportMutation.isPending
- const handleImport: MouseEventHandler = () => {
- if (isImporting || !currentFile) return
- importMutation.mutate(currentFile)
- }
-
- const onUpdateDSLConfirm: MouseEventHandler = () => {
+ const onUpdateDSLConfirm = () => {
if (!pendingImport || isImporting) return
confirmImportMutation.mutate({
@@ -194,120 +200,179 @@ const UpdateDSLModal = ({ appId, appMode, onCancel, onBackup, onImport }: Update
}
return (
- <>
- <Dialog
- open={!pendingImport}
- onOpenChange={(open) => {
- if (!open && !isImporting) onCancel()
- }}
- >
- <DialogContent className="w-120">
- <DialogHeader>
- <DialogTitle>{t(($) => $.importApp, { ns: 'app' })}</DialogTitle>
- <DialogCloseButton
- aria-label={t(($) => $['operation.close'], { ns: 'common' })}
- disabled={isImporting}
- />
- </DialogHeader>
- <DialogBody>
- <div className="relative mb-2 flex grow gap-0.5 overflow-hidden rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur p-2 shadow-xs">
- <div className="pointer-events-none absolute top-0 left-0 size-full bg-toast-warning-bg opacity-40" />
- <div className="flex items-start justify-center p-1">
- <RiAlertFill className="size-4 shrink-0 text-text-warning-secondary" />
- </div>
- <div className="flex grow flex-col items-start gap-0.5 py-1">
- <div className="system-xs-medium whitespace-pre-line text-text-primary">
- {t(($) => $['common.importDSLTip'], { ns: 'workflow' })}
- </div>
- <div className="flex items-start gap-1 self-stretch pt-1 pb-0.5">
- <Button
- size="small"
- variant="secondary"
- className="relative"
- disabled={isImporting}
- onClick={onBackup}
- >
- <RiFileDownloadLine className="size-3.5 text-components-button-secondary-text" />
- <div className="flex items-center justify-center gap-1">
- {t(($) => $['common.backupCurrentDraft'], { ns: 'workflow' })}
- </div>
- </Button>
+ <Dialog
+ actionsRef={actionsRef}
+ open={open}
+ onOpenChange={(nextOpen, details) => {
+ if (!nextOpen && isImporting && details.reason !== 'imperative-action') details.cancel()
+ else onOpenChange?.(nextOpen, details)
+ }}
+ onOpenChangeComplete={(nextOpen) => {
+ if (!nextOpen) {
+ importMutation.reset()
+ confirmImportMutation.reset()
+ }
+ }}
+ >
+ <DialogContent initialFocus={browseButtonRef} className="w-120">
+ <ImportForm
+ browseButtonRef={browseButtonRef}
+ isImporting={isImporting}
+ onBackup={onBackup}
+ onSubmit={(file) => {
+ if (!isImporting) importMutation.mutate(file)
+ }}
+ />
+ {children}
+ <Dialog
+ open={!!pendingImport}
+ onOpenChange={(open, details) => {
+ if (!open && isImporting) details.cancel()
+ else if (!open) importMutation.reset()
+ }}
+ >
+ <DialogContent className="w-120">
+ <form
+ className="contents"
+ onSubmit={(event) => {
+ event.preventDefault()
+ onUpdateDSLConfirm()
+ }}
+ >
+ <DialogHeader>
+ <DialogTitle>
+ {t(($) => $['newApp.appCreateDSLErrorTitle'], { ns: 'app' })}
+ </DialogTitle>
+ </DialogHeader>
+ <DialogBody>
+ <div className="flex flex-col system-md-regular text-text-secondary">
+ <div>{t(($) => $['newApp.appCreateDSLErrorPart1'], { ns: 'app' })}</div>
+ <div>{t(($) => $['newApp.appCreateDSLErrorPart2'], { ns: 'app' })}</div>
+ <br />
+ <div>
+ {t(($) => $['newApp.appCreateDSLErrorPart3'], { ns: 'app' })}
+ <span className="system-md-medium">{pendingImport?.imported_dsl_version}</span>
+ </div>
+ <div>
+ {t(($) => $['newApp.appCreateDSLErrorPart4'], { ns: 'app' })}
+ <span className="system-md-medium">{pendingImport?.current_dsl_version}</span>
+ </div>
</div>
- </div>
- </div>
- <div>
- <div className="pt-2 system-md-semibold text-text-primary">
- {t(($) => $.chooseAppFile, { ns: 'app' })}
- </div>
- <div className="flex w-full flex-col items-start justify-center gap-4 self-stretch py-4">
- <Uploader
- importType="app"
+ </DialogBody>
+ <DialogFooter>
+ <Button
+ type="button"
+ variant="secondary"
disabled={isImporting}
- file={currentFile}
- updateFile={setCurrentFile}
- className="mt-0! w-full"
- />
- </div>
+ onClick={() => importMutation.reset()}
+ >
+ {t(($) => $['newApp.Cancel'], { ns: 'app' })}
+ </Button>
+ <Button
+ variant="primary"
+ tone="destructive"
+ disabled={isImporting}
+ loading={confirmImportMutation.isPending}
+ type="submit"
+ >
+ {t(($) => $['newApp.Confirm'], { ns: 'app' })}
+ </Button>
+ </DialogFooter>
+ </form>
+ </DialogContent>
+ </Dialog>
+ </DialogContent>
+ </Dialog>
+ )
+}
+
+function ImportForm({
+ browseButtonRef,
+ isImporting,
+ onBackup,
+ onSubmit,
+}: {
+ browseButtonRef: React.RefObject<HTMLButtonElement | null>
+ isImporting: boolean
+ onBackup: UpdateDSLModalProps['onBackup']
+ onSubmit: (file: File) => void
+}) {
+ const { t } = useTranslation(['workflow', 'app', 'common'])
+ const [currentFile, setCurrentFile] = useState<File>()
+ return (
+ <form
+ className="contents"
+ onSubmit={(event) => {
+ event.preventDefault()
+ if (event.target === event.currentTarget && !isImporting && currentFile)
+ onSubmit(currentFile)
+ }}
+ >
+ <DialogHeader>
+ <DialogTitle>{t(($) => $.importApp, { ns: 'app' })}</DialogTitle>
+ <DialogCloseButton
+ aria-label={t(($) => $['operation.close'], { ns: 'common' })}
+ disabled={isImporting}
+ />
+ </DialogHeader>
+ <DialogBody>
+ <div className="relative mb-2 flex grow gap-0.5 overflow-hidden rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur p-2 shadow-xs">
+ <div className="pointer-events-none absolute top-0 left-0 size-full bg-toast-warning-bg opacity-40" />
+ <div className="flex items-start justify-center p-1">
+ <RiAlertFill className="size-4 shrink-0 text-text-warning-secondary" />
+ </div>
+ <div className="flex grow flex-col items-start gap-0.5 py-1">
+ <div className="system-xs-medium whitespace-pre-line text-text-primary">
+ {t(($) => $['common.importDSLTip'], { ns: 'workflow' })}
</div>
- </DialogBody>
- <DialogFooter>
- <Button disabled={isImporting} onClick={onCancel}>
- {t(($) => $['newApp.Cancel'], { ns: 'app' })}
- </Button>
- <Button
- disabled={isImporting || !currentFile}
- variant="primary"
- tone="destructive"
- onClick={handleImport}
- loading={importMutation.isPending}
- >
- {t(($) => $['common.overwriteAndImport'], { ns: 'workflow' })}
- </Button>
- </DialogFooter>
- </DialogContent>
- </Dialog>
- <Dialog
- open={!!pendingImport}
- onOpenChange={(open) => {
- if (!open && !isImporting) onCancel()
- }}
- >
- <DialogContent className="w-120">
- <DialogHeader>
- <DialogTitle>{t(($) => $['newApp.appCreateDSLErrorTitle'], { ns: 'app' })}</DialogTitle>
- </DialogHeader>
- <DialogBody>
- <div className="flex flex-col system-md-regular text-text-secondary">
- <div>{t(($) => $['newApp.appCreateDSLErrorPart1'], { ns: 'app' })}</div>
- <div>{t(($) => $['newApp.appCreateDSLErrorPart2'], { ns: 'app' })}</div>
- <br />
- <div>
- {t(($) => $['newApp.appCreateDSLErrorPart3'], { ns: 'app' })}
- <span className="system-md-medium">{pendingImport?.imported_dsl_version}</span>
- </div>
- <div>
- {t(($) => $['newApp.appCreateDSLErrorPart4'], { ns: 'app' })}
- <span className="system-md-medium">{pendingImport?.current_dsl_version}</span>
- </div>
+ <div className="flex items-start gap-1 self-stretch pt-1 pb-0.5">
+ <Button
+ type="button"
+ size="small"
+ variant="secondary"
+ className="relative"
+ disabled={isImporting}
+ onClick={onBackup}
+ >
+ <RiFileDownloadLine className="size-3.5 text-components-button-secondary-text" />
+ <div className="flex items-center justify-center gap-1">
+ {t(($) => $['common.backupCurrentDraft'], { ns: 'workflow' })}
+ </div>
+ </Button>
</div>
- </DialogBody>
- <DialogFooter>
- <Button variant="secondary" disabled={isImporting} onClick={onCancel}>
- {t(($) => $['newApp.Cancel'], { ns: 'app' })}
- </Button>
- <Button
- variant="primary"
- tone="destructive"
+ </div>
+ </div>
+ <div>
+ <div className="pt-2 system-md-semibold text-text-primary">
+ {t(($) => $.chooseAppFile, { ns: 'app' })}
+ </div>
+ <div className="flex w-full flex-col items-start justify-center gap-4 self-stretch py-4">
+ <Uploader
+ browseButtonRef={browseButtonRef}
+ importType="app"
disabled={isImporting}
- loading={confirmImportMutation.isPending}
- onClick={onUpdateDSLConfirm}
- >
- {t(($) => $['newApp.Confirm'], { ns: 'app' })}
- </Button>
- </DialogFooter>
- </DialogContent>
- </Dialog>
- </>
+ file={currentFile}
+ updateFile={setCurrentFile}
+ className="mt-0! w-full"
+ />
+ </div>
+ </div>
+ </DialogBody>
+ <DialogFooter>
+ <DialogClose disabled={isImporting} render={<Button type="button" />}>
+ {t(($) => $['newApp.Cancel'], { ns: 'app' })}
+ </DialogClose>
+ <Button
+ disabled={isImporting || !currentFile}
+ variant="primary"
+ tone="destructive"
+ type="submit"
+ loading={isImporting}
+ >
+ {t(($) => $['common.overwriteAndImport'], { ns: 'workflow' })}
+ </Button>
+ </DialogFooter>
+ </form>
)
}
diff --git a/web/app/components/workflow/workflow-generator/index.tsx b/web/app/components/workflow/workflow-generator/index.tsx
index b42d0270483..8547eadec69 100644
--- a/web/app/components/workflow/workflow-generator/index.tsx
+++ b/web/app/components/workflow/workflow-generator/index.tsx
@@ -591,7 +591,7 @@ function WorkflowGeneratorModal() {
>
<DialogContent
initialFocus={instructionRef}
- className="h-[min(680px,calc(100dvh-2rem))] max-h-none w-285 min-w-0 overflow-hidden"
+ className="h-[min(680px,calc(100dvh-2rem))] w-285 min-w-0 overflow-hidden"
>
<div className="flex h-full min-h-0 flex-col md:flex-row">
{/* Left pane: instructions + ideal output + model selector */}
diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/knowledge/dialog.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/knowledge/dialog.tsx
index 9cb4377f277..e9caef678f6 100644
--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/knowledge/dialog.tsx
+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/knowledge/dialog.tsx
@@ -745,10 +745,7 @@ export function AgentKnowledgeRetrievalDialog({
}: AgentKnowledgeRetrievalDialogProps) {
return (
<Dialog open={open} onOpenChange={onOpenChange}>
- <DialogContent
- backdropProps={{ forceRender: true }}
- className="flex h-130 max-h-[calc(100dvh-2rem)] w-100 flex-col overflow-hidden"
- >
+ <DialogContent backdropProps={{ forceRender: true }} className="h-130 w-100 overflow-hidden">
<AgentKnowledgeRetrievalDialogContent
item={item}
initialName={initialName}
diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/detail-dialog.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/detail-dialog.tsx
index 24af8b73639..3a8c1730c38 100644
--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/detail-dialog.tsx
+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/detail-dialog.tsx
@@ -351,117 +351,119 @@ export function AgentSkillDetailDialog({
return (
<DialogContent
backdropProps={{ forceRender: true, className: 'fixed' }}
- className="flex h-[min(720px,calc(100dvh-2rem))] max-h-none w-[min(960px,calc(100vw-2rem))] overflow-hidden"
+ className="h-[min(720px,calc(100dvh-2rem))] w-[min(960px,calc(100vw-2rem))] overflow-hidden"
>
- <div
- className={cn(
- 'flex w-56 min-w-0 shrink-0 border-r-[0.5px] border-divider-subtle bg-background-section',
- detail.fileListPanelClassName,
- )}
- >
- <DialogDescription className="sr-only">{detail.description}</DialogDescription>
- <DialogTitle id={dialogTitleId} className="sr-only">
- {previewTitle || skillName}
- </DialogTitle>
- <div className="min-h-0 w-full">
- <AgentSkillFileList
- fileListHeader={detail.fileListHeader}
- fileListLoading={detail.fileListLoading}
- fileListTreeClassName={detail.fileListTreeClassName}
- fileListTreeListClassName={detail.fileListTreeListClassName}
- fileListTitle={detail.fileListTitle}
- files={detail.files}
- folderOpenState={detail.folderOpenState}
- onFolderOpenChange={detail.onFolderOpenChange}
- onFolderEnter={detail.onFolderEnter}
- selectedFileId={detail.selectedFileId}
- onSelectFile={detail.onSelectFile}
- renderFolderSuffix={detail.renderFolderSuffix}
- />
- </div>
- </div>
- <div className="flex min-w-0 flex-1 flex-col">
- <div className="flex shrink-0 items-start gap-2 px-4 pt-3.5 pb-2">
- <div className="flex min-w-0 flex-1 items-center gap-2">
- {!!previewTitle && (
- <h2
- className="min-w-0 truncate system-xl-semibold text-text-primary"
- title={previewTitle}
- >
- {previewTitle}
- </h2>
- )}
- </div>
- <div className="-my-0.5 flex shrink-0 items-center gap-1">
- {detail.onDownloadFile && previewTitle && (
- <button
- type="button"
- aria-label={`${isHeaderDownloadLoading ? tCommon(($) => $['operation.downloading']) : tCommon(($) => $['operation.download'])} ${previewTitle}`}
- onClick={() => detail.onDownloadFile?.('header')}
- disabled={isHeaderDownloadLoading}
- className="flex size-8 shrink-0 items-center justify-center rounded-lg text-text-tertiary outline-hidden hover:bg-state-base-hover hover:text-text-secondary focus-visible:bg-state-base-hover focus-visible:text-text-secondary focus-visible:ring-2 focus-visible:ring-state-accent-solid"
- >
- <span
- aria-hidden
- className={cn(
- 'size-4',
- isHeaderDownloadLoading
- ? 'i-ri-loader-2-line animate-spin motion-reduce:animate-none'
- : 'i-ri-download-line',
- )}
- />
- </button>
- )}
- <DialogClose
- render={
- <IconButton
- aria-label={tCommon(($) => $['operation.close'])}
- size="lg"
- className="shrink-0"
- >
- <span aria-hidden className="i-ri-close-line size-4" />
- </IconButton>
- }
+ <div className="flex min-h-0 flex-1">
+ <div
+ className={cn(
+ 'flex w-56 min-w-0 shrink-0 border-r-[0.5px] border-divider-subtle bg-background-section',
+ detail.fileListPanelClassName,
+ )}
+ >
+ <DialogDescription className="sr-only">{detail.description}</DialogDescription>
+ <DialogTitle id={dialogTitleId} className="sr-only">
+ {previewTitle || skillName}
+ </DialogTitle>
+ <div className="min-h-0 w-full">
+ <AgentSkillFileList
+ fileListHeader={detail.fileListHeader}
+ fileListLoading={detail.fileListLoading}
+ fileListTreeClassName={detail.fileListTreeClassName}
+ fileListTreeListClassName={detail.fileListTreeListClassName}
+ fileListTitle={detail.fileListTitle}
+ files={detail.files}
+ folderOpenState={detail.folderOpenState}
+ onFolderOpenChange={detail.onFolderOpenChange}
+ onFolderEnter={detail.onFolderEnter}
+ selectedFileId={detail.selectedFileId}
+ onSelectFile={detail.onSelectFile}
+ renderFolderSuffix={detail.renderFolderSuffix}
/>
</div>
</div>
- <ScrollArea className="min-h-0 flex-1 overflow-hidden rounded-br-2xl">
- <ScrollAreaViewport
- aria-labelledby={dialogTitleId}
- className="overscroll-contain"
- role="region"
- >
- <ScrollAreaContent
- style={{ minWidth: 0 }}
- className="flex min-h-full w-full max-w-full flex-col gap-2"
- >
- {detail.filePreview && (
- <AgentFilePreviewContent
- binary={detail.filePreview.binary}
- content={detail.filePreview.content}
- downloadActionLoadingTarget={detail.filePreview.downloadActionLoadingTarget}
- downloadUrl={detail.filePreview.downloadUrl}
- fileName={detail.filePreview.fileName}
- imageData={detail.filePreview.imageData}
- isDownloadError={detail.filePreview.isDownloadError}
- isDownloadLoading={detail.filePreview.isDownloadLoading}
- isError={detail.filePreview.isError}
- isImage={detail.filePreview.isImage}
- isLoading={detail.filePreview.isLoading}
- onDownloadFile={detail.onDownloadFile}
- />
+ <div className="flex min-w-0 flex-1 flex-col">
+ <div className="flex shrink-0 items-start gap-2 px-4 pt-3.5 pb-2">
+ <div className="flex min-w-0 flex-1 items-center gap-2">
+ {!!previewTitle && (
+ <h2
+ className="min-w-0 truncate system-xl-semibold text-text-primary"
+ title={previewTitle}
+ >
+ {previewTitle}
+ </h2>
+ )}
+ </div>
+ <div className="-my-0.5 flex shrink-0 items-center gap-1">
+ {detail.onDownloadFile && previewTitle && (
+ <button
+ type="button"
+ aria-label={`${isHeaderDownloadLoading ? tCommon(($) => $['operation.downloading']) : tCommon(($) => $['operation.download'])} ${previewTitle}`}
+ onClick={() => detail.onDownloadFile?.('header')}
+ disabled={isHeaderDownloadLoading}
+ className="flex size-8 shrink-0 items-center justify-center rounded-lg text-text-tertiary outline-hidden hover:bg-state-base-hover hover:text-text-secondary focus-visible:bg-state-base-hover focus-visible:text-text-secondary focus-visible:ring-2 focus-visible:ring-state-accent-solid"
+ >
+ <span
+ aria-hidden
+ className={cn(
+ 'size-4',
+ isHeaderDownloadLoading
+ ? 'i-ri-loader-2-line animate-spin motion-reduce:animate-none'
+ : 'i-ri-download-line',
+ )}
+ />
+ </button>
)}
- {detail.sections.map((section) => (
- <div key={section.id} className="px-4">
- <AgentSkillDetailSectionBlock section={section} />
- </div>
- ))}
- </ScrollAreaContent>
- </ScrollAreaViewport>
- <ScrollAreaScrollbar>
- <ScrollAreaThumb />
- </ScrollAreaScrollbar>
- </ScrollArea>
+ <DialogClose
+ render={
+ <IconButton
+ aria-label={tCommon(($) => $['operation.close'])}
+ size="lg"
+ className="shrink-0"
+ >
+ <span aria-hidden className="i-ri-close-line size-4" />
+ </IconButton>
+ }
+ />
+ </div>
+ </div>
+ <ScrollArea className="min-h-0 flex-1 overflow-hidden rounded-br-2xl">
+ <ScrollAreaViewport
+ aria-labelledby={dialogTitleId}
+ className="overscroll-contain"
+ role="region"
+ >
+ <ScrollAreaContent
+ style={{ minWidth: 0 }}
+ className="flex min-h-full w-full max-w-full flex-col gap-2"
+ >
+ {detail.filePreview && (
+ <AgentFilePreviewContent
+ binary={detail.filePreview.binary}
+ content={detail.filePreview.content}
+ downloadActionLoadingTarget={detail.filePreview.downloadActionLoadingTarget}
+ downloadUrl={detail.filePreview.downloadUrl}
+ fileName={detail.filePreview.fileName}
+ imageData={detail.filePreview.imageData}
+ isDownloadError={detail.filePreview.isDownloadError}
+ isDownloadLoading={detail.filePreview.isDownloadLoading}
+ isError={detail.filePreview.isError}
+ isImage={detail.filePreview.isImage}
+ isLoading={detail.filePreview.isLoading}
+ onDownloadFile={detail.onDownloadFile}
+ />
+ )}
+ {detail.sections.map((section) => (
+ <div key={section.id} className="px-4">
+ <AgentSkillDetailSectionBlock section={section} />
+ </div>
+ ))}
+ </ScrollAreaContent>
+ </ScrollAreaViewport>
+ <ScrollAreaScrollbar>
+ <ScrollAreaThumb />
+ </ScrollAreaScrollbar>
+ </ScrollArea>
+ </div>
</div>
</DialogContent>
)
diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/tools/cli-tool/dialog.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/tools/cli-tool/dialog.tsx
index 26345f3ea40..77ce4ad0b02 100644
--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/tools/cli-tool/dialog.tsx
+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/tools/cli-tool/dialog.tsx
@@ -163,7 +163,7 @@ export function CliToolDialog({
return (
<Dialog open={open} onOpenChange={handleOpenChange} disablePointerDismissal>
- <DialogContent className="max-h-[calc(100dvh-2rem)] w-160">
+ <DialogContent className="w-160">
<DialogHeader>
<DialogTitle>
{t(
@@ -180,7 +180,7 @@ export function CliToolDialog({
</DialogDescription>
<DialogCloseButton aria-label={t(($) => $['operation.close'], { ns: 'common' })} />
</DialogHeader>
- <Form<CliToolFormValues> onFormSubmit={handleSubmit}>
+ <Form<CliToolFormValues> className="contents" onFormSubmit={handleSubmit}>
<DialogBody className="flex flex-col gap-4">
<Field name="installCommand">
<FieldLabel>
diff --git a/web/features/agent-v2/roster/components/create-agent-dialog.tsx b/web/features/agent-v2/roster/components/create-agent-dialog.tsx
index ad7dc6c8444..489415cb4b5 100644
--- a/web/features/agent-v2/roster/components/create-agent-dialog.tsx
+++ b/web/features/agent-v2/roster/components/create-agent-dialog.tsx
@@ -62,7 +62,10 @@ function CreateAgentFormSession({
</DialogDescription>
<DialogCloseButton aria-label={tCommon(($) => $['operation.close'])} disabled={pending} />
</DialogHeader>
- <Form<AgentFormValues> onFormSubmit={(formValues) => onSubmit(formValues, agentIcon)}>
+ <Form<AgentFormValues>
+ className="contents"
+ onFormSubmit={(formValues) => onSubmit(formValues, agentIcon)}
+ >
<AgentFormFields
ref={nameInputRef}
defaultValues={createAgentDefaultValues}
@@ -145,7 +148,7 @@ export function CreateAgentDialog({ open, onOpenChange }: CreateAgentDialogProps
</span>
</DialogTrigger>
)}
- <DialogContent initialFocus={nameInputRef} className="max-h-[calc(100dvh-2rem)] w-130">
+ <DialogContent initialFocus={nameInputRef} className="w-130">
<CreateAgentFormSession
nameInputRef={nameInputRef}
pending={createAgentMutation.isPending}
diff --git a/web/features/agent-v2/roster/components/duplicate-agent-dialog.tsx b/web/features/agent-v2/roster/components/duplicate-agent-dialog.tsx
index 4e110fa4c0c..1f98e427932 100644
--- a/web/features/agent-v2/roster/components/duplicate-agent-dialog.tsx
+++ b/web/features/agent-v2/roster/components/duplicate-agent-dialog.tsx
@@ -73,7 +73,10 @@ function DuplicateAgentFormSession({
</DialogDescription>
<DialogCloseButton aria-label={tCommon(($) => $['operation.close'])} disabled={pending} />
</DialogHeader>
- <Form<AgentFormValues> onFormSubmit={(formValues) => onSubmit(formValues, agentIcon)}>
+ <Form<AgentFormValues>
+ className="contents"
+ onFormSubmit={(formValues) => onSubmit(formValues, agentIcon)}
+ >
<AgentFormFields
ref={nameInputRef}
defaultValues={initialValues.fields}
@@ -148,7 +151,7 @@ export function DuplicateAgentDialog({ agent, open, onOpenChange }: DuplicateAge
return (
<>
<Dialog open={open} onOpenChange={handleOpenChange} disablePointerDismissal>
- <DialogContent initialFocus={nameInputRef} className="max-h-[calc(100dvh-2rem)] w-130">
+ <DialogContent initialFocus={nameInputRef} className="w-130">
<DuplicateAgentFormSession
key={latestAgent.id}
agent={latestAgent}
diff --git a/web/features/agent-v2/roster/components/edit-agent-dialog.tsx b/web/features/agent-v2/roster/components/edit-agent-dialog.tsx
index 1d099ec49ff..05b8999701f 100644
--- a/web/features/agent-v2/roster/components/edit-agent-dialog.tsx
+++ b/web/features/agent-v2/roster/components/edit-agent-dialog.tsx
@@ -89,6 +89,7 @@ function EditAgentFormSession({
<DialogCloseButton aria-label={tCommon(($) => $['operation.close'])} disabled={pending} />
</DialogHeader>
<Form<AgentFormValues>
+ className="contents"
onChange={handleFormChange}
onFormSubmit={(formValues) => {
if (hasChanges) onSubmit(formValues, agentIcon)
@@ -160,7 +161,7 @@ export function EditAgentDialog({ agent, open, onOpenChange }: EditAgentDialogPr
return (
<>
<Dialog open={open} onOpenChange={handleOpenChange} disablePointerDismissal>
- <DialogContent initialFocus={nameInputRef} className="max-h-[calc(100dvh-2rem)] w-130">
+ <DialogContent initialFocus={nameInputRef} className="w-130">
<EditAgentFormSession
key={agent.id}
agent={agent}
diff --git a/web/features/skills/detail/restore-version-dialog-content.tsx b/web/features/skills/detail/restore-version-dialog-content.tsx
index 5d467aee406..43856c59cf8 100644
--- a/web/features/skills/detail/restore-version-dialog-content.tsx
+++ b/web/features/skills/detail/restore-version-dialog-content.tsx
@@ -37,7 +37,7 @@ export function RestoreVersionDialogContent({
<AlertDialogCancelButton disabled={isPending}>
{tCommon(($) => $['operation.cancel'])}
</AlertDialogCancelButton>
- <AlertDialogConfirmButton loading={isPending} onClick={onConfirm}>
+ <AlertDialogConfirmButton tone="default" loading={isPending} onClick={onConfirm}>
{t(($) => $['skillManagement.detail.restoreVersion'])}
</AlertDialogConfirmButton>
</AlertDialogFooter>
diff --git a/web/features/skills/detail/sidebar-actions.tsx b/web/features/skills/detail/sidebar-actions.tsx
index 75ab3dedd00..96f4da35910 100644
--- a/web/features/skills/detail/sidebar-actions.tsx
+++ b/web/features/skills/detail/sidebar-actions.tsx
@@ -3,6 +3,7 @@
import type { SkillDetailResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import {
AlertDialog,
+ AlertDialogBody,
AlertDialogCancelButton,
AlertDialogConfirmButton,
AlertDialogContent,
@@ -118,6 +119,7 @@ function SkillDetailDeleteDialog({
>
<AlertDialogContent>
<form
+ className="contents"
onSubmit={(event) => {
event.preventDefault()
handleDelete()
@@ -128,8 +130,10 @@ function SkillDetailDeleteDialog({
{t(($) => $['skillManagement.deleteDialog.title'], { name: detail.display_name })}
</AlertDialogTitle>
<AlertDialogDescription>{description}</AlertDialogDescription>
- {referenceCount > 0 &&
- (referencesQuery.isPending ? (
+ </AlertDialogHeader>
+ {referenceCount > 0 && (
+ <AlertDialogBody className="flex flex-col gap-2">
+ {referencesQuery.isPending ? (
<SkillReferencesListSkeleton compact />
) : (
<SkillReferencesList
@@ -139,8 +143,7 @@ function SkillDetailDeleteDialog({
testId="skill-delete-reference-list"
visibleLimit={5}
/>
- ))}
- {referenceCount > 0 && (
+ )}
<Field name="confirm-skill-name">
<FieldLabel>
<Trans
@@ -176,8 +179,8 @@ function SkillDetailDeleteDialog({
</InputGroupAddon>
</InputGroup>
</Field>
- )}
- </AlertDialogHeader>
+ </AlertDialogBody>
+ )}
<AlertDialogFooter>
<AlertDialogCancelButton disabled={deleteMutation.isPending}>
{tCommon(($) => $['operation.cancel'])}
diff --git a/web/features/skills/page.tsx b/web/features/skills/page.tsx
index af4326131b0..e0e32596ab9 100644
--- a/web/features/skills/page.tsx
+++ b/web/features/skills/page.tsx
@@ -5,6 +5,7 @@ import type { QueryClient } from '@tanstack/react-query'
import type { DragEvent, UIEvent } from 'react'
import {
AlertDialog,
+ AlertDialogBody,
AlertDialogCancelButton,
AlertDialogConfirmButton,
AlertDialogContent,
@@ -329,6 +330,7 @@ function DeleteSkillDialog({
>
<AlertDialogContent>
<form
+ className="contents"
onSubmit={(event) => {
event.preventDefault()
handleDelete()
@@ -339,8 +341,10 @@ function DeleteSkillDialog({
{t(($) => $['skillManagement.deleteDialog.title'], { name: skill.display_name })}
</AlertDialogTitle>
<AlertDialogDescription>{description}</AlertDialogDescription>
- {referenceCount > 0 &&
- (referencesQuery.isPending ? (
+ </AlertDialogHeader>
+ {referenceCount > 0 && (
+ <AlertDialogBody className="flex flex-col gap-2">
+ {referencesQuery.isPending ? (
<SkillReferencesListSkeleton compact />
) : (
<SkillReferencesList
@@ -350,8 +354,7 @@ function DeleteSkillDialog({
testId="skill-delete-reference-list"
visibleLimit={5}
/>
- ))}
- {referenceCount > 0 && (
+ )}
<Field name="confirm-skill-name">
<FieldLabel>
<Trans
@@ -387,8 +390,8 @@ function DeleteSkillDialog({
</InputGroupAddon>
</InputGroup>
</Field>
- )}
- </AlertDialogHeader>
+ </AlertDialogBody>
+ )}
<AlertDialogFooter>
<AlertDialogCancelButton disabled={deleteMutation.isPending}>
{tCommon(($) => $['operation.cancel'])}
@@ -882,6 +885,7 @@ function ImportSkillDialogForm({
return (
<form
+ className="contents"
onSubmit={(event) => {
event.preventDefault()
if (file && !importing) onImport(file)
diff --git a/web/plugins/eslint/hint-content.test.ts b/web/plugins/eslint/hint-content.test.ts
index 820621d0835..d47df9306ab 100644
--- a/web/plugins/eslint/hint-content.test.ts
+++ b/web/plugins/eslint/hint-content.test.ts
@@ -198,7 +198,7 @@ it('keeps centered dialogs on DialogContent while DialogPopup places custom surf
const diagnostics = lintFixture(`
import { DialogContent, DialogPopup } from '@langgenius/dify-ui/dialog'
const examples = <>
- <DialogContent className="flex max-h-[calc(100dvh-2rem)] w-160 flex-col overflow-hidden" />
+ <DialogContent className="max-h-[calc(100dvh-2rem)] w-160 overflow-hidden" />
<DialogPopup className="fixed top-2 right-2 bottom-2 flex w-160 flex-col overflow-hidden rounded-xl" />
<DialogPopup className="fixed top-1/2 left-1/2 w-120 -translate-x-1/2 -translate-y-1/2" />
</>
@@ -207,3 +207,24 @@ it('keeps centered dialogs on DialogContent while DialogPopup places custom surf
for (const className of ['top-1/2', 'left-1/2', '-translate-x-1/2', '-translate-y-1/2'])
expect(diagnostics.some(({ message }) => message.includes(`"${className}"`))).toBe(true)
})
+
+it('keeps centered dialog layout owned by the surface', () => {
+ const diagnostics = lintFixture(`
+ import { DialogContent } from '@langgenius/dify-ui/dialog'
+ import { AlertDialogContent } from '@langgenius/dify-ui/alert-dialog'
+ const examples = <>
+ <DialogContent className="flex flex-col" />
+ <AlertDialogContent className="flex flex-col" />
+ </>
+ `)
+ expect(diagnostics).toHaveLength(4)
+ for (const component of ['DialogContent', 'AlertDialogContent']) {
+ for (const className of ['flex', 'flex-col']) {
+ expect(
+ diagnostics.some(
+ ({ message }) => message.includes(`"${className}"`) && message.includes(component),
+ ),
+ ).toBe(true)
+ }
+ }
+})