Skip to content

Commit

Permalink
Expression Changed, Fix Create/Edit Org/Space & Allow guids of 0 (num…
Browse files Browse the repository at this point in the history
…ber)

- Remove associateSpaceQuota/disassociateSpaceQuota from org quota builder (can update an org quota via updating the core org)
- Added action builder typings
- Fix add/edit org
- Fix add/edit space
- Fix unassigning space quota
- Ensure request info accepts guids of number 0
- ExpressionChanged error on endpoints screen
  • Loading branch information
richard-cox committed Sep 26, 2019
1 parent aac8162 commit 159f8f1
Show file tree
Hide file tree
Showing 14 changed files with 149 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import {
QuotaFormValues,
} from '../../../core/src/features/cloud-foundry/quota-definition-form/quota-definition-form.component';
import {
AssociateSpaceQuota,
CreateQuotaDefinition,
DisassociateSpaceQuota,
GetOrganizationSpaceQuotaDefinitions,
GetQuotaDefinitions,
UpdateQuotaDefinition,
Expand All @@ -26,18 +24,8 @@ export interface QuotaDefinitionActionBuilder extends OrchestratedActionBuilders
getMultiple: (
paginationKey: string,
endpointGuid: string,
{ includeRelations, populateMissing }: CFBasePipelineRequestActionMeta
{ includeRelations, populateMissing }?: CFBasePipelineRequestActionMeta
) => GetQuotaDefinitions;
associateSpaceQuota: (
spaceGuid: string,
endpointGuid: string,
spaceQuotaGuid: string
) => AssociateSpaceQuota;
disassociateSpaceQuota: (
spaceGuid: string,
endpointGuid: string,
spaceQuotaGuid: string
) => DisassociateSpaceQuota;
getOrganizationSpaceQuotaDefinitions: (
orgGuid: string,
paginationKey: string,
Expand All @@ -63,16 +51,16 @@ export const quotaDefinitionActionBuilder: QuotaDefinitionActionBuilder = {
endpointGuid: string,
{ includeRelations, populateMissing }: CFBasePipelineRequestActionMeta = {}
) => new GetQuotaDefinitions(paginationKey, endpointGuid, includeRelations, populateMissing),
associateSpaceQuota: (
spaceGuid: string,
endpointGuid: string,
spaceQuotaGuid: string
) => new AssociateSpaceQuota(spaceGuid, endpointGuid, spaceQuotaGuid),
disassociateSpaceQuota: (
spaceGuid: string,
endpointGuid: string,
spaceQuotaGuid: string
) => new DisassociateSpaceQuota(spaceGuid, endpointGuid, spaceQuotaGuid),
// associateSpaceQuota: (
// spaceGuid: string,
// endpointGuid: string,
// spaceQuotaGuid: string
// ) => new AssociateSpaceQuota(spaceGuid, endpointGuid, spaceQuotaGuid),
// disassociateSpaceQuota: (
// spaceGuid: string,
// endpointGuid: string,
// spaceQuotaGuid: string
// ) => new DisassociateSpaceQuota(spaceGuid, endpointGuid, spaceQuotaGuid),
getOrganizationSpaceQuotaDefinitions: (
orgGuid: string,
paginationKey: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export interface SpaceQuotaDefinitionActionBuilders extends OrchestratedActionBu
orgGuid: string,
endpointGuid: string,
paginationKey: string,
includeRelations: string[],
populateMissing,
includeRelations?: string[],
populateMissing?: boolean,
) => GetOrganizationSpaceQuotaDefinitions;
associateWithSpace: (
spaceGuid: string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,44 @@
import { IUpdateSpace } from '../../../core/src/core/cf-api.types';
import { OrchestratedActionBuilders } from '../../../core/src/core/entity-catalogue/action-orchestrator/action-orchestrator';
import { GetAllOrganizationSpaces } from '../actions/organization.actions';
import { GetSpace, GetAllSpaces, DeleteSpace, CreateSpace, UpdateSpace } from '../actions/space.actions';
import { IUpdateSpace } from '../../../core/src/core/cf-api.types';
import { CreateSpace, DeleteSpace, GetAllSpaces, GetSpace, UpdateSpace } from '../actions/space.actions';
import { CFBasePipelineRequestActionMeta } from '../cf-entity-generator';

export const spaceActionBuilders = {
export interface SpaceActionBuilders extends OrchestratedActionBuilders {
get: (
guid: string,
endpointGuid: string,
{ includeRelations, populateMissing }: CFBasePipelineRequestActionMeta
) => GetSpace;
remove: (
guid: string,
endpointGuid: string,
{ orgGuid }: { orgGuid: string }
) => DeleteSpace;
create: (
id: string,
endpointGuid: string,
{ orgGuid, createSpace }: { orgGuid: string, createSpace: IUpdateSpace }
) => CreateSpace;
update: (
guid: string,
endpointGuid: string,
updatedSpace: IUpdateSpace
) => UpdateSpace;
getMultiple: (
endpointGuid: string,
paginationKey: string,
{ includeRelations, populateMissing }: CFBasePipelineRequestActionMeta
) => GetAllSpaces;
getAllInOrganization: (
orgGuid: string,
endpointGuid: string,
paginationKey: string,
{ includeRelations, populateMissing }: CFBasePipelineRequestActionMeta
) => GetAllOrganizationSpaces;
}

export const spaceActionBuilders: SpaceActionBuilders = {
get: (
guid: string,
endpointGuid: string,
Expand Down Expand Up @@ -59,4 +93,4 @@ export const spaceActionBuilders = {
paginationKey: string,
{ includeRelations, populateMissing }: CFBasePipelineRequestActionMeta = {}
) => new GetAllOrganizationSpaces(paginationKey, orgGuid, endpointGuid, includeRelations, populateMissing)
} as OrchestratedActionBuilders;
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@ import { CF_ENDPOINT_TYPE, CFEntityConfig } from '../../../../cloud-foundry/cf-t
import { CFAppState } from '../../../../cloud-foundry/src/cf-app-state';
import {
organizationEntityType,
quotaDefinitionEntityType,
spaceEntityType,
spaceQuotaEntityType,
} from '../../../../cloud-foundry/src/cf-entity-types';
import { createEntityRelationPaginationKey } from '../../../../cloud-foundry/src/entity-relations/entity-relations.types';
import { ISpaceQuotaDefinition } from '../../../../core/src/core/cf-api.types';
import { entityCatalogue } from '../../../../core/src/core/entity-catalogue/entity-catalogue.service';
import { IEntityMetadata } from '../../../../core/src/core/entity-catalogue/entity-catalogue.types';
import { StepOnNextResult } from '../../../../core/src/shared/components/stepper/step/step.component';
import { PaginationMonitorFactory } from '../../../../core/src/shared/monitors/pagination-monitor.factory';
import { getPaginationKey } from '../../../../store/src/actions/pagination.actions';
import { getPaginationObservables } from '../../../../store/src/reducers/pagination-reducer/pagination-reducer.helper';
import { APIResource } from '../../../../store/src/types/api.types';
import { PaginatedAction } from '../../../../store/src/types/pagination.types';
import { cfEntityFactory } from '../../cf-entity-factory';
import { SpaceQuotaDefinitionActionBuilders } from '../../entity-action-builders/space-quota.action-builders';
import { ActiveRouteCfOrgSpace } from './cf-page.types';

export class AddEditSpaceStepBase {
Expand Down Expand Up @@ -66,13 +67,16 @@ export class AddEditSpaceStepBase {

const quotaPaginationKey = createEntityRelationPaginationKey(organizationEntityType, this.orgGuid);

const quotaEntity = entityCatalogue.getEntity(CF_ENDPOINT_TYPE, quotaDefinitionEntityType);
const actionBuilder = quotaEntity.actionOrchestrator.getActionBuilder('getOrganizationSpaceQuotaDefinitions');
const getOrganizationSpaceQuotaDefnitionsAction = actionBuilder(quotaPaginationKey, this.orgGuid, this.cfGuid);
const quotaEntity = entityCatalogue.getEntity<IEntityMetadata, any, SpaceQuotaDefinitionActionBuilders>(
CF_ENDPOINT_TYPE,
spaceQuotaEntityType
);
const actionBuilder = quotaEntity.actionOrchestrator.getActionBuilder('getAllInOrganization');
const getAllInOrganization = actionBuilder(this.orgGuid, this.cfGuid, quotaPaginationKey);
this.quotaDefinitions$ = getPaginationObservables<APIResource<ISpaceQuotaDefinition>>(
{
store: this.store,
action: getOrganizationSpaceQuotaDefnitionsAction as PaginatedAction,
action: getAllInOrganization as PaginatedAction,
paginationMonitor: this.paginationMonitorFactory.create(
quotaPaginationKey,
cfEntityFactory(spaceQuotaEntityType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,22 @@ import { filter, map, tap } from 'rxjs/operators';

import { CF_ENDPOINT_TYPE } from '../../../../../../cloud-foundry/cf-types';
import { CreateOrganization } from '../../../../../../cloud-foundry/src/actions/organization.actions';
import { GetQuotaDefinitions } from '../../../../../../cloud-foundry/src/actions/quota-definitions.actions';
import { CFAppState } from '../../../../../../cloud-foundry/src/cf-app-state';
import {
organizationEntityType,
quotaDefinitionEntityType,
} from '../../../../../../cloud-foundry/src/cf-entity-types';
import { organizationEntityType, quotaDefinitionEntityType } from '../../../../../../cloud-foundry/src/cf-entity-types';
import {
createEntityRelationPaginationKey,
} from '../../../../../../cloud-foundry/src/entity-relations/entity-relations.types';
import { selectCfRequestInfo } from '../../../../../../cloud-foundry/src/store/selectors/api.selectors';
import { IOrganization, IOrgQuotaDefinition } from '../../../../../../core/src/core/cf-api.types';
import { entityCatalogue } from '../../../../../../core/src/core/entity-catalogue/entity-catalogue.service';
import { IEntityMetadata } from '../../../../../../core/src/core/entity-catalogue/entity-catalogue.types';
import { StepOnNextFunction } from '../../../../../../core/src/shared/components/stepper/step/step.component';
import { PaginationMonitorFactory } from '../../../../../../core/src/shared/monitors/pagination-monitor.factory';
import { endpointSchemaKey } from '../../../../../../store/src/helpers/entity-factory';
import { getPaginationObservables } from '../../../../../../store/src/reducers/pagination-reducer/pagination-reducer.helper';
import { APIResource } from '../../../../../../store/src/types/api.types';
import { cfEntityFactory } from '../../../../cf-entity-factory';
import { QuotaDefinitionActionBuilder } from '../../../../entity-action-builders/quota-definition.action-builders';
import { CloudFoundryEndpointService } from '../../services/cloud-foundry-endpoint.service';


Expand Down Expand Up @@ -79,9 +77,12 @@ export class CreateOrganizationStepComponent implements OnInit, OnDestroy {
);

const quotaPaginationKey = createEntityRelationPaginationKey(endpointSchemaKey, this.cfGuid);
const quotaDefinitionEntity = entityCatalogue.getEntity(CF_ENDPOINT_TYPE, quotaDefinitionEntityType);
const quotaDefinitionEntity = entityCatalogue.getEntity<IEntityMetadata, any, QuotaDefinitionActionBuilder>(
CF_ENDPOINT_TYPE,
quotaDefinitionEntityType
);
const actionBuilder = quotaDefinitionEntity.actionOrchestrator.getActionBuilder('getMultiple');
const getQuotaDefinitionsAction = actionBuilder(this.cfGuid, quotaPaginationKey);
const getQuotaDefinitionsAction = actionBuilder(quotaPaginationKey, this.cfGuid, { includeRelations: [] });
this.quotaDefinitions$ = getPaginationObservables<APIResource<IOrgQuotaDefinition>>(
{
store: this.store,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ import { filter } from 'rxjs/operators';
import { CFAppState } from '../../../../../../cloud-foundry/src/cf-app-state';
import { spaceEntityType } from '../../../../../../cloud-foundry/src/cf-entity-types';
import { selectCfRequestInfo } from '../../../../../../cloud-foundry/src/store/selectors/api.selectors';
import { EntityServiceFactory } from '../../../../../../core/src/core/entity-service-factory.service';
import { entityCatalogue } from '../../../../../../core/src/core/entity-catalogue/entity-catalogue.service';
import { IEntityMetadata } from '../../../../../../core/src/core/entity-catalogue/entity-catalogue.types';
import { StepOnNextFunction } from '../../../../../../core/src/shared/components/stepper/step/step.component';
import { PaginationMonitorFactory } from '../../../../../../core/src/shared/monitors/pagination-monitor.factory';
import { CF_ENDPOINT_TYPE } from '../../../../../cf-types';
import { SpaceActionBuilders } from '../../../../entity-action-builders/space.action-builders';
import { AddEditSpaceStepBase } from '../../add-edit-space-step-base';
import { ActiveRouteCfOrgSpace } from '../../cf-page.types';

Expand Down Expand Up @@ -44,7 +47,6 @@ export class CreateSpaceStepComponent extends AddEditSpaceStepBase implements On
activatedRoute: ActivatedRoute,
paginationMonitorFactory: PaginationMonitorFactory,
activeRouteCfOrgSpace: ActiveRouteCfOrgSpace,
private entityServiceFactory: EntityServiceFactory
) {
super(store, activatedRoute, paginationMonitorFactory, activeRouteCfOrgSpace);
}
Expand Down Expand Up @@ -75,16 +77,21 @@ export class CreateSpaceStepComponent extends AddEditSpaceStepBase implements On
}

submit: StepOnNextFunction = () => {
// const spaceEntity = entityCatalogue.getEntity(CF_ENDPOINT_TYPE, spaceEntityType);
// const actionBuilder = spaceEntity.actionOrchestrator.getActionBuilder('create');
// const createSpaceAction = actionBuilder(this.cfGuid, this.orgGuid, {
// name: this.spaceName.value,
// organization_guid: this.orgGuid,
// space_quota_definition_guid: this.quotaDefinition.value
// });
// this.store.dispatch(createSpaceAction); //TODO: commented out??

return this.store.select(selectCfRequestInfo(spaceEntityType, `${this.orgGuid}-${this.spaceName.value}`)).pipe(
const id = `${this.orgGuid}-${this.spaceName.value}`;
const spaceEntity = entityCatalogue.getEntity<IEntityMetadata, any, SpaceActionBuilders>(
CF_ENDPOINT_TYPE,
spaceEntityType
);
spaceEntity.actionDispatchManager.dispatchCreate(id, this.cfGuid, {
createSpace: {
name: this.spaceName.value,
organization_guid: this.orgGuid,
space_quota_definition_guid: this.quotaDefinition.value
},
orgGuid: this.orgGuid
});

return this.store.select(selectCfRequestInfo(spaceEntityType, id)).pipe(
filter(o => !!o && !o.fetching && !o.creating),
this.map('Failed to create space: ')
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class EditOrganizationStepComponent implements OnInit, OnDestroy {
quotaDefinitionEntityType
);
const actionBuilder = quotaDefinitionEntity.actionOrchestrator.getActionBuilder('getMultiple');
const getQuotaDefinitionsAction = actionBuilder(quotaPaginationKey, this.cfGuid, {});
const getQuotaDefinitionsAction = actionBuilder(quotaPaginationKey, this.cfGuid);
this.quotaDefinitions$ = getPaginationObservables<APIResource<IOrgQuotaDefinition>>(
{
store: this.store,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import { UpdateSpace } from '../../../../../../cloud-foundry/src/actions/space.a
import { CFAppState } from '../../../../../../cloud-foundry/src/cf-app-state';
import { spaceEntityType, spaceQuotaEntityType } from '../../../../../../cloud-foundry/src/cf-entity-types';
import { entityCatalogue } from '../../../../../../core/src/core/entity-catalogue/entity-catalogue.service';
import { IEntityMetadata } from '../../../../../../core/src/core/entity-catalogue/entity-catalogue.types';
import { StepOnNextFunction } from '../../../../../../core/src/shared/components/stepper/step/step.component';
import { PaginationMonitorFactory } from '../../../../../../core/src/shared/monitors/pagination-monitor.factory';
import { selectRequestInfo } from '../../../../../../store/src/selectors/api.selectors';
import { SpaceQuotaDefinitionActionBuilders } from '../../../../entity-action-builders/space-quota.action-builders';
import { AddEditSpaceStepBase } from '../../add-edit-space-step-base';
import { ActiveRouteCfOrgSpace } from '../../cf-page.types';
import { CloudFoundrySpaceService } from '../../services/cloud-foundry-space.service';
Expand Down Expand Up @@ -128,17 +130,18 @@ export class EditSpaceStepComponent extends AddEditSpaceStepBase implements OnDe
let spaceQuotaQueryGuid;
let action: AssociateSpaceQuota | DisassociateSpaceQuota;

const spaceQuotaEntity = entityCatalogue.getEntity(CF_ENDPOINT_TYPE, spaceQuotaEntityType);
const spaceQuotaEntity = entityCatalogue.getEntity<IEntityMetadata, any, SpaceQuotaDefinitionActionBuilders>(
CF_ENDPOINT_TYPE,
spaceQuotaEntityType
);
if (spaceQuotaGuid) {
spaceQuotaQueryGuid = spaceQuotaGuid;
const actionBuilder = spaceQuotaEntity.actionOrchestrator.getActionBuilder('associateSpaceQuota');
const associateSpaceQuotaAction = actionBuilder(this.spaceGuid, this.cfGuid, spaceQuotaGuid);
action = associateSpaceQuotaAction as AssociateSpaceQuota;
const actionBuilder = spaceQuotaEntity.actionOrchestrator.getActionBuilder('associateWithSpace');
action = actionBuilder(this.spaceGuid, this.cfGuid, spaceQuotaQueryGuid) as AssociateSpaceQuota;
} else {
spaceQuotaQueryGuid = this.originalSpaceQuotaGuid;
const actionBuilder = spaceQuotaEntity.actionOrchestrator.getActionBuilder('disassociateSpaceQuota');
const disassociateSpaceQuotaAction = actionBuilder(this.spaceGuid, this.cfGuid, spaceQuotaGuid);
action = disassociateSpaceQuotaAction as AssociateSpaceQuota;
const actionBuilder = spaceQuotaEntity.actionOrchestrator.getActionBuilder('disassociateFromSpace');
action = actionBuilder(this.spaceGuid, this.cfGuid, spaceQuotaQueryGuid) as DisassociateSpaceQuota;
}
this.store.dispatch(action);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ export class EndpointCardComponent extends CardCell<EndpointModel> implements On
this.component.isTable = false;
}
this.component.row = this.pRow;
this.componentRef.changeDetectorRef.detectChanges();


this.updateCardStatus();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ export class EndpointListHelper {
EndpointDetailsContainerRefs {
const componentFactory = componentFactoryResolver.resolveComponentFactory<EndpointListDetailsComponent>(listDetailsComponent);
const componentRef = container.createComponent<EndpointListDetailsComponent>(componentFactory);
componentRef.changeDetectorRef.detectChanges();
const component = isEndpointListDetailsComponent(componentRef.instance);
const refs = {
componentRef,
Expand Down
Loading

0 comments on commit 159f8f1

Please sign in to comment.