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

registry_breadcrumb.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: a1e3c06812cff5d5a83925c35b563ef1963f33b0 (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
<script>
// We are using gl-breadcrumb only at the last child of the handwritten breadcrumb
// until this gitlab-ui issue is resolved: https://gitlab.com/gitlab-org/gitlab-ui/-/issues/1079
//
// See the CSS workaround in app/assets/stylesheets/pages/registry.scss when this file is changed.
import { GlBreadcrumb, GlIcon } from '@gitlab/ui';

export default {
  components: {
    GlBreadcrumb,
    GlIcon,
  },
  computed: {
    rootRoute() {
      return this.$router.options.routes.find((r) => r.meta.root);
    },
    detailsRoute() {
      return this.$router.options.routes.find((r) => r.name === 'details');
    },
    isRootRoute() {
      return this.$route.name === this.rootRoute.name;
    },
    detailsRouteName() {
      return this.detailsRoute.meta.nameGenerator();
    },
    isLoaded() {
      return this.isRootRoute || this.detailsRouteName;
    },
    allCrumbs() {
      const crumbs = [
        {
          text: this.rootRoute.meta.nameGenerator(),
          to: this.rootRoute.path,
        },
      ];
      if (!this.isRootRoute) {
        crumbs.push({
          text: this.detailsRouteName,
          href: this.detailsRoute.meta.path,
        });
      }
      return crumbs;
    },
  },
};
</script>

<template>
  <gl-breadcrumb :key="isLoaded" :items="allCrumbs">
    <template #separator>
      <span class="gl-mx-n5">
        <gl-icon name="angle-right" :size="8" />
      </span>
    </template>
  </gl-breadcrumb>
</template>