|
@@ -48,16 +48,15 @@ function PageEditorModeManager(props) {
|
|
|
const isAdmin = appContainer.isAdmin;
|
|
const isAdmin = appContainer.isAdmin;
|
|
|
const isHackmdEnabled = appContainer.config.env.HACKMD_URI != null;
|
|
const isHackmdEnabled = appContainer.config.env.HACKMD_URI != null;
|
|
|
const showHackmdBtn = isHackmdEnabled || isAdmin;
|
|
const showHackmdBtn = isHackmdEnabled || isAdmin;
|
|
|
- const showHackmdDisabledTooltip = isAdmin && !isHackmdEnabled && editorMode !== EditorMode.HackMD;
|
|
|
|
|
|
|
|
|
|
const pageEditorModeButtonClickedHandler = useCallback((viewType) => {
|
|
const pageEditorModeButtonClickedHandler = useCallback((viewType) => {
|
|
|
- if (isBtnDisabled) {
|
|
|
|
|
|
|
+ if (isBtnDisabled || !isHackmdEnabled) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
if (onPageEditorModeButtonClicked != null) {
|
|
if (onPageEditorModeButtonClicked != null) {
|
|
|
onPageEditorModeButtonClicked(viewType);
|
|
onPageEditorModeButtonClicked(viewType);
|
|
|
}
|
|
}
|
|
|
- }, [isBtnDisabled, onPageEditorModeButtonClicked]);
|
|
|
|
|
|
|
+ }, [isBtnDisabled, isHackmdEnabled, onPageEditorModeButtonClicked]);
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
@@ -88,15 +87,22 @@ function PageEditorModeManager(props) {
|
|
|
/>
|
|
/>
|
|
|
)}
|
|
)}
|
|
|
{(!isDeviceSmallerThanMd || editorMode === EditorMode.View) && showHackmdBtn && (
|
|
{(!isDeviceSmallerThanMd || editorMode === EditorMode.View) && showHackmdBtn && (
|
|
|
- <PageEditorModeButtonWrapper
|
|
|
|
|
- editorMode={editorMode}
|
|
|
|
|
- isBtnDisabled={isBtnDisabled}
|
|
|
|
|
- onClick={pageEditorModeButtonClickedHandler}
|
|
|
|
|
- targetMode={EditorMode.HackMD}
|
|
|
|
|
- icon={<i className="fa fa-file-text-o" />}
|
|
|
|
|
- label={t('hackmd.hack_md')}
|
|
|
|
|
- id="grw-page-editor-mode-manager-hackmd-button"
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ <>
|
|
|
|
|
+ <PageEditorModeButtonWrapper
|
|
|
|
|
+ editorMode={editorMode}
|
|
|
|
|
+ isBtnDisabled={isBtnDisabled || !isHackmdEnabled}
|
|
|
|
|
+ onClick={pageEditorModeButtonClickedHandler}
|
|
|
|
|
+ targetMode={EditorMode.HackMD}
|
|
|
|
|
+ icon={<i className="fa fa-file-text-o" />}
|
|
|
|
|
+ label={t('hackmd.hack_md')}
|
|
|
|
|
+ id="grw-page-editor-mode-manager-hackmd-button"
|
|
|
|
|
+ />
|
|
|
|
|
+ { !isHackmdEnabled && (
|
|
|
|
|
+ <UncontrolledTooltip placement="top" target="grw-page-editor-mode-manager-hackmd-button" fade={false}>
|
|
|
|
|
+ {t('hackmd.not_set_up')}
|
|
|
|
|
+ </UncontrolledTooltip>
|
|
|
|
|
+ )}
|
|
|
|
|
+ </>
|
|
|
)}
|
|
)}
|
|
|
</div>
|
|
</div>
|
|
|
{isBtnDisabled && (
|
|
{isBtnDisabled && (
|
|
@@ -104,11 +110,6 @@ function PageEditorModeManager(props) {
|
|
|
{t('Not available for guest')}
|
|
{t('Not available for guest')}
|
|
|
</UncontrolledTooltip>
|
|
</UncontrolledTooltip>
|
|
|
)}
|
|
)}
|
|
|
- {!isBtnDisabled && showHackmdDisabledTooltip && (
|
|
|
|
|
- <UncontrolledTooltip placement="top" target="grw-page-editor-mode-manager-hackmd-button" fade={false}>
|
|
|
|
|
- {t('hackmd.not_set_up')}
|
|
|
|
|
- </UncontrolledTooltip>
|
|
|
|
|
- )}
|
|
|
|
|
</>
|
|
</>
|
|
|
);
|
|
);
|
|
|
|
|
|