Skip to content
代码片段 群组 项目
提交 aa7bbeb7 编辑于 作者: Phil Hughes's avatar Phil Hughes
浏览文件

Merge branch 'afontaine/update-rollback-modal' into 'master'

Update text for rollback modal

See merge request gitlab-org/gitlab!91289
No related branches found
No related tags found
无相关合并请求
...@@ -6,6 +6,7 @@ import { GlModal, GlSprintf, GlLink } from '@gitlab/ui'; ...@@ -6,6 +6,7 @@ import { GlModal, GlSprintf, GlLink } from '@gitlab/ui';
import { escape } from 'lodash'; import { escape } from 'lodash';
import csrf from '~/lib/utils/csrf'; import csrf from '~/lib/utils/csrf';
import { __, s__, sprintf } from '~/locale'; import { __, s__, sprintf } from '~/locale';
import { helpPagePath } from '~/helpers/help_page_helper';
import rollbackEnvironment from '../graphql/mutations/rollback_environment.mutation.graphql'; import rollbackEnvironment from '../graphql/mutations/rollback_environment.mutation.graphql';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
...@@ -84,7 +85,9 @@ export default { ...@@ -84,7 +85,9 @@ export default {
return this.environment.commitUrl; return this.environment.commitUrl;
}, },
modalActionText() { modalActionText() {
return this.isLastDeployment ? s__('Environments|Re-deploy') : s__('Environments|Rollback'); return this.isLastDeployment
? s__('Environments|Re-deploy environment')
: s__('Environments|Rollback environment');
}, },
primaryProps() { primaryProps() {
let attributes = [{ variant: 'danger' }]; let attributes = [{ variant: 'danger' }];
...@@ -101,6 +104,15 @@ export default { ...@@ -101,6 +104,15 @@ export default {
isLastDeployment() { isLastDeployment() {
return this.environment?.isLastDeployment || this.environment?.lastDeployment?.isLast; return this.environment?.isLastDeployment || this.environment?.lastDeployment?.isLast;
}, },
modalBodyText() {
return this.isLastDeployment
? s__(
'Environments|This action will %{docsStart}retry the latest deployment%{docsEnd} with the commit %{commitId}, for this environment. Are you sure you want to continue?',
)
: s__(
'Environments|This action will %{docsStart}roll back this environment%{docsEnd} to a previously successful deployment for commit %{commitId}. Are you sure you want to continue?',
);
},
}, },
methods: { methods: {
handleChange(event) { handleChange(event) {
...@@ -125,6 +137,7 @@ export default { ...@@ -125,6 +137,7 @@ export default {
text: __('Cancel'), text: __('Cancel'),
attributes: [{ variant: 'danger' }], attributes: [{ variant: 'danger' }],
}, },
docsPath: helpPagePath('ci/environments/index.md', { anchor: 'retry-or-roll-back-a-deployment' }),
}; };
</script> </script>
<template> <template>
...@@ -137,33 +150,14 @@ export default { ...@@ -137,33 +150,14 @@ export default {
@ok="onOk" @ok="onOk"
@change="handleChange" @change="handleChange"
> >
<gl-sprintf <gl-sprintf :message="modalBodyText">
v-if="environment.isLastDeployment" <template #commitId>
:message="
s__(
'Environments|This action will relaunch the job for commit %{linkStart}%{commitId}%{linkEnd}, putting the environment in a previous version. Are you sure you want to continue?',
)
"
>
<template #link>
<gl-link :href="commitUrl" target="_blank" class="commit-sha mr-0">{{ <gl-link :href="commitUrl" target="_blank" class="commit-sha mr-0">{{
commitShortSha commitShortSha
}}</gl-link> }}</gl-link>
</template> </template>
</gl-sprintf> <template #docs="{ content }">
<gl-sprintf <gl-link :href="$options.docsLink" target="_blank">{{ content }}</gl-link>
v-else
:message="
s__(
'Environments|This action will run the job defined by %{name} for commit %{linkStart}%{commitId}%{linkEnd} putting the environment in a previous version. You can revert it by re-deploying the latest version of your application. Are you sure you want to continue?',
)
"
>
<template #name>{{ environment.name }}</template>
<template #link>
<gl-link :href="commitUrl" target="_blank" class="commit-sha mr-0">{{
commitShortSha
}}</gl-link>
</template> </template>
</gl-sprintf> </gl-sprintf>
</gl-modal> </gl-modal>
......
...@@ -14555,7 +14555,7 @@ msgstr "" ...@@ -14555,7 +14555,7 @@ msgstr ""
msgid "Environments|Pod name" msgid "Environments|Pod name"
msgstr "" msgstr ""
   
msgid "Environments|Re-deploy" msgid "Environments|Re-deploy environment"
msgstr "" msgstr ""
   
msgid "Environments|Re-deploy environment %{name}?" msgid "Environments|Re-deploy environment %{name}?"
...@@ -14564,9 +14564,6 @@ msgstr "" ...@@ -14564,9 +14564,6 @@ msgstr ""
msgid "Environments|Re-deploy to environment" msgid "Environments|Re-deploy to environment"
msgstr "" msgstr ""
   
msgid "Environments|Rollback"
msgstr ""
msgid "Environments|Rollback environment" msgid "Environments|Rollback environment"
msgstr "" msgstr ""
   
...@@ -14594,10 +14591,10 @@ msgstr "" ...@@ -14594,10 +14591,10 @@ msgstr ""
msgid "Environments|There was an error fetching the logs. Please try again." msgid "Environments|There was an error fetching the logs. Please try again."
msgstr "" msgstr ""
   
msgid "Environments|This action will relaunch the job for commit %{linkStart}%{commitId}%{linkEnd}, putting the environment in a previous version. Are you sure you want to continue?" msgid "Environments|This action will %{docsStart}retry the latest deployment%{docsEnd} with the commit %{commitId}, for this environment. Are you sure you want to continue?"
msgstr "" msgstr ""
   
msgid "Environments|This action will run the job defined by %{name} for commit %{linkStart}%{commitId}%{linkEnd} putting the environment in a previous version. You can revert it by re-deploying the latest version of your application. Are you sure you want to continue?" msgid "Environments|This action will %{docsStart}roll back this environment%{docsEnd} to a previously successful deployment for commit %{commitId}. Are you sure you want to continue?"
msgstr "" msgstr ""
   
msgid "Environments|Upcoming" msgid "Environments|Upcoming"
...@@ -2,6 +2,7 @@ import { GlModal, GlSprintf } from '@gitlab/ui'; ...@@ -2,6 +2,7 @@ import { GlModal, GlSprintf } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Vue, { nextTick } from 'vue'; import Vue, { nextTick } from 'vue';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import { trimText } from 'helpers/text_helper';
import ConfirmRollbackModal from '~/environments/components/confirm_rollback_modal.vue'; import ConfirmRollbackModal from '~/environments/components/confirm_rollback_modal.vue';
import createMockApollo from 'helpers/mock_apollo_helper'; import createMockApollo from 'helpers/mock_apollo_helper';
import eventHub from '~/environments/event_hub'; import eventHub from '~/environments/event_hub';
...@@ -76,9 +77,9 @@ describe('Confirm Rollback Modal Component', () => { ...@@ -76,9 +77,9 @@ describe('Confirm Rollback Modal Component', () => {
expect(modal.attributes('title')).toContain('Rollback'); expect(modal.attributes('title')).toContain('Rollback');
expect(modal.attributes('title')).toContain('test'); expect(modal.attributes('title')).toContain('test');
expect(modal.props('actionPrimary').text).toBe('Rollback'); expect(modal.props('actionPrimary').text).toBe('Rollback environment');
expect(modal.props('actionPrimary').attributes).toEqual(primaryPropsAttrs); expect(modal.props('actionPrimary').attributes).toEqual(primaryPropsAttrs);
expect(modal.text()).toContain('commit abc0123'); expect(trimText(modal.text())).toContain('commit abc0123');
expect(modal.text()).toContain('Are you sure you want to continue?'); expect(modal.text()).toContain('Are you sure you want to continue?');
}); });
...@@ -95,8 +96,8 @@ describe('Confirm Rollback Modal Component', () => { ...@@ -95,8 +96,8 @@ describe('Confirm Rollback Modal Component', () => {
expect(modal.attributes('title')).toContain('Re-deploy'); expect(modal.attributes('title')).toContain('Re-deploy');
expect(modal.attributes('title')).toContain('test'); expect(modal.attributes('title')).toContain('test');
expect(modal.props('actionPrimary').text).toBe('Re-deploy'); expect(modal.props('actionPrimary').text).toBe('Re-deploy environment');
expect(modal.text()).toContain('commit abc0123'); expect(trimText(modal.text())).toContain('commit abc0123');
expect(modal.text()).toContain('Are you sure you want to continue?'); expect(modal.text()).toContain('Are you sure you want to continue?');
}); });
...@@ -156,7 +157,7 @@ describe('Confirm Rollback Modal Component', () => { ...@@ -156,7 +157,7 @@ describe('Confirm Rollback Modal Component', () => {
); );
const modal = component.find(GlModal); const modal = component.find(GlModal);
expect(modal.text()).toContain('commit abc0123'); expect(trimText(modal.text())).toContain('commit abc0123');
expect(modal.text()).toContain('Are you sure you want to continue?'); expect(modal.text()).toContain('Are you sure you want to continue?');
}); });
...@@ -180,7 +181,7 @@ describe('Confirm Rollback Modal Component', () => { ...@@ -180,7 +181,7 @@ describe('Confirm Rollback Modal Component', () => {
expect(modal.attributes('title')).toContain('Rollback'); expect(modal.attributes('title')).toContain('Rollback');
expect(modal.attributes('title')).toContain('test'); expect(modal.attributes('title')).toContain('test');
expect(modal.props('actionPrimary').text).toBe('Rollback'); expect(modal.props('actionPrimary').text).toBe('Rollback environment');
expect(modal.props('actionPrimary').attributes).toEqual(primaryPropsAttrs); expect(modal.props('actionPrimary').attributes).toEqual(primaryPropsAttrs);
}); });
...@@ -204,7 +205,7 @@ describe('Confirm Rollback Modal Component', () => { ...@@ -204,7 +205,7 @@ describe('Confirm Rollback Modal Component', () => {
expect(modal.attributes('title')).toContain('Re-deploy'); expect(modal.attributes('title')).toContain('Re-deploy');
expect(modal.attributes('title')).toContain('test'); expect(modal.attributes('title')).toContain('test');
expect(modal.props('actionPrimary').text).toBe('Re-deploy'); expect(modal.props('actionPrimary').text).toBe('Re-deploy environment');
}); });
it('should commit the "rollback" mutation when "ok" is clicked', async () => { it('should commit the "rollback" mutation when "ok" is clicked', async () => {
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册