debian-mirror-gitlab/app/assets/javascripts/snippets/components/snippet_visibility_edit.vue

84 lines
2.3 KiB
Vue
Raw Normal View History

2020-04-08 14:13:33 +05:30
<script>
import { GlIcon, GlFormGroup, GlFormRadio, GlFormRadioGroup, GlLink } from '@gitlab/ui';
2020-11-24 15:15:51 +05:30
import { SNIPPET_LEVELS_RESTRICTED, SNIPPET_LEVELS_DISABLED } from '~/snippets/constants';
2021-03-11 19:13:27 +05:30
import { defaultSnippetVisibilityLevels } from '../utils/blob';
2020-04-08 14:13:33 +05:30
export default {
components: {
GlIcon,
GlFormGroup,
GlFormRadio,
GlFormRadioGroup,
GlLink,
},
2021-01-29 00:20:46 +05:30
inject: ['visibilityLevels', 'multipleLevelsRestricted'],
2020-04-08 14:13:33 +05:30
props: {
helpLink: {
type: String,
default: '',
required: false,
},
isProjectSnippet: {
type: Boolean,
required: false,
default: false,
},
2020-04-22 19:07:51 +05:30
value: {
2020-04-08 14:13:33 +05:30
type: String,
2020-11-24 15:15:51 +05:30
required: true,
2020-04-08 14:13:33 +05:30
},
},
2021-01-29 00:20:46 +05:30
computed: {
defaultVisibilityLevels() {
return defaultSnippetVisibilityLevels(this.visibilityLevels);
},
2020-04-08 14:13:33 +05:30
},
2020-11-24 15:15:51 +05:30
SNIPPET_LEVELS_DISABLED,
SNIPPET_LEVELS_RESTRICTED,
2020-04-08 14:13:33 +05:30
};
</script>
<template>
<div class="form-group">
<label>
{{ __('Visibility level') }}
<gl-link v-if="helpLink" :href="helpLink" target="_blank"
><gl-icon :size="12" name="question"
/></gl-link>
</label>
2020-11-24 15:15:51 +05:30
<gl-form-group id="visibility-level-setting" class="gl-mb-0">
<gl-form-radio-group :checked="value" stacked v-bind="$attrs" v-on="$listeners">
2020-04-08 14:13:33 +05:30
<gl-form-radio
2021-01-29 00:20:46 +05:30
v-for="option in defaultVisibilityLevels"
2020-04-22 19:07:51 +05:30
:key="option.value"
2020-04-08 14:13:33 +05:30
:value="option.value"
class="mb-3"
>
<div class="d-flex align-items-center">
<gl-icon :size="16" :name="option.icon" />
2021-04-17 20:07:23 +05:30
<span
class="font-weight-bold ml-1 js-visibility-option"
data-qa-selector="visibility_content"
:data-qa-visibility="option.label"
>{{ option.label }}</span
>
2020-04-08 14:13:33 +05:30
</div>
2020-04-22 19:07:51 +05:30
<template #help>{{
isProjectSnippet && option.description_project
? option.description_project
: option.description
}}</template>
2020-04-08 14:13:33 +05:30
</gl-form-radio>
</gl-form-radio-group>
</gl-form-group>
2020-11-24 15:15:51 +05:30
<div class="text-muted" data-testid="restricted-levels-info">
2021-01-29 00:20:46 +05:30
<template v-if="!defaultVisibilityLevels.length">{{
$options.SNIPPET_LEVELS_DISABLED
}}</template>
2020-11-24 15:15:51 +05:30
<template v-else-if="multipleLevelsRestricted">{{
$options.SNIPPET_LEVELS_RESTRICTED
}}</template>
</div>
2020-04-08 14:13:33 +05:30
</div>
</template>