Commit 067e6b5a authored by JzoNg's avatar JzoNg

app detail redirection

parent 6adb9861
...@@ -122,14 +122,7 @@ const AppCard = ({ app, onRefresh }: AppCardProps) => { ...@@ -122,14 +122,7 @@ const AppCard = ({ app, onRefresh }: AppCardProps) => {
message: t('app.newApp.appCreated'), message: t('app.newApp.appCreated'),
}) })
localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1') localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1')
if (!isCurrentWorkspaceManager) { getRedirection(isCurrentWorkspaceManager, newApp, push)
push(`/app/${newApp.id}/overview`)
}
else {
if (newApp.mode === 'workflow' || newApp.mode === 'advanced-chat')
push(`/app/${newApp.id}/workflow`)
push(`/app/${newApp.id}/configuration`)
}
} }
catch (e) { catch (e) {
notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) notify({ type: 'error', message: t('app.newApp.appCreateFailed') })
......
...@@ -19,6 +19,7 @@ import { ChatBot, CuteRobot } from '@/app/components/base/icons/src/vender/line/ ...@@ -19,6 +19,7 @@ import { ChatBot, CuteRobot } from '@/app/components/base/icons/src/vender/line/
import { HelpCircle } from '@/app/components/base/icons/src/vender/line/general' import { HelpCircle } from '@/app/components/base/icons/src/vender/line/general'
import { Route } from '@/app/components/base/icons/src/vender/line/mapsAndTravel' import { Route } from '@/app/components/base/icons/src/vender/line/mapsAndTravel'
import TooltipPlus from '@/app/components/base/tooltip-plus' import TooltipPlus from '@/app/components/base/tooltip-plus'
import { getRedirection } from '@/utils/app-redirection'
export type AppFormProps = { export type AppFormProps = {
onConfirm: () => void onConfirm: () => void
...@@ -32,7 +33,7 @@ const AppForm = ({ ...@@ -32,7 +33,7 @@ const AppForm = ({
onTipChange, onTipChange,
}: AppFormProps) => { }: AppFormProps) => {
const { t } = useTranslation() const { t } = useTranslation()
const router = useRouter() const { push } = useRouter()
const { notify } = useContext(ToastContext) const { notify } = useContext(ToastContext)
const mutateApps = useContextSelector(AppsContext, state => state.mutateApps) const mutateApps = useContextSelector(AppsContext, state => state.mutateApps)
...@@ -73,21 +74,13 @@ const AppForm = ({ ...@@ -73,21 +74,13 @@ const AppForm = ({
onConfirm() onConfirm()
onHide() onHide()
mutateApps() mutateApps()
if (!isCurrentWorkspaceManager) { getRedirection(isCurrentWorkspaceManager, app, push)
router.push(`/app/${app.id}/overview`)
}
else {
if (app.mode === 'workflow' || app.mode === 'advanced-chat')
router.push(`/app/${app.id}/workflow`)
else
router.push(`/app/${app.id}/configuration`)
}
} }
catch (e) { catch (e) {
notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) notify({ type: 'error', message: t('app.newApp.appCreateFailed') })
} }
isCreatingRef.current = false isCreatingRef.current = false
}, [name, notify, t, appMode, emoji.icon, emoji.icon_background, description, onConfirm, onHide, mutateApps, router, isCurrentWorkspaceManager]) }, [name, notify, t, appMode, emoji.icon, emoji.icon_background, description, onConfirm, onHide, mutateApps, push, isCurrentWorkspaceManager])
return ( return (
<div className='overflow-y-auto'> <div className='overflow-y-auto'>
......
...@@ -15,6 +15,7 @@ import { useProviderContext } from '@/context/provider-context' ...@@ -15,6 +15,7 @@ import { useProviderContext } from '@/context/provider-context'
import AppsFull from '@/app/components/billing/apps-full-in-dialog' import AppsFull from '@/app/components/billing/apps-full-in-dialog'
import { XClose } from '@/app/components/base/icons/src/vender/line/general' import { XClose } from '@/app/components/base/icons/src/vender/line/general'
import { NEED_REFRESH_APP_LIST_KEY } from '@/config' import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
import { getRedirection } from '@/utils/app-redirection'
type CreateFromDSLModalProps = { type CreateFromDSLModalProps = {
show: boolean show: boolean
...@@ -23,7 +24,7 @@ type CreateFromDSLModalProps = { ...@@ -23,7 +24,7 @@ type CreateFromDSLModalProps = {
} }
const CreateFromDSLModal = ({ show, onSuccess, onClose }: CreateFromDSLModalProps) => { const CreateFromDSLModal = ({ show, onSuccess, onClose }: CreateFromDSLModalProps) => {
const router = useRouter() const { push } = useRouter()
const { t } = useTranslation() const { t } = useTranslation()
const { notify } = useContext(ToastContext) const { notify } = useContext(ToastContext)
const [currentFile, setDSLFile] = useState<File>() const [currentFile, setDSLFile] = useState<File>()
...@@ -67,14 +68,7 @@ const CreateFromDSLModal = ({ show, onSuccess, onClose }: CreateFromDSLModalProp ...@@ -67,14 +68,7 @@ const CreateFromDSLModal = ({ show, onSuccess, onClose }: CreateFromDSLModalProp
onClose() onClose()
notify({ type: 'success', message: t('app.newApp.appCreated') }) notify({ type: 'success', message: t('app.newApp.appCreated') })
localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1') localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1')
if (!isCurrentWorkspaceManager) { getRedirection(isCurrentWorkspaceManager, app, push)
router.push(`/app/${app.id}/overview`)
}
else {
if (app.mode === 'workflow' || app.mode === 'advanced-chat')
router.push(`/app/${app.id}/workflow`)
router.push(`/app/${app.id}/configuration`)
}
} }
catch (e) { catch (e) {
notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) notify({ type: 'error', message: t('app.newApp.appCreateFailed') })
......
...@@ -20,6 +20,7 @@ import type { CreateAppModalProps } from '@/app/components/explore/create-app-mo ...@@ -20,6 +20,7 @@ import type { CreateAppModalProps } from '@/app/components/explore/create-app-mo
import Loading from '@/app/components/base/loading' import Loading from '@/app/components/base/loading'
import { NEED_REFRESH_APP_LIST_KEY } from '@/config' import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
import { useAppContext } from '@/context/app-context' import { useAppContext } from '@/context/app-context'
import { getRedirection } from '@/utils/app-redirection'
type AppsProps = { type AppsProps = {
pageType?: PageType pageType?: PageType
...@@ -35,7 +36,7 @@ const Apps = ({ ...@@ -35,7 +36,7 @@ const Apps = ({
}: AppsProps) => { }: AppsProps) => {
const { t } = useTranslation() const { t } = useTranslation()
const { isCurrentWorkspaceManager } = useAppContext() const { isCurrentWorkspaceManager } = useAppContext()
const router = useRouter() const { push } = useRouter()
const { hasEditPermission } = useContext(ExploreContext) const { hasEditPermission } = useContext(ExploreContext)
const allCategoriesEn = t('explore.apps.allCategories', { lng: 'en' }) const allCategoriesEn = t('explore.apps.allCategories', { lng: 'en' })
...@@ -89,14 +90,7 @@ const Apps = ({ ...@@ -89,14 +90,7 @@ const Apps = ({
message: t('app.newApp.appCreated'), message: t('app.newApp.appCreated'),
}) })
localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1') localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1')
if (!isCurrentWorkspaceManager) { getRedirection(isCurrentWorkspaceManager, app, push)
router.push(`/app/${app.id}/overview`)
}
else {
if (app.mode === 'workflow' || app.mode === 'advanced-chat')
router.push(`/app/${app.id}/workflow`)
router.push(`/app/${app.id}/configuration`)
}
} }
catch (e) { catch (e) {
Toast.notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) Toast.notify({ type: 'error', message: t('app.newApp.appCreateFailed') })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment