|
|
@@ -9,6 +9,7 @@ import { smoothScrollIntoView } from '~/client/util/smooth-scroll';
|
|
|
import {
|
|
|
useCurrentPagePath, useIsSharedUser, useIsEditable, useCurrentPageId, useIsUserPage, usePageUser,
|
|
|
} from '~/stores/context';
|
|
|
+import { useSWRxSlackChannels, useSWRxIsSlackEnabled } from '~/stores/editor';
|
|
|
import { useDescendantsPageListModal } from '~/stores/modal';
|
|
|
import { useSWRxPageByPath } from '~/stores/page';
|
|
|
import { EditorMode, useEditorMode } from '~/stores/ui';
|
|
|
@@ -33,18 +34,21 @@ const { isTopPage } = pagePathUtils;
|
|
|
const DisplaySwitcher = (): JSX.Element => {
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
-
|
|
|
// get element for smoothScroll
|
|
|
const getCommentListDom = useMemo(() => { return document.getElementById('page-comments-list') }, []);
|
|
|
|
|
|
|
|
|
const { data: currentPageId } = useCurrentPageId();
|
|
|
- const { data: currentPath } = useCurrentPagePath();
|
|
|
+ const { data: currentPagePath } = useCurrentPagePath();
|
|
|
const { data: isSharedUser } = useIsSharedUser();
|
|
|
const { data: isUserPage } = useIsUserPage();
|
|
|
const { data: isEditable } = useIsEditable();
|
|
|
const { data: pageUser } = usePageUser();
|
|
|
- const { data: currentPage } = useSWRxPageByPath(currentPath);
|
|
|
+ const { data: currentPage } = useSWRxPageByPath(currentPagePath);
|
|
|
+
|
|
|
+ const { data: slackChannelsData } = useSWRxSlackChannels(currentPagePath);
|
|
|
+ const isSlackEnabledByDefault = (slackChannelsData != null && slackChannelsData.length > 0) || false;
|
|
|
+ const { data: isSlackEnabled } = useSWRxIsSlackEnabled(isSlackEnabledByDefault);
|
|
|
|
|
|
const { data: editorMode } = useEditorMode();
|
|
|
|
|
|
@@ -52,7 +56,7 @@ const DisplaySwitcher = (): JSX.Element => {
|
|
|
|
|
|
const isPageExist = currentPageId != null;
|
|
|
const isViewMode = editorMode === EditorMode.View;
|
|
|
- const isTopPagePath = isTopPage(currentPath ?? '');
|
|
|
+ const isTopPagePath = isTopPage(currentPagePath ?? '');
|
|
|
|
|
|
return (
|
|
|
<>
|
|
|
@@ -66,11 +70,11 @@ const DisplaySwitcher = (): JSX.Element => {
|
|
|
|
|
|
{/* Page list */}
|
|
|
<div className="grw-page-accessories-control">
|
|
|
- { currentPath != null && !isSharedUser && (
|
|
|
+ { currentPagePath != null && !isSharedUser && (
|
|
|
<button
|
|
|
type="button"
|
|
|
className="btn btn-block btn-outline-secondary grw-btn-page-accessories rounded-pill d-flex justify-content-between align-items-center"
|
|
|
- onClick={() => openDescendantPageListModal(currentPath)}
|
|
|
+ onClick={() => openDescendantPageListModal(currentPagePath)}
|
|
|
>
|
|
|
<div className="grw-page-accessories-control-icon">
|
|
|
<PageListIcon />
|
|
|
@@ -109,7 +113,7 @@ const DisplaySwitcher = (): JSX.Element => {
|
|
|
|
|
|
<div className="flex-grow-1 flex-basis-0 mw-0">
|
|
|
{ isUserPage && <UserInfo pageUser={pageUser} />}
|
|
|
- <Page />
|
|
|
+ <Page isSlackEnabled={isSlackEnabled} />
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
@@ -117,14 +121,14 @@ const DisplaySwitcher = (): JSX.Element => {
|
|
|
{ isEditable && (
|
|
|
<TabPane tabId={EditorMode.Editor}>
|
|
|
<div data-testid="page-editor" id="page-editor">
|
|
|
- <Editor />
|
|
|
+ <Editor isSlackEnabled={isSlackEnabled} />
|
|
|
</div>
|
|
|
</TabPane>
|
|
|
) }
|
|
|
{ isEditable && (
|
|
|
<TabPane tabId={EditorMode.HackMD}>
|
|
|
<div id="page-editor-with-hackmd">
|
|
|
- <PageEditorByHackmd />
|
|
|
+ <PageEditorByHackmd isSlackEnabled={isSlackEnabled} />
|
|
|
</div>
|
|
|
</TabPane>
|
|
|
) }
|