| setAppDetail() | setAppDetail() | ||||
| fetchAppDetail({ url: '/apps', id: appId }).then((res) => { | fetchAppDetail({ url: '/apps', id: appId }).then((res) => { | ||||
| // redirection | // redirection | ||||
| const canIEditApp = isCurrentWorkspaceEditor | |||||
| if (!canIEditApp && (pathname.endsWith('configuration') || pathname.endsWith('workflow') || pathname.endsWith('logs'))) { | |||||
| router.replace(`/app/${appId}/overview`) | |||||
| return | |||||
| } | |||||
| if ((res.mode === 'workflow' || res.mode === 'advanced-chat') && (pathname).endsWith('configuration')) { | if ((res.mode === 'workflow' || res.mode === 'advanced-chat') && (pathname).endsWith('configuration')) { | ||||
| router.replace(`/app/${appId}/workflow`) | router.replace(`/app/${appId}/workflow`) | ||||
| } | } | ||||
| 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) { | |||||
| if (systemFeatures.enable_web_sso_switch_component && canIEditApp) { | |||||
| fetchAppSSO({ appId }).then((ssoRes) => { | fetchAppSSO({ appId }).then((ssoRes) => { | ||||
| setAppDetail({ ...res, enable_sso: ssoRes.enabled }) | setAppDetail({ ...res, enable_sso: ssoRes.enabled }) | ||||
| }) | }) | ||||
| if (e.status === 404) | if (e.status === 404) | ||||
| router.replace('/apps') | router.replace('/apps') | ||||
| }) | }) | ||||
| }, [appId, isCurrentWorkspaceEditor, systemFeatures]) | |||||
| }, [appId, isCurrentWorkspaceEditor, systemFeatures, getNavigations, pathname, router, setAppDetail]) | |||||
| useUnmount(() => { | useUnmount(() => { | ||||
| setAppDetail() | setAppDetail() | 
| import { useToastContext } from '@/app/components/base/toast' | import { useToastContext } from '@/app/components/base/toast' | ||||
| import { languages } from '@/i18n/language' | import { languages } from '@/i18n/language' | ||||
| import Tooltip from '@/app/components/base/tooltip' | import Tooltip from '@/app/components/base/tooltip' | ||||
| import AppContext from '@/context/app-context' | |||||
| import AppContext, { useAppContext } from '@/context/app-context' | |||||
| import type { AppIconSelection } from '@/app/components/base/app-icon-picker' | import type { AppIconSelection } from '@/app/components/base/app-icon-picker' | ||||
| import AppIconPicker from '@/app/components/base/app-icon-picker' | import AppIconPicker from '@/app/components/base/app-icon-picker' | ||||
| onSave, | onSave, | ||||
| }) => { | }) => { | ||||
| const systemFeatures = useContextSelector(AppContext, state => state.systemFeatures) | const systemFeatures = useContextSelector(AppContext, state => state.systemFeatures) | ||||
| const { isCurrentWorkspaceEditor } = useAppContext() | |||||
| const { notify } = useToastContext() | const { notify } = useToastContext() | ||||
| const [isShowMore, setIsShowMore] = useState(false) | const [isShowMore, setIsShowMore] = useState(false) | ||||
| const { | const { | ||||
| } | } | ||||
| asChild={false} | asChild={false} | ||||
| > | > | ||||
| <Switch disabled={!systemFeatures.sso_enforced_for_web} defaultValue={systemFeatures.sso_enforced_for_web && inputInfo.enable_sso} onChange={v => setInputInfo({ ...inputInfo, enable_sso: v })}></Switch> | |||||
| <Switch disabled={!systemFeatures.sso_enforced_for_web || !isCurrentWorkspaceEditor} defaultValue={systemFeatures.sso_enforced_for_web && inputInfo.enable_sso} onChange={v => setInputInfo({ ...inputInfo, enable_sso: v })}></Switch> | |||||
| </Tooltip> | </Tooltip> | ||||
| </div> | </div> | ||||
| <p className='body-xs-regular text-gray-500'>{t(`${prefixSettings}.sso.description`)}</p> | <p className='body-xs-regular text-gray-500'>{t(`${prefixSettings}.sso.description`)}</p> |