debian-mirror-gitlab/app/assets/javascripts/registry/settings/components/expiration_toggle.vue

63 lines
1.4 KiB
Vue
Raw Normal View History

2021-02-22 17:27:13 +05:30
<script>
import { GlFormGroup, GlToggle, GlSprintf } from '@gitlab/ui';
2021-04-17 20:07:23 +05:30
import { s__ } from '~/locale';
2021-02-22 17:27:13 +05:30
import { ENABLED_TOGGLE_DESCRIPTION, DISABLED_TOGGLE_DESCRIPTION } from '../constants';
export default {
2021-04-17 20:07:23 +05:30
i18n: {
toggleLabel: s__('ContainerRegistry|Enable expiration policy'),
},
2021-02-22 17:27:13 +05:30
components: {
GlFormGroup,
GlToggle,
GlSprintf,
},
props: {
disabled: {
type: Boolean,
required: false,
default: false,
},
value: {
type: Boolean,
required: false,
default: false,
},
},
computed: {
enabled: {
get() {
return this.value;
},
set(value) {
this.$emit('input', value);
},
},
toggleText() {
return this.enabled ? ENABLED_TOGGLE_DESCRIPTION : DISABLED_TOGGLE_DESCRIPTION;
},
},
};
</script>
<template>
<gl-form-group id="expiration-policy-toggle-group" label-for="expiration-policy-toggle">
<div class="gl-display-flex">
2021-04-17 20:07:23 +05:30
<gl-toggle
id="expiration-policy-toggle"
v-model="enabled"
:label="$options.i18n.toggleLabel"
label-position="hidden"
:disabled="disabled"
/>
2021-02-22 17:27:13 +05:30
<span class="gl-ml-5 gl-line-height-24" data-testid="description">
<gl-sprintf :message="toggleText">
2021-03-08 18:12:59 +05:30
<template #strong="{ content }">
2021-02-22 17:27:13 +05:30
<strong>{{ content }}</strong>
</template>
</gl-sprintf>
</span>
</div>
</gl-form-group>
</template>