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

package_list_row.vue « components « shared « packages « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e000279b7942af6dcbd85c98299c8ea4d6c846fb (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
<script>
import { GlButton, GlIcon, GlLink, GlSprintf, GlTooltipDirective } from '@gitlab/ui';
import PackageTags from './package_tags.vue';
import PublishMethod from './publish_method.vue';
import { getPackageTypeLabel } from '../utils';
import timeagoMixin from '~/vue_shared/mixins/timeago';

export default {
  name: 'PackageListRow',
  components: {
    GlButton,
    GlIcon,
    GlLink,
    GlSprintf,
    PackageTags,
    PublishMethod,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  mixins: [timeagoMixin],
  props: {
    packageEntity: {
      type: Object,
      required: true,
    },
    packageLink: {
      type: String,
      required: true,
    },
    disableDelete: {
      type: Boolean,
      default: false,
      required: false,
    },
    isGroup: {
      type: Boolean,
      default: false,
      required: false,
    },
    showPackageType: {
      type: Boolean,
      default: true,
      required: false,
    },
  },
  computed: {
    packageType() {
      return getPackageTypeLabel(this.packageEntity.package_type);
    },
    hasPipeline() {
      return Boolean(this.packageEntity.pipeline);
    },
    hasProjectLink() {
      return Boolean(this.packageEntity.project_path);
    },
  },
};
</script>

<template>
  <div class="gl-responsive-table-row" data-qa-selector="packages-row">
    <div class="table-section section-50 d-flex flex-md-column justify-content-between flex-wrap">
      <div class="d-flex align-items-center mr-2">
        <gl-link
          :href="packageLink"
          data-qa-selector="package_link"
          class="text-dark font-weight-bold mb-md-1"
        >
          {{ packageEntity.name }}
        </gl-link>

        <package-tags
          v-if="packageEntity.tags && packageEntity.tags.length"
          class="gl-ml-3"
          :tags="packageEntity.tags"
          hide-label
          :tag-display-limit="1"
        />
      </div>

      <div class="d-flex text-secondary text-truncate mt-md-2">
        <span>{{ packageEntity.version }}</span>

        <div v-if="hasPipeline" class="d-none d-md-inline-block ml-1">
          <gl-sprintf :message="s__('PackageRegistry|published by %{author}')">
            <template #author>{{ packageEntity.pipeline.user.name }}</template>
          </gl-sprintf>
        </div>

        <div v-if="hasProjectLink" class="d-flex align-items-center">
          <gl-icon name="review-list" class="text-secondary ml-2 mr-1" />

          <gl-link
            data-testid="packages-row-project"
            :href="`/${packageEntity.project_path}`"
            class="text-secondary"
            >{{ packageEntity.projectPathName }}</gl-link
          >
        </div>

        <div v-if="showPackageType" class="d-flex align-items-center" data-testid="package-type">
          <gl-icon name="package" class="text-secondary ml-2 mr-1" />
          <span>{{ packageType }}</span>
        </div>
      </div>
    </div>

    <div
      class="table-section d-flex flex-md-column justify-content-between align-items-md-end"
      :class="disableDelete ? 'section-50' : 'section-40'"
    >
      <publish-method :package-entity="packageEntity" :is-group="isGroup" />

      <div class="text-secondary order-0 order-md-1 mt-md-2">
        <gl-sprintf :message="__('Created %{timestamp}')">
          <template #timestamp>
            <span v-gl-tooltip :title="tooltipTitle(packageEntity.created_at)">
              {{ timeFormatted(packageEntity.created_at) }}
            </span>
          </template>
        </gl-sprintf>
      </div>
    </div>

    <div v-if="!disableDelete" class="table-section section-10 d-flex justify-content-end">
      <gl-button
        data-testid="action-delete"
        icon="remove"
        category="primary"
        variant="danger"
        :title="s__('PackageRegistry|Remove package')"
        :aria-label="s__('PackageRegistry|Remove package')"
        :disabled="!packageEntity._links.delete_api_path"
        @click="$emit('packageToDelete', packageEntity)"
      />
    </div>
  </div>
</template>