From 05481059edaa6eb05ab1cae8e85daefb3d1bdf73 Mon Sep 17 00:00:00 2001 From: CodingOnStar Date: Fri, 8 May 2026 18:38:12 +0800 Subject: [PATCH] refactor: replace CustomDialog with Dialog component across multiple files - Updated DeleteAccount, FeedBack, BatchModal, VersionInfoModal, GetAutomaticRes, GetCodeGeneratorRes, EditModal, ConfigModal, ParamsConfig, DSLConfirmModal, and CreateFromDSLModal to use the new Dialog component from @langgenius/dify-ui/dialog instead of the previous CustomDialog and Modal components. - Enhanced dialog structure for better accessibility and styling consistency. --- .../delete-account/components/feed-back.tsx | 50 +-- .../(commonLayout)/delete-account/index.tsx | 42 ++- .../batch-add-annotation-modal/index.tsx | 62 ++-- .../app/app-publisher/version-info-modal.tsx | 83 ++--- .../__tests__/edit-modal.spec.tsx | 7 +- .../conversation-history/edit-modal.tsx | 66 ++-- .../config-var/config-modal/index.tsx | 64 ++-- .../config/automatic/get-automatic-res.tsx | 269 ++++++++-------- .../code-generator/get-code-generator-res.tsx | 179 +++++------ .../dataset-config/params-config/index.tsx | 52 ++-- .../dsl-confirm-modal.tsx | 63 ++-- .../app/create-from-dsl-modal/index.tsx | 199 ++++++------ .../components/app/duplicate-modal/index.tsx | 69 ++--- .../components/app/switch-app-modal/index.tsx | 122 ++++---- .../components/base/app-icon-picker/index.tsx | 97 +++--- .../sidebar/__tests__/index.spec.tsx | 21 +- .../sidebar/__tests__/rename-modal.spec.tsx | 26 +- .../base/dialog/__tests__/index.spec.tsx | 138 --------- .../components/base/dialog/index.stories.tsx | 152 --------- web/app/components/base/dialog/index.tsx | 70 ----- .../components/base/emoji-picker/index.tsx | 67 ++-- .../annotation-reply/config-param-modal.tsx | 91 +++--- .../moderation/moderation-setting-modal.tsx | 292 +++++++++--------- .../base/modal/__tests__/index.spec.tsx | 172 ----------- .../components/base/modal/index.stories.tsx | 128 -------- web/app/components/base/modal/index.tsx | 93 ------ .../plugins/hitl-input-block/component-ui.tsx | 32 +- .../__tests__/index.spec.tsx | 8 +- .../plugins/shortcuts-popup-plugin/index.tsx | 12 +- .../annotation-full/__tests__/modal.spec.tsx | 26 +- .../billing/annotation-full/modal.tsx | 45 +-- .../dsl-confirm-modal.tsx | 63 ++-- .../create-from-dsl-modal/index.tsx | 90 +++--- .../list/template-card/index.tsx | 52 ++-- .../empty-dataset-creation-modal/index.tsx | 41 ++- .../create/stop-embedding-modal/index.tsx | 41 ++- .../documents/components/rename-modal.tsx | 40 ++- .../documents/detail/batch-modal/index.tsx | 48 +-- .../completed/common/regeneration-modal.tsx | 49 +-- .../__tests__/chunk-detail-modal.spec.tsx | 10 +- .../components/chunk-detail-modal.tsx | 159 +++++----- .../components/result-item-external.tsx | 33 +- .../metadata/edit-metadata-batch/modal.tsx | 87 +++--- .../dataset-metadata-drawer.tsx | 68 ++-- .../datasets/rename-modal/index.tsx | 60 ++-- .../secret-key/secret-key-generate.tsx | 43 ++- .../develop/secret-key/secret-key-modal.tsx | 153 ++++----- web/app/components/explore/try-app/index.tsx | 97 +++--- .../components/header/account-about/index.tsx | 155 +++++----- .../api-based-extension-page/modal.tsx | 76 ++--- .../model-load-balancing-modal.tsx | 180 +++++------ .../install-plugin/install-bundle/index.tsx | 43 +-- .../install-from-github/index.tsx | 138 +++++---- .../install-from-local-package/index.tsx | 95 +++--- .../install-from-marketplace/index.tsx | 110 +++---- .../__tests__/schema-modal.spec.tsx | 13 +- .../plugins/plugin-mutation-model/index.tsx | 79 ++--- .../__tests__/plugin-info.spec.tsx | 10 +- .../plugins/plugin-page/plugin-info.tsx | 33 +- .../__tests__/index.spec.tsx | 35 +-- .../plugins/reference-setting-modal/index.tsx | 107 ++++--- ...blish-as-knowledge-pipeline-modal.spec.tsx | 9 +- .../__tests__/update-dsl-modal.spec.tsx | 20 +- .../__tests__/version-mismatch-modal.spec.tsx | 4 +- .../publish-as-knowledge-pipeline-modal.tsx | 120 ++++--- .../components/update-dsl-modal.tsx | 117 +++---- .../components/version-mismatch-modal.tsx | 63 ++-- .../share/text-generation/info-modal.tsx | 65 ++-- .../components/tools/mcp/mcp-server-modal.tsx | 147 +++++---- web/app/components/tools/mcp/modal.tsx | 26 +- .../http/components/authorization/index.tsx | 126 ++++---- .../nodes/http/components/curl-panel.tsx | 51 +-- .../json-schema-config-modal/index.tsx | 27 +- .../__tests__/integration.spec.tsx | 15 +- .../components/extract-parameter/update.tsx | 119 +++---- .../conversation-variable-modal.tsx | 144 +++++---- .../action-menu/index.tsx | 3 +- .../delete-confirm-modal.tsx | 57 ++-- .../panel/version-history-panel/empty.tsx | 2 +- .../version-history-panel/filter/index.tsx | 1 + .../restore-confirm-modal.tsx | 57 ++-- .../components/workflow/update-dsl-modal.tsx | 164 +++++----- .../education-apply/expire-notice-modal.tsx | 117 +++---- 83 files changed, 3037 insertions(+), 3422 deletions(-) delete mode 100644 web/app/components/base/dialog/__tests__/index.spec.tsx delete mode 100644 web/app/components/base/dialog/index.stories.tsx delete mode 100644 web/app/components/base/dialog/index.tsx delete mode 100644 web/app/components/base/modal/__tests__/index.spec.tsx delete mode 100644 web/app/components/base/modal/index.stories.tsx delete mode 100644 web/app/components/base/modal/index.tsx 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 ee1e72e6e7..5b68290dd0 100644 --- a/web/app/account/(commonLayout)/delete-account/components/feed-back.tsx +++ b/web/app/account/(commonLayout)/delete-account/components/feed-back.tsx @@ -1,9 +1,9 @@ 'use client' import { Button } from '@langgenius/dify-ui/button' +import { Dialog, DialogContent, DialogTitle } from '@langgenius/dify-ui/dialog' import { toast } from '@langgenius/dify-ui/toast' import { useCallback, useState } from 'react' import { useTranslation } from 'react-i18next' -import CustomDialog from '@/app/components/base/dialog' import Textarea from '@/app/components/base/textarea' import { useAppContext } from '@/context/app-context' import { useRouter } from '@/next/navigation' @@ -47,26 +47,34 @@ export default function FeedBack(props: DeleteAccountProps) { handleSuccess() }, [handleSuccess, props]) return ( - { + if (!open) + props.onCancel() + }} > - - + +
+
- {latestParams.length > 0 && ( -
-
-
{t('mcp.server.modal.parameters', { ns: 'tools' })}
- -
-
{t('mcp.server.modal.parametersTip', { ns: 'tools' })}
-
- {latestParams.map(paramItem => ( - handleParamChange(paramItem.variable, value)} - /> - ))} +
+ {!data ? t('mcp.server.modal.addTitle', { ns: 'tools' }) : t('mcp.server.modal.editTitle', { ns: 'tools' })} +
+
+
+
+
{t('mcp.server.modal.description', { ns: 'tools' })}
+
*
+
- )} -
-
- - -
- + {latestParams.length > 0 && ( +
+
+
{t('mcp.server.modal.parameters', { ns: 'tools' })}
+ +
+
{t('mcp.server.modal.parametersTip', { ns: 'tools' })}
+
+ {latestParams.map((paramItem) => { + if (!paramItem.variable) + return null + + const { variable } = paramItem + + return ( + handleParamChange(variable, value)} + /> + ) + })} +
+
+ )} +
+
+ + +
+ + ) } diff --git a/web/app/components/tools/mcp/modal.tsx b/web/app/components/tools/mcp/modal.tsx index 165535127d..79179ae3dc 100644 --- a/web/app/components/tools/mcp/modal.tsx +++ b/web/app/components/tools/mcp/modal.tsx @@ -4,17 +4,15 @@ import type { AppIconSelection } from '@/app/components/base/app-icon-picker' import type { ToolWithProvider } from '@/app/components/workflow/types' import type { AppIconType } from '@/types/app' import { Button } from '@langgenius/dify-ui/button' -import { cn } from '@langgenius/dify-ui/cn' +import { Dialog, DialogContent } from '@langgenius/dify-ui/dialog' import { toast } from '@langgenius/dify-ui/toast' import { RiCloseLine, RiEditLine } from '@remixicon/react' import { useHover } from 'ahooks' -import { noop } from 'es-toolkit/function' import { useTranslation } from 'react-i18next' import AppIcon from '@/app/components/base/app-icon' import AppIconPicker from '@/app/components/base/app-icon-picker' import { Mcp } from '@/app/components/base/icons/src/vender/other' import Input from '@/app/components/base/input' -import Modal from '@/app/components/base/modal' import TabSlider from '@/app/components/base/tab-slider' import { MCPAuthMethod } from '@/app/components/tools/types' import { shouldUseMcpIconForAppIcon } from '@/utils/mcp' @@ -281,18 +279,16 @@ const MCPModal: FC = ({ const formKey = data?.id ?? 'create' return ( - - - + + + + + ) } 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 b72e52911d..684f943d5f 100644 --- a/web/app/components/workflow/nodes/http/components/authorization/index.tsx +++ b/web/app/components/workflow/nodes/http/components/authorization/index.tsx @@ -4,12 +4,12 @@ import type { Authorization as AuthorizationPayloadType } from '../../types' import type { Var } from '@/app/components/workflow/types' import { Button } from '@langgenius/dify-ui/button' import { cn } from '@langgenius/dify-ui/cn' +import { Dialog, DialogContent, DialogTitle } from '@langgenius/dify-ui/dialog' import { produce } from 'immer' import * as React from 'react' import { useCallback, useState } from 'react' import { useTranslation } from 'react-i18next' import BaseInput from '@/app/components/base/input' -import Modal from '@/app/components/base/modal' import Input from '@/app/components/workflow/nodes/_base/components/input-support-select-var' import useAvailableVarList from '@/app/components/workflow/nodes/_base/hooks/use-available-var-list' import { VarType } from '@/app/components/workflow/types' @@ -115,70 +115,78 @@ const Authorization: FC = ({ onHide() }, [tempPayload, onChange, onHide]) return ( - { + if (!open) + onHide() + }} > -
-
- - - + + + {t(`${i18nPrefix}.authorization`, { ns: 'workflow' })} + - {tempPayload.type === AuthorizationType.apiKey && ( - <> - - - - {tempPayload.config?.type === APIType.custom && ( - - +
+ + + + + {tempPayload.type === AuthorizationType.apiKey && ( + <> + + - )} + {tempPayload.config?.type === APIType.custom && ( + + + + )} - -
- -
-
- - )} + +
+ +
+
+ + )} +
+
+ + +
-
- - -
-
-
+ + ) } export default React.memo(Authorization) diff --git a/web/app/components/workflow/nodes/http/components/curl-panel.tsx b/web/app/components/workflow/nodes/http/components/curl-panel.tsx index 8ba5fb36a9..87dc2a3427 100644 --- a/web/app/components/workflow/nodes/http/components/curl-panel.tsx +++ b/web/app/components/workflow/nodes/http/components/curl-panel.tsx @@ -2,11 +2,11 @@ import type { FC } from 'react' import type { HttpNodeType } from '../types' import { Button } from '@langgenius/dify-ui/button' +import { Dialog, DialogContent, DialogTitle } from '@langgenius/dify-ui/dialog' import { toast } from '@langgenius/dify-ui/toast' import * as React from 'react' import { useCallback, useState } from 'react' import { useTranslation } from 'react-i18next' -import Modal from '@/app/components/base/modal' import Textarea from '@/app/components/base/textarea' import { useNodesInteractions } from '@/app/components/workflow/hooks' import { parseCurl } from './curl-parser' @@ -42,28 +42,35 @@ const CurlPanel: FC = ({ nodeId, isShow, onHide, handleCurlImport }) => { }, [onHide, nodeId, inputString, handleNodeSelect, handleCurlImport]) return ( - { + if (!open) + onHide() + }} > -
-