Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
feat(ui): support Button variants in toast actions (#44651)
yyhf8fa851a0290
diff --git a/packages/dify-ui/src/toast/index.stories.tsx b/packages/dify-ui/src/toast/index.stories.tsxindex 0b87992624c..3e63ffed12a 100644--- a/packages/dify-ui/src/toast/index.stories.tsx+++ b/packages/dify-ui/src/toast/index.stories.tsx@@ -1,5 +1,6 @@import type { Meta, StoryObj } from '@storybook/react-vite'import type { ToastType } from '.'+import type { ButtonProps } from '../button'import * as React from 'react'import { expect, waitFor, within } from 'storybook/test'import { createToast, createToastManager, Toaster } from '.'@@ -189,7 +190,7 @@ export const VaryingHeights: Story = {},}-function ActionExample() {+function ActionExample({ variant }: Pick<ButtonProps, 'variant'>) {const [manager] = React.useState(createToastManager)const toast = createToast(manager)@@ -198,6 +199,7 @@ function ActionExample() {description: 'You can restore the project with Undo.',actionProps: {children: 'Undo',+ variant,onClick: () => {toast.dismiss(id)toast.success('Project restored')@@ -214,22 +216,34 @@ function ActionExample() {)}-export const WithAction: Story = {+export const WithAction: StoryObj<typeof ActionExample> = {+ args: { variant: 'primary' },+ argTypes: {+ variant: {+ control: 'select',+ options: ['primary', 'secondary', 'secondary-accent', 'tertiary', 'ghost', 'ghost-accent'],+ },+ },parameters: {- controls: { disable: true },+ controls: { include: ['variant'] },docs: {description: {story:- 'Use `actionProps` for a notification action. The caller closes the original notification when Undo completes.',+ 'Use `actionProps` for a notification action and choose a Button `variant`. Omitting the variant uses Button’s secondary default. Toast owns the spacing; Button owns the appearance. The caller closes the original notification when Undo completes.',},},},- render: () => <ActionExample />,+ render: (args) => <ActionExample {...args} />,play: async ({ canvas, canvasElement, userEvent }) => {const body = within(canvasElement.ownerDocument.body)await userEvent.click(canvas.getByRole('button', { name: 'Archive project' }))const archived = await body.findByRole('dialog', { name: 'Project archived' })- await userEvent.click(within(archived).getByRole('button', { name: 'Undo' }))+ await userEvent.keyboard('{F6}')+ await userEvent.tab()+ await expect(archived).toHaveFocus()+ await userEvent.tab()+ await expect(within(archived).getByRole('button', { name: 'Undo' })).toHaveFocus()+ await userEvent.keyboard('{Enter}')const restored = await body.findByRole('dialog', { name: 'Project restored' })await waitFor(() => expect(restored).toBeVisible())await waitFor(() => expect(archived).not.toBeInTheDocument())diff --git a/packages/dify-ui/src/toast/index.tsx b/packages/dify-ui/src/toast/index.tsxindex 2ff8234fea7..fb17d52f650 100644--- a/packages/dify-ui/src/toast/index.tsx+++ b/packages/dify-ui/src/toast/index.tsx@@ -7,7 +7,9 @@ import type {ToastObject,} from '@base-ui/react/toast'import type * as React from 'react'+import type { ButtonProps } from '../button'import { Toast as BaseToast } from '@base-ui/react/toast'+import { Button } from '../button'import { cn } from '../cn'import { iconButtonVariants } from '../icon-button'import { focusRingClassName } from '../internal/focus'@@ -18,10 +20,13 @@ type ToastType = 'success' | 'error' | 'warning' | 'info'const toastCloseLabel = 'Close notification'+type ToastActionProps = React.ComponentPropsWithoutRef<'button'> & Pick<ButtonProps, 'variant'>+type ToastAddOptions = Omit<ToastManagerAddOptions<ToastData>,'data' | 'positionerProps' | 'type'> & {+ actionProps?: ToastActionPropstype?: ToastType}@@ -29,6 +34,7 @@ type ToastUpdateOptions = Omit<ToastManagerUpdateOptions<ToastData>,'data' | 'positionerProps' | 'type'> & {+ actionProps?: ToastActionPropstype?: ToastType}@@ -194,13 +200,7 @@ function ToastCard({ toast: toastItem, children }: ToastCardProps) {<div className="min-w-0 flex-1 p-1"><BaseToast.Title className="min-w-0 system-sm-semibold wrap-break-word text-text-primary" /><BaseToast.Description className="mt-1 min-w-0 system-xs-regular wrap-break-word text-text-secondary" />- <BaseToast.Action- className={cn(- 'mt-2 mb-1 flex w-fit items-center justify-center overflow-hidden rounded-md border-[0.5px] border-components-button-secondary-border bg-components-button-secondary-bg px-3 py-2 system-sm-medium text-components-button-secondary-text shadow-xs shadow-shadow-shadow-3 backdrop-blur-[5px]',- focusRingClassName,- 'hover:bg-state-base-hover focus-visible:bg-state-base-hover',- )}- />+ <BaseToast.Action render={<Button />} className="mt-2" /></div>{children}<div className="flex shrink-0 items-center justify-center rounded-md p-0.5">