Skip to content
This repository has been archived by the owner on Mar 25, 2023. It is now read-only.

Commit

Permalink
fix(sg-filter): Fix filter by account
Browse files Browse the repository at this point in the history
  • Loading branch information
ksendart committed Dec 12, 2017
1 parent ca45c7b commit 1588f2d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
24 changes: 7 additions & 17 deletions src/app/reducers/security-groups/redux/sg.reducers.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
import {
createEntityAdapter,
EntityAdapter,
EntityState
} from '@ngrx/entity';
import {
createFeatureSelector,
createSelector
} from '@ngrx/store';
import {
SecurityGroup,
SecurityGroupType
} from '../../../security-group/sg.model';
import * as securityGroup from './sg.actions';
import * as fromAccounts from '../../accounts/redux/accounts.reducers';
import { createEntityAdapter, EntityAdapter, EntityState } from '@ngrx/entity';
import { createFeatureSelector, createSelector } from '@ngrx/store';

import { SecurityGroupViewMode } from '../../../security-group/sg-view-mode';
import { SecurityGroup, SecurityGroupType } from '../../../security-group/sg.model';
import * as fromAccounts from '../../accounts/redux/accounts.reducers';
import * as securityGroup from './sg.actions';


export interface State {
Expand Down Expand Up @@ -226,6 +216,7 @@ export const selectFilteredSecurityGroups = createSelector(
filters,
fromAccounts.selectAll,
(securityGroups, filter, accounts) => {
const mode = filter.viewMode;
const queryLower = filter.query ? filter.query.toLowerCase() : '';
const queryFilter = (group: SecurityGroup) => !queryLower || group.name.toLowerCase()
.includes(queryLower);
Expand All @@ -236,10 +227,9 @@ export const selectFilteredSecurityGroups = createSelector(
const domainsMap = selectedAccounts.reduce((m, i) => ({ ...m, [i.domainid]: i }), {});

const selectedAccountIdsFilter = group => !filter.selectedAccountIds.length ||
group.type === SecurityGroupType.PredefinedTemplate ||
(accountsMap[group.account] && domainsMap[group.domainid]);


const mode = filter.viewMode;
const viewModeFilter = (group: SecurityGroup) => {
if (mode === SecurityGroupViewMode.Templates) {
return group.type === SecurityGroupType.PredefinedTemplate || group.type === SecurityGroupType.CustomTemplate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
[dynamicOutputs]="outputs"
>
</cs-grouped-list>
<ng-container *ngIf="!securityGroups.length">
<div class="padding" *ngIf="!securityGroups.length">
{{ 'COMMON.NO_RESULTS' | translate }}
</ng-container>
</div>

0 comments on commit 1588f2d

Please sign in to comment.