mirror of
https://github.com/usememos/memos.git
synced 2025-02-21 21:57:47 +01:00
chore: update upgrade version view (#1791)
This commit is contained in:
parent
32e2f1d339
commit
11a385cda6
@ -10,8 +10,6 @@ type SystemStatus struct {
|
|||||||
// System settings
|
// System settings
|
||||||
// Allow sign up.
|
// Allow sign up.
|
||||||
AllowSignUp bool `json:"allowSignUp"`
|
AllowSignUp bool `json:"allowSignUp"`
|
||||||
// Ignore upgrade
|
|
||||||
IgnoreUpgrade bool `json:"ignoreUpgrade"`
|
|
||||||
// Disable public memos.
|
// Disable public memos.
|
||||||
DisablePublicMemos bool `json:"disablePublicMemos"`
|
DisablePublicMemos bool `json:"disablePublicMemos"`
|
||||||
// Max upload size.
|
// Max upload size.
|
||||||
|
@ -17,8 +17,6 @@ const (
|
|||||||
SystemSettingSecretSessionName SystemSettingName = "secret-session"
|
SystemSettingSecretSessionName SystemSettingName = "secret-session"
|
||||||
// SystemSettingAllowSignUpName is the name of allow signup setting.
|
// SystemSettingAllowSignUpName is the name of allow signup setting.
|
||||||
SystemSettingAllowSignUpName SystemSettingName = "allow-signup"
|
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 is the name of disable public memos setting.
|
||||||
SystemSettingDisablePublicMemosName SystemSettingName = "disable-public-memos"
|
SystemSettingDisablePublicMemosName SystemSettingName = "disable-public-memos"
|
||||||
// SystemSettingMaxUploadSizeMiBName is the name of max upload size setting.
|
// SystemSettingMaxUploadSizeMiBName is the name of max upload size setting.
|
||||||
@ -69,8 +67,6 @@ func (key SystemSettingName) String() string {
|
|||||||
return "secret-session"
|
return "secret-session"
|
||||||
case SystemSettingAllowSignUpName:
|
case SystemSettingAllowSignUpName:
|
||||||
return "allow-signup"
|
return "allow-signup"
|
||||||
case SystemSettingIgnoreUpgradeName:
|
|
||||||
return "ignore-upgrade"
|
|
||||||
case SystemSettingDisablePublicMemosName:
|
case SystemSettingDisablePublicMemosName:
|
||||||
return "disable-public-memos"
|
return "disable-public-memos"
|
||||||
case SystemSettingMaxUploadSizeMiBName:
|
case SystemSettingMaxUploadSizeMiBName:
|
||||||
@ -119,11 +115,6 @@ func (upsert SystemSettingUpsert) Validate() error {
|
|||||||
if err := json.Unmarshal([]byte(upsert.Value), &value); err != nil {
|
if err := json.Unmarshal([]byte(upsert.Value), &value); err != nil {
|
||||||
return fmt.Errorf(systemSettingUnmarshalError, settingName)
|
return fmt.Errorf(systemSettingUnmarshalError, settingName)
|
||||||
}
|
}
|
||||||
case SystemSettingIgnoreUpgradeName:
|
|
||||||
var value bool
|
|
||||||
if err := json.Unmarshal([]byte(upsert.Value), &value); err != nil {
|
|
||||||
return fmt.Errorf(systemSettingUnmarshalError, settingName)
|
|
||||||
}
|
|
||||||
case SystemSettingDisablePublicMemosName:
|
case SystemSettingDisablePublicMemosName:
|
||||||
var value bool
|
var value bool
|
||||||
if err := json.Unmarshal([]byte(upsert.Value), &value); err != nil {
|
if err := json.Unmarshal([]byte(upsert.Value), &value); err != nil {
|
||||||
|
@ -42,7 +42,6 @@ func (s *Server) registerSystemRoutes(g *echo.Group) {
|
|||||||
Profile: *s.Profile,
|
Profile: *s.Profile,
|
||||||
DBSize: 0,
|
DBSize: 0,
|
||||||
AllowSignUp: false,
|
AllowSignUp: false,
|
||||||
IgnoreUpgrade: false,
|
|
||||||
DisablePublicMemos: false,
|
DisablePublicMemos: false,
|
||||||
MaxUploadSizeMiB: 32,
|
MaxUploadSizeMiB: 32,
|
||||||
AdditionalStyle: "",
|
AdditionalStyle: "",
|
||||||
@ -79,8 +78,6 @@ func (s *Server) registerSystemRoutes(g *echo.Group) {
|
|||||||
switch systemSetting.Name {
|
switch systemSetting.Name {
|
||||||
case api.SystemSettingAllowSignUpName:
|
case api.SystemSettingAllowSignUpName:
|
||||||
systemStatus.AllowSignUp = baseValue.(bool)
|
systemStatus.AllowSignUp = baseValue.(bool)
|
||||||
case api.SystemSettingIgnoreUpgradeName:
|
|
||||||
systemStatus.IgnoreUpgrade = baseValue.(bool)
|
|
||||||
case api.SystemSettingDisablePublicMemosName:
|
case api.SystemSettingDisablePublicMemosName:
|
||||||
systemStatus.DisablePublicMemos = baseValue.(bool)
|
systemStatus.DisablePublicMemos = baseValue.(bool)
|
||||||
case api.SystemSettingMaxUploadSizeMiBName:
|
case api.SystemSettingMaxUploadSizeMiBName:
|
||||||
|
@ -3,6 +3,8 @@ import { useTranslation } from "react-i18next";
|
|||||||
import { useMemoStore } from "@/store/module";
|
import { useMemoStore } from "@/store/module";
|
||||||
import { getDateTimeString } from "@/helpers/datetime";
|
import { getDateTimeString } from "@/helpers/datetime";
|
||||||
import useToggle from "@/hooks/useToggle";
|
import useToggle from "@/hooks/useToggle";
|
||||||
|
import Tooltip from "./kit/Tooltip";
|
||||||
|
import Icon from "./Icon";
|
||||||
import MemoContent from "./MemoContent";
|
import MemoContent from "./MemoContent";
|
||||||
import MemoResourceListView from "./MemoResourceListView";
|
import MemoResourceListView from "./MemoResourceListView";
|
||||||
import "@/less/memo.less";
|
import "@/less/memo.less";
|
||||||
@ -53,15 +55,23 @@ const ArchivedMemo: React.FC<Props> = (props: Props) => {
|
|||||||
return (
|
return (
|
||||||
<div className={`memo-wrapper archived ${"memos-" + memo.id}`} onMouseLeave={handleMouseLeaveMemoWrapper}>
|
<div className={`memo-wrapper archived ${"memos-" + memo.id}`} onMouseLeave={handleMouseLeaveMemoWrapper}>
|
||||||
<div className="memo-top-wrapper">
|
<div className="memo-top-wrapper">
|
||||||
<span className="time-text">{getDateTimeString(memo.updatedTs)}</span>
|
<div className="status-text-container">
|
||||||
<div className="btns-container">
|
<span className="time-text">{getDateTimeString(memo.updatedTs)}</span>
|
||||||
<span className="btn-text" onClick={handleRestoreMemoClick}>
|
</div>
|
||||||
{t("common.restore")}
|
<div className="flex flex-row justify-end items-center gap-x-2">
|
||||||
</span>
|
<Tooltip title={t("common.restore")} side="top">
|
||||||
<span className={`btn-text ${showConfirmDeleteBtn ? "final-confirm" : ""}`} onClick={handleDeleteMemoClick}>
|
<button onClick={handleRestoreMemoClick}>
|
||||||
{t("common.delete")}
|
<Icon.ArchiveRestore className="w-4 h-auto cursor-pointer text-gray-500 dark:text-gray-400" />
|
||||||
{showConfirmDeleteBtn ? "!" : ""}
|
</button>
|
||||||
</span>
|
</Tooltip>
|
||||||
|
<Tooltip title={t("common.delete")} side="top">
|
||||||
|
<button
|
||||||
|
onClick={handleDeleteMemoClick}
|
||||||
|
className={`text-gray-500 dark:text-gray-400 ${showConfirmDeleteBtn ? "text-red-600" : ""}`}
|
||||||
|
>
|
||||||
|
<Icon.Trash className="w-4 h-auto cursor-pointer" />
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<MemoContent content={memo.content} />
|
<MemoContent content={memo.content} />
|
||||||
|
@ -23,7 +23,7 @@ const DemoBanner: React.FC = () => {
|
|||||||
if (!state.show) return null;
|
if (!state.show) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-row items-center justify-center w-full py-2 text-sm sm:text-lg font-medium dark:text-gray-300 bg-white dark:bg-zinc-700 shadow">
|
<div className="z-1 flex flex-row items-center justify-center w-full py-2 text-sm sm:text-lg font-medium dark:text-gray-300 bg-white dark:bg-zinc-700 shadow">
|
||||||
<div className="w-full max-w-6xl px-4 flex flex-row justify-between items-center gap-x-3">
|
<div className="w-full max-w-6xl px-4 flex flex-row justify-between items-center gap-x-3">
|
||||||
<span>✨ A lightweight, self-hosted memo hub. Open Source and Free forever. ✨</span>
|
<span>✨ A lightweight, self-hosted memo hub. Open Source and Free forever. ✨</span>
|
||||||
<a className="btn-primary shadow" href="https://usememos.com/docs/install/docker" target="_blank">
|
<a className="btn-primary shadow" href="https://usememos.com/docs/install/docker" target="_blank">
|
||||||
|
@ -7,6 +7,7 @@ import Icon from "./Icon";
|
|||||||
import UserBanner from "./UserBanner";
|
import UserBanner from "./UserBanner";
|
||||||
import showAboutSiteDialog from "./AboutSiteDialog";
|
import showAboutSiteDialog from "./AboutSiteDialog";
|
||||||
import showMemoEditorDialog from "./MemoEditor/MemoEditorDialog";
|
import showMemoEditorDialog from "./MemoEditor/MemoEditorDialog";
|
||||||
|
import UpgradeVersionView from "./UpgradeVersionBanner";
|
||||||
|
|
||||||
const Header = () => {
|
const Header = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@ -139,6 +140,7 @@ const Header = () => {
|
|||||||
<Icon.Edit3 className="w-4 h-auto mr-1" /> New
|
<Icon.Edit3 className="w-4 h-auto mr-1" /> New
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<UpgradeVersionView />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{isVisitorMode && (
|
{isVisitorMode && (
|
||||||
|
@ -12,7 +12,6 @@ import "@/less/settings/system-section.less";
|
|||||||
interface State {
|
interface State {
|
||||||
dbSize: number;
|
dbSize: number;
|
||||||
allowSignUp: boolean;
|
allowSignUp: boolean;
|
||||||
ignoreUpgrade: boolean;
|
|
||||||
disablePublicMemos: boolean;
|
disablePublicMemos: boolean;
|
||||||
additionalStyle: string;
|
additionalStyle: string;
|
||||||
additionalScript: string;
|
additionalScript: string;
|
||||||
@ -27,7 +26,6 @@ const SystemSection = () => {
|
|||||||
const [state, setState] = useState<State>({
|
const [state, setState] = useState<State>({
|
||||||
dbSize: systemStatus.dbSize,
|
dbSize: systemStatus.dbSize,
|
||||||
allowSignUp: systemStatus.allowSignUp,
|
allowSignUp: systemStatus.allowSignUp,
|
||||||
ignoreUpgrade: systemStatus.ignoreUpgrade,
|
|
||||||
additionalStyle: systemStatus.additionalStyle,
|
additionalStyle: systemStatus.additionalStyle,
|
||||||
additionalScript: systemStatus.additionalScript,
|
additionalScript: systemStatus.additionalScript,
|
||||||
disablePublicMemos: systemStatus.disablePublicMemos,
|
disablePublicMemos: systemStatus.disablePublicMemos,
|
||||||
@ -82,17 +80,6 @@ const SystemSection = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleIgnoreUpgradeChanged = async (value: boolean) => {
|
|
||||||
setState({
|
|
||||||
...state,
|
|
||||||
ignoreUpgrade: value,
|
|
||||||
});
|
|
||||||
await api.upsertSystemSetting({
|
|
||||||
name: "ignore-upgrade",
|
|
||||||
value: JSON.stringify(value),
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleUpdateCustomizedProfileButtonClick = () => {
|
const handleUpdateCustomizedProfileButtonClick = () => {
|
||||||
showUpdateCustomizedProfileDialog();
|
showUpdateCustomizedProfileDialog();
|
||||||
};
|
};
|
||||||
@ -261,10 +248,6 @@ const SystemSection = () => {
|
|||||||
<span className="normal-text">{t("setting.system-section.allow-user-signup")}</span>
|
<span className="normal-text">{t("setting.system-section.allow-user-signup")}</span>
|
||||||
<Switch checked={state.allowSignUp} onChange={(event) => handleAllowSignUpChanged(event.target.checked)} />
|
<Switch checked={state.allowSignUp} onChange={(event) => handleAllowSignUpChanged(event.target.checked)} />
|
||||||
</div>
|
</div>
|
||||||
<div className="form-label">
|
|
||||||
<span className="normal-text">{t("setting.system-section.ignore-version-upgrade")}</span>
|
|
||||||
<Switch checked={state.ignoreUpgrade} onChange={(event) => handleIgnoreUpgradeChanged(event.target.checked)} />
|
|
||||||
</div>
|
|
||||||
<div className="form-label">
|
<div className="form-label">
|
||||||
<span className="normal-text">{t("setting.system-section.disable-public-memos")}</span>
|
<span className="normal-text">{t("setting.system-section.disable-public-memos")}</span>
|
||||||
<Switch checked={state.disablePublicMemos} onChange={(event) => handleDisablePublicMemosChanged(event.target.checked)} />
|
<Switch checked={state.disablePublicMemos} onChange={(event) => handleDisablePublicMemosChanged(event.target.checked)} />
|
||||||
|
@ -4,13 +4,14 @@ import * as api from "@/helpers/api";
|
|||||||
import storage from "@/helpers/storage";
|
import storage from "@/helpers/storage";
|
||||||
import { useGlobalStore } from "@/store/module";
|
import { useGlobalStore } from "@/store/module";
|
||||||
import Icon from "./Icon";
|
import Icon from "./Icon";
|
||||||
|
import Tooltip from "./kit/Tooltip";
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
latestVersion: string;
|
latestVersion: string;
|
||||||
show: boolean;
|
show: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const UpgradeVersionBanner: React.FC = () => {
|
const UpgradeVersionView: React.FC = () => {
|
||||||
const globalStore = useGlobalStore();
|
const globalStore = useGlobalStore();
|
||||||
const profile = globalStore.state.systemStatus.profile;
|
const profile = globalStore.state.systemStatus.profile;
|
||||||
const [state, setState] = useState<State>({
|
const [state, setState] = useState<State>({
|
||||||
@ -19,10 +20,6 @@ const UpgradeVersionBanner: React.FC = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (globalStore.state.systemStatus.ignoreUpgrade) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
api.getRepoLatestTag().then((latestTag) => {
|
api.getRepoLatestTag().then((latestTag) => {
|
||||||
const { skippedVersion } = storage.get(["skippedVersion"]);
|
const { skippedVersion } = storage.get(["skippedVersion"]);
|
||||||
const latestVersion = latestTag.slice(1) || "0.0.0";
|
const latestVersion = latestTag.slice(1) || "0.0.0";
|
||||||
@ -46,20 +43,21 @@ const UpgradeVersionBanner: React.FC = () => {
|
|||||||
if (!state.show) return null;
|
if (!state.show) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-row items-center justify-center w-full py-2 text-white bg-green-600">
|
<div className="flex flex-row justify-center items-center w-full py-2 px-2">
|
||||||
<a
|
<a
|
||||||
className="flex flex-row items-center justify-center hover:underline"
|
className="flex flex-row justify-start items-center text-sm break-all text-green-600 hover:underline"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
href="https://github.com/usememos/memos/releases"
|
href="https://github.com/usememos/memos/releases"
|
||||||
>
|
>
|
||||||
<Icon.ArrowUpCircle className="w-5 h-auto mr-2" />
|
✨ New version: v{state.latestVersion}
|
||||||
New Update <span className="ml-1 font-bold">{state.latestVersion}</span>
|
|
||||||
</a>
|
</a>
|
||||||
<button className="absolute opacity-80 right-4 hover:opacity-100" title="Skip this version" onClick={onSkip}>
|
<Tooltip title="Ignore upgrade" side="top">
|
||||||
<Icon.X />
|
<button className="ml-1 opacity-60 text-gray-600 hover:opacity-100" onClick={onSkip}>
|
||||||
</button>
|
<Icon.X className="w-4 h-auto" />
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default UpgradeVersionBanner;
|
export default UpgradeVersionView;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { Outlet } from "react-router-dom";
|
import { Outlet } from "react-router-dom";
|
||||||
import Header from "@/components/Header";
|
import Header from "@/components/Header";
|
||||||
import UpgradeVersionBanner from "@/components/UpgradeVersionBanner";
|
|
||||||
import DemoBanner from "@/components/DemoBanner";
|
import DemoBanner from "@/components/DemoBanner";
|
||||||
|
|
||||||
function Root() {
|
function Root() {
|
||||||
@ -8,9 +7,8 @@ function Root() {
|
|||||||
<div className="w-full min-h-full bg-zinc-100 dark:bg-zinc-800">
|
<div className="w-full min-h-full bg-zinc-100 dark:bg-zinc-800">
|
||||||
<div className="w-full h-auto flex flex-col justify-start items-center">
|
<div className="w-full h-auto flex flex-col justify-start items-center">
|
||||||
<DemoBanner />
|
<DemoBanner />
|
||||||
<UpgradeVersionBanner />
|
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full max-w-6xl mx-auto flex flex-row justify-center items-start">
|
<div className="w-full max-w-6xl mx-auto flex flex-row justify-center items-start sm:px-4">
|
||||||
<Header />
|
<Header />
|
||||||
<main className="w-auto max-w-full flex-grow shrink flex flex-col justify-start items-start">
|
<main className="w-auto max-w-full flex-grow shrink flex flex-col justify-start items-start">
|
||||||
<Outlet />
|
<Outlet />
|
||||||
|
@ -5,10 +5,6 @@
|
|||||||
@apply border-gray-200 border-2 dark:border-zinc-600;
|
@apply border-gray-200 border-2 dark:border-zinc-600;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.archived {
|
|
||||||
@apply border-gray-200 dark:border-zinc-600;
|
|
||||||
}
|
|
||||||
|
|
||||||
> .memo-top-wrapper {
|
> .memo-top-wrapper {
|
||||||
@apply flex flex-row justify-between items-center w-full h-6 mb-1;
|
@apply flex flex-row justify-between items-center w-full h-6 mb-1;
|
||||||
|
|
||||||
@ -36,10 +32,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
> .time-text {
|
|
||||||
@apply text-xs text-gray-400 cursor-pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
> .btns-container {
|
> .btns-container {
|
||||||
@apply flex flex-row justify-end items-center relative shrink-0;
|
@apply flex flex-row justify-end items-center relative shrink-0;
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ export const initialGlobalState = async () => {
|
|||||||
appearance: "system" as Appearance,
|
appearance: "system" as Appearance,
|
||||||
systemStatus: {
|
systemStatus: {
|
||||||
allowSignUp: false,
|
allowSignUp: false,
|
||||||
ignoreUpgrade: false,
|
|
||||||
disablePublicMemos: false,
|
disablePublicMemos: false,
|
||||||
maxUploadSizeMiB: 0,
|
maxUploadSizeMiB: 0,
|
||||||
additionalStyle: "",
|
additionalStyle: "",
|
||||||
|
@ -19,7 +19,6 @@ const globalSlice = createSlice({
|
|||||||
},
|
},
|
||||||
dbSize: 0,
|
dbSize: 0,
|
||||||
allowSignUp: false,
|
allowSignUp: false,
|
||||||
ignoreUpgrade: false,
|
|
||||||
disablePublicMemos: false,
|
disablePublicMemos: false,
|
||||||
additionalStyle: "",
|
additionalStyle: "",
|
||||||
additionalScript: "",
|
additionalScript: "",
|
||||||
|
1
web/src/types/modules/system.d.ts
vendored
1
web/src/types/modules/system.d.ts
vendored
@ -23,7 +23,6 @@ interface SystemStatus {
|
|||||||
dbSize: number;
|
dbSize: number;
|
||||||
// System settings
|
// System settings
|
||||||
allowSignUp: boolean;
|
allowSignUp: boolean;
|
||||||
ignoreUpgrade: boolean;
|
|
||||||
disablePublicMemos: boolean;
|
disablePublicMemos: boolean;
|
||||||
maxUploadSizeMiB: number;
|
maxUploadSizeMiB: number;
|
||||||
additionalStyle: string;
|
additionalStyle: string;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user