Skip to content

Commit

Permalink
Merge pull request cloudfoundry#3670 from cloudfoundry-incubator/enti…
Browse files Browse the repository at this point in the history
…ty-catalogue-store-service-wall-2

Entity catalogue: Service Instance Wall Fix #1
  • Loading branch information
richard-cox authored Jul 9, 2019
2 parents 3f495c8 + ae6d4cd commit a78fd40
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/frontend/packages/cloud-foundry/src/cf-entity-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const serviceBrokerEntityType = 'serviceBroker';
export const userProvidedServiceInstanceEntityType = 'userProvidedServiceInstance';

export const spaceWithOrgEntityType = 'spaceWithOrg';
export const serviceInstancesWithspaceEntityType = 'serviceInstancesWithSpace';
export const serviceInstancesWithSpaceEntityType = 'serviceInstancesWithSpace';
export const serviceInstancesWithNoBindingsEntityType = 'serviceInstanceWithNoBindings';
export const serviceBindingNoBindingsEntityType = 'serviceBindingNoBindings';

Expand Down Expand Up @@ -272,7 +272,7 @@ const ServiceInstancesWithSpaceSchema = new CFEntitySchema(serviceInstancesEntit
service: ServiceSchema
}
}, { idAttribute: getAPIResourceGuid });
entityCache[serviceInstancesWithspaceEntityType] = ServiceInstancesWithSpaceSchema;
entityCache[serviceInstancesWithSpaceEntityType] = ServiceInstancesWithSpaceSchema;

const ServiceInstancesWithNoBindingsSchema = new CFEntitySchema(serviceInstancesEntityType, {
entity: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import {
serviceEntityType,
serviceInstancesEntityType,
serviceInstancesWithNoBindingsEntityType,
serviceInstancesWithspaceEntityType,
serviceInstancesWithSpaceEntityType,
servicePlanEntityType,
servicePlanVisibilityEntityType,
spaceEntityType,
Expand Down Expand Up @@ -301,7 +301,7 @@ function generateCFServiceInstanceEntity(endpointDefinition: IStratosEndpointDef
type: serviceInstancesEntityType,
schema: {
default: cfEntityFactory(serviceInstancesEntityType),
[serviceInstancesWithspaceEntityType]: cfEntityFactory(serviceInstancesWithspaceEntityType),
[serviceInstancesWithSpaceEntityType]: cfEntityFactory(serviceInstancesWithSpaceEntityType),
[serviceInstancesWithNoBindingsEntityType]: cfEntityFactory(serviceInstancesWithNoBindingsEntityType),
},
label: 'Marketplace Service Instance',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ export class StratosBaseCatalogueEntity<T extends IEntityMetadata = IEntityMetad
* If no schemaKey is provided then the default schema will be returned
*/
public getSchema(schemaKey?: string) {
// TODO: schemaKey - ensure wherever this is called it contains the correct schemaKey (with respect to any config
// EntityCatalogueEntityConfig that may use a schemeKey different than that provided by entityCatalogue.getEntity's)
// TODO(NJ) We should do a better job at typeing schemax
// schema always gets changed to a EntityCatalogueSchamas.
const catalogueSchema = (this.definition.schema as EntityCatalogueSchemas);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import { ServicePlanAccessibility } from './services.service';


export const getSvcAvailability = (servicePlan: APIResource<IServicePlan>,
serviceBroker: APIResource<IServiceBroker>,
allServicePlanVisibilities: APIResource<IServicePlanVisibility>[]) => {
serviceBroker: APIResource<IServiceBroker>,
allServicePlanVisibilities: APIResource<IServicePlanVisibility>[]) => {
const svcAvailability = {
isPublic: false, spaceScoped: false, hasVisibilities: false, guid: servicePlan.metadata.guid, spaceGuid: null
};
Expand Down Expand Up @@ -79,6 +79,8 @@ export const isEditServiceInstanceMode = (activatedRoute: ActivatedRoute) => {

export const getServiceInstancesInCf = (cfGuid: string, store: Store<CFAppState>, paginationMonitorFactory: PaginationMonitorFactory) => {
const paginationKey = createEntityRelationPaginationKey(serviceInstancesEntityType, cfGuid);
// TODO: schemaKey - Dispatches the action which has the correct schema key (SI with space), however uses incorrect schema to denormalise
// so entities$ does not contain space
return getPaginationObservables<APIResource<IServiceInstance>>({
store,
action: new GetServiceInstances(cfGuid, paginationKey),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ export abstract class ListDataSource<T, A = T> extends DataSource<T> implements
private getSourceSchema(schema: EntitySchema | MultiActionConfig) {
if (schema instanceof MultiActionConfig) {
const { paginationAction } = schema.schemaConfigs[0];
// TODO: schemaKey - getSchema needs to accept an EntityCatalogueEntityConfig with the correct schemaKey
const catalogueEntity = entityCatalogue.getEntity(paginationAction.endpointType, paginationAction.entityType);
return catalogueEntity.getSchema(paginationAction.schemaKey);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
serviceBindingEntityType,
serviceEntityType,
serviceInstancesEntityType,
serviceInstancesWithspaceEntityType,
serviceInstancesWithSpaceEntityType,
servicePlanEntityType,
spaceEntityType,
} from '../../../../../../../cloud-foundry/src/cf-entity-factory';
Expand All @@ -31,11 +31,11 @@ export class CfSpacesServiceInstancesDataSource extends ListDataSource<APIResour
createEntityRelationKey(serviceInstancesEntityType, spaceEntityType),
createEntityRelationKey(serviceBindingEntityType, applicationEntityType),
], true, false);
action.entity = [cfEntityFactory(serviceInstancesWithspaceEntityType)];
action.entity = [cfEntityFactory(serviceInstancesWithSpaceEntityType)];
super({
store,
action,
schema: cfEntityFactory(serviceInstancesWithspaceEntityType),
schema: cfEntityFactory(serviceInstancesWithSpaceEntityType),
getRowUniqueId: getRowMetadata,
paginationKey,
// This would normally be fetched inline, however some of the SI's children will be missing if the SI was fetched by the org
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ export class ServiceInstanceCardComponent extends CardCell<APIResource<IServiceI
this.cfOrgSpace = new CfOrgSpaceLabelService(
this.store,
this.cfGuid,
row.entity.space.entity.organization_guid,
// TODO: schemaKey - `space` is null due to the incorrect schema used when fetching the service instance
// (see service instance wall data source)
// row.entity.space.entity.organization_guid,
'junk',
row.entity.space_guid);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
serviceInstancesEntityType,
userProvidedServiceInstanceEntityType,
} from '../../../../../../../cloud-foundry/src/cf-entity-factory';
import { getCFEntityKey } from '../../../../../../../cloud-foundry/src/cf-entity-helpers';
import { ListView } from '../../../../../../../store/src/actions/list.actions';
import { CFAppState } from '../../../../../../../store/src/app-state';
import { CurrentUserPermissionsService } from '../../../../../core/current-user-permissions.service';
Expand Down Expand Up @@ -38,8 +39,8 @@ export class ServiceInstancesWallListConfigService extends CfServiceInstancesLis
enableTextFilter = true;
defaultView = 'cards' as ListView;
cardComponent = new CardMultiActionComponents({
[serviceInstancesEntityType]: ServiceInstanceCardComponent,
[userProvidedServiceInstanceEntityType]: UserProvidedServiceInstanceCardComponent
[getCFEntityKey(serviceInstancesEntityType)]: ServiceInstanceCardComponent,
[getCFEntityKey(userProvidedServiceInstanceEntityType)]: UserProvidedServiceInstanceCardComponent
});
viewType = ListViewTypes.BOTH;
pageSizeOptions = defaultPaginationPageSizeOptionsCards;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ export class PaginationMonitor<T = any, Y extends AppState = GeneralEntityAppSta
}

private denormalizePage(page: string[], schema: normalizrSchema.Entity, allEntities: GeneralRequestDataState) {
// TODO: schemaKey - the schema passed must come from a correct EntityCatalogueEntityConfig with schemaKey populated
return page.length
? denormalize(page, [schema], allEntities).filter(ent => !!ent)
: [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
serviceBindingNoBindingsEntityType,
serviceEntityType,
serviceInstancesEntityType,
serviceInstancesWithspaceEntityType,
serviceInstancesWithSpaceEntityType,
servicePlanEntityType,
spaceEntityType,
} from '../../../cloud-foundry/src/cf-entity-factory';
Expand Down Expand Up @@ -43,7 +43,7 @@ export class GetServiceInstances
this.options.params = new URLSearchParams();
}
actions = getActions('Service Instances', 'Get all');
entity = [cfEntityFactory(serviceInstancesWithspaceEntityType)];
entity = [cfEntityFactory(serviceInstancesWithSpaceEntityType)];
entityType = serviceInstancesEntityType;
options: RequestOptions;
initialParams = {
Expand All @@ -70,7 +70,7 @@ export class GetServiceInstance
this.options.params = new URLSearchParams();
}
actions = getActions('Service Instances', 'Get particular instance');
entity = [cfEntityFactory(serviceInstancesWithspaceEntityType)];
entity = [cfEntityFactory(serviceInstancesWithSpaceEntityType)];
entityType = serviceInstancesEntityType;
options: RequestOptions;
}
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/packages/store/src/actions/space.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
routeEntityType,
serviceEntityType,
serviceInstancesEntityType,
serviceInstancesWithspaceEntityType,
serviceInstancesWithSpaceEntityType,
servicePlanEntityType,
spaceEntityType,
spaceWithOrgEntityType,
Expand Down Expand Up @@ -273,7 +273,7 @@ export class GetServiceInstancesForSpace
this.parentGuid = spaceGuid;
}
actions = getActions('Space', 'Get all service instances');
entity = [cfEntityFactory(serviceInstancesWithspaceEntityType)];
entity = [cfEntityFactory(serviceInstancesWithSpaceEntityType)];
entityType = serviceInstancesEntityType;
options: RequestOptions;
initialParams = {
Expand Down

0 comments on commit a78fd40

Please sign in to comment.