gitlab-org--gitlab-foss/app/assets/javascripts/vue_shared/components/deprecated_modal.vue

147 lines
3.4 KiB
Vue
Raw Normal View History

<script>
2018-10-10 03:06:25 -04:00
/* eslint-disable vue/require-default-prop */
import { __ } from '~/locale';
2018-10-10 03:06:25 -04:00
export default {
name: 'DeprecatedModal', // use GlModal instead
2018-10-10 03:06:25 -04:00
props: {
id: {
type: String,
required: false,
},
2018-10-10 03:06:25 -04:00
title: {
type: String,
required: false,
},
text: {
type: String,
required: false,
},
hideFooter: {
type: Boolean,
required: false,
default: false,
},
kind: {
type: String,
required: false,
default: 'primary',
},
modalDialogClass: {
type: String,
required: false,
default: '',
},
closeKind: {
type: String,
required: false,
default: 'default',
},
closeButtonLabel: {
type: String,
required: false,
default: __('Cancel'),
2018-10-10 03:06:25 -04:00
},
primaryButtonLabel: {
type: String,
required: false,
default: '',
},
secondaryButtonLabel: {
type: String,
required: false,
default: '',
},
submitDisabled: {
type: Boolean,
required: false,
default: false,
},
},
2018-10-10 03:06:25 -04:00
computed: {
btnKindClass() {
return {
[`btn-${this.kind}`]: true,
};
},
btnCancelKindClass() {
return {
[`btn-${this.closeKind}`]: true,
};
2017-08-01 09:41:24 -04:00
},
2018-10-10 03:06:25 -04:00
},
2018-10-10 03:06:25 -04:00
methods: {
emitCancel(event) {
this.$emit('cancel', event);
},
emitSubmit(event) {
this.$emit('submit', event);
2017-08-01 09:41:24 -04:00
},
2018-10-10 03:06:25 -04:00
},
};
</script>
2017-08-15 14:16:42 -04:00
<template>
2018-01-06 13:59:49 -05:00
<div class="modal-open">
2018-11-16 15:07:38 -05:00
<div :id="id" :class="id ? '' : 'd-block'" class="modal" role="dialog" tabindex="-1">
<div :class="modalDialogClass" class="modal-dialog" role="document">
2018-01-06 13:59:49 -05:00
<div class="modal-content">
<div class="modal-header">
<slot name="header">
2018-11-16 15:07:38 -05:00
<h4 class="modal-title float-left">{{ title }}</h4>
2018-01-06 13:59:49 -05:00
<button
type="button"
class="close float-right"
2018-01-06 13:59:49 -05:00
data-dismiss="modal"
:aria-label="__('Close')"
@click="emitCancel($event)"
2018-01-06 13:59:49 -05:00
>
<span aria-hidden="true">&times;</span>
</button>
</slot>
</div>
<div class="modal-body">
2018-11-16 15:07:38 -05:00
<slot :text="text" name="body">
2018-01-08 15:45:34 -05:00
<p>{{ text }}</p>
2018-01-06 13:59:49 -05:00
</slot>
</div>
2018-11-16 15:07:38 -05:00
<div v-if="!hideFooter" class="modal-footer">
<button
2018-06-11 05:49:47 -04:00
:class="btnCancelKindClass"
type="button"
2018-01-09 04:08:28 -05:00
class="btn"
data-dismiss="modal"
@click="emitCancel($event)"
>
2018-01-06 13:59:49 -05:00
{{ closeButtonLabel }}
</button>
2018-11-16 15:07:38 -05:00
<slot v-if="secondaryButtonLabel" name="secondary-button">
<button v-if="secondaryButtonLabel" type="button" class="btn" data-dismiss="modal">
{{ secondaryButtonLabel }}
</button>
</slot>
2018-01-06 13:59:49 -05:00
<button
v-if="primaryButtonLabel"
:disabled="submitDisabled"
:class="btnKindClass"
2018-06-11 05:49:47 -04:00
type="button"
class="btn js-primary-button"
2018-01-06 13:59:49 -05:00
data-dismiss="modal"
data-qa-selector="save_changes_button"
@click="emitSubmit($event)"
2018-01-06 13:59:49 -05:00
>
{{ primaryButtonLabel }}
</button>
</div>
2017-10-31 15:02:11 -04:00
</div>
</div>
</div>
2018-11-16 15:07:38 -05:00
<div v-if="!id" class="modal-backdrop fade show"></div>
</div>
2017-08-01 09:41:24 -04:00
</template>