debian-mirror-gitlab/app/assets/javascripts/ide/components/error_message.vue

63 lines
1.2 KiB
Vue
Raw Normal View History

2018-11-08 19:23:39 +05:30
<script>
2020-11-24 15:15:51 +05:30
/* eslint-disable vue/no-v-html */
2020-03-13 15:44:24 +05:30
import { GlAlert, GlLoadingIcon } from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import { mapActions } from 'vuex';
2018-11-08 19:23:39 +05:30
export default {
2018-12-13 13:39:08 +05:30
components: {
2020-03-13 15:44:24 +05:30
GlAlert,
2018-12-13 13:39:08 +05:30
GlLoadingIcon,
},
2018-11-08 19:23:39 +05:30
props: {
message: {
type: Object,
required: true,
},
},
data() {
return {
isLoading: false,
};
},
2020-03-13 15:44:24 +05:30
computed: {
canDismiss() {
return !this.message.action;
},
},
2018-11-08 19:23:39 +05:30
methods: {
...mapActions(['setErrorMessage']),
2020-03-13 15:44:24 +05:30
doAction() {
2018-11-08 19:23:39 +05:30
if (this.isLoading) return;
this.isLoading = true;
this.message
.action(this.message.actionPayload)
.then(() => {
this.isLoading = false;
})
.catch(() => {
this.isLoading = false;
});
},
2020-03-13 15:44:24 +05:30
dismiss() {
this.setErrorMessage(null);
2018-11-08 19:23:39 +05:30
},
},
};
</script>
<template>
2020-03-13 15:44:24 +05:30
<gl-alert
data-qa-selector="flash_alert"
variant="danger"
:dismissible="canDismiss"
:primary-button-text="message.actionText"
@dismiss="dismiss"
@primaryAction="doAction"
>
<span v-html="message.text"></span>
<gl-loading-icon v-show="isLoading" inline class="vertical-align-middle ml-1" />
</gl-alert>
2018-11-08 19:23:39 +05:30
</template>