Commit 8fae18cd authored by Denys Mishunov's avatar Denys Mishunov

Merge branch 'init-jira-connect-state' into 'master'

Add basic state management to Jira Connect Vue app

See merge request gitlab-org/gitlab!48750
parents 4bf9fb98 99defdae
<script>
export default {
name: 'JiraConnectApp',
computed: {
state() {
return this.$root.$data.state || {};
},
error() {
return this.state.error;
},
},
};
</script>
<template> <template>
<div></div> <div></div>
</template> </template>
...@@ -2,6 +2,15 @@ import Vue from 'vue'; ...@@ -2,6 +2,15 @@ import Vue from 'vue';
import $ from 'jquery'; import $ from 'jquery';
import App from './components/app.vue'; import App from './components/app.vue';
const store = {
state: {
error: '',
},
setErrorMessage(errorMessage) {
this.state.error = errorMessage;
},
};
/** /**
* Initialize necessary form handlers for the Jira Connect app * Initialize necessary form handlers for the Jira Connect app
*/ */
...@@ -11,9 +20,11 @@ const initJiraFormHandlers = () => { ...@@ -11,9 +20,11 @@ const initJiraFormHandlers = () => {
}; };
const reqFailed = (res, fallbackErrorMessage) => { const reqFailed = (res, fallbackErrorMessage) => {
const { responseJSON: { error } = {} } = res || {}; const { responseJSON: { error = fallbackErrorMessage } = {} } = res || {};
store.setErrorMessage(error);
// eslint-disable-next-line no-alert // eslint-disable-next-line no-alert
alert(error || fallbackErrorMessage); alert(error);
}; };
AP.getLocation(location => { AP.getLocation(location => {
...@@ -66,6 +77,9 @@ function initJiraConnect() { ...@@ -66,6 +77,9 @@ function initJiraConnect() {
return new Vue({ return new Vue({
el, el,
data: {
state: store.state,
},
render(createElement) { render(createElement) {
return createElement(App, {}); 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