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

package_path.vue « components « shared « packages_and_registries « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6fb001e5e92eb8bac851529ea20927848253cf2c (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
<script>
import { GlIcon, GlLink, GlTooltipDirective } from '@gitlab/ui';
import { joinPaths } from '~/lib/utils/url_utility';

export default {
  name: 'PackagePath',
  components: {
    GlIcon,
    GlLink,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  props: {
    path: {
      type: String,
      required: true,
    },
    disabled: {
      type: Boolean,
      required: false,
      default: false,
    },
  },
  computed: {
    pathPieces() {
      return this.path.split('/');
    },
    root() {
      // we skip the first part of the path since is the 'base' group
      return this.pathPieces[1];
    },
    rootLink() {
      return joinPaths(this.pathPieces[0], this.root);
    },
    leaf() {
      return this.pathPieces[this.pathPieces.length - 1];
    },
    deeplyNested() {
      return this.pathPieces.length > 3;
    },
    hasGroup() {
      return this.root !== this.leaf;
    },
  },
};
</script>

<template>
  <div data-qa-selector="package-path" class="gl-display-flex gl-align-items-center">
    <gl-icon data-testid="base-icon" name="project" class="gl-mx-3 gl-min-w-0" />

    <gl-link
      data-testid="root-link"
      class="gl-text-gray-500 gl-min-w-0"
      :href="`/${rootLink}`"
      :disabled="disabled"
    >
      {{ root }}
    </gl-link>

    <template v-if="hasGroup">
      <gl-icon data-testid="root-chevron" name="chevron-right" class="gl-mx-2 gl-min-w-0" />

      <template v-if="deeplyNested">
        <span
          v-gl-tooltip="{ title: path }"
          data-testid="ellipsis-icon"
          class="gl-inset-border-1-gray-200 gl-rounded-base gl-px-2 gl-min-w-0"
        >
          <gl-icon name="ellipsis_h" />
        </span>
        <gl-icon data-testid="ellipsis-chevron" name="chevron-right" class="gl-mx-2 gl-min-w-0" />
      </template>

      <gl-link
        data-testid="leaf-link"
        class="gl-text-gray-500 gl-min-w-0"
        :href="`/${path}`"
        :disabled="disabled"
      >
        {{ leaf }}
      </gl-link>
    </template>
  </div>
</template>