Commit 62f34905 authored by Justin Ho Tuan Duong's avatar Justin Ho Tuan Duong Committed by Martin Wortschack

Rename admin integration to default integration

In controllers / backend
parent ed8236e5
...@@ -25,7 +25,7 @@ export default { ...@@ -25,7 +25,7 @@ export default {
mixins: [glFeatureFlagsMixin()], mixins: [glFeatureFlagsMixin()],
computed: { computed: {
...mapGetters(['currentKey', 'propsSource', 'isSavingOrTesting']), ...mapGetters(['currentKey', 'propsSource', 'isSavingOrTesting']),
...mapState(['adminState', 'override', 'isSaving', 'isTesting']), ...mapState(['defaultState', 'override', 'isSaving', 'isTesting']),
isEditable() { isEditable() {
return this.propsSource.editable; return this.propsSource.editable;
}, },
...@@ -53,8 +53,8 @@ export default { ...@@ -53,8 +53,8 @@ export default {
<template> <template>
<div> <div>
<override-dropdown <override-dropdown
v-if="adminState !== null" v-if="defaultState !== null"
:inherit-from-id="adminState.id" :inherit-from-id="defaultState.id"
:override="override" :override="override"
:learn-more-path="propsSource.learnMorePath" :learn-more-path="propsSource.learnMorePath"
@change="setOverride" @change="setOverride"
......
...@@ -44,9 +44,9 @@ export default { ...@@ -44,9 +44,9 @@ export default {
}; };
}, },
computed: { computed: {
...mapState(['adminState']), ...mapState(['defaultState']),
description() { description() {
const level = this.adminState.integrationLevel; const level = this.defaultState.integrationLevel;
return ( return (
overrideDropdownDescriptions[level] || overrideDropdownDescriptions[defaultIntegrationLevel] overrideDropdownDescriptions[level] || overrideDropdownDescriptions[defaultIntegrationLevel]
......
...@@ -72,7 +72,7 @@ function parseDatasetToProps(data) { ...@@ -72,7 +72,7 @@ function parseDatasetToProps(data) {
}; };
} }
export default (el, adminEl) => { export default (el, defaultEl) => {
if (!el) { if (!el) {
return null; return null;
} }
...@@ -80,12 +80,12 @@ export default (el, adminEl) => { ...@@ -80,12 +80,12 @@ export default (el, adminEl) => {
const props = parseDatasetToProps(el.dataset); const props = parseDatasetToProps(el.dataset);
const initialState = { const initialState = {
adminState: null, defaultState: null,
customState: props, customState: props,
}; };
if (adminEl) { if (defaultEl) {
initialState.adminState = Object.freeze(parseDatasetToProps(adminEl.dataset)); initialState.defaultState = Object.freeze(parseDatasetToProps(defaultEl.dataset));
} }
return new Vue({ return new Vue({
......
export const isInheriting = state => (state.adminState === null ? false : !state.override); export const isInheriting = state => (state.defaultState === null ? false : !state.override);
export const isSavingOrTesting = state => state.isSaving || state.isTesting; export const isSavingOrTesting = state => state.isSaving || state.isTesting;
export const propsSource = (state, getters) => export const propsSource = (state, getters) =>
getters.isInheriting ? state.adminState : state.customState; getters.isInheriting ? state.defaultState : state.customState;
export const currentKey = (state, getters) => (getters.isInheriting ? 'admin' : 'custom'); export const currentKey = (state, getters) => (getters.isInheriting ? 'admin' : 'custom');
export default ({ adminState = null, customState = {} } = {}) => { export default ({ defaultState = null, customState = {} } = {}) => {
const override = adminState !== null ? adminState.id !== customState.inheritFromId : false; const override = defaultState !== null ? defaultState.id !== customState.inheritFromId : false;
return { return {
override, override,
adminState, defaultState,
customState, customState,
isSaving: false, isSaving: false,
isTesting: false, isTesting: false,
......
...@@ -20,7 +20,7 @@ export default class IntegrationSettingsForm { ...@@ -20,7 +20,7 @@ export default class IntegrationSettingsForm {
// Init Vue component // Init Vue component
this.vue = initForm( this.vue = initForm(
document.querySelector('.js-vue-integration-settings'), document.querySelector('.js-vue-integration-settings'),
document.querySelector('.js-vue-admin-integration-settings'), document.querySelector('.js-vue-default-integration-settings'),
); );
eventHub.$on('toggle', active => { eventHub.$on('toggle', active => {
this.formActive = active; this.formActive = active;
......
...@@ -12,7 +12,7 @@ module Groups ...@@ -12,7 +12,7 @@ module Groups
end end
def edit def edit
@admin_integration = Service.default_integration(integration.type, group) @default_integration = Service.default_integration(integration.type, group)
super super
end end
......
...@@ -20,7 +20,7 @@ class Projects::ServicesController < Projects::ApplicationController ...@@ -20,7 +20,7 @@ class Projects::ServicesController < Projects::ApplicationController
layout "project_settings" layout "project_settings"
def edit def edit
@admin_integration = Service.default_integration(service.type, project) @default_integration = Service.default_integration(service.type, project)
end end
def update def update
......
...@@ -8,6 +8,6 @@ ...@@ -8,6 +8,6 @@
= markdown integration.help = markdown integration.help
.service-settings .service-settings
- if @admin_integration - if @default_integration
.js-vue-admin-integration-settings{ data: integration_form_data(@admin_integration) } .js-vue-default-integration-settings{ data: integration_form_data(@default_integration) }
.js-vue-integration-settings{ data: integration_form_data(integration) } .js-vue-integration-settings{ data: integration_form_data(integration) }
...@@ -137,13 +137,13 @@ describe('IntegrationForm', () => { ...@@ -137,13 +137,13 @@ describe('IntegrationForm', () => {
}); });
}); });
describe('adminState state is null', () => { describe('defaultState state is null', () => {
it('does not render OverrideDropdown', () => { it('does not render OverrideDropdown', () => {
createComponent( createComponent(
{}, {},
{}, {},
{ {
adminState: null, defaultState: null,
}, },
); );
...@@ -151,13 +151,13 @@ describe('IntegrationForm', () => { ...@@ -151,13 +151,13 @@ describe('IntegrationForm', () => {
}); });
}); });
describe('adminState state is an object', () => { describe('defaultState state is an object', () => {
it('renders OverrideDropdown', () => { it('renders OverrideDropdown', () => {
createComponent( createComponent(
{}, {},
{}, {},
{ {
adminState: { defaultState: {
...mockIntegrationProps, ...mockIntegrationProps,
}, },
}, },
......
...@@ -13,15 +13,15 @@ describe('OverrideDropdown', () => { ...@@ -13,15 +13,15 @@ describe('OverrideDropdown', () => {
override: true, override: true,
}; };
const defaultAdminStateProps = { const defaultDefaultStateProps = {
integrationLevel: 'group', integrationLevel: 'group',
}; };
const createComponent = (props = {}, adminStateProps = {}) => { const createComponent = (props = {}, defaultStateProps = {}) => {
wrapper = shallowMount(OverrideDropdown, { wrapper = shallowMount(OverrideDropdown, {
propsData: { ...defaultProps, ...props }, propsData: { ...defaultProps, ...props },
store: createStore({ store: createStore({
adminState: { ...defaultAdminStateProps, ...adminStateProps }, defaultState: { ...defaultDefaultStateProps, ...defaultStateProps },
}), }),
}); });
}; };
......
...@@ -5,22 +5,22 @@ import { mockIntegrationProps } from '../mock_data'; ...@@ -5,22 +5,22 @@ import { mockIntegrationProps } from '../mock_data';
describe('Integration form store getters', () => { describe('Integration form store getters', () => {
let state; let state;
const customState = { ...mockIntegrationProps, type: 'CustomState' }; const customState = { ...mockIntegrationProps, type: 'CustomState' };
const adminState = { ...mockIntegrationProps, type: 'AdminState' }; const defaultState = { ...mockIntegrationProps, type: 'DefaultState' };
beforeEach(() => { beforeEach(() => {
state = createState({ customState }); state = createState({ customState });
}); });
describe('isInheriting', () => { describe('isInheriting', () => {
describe('when adminState is null', () => { describe('when defaultState is null', () => {
it('returns false', () => { it('returns false', () => {
expect(isInheriting(state)).toBe(false); expect(isInheriting(state)).toBe(false);
}); });
}); });
describe('when adminState is an object', () => { describe('when defaultState is an object', () => {
beforeEach(() => { beforeEach(() => {
state.adminState = adminState; state.defaultState = defaultState;
}); });
describe('when override is false', () => { describe('when override is false', () => {
...@@ -47,11 +47,11 @@ describe('Integration form store getters', () => { ...@@ -47,11 +47,11 @@ describe('Integration form store getters', () => {
describe('propsSource', () => { describe('propsSource', () => {
beforeEach(() => { beforeEach(() => {
state.adminState = adminState; state.defaultState = defaultState;
}); });
it('equals adminState if inheriting', () => { it('equals defaultState if inheriting', () => {
expect(propsSource(state, { isInheriting: true })).toEqual(adminState); expect(propsSource(state, { isInheriting: true })).toEqual(defaultState);
}); });
it('equals customState if not inheriting', () => { it('equals customState if not inheriting', () => {
......
...@@ -3,7 +3,7 @@ import createState from '~/integrations/edit/store/state'; ...@@ -3,7 +3,7 @@ import createState from '~/integrations/edit/store/state';
describe('Integration form state factory', () => { describe('Integration form state factory', () => {
it('states default to null', () => { it('states default to null', () => {
expect(createState()).toEqual({ expect(createState()).toEqual({
adminState: null, defaultState: null,
customState: {}, customState: {},
isSaving: false, isSaving: false,
isTesting: false, isTesting: false,
...@@ -19,9 +19,9 @@ describe('Integration form state factory', () => { ...@@ -19,9 +19,9 @@ describe('Integration form state factory', () => {
[null, { inheritFromId: null }, false], [null, { inheritFromId: null }, false],
[null, { inheritFromId: 25 }, false], [null, { inheritFromId: 25 }, false],
])( ])(
'for adminState: %p, customState: %p: override = `%p`', 'for defaultState: %p, customState: %p: override = `%p`',
(adminState, customState, expected) => { (defaultState, customState, expected) => {
expect(createState({ adminState, customState }).override).toEqual(expected); expect(createState({ defaultState, customState }).override).toEqual(expected);
}, },
); );
}); });
......
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