From d38b58cd85d663ecadaf785d53dc16666444fa9a Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Tue, 14 Jul 2020 17:08:53 +0300 Subject: [PATCH 1/3] * POST /control/version.json: change response when update is disabled --- AGHTechDoc.md | 6 +++++- home/control_update.go | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/AGHTechDoc.md b/AGHTechDoc.md index 3e3574e23ff..527a7eaafe8 100644 --- a/AGHTechDoc.md +++ b/AGHTechDoc.md @@ -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 aragument: 200 OK + { + "disabled":true + } + It means that update check is disabled by user. UI should do nothing. diff --git a/home/control_update.go b/home/control_update.go index d734f4d1644..566b8327bc1 100644 --- a/home/control_update.go +++ b/home/control_update.go @@ -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 } From 54693bb158cff978236adef1291966525da08965 Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Tue, 14 Jul 2020 17:10:34 +0300 Subject: [PATCH 2/3] minor --- AGHTechDoc.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AGHTechDoc.md b/AGHTechDoc.md index 527a7eaafe8..e70d1609a06 100644 --- a/AGHTechDoc.md +++ b/AGHTechDoc.md @@ -344,7 +344,7 @@ Response: If `can_autoupdate` is true, then the server can automatically upgrade to a new version. -Response when auto-update is disabled by command-line aragument: +Response when auto-update is disabled by command-line argument: 200 OK From 61981a927babe1ec771c01c13e2d503e3dc957e5 Mon Sep 17 00:00:00 2001 From: ArtemBaskal Date: Tue, 14 Jul 2020 18:42:24 +0300 Subject: [PATCH 3/3] Change getVersionSuccess reducer --- client/src/reducers/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/src/reducers/index.js b/client/src/reducers/index.js index 642d85032c5..cc25a4b9a20 100644 --- a/client/src/reducers/index.js +++ b/client/src/reducers/index.js @@ -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, }; },