2020-05-27 12:08:19 +00:00
|
|
|
<script>
|
2020-09-09 09:08:40 +00:00
|
|
|
import TitleArea from '~/vue_shared/components/registry/title_area.vue';
|
2020-09-15 12:09:30 +00:00
|
|
|
import MetadataItem from '~/vue_shared/components/registry/metadata_item.vue';
|
|
|
|
import { n__, sprintf } from '~/locale';
|
2020-05-27 12:08:19 +00:00
|
|
|
import { approximateDuration, calculateRemainingMilliseconds } from '~/lib/utils/datetime_utility';
|
|
|
|
|
|
|
|
import {
|
|
|
|
CONTAINER_REGISTRY_TITLE,
|
|
|
|
LIST_INTRO_TEXT,
|
|
|
|
EXPIRATION_POLICY_WILL_RUN_IN,
|
|
|
|
EXPIRATION_POLICY_DISABLED_TEXT,
|
|
|
|
EXPIRATION_POLICY_DISABLED_MESSAGE,
|
2020-06-04 12:08:21 +00:00
|
|
|
} from '../../constants/index';
|
2020-05-27 12:08:19 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
2020-09-09 09:08:40 +00:00
|
|
|
TitleArea,
|
2020-09-15 12:09:30 +00:00
|
|
|
MetadataItem,
|
2020-05-27 12:08:19 +00:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
expirationPolicy: {
|
|
|
|
type: Object,
|
|
|
|
default: () => ({}),
|
|
|
|
required: false,
|
|
|
|
},
|
|
|
|
imagesCount: {
|
|
|
|
type: Number,
|
|
|
|
default: 0,
|
|
|
|
required: false,
|
|
|
|
},
|
|
|
|
helpPagePath: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
required: false,
|
|
|
|
},
|
|
|
|
expirationPolicyHelpPagePath: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
required: false,
|
|
|
|
},
|
|
|
|
hideExpirationPolicyData: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
loader: {
|
|
|
|
repeat: 10,
|
|
|
|
width: 1000,
|
|
|
|
height: 40,
|
|
|
|
},
|
|
|
|
i18n: {
|
|
|
|
CONTAINER_REGISTRY_TITLE,
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
imagesCountText() {
|
2020-09-15 12:09:30 +00:00
|
|
|
const pluralisedString = n__(
|
2020-05-27 12:08:19 +00:00
|
|
|
'ContainerRegistry|%{count} Image repository',
|
|
|
|
'ContainerRegistry|%{count} Image repositories',
|
|
|
|
this.imagesCount,
|
|
|
|
);
|
2020-09-15 12:09:30 +00:00
|
|
|
return sprintf(pluralisedString, { count: this.imagesCount });
|
2020-05-27 12:08:19 +00:00
|
|
|
},
|
|
|
|
timeTillRun() {
|
|
|
|
const difference = calculateRemainingMilliseconds(this.expirationPolicy?.next_run_at);
|
|
|
|
return approximateDuration(difference / 1000);
|
|
|
|
},
|
|
|
|
expirationPolicyEnabled() {
|
|
|
|
return this.expirationPolicy?.enabled;
|
|
|
|
},
|
|
|
|
expirationPolicyText() {
|
|
|
|
return this.expirationPolicyEnabled
|
2020-09-15 12:09:30 +00:00
|
|
|
? sprintf(EXPIRATION_POLICY_WILL_RUN_IN, { time: this.timeTillRun })
|
2020-05-27 12:08:19 +00:00
|
|
|
: EXPIRATION_POLICY_DISABLED_TEXT;
|
|
|
|
},
|
|
|
|
showExpirationPolicyTip() {
|
|
|
|
return (
|
|
|
|
!this.expirationPolicyEnabled && this.imagesCount > 0 && !this.hideExpirationPolicyData
|
|
|
|
);
|
|
|
|
},
|
2020-09-18 18:10:26 +00:00
|
|
|
infoMessages() {
|
|
|
|
const base = [{ text: LIST_INTRO_TEXT, link: this.helpPagePath }];
|
|
|
|
return this.showExpirationPolicyTip
|
|
|
|
? [
|
|
|
|
...base,
|
|
|
|
{ text: EXPIRATION_POLICY_DISABLED_MESSAGE, link: this.expirationPolicyHelpPagePath },
|
|
|
|
]
|
|
|
|
: base;
|
|
|
|
},
|
2020-05-27 12:08:19 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2020-09-18 18:10:26 +00:00
|
|
|
<title-area :title="$options.i18n.CONTAINER_REGISTRY_TITLE" :info-messages="infoMessages">
|
|
|
|
<template #right-actions>
|
|
|
|
<slot name="commands"></slot>
|
|
|
|
</template>
|
2020-10-08 15:08:17 +00:00
|
|
|
<template #metadata-count>
|
2020-09-18 18:10:26 +00:00
|
|
|
<metadata-item
|
|
|
|
v-if="imagesCount"
|
|
|
|
data-testid="images-count"
|
|
|
|
icon="container-image"
|
|
|
|
:text="imagesCountText"
|
|
|
|
/>
|
|
|
|
</template>
|
2020-10-08 15:08:17 +00:00
|
|
|
<template #metadata-exp-policies>
|
2020-09-18 18:10:26 +00:00
|
|
|
<metadata-item
|
|
|
|
v-if="!hideExpirationPolicyData"
|
|
|
|
data-testid="expiration-policy"
|
|
|
|
icon="expire"
|
|
|
|
:text="expirationPolicyText"
|
|
|
|
size="xl"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
</title-area>
|
2020-05-27 12:08:19 +00:00
|
|
|
</template>
|