Commit 299e51f7 authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch...

Merge branch '329182-clean-up-ee-app-assets-javascripts-pages-admin-application_settings-index-js' into 'master'

Extract advanced_search JS code to separate bundle

See merge request gitlab-org/gitlab!60596
parents c6c3708a e58e48a8
......@@ -37,7 +37,6 @@ export default {
<input name="service[active]" type="hidden" :value="activated || false" />
<gl-form-checkbox
v-model="activated"
name="service[active]"
class="gl-display-block"
:disabled="isInheriting"
@change="onChange"
......
import $ from 'jquery';
import initIntegrationsList from '~/integrations/index';
import Api from '~/api';
import { loadCSSFile } from '~/lib/utils/css_utils';
import { select2AxiosTransport } from '~/lib/utils/select2_utils';
import { s__ } from '~/locale';
import PersistentUserCallout from '~/persistent_user_callout';
const onLimitCheckboxChange = (checked, $limitByNamespaces, $limitByProjects) => {
$limitByNamespaces.find('.select2').select2('data', null);
......@@ -12,14 +11,14 @@ const onLimitCheckboxChange = (checked, $limitByNamespaces, $limitByProjects) =>
$limitByProjects.toggleClass('hidden', !checked);
};
const getDropdownConfig = (placeholder, url) => ({
const getDropdownConfig = (placeholder, apiPath, textProp) => ({
placeholder,
multiple: true,
initSelection($el, callback) {
callback($el.data('selected'));
},
ajax: {
url,
url: Api.buildUrl(apiPath),
dataType: 'JSON',
quietMillis: 250,
data(search) {
......@@ -30,8 +29,8 @@ const getDropdownConfig = (placeholder, url) => ({
results(data) {
return {
results: data.results.map((entity) => ({
id: entity.source_id,
text: entity.path,
id: entity.id,
text: entity[textProp],
})),
};
},
......@@ -39,11 +38,6 @@ const getDropdownConfig = (placeholder, url) => ({
},
});
const callout = document.querySelector('.js-admin-integrations-moved');
PersistentUserCallout.factory(callout);
initIntegrationsList();
// ElasticSearch
const $container = $('#js-elasticsearch-settings');
......@@ -67,7 +61,8 @@ import(/* webpackChunkName: 'select2' */ 'select2/select2')
.select2(
getDropdownConfig(
s__('Elastic|None. Select namespaces to index.'),
'/-/autocomplete/namespace_routes.json',
Api.namespacesPath,
'full_path',
),
);
......@@ -76,7 +71,8 @@ import(/* webpackChunkName: 'select2' */ 'select2/select2')
.select2(
getDropdownConfig(
s__('Elastic|None. Select projects to index.'),
'/-/autocomplete/project_routes.json',
Api.projectsPath,
'name_with_namespace',
),
);
})
......
import '~/pages/admin/application_settings/index';
import $ from 'jquery';
import Api from '~/api';
import groupsSelect from '~/groups_select';
import { loadCSSFile } from '~/lib/utils/css_utils';
import { select2AxiosTransport } from '~/lib/utils/select2_utils';
import { s__ } from '~/locale';
const onLimitCheckboxChange = (checked, $limitByNamespaces, $limitByProjects) => {
$limitByNamespaces.find('.select2').select2('data', null);
$limitByNamespaces.find('.select2').select2('data', null);
$limitByNamespaces.toggleClass('hidden', !checked);
$limitByProjects.toggleClass('hidden', !checked);
};
const getDropdownConfig = (placeholder, apiPath, textProp) => ({
placeholder,
multiple: true,
initSelection($el, callback) {
callback($el.data('selected'));
},
ajax: {
url: Api.buildUrl(apiPath),
dataType: 'JSON',
quietMillis: 250,
data(search) {
return {
search,
};
},
results(data) {
return {
results: data.results.map((entity) => ({
id: entity.id,
text: entity[textProp],
})),
};
},
transport: select2AxiosTransport,
},
});
groupsSelect();
// ElasticSearch
const $container = $('#js-elasticsearch-settings');
$container
.find('.js-limit-checkbox')
.on('change', (e) =>
onLimitCheckboxChange(
e.currentTarget.checked,
$container.find('.js-limit-namespaces'),
$container.find('.js-limit-projects'),
),
);
import(/* webpackChunkName: 'select2' */ 'select2/select2')
.then(() => {
// eslint-disable-next-line promise/no-nesting
loadCSSFile(gon.select2_css_path)
.then(() => {
$container
.find('.js-elasticsearch-namespaces')
.select2(
getDropdownConfig(
s__('Elastic|None. Select namespaces to index.'),
Api.namespacesPath,
'full_path',
),
);
$container
.find('.js-elasticsearch-projects')
.select2(
getDropdownConfig(
s__('Elastic|None. Select projects to index.'),
Api.projectsPath,
'name_with_namespace',
),
);
})
.catch(() => {});
})
.catch(() => {});
......@@ -22,7 +22,7 @@ RSpec.shared_context 'project service activation' do
end
def click_active_checkbox
find('input[name="service[active]"]').click
find('label', text: 'Active').click
end
def click_save_integration
......
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