diff --git a/app/assets/javascripts/environments/components/confirm_rollback_modal.vue b/app/assets/javascripts/environments/components/confirm_rollback_modal.vue index ce919f73858e7a49212f5700a3e2e766209a24dc..8259574f8e37867035fecd9f68fd3ba3814160f7 100644 --- a/app/assets/javascripts/environments/components/confirm_rollback_modal.vue +++ b/app/assets/javascripts/environments/components/confirm_rollback_modal.vue @@ -6,6 +6,7 @@ import { GlModal, GlSprintf, GlLink } from '@gitlab/ui'; import { escape } from 'lodash'; import csrf from '~/lib/utils/csrf'; import { __, s__, sprintf } from '~/locale'; +import { helpPagePath } from '~/helpers/help_page_helper'; import rollbackEnvironment from '../graphql/mutations/rollback_environment.mutation.graphql'; import eventHub from '../event_hub'; @@ -84,7 +85,9 @@ export default { return this.environment.commitUrl; }, modalActionText() { - return this.isLastDeployment ? s__('Environments|Re-deploy') : s__('Environments|Rollback'); + return this.isLastDeployment + ? s__('Environments|Re-deploy environment') + : s__('Environments|Rollback environment'); }, primaryProps() { let attributes = [{ variant: 'danger' }]; @@ -101,6 +104,15 @@ export default { isLastDeployment() { 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: { handleChange(event) { @@ -125,6 +137,7 @@ export default { text: __('Cancel'), attributes: [{ variant: 'danger' }], }, + docsPath: helpPagePath('ci/environments/index.md', { anchor: 'retry-or-roll-back-a-deployment' }), }; </script> <template> @@ -137,33 +150,14 @@ export default { @ok="onOk" @change="handleChange" > - <gl-sprintf - v-if="environment.isLastDeployment" - :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-sprintf :message="modalBodyText"> + <template #commitId> <gl-link :href="commitUrl" target="_blank" class="commit-sha mr-0">{{ commitShortSha }}</gl-link> </template> - </gl-sprintf> - <gl-sprintf - 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 #docs="{ content }"> + <gl-link :href="$options.docsLink" target="_blank">{{ content }}</gl-link> </template> </gl-sprintf> </gl-modal> diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 207ec7fffe506edba94ea0672ed640ae4f4d7b1f..c1ee0b360e87cdafe30e9b5a7ad072f016ec5d0d 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -14555,7 +14555,7 @@ msgstr "" msgid "Environments|Pod name" msgstr "" -msgid "Environments|Re-deploy" +msgid "Environments|Re-deploy environment" msgstr "" msgid "Environments|Re-deploy environment %{name}?" @@ -14564,9 +14564,6 @@ msgstr "" msgid "Environments|Re-deploy to environment" msgstr "" -msgid "Environments|Rollback" -msgstr "" - msgid "Environments|Rollback environment" msgstr "" @@ -14594,10 +14591,10 @@ msgstr "" msgid "Environments|There was an error fetching the logs. Please try again." 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 "" -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 "" msgid "Environments|Upcoming" diff --git a/spec/frontend/environments/confirm_rollback_modal_spec.js b/spec/frontend/environments/confirm_rollback_modal_spec.js index b8dcb7c0d08a0aad930b82e9179e1c3b224f6a3c..c4763933468e76b9888c5e9ecef4ee05d9e8cacd 100644 --- a/spec/frontend/environments/confirm_rollback_modal_spec.js +++ b/spec/frontend/environments/confirm_rollback_modal_spec.js @@ -2,6 +2,7 @@ import { GlModal, GlSprintf } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; import Vue, { nextTick } from 'vue'; import VueApollo from 'vue-apollo'; +import { trimText } from 'helpers/text_helper'; import ConfirmRollbackModal from '~/environments/components/confirm_rollback_modal.vue'; import createMockApollo from 'helpers/mock_apollo_helper'; import eventHub from '~/environments/event_hub'; @@ -76,9 +77,9 @@ describe('Confirm Rollback Modal Component', () => { expect(modal.attributes('title')).toContain('Rollback'); 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.text()).toContain('commit abc0123'); + expect(trimText(modal.text())).toContain('commit abc0123'); expect(modal.text()).toContain('Are you sure you want to continue?'); }); @@ -95,8 +96,8 @@ describe('Confirm Rollback Modal Component', () => { expect(modal.attributes('title')).toContain('Re-deploy'); expect(modal.attributes('title')).toContain('test'); - expect(modal.props('actionPrimary').text).toBe('Re-deploy'); - expect(modal.text()).toContain('commit abc0123'); + expect(modal.props('actionPrimary').text).toBe('Re-deploy environment'); + expect(trimText(modal.text())).toContain('commit abc0123'); expect(modal.text()).toContain('Are you sure you want to continue?'); }); @@ -156,7 +157,7 @@ describe('Confirm Rollback Modal Component', () => { ); 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?'); }); @@ -180,7 +181,7 @@ describe('Confirm Rollback Modal Component', () => { expect(modal.attributes('title')).toContain('Rollback'); 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); }); @@ -204,7 +205,7 @@ describe('Confirm Rollback Modal Component', () => { expect(modal.attributes('title')).toContain('Re-deploy'); 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 () => {