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

62 lines
1.1 KiB
Vue
Raw Normal View History

2018-11-08 19:23:39 +05:30
<script>
import { mapActions } from 'vuex';
2020-03-13 15:44:24 +05:30
import { GlAlert, GlLoadingIcon } from '@gitlab/ui';
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>