Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
3eac19d2
Unverified
Commit
3eac19d2
authored
Apr 08, 2023
by
boojack
Committed by
GitHub
Apr 08, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: add ignore version upgrade setting (#1491)
parent
ab867b68
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
43 additions
and
4 deletions
+43
-4
system.go
api/system.go
+2
-0
system_setting.go
api/system_setting.go
+10
-0
system.go
server/system.go
+3
-0
SystemSection.tsx
web/src/components/Settings/SystemSection.tsx
+17
-0
UpgradeVersionBanner.tsx
web/src/components/UpgradeVersionBanner.tsx
+6
-2
Root.tsx
web/src/layouts/Root.tsx
+2
-2
global.ts
web/src/store/module/global.ts
+1
-0
global.ts
web/src/store/reducer/global.ts
+1
-0
system.d.ts
web/src/types/modules/system.d.ts
+1
-0
No files found.
api/system.go
View file @
3eac19d2
...
@@ -10,6 +10,8 @@ type SystemStatus struct {
...
@@ -10,6 +10,8 @@ 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"`
// Additional style.
// Additional style.
...
...
api/system_setting.go
View file @
3eac19d2
...
@@ -17,6 +17,8 @@ const (
...
@@ -17,6 +17,8 @@ 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"
// SystemSettingAdditionalStyleName is the name of additional style.
// SystemSettingAdditionalStyleName is the name of additional style.
...
@@ -62,6 +64,8 @@ func (key SystemSettingName) String() string {
...
@@ -62,6 +64,8 @@ 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
SystemSettingAdditionalStyleName
:
case
SystemSettingAdditionalStyleName
:
...
@@ -102,6 +106,12 @@ func (upsert SystemSettingUpsert) Validate() error {
...
@@ -102,6 +106,12 @@ func (upsert SystemSettingUpsert) Validate() error {
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to unmarshal system setting allow signup value"
)
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
{
}
else
if
upsert
.
Name
==
SystemSettingDisablePublicMemosName
{
value
:=
false
value
:=
false
err
:=
json
.
Unmarshal
([]
byte
(
upsert
.
Value
),
&
value
)
err
:=
json
.
Unmarshal
([]
byte
(
upsert
.
Value
),
&
value
)
...
...
server/system.go
View file @
3eac19d2
...
@@ -42,6 +42,7 @@ func (s *Server) registerSystemRoutes(g *echo.Group) {
...
@@ -42,6 +42,7 @@ 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
,
AdditionalStyle
:
""
,
AdditionalStyle
:
""
,
AdditionalScript
:
""
,
AdditionalScript
:
""
,
...
@@ -75,6 +76,8 @@ func (s *Server) registerSystemRoutes(g *echo.Group) {
...
@@ -75,6 +76,8 @@ func (s *Server) registerSystemRoutes(g *echo.Group) {
if
systemSetting
.
Name
==
api
.
SystemSettingAllowSignUpName
{
if
systemSetting
.
Name
==
api
.
SystemSettingAllowSignUpName
{
systemStatus
.
AllowSignUp
=
baseValue
.
(
bool
)
systemStatus
.
AllowSignUp
=
baseValue
.
(
bool
)
}
else
if
systemSetting
.
Name
==
api
.
SystemSettingIgnoreUpgradeName
{
systemStatus
.
IgnoreUpgrade
=
baseValue
.
(
bool
)
}
else
if
systemSetting
.
Name
==
api
.
SystemSettingDisablePublicMemosName
{
}
else
if
systemSetting
.
Name
==
api
.
SystemSettingDisablePublicMemosName
{
systemStatus
.
DisablePublicMemos
=
baseValue
.
(
bool
)
systemStatus
.
DisablePublicMemos
=
baseValue
.
(
bool
)
}
else
if
systemSetting
.
Name
==
api
.
SystemSettingAdditionalStyleName
{
}
else
if
systemSetting
.
Name
==
api
.
SystemSettingAdditionalStyleName
{
...
...
web/src/components/Settings/SystemSection.tsx
View file @
3eac19d2
...
@@ -10,6 +10,7 @@ import "@/less/settings/system-section.less";
...
@@ -10,6 +10,7 @@ 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
;
...
@@ -31,6 +32,7 @@ const SystemSection = () => {
...
@@ -31,6 +32,7 @@ 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
,
...
@@ -75,6 +77,17 @@ const SystemSection = () => {
...
@@ -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
=
()
=>
{
const
handleUpdateCustomizedProfileButtonClick
=
()
=>
{
showUpdateCustomizedProfileDialog
();
showUpdateCustomizedProfileDialog
();
};
};
...
@@ -189,6 +202,10 @@ const SystemSection = () => {
...
@@ -189,6 +202,10 @@ 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"
>
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
)
}
/>
...
...
web/src/components/Up
dat
eVersionBanner.tsx
→
web/src/components/Up
grad
eVersionBanner.tsx
View file @
3eac19d2
...
@@ -10,7 +10,7 @@ interface State {
...
@@ -10,7 +10,7 @@ interface State {
show
:
boolean
;
show
:
boolean
;
}
}
const
Up
dat
eVersionBanner
:
React
.
FC
=
()
=>
{
const
Up
grad
eVersionBanner
:
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,6 +19,10 @@ const UpdateVersionBanner: React.FC = () => {
...
@@ -19,6 +19,10 @@ const UpdateVersionBanner: 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"
;
...
@@ -58,4 +62,4 @@ const UpdateVersionBanner: React.FC = () => {
...
@@ -58,4 +62,4 @@ const UpdateVersionBanner: React.FC = () => {
);
);
};
};
export
default
Up
dat
eVersionBanner
;
export
default
Up
grad
eVersionBanner
;
web/src/layouts/Root.tsx
View file @
3eac19d2
import
{
Outlet
}
from
"react-router-dom"
;
import
{
Outlet
}
from
"react-router-dom"
;
import
Header
from
"@/components/Header"
;
import
Header
from
"@/components/Header"
;
import
Up
dateVersionBanner
from
"@/components/Updat
eVersionBanner"
;
import
Up
gradeVersionBanner
from
"@/components/Upgrad
eVersionBanner"
;
function
Root
()
{
function
Root
()
{
return
(
return
(
<
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"
>
<
Up
dat
eVersionBanner
/>
<
Up
grad
eVersionBanner
/>
</
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"
>
<
Header
/>
<
Header
/>
...
...
web/src/store/module/global.ts
View file @
3eac19d2
...
@@ -11,6 +11,7 @@ export const initialGlobalState = async () => {
...
@@ -11,6 +11,7 @@ export const initialGlobalState = async () => {
appearance
:
"system"
as
Appearance
,
appearance
:
"system"
as
Appearance
,
systemStatus
:
{
systemStatus
:
{
allowSignUp
:
false
,
allowSignUp
:
false
,
ignoreUpgrade
:
false
,
disablePublicMemos
:
false
,
disablePublicMemos
:
false
,
additionalStyle
:
""
,
additionalStyle
:
""
,
additionalScript
:
""
,
additionalScript
:
""
,
...
...
web/src/store/reducer/global.ts
View file @
3eac19d2
...
@@ -19,6 +19,7 @@ const globalSlice = createSlice({
...
@@ -19,6 +19,7 @@ const globalSlice = createSlice({
},
},
dbSize
:
0
,
dbSize
:
0
,
allowSignUp
:
false
,
allowSignUp
:
false
,
ignoreUpgrade
:
false
,
disablePublicMemos
:
false
,
disablePublicMemos
:
false
,
additionalStyle
:
""
,
additionalStyle
:
""
,
additionalScript
:
""
,
additionalScript
:
""
,
...
...
web/src/types/modules/system.d.ts
View file @
3eac19d2
...
@@ -23,6 +23,7 @@ interface SystemStatus {
...
@@ -23,6 +23,7 @@ interface SystemStatus {
dbSize
:
number
;
dbSize
:
number
;
// System settings
// System settings
allowSignUp
:
boolean
;
allowSignUp
:
boolean
;
ignoreUpgrade
:
boolean
;
disablePublicMemos
:
boolean
;
disablePublicMemos
:
boolean
;
additionalStyle
:
string
;
additionalStyle
:
string
;
additionalScript
:
string
;
additionalScript
:
string
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment