aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/site/layouts/default.vue29
-rw-r--r--src/site/plugins/notifier.js22
2 files changed, 39 insertions, 12 deletions
diff --git a/src/site/layouts/default.vue b/src/site/layouts/default.vue
index 13a56c0..0049b88 100644
--- a/src/site/layouts/default.vue
+++ b/src/site/layouts/default.vue
@@ -21,19 +21,28 @@ export default {
Navbar,
Footer,
},
- computed: mapState(['config']),
+ computed: mapState(['config', 'alert']),
created() {
- this.$store.watch((state) => state.alert.text, () => {
- const { text, error } = this.$store.state.alert;
+ this.$store.watch((state) => state.alert.message, () => {
+ const { message, type, snackbar } = this.alert;
- if (!text) return;
+ if (!message) return;
- this.$buefy.toast.open({
- duration: 3500,
- message: text,
- position: 'is-bottom',
- type: error ? 'is-danger' : 'is-success',
- });
+ if (snackbar) {
+ this.$buefy.snackbar.open({
+ duration: 3500,
+ position: 'is-bottom',
+ message,
+ type,
+ });
+ } else {
+ this.$buefy.toast.open({
+ duration: 3500,
+ position: 'is-bottom',
+ message,
+ type,
+ });
+ }
this.$store.dispatch('alert/clear', null);
});
diff --git a/src/site/plugins/notifier.js b/src/site/plugins/notifier.js
index f37b96e..4fe1262 100644
--- a/src/site/plugins/notifier.js
+++ b/src/site/plugins/notifier.js
@@ -1,7 +1,25 @@
+import AlertTypes from '~/constants/alertTypes';
+
export default ({ store }, inject) => {
inject('notifier', {
- showMessage({ content = '', type = '' }) {
- store.commit('alert/set', { content, type });
+ showMessage({ message = '', type = '', snackbar = false }) {
+ store.commit('alert/set', { message, type, snackbar });
},
+ message(message, snackbar) {
+ this.showMessage({ message, type: AlertTypes.PRIMARY, snackbar });
+ },
+ info(message, snackbar) {
+ this.showMessage({ message, type: AlertTypes.INFO, snackbar });
+ },
+ warning(message, snackbar) {
+ this.showMessage({ message, type: AlertTypes.WARNING, snackbar });
+ },
+ success(message, snackbar) {
+ this.showMessage({ message, type: AlertTypes.SUCCESS, snackbar });
+ },
+ error(message, snackbar) {
+ this.showMessage({ message, type: AlertTypes.ERROR, snackbar });
+ },
+ types: AlertTypes,
});
};