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

pipeline_schedule_actions.vue « cells « table « components « pipeline_schedules « ci « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a56da06f5dab4504a69f9b50df426b8cb33c8787 (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
<script>
import { GlButton, GlButtonGroup, GlTooltipDirective as GlTooltip } from '@gitlab/ui';
import { s__ } from '~/locale';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';

export const i18n = {
  playTooltip: s__('PipelineSchedules|Run pipeline schedule'),
  editTooltip: s__('PipelineSchedules|Edit pipeline schedule'),
  deleteTooltip: s__('PipelineSchedules|Delete pipeline schedule'),
  takeOwnershipTooltip: s__('PipelineSchedules|Take ownership of pipeline schedule'),
};

export default {
  i18n,
  components: {
    GlButton,
    GlButtonGroup,
  },
  directives: {
    GlTooltip,
  },
  props: {
    schedule: {
      type: Object,
      required: true,
    },
    currentUser: {
      type: Object,
      required: true,
    },
  },
  computed: {
    canPlay() {
      return this.schedule.userPermissions.playPipelineSchedule;
    },
    isCurrentUserOwner() {
      return this.schedule.owner.username === this.currentUser.username;
    },
    canTakeOwnership() {
      return !this.isCurrentUserOwner && this.schedule.userPermissions.adminPipelineSchedule;
    },
    canUpdate() {
      return this.schedule.userPermissions.updatePipelineSchedule;
    },
    canRemove() {
      return this.schedule.userPermissions.adminPipelineSchedule;
    },
    editPathWithIdParam() {
      const id = getIdFromGraphQLId(this.schedule.id);

      return `${this.schedule.editPath}?id=${id}`;
    },
  },
};
</script>

<template>
  <div class="gl-display-flex gl-justify-content-end">
    <gl-button-group>
      <gl-button
        v-if="canPlay"
        v-gl-tooltip
        :title="$options.i18n.playTooltip"
        icon="play"
        data-testid="play-pipeline-schedule-btn"
        @click="$emit('playPipelineSchedule', schedule.id)"
      />
      <gl-button
        v-if="canTakeOwnership"
        v-gl-tooltip
        :title="$options.i18n.takeOwnershipTooltip"
        icon="user"
        data-testid="take-ownership-pipeline-schedule-btn"
        @click="$emit('showTakeOwnershipModal', schedule.id)"
      />
      <gl-button
        v-if="canUpdate"
        v-gl-tooltip
        :href="editPathWithIdParam"
        :title="$options.i18n.editTooltip"
        icon="pencil"
        data-testid="edit-pipeline-schedule-btn"
      />
      <gl-button
        v-if="canRemove"
        v-gl-tooltip
        :title="$options.i18n.deleteTooltip"
        icon="remove"
        variant="danger"
        data-testid="delete-pipeline-schedule-btn"
        @click="$emit('showDeleteModal', schedule.id)"
      />
    </gl-button-group>
  </div>
</template>