Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imprv: Display page tree in page select modal with scrollbar #9023

Merged
merged 11 commits into from
Sep 3, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.grw-page-select-modal-wrapper {
height: 50vh;
}
42 changes: 31 additions & 11 deletions apps/app/src/client/components/PageSelectModal/PageSelectModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { FC } from 'react';
import {
Suspense, useState, useCallback,
memo,
} from 'react';

import nodePath from 'path';
Expand All @@ -10,6 +11,7 @@ import { useTranslation } from 'next-i18next';
import {
Modal, ModalHeader, ModalBody, ModalFooter, Button,
} from 'reactstrap';
import SimpleBar from 'simplebar-react';

import type { IPageForItem } from '~/interfaces/page';
import { useTargetAndAncestors, useIsGuestUser, useIsReadOnlyUser } from '~/stores-universal/context';
Expand All @@ -22,6 +24,20 @@ import { usePagePathRenameHandler } from '../PageEditor/page-path-rename-utils';

import { TreeItemForModal } from './TreeItemForModal';

import 'simplebar-react/dist/simplebar.min.css';

const TreeForModalWrapper = memo((props: { children: JSX.Element }) => {
miya marked this conversation as resolved.
Show resolved Hide resolved

const { children } = props;
return (
<div className="grw-page-select-modal-wrapper">
<SimpleBar style={{ maxHeight: 350 }}>
{ children }
</SimpleBar>
</div>
);
});

export const PageSelectModal: FC = () => {
const {
data: PageSelectModalData,
Expand Down Expand Up @@ -82,20 +98,24 @@ export const PageSelectModal: FC = () => {
isOpen={isOpened}
toggle={closeModal}
centered
size="sm"
size="lg"
>
<ModalHeader toggle={closeModal}>{t('page_select_modal.select_page_location')}</ModalHeader>
<ModalBody>
<ModalBody className="p-0">
<Suspense fallback={<ItemsTreeContentSkeleton />}>
<ItemsTree
CustomTreeItem={TreeItemForModal}
isEnableActions={!isGuestUser}
isReadOnlyUser={!!isReadOnlyUser}
targetPath={targetPath}
targetPathOrId={targetPathOrId}
targetAndAncestorsData={targetAndAncestorsData}
onClickTreeItem={onClickTreeItem}
/>
<TreeForModalWrapper>
<div className="p-3">
<ItemsTree
CustomTreeItem={TreeItemForModal}
isEnableActions={!isGuestUser}
isReadOnlyUser={!!isReadOnlyUser}
targetPath={targetPath}
targetPathOrId={targetPathOrId}
targetAndAncestorsData={targetAndAncestorsData}
onClickTreeItem={onClickTreeItem}
/>
</div>
</TreeForModalWrapper>
</Suspense>
</ModalBody>
<ModalFooter>
Expand Down
Loading