Commit 0cf721bd authored by Filipa Lacerda's avatar Filipa Lacerda Committed by Phil Hughes

Disable stop environment button while deployment is running

parent e232ebf7
...@@ -65,6 +65,14 @@ export default { ...@@ -65,6 +65,14 @@ export default {
deployedText() { deployedText() {
return this.$options.deployedTextMap[this.deployment.status]; return this.$options.deployedTextMap[this.deployment.status];
}, },
isDeployInProgress() {
return this.deployment.status === 'running';
},
deployInProgressTooltip() {
return this.isDeployInProgress
? __('Stopping this environment is currently not possible as a deployment is in progress')
: '';
},
shouldRenderDropdown() { shouldRenderDropdown() {
return ( return (
this.enableCiEnvironmentsStatusChanges && this.enableCiEnvironmentsStatusChanges &&
...@@ -183,15 +191,23 @@ export default { ...@@ -183,15 +191,23 @@ export default {
css-class="js-deploy-url js-deploy-url-feature-flag deploy-link btn btn-default btn-sm inlin" css-class="js-deploy-url js-deploy-url-feature-flag deploy-link btn btn-default btn-sm inlin"
/> />
</template> </template>
<loading-button <span
v-if="deployment.stop_url" v-if="deployment.stop_url"
:loading="isStopping" v-tooltip
container-class="btn btn-default btn-sm inline prepend-left-4" :title="deployInProgressTooltip"
title="Stop environment" class="d-inline-block"
@click="stopEnvironment" tabindex="0"
> >
<icon name="stop" /> <loading-button
</loading-button> :loading="isStopping"
:disabled="isDeployInProgress"
:title="__('Stop environment')"
container-class="js-stop-env btn btn-default btn-sm inline prepend-left-4"
@click="stopEnvironment"
>
<icon name="stop" />
</loading-button>
</span>
</div> </div>
</div> </div>
</div> </div>
......
---
title: Disables stop environment button while the deploy is in progress
merge_request:
author:
type: other
...@@ -5847,6 +5847,9 @@ msgstr "" ...@@ -5847,6 +5847,9 @@ msgstr ""
msgid "Status" msgid "Status"
msgstr "" msgstr ""
msgid "Stop environment"
msgstr ""
msgid "Stop impersonation" msgid "Stop impersonation"
msgstr "" msgstr ""
...@@ -5856,6 +5859,9 @@ msgstr "" ...@@ -5856,6 +5859,9 @@ msgstr ""
msgid "Stopped" msgid "Stopped"
msgstr "" msgstr ""
msgid "Stopping this environment is currently not possible as a deployment is in progress"
msgstr ""
msgid "Storage" msgid "Storage"
msgstr "" msgstr ""
......
...@@ -38,7 +38,7 @@ describe 'Merge request > User sees deployment widget', :js do ...@@ -38,7 +38,7 @@ describe 'Merge request > User sees deployment widget', :js do
end end
it 'does start build when stop button clicked' do it 'does start build when stop button clicked' do
accept_confirm { click_button('Stop environment') } accept_confirm { find('.js-stop-env').click }
expect(page).to have_content('close_app') expect(page).to have_content('close_app')
end end
...@@ -47,7 +47,7 @@ describe 'Merge request > User sees deployment widget', :js do ...@@ -47,7 +47,7 @@ describe 'Merge request > User sees deployment widget', :js do
let(:role) { :reporter } let(:role) { :reporter }
it 'does not show stop button' do it 'does not show stop button' do
expect(page).not_to have_button('Stop environment') expect(page).not_to have_selector('.js-stop-env')
end end
end end
end end
......
...@@ -242,6 +242,10 @@ describe('Deployment component', () => { ...@@ -242,6 +242,10 @@ describe('Deployment component', () => {
it('renders information about running deployment', () => { it('renders information about running deployment', () => {
expect(vm.$el.querySelector('.js-deployment-info').textContent).toContain('Deploying to'); expect(vm.$el.querySelector('.js-deployment-info').textContent).toContain('Deploying to');
}); });
it('renders disabled stop button', () => {
expect(vm.$el.querySelector('.js-stop-env').getAttribute('disabled')).toBe('disabled');
});
}); });
describe('success', () => { describe('success', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment