From 4a28599fbdb62766fbb4c3ac6968a8a439dfe25e Mon Sep 17 00:00:00 2001 From: bowen <54492610+jiaowoxiaobala@users.noreply.github.com> Date: Tue, 5 Sep 2023 09:13:59 +0800 Subject: [PATCH] fix: optimize feedback and app icon (#1099) --- .../[appId]/overview/cardView.tsx | 33 ++++++++++--------- web/app/(commonLayout)/apps/AppCard.tsx | 2 +- .../prompt-value-panel/index.tsx | 2 +- web/app/components/app/log/list.tsx | 8 ++--- web/app/components/app/overview/appCard.tsx | 8 +++-- .../app/overview/settings/index.tsx | 3 +- web/app/components/base/confirm-ui/index.tsx | 4 +-- .../documents/detail/completed/index.tsx | 4 +-- .../documents/detail/embedding/index.tsx | 2 +- .../documents/detail/metadata/index.tsx | 2 +- .../components/datasets/documents/list.tsx | 2 +- .../datasets/settings/form/index.tsx | 2 +- .../share/chat/welcome/massive-component.tsx | 2 +- web/i18n/lang/common.en.ts | 4 ++- web/i18n/lang/common.zh.ts | 4 ++- 15 files changed, 45 insertions(+), 37 deletions(-) diff --git a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/cardView.tsx b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/cardView.tsx index 375524023c..9bebc68f87 100644 --- a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/cardView.tsx +++ b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/cardView.tsx @@ -33,20 +33,18 @@ const CardView: FC = ({ appId }) => { if (!response) return - const handleError = (err: Error | null) => { - if (!err) { - notify({ - type: 'success', - message: t('common.actionMsg.modifiedSuccessfully'), - }) + const handleCallbackResult = (err: Error | null, message?: string) => { + const type = err ? 'error' : 'success' + + message ||= (type === 'success' ? 'modifiedSuccessfully' : 'modifiedUnsuccessfully') + + if (type === 'success') { mutate(detailParams) } - else { - notify({ - type: 'error', - message: t('common.actionMsg.modificationFailed'), - }) - } + notify({ + type, + message: t(`common.actionMsg.${message}`), + }) } const onChangeSiteStatus = async (value: boolean) => { @@ -56,7 +54,8 @@ const CardView: FC = ({ appId }) => { body: { enable_site: value }, }) as Promise, ) - handleError(err) + + handleCallbackResult(err) } const onChangeApiStatus = async (value: boolean) => { @@ -66,7 +65,8 @@ const CardView: FC = ({ appId }) => { body: { enable_api: value }, }) as Promise, ) - handleError(err) + + handleCallbackResult(err) } const onSaveSiteConfig: IAppCardProps['onSaveSiteConfig'] = async (params) => { @@ -79,7 +79,7 @@ const CardView: FC = ({ appId }) => { if (!err) localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1') - handleError(err) + handleCallbackResult(err) } const onGenerateCode = async () => { @@ -88,7 +88,8 @@ const CardView: FC = ({ appId }) => { url: `/apps/${appId}/site/access-token-reset`, }) as Promise, ) - handleError(err) + + handleCallbackResult(err, err ? 'generatedUnsuccessfully' : 'generatedSuccessfully') } return ( diff --git a/web/app/(commonLayout)/apps/AppCard.tsx b/web/app/(commonLayout)/apps/AppCard.tsx index a7aaf01510..4080ac6db6 100644 --- a/web/app/(commonLayout)/apps/AppCard.tsx +++ b/web/app/(commonLayout)/apps/AppCard.tsx @@ -93,7 +93,7 @@ const AppCard = ({ app, onRefresh }: AppCardProps) => { else { notify({ type: 'error', - message: t('common.actionMsg.modificationFailed'), + message: t('common.actionMsg.modifiedUnsuccessfully'), }) } }, diff --git a/web/app/components/app/configuration/prompt-value-panel/index.tsx b/web/app/components/app/configuration/prompt-value-panel/index.tsx index 3ea87683ea..ef0925499a 100644 --- a/web/app/components/app/configuration/prompt-value-panel/index.tsx +++ b/web/app/components/app/configuration/prompt-value-panel/index.tsx @@ -134,7 +134,7 @@ const PromptValuePanel: FC = ({
{promptVariables.map(({ key, name, type, options, max_length, required }) => (
-
{name || key}
+
{name || key}
{type === 'select' ? (