Commit 0c5749fe authored by Martin Wortschack's avatar Martin Wortschack

Merge branch '233938-refactor-admin-integration-variable' into 'master'

Rename admin integration to default integration

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