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

delete_branch_button.vue « components « branches « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5a5f49e25e7db375c37dbd3b58f3c4ed63af6d5d (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
<script>
import { GlButton, GlTooltipDirective } from '@gitlab/ui';
import { s__ } from '~/locale';
import eventHub from '../event_hub';

export default {
  name: 'DeleteBranchButton',
  components: { GlButton },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  props: {
    branchName: {
      type: String,
      required: false,
      default: '',
    },
    defaultBranchName: {
      type: String,
      required: false,
      default: '',
    },
    deletePath: {
      type: String,
      required: false,
      default: '',
    },
    tooltip: {
      type: String,
      required: false,
      default: s__('Branches|Delete branch'),
    },
    disabled: {
      type: Boolean,
      required: false,
      default: false,
    },
    isProtectedBranch: {
      type: Boolean,
      required: false,
      default: false,
    },
    merged: {
      type: Boolean,
      required: false,
      default: false,
    },
  },
  computed: {
    variant() {
      if (this.disabled) {
        return 'default';
      }
      return 'danger';
    },
    title() {
      if (this.isProtectedBranch && this.disabled) {
        return s__('Branches|Only a project maintainer or owner can delete a protected branch');
      } else if (this.isProtectedBranch) {
        return s__('Branches|Delete protected branch');
      }
      return this.tooltip;
    },
  },
  methods: {
    openModal() {
      eventHub.$emit('openModal', {
        branchName: this.branchName,
        defaultBranchName: this.defaultBranchName,
        deletePath: this.deletePath,
        isProtectedBranch: this.isProtectedBranch,
        merged: this.merged,
      });
    },
  },
};
</script>

<template>
  <gl-button
    v-gl-tooltip.hover
    icon="remove"
    class="js-delete-branch-button"
    data-qa-selector="delete_branch_button"
    :disabled="disabled"
    :variant="variant"
    :title="title"
    :aria-label="title"
    @click="openModal"
  />
</template>