summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/releases/components/release_block_header.vue
blob: 070865cf84b0414fd8a9bc83fb4dc809b731b8be (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
<script>
import { GlTooltipDirective, GlLink, GlBadge, GlButton, GlIcon } from '@gitlab/ui';
import { setUrlParams } from '~/lib/utils/url_utility';
import { __ } from '~/locale';
import { BACK_URL_PARAM } from '~/releases/constants';

export default {
  i18n: {
    editButton: __('Edit this release'),
    historical: __('Historical release'),
    historicalTooltip: __(
      'This release was created with a date in the past. Evidence collection at the moment of the release is unavailable.',
    ),
  },
  name: 'ReleaseBlockHeader',
  components: {
    GlLink,
    GlBadge,
    GlButton,
    GlIcon,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  props: {
    release: {
      type: Object,
      required: true,
    },
  },
  computed: {
    editLink() {
      if (this.release._links?.editUrl) {
        const queryParams = {
          [BACK_URL_PARAM]: window.location.href,
        };

        return setUrlParams(queryParams, this.release._links.editUrl);
      }

      return undefined;
    },
    selfLink() {
      return this.release._links?.self;
    },
  },
};
</script>

<template>
  <div class="card-header d-flex align-items-center bg-white pr-0">
    <h2 class="card-title my-2 mr-auto">
      <gl-link v-if="selfLink" :href="selfLink" class="font-size-inherit">
        {{ release.name }}
      </gl-link>
      <template v-else>
        {{ release.name }}
        <gl-icon
          v-gl-tooltip
          name="lock"
          :title="
            __(
              'Private - Guest users are not allowed to view detailed release information like title and source code.',
            )
          "
          class="text-secondary gl-mb-2"
        />
      </template>
      <gl-badge v-if="release.upcomingRelease" variant="warning" class="align-middle">{{
        __('Upcoming Release')
      }}</gl-badge>
      <gl-badge
        v-else-if="release.historicalRelease"
        v-gl-tooltip
        :title="$options.i18n.historicalTooltip"
        class="gl-vertical-align-middle"
      >
        {{ $options.i18n.historical }}
      </gl-badge>
    </h2>
    <gl-button
      v-if="editLink"
      v-gl-tooltip
      category="primary"
      variant="default"
      icon="pencil"
      class="gl-mr-3 js-edit-button gl-ml-3 gl-pb-3"
      :title="$options.i18n.editButton"
      :aria-label="$options.i18n.editButton"
      :href="editLink"
    />
  </div>
</template>