Преглед на файлове

Merge pull request #6289 from weseek/feat/render-putback-page-modal

feat: Render putback page modal
Yuki Takei преди 3 години
родител
ревизия
307051d506
променени са 2 файла, в които са добавени 39 реда и са изтрити 0 реда
  1. 12 0
      packages/app/src/pages/[[...path]].page.tsx
  2. 27 0
      packages/app/src/pages/search.page.tsx

+ 12 - 0
packages/app/src/pages/[[...path]].page.tsx

@@ -77,6 +77,11 @@ const IdenticalPathPage = (): JSX.Element => {
   return <IdenticalPathPage />;
 };
 
+const PutbackPageModal = (): JSX.Element => {
+  const PutbackPageModal = dynamic(() => import('../components/PutbackPageModal'), { ssr: false });
+  return <PutbackPageModal />;
+};
+
 type IPageToShowRevisionWithMeta = IDataWithMeta<IPagePopulatedToShowRevision, IPageInfoForEntity>;
 
 type Props = CommonProps & {
@@ -194,6 +199,12 @@ const GrowiPage: NextPage<Props> = (props: Props) => {
   if (props.pageWithMetaStr != null) {
     pageWithMeta = JSON.parse(props.pageWithMetaStr) as IPageToShowRevisionWithMeta;
   }
+
+  let shouldRenderPutbackPageModal = false;
+  if (pageWithMeta != null) {
+    shouldRenderPutbackPageModal = _isTrashPage(pageWithMeta.data.path);
+  }
+
   useCurrentPageId(pageWithMeta?.data._id);
   useSWRxCurrentPage(undefined, pageWithMeta?.data); // store initial data
   // useSWRxPage(pageWithMeta?.data._id);
@@ -285,6 +296,7 @@ const GrowiPage: NextPage<Props> = (props: Props) => {
         </footer>
 
         <UnsavedAlertDialog />
+        {shouldRenderPutbackPageModal && <PutbackPageModal />}
 
       </BasicLayout>
     </>

+ 27 - 0
packages/app/src/pages/search.page.tsx

@@ -0,0 +1,27 @@
+import {
+  NextPage, GetServerSideProps,
+} from 'next';
+import dynamic from 'next/dynamic';
+
+const SearchPage: NextPage = () => {
+
+  const PutbackPageModal = (): JSX.Element => {
+    const PutbackPageModal = dynamic(() => import('../components/PutbackPageModal'), { ssr: false });
+    return <PutbackPageModal />;
+  };
+
+  return (
+    <>
+      SearchPage
+      <PutbackPageModal />
+    </>
+  );
+};
+
+export const getServerSideProps: GetServerSideProps = async() => {
+  return {
+    props: { },
+  };
+};
+
+export default SearchPage;