fix: fix fallback route logic (#13199)

This commit is contained in:
Wu Tianwei 2025-02-05 14:38:36 +08:00 committed by GitHub
parent 2710242982
commit 6642fc6012
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 28 additions and 219 deletions

View File

@ -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 }
}

View File

@ -106,6 +106,7 @@ const AppDetailLayout: FC<IAppDetailLayoutProps> = (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(() => {

View File

@ -123,36 +123,6 @@ const ConfigPopup: FC<PopupProps> = ({
/>
)
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

View File

@ -123,7 +123,8 @@ const ProviderConfigModal: FC<Props> = ({
}
if (type === TracingProvider.opik) {
const postData = config as OpikConfig
// todo: check field validity
// const postData = config as OpikConfig
}
return errorMessage

View File

@ -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'

View File

@ -15,6 +15,7 @@ const AppDetail: FC<IAppDetail> = ({ children }) => {
useEffect(() => {
if (isCurrentWorkspaceDatasetOperator)
return router.replace('/datasets')
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isCurrentWorkspaceDatasetOperator])
return (

View File

@ -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') })
}
}

View File

@ -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 (
<div className='flex flex-col bg-components-panel-bg' style={{ height: 'calc(100vh - 56px)' }}>
<Topbar activeIndex={step - 1} />
<TopBar activeIndex={step - 1} datasetId={datasetId} />
<div style={{ height: 'calc(100% - 52px)' }}>
{step === 1 && <StepOne
hasConnection={hasConnection}

View File

@ -1,107 +0,0 @@
.stepsHeader {
@apply flex items-center px-6 py-6;
color: #344054;
font-weight: 600;
font-size: 14px;
line-height: 20px;
}
.navBack {
@apply box-border flex justify-center items-center mr-3 w-8 h-8 bg-white bg-center bg-no-repeat cursor-pointer hover:border-gray-300;
border: 0.5px solid #F2F4F7;
box-shadow: 0px 12px 16px -4px rgba(16, 24, 40, 0.08), 0px 4px 6px -2px rgba(16, 24, 40, 0.03);
border-radius: 32px;
background-image: url(../assets/arrow-narrow-left.svg);
background-size: 16px;
}
.stepList {
@apply p-4 relative;
line-height: 18px;
}
.stepItem {
@apply relative flex justify-items-start pt-3 pr-0 pb-3 box-content;
padding-left: 52px;
font-size: 13px;
height: 18px;
}
.stepItem.step1::before {
content: '';
position: absolute;
bottom: 0;
left: 23px;
width: 2px;
height: 7px;
background-color: #f2f4f7;
}
.stepItem.step2::before {
content: '';
position: absolute;
top: 0;
left: 23px;
width: 2px;
height: 100%;
background-color: #f2f4f7;
}
.stepItem.step2::after {
content: '';
position: absolute;
top: 6px;
left: 23px;
width: 2px;
height: 28px;
background-color: #fff;
}
.stepItem.step3::before {
content: '';
position: absolute;
top: 0;
left: 23px;
width: 2px;
height: 7px;
background-color: #f2f4f7;
}
.stepNum {
@apply box-border absolute top-2 left-3 flex justify-center items-center w-6 h-6;
color: #98a2b3;
font-size: 12px;
border: 1px solid #F2F4F7;
border-radius: 24px;
z-index: 1;
}
.stepName {
color: #98a2b3;
}
.stepItem.active .stepNum {
color: #1c64f2;
background-color: #EFF4FF;
border: none;
}
.stepItem.active .stepName {
color: #1c64f2;
}
.stepItem.done .stepNum {
color: #667085;
background-color: #f2f4f7;
border: none;
}
.stepItem.done .stepNum::after {
content: '';
display: flex;
width: 12px;
height: 12px;
background: center no-repeat url(../assets/check.svg);
background-size: 12px;
}
.stepItem.done .stepName {
color: #667085;
}

View File

@ -1,61 +0,0 @@
'use client'
import { useTranslation } from 'react-i18next'
import { useRouter } from 'next/navigation'
import { useCallback } from 'react'
import s from './index.module.css'
import cn from '@/utils/classnames'
import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
type IStepsNavBarProps = {
step: number
datasetId?: string
}
const STEP_T_MAP: Record<number, string> = {
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 (
<div className='w-full pt-4'>
<div className={cn(s.stepsHeader, isMobile && '!px-0 justify-center')}>
<div onClick={navBackHandle} className={cn(s.navBack, isMobile && '!mr-0')} />
{!isMobile && (!datasetId ? t('datasetCreation.steps.header.creation') : t('datasetCreation.steps.header.update'))}
</div>
<div className={cn(s.stepList, isMobile && '!p-0')}>
{STEP_LIST.map(item => (
<div
key={item}
className={cn(s.stepItem, s[`step${item}`], step === item && s.active, step > item && s.done, isMobile && 'px-0')}
>
<div className={cn(s.stepNum)}>{step > item ? '' : item}</div>
<div className={cn(s.stepName)}>{isMobile ? '' : t(STEP_T_MAP[item])}</div>
</div>
))}
</div>
</div>
)
}
export default StepsNavBar

View File

@ -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<StepperProps, 'activeIndex'> & {
export type TopBarProps = Pick<StepperProps, 'activeIndex'> & {
className?: string
datasetId?: string
}
const STEP_T_MAP: Record<number, string> = {
@ -15,20 +16,25 @@ const STEP_T_MAP: Record<number, string> = {
3: 'datasetCreation.steps.three',
}
export const Topbar: FC<TopbarProps> = (props) => {
const { className, ...rest } = props
export const TopBar: FC<TopBarProps> = (props) => {
const { className, datasetId, ...rest } = props
const { t } = useTranslation()
const fallbackRoute = useMemo(() => {
return datasetId ? `/datasets/${datasetId}/documents` : '/datasets'
}, [datasetId])
return <div className={classNames('flex shrink-0 h-[52px] items-center justify-between relative border-b border-b-divider-subtle', className)}>
<Link href={'/datasets'} className="h-12 pl-2 pr-6 py-2 justify-start items-center gap-1 inline-flex">
<Link href={fallbackRoute} replace className="h-12 pl-2 pr-6 py-2 justify-start items-center gap-1 inline-flex">
<div className='p-2'>
<RiArrowLeftLine className='size-4 text-text-primary' />
</div>
<p className="text-text-primary system-sm-semibold-uppercase">
{t('datasetCreation.steps.header.creation')}
{t('datasetCreation.steps.header.fallbackRoute')}
</p>
</Link>
<div className={
'top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 absolute'
'top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 absolute'
}>
<Stepper
steps={Array.from({ length: 3 }, (_, i) => ({

View File

@ -1,8 +1,7 @@
const translation = {
steps: {
header: {
creation: 'Create Knowledge',
update: 'Add data',
fallbackRoute: 'Knowledge',
},
one: 'Data Source',
two: 'Document Processing',

View File

@ -1,8 +1,7 @@
const translation = {
steps: {
header: {
creation: '创建知识库',
update: '上传文件',
fallbackRoute: '知识库',
},
one: '选择数据源',
two: '文本分段与清洗',