From 5364ffb6ba3ef592a51304465c4b70e2c5f3855e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Avelino?= Date: Thu, 15 Aug 2019 16:30:40 -0300 Subject: [PATCH 1/4] Added backward compatility to old action types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We are changing the string format of action type and to avoid breaking everything we added the backward compatibility to work with the old format. This way we can slowly transition to the new format without breaking all the features at once. Signed-off-by: VĂ­tor Avelino --- .../src/actions/route.actions.ts | 8 ++-- .../entity-catalogue-entity.ts | 44 +++++++++++++++---- .../shared/components/list/list.component.ts | 1 - .../endpoint-errors.handler.spec.ts | 6 +-- .../endpoint-errors.handler.ts | 2 +- .../fail-entity-request.handler.ts | 7 +-- .../start-entity-request.handler.ts | 2 +- .../success-entity-request.handler.ts | 8 ++-- .../entity-request-pipeline.ts | 12 ++--- .../api-request-reducer/request-helpers.ts | 6 +-- .../packages/store/src/types/request.types.ts | 7 ++- 11 files changed, 67 insertions(+), 36 deletions(-) diff --git a/src/frontend/packages/cloud-foundry/src/actions/route.actions.ts b/src/frontend/packages/cloud-foundry/src/actions/route.actions.ts index afaf448567..291460c581 100644 --- a/src/frontend/packages/cloud-foundry/src/actions/route.actions.ts +++ b/src/frontend/packages/cloud-foundry/src/actions/route.actions.ts @@ -10,12 +10,12 @@ import { routeEntityType, spaceEntityType, } from '../cf-entity-factory'; -import { CFStartAction } from './cf-action.types'; import { - EntityInlineParentAction, createEntityRelationKey, - createEntityRelationPaginationKey + createEntityRelationPaginationKey, + EntityInlineParentAction, } from '../entity-relations/entity-relations.types'; +import { CFStartAction } from './cf-action.types'; export const CREATE_ROUTE = '[Route] Create start'; export const CREATE_ROUTE_SUCCESS = '[Route] Create success'; @@ -112,7 +112,7 @@ export class UnmapRoute extends BaseRouteAction { this.options.method = 'delete'; this.options.params = new URLSearchParams(); } - endpointTYpe = 'cf'; + endpointType = 'cf'; actions = [ RouteEvents.UNMAP_ROUTE, RouteEvents.UNMAP_ROUTE_SUCCESS, diff --git a/src/frontend/packages/core/src/core/entity-catalogue/entity-catalogue-entity.ts b/src/frontend/packages/core/src/core/entity-catalogue/entity-catalogue-entity.ts index d9d3b81760..070a4b518f 100644 --- a/src/frontend/packages/core/src/core/entity-catalogue/entity-catalogue-entity.ts +++ b/src/frontend/packages/core/src/core/entity-catalogue/entity-catalogue-entity.ts @@ -1,8 +1,12 @@ -import { Store, ActionReducer, Action } from '@ngrx/store'; +import { ActionReducer, Store } from '@ngrx/store'; +import { normalize } from 'normalizr'; import { AppState, IRequestEntityTypeState } from '../../../../store/src/app-state'; import { EntitySchema } from '../../../../store/src/helpers/entity-schema'; +import { ApiRequestTypes } from '../../../../store/src/reducers/api-request-reducer/request-helpers'; +import { NormalizedResponse } from '../../../../store/src/types/api.types'; import { EndpointModel } from '../../../../store/src/types/endpoint.types'; +import { APISuccessOrFailedAction, EntityRequestAction } from '../../../../store/src/types/request.types'; import { IEndpointFavMetadata } from '../../../../store/src/types/user-favorites.types'; import { endpointEntitySchema } from '../../base-entity-schemas'; import { getFullEndpointApiUrl } from '../../features/endpoints/endpoint-helpers'; @@ -15,13 +19,10 @@ import { IEntityMetadata, IStratosBaseEntityDefinition, IStratosEndpointDefinition, - StratosEndpointExtensionDefinition, IStratosEntityBuilder, IStratosEntityDefinition, + StratosEndpointExtensionDefinition, } from './entity-catalogue.types'; -import { ApiRequestTypes } from '../../../../store/src/reducers/api-request-reducer/request-helpers'; -import { NormalizedResponse } from '../../../../store/src/types/api.types'; -import { normalize } from 'normalizr'; export interface EntityCatalogueBuilders< T extends IEntityMetadata = IEntityMetadata, @@ -136,10 +137,35 @@ export class StratosBaseCatalogueEntity< }; } - public getRequestAction(actionString: 'start' | 'success' | 'failure' | 'complete', requestType: ApiRequestTypes): Action { - return { - type: `@stratos/${this.entityKey}/${requestType}/${actionString}` - }; + public getRequestAction( + actionString: 'start' | 'success' | 'failure' | 'complete', + requestType: ApiRequestTypes, + action?: EntityRequestAction, + response?: any): APISuccessOrFailedAction { + // backward compatibility with the old actions. + // it should be removed after everything is based on the new flow + if (action && action.actions) { + let type; + + switch (actionString) { + case 'success': + type = action.actions[1]; + break; + case 'failure': + type = action.actions[2]; + break; + case 'start': + type = action.actions[0]; + break; + } + + if (type) { + return new APISuccessOrFailedAction(type, action, response); + } + } + + return new APISuccessOrFailedAction(`@stratos/${this.entityKey}/${requestType}/${actionString}`, + action, response); } public getNormalizedEntityData(entities: Y | Y[], schemaKey?: string): NormalizedResponse { diff --git a/src/frontend/packages/core/src/shared/components/list/list.component.ts b/src/frontend/packages/core/src/shared/components/list/list.component.ts index df597b82b4..f2db44ec91 100644 --- a/src/frontend/packages/core/src/shared/components/list/list.component.ts +++ b/src/frontend/packages/core/src/shared/components/list/list.component.ts @@ -436,7 +436,6 @@ export class ListComponent implements OnInit, OnChanges, OnDestroy, AfterView map((f: ListFilter) => { const isFilteringByString = f.string ? !!f.string.length : false; const isFilteringByItems = Object.values(f.items).filter(value => !!value).length > 0; - console.log(f.items); return isFilteringByString || isFilteringByItems; }) ); diff --git a/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/endpoint-errors.handler.spec.ts b/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/endpoint-errors.handler.spec.ts index d61e91c2f4..957d91d1e5 100644 --- a/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/endpoint-errors.handler.spec.ts +++ b/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/endpoint-errors.handler.spec.ts @@ -1,11 +1,12 @@ import { Action } from '@ngrx/store'; + +import { StratosBaseCatalogueEntity } from '../../../../core/src/core/entity-catalogue/entity-catalogue-entity'; import { SendEventAction } from '../../actions/internal-events.actions'; +import { EntitySchema } from '../../helpers/entity-schema'; import { InternalEventSeverity } from '../../types/internal-events.types'; import { APISuccessOrFailedAction, EntityRequestAction } from '../../types/request.types'; import { endpointErrorsHandlerFactory } from './endpoint-errors.handler'; import { JetstreamError } from './handle-multi-endpoints.pipe'; -import { StratosBaseCatalogueEntity } from '../../../../core/src/core/entity-catalogue/entity-catalogue-entity'; -import { EntitySchema } from '../../helpers/entity-schema'; describe('endpoint-error-handler', () => { @@ -21,7 +22,6 @@ describe('endpoint-error-handler', () => { label: 'Entity', labelPlural: 'Entities', }); - console.log(entity); const endpointGuid = '123GUID'; const requestType = 'fetch'; const error = new JetstreamError( diff --git a/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/endpoint-errors.handler.ts b/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/endpoint-errors.handler.ts index 2e728fbbb3..ee64e88336 100644 --- a/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/endpoint-errors.handler.ts +++ b/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/endpoint-errors.handler.ts @@ -14,7 +14,7 @@ export const endpointErrorsHandlerFactory = (actionDispatcher: ActionDispatcher) errors: JetstreamError[] ) => { errors.forEach(error => { - const entityErrorAction = catalogueEntity.getRequestAction('failure', requestType); + const entityErrorAction = catalogueEntity.getRequestAction('failure', requestType, action); // Dispatch a error action for the specific endpoint that's failed const fakedAction = { ...action, endpointGuid: error.guid }; const errorMessage = error.errorResponse diff --git a/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/fail-entity-request.handler.ts b/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/fail-entity-request.handler.ts index ac450d079d..3e70253cac 100644 --- a/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/fail-entity-request.handler.ts +++ b/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/fail-entity-request.handler.ts @@ -1,6 +1,7 @@ -import { SucceedOrFailEntityRequestHandler } from '../entity-request-pipeline.types'; -import { WrapperRequestActionFailed } from '../../types/request.types'; import { RecursiveDeleteFailed } from '../../effects/recursive-entity-delete.effect'; +import { WrapperRequestActionFailed } from '../../types/request.types'; +import { SucceedOrFailEntityRequestHandler } from '../entity-request-pipeline.types'; + // This might not be needed export const failedEntityHandler: SucceedOrFailEntityRequestHandler = ( actionDispatcher, @@ -9,7 +10,7 @@ export const failedEntityHandler: SucceedOrFailEntityRequestHandler = ( action, recursivelyDeleting ) => { - const entityAction = catalogueEntity.getRequestAction('failure', requestType); + const entityAction = catalogueEntity.getRequestAction('failure', requestType, action); actionDispatcher(entityAction); actionDispatcher(new WrapperRequestActionFailed('Api Request Failed', action, requestType)); if (recursivelyDeleting) { diff --git a/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/start-entity-request.handler.ts b/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/start-entity-request.handler.ts index fa476c2f35..df3eba374f 100644 --- a/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/start-entity-request.handler.ts +++ b/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/start-entity-request.handler.ts @@ -7,7 +7,7 @@ export const startEntityHandler: StartEntityRequestHandler = ( requestType, action ) => { - const entityAction = catalogueEntity.getRequestAction('start', requestType); + const entityAction = catalogueEntity.getRequestAction('start', requestType, action); actionDispatcher(new StartRequestAction(action, requestType)); actionDispatcher(entityAction); }; diff --git a/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/success-entity-request.handler.ts b/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/success-entity-request.handler.ts index d728a9b1f4..e05db9815d 100644 --- a/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/success-entity-request.handler.ts +++ b/src/frontend/packages/store/src/entity-request-pipeline/entity-request-base-handlers/success-entity-request.handler.ts @@ -1,7 +1,7 @@ -import { SucceedOrFailEntityRequestHandler } from '../entity-request-pipeline.types'; -import { WrapperRequestActionSuccess } from '../../types/request.types'; -import { RecursiveDeleteComplete } from '../../effects/recursive-entity-delete.effect'; import { ClearPaginationOfEntity, ClearPaginationOfType } from '../../actions/pagination.actions'; +import { RecursiveDeleteComplete } from '../../effects/recursive-entity-delete.effect'; +import { WrapperRequestActionSuccess } from '../../types/request.types'; +import { SucceedOrFailEntityRequestHandler } from '../entity-request-pipeline.types'; export const successEntityHandler: SucceedOrFailEntityRequestHandler = ( actionDispatcher, @@ -11,7 +11,7 @@ export const successEntityHandler: SucceedOrFailEntityRequestHandler = ( data, recursivelyDeleting ) => { - const entityAction = catalogueEntity.getRequestAction('success', requestType); + const entityAction = catalogueEntity.getRequestAction('success', requestType, action, data); if ( !action.updatingKey && (requestType === 'create' || requestType === 'delete') diff --git a/src/frontend/packages/store/src/entity-request-pipeline/entity-request-pipeline.ts b/src/frontend/packages/store/src/entity-request-pipeline/entity-request-pipeline.ts index 4b904766fa..df0051b163 100644 --- a/src/frontend/packages/store/src/entity-request-pipeline/entity-request-pipeline.ts +++ b/src/frontend/packages/store/src/entity-request-pipeline/entity-request-pipeline.ts @@ -1,19 +1,19 @@ import { Action, Store } from '@ngrx/store'; -import { map, tap, catchError } from 'rxjs/operators'; +import { of } from 'rxjs'; +import { catchError, map, tap } from 'rxjs/operators'; + import { StratosBaseCatalogueEntity } from '../../../core/src/core/entity-catalogue/entity-catalogue-entity'; import { entityCatalogue } from '../../../core/src/core/entity-catalogue/entity-catalogue.service'; -import { IStratosEntityDefinition } from '../../../core/src/core/entity-catalogue/entity-catalogue.types'; import { AppState, InternalAppState } from '../app-state'; +import { RecursiveDelete } from '../effects/recursive-entity-delete.effect'; import { ApiRequestTypes, getRequestTypeFromMethod } from '../reducers/api-request-reducer/request-helpers'; import { EntityRequestAction } from '../types/request.types'; import { failedEntityHandler } from './entity-request-base-handlers/fail-entity-request.handler'; +import { jetstreamErrorHandler } from './entity-request-base-handlers/jetstream-error.handler'; import { startEntityHandler } from './entity-request-base-handlers/start-entity-request.handler'; import { successEntityHandler } from './entity-request-base-handlers/success-entity-request.handler'; import { EntityRequestPipeline, PreApiRequest, SuccessfulApiResponseDataMapper } from './entity-request-pipeline.types'; import { PipelineHttpClient } from './pipline-http-client.service'; -import { RecursiveDelete } from '../effects/recursive-entity-delete.effect'; -import { jetstreamErrorHandler } from './entity-request-base-handlers/jetstream-error.handler'; -import { of } from 'rxjs'; export interface PipelineFactoryConfig { store: Store; @@ -65,7 +65,7 @@ export const apiRequestPipelineFactory = ( failedEntityHandler(actionDispatcher, catalogueEntity, requestType, action, response.response, recursivelyDelete); } }), - map(() => catalogueEntity.getRequestAction('complete', requestType)), + map(() => catalogueEntity.getRequestAction('complete', requestType, action)), catchError(error => { // TODO We should pass the endpoint ids to this so we can correctly map the error to the endpoint. jetstreamErrorHandler( diff --git a/src/frontend/packages/store/src/reducers/api-request-reducer/request-helpers.ts b/src/frontend/packages/store/src/reducers/api-request-reducer/request-helpers.ts index c5273ed61a..d196261ce8 100644 --- a/src/frontend/packages/store/src/reducers/api-request-reducer/request-helpers.ts +++ b/src/frontend/packages/store/src/reducers/api-request-reducer/request-helpers.ts @@ -1,6 +1,7 @@ import { RequestMethod } from '@angular/http'; import { Store } from '@ngrx/store'; +import { StratosBaseCatalogueEntity } from '../../../../core/src/core/entity-catalogue/entity-catalogue-entity'; import { entityCatalogue } from '../../../../core/src/core/entity-catalogue/entity-catalogue.service'; import { pathGet } from '../../../../core/src/core/utils.service'; import { APIResponse } from '../../actions/request.actions'; @@ -10,16 +11,15 @@ import { NormalizedResponse } from '../../types/api.types'; import { PaginatedAction } from '../../types/pagination.types'; import { APISuccessOrFailedAction, + EntityRequestAction, ICFAction, InternalEndpointError, SingleEntityAction, StartRequestAction, WrapperRequestActionFailed, WrapperRequestActionSuccess, - EntityRequestAction, } from '../../types/request.types'; import { defaultDeletingActionState, getDefaultRequestState, RequestInfoState, rootUpdatingKey } from './types'; -import { StratosBaseCatalogueEntity } from '../../../../core/src/core/entity-catalogue/entity-catalogue-entity'; export function getEntityRequestState( state: BaseRequestState, @@ -215,7 +215,7 @@ export function getFailApiRequestActions( internalEndpointError?: InternalEndpointError, ) { return [ - new APISuccessOrFailedAction(catalogueEntity.getRequestAction('failure', requestType).type, apiAction, error.message), + new APISuccessOrFailedAction(catalogueEntity.getRequestAction('failure', requestType, apiAction).type, apiAction, error.message), new WrapperRequestActionFailed( error.message, apiAction, diff --git a/src/frontend/packages/store/src/types/request.types.ts b/src/frontend/packages/store/src/types/request.types.ts index 0569e87353..9ec26f0387 100644 --- a/src/frontend/packages/store/src/types/request.types.ts +++ b/src/frontend/packages/store/src/types/request.types.ts @@ -1,3 +1,4 @@ +import { HttpRequest } from '@angular/common/http'; import { RequestOptions } from '@angular/http'; import { Action } from '@ngrx/store'; @@ -7,7 +8,6 @@ import { EntitySchema } from '../helpers/entity-schema'; import { ApiRequestTypes } from '../reducers/api-request-reducer/request-helpers'; import { NormalizedResponse } from './api.types'; import { PaginatedAction } from './pagination.types'; -import { HttpRequest } from '@angular/common/http'; export interface SingleEntityAction { entityType: string; @@ -33,6 +33,11 @@ export enum RequestEntityLocation { export type RequestActionEntity = EntitySchema | EntitySchema[]; export interface EntityRequestAction extends EntityCatalogueEntityConfig, RequestAction { + /** + * This is just to maintain backwards compatibility while transitioning + * to entity pipeline proper usage + */ + actions?: string[]; entity?: RequestActionEntity; /** * This is used for multiaction lists where the deleted entity From 1d4a58d54cfc9bb280a3e4ac9f3a3a88b7107d39 Mon Sep 17 00:00:00 2001 From: Nathan Jones Date: Tue, 20 Aug 2019 10:52:07 +0100 Subject: [PATCH 2/4] Merge changes --- .../quota-definition-form/quota-definition-form.component.ts | 2 +- .../space-quota-definition-form.component.ts | 2 +- .../list-types/cf-quotas/cf-quotas-data-source.service.ts | 4 +--- .../cf-space-quotas/cf-space-quotas-data-source.service.ts | 4 +--- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/frontend/packages/core/src/features/cloud-foundry/quota-definition-form/quota-definition-form.component.ts b/src/frontend/packages/core/src/features/cloud-foundry/quota-definition-form/quota-definition-form.component.ts index dcaa37dda0..81ee69e76b 100644 --- a/src/frontend/packages/core/src/features/cloud-foundry/quota-definition-form/quota-definition-form.component.ts +++ b/src/frontend/packages/core/src/features/cloud-foundry/quota-definition-form/quota-definition-form.component.ts @@ -4,7 +4,6 @@ import { ActivatedRoute } from '@angular/router'; import { Store } from '@ngrx/store'; import { Observable, Subscription } from 'rxjs'; import { filter, map, tap } from 'rxjs/operators'; -import { createEntityRelationPaginationKey } from '../../../../../store/src/helpers/entity-relations/entity-relations.types'; import { getPaginationObservables } from '../../../../../store/src/reducers/pagination-reducer/pagination-reducer.helper'; import { APIResource } from '../../../../../store/src/types/api.types'; import { IQuotaDefinition } from '../../../core/cf-api.types'; @@ -14,6 +13,7 @@ import { CFAppState } from '../../../../../cloud-foundry/src/cf-app-state'; import { endpointSchemaKey } from '../../../../../store/src/helpers/entity-factory'; import { GetQuotaDefinitions } from '../../../../../cloud-foundry/src/actions/quota-definitions.actions'; import { quotaDefinitionEntityType, cfEntityFactory } from '../../../../../cloud-foundry/src/cf-entity-factory'; +import { createEntityRelationPaginationKey } from '../../../../../cloud-foundry/src/entity-relations/entity-relations.types'; @Component({ diff --git a/src/frontend/packages/core/src/features/cloud-foundry/space-quota-definition-form/space-quota-definition-form.component.ts b/src/frontend/packages/core/src/features/cloud-foundry/space-quota-definition-form/space-quota-definition-form.component.ts index df56bdd4f3..529de09593 100644 --- a/src/frontend/packages/core/src/features/cloud-foundry/space-quota-definition-form/space-quota-definition-form.component.ts +++ b/src/frontend/packages/core/src/features/cloud-foundry/space-quota-definition-form/space-quota-definition-form.component.ts @@ -7,7 +7,6 @@ import { filter, map, tap } from 'rxjs/operators'; import { AppState } from '../../../../../store/src/app-state'; import { endpointSchemaKey, entityFactory } from '../../../../../store/src/helpers/entity-factory'; -import { createEntityRelationPaginationKey } from '../../../../../store/src/helpers/entity-relations/entity-relations.types'; import { getPaginationObservables } from '../../../../../store/src/reducers/pagination-reducer/pagination-reducer.helper'; import { APIResource } from '../../../../../store/src/types/api.types'; import { IQuotaDefinition } from '../../../core/cf-api.types'; @@ -15,6 +14,7 @@ import { safeUnsubscribe } from '../../../core/utils.service'; import { PaginationMonitorFactory } from '../../../shared/monitors/pagination-monitor.factory'; import { GetOrganizationSpaceQuotaDefinitions } from '../../../../../cloud-foundry/src/actions/quota-definitions.actions'; import { spaceQuotaEntityType } from '../../../../../cloud-foundry/src/cf-entity-factory'; +import { createEntityRelationPaginationKey } from '../../../../../cloud-foundry/src/entity-relations/entity-relations.types'; @Component({ diff --git a/src/frontend/packages/core/src/shared/components/list/list-types/cf-quotas/cf-quotas-data-source.service.ts b/src/frontend/packages/core/src/shared/components/list/list-types/cf-quotas/cf-quotas-data-source.service.ts index 2a5f583b28..6097f6bed2 100644 --- a/src/frontend/packages/core/src/shared/components/list/list-types/cf-quotas/cf-quotas-data-source.service.ts +++ b/src/frontend/packages/core/src/shared/components/list/list-types/cf-quotas/cf-quotas-data-source.service.ts @@ -5,9 +5,6 @@ import { distinctUntilChanged, map } from 'rxjs/operators'; import { endpointSchemaKey, } from '../../../../../../../store/src/helpers/entity-factory'; -import { - createEntityRelationPaginationKey, -} from '../../../../../../../store/src/helpers/entity-relations/entity-relations.types'; import { APIResource } from '../../../../../../../store/src/types/api.types'; import { EntityMonitor } from '../../../../monitors/entity-monitor'; import { ListDataSource } from '../../data-sources-controllers/list-data-source'; @@ -17,6 +14,7 @@ import { GetQuotaDefinitions } from '../../../../../../../cloud-foundry/src/acti import { getRowMetadata } from '../../../../../../../cloud-foundry/src/features/cloud-foundry/cf.helpers'; import { CFAppState } from '../../../../../../../cloud-foundry/src/cf-app-state'; import { quotaDefinitionEntityType, cfEntityFactory } from '../../../../../../../cloud-foundry/src/cf-entity-factory'; +import { createEntityRelationPaginationKey } from '../../../../../../../cloud-foundry/src/entity-relations/entity-relations.types'; export class CfQuotasDataSourceService extends ListDataSource { diff --git a/src/frontend/packages/core/src/shared/components/list/list-types/cf-space-quotas/cf-space-quotas-data-source.service.ts b/src/frontend/packages/core/src/shared/components/list/list-types/cf-space-quotas/cf-space-quotas-data-source.service.ts index 1ab0450b9c..f55d1705d3 100644 --- a/src/frontend/packages/core/src/shared/components/list/list-types/cf-space-quotas/cf-space-quotas-data-source.service.ts +++ b/src/frontend/packages/core/src/shared/components/list/list-types/cf-space-quotas/cf-space-quotas-data-source.service.ts @@ -2,9 +2,6 @@ import { Store } from '@ngrx/store'; import { of } from 'rxjs'; import { distinctUntilChanged, map } from 'rxjs/operators'; -import { - createEntityRelationPaginationKey, -} from '../../../../../../../store/src/helpers/entity-relations/entity-relations.types'; import { APIResource } from '../../../../../../../store/src/types/api.types'; import { EntityMonitor } from '../../../../monitors/entity-monitor'; import { ListDataSource } from '../../data-sources-controllers/list-data-source'; @@ -15,6 +12,7 @@ import { GetOrganizationSpaceQuotaDefinitions } from '../../../../../../../cloud import { getRowMetadata } from '../../../../../../../cloud-foundry/src/features/cloud-foundry/cf.helpers'; import { CFAppState } from '../../../../../../../cloud-foundry/src/cf-app-state'; import { cfEntityFactory, spaceQuotaEntityType } from '../../../../../../../cloud-foundry/src/cf-entity-factory'; +import { createEntityRelationPaginationKey } from '../../../../../../../cloud-foundry/src/entity-relations/entity-relations.types'; export class CfOrgSpaceQuotasDataSourceService extends ListDataSource { From 2c0aa048cef64f7b99db3c9e49a1c0809019a5ee Mon Sep 17 00:00:00 2001 From: Nathan Jones Date: Tue, 20 Aug 2019 11:17:45 +0100 Subject: [PATCH 3/4] Fixed user apce roles data source --- .../cf-users-space-roles-data-source.service.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-users-org-space-roles/cf-users-space-roles-data-source.service.ts b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-users-org-space-roles/cf-users-space-roles-data-source.service.ts index b96fe7bad3..dce7de79cc 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-users-org-space-roles/cf-users-space-roles-data-source.service.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-users-org-space-roles/cf-users-space-roles-data-source.service.ts @@ -18,11 +18,15 @@ import { CurrentUserPermissionsService } from '../../../../../../../core/src/cor import { IListConfig } from '../../../../../../../core/src/shared/components/list/list.component.types'; export class CfUsersSpaceRolesDataSourceService extends ListDataSource> { + constructor( + cfGuid: string, + orgGuid: string, spaceGuid: string, store: Store, userPerms: CurrentUserPermissionsService, - listConfig?: IListConfig) { + listConfig?: IListConfig + ) { const paginationKey = cfUserEntityType + '-' + orgGuid; const action = new GetAllOrganizationSpacesWithOrgs( paginationKey, From 06c6d1c58c826dd458098534bc7e157bd3f6beb2 Mon Sep 17 00:00:00 2001 From: Nathan Jones Date: Tue, 20 Aug 2019 13:36:50 +0100 Subject: [PATCH 4/4] Tidy up get request action method. --- .../entity-catalogue-entity.ts | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/src/frontend/packages/core/src/core/entity-catalogue/entity-catalogue-entity.ts b/src/frontend/packages/core/src/core/entity-catalogue/entity-catalogue-entity.ts index 070a4b518f..87b772c4d5 100644 --- a/src/frontend/packages/core/src/core/entity-catalogue/entity-catalogue-entity.ts +++ b/src/frontend/packages/core/src/core/entity-catalogue/entity-catalogue-entity.ts @@ -136,36 +136,33 @@ export class StratosBaseCatalogueEntity< subType }; } - - public getRequestAction( - actionString: 'start' | 'success' | 'failure' | 'complete', - requestType: ApiRequestTypes, - action?: EntityRequestAction, - response?: any): APISuccessOrFailedAction { - // backward compatibility with the old actions. - // it should be removed after everything is based on the new flow + // Backward compatibility with the old actions. + // This should be removed after everything is based on the new flow + private getLegacyTypeFromAction( + action: EntityRequestAction, + actionString: 'start' | 'success' | 'failure' | 'complete' + ) { if (action && action.actions) { - let type; - switch (actionString) { case 'success': - type = action.actions[1]; - break; + return action.actions[1]; case 'failure': - type = action.actions[2]; - break; + return action.actions[2]; case 'start': - type = action.actions[0]; - break; - } - - if (type) { - return new APISuccessOrFailedAction(type, action, response); + return action.actions[0]; } } + return null; + } - return new APISuccessOrFailedAction(`@stratos/${this.entityKey}/${requestType}/${actionString}`, - action, response); + public getRequestAction( + actionString: 'start' | 'success' | 'failure' | 'complete', + requestType: ApiRequestTypes, + action?: EntityRequestAction, + response?: any + ): APISuccessOrFailedAction { + const type = this.getLegacyTypeFromAction(action, actionString) || `@stratos/${this.entityKey}/${requestType}/${actionString}`; + return new APISuccessOrFailedAction(type, action, response); } public getNormalizedEntityData(entities: Y | Y[], schemaKey?: string): NormalizedResponse {