From 16cca3a0ea7f4b95e99d7b3e8d4953334fa7bec7 Mon Sep 17 00:00:00 2001 From: Toon Claes Date: Fri, 17 Mar 2017 17:25:17 +0100 Subject: Expose if action is playable in JSON To avoid a manual build action being played (resulting in a 404), expose `playable?` in the JSON so the frontend can disable/hide the play button if it's not playable. --- app/assets/javascripts/environments/components/environment_item.js | 1 + app/serializers/build_action_entity.rb | 2 ++ app/serializers/build_entity.rb | 1 + 3 files changed, 4 insertions(+) (limited to 'app') diff --git a/app/assets/javascripts/environments/components/environment_item.js b/app/assets/javascripts/environments/components/environment_item.js index 93919d41c60..9d753b4f808 100644 --- a/app/assets/javascripts/environments/components/environment_item.js +++ b/app/assets/javascripts/environments/components/environment_item.js @@ -141,6 +141,7 @@ export default { const parsedAction = { name: gl.text.humanize(action.name), play_path: action.play_path, + playable: action.playable, }; return parsedAction; }); diff --git a/app/serializers/build_action_entity.rb b/app/serializers/build_action_entity.rb index 184f5fd4b52..184b4b7a681 100644 --- a/app/serializers/build_action_entity.rb +++ b/app/serializers/build_action_entity.rb @@ -11,4 +11,6 @@ class BuildActionEntity < Grape::Entity build.project, build) end + + expose :playable?, as: :playable end diff --git a/app/serializers/build_entity.rb b/app/serializers/build_entity.rb index 5bcbe285052..2c116102888 100644 --- a/app/serializers/build_entity.rb +++ b/app/serializers/build_entity.rb @@ -16,6 +16,7 @@ class BuildEntity < Grape::Entity path_to(:play_namespace_project_build, build) end + expose :playable?, as: :playable expose :created_at expose :updated_at -- cgit v1.2.1 From 3db1b959f6488cf861a2bdf32f1c5ff336f7a881 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Mon, 3 Apr 2017 17:54:16 +0100 Subject: Buttons will be disabled when playable key is false --- .../javascripts/environments/components/environment_actions.js | 6 +++++- .../vue_pipelines_index/components/pipelines_actions.js | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/assets/javascripts/environments/components/environment_actions.js b/app/assets/javascripts/environments/components/environment_actions.js index 385085c03e2..49b3ae683d0 100644 --- a/app/assets/javascripts/environments/components/environment_actions.js +++ b/app/assets/javascripts/environments/components/environment_actions.js @@ -50,6 +50,7 @@ export default { template: `
-- cgit v1.2.1 From d037a2e998b807d01585a48af90a3b3182eeebc5 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Tue, 4 Apr 2017 09:14:46 +0100 Subject: Fix typo Adds tests --- .../javascripts/environments/components/environment_actions.js | 2 +- .../javascripts/vue_pipelines_index/components/pipelines_actions.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/assets/javascripts/environments/components/environment_actions.js b/app/assets/javascripts/environments/components/environment_actions.js index 49b3ae683d0..b88b1c6556e 100644 --- a/app/assets/javascripts/environments/components/environment_actions.js +++ b/app/assets/javascripts/environments/components/environment_actions.js @@ -69,7 +69,7 @@ export default { type="button" @click="onClickAction(action.play_path)" class="js-manual-action-link no-btn btn" - :class="{ 'disabled': !actions.playable }" + :class="{ 'disabled': !action.playable }" :disabled="!action.playable"> ${playIconSvg} diff --git a/app/assets/javascripts/vue_pipelines_index/components/pipelines_actions.js b/app/assets/javascripts/vue_pipelines_index/components/pipelines_actions.js index 8e9850233ab..5eebda93b39 100644 --- a/app/assets/javascripts/vue_pipelines_index/components/pipelines_actions.js +++ b/app/assets/javascripts/vue_pipelines_index/components/pipelines_actions.js @@ -49,7 +49,7 @@ export default { data-toggle="dropdown" data-placement="top" aria-label="Manual job" - :disabled="isDisabled"> + :disabled="isLoading"> ${playIconSvg} @@ -60,9 +60,9 @@ export default { -- cgit v1.2.1 From 5197b011a97a86b1c57cff8d8de73c30914c8c76 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Tue, 4 Apr 2017 14:14:15 +0100 Subject: Fixes broken lints Adds js unit tests --- .../environments/components/environment_actions.js | 23 +++++++++++++++++----- .../components/pipelines_actions.js | 21 ++++++++++++++++---- 2 files changed, 35 insertions(+), 9 deletions(-) (limited to 'app') diff --git a/app/assets/javascripts/environments/components/environment_actions.js b/app/assets/javascripts/environments/components/environment_actions.js index b88b1c6556e..4bb7920bb5e 100644 --- a/app/assets/javascripts/environments/components/environment_actions.js +++ b/app/assets/javascripts/environments/components/environment_actions.js @@ -45,6 +45,14 @@ export default { new Flash('An error occured while making the request.'); }); }, + + isActionDisabled(action) { + if (action.playable === undefined) { + return false; + } + + return !action.playable; + }, }, template: ` @@ -59,18 +67,23 @@ export default { :disabled="isLoading"> - - +