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