import React, { FC, memo } from 'react'; import { useTranslation } from 'react-i18next'; import { useSWRxV5MigrationStatus } from '~/stores/page-listing'; import { useCurrentPagePath, useCurrentPageId, useTargetAndAncestors, useIsGuestUser, useNotFoundTargetPathOrId, } from '~/stores/context'; import ItemsTree from './PageTree/ItemsTree'; import { PrivateLegacyPagesLink } from './PageTree/PrivateLegacyPagesLink'; const PageTree: FC = memo(() => { const { t } = useTranslation(); const { data: isGuestUser } = useIsGuestUser(); const { data: currentPath } = useCurrentPagePath(); const { data: targetId } = useCurrentPageId(); const { data: targetAndAncestorsData } = useTargetAndAncestors(); const { data: notFoundTargetPathOrIdData } = useNotFoundTargetPathOrId(); const { data: migrationStatus } = useSWRxV5MigrationStatus(); const targetPathOrId = targetId || notFoundTargetPathOrIdData?.notFoundTargetPathOrId; if (migrationStatus == null) { return ( <>

{t('Page Tree')}

Page Tree now loading...

); } if (!migrationStatus?.isV5Compatible) { // TODO : improve design // Story : https://redmine.weseek.co.jp/issues/83755 return ( <>

{t('Page Tree')}

{t('admin:v5_page_migration.page_tree_not_avaliable')}

{t('admin:v5_page_migration.go_to_settings')}
); } /* * dependencies */ if (isGuestUser == null) { return null; } const path = currentPath || '/'; return ( <>

{t('Page Tree')}

{!isGuestUser && migrationStatus?.migratablePagesCount != null && migrationStatus.migratablePagesCount !== 0 && (
)} ); }); export default PageTree;