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

ambiguous_ref_modal.vue « components « ref « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d17144669feee699c8f4d2ca84bb9a3bca7b8a70 (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
<!-- eslint-disable vue/multi-word-component-names -->
<script>
import { GlModal, GlButton, GlSprintf } from '@gitlab/ui';
import { sprintf, s__ } from '~/locale';
import { visitUrl } from '~/lib/utils/url_utility';
import { REF_TYPE_PARAM_NAME, TAG_REF_TYPE, BRANCH_REF_TYPE } from '../constants';

export default {
  i18n: {
    title: s__('AmbiguousRef|Which reference do you want to view?'),
    description: sprintf(
      s__('AmbiguousRef|There is a branch and a tag with the same name of %{ref}.'),
    ),
    secondaryDescription: s__('AmbiguousRef|Which reference would you like to view?'),
    viewTagButton: s__('AmbiguousRef|View tag'),
    viewBranchButton: s__('AmbiguousRef|View branch'),
  },
  tagRefType: TAG_REF_TYPE,
  branchRefType: BRANCH_REF_TYPE,
  components: {
    GlModal,
    GlButton,
    GlSprintf,
  },

  props: {
    refName: {
      type: String,
      required: true,
    },
  },
  mounted() {
    this.$refs.ambiguousRefModal.show();
  },
  methods: {
    navigate(refType) {
      const url = new URL(window.location.href);
      url.searchParams.set(REF_TYPE_PARAM_NAME, refType);

      visitUrl(url.toString());
    },
  },
};
</script>

<template>
  <gl-modal
    ref="ambiguousRefModal"
    modal-id="ambiguous-ref"
    :title="$options.i18n.title"
    @primary="navigate"
  >
    <p class="gl-mb-0">
      <gl-sprintf :message="$options.i18n.description">
        <template #ref
          ><code>{{ refName }}</code></template
        >
      </gl-sprintf>
    </p>

    <p>
      {{ $options.i18n.secondaryDescription }}
    </p>

    <template #modal-footer>
      <gl-button
        category="secondary"
        variant="confirm"
        @click="() => navigate($options.tagRefType)"
        >{{ $options.i18n.viewTagButton }}</gl-button
      >
      <gl-button
        category="secondary"
        variant="confirm"
        @click="() => navigate($options.branchRefType)"
        >{{ $options.i18n.viewBranchButton }}</gl-button
      >
    </template>
  </gl-modal>
</template>