Commit ee0d1c43 authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera

Merge branch...

Merge branch '241919-remove-v-html-from-app-assets-javascripts-vue_merge_request_widget-components-states' into 'master'

Replace v-html with gl-icon and gl-sprintf in app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue

Closes #241919

See merge request gitlab-org/gitlab!41514
parents b4fe7184 ce713e15
<script> <script>
/* eslint-disable vue/no-v-html */
import { isEmpty } from 'lodash'; import { isEmpty } from 'lodash';
import { GlIcon, GlButton, GlSprintf, GlLink } from '@gitlab/ui'; import { GlIcon, GlButton, GlSprintf, GlLink } from '@gitlab/ui';
import successSvg from 'icons/_icon_status_success.svg';
import warningSvg from 'icons/_icon_status_warning.svg';
import readyToMergeMixin from 'ee_else_ce/vue_merge_request_widget/mixins/ready_to_merge'; import readyToMergeMixin from 'ee_else_ce/vue_merge_request_widget/mixins/ready_to_merge';
import simplePoll from '~/lib/utils/simple_poll'; import simplePoll from '~/lib/utils/simple_poll';
import { __, sprintf } from '~/locale'; import { __ } from '~/locale';
import MergeRequest from '../../../merge_request'; import MergeRequest from '../../../merge_request';
import { refreshUserMergeRequestCounts } from '~/commons/nav/user_merge_requests'; import { refreshUserMergeRequestCounts } from '~/commons/nav/user_merge_requests';
import { deprecatedCreateFlash as Flash } from '../../../flash'; import { deprecatedCreateFlash as Flash } from '../../../flash';
...@@ -59,8 +56,6 @@ export default { ...@@ -59,8 +56,6 @@ export default {
commitMessage: this.mr.commitMessage, commitMessage: this.mr.commitMessage,
squashBeforeMerge: this.mr.squashIsSelected, squashBeforeMerge: this.mr.squashIsSelected,
isSquashReadOnly: this.mr.squashIsReadonly, isSquashReadOnly: this.mr.squashIsReadonly,
successSvg,
warningSvg,
squashCommitMessage: this.mr.squashCommitMessage, squashCommitMessage: this.mr.squashCommitMessage,
}; };
}, },
...@@ -147,16 +142,7 @@ export default { ...@@ -147,16 +142,7 @@ export default {
return !this.mr.ffOnlyEnabled; return !this.mr.ffOnlyEnabled;
}, },
shaMismatchLink() { shaMismatchLink() {
const href = this.mr.mergeRequestDiffsPath; return this.mr.mergeRequestDiffsPath;
return sprintf(
__('New changes were added. %{linkStart}Reload the page to review them%{linkEnd}'),
{
linkStart: `<a href="${href}">`,
linkEnd: '</a>',
},
false,
);
}, },
}, },
methods: { methods: {
...@@ -331,7 +317,7 @@ export default { ...@@ -331,7 +317,7 @@ export default {
@click.prevent="handleMergeButtonClick(true)" @click.prevent="handleMergeButtonClick(true)"
> >
<span class="media"> <span class="media">
<span class="merge-opt-icon" aria-hidden="true" v-html="successSvg"></span> <gl-icon name="status_success" class="merge-opt-icon" aria-hidden="true" />
<span class="media-body merge-opt-title">{{ autoMergeText }}</span> <span class="media-body merge-opt-title">{{ autoMergeText }}</span>
</span> </span>
</a> </a>
...@@ -349,7 +335,7 @@ export default { ...@@ -349,7 +335,7 @@ export default {
@click.prevent="handleMergeImmediatelyButtonClick" @click.prevent="handleMergeImmediatelyButtonClick"
> >
<span class="media"> <span class="media">
<span class="merge-opt-icon" aria-hidden="true" v-html="warningSvg"></span> <gl-icon name="status_warning" class="merge-opt-icon" aria-hidden="true" />
<span class="media-body merge-opt-title">{{ __('Merge immediately') }}</span> <span class="media-body merge-opt-title">{{ __('Merge immediately') }}</span>
</span> </span>
</a> </a>
...@@ -400,7 +386,17 @@ export default { ...@@ -400,7 +386,17 @@ export default {
</div> </div>
<div v-if="mr.isSHAMismatch" class="d-flex align-items-center mt-2 js-sha-mismatch"> <div v-if="mr.isSHAMismatch" class="d-flex align-items-center mt-2 js-sha-mismatch">
<gl-icon name="warning-solid" class="text-warning mr-1" /> <gl-icon name="warning-solid" class="text-warning mr-1" />
<span class="text-warning" v-html="shaMismatchLink"></span> <span class="text-warning">
<gl-sprintf
:message="
__('New changes were added. %{linkStart}Reload the page to review them%{linkEnd}')
"
>
<template #link="{ content }">
<gl-link :href="mr.mergeRequestDiffsPath">{{ content }}</gl-link>
</template>
</gl-sprintf>
</span>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -101,8 +101,6 @@ describe('ReadyToMerge', () => { ...@@ -101,8 +101,6 @@ describe('ReadyToMerge', () => {
expect(vm.isMakingRequest).toBeFalsy(); expect(vm.isMakingRequest).toBeFalsy();
expect(vm.isMergingImmediately).toBeFalsy(); expect(vm.isMergingImmediately).toBeFalsy();
expect(vm.commitMessage).toBe(vm.mr.commitMessage); expect(vm.commitMessage).toBe(vm.mr.commitMessage);
expect(vm.successSvg).toBeDefined();
expect(vm.warningSvg).toBeDefined();
}); });
}); });
......
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