Commit 770b8cf0 authored by Clement Ho's avatar Clement Ho

Merge branch 'jivanvl-correct-boolean-self-monitor-bug' into 'master'

Change the name of a prop for the initial state of self monitor

See merge request gitlab-org/gitlab!23196
parents b46db7b9 2f9b211f
...@@ -4,15 +4,12 @@ import SelfMonitorForm from './components/self_monitor_form.vue'; ...@@ -4,15 +4,12 @@ import SelfMonitorForm from './components/self_monitor_form.vue';
export default () => { export default () => {
const el = document.querySelector('.js-self-monitoring-settings'); const el = document.querySelector('.js-self-monitoring-settings');
let selfMonitorProjectCreated;
if (el) { if (el) {
selfMonitorProjectCreated = el.dataset.selfMonitoringProjectExists;
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new Vue({ new Vue({
el, el,
store: store({ store: store({
projectEnabled: selfMonitorProjectCreated,
...el.dataset, ...el.dataset,
}), }),
render(createElement) { render(createElement) {
......
...@@ -52,7 +52,7 @@ export const requestCreateProjectStatus = ({ dispatch, state }, jobId) => { ...@@ -52,7 +52,7 @@ export const requestCreateProjectStatus = ({ dispatch, state }, jobId) => {
}); });
}; };
export const requestCreateProjectSuccess = ({ commit }, selfMonitorData) => { export const requestCreateProjectSuccess = ({ commit, dispatch }, selfMonitorData) => {
commit(types.SET_LOADING, false); commit(types.SET_LOADING, false);
commit(types.SET_PROJECT_URL, selfMonitorData.project_full_path); commit(types.SET_PROJECT_URL, selfMonitorData.project_full_path);
commit(types.SET_ALERT_CONTENT, { commit(types.SET_ALERT_CONTENT, {
...@@ -62,6 +62,7 @@ export const requestCreateProjectSuccess = ({ commit }, selfMonitorData) => { ...@@ -62,6 +62,7 @@ export const requestCreateProjectSuccess = ({ commit }, selfMonitorData) => {
}); });
commit(types.SET_SHOW_ALERT, true); commit(types.SET_SHOW_ALERT, true);
commit(types.SET_PROJECT_CREATED, true); commit(types.SET_PROJECT_CREATED, true);
dispatch('setSelfMonitor', true);
}; };
export const requestCreateProjectError = ({ commit }, error) => { export const requestCreateProjectError = ({ commit }, error) => {
......
import { parseBoolean } from '~/lib/utils/common_utils'; import { parseBoolean } from '~/lib/utils/common_utils';
export default (initialState = {}) => ({ export default (initialState = {}) => ({
projectEnabled: parseBoolean(initialState.projectEnabled) || false, projectEnabled: parseBoolean(initialState.selfMonitoringProjectExists) || false,
projectCreated: parseBoolean(initialState.selfMonitorProjectCreated) || false, projectCreated: parseBoolean(initialState.selfMonitoringProjectExists) || false,
createProjectEndpoint: initialState.createSelfMonitoringProjectPath || '', createProjectEndpoint: initialState.createSelfMonitoringProjectPath || '',
deleteProjectEndpoint: initialState.deleteSelfMonitoringProjectPath || '', deleteProjectEndpoint: initialState.deleteSelfMonitoringProjectPath || '',
createProjectStatusEndpoint: initialState.statusCreateSelfMonitoringProjectPath || '', createProjectStatusEndpoint: initialState.statusCreateSelfMonitoringProjectPath || '',
......
...@@ -11,7 +11,7 @@ describe('self monitor component', () => { ...@@ -11,7 +11,7 @@ describe('self monitor component', () => {
beforeEach(() => { beforeEach(() => {
store = createStore({ store = createStore({
projectEnabled: false, projectEnabled: false,
selfMonitorProjectCreated: false, selfMonitoringProjectExists: false,
createSelfMonitoringProjectPath: '/create', createSelfMonitoringProjectPath: '/create',
deleteSelfMonitoringProjectPath: '/delete', deleteSelfMonitoringProjectPath: '/delete',
}); });
...@@ -69,7 +69,7 @@ describe('self monitor component', () => { ...@@ -69,7 +69,7 @@ describe('self monitor component', () => {
it('renders the form description with a link', () => { it('renders the form description with a link', () => {
store = createStore({ store = createStore({
projectEnabled: true, projectEnabled: true,
selfMonitorProjectCreated: true, selfMonitoringProjectExists: true,
createSelfMonitoringProjectPath: '/create', createSelfMonitoringProjectPath: '/create',
deleteSelfMonitoringProjectPath: '/delete', deleteSelfMonitoringProjectPath: '/delete',
}); });
......
...@@ -140,7 +140,12 @@ describe('self monitor actions', () => { ...@@ -140,7 +140,12 @@ describe('self monitor actions', () => {
{ type: types.SET_SHOW_ALERT, payload: true }, { type: types.SET_SHOW_ALERT, payload: true },
{ type: types.SET_PROJECT_CREATED, payload: true }, { type: types.SET_PROJECT_CREATED, payload: true },
], ],
[], [
{
payload: true,
type: 'setSelfMonitor',
},
],
done, done,
); );
}); });
......
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