2019-06-06 07:36:45 +00:00
|
|
|
<script>
|
2020-04-03 09:09:31 +00:00
|
|
|
import { GlDeprecatedButton } from '@gitlab/ui';
|
2019-06-06 07:36:45 +00:00
|
|
|
import Icon from './icon.vue';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
Icon,
|
2020-04-03 09:09:31 +00:00
|
|
|
GlDeprecatedButton,
|
2019-06-06 07:36:45 +00:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
size: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
primaryButtonClass: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
dropdownClass: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
actions: {
|
|
|
|
type: Array,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
defaultAction: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
selectedAction: this.defaultAction,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
selectedActionTitle() {
|
|
|
|
return this.actions[this.selectedAction].title;
|
|
|
|
},
|
|
|
|
buttonSizeClass() {
|
|
|
|
return `btn-${this.size}`;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
handlePrimaryActionClick() {
|
|
|
|
this.$emit('onActionClick', this.actions[this.selectedAction]);
|
|
|
|
},
|
|
|
|
handleActionClick(selectedAction) {
|
|
|
|
this.selectedAction = selectedAction;
|
|
|
|
this.$emit('onActionSelect', selectedAction);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="btn-group droplab-dropdown comment-type-dropdown">
|
2020-04-03 09:09:31 +00:00
|
|
|
<gl-deprecated-button
|
|
|
|
:class="primaryButtonClass"
|
|
|
|
:size="size"
|
|
|
|
@click.prevent="handlePrimaryActionClick"
|
|
|
|
>
|
2019-06-06 07:36:45 +00:00
|
|
|
{{ selectedActionTitle }}
|
2020-04-03 09:09:31 +00:00
|
|
|
</gl-deprecated-button>
|
2019-06-06 07:36:45 +00:00
|
|
|
<button
|
|
|
|
:class="buttonSizeClass"
|
|
|
|
type="button"
|
|
|
|
class="btn dropdown-toggle pl-2 pr-2"
|
|
|
|
data-display="static"
|
|
|
|
data-toggle="dropdown"
|
|
|
|
>
|
2020-02-06 15:09:11 +00:00
|
|
|
<icon name="chevron-down" :aria-label="__('toggle dropdown')" />
|
2019-06-06 07:36:45 +00:00
|
|
|
</button>
|
|
|
|
<ul :class="dropdownClass" class="dropdown-menu dropdown-open-top">
|
|
|
|
<template v-for="(action, index) in actions">
|
|
|
|
<li :key="index" :class="{ 'droplab-item-selected': selectedAction === index }">
|
2020-04-03 09:09:31 +00:00
|
|
|
<gl-deprecated-button class="btn-transparent" @click.prevent="handleActionClick(index)">
|
2019-06-06 07:36:45 +00:00
|
|
|
<i aria-hidden="true" class="fa fa-check icon"> </i>
|
|
|
|
<div class="description">
|
|
|
|
<strong>{{ action.title }}</strong>
|
|
|
|
<p>{{ action.description }}</p>
|
|
|
|
</div>
|
2020-04-03 09:09:31 +00:00
|
|
|
</gl-deprecated-button>
|
2019-06-06 07:36:45 +00:00
|
|
|
</li>
|
|
|
|
<li v-if="index === 0" :key="`${index}-separator`" class="divider droplab-item-ignore"></li>
|
|
|
|
</template>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</template>
|