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

cleanup_status.vue « list_page « components « explorer « container_registry « 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: ce221a274c97909705256fb4b5a1da05ec248c3e (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
<script>
import { uniqueId } from 'lodash';
import { GlIcon, GlPopover, GlLink, GlSprintf } from '@gitlab/ui';
import { helpPagePath } from '~/helpers/help_page_helper';
import { timeTilRun } from '../../utils';
import {
  PARTIAL_CLEANUP_CONTINUE_MESSAGE,
  CLEANUP_STATUS_SCHEDULED,
  CLEANUP_STATUS_ONGOING,
  CLEANUP_STATUS_UNFINISHED,
  UNFINISHED_STATUS,
  UNSCHEDULED_STATUS,
  SCHEDULED_STATUS,
  ONGOING_STATUS,
} from '../../constants/index';

export default {
  name: 'CleanupStatus',
  components: {
    GlIcon,
    GlPopover,
    GlLink,
    GlSprintf,
  },
  props: {
    status: {
      type: String,
      required: true,
      validator(value) {
        return [UNFINISHED_STATUS, UNSCHEDULED_STATUS, SCHEDULED_STATUS, ONGOING_STATUS].includes(
          value,
        );
      },
    },
    expirationPolicy: {
      type: Object,
      default: () => ({}),
      required: false,
    },
  },
  i18n: {
    CLEANUP_STATUS_SCHEDULED,
    CLEANUP_STATUS_ONGOING,
    CLEANUP_STATUS_UNFINISHED,
    PARTIAL_CLEANUP_CONTINUE_MESSAGE,
  },
  data() {
    return {
      iconId: uniqueId('status-info-'),
    };
  },
  computed: {
    showStatus() {
      return this.status !== UNSCHEDULED_STATUS;
    },
    failedDelete() {
      return this.status === UNFINISHED_STATUS;
    },
    statusText() {
      return this.$options.i18n[`CLEANUP_STATUS_${this.status}`];
    },
    calculatedTimeTilNextRun() {
      return timeTilRun(this.expirationPolicy?.next_run_at);
    },
    expireIconName() {
      return this.failedDelete ? 'expire' : 'clock';
    },
  },
  statusPopoverOptions: {
    triggers: 'hover',
    placement: 'top',
  },
  cleanupPolicyHelpPage: helpPagePath(
    'user/packages/container_registry/reduce_container_registry_storage.html',
    { anchor: 'how-the-cleanup-policy-works' },
  ),
};
</script>

<template>
  <div
    v-if="showStatus"
    id="status-popover-container"
    class="gl-display-inline-flex gl-align-items-center"
  >
    <div class="gl-display-inline-flex gl-align-items-center">
      <gl-icon :name="expireIconName" data-testid="main-icon" />
    </div>
    <span class="gl-mx-2">
      {{ statusText }}
    </span>
    <gl-icon
      v-if="failedDelete && calculatedTimeTilNextRun"
      :id="iconId"
      :size="16"
      class="gl-text-gray-500"
      data-testid="extra-info"
      name="information-o"
    />
    <gl-popover
      :target="iconId"
      container="status-popover-container"
      v-bind="$options.statusPopoverOptions"
    >
      <template #title>
        {{ $options.i18n.CLEANUP_STATUS_UNFINISHED }}
      </template>
      <gl-sprintf :message="$options.i18n.PARTIAL_CLEANUP_CONTINUE_MESSAGE">
        <template #time>{{ calculatedTimeTilNextRun }}</template
        ><template #link="{ content }"
          ><gl-link :href="$options.cleanupPolicyHelpPage" class="gl-font-sm" target="_blank">{{
            content
          }}</gl-link></template
        >
      </gl-sprintf>
    </gl-popover>
  </div>
</template>