Skip to content

Commit ec20be8

Browse files
committed
Fix two role bugs related to Non-admins missing roles in Organisation Users page
- Bug 1 - Refreshing on org users page as non-admin throws exception (cf.helpers.ts) - Bug 2 - Passing non-normalized properties to `normalizr` pollutes `normalizr` cache - When `normalize` tries to normalize an object it sometimes caches entities in a map by id - Sometimes a non-normalized property would be found where an id was expected, leading to map keys of `[object Object]` - This basically duped records - Fix is to make entityOrId type safe - This didn't apply in many places as each import of `normalize` contains it's own cache Note - only addition to `normalizr` is ``` if (typeof input === 'object' && schema.getId) { input = schema.getId(input); } ```
1 parent ce04911 commit ec20be8

File tree

17 files changed

+682
-15
lines changed

17 files changed

+682
-15
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@
8585
"ngrx-store-localstorage": "10.1.1",
8686
"ngx-moment": "^3.5.0",
8787
"ngx-monaco-editor": "^9.0.0",
88-
"normalizr": "^3.6.0",
8988
"reselect": "^4.0.0",
9089
"rxjs": "^6.6.3",
9190
"rxjs-spy": "^7.5.2",

src/frontend/packages/cf-autoscaler/src/store/autoscaler-entity-factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Schema, schema } from 'normalizr';
1+
import { Schema, schema } from '../../../store/src/normalizr/normalizr';
22

33
import { getAPIResourceGuid } from '../../../cloud-foundry/src/store/selectors/api.selectors';
44
import { EntitySchema } from '../../../store/src/helpers/entity-schema';

src/frontend/packages/cloud-foundry/src/cf-entity-schema-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Schema, schema } from 'normalizr';
1+
import { Schema, schema } from '../../store/src/normalizr/normalizr';
22

33
import { EntitySchema } from '../../store/src/helpers/entity-schema';
44
import {

src/frontend/packages/cloud-foundry/src/entity-relations/entity-relations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Action, Store } from '@ngrx/store';
2-
import { denormalize } from 'normalizr';
2+
import { denormalize } from '../../../store/src/normalizr/normalizr';
33
import { Observable, of as observableOf } from 'rxjs';
44
import { filter, first, map, mergeMap, pairwise, skipWhile, switchMap, withLatestFrom } from 'rxjs/operators';
55

src/frontend/packages/cloud-foundry/src/features/cf/cf.helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export function hasSpaceRoleWithinOrg(user: CfUser, orgGuid: string): boolean {
191191
const orgSpaces = [];
192192

193193
for (const role of roles) {
194-
const roleSpaces = user[role] as APIResource<ISpace>[];
194+
const roleSpaces = (user[role] || []) as APIResource<ISpace>[];
195195

196196
orgSpaces.push(...roleSpaces.filter((space) => {
197197
return space.entity.organization_guid === orgGuid;

src/frontend/packages/core/src/shared/components/app-action-monitor/app-action-monitor.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, Input, OnInit } from '@angular/core';
2-
import { schema } from 'normalizr';
2+
import { schema } from '../../../../../store/src/normalizr/normalizr';
33
import { never as observableNever, Observable, of as observableOf } from 'rxjs';
44
import { map, publishReplay, refCount } from 'rxjs/operators';
55

src/frontend/packages/git/src/store/git-entity-factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { schema } from 'normalizr';
1+
import { Schema, schema } from '../../../store/src/normalizr/normalizr';
22

33
import { EntitySchema } from '../../../store/src/helpers/entity-schema';
44
import { GitBranch, GitCommit, GitRepo } from './git.public-types';

src/frontend/packages/kubernetes/src/helm/helm-entity-factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Schema, schema } from 'normalizr';
1+
import { Schema, schema } from '../../../store/src/normalizr/normalizr';
22

33
import { EntitySchema } from '../../../store/src/helpers/entity-schema';
44
import { stratosMonocularEndpointGuid } from './monocular/stratos-monocular.helper';

src/frontend/packages/kubernetes/src/kubernetes/kubernetes-entity-factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Schema, schema } from 'normalizr';
1+
import { Schema, schema } from '../../../store/src/normalizr/normalizr';
22

33
import { getAPIResourceGuid } from '../../../cloud-foundry/src/store/selectors/api.selectors';
44
import { EntitySchema } from '../../../store/src/helpers/entity-schema';

src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/map-multi-endpoint.pipes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Action } from '@ngrx/store';
2-
import { normalize } from 'normalizr';
2+
import { normalize } from '../../../../store/src/normalizr/normalizr';
33

44
import { entityCatalog } from '../../entity-catalog/entity-catalog';
55
import { StratosBaseCatalogEntity } from '../../entity-catalog/entity-catalog-entity/entity-catalog-entity';

0 commit comments

Comments
 (0)