Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix fallback route logic #13199

Merged
merged 2 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions web/app/(commonLayout)/app/(appDetailLayout)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
9 changes: 5 additions & 4 deletions web/app/(commonLayout)/apps/AppCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 ({
Expand Down Expand Up @@ -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])
Expand All @@ -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') })
}
}
Expand All @@ -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') })
}
}
Expand All @@ -163,7 +164,7 @@ const AppCard = ({ app, onRefresh }: AppCardProps) => {
}
setSecretEnvList(list)
}
catch (e) {
catch {
notify({ type: 'error', message: t('app.exportFailed') })
}
}
Expand Down
6 changes: 3 additions & 3 deletions web/app/components/datasets/create/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -111,7 +111,7 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => {
const detail = await fetchDatasetDetail(datasetId)
setDetail(detail)
}
catch (e) {
catch {
setHasError(true)
}
}
Expand All @@ -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}
Expand Down
107 changes: 0 additions & 107 deletions web/app/components/datasets/create/steps-nav-bar/index.module.css

This file was deleted.

61 changes: 0 additions & 61 deletions web/app/components/datasets/create/steps-nav-bar/index.tsx

This file was deleted.

20 changes: 13 additions & 7 deletions web/app/components/datasets/create/top-bar/index.tsx
Original file line number Diff line number Diff line change
@@ -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> = {
Expand All @@ -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) => ({
Expand Down
3 changes: 1 addition & 2 deletions web/i18n/en-US/dataset-creation.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const translation = {
steps: {
header: {
creation: 'Create Knowledge',
update: 'Add data',
fallbackRoute: 'Knowledge',
},
one: 'Data Source',
two: 'Document Processing',
Expand Down
3 changes: 1 addition & 2 deletions web/i18n/zh-Hans/dataset-creation.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const translation = {
steps: {
header: {
creation: '创建知识库',
update: '上传文件',
fallbackRoute: '知识库',
},
one: '选择数据源',
two: '文本分段与清洗',
Expand Down
Loading