|
@@ -1,17 +1,16 @@
|
|
|
import React from 'react';
|
|
import React from 'react';
|
|
|
import PropTypes from 'prop-types';
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
-import { withTranslation } from 'react-i18next';
|
|
|
|
|
-
|
|
|
|
|
import { DevidedPagePath } from '@growi/core';
|
|
import { DevidedPagePath } from '@growi/core';
|
|
|
import PagePathHierarchicalLink from '~/components/PagePathHierarchicalLink';
|
|
import PagePathHierarchicalLink from '~/components/PagePathHierarchicalLink';
|
|
|
import LinkedPagePath from '~/models/linked-page-path';
|
|
import LinkedPagePath from '~/models/linked-page-path';
|
|
|
|
|
|
|
|
import { withUnstatedContainers } from '../UnstatedUtils';
|
|
import { withUnstatedContainers } from '../UnstatedUtils';
|
|
|
import AppContainer from '~/client/services/AppContainer';
|
|
import AppContainer from '~/client/services/AppContainer';
|
|
|
-import NavigationContainer from '~/client/services/NavigationContainer';
|
|
|
|
|
import PageContainer from '~/client/services/PageContainer';
|
|
import PageContainer from '~/client/services/PageContainer';
|
|
|
-import { useDrawerMode, useIsDeviceSmallerThanMd } from '~/stores/ui';
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ EditorMode, useDrawerMode, useEditorMode, useIsDeviceSmallerThanMd,
|
|
|
|
|
+} from '~/stores/ui';
|
|
|
|
|
|
|
|
import CopyDropdown from '../Page/CopyDropdown';
|
|
import CopyDropdown from '../Page/CopyDropdown';
|
|
|
import TagLabels from '../Page/TagLabels';
|
|
import TagLabels from '../Page/TagLabels';
|
|
@@ -70,22 +69,22 @@ const PagePathNav = ({
|
|
|
const GrowiSubNavigation = (props) => {
|
|
const GrowiSubNavigation = (props) => {
|
|
|
const { data: isDeviceSmallerThanMd } = useIsDeviceSmallerThanMd();
|
|
const { data: isDeviceSmallerThanMd } = useIsDeviceSmallerThanMd();
|
|
|
const { data: isDrawerMode } = useDrawerMode();
|
|
const { data: isDrawerMode } = useDrawerMode();
|
|
|
|
|
+ const { data: editorMode, mutate: mutateEditorMode } = useEditorMode();
|
|
|
|
|
|
|
|
const {
|
|
const {
|
|
|
- appContainer, navigationContainer, pageContainer, isCompactMode,
|
|
|
|
|
|
|
+ appContainer, pageContainer, isCompactMode,
|
|
|
} = props;
|
|
} = props;
|
|
|
- const { editorMode } = navigationContainer.state;
|
|
|
|
|
const {
|
|
const {
|
|
|
pageId, path, createdAt, creator, updatedAt, revisionAuthor, isPageExist,
|
|
pageId, path, createdAt, creator, updatedAt, revisionAuthor, isPageExist,
|
|
|
} = pageContainer.state;
|
|
} = pageContainer.state;
|
|
|
|
|
|
|
|
const { isGuestUser } = appContainer;
|
|
const { isGuestUser } = appContainer;
|
|
|
- const isEditorMode = editorMode !== 'view';
|
|
|
|
|
|
|
+ const isEditorMode = editorMode !== EditorMode.View;
|
|
|
// Tags cannot be edited while the new page and editorMode is view
|
|
// Tags cannot be edited while the new page and editorMode is view
|
|
|
- const isTagLabelHidden = (editorMode !== 'edit' && !isPageExist);
|
|
|
|
|
|
|
+ const isTagLabelHidden = (editorMode !== EditorMode.Editor && !isPageExist);
|
|
|
|
|
|
|
|
function onPageEditorModeButtonClicked(viewType) {
|
|
function onPageEditorModeButtonClicked(viewType) {
|
|
|
- navigationContainer.setEditorMode(viewType);
|
|
|
|
|
|
|
+ mutateEditorMode(viewType);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
@@ -149,16 +148,14 @@ const GrowiSubNavigation = (props) => {
|
|
|
/**
|
|
/**
|
|
|
* Wrapper component for using unstated
|
|
* Wrapper component for using unstated
|
|
|
*/
|
|
*/
|
|
|
-const GrowiSubNavigationWrapper = withUnstatedContainers(GrowiSubNavigation, [AppContainer, NavigationContainer, PageContainer]);
|
|
|
|
|
|
|
+const GrowiSubNavigationWrapper = withUnstatedContainers(GrowiSubNavigation, [AppContainer, PageContainer]);
|
|
|
|
|
|
|
|
|
|
|
|
|
GrowiSubNavigation.propTypes = {
|
|
GrowiSubNavigation.propTypes = {
|
|
|
- t: PropTypes.func.isRequired, // i18next
|
|
|
|
|
appContainer: PropTypes.instanceOf(AppContainer).isRequired,
|
|
appContainer: PropTypes.instanceOf(AppContainer).isRequired,
|
|
|
- navigationContainer: PropTypes.instanceOf(NavigationContainer).isRequired,
|
|
|
|
|
pageContainer: PropTypes.instanceOf(PageContainer).isRequired,
|
|
pageContainer: PropTypes.instanceOf(PageContainer).isRequired,
|
|
|
|
|
|
|
|
isCompactMode: PropTypes.bool,
|
|
isCompactMode: PropTypes.bool,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-export default withTranslation()(GrowiSubNavigationWrapper);
|
|
|
|
|
|
|
+export default GrowiSubNavigationWrapper;
|