Merge: - fix 'Check for Updates' button visibility

Close #1878

* commit '61981a927babe1ec771c01c13e2d503e3dc957e5':
  Change getVersionSuccess reducer
  minor
  * POST /control/version.json: change response when update is disabled
This commit is contained in:
Simon Zolin 2020-07-14 19:28:56 +03:00
commit 95f4128551
3 changed files with 12 additions and 3 deletions

View File

@ -344,10 +344,14 @@ Response:
If `can_autoupdate` is true, then the server can automatically upgrade to a new version.
Response with empty body:
Response when auto-update is disabled by command-line argument:
200 OK
{
"disabled":true
}
It means that update check is disabled by user. UI should do nothing.

View File

@ -82,7 +82,7 @@ const dashboard = handleActions(
[actions.getVersionSuccess]: (state, { payload }) => {
const currentVersion = state.dnsVersion === 'undefined' ? 0 : state.dnsVersion;
if (payload && isVersionGreater(currentVersion, payload.new_version)) {
if (!payload.disabled && isVersionGreater(currentVersion, payload.new_version)) {
const {
announcement_url: announcementUrl,
new_version: newVersion,
@ -96,7 +96,7 @@ const dashboard = handleActions(
canAutoUpdate,
isUpdateAvailable: true,
processingVersion: false,
checkUpdateFlag: !!payload,
checkUpdateFlag: !payload.disabled,
};
return newState;
}
@ -104,6 +104,7 @@ const dashboard = handleActions(
return {
...state,
processingVersion: false,
checkUpdateFlag: !payload.disabled,
};
},

View File

@ -41,6 +41,10 @@ type getVersionJSONRequest struct {
// Get the latest available version from the Internet
func handleGetVersionJSON(w http.ResponseWriter, r *http.Request) {
if Context.disableUpdate {
resp := make(map[string]interface{})
resp["disabled"] = true
d, _ := json.Marshal(resp)
_, _ = w.Write(d)
return
}