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

issuable_header.vue « components « show « issuable « vue_shared « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a9b5e3a66a859a57bb6437bb639bb250e745ee17 (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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<script>
import { GlIcon, GlBadge, GlButton, GlLink, GlSprintf, GlTooltipDirective } from '@gitlab/ui';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import HiddenBadge from '~/issuable/components/hidden_badge.vue';
import LockedBadge from '~/issuable/components/locked_badge.vue';
import { issuableStatusText, STATUS_OPEN, STATUS_REOPENED } from '~/issues/constants';
import { isExternal } from '~/lib/utils/url_utility';
import { __, n__, sprintf } from '~/locale';
import ConfidentialityBadge from '~/vue_shared/components/confidentiality_badge.vue';
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import WorkItemTypeIcon from '~/work_items/components/work_item_type_icon.vue';

export default {
  components: {
    ConfidentialityBadge,
    GlIcon,
    GlBadge,
    GlButton,
    GlLink,
    GlSprintf,
    HiddenBadge,
    LockedBadge,
    TimeAgoTooltip,
    WorkItemTypeIcon,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  props: {
    createdAt: {
      type: String,
      required: true,
    },
    author: {
      type: Object,
      required: true,
    },
    issuableState: {
      type: String,
      required: false,
      default: '',
    },
    statusIcon: {
      type: String,
      required: false,
      default: '',
    },
    statusIconClass: {
      type: String,
      required: false,
      default: '',
    },
    blocked: {
      type: Boolean,
      required: false,
      default: false,
    },
    confidential: {
      type: Boolean,
      required: false,
      default: false,
    },
    isFirstContribution: {
      type: Boolean,
      required: false,
      default: false,
    },
    isHidden: {
      type: Boolean,
      required: false,
      default: false,
    },
    issuableType: {
      type: String,
      required: false,
      default: '',
    },
    serviceDeskReplyTo: {
      type: String,
      required: false,
      default: '',
    },
    showWorkItemTypeIcon: {
      type: Boolean,
      required: false,
      default: false,
    },
    taskCompletionStatus: {
      type: Object,
      required: false,
      default: null,
    },
    workspaceType: {
      type: String,
      required: false,
      default: '',
    },
  },
  computed: {
    badgeText() {
      return issuableStatusText[this.issuableState];
    },
    badgeVariant() {
      return this.issuableState === STATUS_OPEN || this.issuableState === STATUS_REOPENED
        ? 'success'
        : 'info';
    },
    shouldShowWorkItemTypeIcon() {
      return this.showWorkItemTypeIcon && this.issuableType;
    },
    createdMessage() {
      if (this.serviceDeskReplyTo) {
        return this.shouldShowWorkItemTypeIcon
          ? __('created %{timeAgo} by %{email} via %{author}')
          : __('Created %{timeAgo} by %{email} via %{author}');
      }
      return this.shouldShowWorkItemTypeIcon
        ? __('created %{timeAgo} by %{author}')
        : __('Created %{timeAgo} by %{author}');
    },
    authorId() {
      return getIdFromGraphQLId(`${this.author.id}`);
    },
    isAuthorExternal() {
      return isExternal(this.author.webUrl ?? '');
    },
    taskStatusString() {
      const { count, completedCount } = this.taskCompletionStatus;

      return sprintf(
        n__(
          '%{completedCount} of %{count} checklist item completed',
          '%{completedCount} of %{count} checklist items completed',
          count,
        ),
        { completedCount, count },
      );
    },
    hasTasks() {
      return this.taskCompletionStatus.count > 0;
    },
  },
  mounted() {
    this.toggleSidebarButtonEl = document.querySelector('.js-toggle-right-sidebar-button');
  },
  methods: {
    handleRightSidebarToggleClick() {
      this.$emit('toggle');
      if (this.toggleSidebarButtonEl) {
        this.toggleSidebarButtonEl.dispatchEvent(new Event('click'));
      }
    },
  },
};
</script>

<template>
  <div class="detail-page-header gl-flex-direction-column gl-sm-flex-direction-row">
    <div class="detail-page-header-body gl-flex-wrap gl-gap-2">
      <gl-badge :variant="badgeVariant" data-testid="issue-state-badge">
        <gl-icon v-if="statusIcon" :name="statusIcon" :class="statusIconClass" />
        <span class="gl-display-none gl-sm-display-block" :class="{ 'gl-ml-2': statusIcon }">
          <slot name="status-badge">{{ badgeText }}</slot>
        </span>
      </gl-badge>
      <confidentiality-badge
        v-if="confidential"
        :issuable-type="issuableType"
        :workspace-type="workspaceType"
      />
      <locked-badge v-if="blocked" :issuable-type="issuableType" />
      <hidden-badge v-if="isHidden" :issuable-type="issuableType" />
      <work-item-type-icon
        v-if="shouldShowWorkItemTypeIcon"
        show-text
        :work-item-type="issuableType"
      />
      <gl-sprintf :message="createdMessage">
        <template #timeAgo>
          <time-ago-tooltip :time="createdAt" />
        </template>
        <template #email>
          {{ serviceDeskReplyTo }}
        </template>
        <template #author>
          <gl-link
            class="gl-font-weight-bold js-user-link"
            :href="author.webUrl"
            :data-user-id="authorId"
          >
            <span :class="[{ 'gl-display-none': !isAuthorExternal }, 'gl-sm-display-inline']">
              {{ author.name }}
            </span>
            <gl-icon
              v-if="isAuthorExternal"
              name="external-link"
              :aria-label="__('external link')"
            />
            <strong v-if="author.username" class="author gl-display-inline gl-sm-display-none!"
              >@{{ author.username }}</strong
            >
          </gl-link>
        </template>
      </gl-sprintf>
      <gl-icon
        v-if="isFirstContribution"
        v-gl-tooltip
        name="first-contribution"
        :title="__('1st contribution!')"
        :aria-label="__('1st contribution!')"
      />
      <span
        v-if="taskCompletionStatus && hasTasks"
        class="gl-display-none gl-md-display-block gl-lg-display-inline-block"
        >{{ taskStatusString }}</span
      >
      <gl-button
        icon="chevron-double-lg-left"
        class="gl-ml-auto gl-display-block gl-sm-display-none! js-sidebar-toggle"
        :aria-label="__('Expand sidebar')"
        @click="handleRightSidebarToggleClick"
      />
    </div>
    <div class="detail-page-header-actions gl-display-flex">
      <slot name="header-actions"></slot>
    </div>
  </div>
</template>