From 79d1a446575356aca5779ebc6b2c5ba9cca412ad Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Fri, 9 Nov 2018 17:09:13 +0300 Subject: [PATCH] Allow updating to the specified version from WebUI --- lib/Controller/MarketController.php | 10 ++++++---- src/components/Details.vue | 8 ++++++-- src/components/UpdateList.vue | 2 +- src/store.js | 4 +++- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/Controller/MarketController.php b/lib/Controller/MarketController.php index cec2b2fa..10feb480 100644 --- a/lib/Controller/MarketController.php +++ b/lib/Controller/MarketController.php @@ -202,15 +202,17 @@ public function uninstall($appId) { * @return array | DataResponse */ public function update($appId) { + $targetVersion = $this->request->getParam('toVersion'); try { - $this->marketService->updateApp($appId); + $this->marketService->updateApp($appId, $targetVersion); return [ 'message' => $this->l10n->t('App %s updated successfully', $appId) ]; } catch(\Exception $ex) { - return new DataResponse([ - 'message' => $ex->getMessage() - ], Http::STATUS_BAD_REQUEST); + return new DataResponse( + ['message' => $ex->getMessage()], + Http::STATUS_BAD_REQUEST + ); } } diff --git a/src/components/Details.vue b/src/components/Details.vue index a97e2139..b02c5202 100644 --- a/src/components/Details.vue +++ b/src/components/Details.vue @@ -112,7 +112,7 @@ data () { return { // Key of releases array - // if length exeeds 1 + // if length exceeds 1 updateVersion : 0 } }, @@ -202,7 +202,11 @@ }); }, update () { - this.$store.dispatch('PROCESS_APPLICATION', [this.application.id, 'update']) + if (this.releases.length > 1) { + this.$store.dispatch('PROCESS_APPLICATION', [this.application.id, 'update', {'version' : this.releases[this.updateVersion].version}]); + } else { + this.$store.dispatch('PROCESS_APPLICATION', [this.application.id, 'update']); + } }, setUpdateVersion (version) { UIkit.dropdown('._multiupdate-uikit-element').hide(); diff --git a/src/components/UpdateList.vue b/src/components/UpdateList.vue index 91ba8d84..968964d7 100644 --- a/src/components/UpdateList.vue +++ b/src/components/UpdateList.vue @@ -54,7 +54,7 @@ }, methods: { update (id, version) { - this.$store.dispatch('PROCESS_APPLICATION', [id, 'update']) + this.$store.dispatch('PROCESS_APPLICATION', [id, 'update', {'version' : version}]) }, processing(id) { return _.contains(this.$store.state.processing, id) diff --git a/src/store.js b/src/store.js index efb6fef6..5d52ed2d 100644 --- a/src/store.js +++ b/src/store.js @@ -236,8 +236,10 @@ const actions = { context.commit("START_PROCESSING", id); + let data = (options.version) ? {'toVersion' : options.version} : {}; + return Axios.post(OC.generateUrl("/apps/market/apps/{id}/" + route, {id}), - {}, { + data, { headers: { requesttoken: OC.requestToken }