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(web): move knowledge, billing and skill banners to dify-ui Alert (#45268)

yyhc4e011609647
diff --git a/oxlint-suppressions.json b/oxlint-suppressions.json
index 4d53c7e45f8..8441f4a5e01 100644
--- a/oxlint-suppressions.json
+++ b/oxlint-suppressions.json
@@ -2238,11 +2238,6 @@
"count": 1
}
},
- "web/app/components/datasets/create/website/base/error-message.tsx": {
- "better-tailwindcss/enforce-logical-properties": {
- "count": 2
- }
- },
"web/app/components/datasets/create/website/base/field.tsx": {
"better-tailwindcss/enforce-logical-properties": {
"count": 2
@@ -6410,7 +6405,7 @@
},
"web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/upload-dialog.tsx": {
"better-tailwindcss/enforce-logical-properties": {
- "count": 6
+ "count": 5
}
},
"web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/use-skill-detail.ts": {
diff --git a/web/app/components/billing/vector-space-unavailable/index.tsx b/web/app/components/billing/vector-space-unavailable/index.tsx
index ac0470622fe..59930659541 100644
--- a/web/app/components/billing/vector-space-unavailable/index.tsx
+++ b/web/app/components/billing/vector-space-unavailable/index.tsx
@@ -1,5 +1,6 @@
'use client'
+import { Alert, AlertActions, AlertTitle } from '@langgenius/dify-ui/alert'
import { Button } from '@langgenius/dify-ui/button'
import { useTranslation } from 'react-i18next'
@@ -12,19 +13,17 @@ const VectorSpaceUnavailable = ({ isRetrying, onRetry }: Props) => {
const { t } = useTranslation(['billing', 'common'])
return (
- <div
- role="alert"
- className="flex items-center gap-2 rounded-xl border border-state-destructive-border bg-state-destructive-hover-alt p-3"
- >
- <span className="i-ri-error-warning-fill size-4 shrink-0 text-text-destructive" />
- <div className="grow system-sm-medium text-text-destructive">
+ <Alert type="error">
+ <AlertTitle>
{t(($) => $['usagePage.vectorSpace'], { ns: 'billing' })}:{' '}
{t(($) => $['plansCommon.unavailable'], { ns: 'billing' })}
- </div>
- <Button size="small" variant="secondary" loading={isRetrying} onClick={onRetry}>
- {t(($) => $['operation.retry'], { ns: 'common' })}
- </Button>
- </div>
+ </AlertTitle>
+ <AlertActions>
+ <Button size="small" loading={isRetrying} onClick={onRetry}>
+ {t(($) => $['operation.retry'], { ns: 'common' })}
+ </Button>
+ </AlertActions>
+ </Alert>
)
}
diff --git a/web/app/components/datasets/common/retrieval-param-config/index.tsx b/web/app/components/datasets/common/retrieval-param-config/index.tsx
index 817e9fdc8c2..c1d7c968d8a 100644
--- a/web/app/components/datasets/common/retrieval-param-config/index.tsx
+++ b/web/app/components/datasets/common/retrieval-param-config/index.tsx
@@ -1,6 +1,7 @@
'use client'
import type { FC } from 'react'
import type { RetrievalConfig } from '@/types/app'
+import { Alert, AlertTitle } from '@langgenius/dify-ui/alert'
import { cn } from '@langgenius/dify-ui/cn'
import { Infotip, InfotipContent, InfotipTrigger } from '@langgenius/dify-ui/infotip'
import { RadioGroup } from '@langgenius/dify-ui/radio-group'
@@ -166,18 +167,11 @@ const RetrievalParamConfig: FC<Props> = ({
disabled={disabled}
/>
{showMultiModalTip && (
- <div className="mt-2 flex h-10 items-center gap-x-0.5 overflow-hidden rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur p-2 shadow-xs backdrop-blur-[5px]">
- <div className="absolute inset-0 bg-dataset-warning-message-bg opacity-40" />
- <div className="p-1">
- <span
- aria-hidden
- className="i-custom-vender-solid-alertsAndFeedback-alert-triangle size-4 text-text-warning-secondary"
- />
- </div>
- <span className="system-xs-medium text-text-primary">
+ <Alert type="warning" className="mt-2">
+ <AlertTitle>
{t(($) => $['form.retrievalSetting.multiModalTip'], { ns: 'datasetSettings' })}
- </span>
- </div>
+ </AlertTitle>
+ </Alert>
)}
</>
)}
@@ -302,18 +296,11 @@ const RetrievalParamConfig: FC<Props> = ({
disabled={disabled}
/>
{showMultiModalTip && (
- <div className="mt-2 flex h-10 items-center gap-x-0.5 overflow-hidden rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur p-2 shadow-xs backdrop-blur-[5px]">
- <div className="absolute inset-0 bg-dataset-warning-message-bg opacity-40" />
- <div className="p-1">
- <span
- aria-hidden
- className="i-custom-vender-solid-alertsAndFeedback-alert-triangle size-4 text-text-warning-secondary"
- />
- </div>
- <span className="system-xs-medium text-text-primary">
+ <Alert type="warning" className="mt-2">
+ <AlertTitle>
{t(($) => $['form.retrievalSetting.multiModalTip'], { ns: 'datasetSettings' })}
- </span>
- </div>
+ </AlertTitle>
+ </Alert>
)}
</>
)}
diff --git a/web/app/components/datasets/common/vector-space-admission-alert.tsx b/web/app/components/datasets/common/vector-space-admission-alert.tsx
index 0102d17f044..90b3193dee7 100644
--- a/web/app/components/datasets/common/vector-space-admission-alert.tsx
+++ b/web/app/components/datasets/common/vector-space-admission-alert.tsx
@@ -1,3 +1,4 @@
+import { Alert, AlertActions, AlertDescription, AlertTitle } from '@langgenius/dify-ui/alert'
import { useTranslation } from 'react-i18next'
import UpgradeBtn from '@/app/components/billing/upgrade-btn'
@@ -15,27 +16,25 @@ const VectorSpaceAdmissionAlert = ({
const { t } = useTranslation(['datasetDocuments'])
return (
- <div
- role="alert"
- className="flex items-start gap-2 rounded-xl border border-state-destructive-border bg-state-destructive-hover-alt p-3"
- >
- <span className="mt-0.5 i-ri-error-warning-fill size-4 shrink-0 text-text-destructive" />
- <div className="grow">
- <div className="system-sm-semibold text-text-destructive">
- {t(($) => $['embedding.vectorSpaceEstimateExceeded.title'], {
- ns: 'datasetDocuments',
- })}
- </div>
- <div className="mt-0.5 body-xs-regular text-text-secondary">
- {t(($) => $['embedding.vectorSpaceEstimateExceeded.description'], {
- ns: 'datasetDocuments',
- estimated: estimatedMb,
- limit: planLimitMb,
- })}
- </div>
- </div>
- {showUpgrade && <UpgradeBtn loc="knowledge-vector-space-admission" />}
- </div>
+ <Alert type="error">
+ <AlertTitle>
+ {t(($) => $['embedding.vectorSpaceEstimateExceeded.title'], {
+ ns: 'datasetDocuments',
+ })}
+ </AlertTitle>
+ <AlertDescription>
+ {t(($) => $['embedding.vectorSpaceEstimateExceeded.description'], {
+ ns: 'datasetDocuments',
+ estimated: estimatedMb,
+ limit: planLimitMb,
+ })}
+ </AlertDescription>
+ {showUpgrade && (
+ <AlertActions>
+ <UpgradeBtn size="s" loc="knowledge-vector-space-admission" />
+ </AlertActions>
+ )}
+ </Alert>
)
}
diff --git a/web/app/components/datasets/create/step-two/__tests__/index.spec.tsx b/web/app/components/datasets/create/step-two/__tests__/index.spec.tsx
index 07a01dfe728..6f41aed1718 100644
--- a/web/app/components/datasets/create/step-two/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/create/step-two/__tests__/index.spec.tsx
@@ -433,7 +433,7 @@ it.each([
}),
)
expect(screen.getByRole('button', { name: nextName })).toBeInTheDocument()
- expect(screen.getByRole('status')).toHaveTextContent('common.loading')
+ expect(screen.getByText('common.loading').closest('[role="status"]')).toBeInTheDocument()
expect(screen.queryByText('Previewed chunk')).not.toBeInTheDocument()
await act(async () =>
pending.resolve({
diff --git a/web/app/components/datasets/create/step-two/components/general-chunking-options.tsx b/web/app/components/datasets/create/step-two/components/general-chunking-options.tsx
index 6a37409efbb..40097769238 100644
--- a/web/app/components/datasets/create/step-two/components/general-chunking-options.tsx
+++ b/web/app/components/datasets/create/step-two/components/general-chunking-options.tsx
@@ -3,11 +3,12 @@
import type { PreProcessingRule } from '@dify/contracts/api/console/datasets/types.gen'
import type { FC, MouseEventHandler } from 'react'
import type { SummaryIndexSetting as SummaryIndexSettingType } from '@/models/datasets'
+import { Alert, AlertTitle } from '@langgenius/dify-ui/alert'
import { Button } from '@langgenius/dify-ui/button'
import { Checkbox } from '@langgenius/dify-ui/checkbox'
import { Infotip, InfotipContent, InfotipTrigger } from '@langgenius/dify-ui/infotip'
import { Separator } from '@langgenius/dify-ui/separator'
-import { RiAlertFill, RiSearchEyeLine } from '@remixicon/react'
+import { RiSearchEyeLine } from '@remixicon/react'
import { useSuspenseQuery } from '@tanstack/react-query'
import { useId } from 'react'
import { useTranslation } from 'react-i18next'
@@ -198,18 +199,11 @@ export const GeneralChunkingOptions: FC<GeneralChunkingOptionsProps> = ({
</Infotip>
</div>
{currentDocForm === ChunkingMode.qa && (
- <div
- style={{
- background:
- 'linear-gradient(92deg, rgba(247, 144, 9, 0.1) 0%, rgba(255, 255, 255, 0.00) 100%)',
- }}
- className="mt-2 flex min-h-10 items-center gap-2 rounded-xl border border-components-panel-border px-3 text-xs shadow-xs backdrop-blur-[5px]"
- >
- <RiAlertFill className="size-4 text-text-warning-secondary" />
- <span className="system-xs-medium text-text-primary">
+ <Alert type="warning" className="mt-2">
+ <AlertTitle>
{t(($) => $['stepTwo.QATip'], { ns: 'datasetCreation' })}
- </span>
- </div>
+ </AlertTitle>
+ </Alert>
)}
</>
)}
diff --git a/web/app/components/datasets/create/step-two/components/indexing-mode-section.tsx b/web/app/components/datasets/create/step-two/components/indexing-mode-section.tsx
index 7c399fce58c..3a5b3868aa2 100644
--- a/web/app/components/datasets/create/step-two/components/indexing-mode-section.tsx
+++ b/web/app/components/datasets/create/step-two/components/indexing-mode-section.tsx
@@ -3,6 +3,7 @@ import type { ProviderWithModelsResponse } from '@dify/contracts/api/console/wor
import type { FC } from 'react'
import type { DefaultModel } from '@/app/components/header/account-setting/model-provider-page/declarations'
import type { RetrievalConfig } from '@/types/app'
+import { Alert, AlertTitle } from '@langgenius/dify-ui/alert'
import {
AlertDialog,
AlertDialogCancelButton,
@@ -171,15 +172,11 @@ export const IndexingModeSection: FC<IndexingModeSectionProps> = ({
{/* High quality tip */}
{!hasSetIndexType && indexType === IndexingType.QUALIFIED && (
- <div className="mt-2 flex min-h-10 items-center gap-x-0.5 overflow-hidden rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur p-2 shadow-xs backdrop-blur-[5px]">
- <div className="absolute inset-0 bg-dataset-warning-message-bg opacity-40"></div>
- <div className="p-1">
- <span className="size-4 text-text-warning-secondary" />
- </div>
- <span className="system-xs-medium text-text-primary">
+ <Alert type="warning" className="mt-2">
+ <AlertTitle>
{t(($) => $['stepTwo.highQualityTip'], { ns: 'datasetCreation' })}
- </span>
- </div>
+ </AlertTitle>
+ </Alert>
)}
{/* Economical index setting tip */}
diff --git a/web/app/components/datasets/create/website/base/error-message.tsx b/web/app/components/datasets/create/website/base/error-message.tsx
index ea5a4ef9c47..656907d6c52 100644
--- a/web/app/components/datasets/create/website/base/error-message.tsx
+++ b/web/app/components/datasets/create/website/base/error-message.tsx
@@ -1,6 +1,6 @@
'use client'
import type { FC } from 'react'
-import { cn } from '@langgenius/dify-ui/cn'
+import { Alert, AlertDescription, AlertTitle } from '@langgenius/dify-ui/alert'
import * as React from 'react'
type Props = Readonly<{
@@ -11,23 +11,10 @@ type Props = Readonly<{
const ErrorMessage: FC<Props> = ({ className, title, errorMsg }) => {
return (
- <div
- className={cn(
- className,
- 'border-t border-divider-subtle bg-dataset-warning-message-bg px-4 py-2 opacity-40',
- )}
- >
- <div className="flex h-5 items-center">
- <span
- aria-hidden
- className="mr-2 i-custom-vender-solid-alertsAndFeedback-alert-triangle size-4 text-text-warning-secondary"
- />
- <div className="system-md-medium text-text-warning">{title}</div>
- </div>
- {errorMsg && (
- <div className="mt-1 pl-6 system-xs-regular text-text-secondary">{errorMsg}</div>
- )}
- </div>
+ <Alert type="error" className={className}>
+ <AlertTitle>{title}</AlertTitle>
+ {errorMsg && <AlertDescription>{errorMsg}</AlertDescription>}
+ </Alert>
)
}
export default React.memo(ErrorMessage)
diff --git a/web/app/components/datasets/create/website/firecrawl/index.tsx b/web/app/components/datasets/create/website/firecrawl/index.tsx
index d5b9f3f8e1b..5d2af449b3d 100644
--- a/web/app/components/datasets/create/website/firecrawl/index.tsx
+++ b/web/app/components/datasets/create/website/firecrawl/index.tsx
@@ -237,7 +237,7 @@ const FireCrawl: FC<Props> = ({
)}
{showError && (
<ErrorMessage
- className="rounded-b-xl"
+ className="mx-4 mt-2 mb-4"
title={t(($) => $[`${I18N_PREFIX}.exceptionErrorTitle`], { ns: 'datasetCreation' })}
errorMsg={crawlErrorMessage}
/>
diff --git a/web/app/components/datasets/create/website/jina-reader/index.tsx b/web/app/components/datasets/create/website/jina-reader/index.tsx
index 3c3930f30b2..2d6d74154a7 100644
--- a/web/app/components/datasets/create/website/jina-reader/index.tsx
+++ b/web/app/components/datasets/create/website/jina-reader/index.tsx
@@ -223,7 +223,7 @@ const JinaReader: FC<Props> = ({
)}
{showError && (
<ErrorMessage
- className="rounded-b-xl"
+ className="mx-4 mt-2 mb-4"
title={t(($) => $[`${I18N_PREFIX}.exceptionErrorTitle`], { ns: 'datasetCreation' })}
errorMsg={crawlErrorMessage}
/>
diff --git a/web/app/components/datasets/create/website/watercrawl/index.tsx b/web/app/components/datasets/create/website/watercrawl/index.tsx
index 593475bfba3..81df7d0222f 100644
--- a/web/app/components/datasets/create/website/watercrawl/index.tsx
+++ b/web/app/components/datasets/create/website/watercrawl/index.tsx
@@ -209,7 +209,7 @@ const WaterCrawl: FC<Props> = ({
)}
{showError && (
<ErrorMessage
- className="rounded-b-xl"
+ className="mx-4 mt-2 mb-4"
title={t(($) => $[`${I18N_PREFIX}.exceptionErrorTitle`], { ns: 'datasetCreation' })}
errorMsg={crawlErrorMessage}
/>
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/error-message.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/error-message.tsx
index a1f0efa285d..8f65cbf9c9c 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/error-message.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/website-crawl/base/error-message.tsx
@@ -1,5 +1,4 @@
-import { cn } from '@langgenius/dify-ui/cn'
-import { RiErrorWarningFill } from '@remixicon/react'
+import { Alert, AlertDescription, AlertTitle } from '@langgenius/dify-ui/alert'
import * as React from 'react'
type ErrorMessageProps = {
@@ -10,20 +9,10 @@ type ErrorMessageProps = {
const ErrorMessage = ({ className, title, errorMsg }: ErrorMessageProps) => {
return (
- <div
- className={cn(
- 'flex gap-x-0.5 rounded-xl border-[0.5px] border-components-panel-border bg-toast-error-bg p-2 shadow-xs shadow-shadow-shadow-3',
- className,
- )}
- >
- <div className="flex size-6 items-center justify-center">
- <RiErrorWarningFill className="size-4 text-text-destructive" />
- </div>
- <div className="flex flex-col gap-y-0.5 py-1">
- <div className="system-xs-medium text-text-primary">{title}</div>
- {errorMsg && <div className="system-xs-regular text-text-secondary">{errorMsg}</div>}
- </div>
- </div>
+ <Alert type="error" className={className}>
+ <AlertTitle>{title}</AlertTitle>
+ {errorMsg && <AlertDescription>{errorMsg}</AlertDescription>}
+ </Alert>
)
}
export default React.memo(ErrorMessage)
diff --git a/web/app/components/datasets/settings/form/components/indexing-section.tsx b/web/app/components/datasets/settings/form/components/indexing-section.tsx
index d6ed804ef27..70ec20a667d 100644
--- a/web/app/components/datasets/settings/form/components/indexing-section.tsx
+++ b/web/app/components/datasets/settings/form/components/indexing-section.tsx
@@ -4,6 +4,7 @@ import type { ProviderWithModelsResponse } from '@dify/contracts/api/console/wor
import type { DefaultModel } from '@/app/components/header/account-setting/model-provider-page/declarations'
import type { SummaryIndexSetting as SummaryIndexSettingType } from '@/models/datasets'
import type { RetrievalConfig } from '@/types/app'
+import { Alert, AlertTitle } from '@langgenius/dify-ui/alert'
import { Separator } from '@langgenius/dify-ui/separator'
import { useSuspenseQuery } from '@tanstack/react-query'
import { useId } from 'react'
@@ -143,18 +144,11 @@ const IndexingSection = ({
onKeywordNumberChange={setKeywordNumber}
/>
{showUpgradeWarning && (
- <div className="relative mt-2 flex min-h-10 items-start gap-x-0.5 rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur px-2 py-2 shadow-xs shadow-shadow-shadow-3">
- <div className="pointer-events-none absolute inset-0 rounded-xl bg-toast-warning-bg opacity-40" />
- <div className="relative shrink-0 p-1">
- <span
- aria-hidden
- className="i-ri-alert-fill size-4 text-text-warning-secondary"
- />
- </div>
- <span className="relative min-w-0 py-1 system-xs-medium wrap-anywhere text-text-primary">
+ <Alert type="warning" className="mt-2">
+ <AlertTitle>
{t(($) => $['form.upgradeHighQualityTip'], { ns: 'datasetSettings' })}
- </span>
- </div>
+ </AlertTitle>
+ </Alert>
)}
</div>
</div>
diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/upload-dialog.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/upload-dialog.tsx
index 973ac3aa7a4..3c02d72f1be 100644
--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/upload-dialog.tsx
+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/upload-dialog.tsx
@@ -5,6 +5,7 @@ import type { PostAppsByAppIdAgentConfigSkillsUploadResponse } from '@dify/contr
import type { ChangeEvent, DragEvent } from 'react'
import type { AgentConfigApiContext } from '../config-context'
import type { AgentSkill } from '@/features/agent-v2/agent-composer/form-state'
+import { Alert, AlertTitle } from '@langgenius/dify-ui/alert'
import { Button } from '@langgenius/dify-ui/button'
import { cn } from '@langgenius/dify-ui/cn'
import {
@@ -219,31 +220,29 @@ function AgentSkillPackageUploader({
})}
</p>
{showWarning && (
- <div className="mt-2 flex items-start gap-2 rounded-lg border-[0.5px] border-components-badge-status-light-warning-halo bg-state-warning-hover px-3 py-2.5">
- <span
- aria-hidden
- className="mt-0.5 i-ri-alert-fill size-4 shrink-0 text-text-warning-secondary"
- />
- <ul className="list-disc space-y-1 pl-4 system-xs-regular text-text-warning">
- <li>
- <Trans
- i18nKey={($) => $['agentDetail.configure.skills.upload.warning.specification']}
- ns="agentV2"
- components={{
- specificationLink: (
- <Link
- href="https://agentskills.io/specification"
- target="_blank"
- rel="noopener noreferrer"
- className="rounded-sm underline focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"
- />
- ),
- }}
- />
- </li>
- <li>{t(($) => $['agentDetail.configure.skills.upload.warning.files'])}</li>
- </ul>
- </div>
+ <Alert type="warning" className="mt-2">
+ <AlertTitle>
+ <ul className="list-disc space-y-1 ps-4">
+ <li>
+ <Trans
+ i18nKey={($) => $['agentDetail.configure.skills.upload.warning.specification']}
+ ns="agentV2"
+ components={{
+ specificationLink: (
+ <Link
+ href="https://agentskills.io/specification"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="rounded-sm underline focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"
+ />
+ ),
+ }}
+ />
+ </li>
+ <li>{t(($) => $['agentDetail.configure.skills.upload.warning.files'])}</li>
+ </ul>
+ </AlertTitle>
+ </Alert>
)}
</div>
)
diff --git a/web/features/new-rag/components/knowledge-model-readiness-banner.tsx b/web/features/new-rag/components/knowledge-model-readiness-banner.tsx
index b87d2453df0..868f2b9d327 100644
--- a/web/features/new-rag/components/knowledge-model-readiness-banner.tsx
+++ b/web/features/new-rag/components/knowledge-model-readiness-banner.tsx
@@ -1,17 +1,14 @@
'use client'
import type { KnowledgeModelCapability } from '../routes'
-import { Button } from '@langgenius/dify-ui/button'
+import { Alert, AlertActions, AlertDescription, AlertTitle } from '@langgenius/dify-ui/alert'
+import { Button, buttonVariants } from '@langgenius/dify-ui/button'
import { useQuery } from '@tanstack/react-query'
import { useTranslation } from 'react-i18next'
import Link from '@/next/link'
import { usePathname, useSearchParams } from '@/next/navigation'
import { consoleQuery } from '@/service/console'
import { newKnowledgeSettingsReturnPath } from '../routes'
-import {
- knowledgeModelReadinessActionClassName,
- KnowledgeModelReadinessNotice,
-} from './knowledge-model-readiness-notice'
export function KnowledgeModelReadinessBanner({
capability,
@@ -52,25 +49,23 @@ export function KnowledgeModelReadinessBanner({
: t(($) => $['overview.attention.modelReadiness.profilesMissing'])
return (
- <KnowledgeModelReadinessNotice
- action={
- query.isError ? (
+ <Alert type={isFailure ? 'error' : 'warning'} className={className}>
+ <AlertTitle>{title}</AlertTitle>
+ {description && <AlertDescription>{description}</AlertDescription>}
+ <AlertActions>
+ {query.isError ? (
<Button size="small" onClick={() => void query.refetch()}>
{tCommon(($) => $['operation.retry'])}
</Button>
) : (
<Link
- className={knowledgeModelReadinessActionClassName}
+ className={buttonVariants({ size: 'small' })}
href={newKnowledgeSettingsReturnPath(knowledgeSpaceId, { capability, returnTo })}
>
{t(($) => $['overview.attention.action.configureModels'], { ns: 'knowledgeSpace' })}
</Link>
- )
- }
- className={className}
- description={description}
- title={title}
- tone={isFailure ? 'destructive' : 'warning'}
- />
+ )}
+ </AlertActions>
+ </Alert>
)
}
diff --git a/web/features/new-rag/components/knowledge-model-readiness-notice.tsx b/web/features/new-rag/components/knowledge-model-readiness-notice.tsx
deleted file mode 100644
index 5e66188b485..00000000000
--- a/web/features/new-rag/components/knowledge-model-readiness-notice.tsx
+++ /dev/null
@@ -1,54 +0,0 @@
-import type { ReactNode } from 'react'
-import { cn } from '@langgenius/dify-ui/cn'
-
-export type KnowledgeModelReadinessTone = 'destructive' | 'warning'
-
-export const knowledgeModelReadinessActionClassName =
- 'shrink-0 cursor-pointer rounded-sm system-sm-medium text-text-accent outline-hidden hover:underline focus-visible:ring-2 focus-visible:ring-state-accent-solid'
-
-export function KnowledgeModelReadinessNotice({
- action,
- className,
- description,
- title,
- tone,
-}: {
- action?: ReactNode
- className?: string
- description?: ReactNode
- title: ReactNode
- tone: KnowledgeModelReadinessTone
-}) {
- const isDestructive = tone === 'destructive'
-
- return (
- <div
- className={cn(
- 'flex items-center gap-2.5 overflow-hidden rounded-lg px-3.5 py-2.5',
- isDestructive ? 'bg-state-destructive-hover' : 'bg-state-warning-hover',
- className,
- )}
- role={isDestructive ? 'alert' : 'status'}
- >
- <span
- aria-hidden
- className={cn(
- 'size-4 shrink-0',
- isDestructive
- ? 'i-ri-error-warning-fill text-text-destructive'
- : 'i-ri-error-warning-fill text-text-warning',
- )}
- />
- <p className="min-w-0 flex-1 system-sm-regular text-text-secondary">
- {title}
- {description != null && description !== false && (
- <>
- <span aria-hidden> — </span>
- {description}
- </>
- )}
- </p>
- {action}
- </div>
- )
-}
diff --git a/web/features/new-rag/components/model-cost-notice.tsx b/web/features/new-rag/components/model-cost-notice.tsx
index a47b06a5a35..cbbd3a371d2 100644
--- a/web/features/new-rag/components/model-cost-notice.tsx
+++ b/web/features/new-rag/components/model-cost-notice.tsx
@@ -1,6 +1,7 @@
'use client'
import type { ReactNode } from 'react'
+import { Alert, AlertDescription, AlertTitle } from '@langgenius/dify-ui/alert'
import { cn } from '@langgenius/dify-ui/cn'
import { useId } from 'react'
import { useTranslation } from 'react-i18next'
@@ -26,21 +27,12 @@ export function ModelCostNotice({
{summary != null && summary !== false && (
<p className="system-sm-medium text-text-secondary">{summary}</p>
)}
- <section
- aria-labelledby={titleId}
- className="flex gap-2.5 rounded-lg bg-state-warning-hover px-3.5 py-2.5"
- >
- <span
- aria-hidden
- className="mt-0.5 i-ri-error-warning-fill size-4 shrink-0 text-text-warning"
- />
- <div className="min-w-0 flex-1">
- <h3 id={titleId} className="system-sm-semibold text-text-primary">
- {t(($) => $['modelCost.title'], { ns: 'knowledgeSpace' })}
- </h3>
- <p className="mt-0.5 system-xs-regular text-text-secondary">{description}</p>
- </div>
- </section>
+ <Alert type="warning" role="region" aria-labelledby={titleId}>
+ <AlertTitle id={titleId}>
+ {t(($) => $['modelCost.title'], { ns: 'knowledgeSpace' })}
+ </AlertTitle>
+ <AlertDescription>{description}</AlertDescription>
+ </Alert>
</div>
)
}
diff --git a/web/features/new-rag/documents/detail/status.tsx b/web/features/new-rag/documents/detail/status.tsx
index 077caedc863..b3819d2300c 100644
--- a/web/features/new-rag/documents/detail/status.tsx
+++ b/web/features/new-rag/documents/detail/status.tsx
@@ -1,3 +1,4 @@
+import { Alert, AlertActions, AlertTitle } from '@langgenius/dify-ui/alert'
import { Button } from '@langgenius/dify-ui/button'
import { useAtomValueRawSync, useSetAtom } from 'jotai'
import { useEffect, useRef } from 'react'
@@ -58,28 +59,25 @@ export function DocumentTaskNotices({ onViewTasks }: { onViewTasks: () => void }
</div>
)}
{latestTask?.state === 'failed' && (
- <div
- className="mt-4 flex items-center gap-2 rounded-lg bg-state-destructive-hover px-3 py-2 system-xs-regular text-text-destructive"
- role="alert"
- >
- <span aria-hidden className="i-ri-error-warning-fill size-4 shrink-0" />
- <span className="min-w-0 flex-1">
- {t(($) => $.documentReindexFailed, { ns: 'knowledgeDocuments' })}
- </span>
- <Button size="small" variant="ghost" onClick={onViewTasks}>
- {t(($) => $.viewTask, { ns: 'knowledgeDocuments' })}
- </Button>
- </div>
+ <Alert type="error" className="mt-4">
+ <AlertTitle>{t(($) => $.documentReindexFailed, { ns: 'knowledgeDocuments' })}</AlertTitle>
+ <AlertActions>
+ <Button size="small" onClick={onViewTasks}>
+ {t(($) => $.viewTask, { ns: 'knowledgeDocuments' })}
+ </Button>
+ </AlertActions>
+ </Alert>
)}
{tasksError && (
- <div
- className="mt-4 flex flex-wrap items-center justify-between gap-2 rounded-lg bg-state-warning-hover px-3 py-2 system-xs-regular text-text-warning"
- role="alert"
- >
- <span>{t(($) => $.tasksErrorDescription)}</span>
- <Button onClick={() => void retryTasks()}>{tCommon(($) => $['operation.retry'])}</Button>
- </div>
+ <Alert type="warning" role="alert" className="mt-4">
+ <AlertTitle>{t(($) => $.tasksErrorDescription)}</AlertTitle>
+ <AlertActions>
+ <Button size="small" onClick={() => void retryTasks()}>
+ {tCommon(($) => $['operation.retry'])}
+ </Button>
+ </AlertActions>
+ </Alert>
)}
</>
)
@@ -104,23 +102,23 @@ export function DocumentPermissionRecoveryNotice() {
if (!permissionRecoveryNeeded) return null
return (
- <div
- className="mt-4 flex flex-wrap items-center justify-between gap-2 rounded-lg bg-state-warning-hover px-3 py-2 system-xs-regular text-text-warning"
- role="alert"
- >
- <span>{t(($) => $.documentPermissionRestricted)}</span>
- <Button
- ref={permissionRetryRef}
- loading={permissionRecoveryBusy}
- onClick={() =>
- void retryWritePermission(refreshWritePermission).then((recovered) => {
- if (recovered) focusDocumentDetailTitle()
- else permissionRetryRef.current?.focus()
- })
- }
- >
- {tCommon(($) => $['operation.retry'])}
- </Button>
- </div>
+ <Alert type="warning" role="alert" className="mt-4">
+ <AlertTitle>{t(($) => $.documentPermissionRestricted)}</AlertTitle>
+ <AlertActions>
+ <Button
+ size="small"
+ ref={permissionRetryRef}
+ loading={permissionRecoveryBusy}
+ onClick={() =>
+ void retryWritePermission(refreshWritePermission).then((recovered) => {
+ if (recovered) focusDocumentDetailTitle()
+ else permissionRetryRef.current?.focus()
+ })
+ }
+ >
+ {tCommon(($) => $['operation.retry'])}
+ </Button>
+ </AlertActions>
+ </Alert>
)
}
diff --git a/web/features/new-rag/quality/quality-evaluation-panel.tsx b/web/features/new-rag/quality/quality-evaluation-panel.tsx
index 640dbfba6b7..16d78512c15 100644
--- a/web/features/new-rag/quality/quality-evaluation-panel.tsx
+++ b/web/features/new-rag/quality/quality-evaluation-panel.tsx
@@ -5,6 +5,7 @@ import type {
KnowledgeFsQualityReplayResponse,
} from '@dify/contracts/api/console/knowledge-fs/types.gen'
import type { RetrievalMode } from '../components/retrieval-mode-segmented-control'
+import { Alert, AlertTitle } from '@langgenius/dify-ui/alert'
import { Button } from '@langgenius/dify-ui/button'
import { cn } from '@langgenius/dify-ui/cn'
import {
@@ -175,9 +176,11 @@ export function EvaluationReport({
</div>
{run.error && (
- <div className="mt-4 rounded-lg border border-state-destructive-border bg-state-destructive-hover p-3 system-xs-regular text-text-destructive">
- {t(($) => $['qualityPage.evaluation.executionFailed'], { ns: 'knowledgeQuality' })}
- </div>
+ <Alert type="error" className="mt-4">
+ <AlertTitle>
+ {t(($) => $['qualityPage.evaluation.executionFailed'], { ns: 'knowledgeQuality' })}
+ </AlertTitle>
+ </Alert>
)}
<div className="mt-4 grid gap-3 sm:grid-cols-2 xl:grid-cols-4">
diff --git a/web/features/new-rag/settings/form.tsx b/web/features/new-rag/settings/form.tsx
index fbd353a87d2..44f5ff54e7f 100644
--- a/web/features/new-rag/settings/form.tsx
+++ b/web/features/new-rag/settings/form.tsx
@@ -1,11 +1,11 @@
'use client'
+import { Alert, AlertActions, AlertTitle } from '@langgenius/dify-ui/alert'
import { Button } from '@langgenius/dify-ui/button'
import { Form } from '@langgenius/dify-ui/form'
import { useAtomValue, useSetAtom } from 'jotai'
import { useTranslation } from 'react-i18next'
import { toast } from '@/app/notifications'
-import { KnowledgeModelReadinessNotice } from '../components/knowledge-model-readiness-notice'
import { BasicInformationSection } from './basic-information'
import { DeleteKnowledgeAction } from './delete-knowledge'
import { ExternalAccessSection } from './external-access'
@@ -84,15 +84,16 @@ export function KnowledgeSettingsForm() {
}}
>
{(hasConflict || saveError === 'settings.revisionConflict') && !isSaving && (
- <KnowledgeModelReadinessNotice
- title={t(($) => $['settings.serverConflict'], { ns: 'knowledgeSettings' })}
- tone="warning"
- action={
- <Button type="button" onClick={() => void cancel()}>
+ <Alert type="warning">
+ <AlertTitle>
+ {t(($) => $['settings.serverConflict'], { ns: 'knowledgeSettings' })}
+ </AlertTitle>
+ <AlertActions>
+ <Button type="button" size="small" onClick={() => void cancel()}>
{t(($) => $['settings.reloadLatest'], { ns: 'knowledgeSettings' })}
</Button>
- }
- />
+ </AlertActions>
+ </Alert>
)}
<BasicInformationSection />
<ExternalAccessSection />
diff --git a/web/features/new-rag/settings/retrieval-settings.tsx b/web/features/new-rag/settings/retrieval-settings.tsx
index 52779e642d9..b1f86be863f 100644
--- a/web/features/new-rag/settings/retrieval-settings.tsx
+++ b/web/features/new-rag/settings/retrieval-settings.tsx
@@ -2,6 +2,7 @@
import type { RetrievalSettingsDraft } from './model'
import type { DefaultModel } from '@/app/components/header/account-setting/model-provider-page/declarations'
+import { Alert, AlertDescription, AlertTitle } from '@langgenius/dify-ui/alert'
import {
AlertDialog,
AlertDialogCancelButton,
@@ -29,7 +30,6 @@ import { useTranslation } from 'react-i18next'
import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
import { ModelSelector } from '@/app/components/header/account-setting/model-provider-page/model-selector'
import { consoleQuery } from '@/service/console'
-import { KnowledgeModelReadinessNotice } from '../components/knowledge-model-readiness-notice'
import { RetrievalModeSegmentedControl } from '../components/retrieval-mode-segmented-control'
import {
modelFingerprint,
@@ -112,22 +112,23 @@ export function RetrievalSettingsSection() {
<>
{settings.configuration_state !== 'pending-validation' &&
settings.configuration_state !== 'active' && (
- <KnowledgeModelReadinessNotice
+ <Alert
+ type={settings.configuration_state === 'validation-failed' ? 'error' : 'warning'}
className="mb-3"
- description={
- settings.issues.length > 0
- ? settings.issues.map(({ field }) => readinessFieldLabel(field)).join(' · ')
- : settings.active_profile_available
- ? t(($) => $['overview.attention.modelReadiness.description'])
- : undefined
- }
- title={
- settings.configuration_state === 'validation-failed'
+ >
+ <AlertTitle>
+ {settings.configuration_state === 'validation-failed'
? tCommon(($) => $['api.actionFailed'])
- : tCommon(($) => $['modelProvider.toBeConfigured'], { ns: 'modelProvider' })
- }
- tone={settings.configuration_state === 'validation-failed' ? 'destructive' : 'warning'}
- />
+ : tCommon(($) => $['modelProvider.toBeConfigured'], { ns: 'modelProvider' })}
+ </AlertTitle>
+ {(settings.issues.length > 0 || settings.active_profile_available) && (
+ <AlertDescription>
+ {settings.issues.length > 0
+ ? settings.issues.map(({ field }) => readinessFieldLabel(field)).join(' · ')
+ : t(($) => $['overview.attention.modelReadiness.description'])}
+ </AlertDescription>
+ )}
+ </Alert>
)}
<div className="h-px bg-divider-subtle" />