Commit 801bd579 authored by Justin Ho's avatar Justin Ho Committed by Lukas Eipert

Pass overrideAvailable from backend to frontend

- Using the value of inherit_from_id to determine
value of overrideAvailable. This approach might change in
the future if we discuss with backend and the way this work
changes.
- Add store to Jest specs
- Update translations file and changelog
parent a3336953
<script> <script>
import { __ } from '~/locale'; import { s__ } from '~/locale';
import { mapState } from 'vuex'; import { mapState } from 'vuex';
import { GlNewDropdown, GlNewDropdownItem } from '@gitlab/ui'; import { GlNewDropdown, GlNewDropdownItem } from '@gitlab/ui';
const options = [ const options = [
{ {
value: 'instance', value: 'instance',
text: __('Use instance level settings'), text: s__('Integrations|Use instance level settings'),
}, },
{ {
value: 'project', value: 'project',
text: __('Use custom settings'), text: s__('Integrations|Use custom settings'),
}, },
]; ];
...@@ -46,7 +46,7 @@ export default { ...@@ -46,7 +46,7 @@ export default {
<div <div
class="gl-display-flex gl-justify-content-space-between gl-align-items-baseline gl-py-4 gl-mt-5 gl-mb-6 gl-border-t-1 gl-border-t-solid gl-border-b-1 gl-border-b-solid gl-border-gray-100" class="gl-display-flex gl-justify-content-space-between gl-align-items-baseline gl-py-4 gl-mt-5 gl-mb-6 gl-border-t-1 gl-border-t-solid gl-border-b-1 gl-border-b-solid gl-border-gray-100"
> >
<span>{{ __('This integration has multiple settings available.') }}</span> <span>{{ s__('Integrations|This integration has multiple settings available.') }}</span>
<gl-new-dropdown :text="selected.text"> <gl-new-dropdown :text="selected.text">
<gl-new-dropdown-item v-for="option in options" :key="option.value" @click="onClick(option)"> <gl-new-dropdown-item v-for="option in options" :key="option.value" @click="onClick(option)">
{{ option.text }} {{ option.text }}
......
import Vue from 'vue'; import Vue from 'vue';
import { isEmpty } from 'lodash';
import { createStore } from './store'; import { createStore } from './store';
import { parseBoolean } from '~/lib/utils/common_utils'; import { parseBoolean } from '~/lib/utils/common_utils';
import IntegrationForm from './components/integration_form.vue'; import IntegrationForm from './components/integration_form.vue';
...@@ -24,6 +25,7 @@ export default el => { ...@@ -24,6 +25,7 @@ export default el => {
editProjectPath, editProjectPath,
triggerEvents, triggerEvents,
fields, fields,
inheritFromId,
...booleanAttributes ...booleanAttributes
} = el.dataset; } = el.dataset;
const { const {
...@@ -36,9 +38,13 @@ export default el => { ...@@ -36,9 +38,13 @@ export default el => {
enableJiraIssues, enableJiraIssues,
} = parseBooleanInData(booleanAttributes); } = parseBooleanInData(booleanAttributes);
const initialState = {
overrideAvailable: !isEmpty(inheritFromId),
};
return new Vue({ return new Vue({
el, el,
store: createStore(), store: createStore(initialState),
render(createElement) { render(createElement) {
return createElement(IntegrationForm, { return createElement(IntegrationForm, {
props: { props: {
......
...@@ -3,15 +3,16 @@ import Vuex from 'vuex'; ...@@ -3,15 +3,16 @@ import Vuex from 'vuex';
import * as actions from './actions'; import * as actions from './actions';
import * as getters from './getters'; import * as getters from './getters';
import mutations from './mutations'; import mutations from './mutations';
import state from './state'; import createState from './state';
Vue.use(Vuex); Vue.use(Vuex);
export const createStore = () => export const createStore = (initialState = {}) =>
new Vuex.Store({ new Vuex.Store({
actions, actions,
getters, getters,
mutations, mutations,
state, state: createState(initialState),
}); });
export default createStore(); export default createStore();
export default () => ({ export default ({ overrideAvailable = false }) => ({
override: false, override: false,
overrideAvailable: true, // TODO: Should default to false and be passed from the backend overrideAvailable,
}); });
...@@ -109,7 +109,8 @@ module ServicesHelper ...@@ -109,7 +109,8 @@ module ServicesHelper
enable_comments: integration.comment_on_event_enabled.to_s, enable_comments: integration.comment_on_event_enabled.to_s,
comment_detail: integration.comment_detail, comment_detail: integration.comment_detail,
trigger_events: trigger_events_for_service(integration), trigger_events: trigger_events_for_service(integration),
fields: fields_for_service(integration) fields: fields_for_service(integration),
inherit_from_id: integration.inherit_from_id
} }
end end
......
---
title: Add override selector for project-level integrations
merge_request: 34742
author:
type: added
...@@ -12754,6 +12754,15 @@ msgstr "" ...@@ -12754,6 +12754,15 @@ msgstr ""
msgid "Integrations|Standard" msgid "Integrations|Standard"
msgstr "" msgstr ""
msgid "Integrations|This integration has multiple settings available."
msgstr ""
msgid "Integrations|Use custom settings"
msgstr ""
msgid "Integrations|Use instance level settings"
msgstr ""
msgid "Integrations|When a Jira issue is mentioned in a commit or merge request a remote link and comment (if enabled) will be created." msgid "Integrations|When a Jira issue is mentioned in a commit or merge request a remote link and comment (if enabled) will be created."
msgstr "" msgstr ""
......
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { createStore } from '~/integrations/edit/store';
import DynamicField from '~/integrations/edit/components/dynamic_field.vue'; import DynamicField from '~/integrations/edit/components/dynamic_field.vue';
import { GlFormGroup, GlFormCheckbox, GlFormInput, GlFormSelect, GlFormTextarea } from '@gitlab/ui'; import { GlFormGroup, GlFormCheckbox, GlFormInput, GlFormSelect, GlFormTextarea } from '@gitlab/ui';
...@@ -17,6 +18,7 @@ describe('DynamicField', () => { ...@@ -17,6 +18,7 @@ describe('DynamicField', () => {
const createComponent = props => { const createComponent = props => {
wrapper = mount(DynamicField, { wrapper = mount(DynamicField, {
propsData: { ...defaultProps, ...props }, propsData: { ...defaultProps, ...props },
store: createStore(),
}); });
}; };
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { createStore } from '~/integrations/edit/store';
import IntegrationForm from '~/integrations/edit/components/integration_form.vue'; import IntegrationForm from '~/integrations/edit/components/integration_form.vue';
import ActiveToggle from '~/integrations/edit/components/active_toggle.vue'; import ActiveToggle from '~/integrations/edit/components/active_toggle.vue';
import JiraTriggerFields from '~/integrations/edit/components/jira_trigger_fields.vue'; import JiraTriggerFields from '~/integrations/edit/components/jira_trigger_fields.vue';
...@@ -26,6 +27,7 @@ describe('IntegrationForm', () => { ...@@ -26,6 +27,7 @@ describe('IntegrationForm', () => {
const createComponent = (props, featureFlags = {}) => { const createComponent = (props, featureFlags = {}) => {
wrapper = shallowMount(IntegrationForm, { wrapper = shallowMount(IntegrationForm, {
propsData: { ...defaultProps, ...props }, propsData: { ...defaultProps, ...props },
store: createStore(),
stubs: { stubs: {
ActiveToggle, ActiveToggle,
JiraTriggerFields, JiraTriggerFields,
......
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { createStore } from '~/integrations/edit/store';
import TriggerFields from '~/integrations/edit/components/trigger_fields.vue'; import TriggerFields from '~/integrations/edit/components/trigger_fields.vue';
import { GlFormGroup, GlFormCheckbox, GlFormInput } from '@gitlab/ui'; import { GlFormGroup, GlFormCheckbox, GlFormInput } from '@gitlab/ui';
...@@ -12,6 +13,7 @@ describe('TriggerFields', () => { ...@@ -12,6 +13,7 @@ describe('TriggerFields', () => {
const createComponent = props => { const createComponent = props => {
wrapper = mount(TriggerFields, { wrapper = mount(TriggerFields, {
propsData: { ...defaultProps, ...props }, propsData: { ...defaultProps, ...props },
store: createStore(),
}); });
}; };
......
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