|
@@ -1,58 +1,14 @@
|
|
|
import React, { useMemo } from 'react';
|
|
import React, { useMemo } from 'react';
|
|
|
|
|
|
|
|
import PropTypes from 'prop-types';
|
|
import PropTypes from 'prop-types';
|
|
|
-import { withTranslation, useTranslation } from 'react-i18next';
|
|
|
|
|
-
|
|
|
|
|
-import { usePageDeleteModal } from '~/stores/modal';
|
|
|
|
|
-import { useSWRxDescendantsPageListForCurrrentPath, useSWRxPageInfoForList } from '~/stores/page';
|
|
|
|
|
|
|
+import { withTranslation } from 'react-i18next';
|
|
|
|
|
|
|
|
import CustomNavAndContents from './CustomNavigation/CustomNavAndContents';
|
|
import CustomNavAndContents from './CustomNavigation/CustomNavAndContents';
|
|
|
import { DescendantsPageListForCurrentPath } from './DescendantsPageList';
|
|
import { DescendantsPageListForCurrentPath } from './DescendantsPageList';
|
|
|
|
|
+import EmptyTrashButton from './EmptyTrashButton';
|
|
|
import PageListIcon from './Icons/PageListIcon';
|
|
import PageListIcon from './Icons/PageListIcon';
|
|
|
|
|
|
|
|
|
|
|
|
|
-const EmptyTrashButton = () => {
|
|
|
|
|
- const { t } = useTranslation();
|
|
|
|
|
- const { open: openDeleteModal } = usePageDeleteModal();
|
|
|
|
|
- const { data: pagingResult } = useSWRxDescendantsPageListForCurrrentPath();
|
|
|
|
|
-
|
|
|
|
|
- const pageIds = pagingResult?.items?.map(page => page._id);
|
|
|
|
|
- const { injectTo } = useSWRxPageInfoForList(pageIds, true, true);
|
|
|
|
|
-
|
|
|
|
|
- let pageWithMetas = [];
|
|
|
|
|
-
|
|
|
|
|
- const convertToIDataWithMeta = (page) => {
|
|
|
|
|
- return { data: page };
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- if (pagingResult != null) {
|
|
|
|
|
- const dataWithMetas = pagingResult.items.map(page => convertToIDataWithMeta(page));
|
|
|
|
|
- pageWithMetas = injectTo(dataWithMetas);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const onDeletedHandler = (...args) => {
|
|
|
|
|
- // process after multipe pages delete api
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- const emptyTrashClickHandler = () => {
|
|
|
|
|
- openDeleteModal(pageWithMetas, { onDeleted: onDeletedHandler, emptyTrash: true });
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- return (
|
|
|
|
|
- <div className="d-flex align-items-center">
|
|
|
|
|
- <button
|
|
|
|
|
- type="button"
|
|
|
|
|
- className="btn btn-outline-secondary rounded-pill text-danger d-flex align-items-center"
|
|
|
|
|
- onClick={() => emptyTrashClickHandler()}
|
|
|
|
|
- >
|
|
|
|
|
- <i className="icon-fw icon-trash"></i>
|
|
|
|
|
- <div>{t('modal_delete.empty_trash')}</div>
|
|
|
|
|
- </button>
|
|
|
|
|
- </div>
|
|
|
|
|
- );
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
const TrashPageList = (props) => {
|
|
const TrashPageList = (props) => {
|
|
|
const { t } = props;
|
|
const { t } = props;
|
|
|
|
|
|
|
@@ -67,9 +23,13 @@ const TrashPageList = (props) => {
|
|
|
};
|
|
};
|
|
|
}, [t]);
|
|
}, [t]);
|
|
|
|
|
|
|
|
|
|
+ const EmptyTrashButton = useMemo(() => {
|
|
|
|
|
+ return <EmptyTrashButton />;
|
|
|
|
|
+ }, [t]);
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<div data-testid="trash-page-list" className="mt-5 d-edit-none">
|
|
<div data-testid="trash-page-list" className="mt-5 d-edit-none">
|
|
|
- <CustomNavAndContents navTabMapping={navTabMapping} navRightElement={EmptyTrashButton()} />
|
|
|
|
|
|
|
+ <CustomNavAndContents navTabMapping={navTabMapping} navRightElement={EmptyTrashButton} />
|
|
|
</div>
|
|
</div>
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|