diff --git a/api/system.go b/api/system.go index 4d3669bc..82e88658 100644 --- a/api/system.go +++ b/api/system.go @@ -10,6 +10,8 @@ type SystemStatus struct { // System settings // Allow sign up. AllowSignUp bool `json:"allowSignUp"` + // Ignore upgrade + IgnoreUpgrade bool `json:"ignoreUpgrade"` // Disable public memos. DisablePublicMemos bool `json:"disablePublicMemos"` // Additional style. diff --git a/api/system_setting.go b/api/system_setting.go index 7f61281f..398ec92a 100644 --- a/api/system_setting.go +++ b/api/system_setting.go @@ -17,6 +17,8 @@ const ( SystemSettingSecretSessionName SystemSettingName = "secret-session" // SystemSettingAllowSignUpName is the name of allow signup setting. SystemSettingAllowSignUpName SystemSettingName = "allow-signup" + // SystemSettingIgnoreUpgradeName is the name of ignore upgrade. + SystemSettingIgnoreUpgradeName SystemSettingName = "ignore-upgrade" // SystemSettingDisablePublicMemosName is the name of disable public memos setting. SystemSettingDisablePublicMemosName SystemSettingName = "disable-public-memos" // SystemSettingAdditionalStyleName is the name of additional style. @@ -62,6 +64,8 @@ func (key SystemSettingName) String() string { return "secret-session" case SystemSettingAllowSignUpName: return "allow-signup" + case SystemSettingIgnoreUpgradeName: + return "ignore-upgrade" case SystemSettingDisablePublicMemosName: return "disable-public-memos" case SystemSettingAdditionalStyleName: @@ -102,6 +106,12 @@ func (upsert SystemSettingUpsert) Validate() error { if err != nil { return fmt.Errorf("failed to unmarshal system setting allow signup value") } + } else if upsert.Name == SystemSettingIgnoreUpgradeName { + value := false + err := json.Unmarshal([]byte(upsert.Value), &value) + if err != nil { + return fmt.Errorf("failed to unmarshal system setting ignore upgrade value") + } } else if upsert.Name == SystemSettingDisablePublicMemosName { value := false err := json.Unmarshal([]byte(upsert.Value), &value) diff --git a/server/system.go b/server/system.go index a047e90c..ac521457 100644 --- a/server/system.go +++ b/server/system.go @@ -42,6 +42,7 @@ func (s *Server) registerSystemRoutes(g *echo.Group) { Profile: *s.Profile, DBSize: 0, AllowSignUp: false, + IgnoreUpgrade: false, DisablePublicMemos: false, AdditionalStyle: "", AdditionalScript: "", @@ -75,6 +76,8 @@ func (s *Server) registerSystemRoutes(g *echo.Group) { if systemSetting.Name == api.SystemSettingAllowSignUpName { systemStatus.AllowSignUp = baseValue.(bool) + } else if systemSetting.Name == api.SystemSettingIgnoreUpgradeName { + systemStatus.IgnoreUpgrade = baseValue.(bool) } else if systemSetting.Name == api.SystemSettingDisablePublicMemosName { systemStatus.DisablePublicMemos = baseValue.(bool) } else if systemSetting.Name == api.SystemSettingAdditionalStyleName { diff --git a/web/src/components/Settings/SystemSection.tsx b/web/src/components/Settings/SystemSection.tsx index f3a290e9..545f60b8 100644 --- a/web/src/components/Settings/SystemSection.tsx +++ b/web/src/components/Settings/SystemSection.tsx @@ -10,6 +10,7 @@ import "@/less/settings/system-section.less"; interface State { dbSize: number; allowSignUp: boolean; + ignoreUpgrade: boolean; disablePublicMemos: boolean; additionalStyle: string; additionalScript: string; @@ -31,6 +32,7 @@ const SystemSection = () => { const [state, setState] = useState({ dbSize: systemStatus.dbSize, allowSignUp: systemStatus.allowSignUp, + ignoreUpgrade: systemStatus.ignoreUpgrade, additionalStyle: systemStatus.additionalStyle, additionalScript: systemStatus.additionalScript, disablePublicMemos: systemStatus.disablePublicMemos, @@ -75,6 +77,17 @@ const SystemSection = () => { }); }; + const handleIgnoreUpgradeChanged = async (value: boolean) => { + setState({ + ...state, + ignoreUpgrade: value, + }); + await api.upsertSystemSetting({ + name: "ignore-upgrade", + value: JSON.stringify(value), + }); + }; + const handleUpdateCustomizedProfileButtonClick = () => { showUpdateCustomizedProfileDialog(); }; @@ -189,6 +202,10 @@ const SystemSection = () => { {t("setting.system-section.allow-user-signup")} handleAllowSignUpChanged(event.target.checked)} /> +
+ Ignore version upgrade + handleIgnoreUpgradeChanged(event.target.checked)} /> +
{t("setting.system-section.disable-public-memos")} handleDisablePublicMemosChanged(event.target.checked)} /> diff --git a/web/src/components/UpdateVersionBanner.tsx b/web/src/components/UpgradeVersionBanner.tsx similarity index 91% rename from web/src/components/UpdateVersionBanner.tsx rename to web/src/components/UpgradeVersionBanner.tsx index fbd081bd..7c72ad5d 100644 --- a/web/src/components/UpdateVersionBanner.tsx +++ b/web/src/components/UpgradeVersionBanner.tsx @@ -10,7 +10,7 @@ interface State { show: boolean; } -const UpdateVersionBanner: React.FC = () => { +const UpgradeVersionBanner: React.FC = () => { const globalStore = useGlobalStore(); const profile = globalStore.state.systemStatus.profile; const [state, setState] = useState({ @@ -19,6 +19,10 @@ const UpdateVersionBanner: React.FC = () => { }); useEffect(() => { + if (globalStore.state.systemStatus.ignoreUpgrade) { + return; + } + api.getRepoLatestTag().then((latestTag) => { const { skippedVersion } = storage.get(["skippedVersion"]); const latestVersion = latestTag.slice(1) || "0.0.0"; @@ -58,4 +62,4 @@ const UpdateVersionBanner: React.FC = () => { ); }; -export default UpdateVersionBanner; +export default UpgradeVersionBanner; diff --git a/web/src/layouts/Root.tsx b/web/src/layouts/Root.tsx index 33102122..76b3b12a 100644 --- a/web/src/layouts/Root.tsx +++ b/web/src/layouts/Root.tsx @@ -1,12 +1,12 @@ import { Outlet } from "react-router-dom"; import Header from "@/components/Header"; -import UpdateVersionBanner from "@/components/UpdateVersionBanner"; +import UpgradeVersionBanner from "@/components/UpgradeVersionBanner"; function Root() { return (
- +
diff --git a/web/src/store/module/global.ts b/web/src/store/module/global.ts index ed5f18ed..311feb34 100644 --- a/web/src/store/module/global.ts +++ b/web/src/store/module/global.ts @@ -11,6 +11,7 @@ export const initialGlobalState = async () => { appearance: "system" as Appearance, systemStatus: { allowSignUp: false, + ignoreUpgrade: false, disablePublicMemos: false, additionalStyle: "", additionalScript: "", diff --git a/web/src/store/reducer/global.ts b/web/src/store/reducer/global.ts index 72b2514a..bd201f78 100644 --- a/web/src/store/reducer/global.ts +++ b/web/src/store/reducer/global.ts @@ -19,6 +19,7 @@ const globalSlice = createSlice({ }, dbSize: 0, allowSignUp: false, + ignoreUpgrade: false, disablePublicMemos: false, additionalStyle: "", additionalScript: "", diff --git a/web/src/types/modules/system.d.ts b/web/src/types/modules/system.d.ts index 3e7de52d..7142bf58 100644 --- a/web/src/types/modules/system.d.ts +++ b/web/src/types/modules/system.d.ts @@ -23,6 +23,7 @@ interface SystemStatus { dbSize: number; // System settings allowSignUp: boolean; + ignoreUpgrade: boolean; disablePublicMemos: boolean; additionalStyle: string; additionalScript: string;