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

mr_widget_missing_branch.vue « states « components « vue_merge_request_widget « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 214d1b49732664dc304cd7e2aed955ecb3c7d8c5 (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
<script>
import { GlIcon, GlTooltipDirective, GlSprintf } from '@gitlab/ui';
import { sprintf } from '~/locale';
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import mergeRequestQueryVariablesMixin from '../../mixins/merge_request_query_variables';
import missingBranchQuery from '../../queries/states/missing_branch.query.graphql';
import {
  MR_WIDGET_MISSING_BRANCH_WHICH,
  MR_WIDGET_MISSING_BRANCH_RESTORE,
  MR_WIDGET_MISSING_BRANCH_MANUALCLI,
} from '../../i18n';
import StatusIcon from '../mr_widget_status_icon.vue';

export default {
  name: 'MRWidgetMissingBranch',
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  components: {
    GlIcon,
    GlSprintf,
    StatusIcon,
  },
  mixins: [glFeatureFlagMixin(), mergeRequestQueryVariablesMixin],
  apollo: {
    state: {
      query: missingBranchQuery,
      skip() {
        return !this.glFeatures.mergeRequestWidgetGraphql;
      },
      variables() {
        return this.mergeRequestQueryVariables;
      },
      update: (data) => data.project.mergeRequest,
    },
  },
  props: {
    mr: {
      type: Object,
      required: true,
    },
  },
  data() {
    return { state: {} };
  },
  computed: {
    sourceBranchRemoved() {
      if (this.glFeatures.mergeRequestWidgetGraphql) {
        return !this.state.sourceBranchExists;
      }

      return this.mr.sourceBranchRemoved;
    },
    type() {
      return this.sourceBranchRemoved ? 'source' : 'target';
    },
    name() {
      return this.type === 'source' ? this.mr.sourceBranch : this.mr.targetBranch;
    },
    warning() {
      return sprintf(MR_WIDGET_MISSING_BRANCH_WHICH, { type: this.type, name: this.name });
    },
    restore() {
      return sprintf(MR_WIDGET_MISSING_BRANCH_RESTORE, { type: this.type });
    },
    message() {
      return sprintf(MR_WIDGET_MISSING_BRANCH_MANUALCLI, { type: this.type });
    },
  },
};
</script>
<template>
  <div class="mr-widget-body media">
    <status-icon :show-disabled-button="true" status="failed" />

    <div class="media-body space-children">
      <span class="gl-font-weight-bold js-branch-text" data-testid="widget-content">
        <gl-sprintf :message="warning">
          <template #code="{ content }">
            <code>{{ content }}</code>
          </template>
        </gl-sprintf>
        {{ restore }}
        <gl-icon
          v-gl-tooltip
          :title="message"
          :aria-label="message"
          name="question-o"
          class="gl-text-blue-600 gl-cursor-pointer"
        />
      </span>
    </div>
  </div>
</template>