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

Commit

Permalink
Merge pull request #2487 from cloudfoundry-incubator/fix-create-space…
Browse files Browse the repository at this point in the history
…-cancel

Improved fix for exception on org screen after fresh load on create space
  • Loading branch information
nwmac committed Jun 21, 2018
2 parents 44c6eec + 0e52e4b commit b651e9f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/frontend/app/store/helpers/entity-relations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,14 @@ function createSingleAction(config: HandleRelationsConfig) {

function createPaginationAction(config: HandleRelationsConfig) {
const { cfGuid, parentRelation, parentEntity, childRelation, childEntitiesUrl, includeRelations, populateMissing } = config;
const parentGuid = parentEntity.metadata ? parentEntity.metadata.guid : parentEntity.entity.guid;
return new FetchRelationPaginatedAction(
cfGuid,
parentEntity.metadata.guid,
parentGuid,
parentRelation,
childRelation,
includeRelations,
createEntityRelationPaginationKey(parentRelation.entityKey, parentEntity.metadata.guid, childRelation.entity.relationKey),
createEntityRelationPaginationKey(parentRelation.entityKey, parentGuid, childRelation.entity.relationKey),
populateMissing,
childEntitiesUrl
);
Expand Down Expand Up @@ -490,7 +491,7 @@ export function populatePaginationFromParent(store: Store<AppState>, action: Pag
withLatestFrom(store.select(getAPIRequestDataState)),
map(([entityState, allEntities]) => {
const [entityInfo, entity] = entityState;
if (!entityInfo || !entity) {
if (!entity) {
return;
}
// Find the property name (for instance a list of routes in a parent space would have param name `routes`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,17 @@ function populateParentEntity(state, successAction) {
const childRelation = parentEntityTree.rootRelation.childRelations.find(rel => rel.entityKey === successAction.apiAction.entityKey);
const entityParamName = childRelation.paramName;

let newParentEntity = pathGet(`${parentEntityKey}.${parentGuid}`, state) || {};
let newParentEntity = pathGet(`${parentEntityKey}.${parentGuid}`, state);
if (!newParentEntity) {
// We haven't yet fetched the parent entity so create one to store this list in. This can be used to fetch the child list in the future.
// NOTE - This should not contain the metadata property as the lack thereof forces the entity to fail validation and to be fetched
// properly with all it's properties
newParentEntity = {
entity: {
guid: parentGuid,
}
};
}
newParentEntity = {
...newParentEntity,
entity: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Store } from '@ngrx/store';
import { combineLatest , Observable } from 'rxjs';
import { combineLatest, Observable } from 'rxjs';
import { filter, first, publishReplay, refCount, switchMap, tap, distinctUntilChanged } from 'rxjs/operators';

import { PaginationMonitor } from '../../../shared/monitors/pagination-monitor';
Expand Down

0 comments on commit b651e9f

Please sign in to comment.