Commit 4b0e584f authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'ph/284212/moveCodeownersTipToVueApp' into 'master'

Moves the CODEOWNERS tip into the Vue approvals app

See merge request gitlab-org/gitlab!54830
parents b5e740a0 c5c1d599
---
title: Moved CODEOWNERS tip into approvals Vue app
merge_request: 54830
author:
type: changed
<script> <script>
import { GlSafeHtmlDirective, GlAccordion, GlAccordionItem } from '@gitlab/ui'; import { GlSafeHtmlDirective, GlAccordion, GlAccordionItem, GlSprintf, GlLink } from '@gitlab/ui';
import { mapState } from 'vuex'; import { mapState } from 'vuex';
import { helpPagePath } from '~/helpers/help_page_helper';
import { __, n__, sprintf, s__ } from '~/locale'; import { __, n__, sprintf, s__ } from '~/locale';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import App from '../app.vue'; import App from '../app.vue';
...@@ -11,6 +12,8 @@ export default { ...@@ -11,6 +12,8 @@ export default {
components: { components: {
GlAccordion, GlAccordion,
GlAccordionItem, GlAccordionItem,
GlSprintf,
GlLink,
App, App,
MrRules, MrRules,
MrRulesHiddenInputs, MrRulesHiddenInputs,
...@@ -23,6 +26,8 @@ export default { ...@@ -23,6 +26,8 @@ export default {
...mapState({ ...mapState({
rules: (state) => state.approvals.rules, rules: (state) => state.approvals.rules,
canOverride: (state) => state.settings.canOverride, canOverride: (state) => state.settings.canOverride,
canUpdateApprovers: (state) => state.settings.canUpdateApprovers,
showCodeOwnerTip: (state) => state.settings.showCodeOwnerTip,
}), }),
accordionTitle() { accordionTitle() {
return s__('ApprovalRule|Approval rules'); return s__('ApprovalRule|Approval rules');
...@@ -95,6 +100,7 @@ export default { ...@@ -95,6 +100,7 @@ export default {
return null; return null;
}, },
}, },
codeOwnerHelpPage: helpPagePath('user/project/code_owners'),
}; };
</script> </script>
...@@ -110,7 +116,28 @@ export default { ...@@ -110,7 +116,28 @@ export default {
<gl-accordion-item :title="accordionTitle"> <gl-accordion-item :title="accordionTitle">
<app> <app>
<mr-rules slot="rules" /> <mr-rules slot="rules" />
<mr-rules-hidden-inputs slot="footer" /> <div slot="footer">
<mr-rules-hidden-inputs />
<div
v-if="canUpdateApprovers && showCodeOwnerTip"
class="form-text text-muted"
data-testid="codeowners-tip"
>
<gl-sprintf
:message="
__(
'Tip: add a %{linkStart}CODEOWNERS%{linkEnd} to automatically add approvers based on file paths and file types.',
)
"
>
<template #link="{ content }">
<gl-link :href="$options.codeOwnerHelpPage" target="_blank">{{
content
}}</gl-link>
</template>
</gl-sprintf>
</div>
</div>
</app> </app>
</gl-accordion-item> </gl-accordion-item>
</gl-accordion> </gl-accordion>
......
...@@ -20,6 +20,8 @@ export default function mountApprovalInput(el) { ...@@ -20,6 +20,8 @@ export default function mountApprovalInput(el) {
...el.dataset, ...el.dataset,
prefix: 'mr-edit', prefix: 'mr-edit',
canEdit: parseBoolean(el.dataset.canEdit), canEdit: parseBoolean(el.dataset.canEdit),
canUpdateApprovers: parseBoolean(el.dataset.canUpdateApprovers),
showCodeOwnerTip: parseBoolean(el.dataset.showCodeOwnerTip),
allowMultiRule: parseBoolean(el.dataset.allowMultiRule), allowMultiRule: parseBoolean(el.dataset.allowMultiRule),
canOverride: parseBoolean(el.dataset.canOverride), canOverride: parseBoolean(el.dataset.canOverride),
}); });
......
...@@ -2,9 +2,13 @@ ...@@ -2,9 +2,13 @@
- presenter = local_assigns.fetch(:presenter) - presenter = local_assigns.fetch(:presenter)
- can_update_approvers = can?(current_user, :update_approvers, issuable) - can_update_approvers = can?(current_user, :update_approvers, issuable)
- approver_presenter = MergeRequestApproverPresenter.new(issuable, skip_user: current_user)
- show_code_owner_tip = approver_presenter.show_code_owner_tips?
#js-mr-approvals-input{ data: { 'project_id': @target_project.id, #js-mr-approvals-input{ data: { 'project_id': @target_project.id,
'can_edit': can?(current_user, :update_approvers, issuable).to_s, 'can_edit': can?(current_user, :update_approvers, issuable).to_s,
'can_update_approvers': can_update_approvers.to_s,
'show_code_owner_tip': show_code_owner_tip.to_s,
'allow_multi_rule': @target_project.multiple_approval_rules_available?.to_s, 'allow_multi_rule': @target_project.multiple_approval_rules_available?.to_s,
'can-override': @target_project.can_override_approvers?.to_s, 'can-override': @target_project.can_override_approvers?.to_s,
'mr_id': issuable.iid, 'mr_id': issuable.iid,
...@@ -12,9 +16,7 @@ ...@@ -12,9 +16,7 @@
'eligible_approvers_docs_path': help_page_path('user/project/merge_requests/merge_request_approvals', anchor: 'eligible-approvers'), 'eligible_approvers_docs_path': help_page_path('user/project/merge_requests/merge_request_approvals', anchor: 'eligible-approvers'),
'project_settings_path': presenter.api_project_approval_settings_path } } 'project_settings_path': presenter.api_project_approval_settings_path } }
= sprite_icon('spinner', size: 24, css_class: 'gl-spinner') = sprite_icon('spinner', size: 24, css_class: 'gl-spinner')
- if can_update_approvers - if can_update_approvers && show_code_owner_tip && Feature.disabled?(:mr_collapsed_approval_rules, @project, default_enabled: :yaml)
- approver_presenter = MergeRequestApproverPresenter.new(issuable, skip_user: current_user)
- if approver_presenter.show_code_owner_tips?
.form-text.text-muted .form-text.text-muted
= _('Tip: add a') = _('Tip: add a')
= link_to 'CODEOWNERS', help_page_path('user/project/code_owners'), target: '_blank', tabindex: -1 = link_to 'CODEOWNERS', help_page_path('user/project/code_owners'), target: '_blank', tabindex: -1
......
...@@ -41,6 +41,15 @@ describe('EE Approvals MREditApp', () => { ...@@ -41,6 +41,15 @@ describe('EE Approvals MREditApp', () => {
axiosMock.restore(); axiosMock.restore();
}); });
it('renders CODEOWNERS tip', () => {
store.state.settings.canUpdateApprovers = true;
store.state.settings.showCodeOwnerTip = true;
factory(true);
expect(wrapper.find('[data-testid="codeowners-tip"]').exists()).toBe(true);
});
describe('with empty rules', () => { describe('with empty rules', () => {
beforeEach(() => { beforeEach(() => {
store.modules.approvals.state.rules = []; store.modules.approvals.state.rules = [];
......
...@@ -30970,6 +30970,9 @@ msgstr "" ...@@ -30970,6 +30970,9 @@ msgstr ""
msgid "Tip: add a" msgid "Tip: add a"
msgstr "" msgstr ""
msgid "Tip: add a %{linkStart}CODEOWNERS%{linkEnd} to automatically add approvers based on file paths and file types."
msgstr ""
msgid "Title" msgid "Title"
msgstr "" msgstr ""
......
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