Sfoglia il codice sorgente

fix: unexpected redirection when landing at workflow (#22932)

tags/1.7.1
KVOJJJin 3 mesi fa
parent
commit
cff6a488f8
Nessun account collegato all'indirizzo email del committer

+ 2
- 5
web/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout-main.tsx Vedi File

const pathname = usePathname() const pathname = usePathname()
const media = useBreakpoints() const media = useBreakpoints()
const isMobile = media === MediaType.mobile const isMobile = media === MediaType.mobile
const { isCurrentWorkspaceEditor, isLoadingCurrentWorkspace } = useAppContext()
const { isCurrentWorkspaceEditor, isLoadingCurrentWorkspace, currentWorkspace } = useAppContext()
const { appDetail, setAppDetail, setAppSiderbarExpand } = useStore(useShallow(state => ({ const { appDetail, setAppDetail, setAppSiderbarExpand } = useStore(useShallow(state => ({
appDetail: state.appDetail, appDetail: state.appDetail,
setAppDetail: state.setAppDetail, setAppDetail: state.setAppDetail,
// if ((appDetail.mode === 'advanced-chat' || appDetail.mode === 'workflow') && (pathname).endsWith('workflow')) // if ((appDetail.mode === 'advanced-chat' || appDetail.mode === 'workflow') && (pathname).endsWith('workflow'))
// setAppSiderbarExpand('collapse') // setAppSiderbarExpand('collapse')
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [appDetail, isMobile]) }, [appDetail, isMobile])


useEffect(() => { useEffect(() => {
}).finally(() => { }).finally(() => {
setIsLoadingAppDetail(false) setIsLoadingAppDetail(false)
}) })
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [appId, pathname]) }, [appId, pathname])


useEffect(() => { useEffect(() => {
if (!appDetailRes || isLoadingCurrentWorkspace || isLoadingAppDetail)
if (!appDetailRes || !currentWorkspace.id || isLoadingCurrentWorkspace || isLoadingAppDetail)
return return
const res = appDetailRes const res = appDetailRes
// redirection // redirection
setAppDetail({ ...res, enable_sso: false }) setAppDetail({ ...res, enable_sso: false })
setNavigation(getNavigations(appId, isCurrentWorkspaceEditor, res.mode)) setNavigation(getNavigations(appId, isCurrentWorkspaceEditor, res.mode))
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [appDetailRes, isCurrentWorkspaceEditor, isLoadingAppDetail, isLoadingCurrentWorkspace]) }, [appDetailRes, isCurrentWorkspaceEditor, isLoadingAppDetail, isLoadingCurrentWorkspace])


useUnmount(() => { useUnmount(() => {

+ 4
- 2
web/app/components/app/configuration/index.tsx Vedi File

import { MittProvider } from '@/context/mitt-context' import { MittProvider } from '@/context/mitt-context'
import { fetchAndMergeValidCompletionParams } from '@/utils/completion-params' import { fetchAndMergeValidCompletionParams } from '@/utils/completion-params'
import Toast from '@/app/components/base/toast' import Toast from '@/app/components/base/toast'
import { useAppContext } from '@/context/app-context'


type PublishConfig = { type PublishConfig = {
modelConfig: ModelConfig modelConfig: ModelConfig
const Configuration: FC = () => { const Configuration: FC = () => {
const { t } = useTranslation() const { t } = useTranslation()
const { notify } = useContext(ToastContext) const { notify } = useContext(ToastContext)
const { isLoadingCurrentWorkspace, currentWorkspace } = useAppContext()

const { appDetail, showAppConfigureFeaturesModal, setAppSiderbarExpand, setShowAppConfigureFeaturesModal } = useAppStore(useShallow(state => ({ const { appDetail, showAppConfigureFeaturesModal, setAppSiderbarExpand, setShowAppConfigureFeaturesModal } = useAppStore(useShallow(state => ({
appDetail: state.appDetail, appDetail: state.appDetail,
setAppSiderbarExpand: state.setAppSiderbarExpand, setAppSiderbarExpand: state.setAppSiderbarExpand,
setHasFetchedDetail(true) setHasFetchedDetail(true)
}) })
})() })()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [appId]) }, [appId])


const promptEmpty = (() => { const promptEmpty = (() => {
setAppSiderbarExpand('collapse') setAppSiderbarExpand('collapse')
} }


if (isLoading) {
if (isLoading || isLoadingCurrentWorkspace || !currentWorkspace.id) {
return <div className='flex h-full items-center justify-center'> return <div className='flex h-full items-center justify-center'>
<Loading type='area' /> <Loading type='area' />
</div> </div>

+ 3
- 1
web/app/components/workflow-app/index.tsx Vedi File

import type { Features as FeaturesData } from '@/app/components/base/features/types' import type { Features as FeaturesData } from '@/app/components/base/features/types'
import { FILE_EXTS } from '@/app/components/base/prompt-editor/constants' import { FILE_EXTS } from '@/app/components/base/prompt-editor/constants'
import { fetchFileUploadConfig } from '@/service/common' import { fetchFileUploadConfig } from '@/service/common'
import { useAppContext } from '@/context/app-context'
import WorkflowWithDefaultContext from '@/app/components/workflow' import WorkflowWithDefaultContext from '@/app/components/workflow'
import { import {
WorkflowContextProvider, WorkflowContextProvider,
data, data,
isLoading, isLoading,
} = useWorkflowInit() } = useWorkflowInit()
const { isLoadingCurrentWorkspace, currentWorkspace } = useAppContext()
const { data: fileUploadConfigResponse } = useSWR({ url: '/files/upload' }, fetchFileUploadConfig) const { data: fileUploadConfigResponse } = useSWR({ url: '/files/upload' }, fetchFileUploadConfig)


const nodesData = useMemo(() => { const nodesData = useMemo(() => {
return [] return []
}, [data]) }, [data])


if (!data || isLoading) {
if (!data || isLoading || isLoadingCurrentWorkspace || !currentWorkspace.id) {
return ( return (
<div className='relative flex h-full w-full items-center justify-center'> <div className='relative flex h-full w-full items-center justify-center'>
<Loading /> <Loading />

Loading…
Annulla
Salva