fix: console page show error if click app card

pull/19898/head
NFish 1 year ago
parent 27716538e6
commit 96ff86a627

@ -15,14 +15,13 @@ import {
} from '@remixicon/react' } from '@remixicon/react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { useShallow } from 'zustand/react/shallow' import { useShallow } from 'zustand/react/shallow'
import { useContextSelector } from 'use-context-selector'
import s from './style.module.css' import s from './style.module.css'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import { useStore } from '@/app/components/app/store' import { useStore } from '@/app/components/app/store'
import AppSideBar from '@/app/components/app-sidebar' import AppSideBar from '@/app/components/app-sidebar'
import type { NavIcon } from '@/app/components/app-sidebar/navLink' import type { NavIcon } from '@/app/components/app-sidebar/navLink'
import { fetchAppDetail, fetchAppSSO } from '@/service/apps' import { fetchAppDetail } from '@/service/apps'
import AppContext, { useAppContext } from '@/context/app-context' import { useAppContext } from '@/context/app-context'
import Loading from '@/app/components/base/loading' import Loading from '@/app/components/base/loading'
import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints' import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
import type { App } from '@/types/app' import type { App } from '@/types/app'
@ -56,7 +55,6 @@ const AppDetailLayout: FC<IAppDetailLayoutProps> = (props) => {
icon: NavIcon icon: NavIcon
selectedIcon: NavIcon selectedIcon: NavIcon
}>>([]) }>>([])
const systemFeatures = useContextSelector(AppContext, state => state.systemFeatures)
const getNavigations = useCallback((appId: string, isCurrentWorkspaceEditor: boolean, mode: string) => { const getNavigations = useCallback((appId: string, isCurrentWorkspaceEditor: boolean, mode: string) => {
const navs = [ const navs = [
@ -142,14 +140,9 @@ const AppDetailLayout: FC<IAppDetailLayoutProps> = (props) => {
else { else {
setAppDetail({ ...res, enable_sso: false }) setAppDetail({ ...res, enable_sso: false })
setNavigation(getNavigations(appId, isCurrentWorkspaceEditor, res.mode)) setNavigation(getNavigations(appId, isCurrentWorkspaceEditor, res.mode))
if (systemFeatures.enable_web_sso_switch_component && canIEditApp) {
fetchAppSSO({ appId }).then((ssoRes) => {
setAppDetail({ ...res, enable_sso: ssoRes.enabled })
})
}
} }
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [appDetailRes, isCurrentWorkspaceEditor, isLoadingAppDetail, isLoadingCurrentWorkspace, systemFeatures.enable_web_sso_switch_component]) }, [appDetailRes, isCurrentWorkspaceEditor, isLoadingAppDetail, isLoadingCurrentWorkspace])
useUnmount(() => { useUnmount(() => {
setAppDetail() setAppDetail()

@ -26,9 +26,8 @@ import type { StartNodeType } from '@/app/components/workflow/nodes/start/types'
import { useToastContext } from '@/app/components/base/toast' import { useToastContext } from '@/app/components/base/toast'
import { usePublishWorkflow, useResetWorkflowVersionHistory } from '@/service/use-workflow' import { usePublishWorkflow, useResetWorkflowVersionHistory } from '@/service/use-workflow'
import type { PublishWorkflowParams } from '@/types/workflow' import type { PublishWorkflowParams } from '@/types/workflow'
import { fetchAppDetail, fetchAppSSO } from '@/service/apps' import { fetchAppDetail } from '@/service/apps'
import { useStore as useAppStore } from '@/app/components/app/store' import { useStore as useAppStore } from '@/app/components/app/store'
import { useSelector as useAppSelector } from '@/context/app-context'
const FeaturesTrigger = () => { const FeaturesTrigger = () => {
const { t } = useTranslation() const { t } = useTranslation()
@ -36,7 +35,6 @@ const FeaturesTrigger = () => {
const appDetail = useAppStore(s => s.appDetail) const appDetail = useAppStore(s => s.appDetail)
const appID = appDetail?.id const appID = appDetail?.id
const setAppDetail = useAppStore(s => s.setAppDetail) const setAppDetail = useAppStore(s => s.setAppDetail)
const systemFeatures = useAppSelector(state => state.systemFeatures)
const { const {
nodesReadOnly, nodesReadOnly,
getNodesReadOnly, getNodesReadOnly,
@ -85,18 +83,12 @@ const FeaturesTrigger = () => {
const updateAppDetail = useCallback(async () => { const updateAppDetail = useCallback(async () => {
try { try {
const res = await fetchAppDetail({ url: '/apps', id: appID! }) const res = await fetchAppDetail({ url: '/apps', id: appID! })
if (systemFeatures.enable_web_sso_switch_component) {
const ssoRes = await fetchAppSSO({ appId: appID! })
setAppDetail({ ...res, enable_sso: ssoRes.enabled })
}
else {
setAppDetail({ ...res }) setAppDetail({ ...res })
} }
}
catch (error) { catch (error) {
console.error(error) console.error(error)
} }
}, [appID, setAppDetail, systemFeatures.enable_web_sso_switch_component]) }, [appID, setAppDetail])
const { mutateAsync: publishWorkflow } = usePublishWorkflow(appID!) const { mutateAsync: publishWorkflow } = usePublishWorkflow(appID!)
const onPublish = useCallback(async (params?: PublishWorkflowParams) => { const onPublish = useCallback(async (params?: PublishWorkflowParams) => {
if (await handleCheckBeforePublish()) { if (await handleCheckBeforePublish()) {

@ -23,7 +23,6 @@ export type SystemFeatures = {
sso_enforced_for_signin_protocol: SSOProtocol | '' sso_enforced_for_signin_protocol: SSOProtocol | ''
sso_enforced_for_web: boolean sso_enforced_for_web: boolean
sso_enforced_for_web_protocol: SSOProtocol | '' sso_enforced_for_web_protocol: SSOProtocol | ''
enable_web_sso_switch_component: boolean
enable_marketplace: boolean enable_marketplace: boolean
enable_email_code_login: boolean enable_email_code_login: boolean
enable_email_password_login: boolean enable_email_password_login: boolean
@ -55,7 +54,6 @@ export const defaultSystemFeatures: SystemFeatures = {
sso_enforced_for_signin_protocol: '', sso_enforced_for_signin_protocol: '',
sso_enforced_for_web: false, sso_enforced_for_web: false,
sso_enforced_for_web_protocol: '', sso_enforced_for_web_protocol: '',
enable_web_sso_switch_component: false,
enable_marketplace: false, enable_marketplace: false,
enable_email_code_login: false, enable_email_code_login: false,
enable_email_password_login: false, enable_email_password_login: false,

Loading…
Cancel
Save