Skip to content

Commit

Permalink
Merge: - fix 'Check for Updates' button visibility
Browse files Browse the repository at this point in the history
Close #1878

* commit '61981a927babe1ec771c01c13e2d503e3dc957e5':
  Change getVersionSuccess reducer
  minor
  * POST /control/version.json: change response when update is disabled
  • Loading branch information
szolin committed Jul 14, 2020
2 parents b9fca8d + 61981a9 commit 95f4128
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion AGHTechDoc.md
Expand Up @@ -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.


Expand Down
5 changes: 3 additions & 2 deletions client/src/reducers/index.js
Expand Up @@ -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,
Expand All @@ -96,14 +96,15 @@ const dashboard = handleActions(
canAutoUpdate,
isUpdateAvailable: true,
processingVersion: false,
checkUpdateFlag: !!payload,
checkUpdateFlag: !payload.disabled,
};
return newState;
}

return {
...state,
processingVersion: false,
checkUpdateFlag: !payload.disabled,
};
},

Expand Down
4 changes: 4 additions & 0 deletions home/control_update.go
Expand Up @@ -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
}

Expand Down

0 comments on commit 95f4128

Please sign in to comment.