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

76 lines
1.9 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-04-22 19:07:51 +05:30
import {
SNIPPET_VISIBILITY,
SNIPPET_VISIBILITY_PRIVATE,
SNIPPET_VISIBILITY_INTERNAL,
SNIPPET_VISIBILITY_PUBLIC,
} from '~/snippets/constants';
2020-04-08 14:13:33 +05:30
export default {
components: {
GlIcon,
GlFormGroup,
GlFormRadio,
GlFormRadioGroup,
GlLink,
},
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,
required: false,
2020-04-22 19:07:51 +05:30
default: SNIPPET_VISIBILITY_PRIVATE,
2020-04-08 14:13:33 +05:30
},
},
computed: {
visibilityOptions() {
return [
2020-04-22 19:07:51 +05:30
SNIPPET_VISIBILITY_PRIVATE,
SNIPPET_VISIBILITY_INTERNAL,
SNIPPET_VISIBILITY_PUBLIC,
].map(key => ({ value: key, ...SNIPPET_VISIBILITY[key] }));
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>
<gl-form-group id="visibility-level-setting">
2020-04-22 19:07:51 +05:30
<gl-form-radio-group v-bind="$attrs" :checked="value" stacked v-on="$listeners">
2020-04-08 14:13:33 +05:30
<gl-form-radio
v-for="option in visibilityOptions"
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" />
2020-04-22 19:07:51 +05:30
<span class="font-weight-bold ml-1 js-visibility-option">{{ 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>
</div>
</template>