From 6642fc60125f882ad776d0b7a998b31a5ccee986 Mon Sep 17 00:00:00 2001 From: Wu Tianwei <30284043+WTW0313@users.noreply.github.com> Date: Wed, 5 Feb 2025 14:38:36 +0800 Subject: [PATCH] fix: fix fallback route logic (#13199) --- .../[appId]/annotations/page.tsx | 2 +- .../app/(appDetailLayout)/[appId]/layout.tsx | 1 + .../[appId]/overview/tracing/config-popup.tsx | 30 ----- .../tracing/provider-config-modal.tsx | 3 +- .../overview/tracing/provider-panel.tsx | 1 - .../app/(appDetailLayout)/layout.tsx | 1 + web/app/(commonLayout)/apps/AppCard.tsx | 9 +- web/app/components/datasets/create/index.tsx | 6 +- .../create/steps-nav-bar/index.module.css | 107 ------------------ .../datasets/create/steps-nav-bar/index.tsx | 61 ---------- .../datasets/create/top-bar/index.tsx | 20 ++-- web/i18n/en-US/dataset-creation.ts | 3 +- web/i18n/zh-Hans/dataset-creation.ts | 3 +- 13 files changed, 28 insertions(+), 219 deletions(-) delete mode 100644 web/app/components/datasets/create/steps-nav-bar/index.module.css delete mode 100644 web/app/components/datasets/create/steps-nav-bar/index.tsx diff --git a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/annotations/page.tsx b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/annotations/page.tsx index 7beb1d76bb..0af2e945f3 100644 --- a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/annotations/page.tsx +++ b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/annotations/page.tsx @@ -2,7 +2,7 @@ import React from 'react' import Main from '@/app/components/app/log-annotation' import { PageType } from '@/app/components/base/features/new-feature-panel/annotation-reply/type' -export interface IProps { +export type IProps = { params: { appId: string } } diff --git a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout.tsx b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout.tsx index 1d96320309..1b4efb0b5b 100644 --- a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout.tsx +++ b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout.tsx @@ -106,6 +106,7 @@ const AppDetailLayout: FC = (props) => { // if ((appDetail.mode === 'advanced-chat' || appDetail.mode === 'workflow') && (pathname).endsWith('workflow')) // setAppSiderbarExpand('collapse') } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [appDetail, isMobile]) useEffect(() => { diff --git a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/config-popup.tsx b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/config-popup.tsx index 646a3b5a0b..1f40dc0b13 100644 --- a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/config-popup.tsx +++ b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/config-popup.tsx @@ -123,36 +123,6 @@ const ConfigPopup: FC = ({ /> ) - const configuredProviderPanel = () => { - const configuredPanels: ProviderPanel[] = [] - - if (langSmithConfig) - configuredPanels.push(langSmithPanel) - - if (langFuseConfig) - configuredPanels.push(langfusePanel) - - if (opikConfig) - configuredPanels.push(opikPanel) - - return configuredPanels - } - - const moreProviderPanel = () => { - const notConfiguredPanels: ProviderPanel[] = [] - - if (!langSmithConfig) - notConfiguredPanels.push(langSmithPanel) - - if (!langFuseConfig) - notConfiguredPanels.push(langfusePanel) - - if (!opikConfig) - notConfiguredPanels.push(opikPanel) - - return notConfiguredPanels - } - const configuredProviderConfig = () => { if (currentProvider === TracingProvider.langSmith) return langSmithConfig diff --git a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/provider-config-modal.tsx b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/provider-config-modal.tsx index 069df8f7f6..d446270cf9 100644 --- a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/provider-config-modal.tsx +++ b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/provider-config-modal.tsx @@ -123,7 +123,8 @@ const ProviderConfigModal: FC = ({ } if (type === TracingProvider.opik) { - const postData = config as OpikConfig + // todo: check field validity + // const postData = config as OpikConfig } return errorMessage diff --git a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/provider-panel.tsx b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/provider-panel.tsx index df7618499e..36221357a4 100644 --- a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/provider-panel.tsx +++ b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/provider-panel.tsx @@ -8,7 +8,6 @@ import { useTranslation } from 'react-i18next' import { TracingProvider } from './type' import cn from '@/utils/classnames' import { LangfuseIconBig, LangsmithIconBig, OpikIconBig } from '@/app/components/base/icons/src/public/tracing' -import { Settings04 } from '@/app/components/base/icons/src/vender/line/general' import { Eye as View } from '@/app/components/base/icons/src/vender/solid/general' const I18N_PREFIX = 'app.tracing' diff --git a/web/app/(commonLayout)/app/(appDetailLayout)/layout.tsx b/web/app/(commonLayout)/app/(appDetailLayout)/layout.tsx index 211b0b3677..dda198fc89 100644 --- a/web/app/(commonLayout)/app/(appDetailLayout)/layout.tsx +++ b/web/app/(commonLayout)/app/(appDetailLayout)/layout.tsx @@ -15,6 +15,7 @@ const AppDetail: FC = ({ children }) => { useEffect(() => { if (isCurrentWorkspaceDatasetOperator) return router.replace('/datasets') + // eslint-disable-next-line react-hooks/exhaustive-deps }, [isCurrentWorkspaceDatasetOperator]) return ( diff --git a/web/app/(commonLayout)/apps/AppCard.tsx b/web/app/(commonLayout)/apps/AppCard.tsx index dabe75ee62..e7e1251897 100644 --- a/web/app/(commonLayout)/apps/AppCard.tsx +++ b/web/app/(commonLayout)/apps/AppCard.tsx @@ -71,6 +71,7 @@ const AppCard = ({ app, onRefresh }: AppCardProps) => { }) } setShowConfirmDelete(false) + // eslint-disable-next-line react-hooks/exhaustive-deps }, [app.id]) const onEdit: CreateAppModalProps['onConfirm'] = useCallback(async ({ @@ -100,7 +101,7 @@ const AppCard = ({ app, onRefresh }: AppCardProps) => { onRefresh() mutateApps() } - catch (e) { + catch { notify({ type: 'error', message: t('app.editFailed') }) } }, [app.id, mutateApps, notify, onRefresh, t]) @@ -127,7 +128,7 @@ const AppCard = ({ app, onRefresh }: AppCardProps) => { onPlanInfoChanged() getRedirection(isCurrentWorkspaceEditor, newApp, push) } - catch (e) { + catch { notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) } } @@ -144,7 +145,7 @@ const AppCard = ({ app, onRefresh }: AppCardProps) => { a.download = `${app.name}.yml` a.click() } - catch (e) { + catch { notify({ type: 'error', message: t('app.exportFailed') }) } } @@ -163,7 +164,7 @@ const AppCard = ({ app, onRefresh }: AppCardProps) => { } setSecretEnvList(list) } - catch (e) { + catch { notify({ type: 'error', message: t('app.exportFailed') }) } } diff --git a/web/app/components/datasets/create/index.tsx b/web/app/components/datasets/create/index.tsx index 9556b9fad5..b1e4087226 100644 --- a/web/app/components/datasets/create/index.tsx +++ b/web/app/components/datasets/create/index.tsx @@ -6,7 +6,7 @@ import { ModelTypeEnum } from '../../header/account-setting/model-provider-page/ import StepOne from './step-one' import StepTwo from './step-two' import StepThree from './step-three' -import { Topbar } from './top-bar' +import { TopBar } from './top-bar' import { DataSourceType } from '@/models/datasets' import type { CrawlOptions, CrawlResultItem, DataSet, FileItem, createDocumentResponse } from '@/models/datasets' import { fetchDataSource } from '@/service/common' @@ -111,7 +111,7 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => { const detail = await fetchDatasetDetail(datasetId) setDetail(detail) } - catch (e) { + catch { setHasError(true) } } @@ -123,7 +123,7 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => { return (
- +
{step === 1 && = { - 1: 'datasetCreation.steps.one', - 2: 'datasetCreation.steps.two', - 3: 'datasetCreation.steps.three', -} - -const STEP_LIST = [1, 2, 3] - -const StepsNavBar = ({ - step, - datasetId, -}: IStepsNavBarProps) => { - const { t } = useTranslation() - const router = useRouter() - - const media = useBreakpoints() - const isMobile = media === MediaType.mobile - - const navBackHandle = useCallback(() => { - if (!datasetId) - router.replace('/datasets') - else - router.replace(`/datasets/${datasetId}/documents`) - }, [router, datasetId]) - - return ( -
-
-
- {!isMobile && (!datasetId ? t('datasetCreation.steps.header.creation') : t('datasetCreation.steps.header.update'))} -
-
- {STEP_LIST.map(item => ( -
item && s.done, isMobile && 'px-0')} - > -
{step > item ? '' : item}
-
{isMobile ? '' : t(STEP_T_MAP[item])}
-
- ))} -
-
- ) -} - -export default StepsNavBar diff --git a/web/app/components/datasets/create/top-bar/index.tsx b/web/app/components/datasets/create/top-bar/index.tsx index 20ba7158db..8235c4f804 100644 --- a/web/app/components/datasets/create/top-bar/index.tsx +++ b/web/app/components/datasets/create/top-bar/index.tsx @@ -1,12 +1,13 @@ -import type { FC } from 'react' +import { type FC, useMemo } from 'react' import { RiArrowLeftLine } from '@remixicon/react' import Link from 'next/link' import { useTranslation } from 'react-i18next' import { Stepper, type StepperProps } from '../stepper' import classNames from '@/utils/classnames' -export type TopbarProps = Pick & { +export type TopBarProps = Pick & { className?: string + datasetId?: string } const STEP_T_MAP: Record = { @@ -15,20 +16,25 @@ const STEP_T_MAP: Record = { 3: 'datasetCreation.steps.three', } -export const Topbar: FC = (props) => { - const { className, ...rest } = props +export const TopBar: FC = (props) => { + const { className, datasetId, ...rest } = props const { t } = useTranslation() + + const fallbackRoute = useMemo(() => { + return datasetId ? `/datasets/${datasetId}/documents` : '/datasets' + }, [datasetId]) + return
- +

- {t('datasetCreation.steps.header.creation')} + {t('datasetCreation.steps.header.fallbackRoute')}

({ diff --git a/web/i18n/en-US/dataset-creation.ts b/web/i18n/en-US/dataset-creation.ts index 8490896e3b..0ee75c2faa 100644 --- a/web/i18n/en-US/dataset-creation.ts +++ b/web/i18n/en-US/dataset-creation.ts @@ -1,8 +1,7 @@ const translation = { steps: { header: { - creation: 'Create Knowledge', - update: 'Add data', + fallbackRoute: 'Knowledge', }, one: 'Data Source', two: 'Document Processing', diff --git a/web/i18n/zh-Hans/dataset-creation.ts b/web/i18n/zh-Hans/dataset-creation.ts index 3b3824d2cb..d5519e5420 100644 --- a/web/i18n/zh-Hans/dataset-creation.ts +++ b/web/i18n/zh-Hans/dataset-creation.ts @@ -1,8 +1,7 @@ const translation = { steps: { header: { - creation: '创建知识库', - update: '上传文件', + fallbackRoute: '知识库', }, one: '选择数据源', two: '文本分段与清洗',