Commit b16a0701 authored by Justin Ho's avatar Justin Ho Committed by Lukas Eipert

Add Vuex state to integration form

Add state for override and overrideAvailable to disable all
form fields
parent 3a79b4e7
import Vue from 'vue';
import { createStore } from './store';
import { parseBoolean } from '~/lib/utils/common_utils';
import IntegrationForm from './components/integration_form.vue';
......@@ -37,6 +38,7 @@ export default el => {
return new Vue({
el,
store: createStore(),
render(createElement) {
return createElement(IntegrationForm, {
props: {
......
import * as types from './mutation_types';
export const setOverride = ({ commit }, override) => commit(types.SET_OVERRIDE, override);
export const setOverrideAvailable = ({ commit }, overrideAvailable) =>
commit(types.SET_OVERRIDE_AVAILABLE, overrideAvailable);
// eslint-disable-next-line import/prefer-default-export
export const disableForm = state => state.overrideAvailable && !state.override;
import Vue from 'vue';
import Vuex from 'vuex';
import * as actions from './actions';
import * as getters from './getters';
import mutations from './mutations';
import state from './state';
Vue.use(Vuex);
export const createStore = () =>
new Vuex.Store({
actions,
getters,
mutations,
state,
});
export default createStore();
export const SET_OVERRIDE = 'SET_OVERRIDE';
export const SET_OVERRIDE_AVAILABLE = 'SET_OVERRIDE_AVAILABLE';
import * as types from './mutation_types';
export default {
[types.SET_OVERRIDE](state, override) {
state.override = override;
},
[types.SET_OVERRIDE_AVAILABLE](state, overrideAvailable) {
state.overrideAvailable = overrideAvailable;
},
};
export default () => ({
override: false,
overrideAvailable: true, // TODO: Should default to false and be passed from the backend
});
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