import React, { FC, memo } from 'react'; import { useTranslation } from 'next-i18next'; import { useCurrentPageId, useTargetAndAncestors, useIsGuestUser, } from '~/stores/context'; import { useCurrentPagePath } from '~/stores/page'; import { useSWRxV5MigrationStatus } from '~/stores/page-listing'; import ItemsTree from './PageTree/ItemsTree'; import { PrivateLegacyPagesLink } from './PageTree/PrivateLegacyPagesLink'; import { SidebarHeader } from './SidebarHeader'; import PageTreeContentSkelton from './Skelton/PageTreeContentSkelton'; 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: migrationStatus } = useSWRxV5MigrationStatus(); const targetPathOrId = targetId || currentPath; if (migrationStatus == null) { return ( <> ); } if (!migrationStatus?.isV5Compatible) { // TODO : improve design // Story : https://redmine.weseek.co.jp/issues/83755 return ( <>

{t('v5_page_migration.page_tree_not_avaliable')}

{t('v5_page_migration.go_to_settings')}
); } /* * dependencies */ if (isGuestUser == null) { return null; } const path = currentPath || '/'; return ( <> {!isGuestUser && migrationStatus?.migratablePagesCount != null && migrationStatus.migratablePagesCount !== 0 && (
)} ); }); PageTree.displayName = 'PageTree'; export default PageTree;