UI - replication path filtering (#7620)

* rename mount-filter-config models, components, serializer, adapters to path-filter-config

* move search-select component to core addon

* add js class for search-select-placeholder and sort out power-select deps for moving to the core component

* expose oninput from powerselect through search-select

* don't fetch mounts in the replication routes

* remove toggle from add template

* start cross-namespace fetching

* group options and set up for namespace fetch via power-select search prop

* add and style up radio-card CSS component

* add xlm size for icons between l and xl

* copy defaults so they're not getting mutated

* finalize cross-namespace fetching and getting that to work with power-select

* when passing options but no models, format the options in search select so that they render properly in the list

* tint the background of a selected radio card

* default to null mode and uniq options in search-select

* finish styling radio-card

* format inputValues when first rendering the component if options are being passed from outside

* treat mode:null as deleting existing config which simplifies save logic

* correctly prune the auto complete list since path-filter-config-list handles all of that and finish styling

* remove old component

* add search debounce and fix linting

* update search-select docs

* updating tests

* support grouped options for when to show the create prompt

* update and add tests for path-filter-config-list

* fix tests for search-select and path-filter-config-list

* the new api uses allow/deny instead of whitelist/blacklist
This commit is contained in:
Matthew Irish
2019-10-25 13:16:45 -05:00
committed by GitHub
parent 25c2042ab6
commit 373b5d6a25
37 changed files with 620 additions and 300 deletions

View File

@@ -2,22 +2,23 @@ import { isPresent } from '@ember/utils';
import { alias } from '@ember/object/computed';
import { inject as service } from '@ember/service';
import Controller from '@ember/controller';
import { copy } from 'ember-copy';
import { resolve } from 'rsvp';
const DEFAULTS = {
token: null,
id: null,
loading: false,
errors: [],
showFilterConfig: false,
primary_api_addr: null,
primary_cluster_addr: null,
filterConfig: {
mode: 'whitelist',
mode: null,
paths: [],
},
};
export default Controller.extend(DEFAULTS, {
export default Controller.extend(copy(DEFAULTS, true), {
store: service(),
rm: service('replication-mode'),
replicationMode: alias('rm.mode'),
@@ -34,12 +35,16 @@ export default Controller.extend(DEFAULTS, {
const config = this.get('filterConfig');
const id = this.get('id');
config.id = id;
const configRecord = this.get('store').createRecord('mount-filter-config', config);
// if there is no mode, then they don't want to filter, so we don't save a filter config
if (!config.mode) {
return resolve();
}
const configRecord = this.get('store').createRecord('path-filter-config', config);
return configRecord.save().catch(e => this.submitError(e));
},
reset() {
this.setProperties(DEFAULTS);
this.setProperties(copy(DEFAULTS, true));
},
submitSuccess(resp, action) {
@@ -66,14 +71,9 @@ export default Controller.extend(DEFAULTS, {
submitHandler(action, clusterMode, data, event) {
const replicationMode = this.get('replicationMode');
let saveFilterConfig;
if (event && event.preventDefault) {
event.preventDefault();
}
if (data && isPresent(data.saveFilterConfig)) {
saveFilterConfig = data.saveFilterConfig;
delete data.saveFilterConfig;
}
this.setProperties({
loading: true,
errors: [],
@@ -93,13 +93,9 @@ export default Controller.extend(DEFAULTS, {
.replicationAction(action, replicationMode, clusterMode, data)
.then(
resp => {
if (saveFilterConfig) {
return this.saveFilterConfig().then(() => {
return this.submitSuccess(resp, action, clusterMode);
});
} else {
return this.saveFilterConfig().then(() => {
return this.submitSuccess(resp, action, clusterMode);
}
});
},
(...args) => this.submitError(...args)
);