debian-mirror-gitlab/app/assets/javascripts/design_management/components/delete_button.vue
2020-11-24 15:15:51 +05:30

104 lines
2.2 KiB
Vue

<script>
import { GlButton, GlModal, GlModalDirective } from '@gitlab/ui';
import { uniqueId } from 'lodash';
import { s__, __ } from '~/locale';
export default {
name: 'DeleteButton',
components: {
GlButton,
GlModal,
},
directives: {
GlModalDirective,
},
props: {
isDeleting: {
type: Boolean,
required: false,
default: false,
},
buttonClass: {
type: String,
required: false,
default: '',
},
buttonVariant: {
type: String,
required: false,
default: 'info',
},
buttonCategory: {
type: String,
required: false,
default: 'primary',
},
buttonIcon: {
type: String,
required: false,
default: undefined,
},
buttonSize: {
type: String,
required: false,
default: 'medium',
},
hasSelectedDesigns: {
type: Boolean,
required: false,
default: true,
},
loading: {
type: Boolean,
required: false,
default: false,
},
},
data() {
return {
modalId: uniqueId('design-deletion-confirmation-'),
};
},
modal: {
title: s__('DesignManagement|Are you sure you want to archive the selected designs?'),
actionPrimary: {
text: s__('DesignManagement|Archive designs'),
attributes: { variant: 'warning' },
},
actionCancel: {
text: __('Cancel'),
},
},
};
</script>
<template>
<div class="gl-display-flex gl-align-items-center gl-h-full">
<gl-modal
:modal-id="modalId"
:title="$options.modal.title"
:action-primary="$options.modal.actionPrimary"
:action-cancel="$options.modal.actionCancel"
@ok="$emit('deleteSelectedDesigns')"
>
<p>
{{
s__(
'DesignManagement|Archived designs will still be available in previous versions of the design collection.',
)
}}
</p>
</gl-modal>
<gl-button
v-gl-modal-directive="modalId"
:variant="buttonVariant"
:category="buttonCategory"
:size="buttonSize"
:class="buttonClass"
:loading="loading"
:icon="buttonIcon"
:disabled="isDeleting || !hasSelectedDesigns"
><slot></slot
></gl-button>
</div>
</template>