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

65 lines
1.2 KiB
Vue
Raw Normal View History

2018-11-08 19:23:39 +05:30
<script>
2021-11-11 11:23:49 +05:30
import { GlAlert, GlLoadingIcon, GlSafeHtmlDirective } 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,
},
2021-11-11 11:23:49 +05:30
directives: {
SafeHtml: GlSafeHtmlDirective,
},
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"
>
2021-11-11 11:23:49 +05:30
<span v-safe-html="message.text"></span>
2021-09-30 23:02:18 +05:30
<gl-loading-icon v-show="isLoading" size="sm" inline class="vertical-align-middle ml-1" />
2020-03-13 15:44:24 +05:30
</gl-alert>
2018-11-08 19:23:39 +05:30
</template>