summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/projects/settings/branch_rules/components/edit/protections/index.vue
blob: bcc0f64d667364738dffe0fd9d3f65d28aa03734 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<script>
import { GlSprintf, GlLink } from '@gitlab/ui';
import { s__ } from '~/locale';
import { helpPagePath } from '~/helpers/help_page_helper';
import PushProtections from './push_protections.vue';
import MergeProtections from './merge_protections.vue';

export const i18n = {
  protections: s__('BranchRules|Protections'),
  protectionsHelpText: s__(
    'BranchRules|Keep stable branches secure and force developers to use merge requests. %{linkStart}What are protected branches?%{linkEnd}',
  ),
};

export default {
  name: 'BranchProtections',
  i18n,
  components: {
    GlSprintf,
    GlLink,
    PushProtections,
    MergeProtections,
  },
  protectedBranchesHelpPath: helpPagePath('user/project/protected_branches'),
  props: {
    protections: {
      type: Object,
      required: true,
    },
  },
};
</script>

<template>
  <div>
    <h4 class="gl-border-t gl-pt-4">{{ $options.i18n.protections }}</h4>

    <div data-testid="protections-help-text">
      <gl-sprintf :message="$options.i18n.protectionsHelpText">
        <template #link="{ content }">
          <gl-link :href="$options.protectedBranchesHelpPath">{{ content }}</gl-link>
        </template>
      </gl-sprintf>
    </div>

    <push-protections
      class="gl-mt-5"
      :members-allowed-to-push="protections.membersAllowedToPush"
      :allow-force-push="protections.allowForcePush"
      v-on="$listeners"
    />

    <merge-protections
      :members-allowed-to-merge="protections.membersAllowedToMerge"
      :require-code-owners-approval="protections.requireCodeOwnersApproval"
      v-on="$listeners"
    />
  </div>
</template>