2018-11-08 19:23:39 +05:30
|
|
|
<script>
|
|
|
|
import { mapActions } from 'vuex';
|
2019-02-15 15:39:39 +05:30
|
|
|
import { GlLoadingIcon } from '@gitlab/ui';
|
2018-11-08 19:23:39 +05:30
|
|
|
|
|
|
|
export default {
|
2018-12-13 13:39:08 +05:30
|
|
|
components: {
|
|
|
|
GlLoadingIcon,
|
|
|
|
},
|
2018-11-08 19:23:39 +05:30
|
|
|
props: {
|
|
|
|
message: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isLoading: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
...mapActions(['setErrorMessage']),
|
|
|
|
clickAction() {
|
|
|
|
if (this.isLoading) return;
|
|
|
|
|
|
|
|
this.isLoading = true;
|
|
|
|
|
|
|
|
this.message
|
|
|
|
.action(this.message.actionPayload)
|
|
|
|
.then(() => {
|
|
|
|
this.isLoading = false;
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
this.isLoading = false;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
clickFlash() {
|
|
|
|
if (!this.message.action) {
|
|
|
|
this.setErrorMessage(null);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2019-02-15 15:39:39 +05:30
|
|
|
<div class="flash-container flash-container-page" @click="clickFlash">
|
2019-12-04 20:38:33 +05:30
|
|
|
<div class="flash-alert" data-qa-selector="flash_alert">
|
2019-02-15 15:39:39 +05:30
|
|
|
<span v-html="message.text"> </span>
|
2018-11-08 19:23:39 +05:30
|
|
|
<button
|
|
|
|
v-if="message.action"
|
|
|
|
type="button"
|
|
|
|
class="flash-action text-white p-0 border-top-0 border-right-0 border-left-0 bg-transparent"
|
|
|
|
@click.stop.prevent="clickAction"
|
|
|
|
>
|
|
|
|
{{ message.actionText }}
|
2019-02-15 15:39:39 +05:30
|
|
|
<gl-loading-icon v-show="isLoading" inline />
|
2018-11-08 19:23:39 +05:30
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|