Commit 351de0d1 authored by Tom Quirk's avatar Tom Quirk

Add basic shared state to jira connect Vue app

parent d53fc7f5
<script>
export default {
name: 'JiraConnectApp',
computed: {
state() {
return this.$root.$data.state || {};
},
error() {
return this.state.error;
},
},
};
</script>
<template>
<div></div>
</template>
......@@ -2,6 +2,15 @@ import Vue from 'vue';
import $ from 'jquery';
import App from './components/app.vue';
const store = {
state: {
error: '',
},
setErrorMessage(errorMessage) {
store.state.error = errorMessage;
},
};
/**
* Initialize necessary form handlers for the Jira Connect app
*/
......@@ -11,9 +20,12 @@ const initJiraFormHandlers = () => {
};
const reqFailed = (res, fallbackErrorMessage) => {
const { responseJSON: { error } = {} } = res || {};
const { responseJSON: { error = fallbackErrorMessage } = {} } = res || {};
store.setErrorMessage(error);
// eslint-disable-next-line no-alert
alert(error || fallbackErrorMessage);
alert(error);
};
AP.getLocation(location => {
......@@ -66,6 +78,9 @@ function initJiraConnect() {
return new Vue({
el,
data: {
state: store.state,
},
render(createElement) {
return createElement(App, {});
},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment