Welcome to mirror list, hosted at ThFree Co, Russian Federation.

protection.vue « view « components « branch_rules « settings « projects « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cfe2df0dbda1facc5d8ef742c165a4428b5e5a7f (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<script>
import { GlCard, GlLink } from '@gitlab/ui';
import { s__ } from '~/locale';
import ProtectionRow from './protection_row.vue';

export const i18n = {
  rolesTitle: s__('BranchRules|Roles'),
  usersTitle: s__('BranchRules|Users'),
  groupsTitle: s__('BranchRules|Groups'),
};

export default {
  name: 'ProtectionDetail',
  i18n,
  components: { GlCard, GlLink, ProtectionRow },
  props: {
    header: {
      type: String,
      required: true,
    },
    headerLinkTitle: {
      type: String,
      required: true,
    },
    headerLinkHref: {
      type: String,
      required: true,
    },
    roles: {
      type: Array,
      required: false,
      default: () => [],
    },
    users: {
      type: Array,
      required: false,
      default: () => [],
    },
    groups: {
      type: Array,
      required: false,
      default: () => [],
    },
    approvals: {
      type: Array,
      required: false,
      default: () => [],
    },
  },
  computed: {
    showUsersDivider() {
      return Boolean(this.roles.length);
    },
    showGroupsDivider() {
      return Boolean(this.roles.length || this.users.length);
    },
  },
};
</script>

<template>
  <gl-card class="gl-mb-5" body-class="gl-py-0">
    <template #header>
      <div class="gl-display-flex gl-justify-content-space-between">
        <strong>{{ header }}</strong>
        <gl-link :href="headerLinkHref">{{ headerLinkTitle }}</gl-link>
      </div>
    </template>

    <!-- Roles -->
    <protection-row v-if="roles.length" :title="$options.i18n.rolesTitle" :access-levels="roles" />

    <!-- Users -->
    <protection-row
      v-if="users.length"
      :show-divider="showUsersDivider"
      :users="users"
      :title="$options.i18n.usersTitle"
    />

    <!-- Groups -->
    <protection-row
      v-if="groups.length"
      :show-divider="showGroupsDivider"
      :title="$options.i18n.groupsTitle"
      :access-levels="groups"
    />

    <!-- Approvals -->
    <protection-row
      v-for="(approval, index) in approvals"
      :key="approval.name"
      :show-divider="index !== 0"
      :title="approval.name"
      :users="approval.eligibleApprovers.nodes"
      :approvals-required="approval.approvalsRequired"
    />
  </gl-card>
</template>