Skip to content

Commit

Permalink
fix(core): ensure filter tag removal removes tags from filter (#7212)
Browse files Browse the repository at this point in the history
  • Loading branch information
anotherchrisberry authored and Jammy Louie committed Sep 12, 2019
1 parent 733132b commit 42c2946
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
17 changes: 4 additions & 13 deletions app/scripts/modules/core/src/filterModel/FilterModelService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cloneDeep, size, some, isNil, reduce, forOwn, includes, pick } from 'lodash';

import { IFilterModel, IFilterConfig } from './IFilterModel';
import { IFilterModel, IFilterConfig, ITrueKeyModel } from './IFilterModel';
import { ReactInjector } from 'core/reactShims';

export class FilterModelService {
Expand Down Expand Up @@ -204,17 +204,6 @@ export class FilterModelService {
};
}

public static checkCategoryFilters(model: IFilterModel) {
return (target: any) => {
if (this.isFilterable(model.sortFilter.category)) {
const checkedCategories = this.getCheckValues(model.sortFilter.category);
return includes(checkedCategories, target.type) || includes(checkedCategories, target.category);
} else {
return true;
}
};
}

private static addTagsForSection(model: IFilterModel, property: IFilterConfig) {
const key = property.model;
const label = property.filterLabel || property.model;
Expand All @@ -231,7 +220,9 @@ export class FilterModelService {
label,
value: translator[value] || value,
clear() {
delete (modelVal as any)[value];
// do not reuse the modelVal variable - it's possible it has been reassigned since the tag was created
const toClearFrom: ITrueKeyModel = model.sortFilter[key] as ITrueKeyModel;
delete toClearFrom[value];
model.applyParamsToUrl();
},
});
Expand Down
24 changes: 14 additions & 10 deletions app/scripts/modules/core/src/filterModel/IFilterModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,41 @@ export interface IFilterConfig {
array?: boolean;
}

export interface ITrueKeyModel {
[key: string]: boolean;
}

// The sortFilter objects are generated, so leaving all fields as required
// In addition, there should technically be a few different ISortFilter
// sub-interfaces (Clusters, Pipeline, Load Balancer, etc)
// but I want to delete all this stuff in favor of router params eventually
// anyway, so keeping the interface consolidated for now.
export interface ISortFilter {
account: { [key: string]: boolean };
availabilityZone: { [key: string]: boolean };
account: ITrueKeyModel;
availabilityZone: ITrueKeyModel;
category: { [key: string]: any };
clusters: { [key: string]: any };
count: number;
detail: { [key: string]: boolean };
detail: ITrueKeyModel;
filter: string;
groupBy: string;
instanceSort: string;
instanceType: { [key: string]: boolean };
labels: { [key: string]: boolean };
instanceType: ITrueKeyModel;
labels: ITrueKeyModel;
listInstances: boolean;
maxInstances: number;
minInstances: number;
multiselect: boolean;
pipeline: { [key: string]: boolean };
providerType: { [key: string]: boolean };
region: { [key: string]: boolean };
pipeline: ITrueKeyModel;
providerType: ITrueKeyModel;
region: ITrueKeyModel;
showAllInstances: boolean;
showInstances: boolean;
showLoadBalancers: boolean;
showServerGroups: boolean;
showDurations: boolean;
stack: { [key: string]: boolean };
status: { [key: string]: boolean };
stack: ITrueKeyModel;
status: ITrueKeyModel;
}

export interface IFilterModel {
Expand Down

0 comments on commit 42c2946

Please sign in to comment.