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

image_list_row.vue « list_page « components « explorer « registry « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cd878c3808143bc2dcdaefd9bc14a8dad87af680 (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
<script>
import { GlTooltipDirective, GlButton, GlIcon, GlSprintf } from '@gitlab/ui';
import { n__ } from '~/locale';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';

import {
  ASYNC_DELETE_IMAGE_ERROR_MESSAGE,
  LIST_DELETE_BUTTON_DISABLED,
  REMOVE_REPOSITORY_LABEL,
  ROW_SCHEDULED_FOR_DELETION,
} from '../../constants/index';

export default {
  name: 'ImageListrow',
  components: {
    ClipboardButton,
    GlButton,
    GlSprintf,
    GlIcon,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  props: {
    item: {
      type: Object,
      required: true,
    },
    showTopBorder: {
      type: Boolean,
      default: false,
      required: false,
    },
  },
  i18n: {
    LIST_DELETE_BUTTON_DISABLED,
    REMOVE_REPOSITORY_LABEL,
    ROW_SCHEDULED_FOR_DELETION,
    ASYNC_DELETE_IMAGE_ERROR_MESSAGE,
  },
  computed: {
    encodedItem() {
      const params = JSON.stringify({
        name: this.item.path,
        tags_path: this.item.tags_path,
        id: this.item.id,
      });
      return window.btoa(params);
    },
    disabledDelete() {
      return !this.item.destroy_path || this.item.deleting;
    },
    tagsCountText() {
      return n__(
        'ContainerRegistry|%{count} Tag',
        'ContainerRegistry|%{count} Tags',
        this.item.tags_count,
      );
    },
  },
};
</script>

<template>
  <div
    v-gl-tooltip="{
      placement: 'left',
      disabled: !item.deleting,
      title: $options.i18n.ROW_SCHEDULED_FOR_DELETION,
    }"
  >
    <div
      class="gl-display-flex gl-justify-content-space-between gl-align-items-center gl-py-2 gl-px-1 gl-border-gray-200 gl-border-b-solid gl-border-b-1 gl-py-4 "
      :class="{
        'gl-border-t-solid gl-border-t-1': showTopBorder,
        'disabled-content': item.deleting,
      }"
    >
      <div class="gl-display-flex gl-flex-direction-column">
        <div class="gl-display-flex gl-align-items-center">
          <router-link
            class="gl-text-black-normal gl-font-weight-bold"
            data-testid="detailsLink"
            :to="{ name: 'details', params: { id: encodedItem } }"
          >
            {{ item.path }}
          </router-link>
          <clipboard-button
            v-if="item.location"
            :disabled="item.deleting"
            :text="item.location"
            :title="item.location"
            css-class="btn-default btn-transparent btn-clipboard gl-text-gray-500"
          />
          <gl-icon
            v-if="item.failedDelete"
            v-gl-tooltip
            :title="$options.i18n.ASYNC_DELETE_IMAGE_ERROR_MESSAGE"
            name="warning"
            class="text-warning"
          />
        </div>
        <div class="gl-font-sm gl-text-gray-500">
          <span class="gl-display-flex gl-align-items-center" data-testid="tagsCount">
            <gl-icon name="tag" class="gl-mr-2" />
            <gl-sprintf :message="tagsCountText">
              <template #count>
                {{ item.tags_count }}
              </template>
            </gl-sprintf>
          </span>
        </div>
      </div>
      <div
        v-gl-tooltip="{
          disabled: item.destroy_path,
          title: $options.i18n.LIST_DELETE_BUTTON_DISABLED,
        }"
        class="d-none d-sm-block"
        data-testid="deleteButtonWrapper"
      >
        <gl-button
          v-gl-tooltip
          data-testid="deleteImageButton"
          :disabled="disabledDelete"
          :title="$options.i18n.REMOVE_REPOSITORY_LABEL"
          :aria-label="$options.i18n.REMOVE_REPOSITORY_LABEL"
          category="secondary"
          variant="danger"
          icon="remove"
          @click="$emit('delete', item)"
        />
      </div>
    </div>
  </div>
</template>