summaryrefslogtreecommitdiffstats
path: root/src/components/ConfirmationDialog.vue
blob: d42e8f262174401f709ef7deafa52e61c81cd3d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<template>
	<NcModal class="confirm-modal" @close="cancel">
		<div class="confirm-modal">
			<h2>{{ title }}</h2>
			<slot />
			<div class="confirm-modal__buttons">
				<NcButton type="tertiary" :disabled="disabled" @click="cancel">
					{{ t('contacts', 'Cancel') }}
				</NcButton>
				<NcButton v-if="resolve"
					:disabled="disabled"
					type="primary"
					@click="confirm">
					{{ confirmText }}
				</NcButton>
			</div>
		</div>
	</NcModal>
</template>

<script>
import { NcButton, NcModal } from '@nextcloud/vue'
import { translate as t } from '@nextcloud/l10n'

export default {
	name: 'ConfirmationDialog',
	components: {
		NcButton,
		NcModal,
	},
	props: {
		title: {
			type: String,
			required: true,
		},
		resolve: {
			type: Function,
			required: true,
		},
		reject: {
			type: Function,
			required: true,
		},
		confirmText: {
			type: String,
			default: t('contacts', 'Confirm'),
		},
		disabled: {
			type: Boolean,
			default: undefined,
		},
	},
	methods: {
		confirm() {
			this.resolve()
		},
		cancel() {
			this.reject()
		},
	},
}
</script>

<style lang="scss" scoped>
.confirm-modal {
	padding: 20px;

	&__buttons {
		display: flex;
		justify-content: space-between;
	}
}
</style>