|
|
@@ -1,4 +1,4 @@
|
|
|
-import React from 'react';
|
|
|
+import React, { useState } from 'react';
|
|
|
import PropTypes from 'prop-types';
|
|
|
import { withTranslation } from 'react-i18next';
|
|
|
|
|
|
@@ -6,6 +6,7 @@ import { isTopPage, isUserPage } from '@commons/util/path-utils';
|
|
|
import { createSubscribedElement } from '../UnstatedUtils';
|
|
|
import AppContainer from '../../services/AppContainer';
|
|
|
import PageContainer from '../../services/PageContainer';
|
|
|
+import PageDeleteModal from '../PageDeleteModal';
|
|
|
|
|
|
|
|
|
const PageManagement = (props) => {
|
|
|
@@ -15,6 +16,20 @@ const PageManagement = (props) => {
|
|
|
const isTopPagePath = isTopPage(path);
|
|
|
const isUserPagePath = isUserPage(path);
|
|
|
|
|
|
+ const [isPageDeleteModalShown, setIsPageDeleteModalShown] = useState(false);
|
|
|
+
|
|
|
+ function openPageDeleteModal() {
|
|
|
+ setIsPageDeleteModalShown(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ function closePageDeleteModal() {
|
|
|
+ setIsPageDeleteModalShown(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ async function onClickDeleteBtn() {
|
|
|
+ console.log('pushed');
|
|
|
+ }
|
|
|
+
|
|
|
function renderDropdownItemForNotTopPage() {
|
|
|
return (
|
|
|
<>
|
|
|
@@ -33,7 +48,7 @@ const PageManagement = (props) => {
|
|
|
return (
|
|
|
<>
|
|
|
<div className="dropdown-divider"></div>
|
|
|
- <a className="dropdown-item" href="#" data-target="#deletePage" data-toggle="modal">
|
|
|
+ <a className="dropdown-item" type="button" onClick={openPageDeleteModal}>
|
|
|
<i className="icon-fw icon-fire text-danger"></i> { t('Delete') }
|
|
|
</a>
|
|
|
</>
|
|
|
@@ -41,26 +56,29 @@ const PageManagement = (props) => {
|
|
|
}
|
|
|
|
|
|
return (
|
|
|
- <li className="nav-item dropdown">
|
|
|
- <a
|
|
|
- role="button"
|
|
|
- className={`nav-link dropdown-toggle dropdown-toggle-no-caret ${currentUser == null && 'dropdown-toggle-disabled'}`}
|
|
|
- href="#"
|
|
|
- data-toggle={`${currentUser == null ? 'tooltip' : 'dropdown'}`}
|
|
|
- data-placement="top"
|
|
|
- data-container="body"
|
|
|
- title={t('Not available for guest')}
|
|
|
- >
|
|
|
- <i className="icon-options-vertical"></i>
|
|
|
- </a>
|
|
|
- <div className="dropdown-menu dropdown-menu-right">
|
|
|
- {!isTopPagePath && renderDropdownItemForNotTopPage()}
|
|
|
- <a className="dropdown-item" href="#" data-target="#create-template" data-toggle="modal">
|
|
|
- <i className="icon-fw icon-magic-wand"></i> { t('template.option_label.create/edit') }
|
|
|
+ <>
|
|
|
+ <li className="nav-item dropdown">
|
|
|
+ <a
|
|
|
+ role="button"
|
|
|
+ className={`nav-link dropdown-toggle dropdown-toggle-no-caret ${currentUser == null && 'dropdown-toggle-disabled'}`}
|
|
|
+ href="#"
|
|
|
+ data-toggle={`${currentUser == null ? 'tooltip' : 'dropdown'}`}
|
|
|
+ data-placement="top"
|
|
|
+ data-container="body"
|
|
|
+ title={t('Not available for guest')}
|
|
|
+ >
|
|
|
+ <i className="icon-options-vertical"></i>
|
|
|
</a>
|
|
|
- {(!isTopPagePath && !isUserPagePath) && renderDropdownItemForDeletablePage()}
|
|
|
- </div>
|
|
|
- </li>
|
|
|
+ <div className="dropdown-menu dropdown-menu-right">
|
|
|
+ {!isTopPagePath && renderDropdownItemForNotTopPage()}
|
|
|
+ <a className="dropdown-item" href="#" data-target="#create-template" data-toggle="modal">
|
|
|
+ <i className="icon-fw icon-magic-wand"></i> { t('template.option_label.create/edit') }
|
|
|
+ </a>
|
|
|
+ {(!isTopPagePath && !isUserPagePath) && renderDropdownItemForDeletablePage()}
|
|
|
+ </div>
|
|
|
+ </li>
|
|
|
+ <PageDeleteModal isOpen={isPageDeleteModalShown} toggle={closePageDeleteModal} onClickSubmit={onClickDeleteBtn} path={path} />
|
|
|
+ </>
|
|
|
);
|
|
|
};
|
|
|
|