summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/projects/settings/branch_rules/components/edit/protections/push_protections.vue
blob: 95e140f30a911d63015c547f88f7e6b47ca350a6 (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
<script>
import { GlFormGroup, GlSprintf, GlLink, GlFormCheckbox } from '@gitlab/ui';
import { s__ } from '~/locale';
import { helpPagePath } from '~/helpers/help_page_helper';

export const i18n = {
  allowedToPush: s__('BranchRules|Allowed to push and merge'),
  forcePushTitle: s__(
    'BranchRules|Allow all users with push access to %{linkStart}force push%{linkEnd}.',
  ),
};

export default {
  name: 'BranchPushProtections',
  i18n,
  components: {
    GlFormGroup,
    GlSprintf,
    GlLink,
    GlFormCheckbox,
  },
  forcePushHelpPath: helpPagePath('topics/git/git_rebase', { anchor: 'force-push' }),
  props: {
    membersAllowedToPush: {
      type: Array,
      required: true,
    },
    allowForcePush: {
      type: Boolean,
      required: true,
    },
  },
};
</script>

<template>
  <gl-form-group :label="$options.i18n.allowedToPush">
    <!-- TODO: add multi-select-dropdown (https://gitlab.com/gitlab-org/gitlab/-/issues/362212) -->

    <gl-form-checkbox
      class="gl-mt-5"
      :checked="allowForcePush"
      @change="$emit('change-allow-force-push', $event)"
    >
      <gl-sprintf :message="$options.i18n.forcePushTitle">
        <template #link="{ content }">
          <gl-link :href="$options.forcePushHelpPath">{{ content }}</gl-link>
        </template>
      </gl-sprintf>
    </gl-form-checkbox>
  </gl-form-group>
</template>