WNomunomu 2 лет назад
Родитель
Сommit
f3ac093f3b

+ 8 - 18
apps/app/src/components/Sidebar/PageTree/PageTreeItem.tsx

@@ -4,37 +4,27 @@ import React, {
 
 import nodePath from 'path';
 
-import { pagePathUtils, Nullable } from '@growi/core';
+import { pagePathUtils } from '@growi/core';
 import { useTranslation } from 'next-i18next';
 import { useDrag, useDrop } from 'react-dnd';
 
 import { apiv3Put } from '~/client/util/apiv3-client';
 import { toastWarning, toastError } from '~/client/util/toastr';
-import { IPageHasId, IPageToDeleteWithMeta } from '~/interfaces/page';
-import { IPageForPageDuplicateModal } from '~/stores/modal';
+import { IPageHasId } from '~/interfaces/page';
 import { mutatePageTree, useSWRxPageChildren } from '~/stores/page-listing';
 import loggerFactory from '~/utils/logger';
 
 
 import { ItemNode } from './ItemNode';
-import SimpleItem from './SimpleItem';
-
+import SimpleItem, { SimpleItemProps } from './SimpleItem';
 
 const logger = loggerFactory('growi:cli:Item');
 
-interface ItemProps {
-  key
-  isEnableActions: boolean
-  isReadOnlyUser: boolean
-  itemNode: ItemNode
-  targetPathOrId?: Nullable<string>
-  isOpen?: boolean
-  onRenamed?(fromPath: string | undefined, toPath: string): void
-  onClickDuplicateMenuItem?(pageToDuplicate: IPageForPageDuplicateModal): void
-  onClickDeleteMenuItem?(pageToDelete: IPageToDeleteWithMeta): void
-}
-
-export const PageTreeItem: FC<ItemProps> = (props: ItemProps) => {
+type Optional = 'itemRef' | 'itemClass' | 'mainClassName';
+
+type PageTreeItemProps = Omit<SimpleItemProps, Optional> & {key};
+
+export const PageTreeItem: FC<PageTreeItemProps> = (props: PageTreeItemProps) => {
   const getNewPathAfterMoved = (droppedPagePath: string, newParentPagePath: string): string => {
     const pageTitle = nodePath.basename(droppedPagePath);
     return nodePath.join(newParentPagePath, pageTitle);

+ 4 - 4
apps/app/src/components/Sidebar/PageTree/SimpleItem.tsx

@@ -35,7 +35,7 @@ import { PageItemControl } from '../../Common/Dropdown/PageItemControl';
 import { ItemNode } from './ItemNode';
 
 
-interface ItemProps {
+export type SimpleItemProps = {
   isEnableActions: boolean
   isReadOnlyUser: boolean
   itemNode: ItemNode
@@ -45,9 +45,9 @@ interface ItemProps {
   onClickDuplicateMenuItem?(pageToDuplicate: IPageForPageDuplicateModal): void
   onClickDeleteMenuItem?(pageToDelete: IPageToDeleteWithMeta): void
   itemRef?
-  itemClass?: React.FunctionComponent<ItemProps>
+  itemClass?: React.FunctionComponent<SimpleItemProps>
   mainClassName?: string
-}
+};
 
 // Utility to mark target
 const markTarget = (children: ItemNode[], targetPathOrId?: Nullable<string>): void => {
@@ -91,7 +91,7 @@ const NotDraggableForClosableTextInput = (props: NotDraggableProps): JSX.Element
 };
 
 
-const SimpleItem: FC<ItemProps> = (props: ItemProps) => {
+const SimpleItem: FC<SimpleItemProps> = (props: SimpleItemProps) => {
   const { t } = useTranslation();
   const router = useRouter();