|
@@ -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 (
|
|
|
<>
|
|
<>
|
|
@@ -90,7 +89,7 @@ function PageEditorModeManager(props) {
|
|
|
{(!isDeviceSmallerThanMd || editorMode === EditorMode.View) && showHackmdBtn && (
|
|
{(!isDeviceSmallerThanMd || editorMode === EditorMode.View) && showHackmdBtn && (
|
|
|
<PageEditorModeButtonWrapper
|
|
<PageEditorModeButtonWrapper
|
|
|
editorMode={editorMode}
|
|
editorMode={editorMode}
|
|
|
- isBtnDisabled={isBtnDisabled}
|
|
|
|
|
|
|
+ isBtnDisabled={isBtnDisabled || !isHackmdEnabled}
|
|
|
onClick={pageEditorModeButtonClickedHandler}
|
|
onClick={pageEditorModeButtonClickedHandler}
|
|
|
targetMode={EditorMode.HackMD}
|
|
targetMode={EditorMode.HackMD}
|
|
|
icon={<i className="fa fa-file-text-o" />}
|
|
icon={<i className="fa fa-file-text-o" />}
|
|
@@ -104,7 +103,7 @@ function PageEditorModeManager(props) {
|
|
|
{t('Not available for guest')}
|
|
{t('Not available for guest')}
|
|
|
</UncontrolledTooltip>
|
|
</UncontrolledTooltip>
|
|
|
)}
|
|
)}
|
|
|
- {!isBtnDisabled && showHackmdDisabledTooltip && (
|
|
|
|
|
|
|
+ {(!isDeviceSmallerThanMd || editorMode === EditorMode.View) && showHackmdBtn && !isHackmdEnabled && (
|
|
|
<UncontrolledTooltip placement="top" target="grw-page-editor-mode-manager-hackmd-button" fade={false}>
|
|
<UncontrolledTooltip placement="top" target="grw-page-editor-mode-manager-hackmd-button" fade={false}>
|
|
|
{t('hackmd.not_set_up')}
|
|
{t('hackmd.not_set_up')}
|
|
|
</UncontrolledTooltip>
|
|
</UncontrolledTooltip>
|