mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
feat(system): support for disabling public memos (#1003)
* feat(system): support for disabling public memos * fix(web/editor): set visibility to private on disabled public memos * feat(server/memo): find/check if public memos are disabled * fix(server/memo): handle error for finding system error * fix(server/memo): unmarshal visiblity when getting system settings * chore(web): move side effect imports to end * Update memo.go --------- Co-authored-by: boojack <stevenlgtm@gmail.com>
This commit is contained in:
@ -4,7 +4,15 @@ import { useTranslation } from "react-i18next";
|
||||
import { getMatchedNodes } from "../labs/marked";
|
||||
import { deleteMemoResource, upsertMemoResource } from "../helpers/api";
|
||||
import { TAB_SPACE_WIDTH, UNKNOWN_ID, VISIBILITY_SELECTOR_ITEMS } from "../helpers/consts";
|
||||
import { useEditorStore, useLocationStore, useMemoStore, useResourceStore, useTagStore, useUserStore } from "../store/module";
|
||||
import {
|
||||
useEditorStore,
|
||||
useGlobalStore,
|
||||
useLocationStore,
|
||||
useMemoStore,
|
||||
useResourceStore,
|
||||
useTagStore,
|
||||
useUserStore,
|
||||
} from "../store/module";
|
||||
import * as storage from "../helpers/storage";
|
||||
import Icon from "./Icon";
|
||||
import toastHelper from "./Toast";
|
||||
@ -42,6 +50,9 @@ const MemoEditor = () => {
|
||||
const memoStore = useMemoStore();
|
||||
const tagStore = useTagStore();
|
||||
const resourceStore = useResourceStore();
|
||||
const {
|
||||
state: { systemStatus },
|
||||
} = useGlobalStore();
|
||||
|
||||
const [state, setState] = useState<State>({
|
||||
fullscreen: false,
|
||||
@ -63,6 +74,12 @@ const MemoEditor = () => {
|
||||
};
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (systemStatus.disablePublicMemos) {
|
||||
editorStore.setMemoVisibility("PRIVATE");
|
||||
}
|
||||
}, [systemStatus.disablePublicMemos]);
|
||||
|
||||
useEffect(() => {
|
||||
const { editingMemoIdCache } = storage.get(["editingMemoIdCache"]);
|
||||
if (editingMemoIdCache) {
|
||||
@ -484,7 +501,9 @@ const MemoEditor = () => {
|
||||
<Selector
|
||||
className="visibility-selector"
|
||||
value={editorState.memoVisibility}
|
||||
tooltipTitle={t("memo.visibility.disabled")}
|
||||
dataSource={memoVisibilityOptionSelectorItems}
|
||||
disabled={systemStatus.disablePublicMemos}
|
||||
handleValueChanged={handleMemoVisibilityOptionChanged}
|
||||
/>
|
||||
<div className="buttons-container">
|
||||
|
Reference in New Issue
Block a user