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

Commit

Permalink
Remove dependencies between store and core that have crept in (#4517)
Browse files Browse the repository at this point in the history
* Remove dependencies between store and core that have crept in

* Fix issue with unit tests

* Import fixes and unit test fix
  • Loading branch information
nwmac committed Aug 21, 2020
1 parent 9a70ea6 commit 77d5a20
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { CoreTestingModule } from '../../../../test-framework/core-test.modules'
import { CoreModule } from '../../../core/core.module';
import { SidePanelService } from '../../../shared/services/side-panel.service';
import { SharedModule } from '../../../shared/shared.module';
import { MetricsModule } from '../../metrics/metrics.module';
import { ConnectEndpointComponent } from '../connect-endpoint/connect-endpoint.component';
import { ConnectEndpointConfig } from '../connect.service';
import { CredentialsAuthFormComponent } from './auth-forms/credentials-auth-form.component';
Expand Down Expand Up @@ -49,7 +50,8 @@ describe('ConnectEndpointDialogComponent', () => {
RouterTestingModule,
NoopAnimationsModule,
CoreTestingModule,
createBasicStoreModule()
createBasicStoreModule(),
MetricsModule,
]
}).overrideModule(BrowserDynamicTestingModule, {
set: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';

import { stratosEntityCatalog } from '../../../../store/src/stratos-entity-catalog';
import { CoreModule } from '../../core/core.module';
import { BaseEndpointAuth } from '../../core/endpoint-auth';
import { SharedModule } from '../../shared/shared.module';
import { MetricsEndpointDetailsComponent } from './metrics-endpoint-details/metrics-endpoint-details.component';
import { MetricsRoutingModule } from './metrics.routing';
Expand All @@ -23,4 +25,13 @@ import { MetricsService } from './services/metrics-service';
MetricsEndpointDetailsComponent,
]
})
export class MetricsModule { }
export class MetricsModule {

constructor() {
// Register the endpoint details component
// This is done here to break circular dependency - since the registration is done in the store package
// But the core package defines the component for the endpoint card details
stratosEntityCatalog.metricsEndpoint.setListComponent(MetricsEndpointDetailsComponent);
stratosEntityCatalog.metricsEndpoint.setAuthTypes([BaseEndpointAuth.UsernamePassword, BaseEndpointAuth.None]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
PaginationPageIteratorConfig,
} from '../../entity-request-pipeline/pagination-request-base-handlers/pagination-iterator.pipe';
import { EntityPipelineEntity, stratosEndpointGuidKey } from '../../entity-request-pipeline/pipeline.types';
import { EndpointAuthTypeConfig } from '../../extension-types';
import { EntitySchema } from '../../helpers/entity-schema';
import { endpointEntityType, STRATOS_ENDPOINT_TYPE, stratosEntityFactory } from '../../helpers/stratos-entity-factory';
import { EndpointModel } from '../../types/endpoint.types';
Expand Down Expand Up @@ -352,5 +353,20 @@ export class StratosCatalogEndpointEntity extends StratosBaseCatalogEntity<IEndp
}
});
}

public setListComponent(component: any) {
// Can only be set once
if (!this.definition.listDetailsComponent) {
(this.definition as any).listDetailsComponent = component;
}
}

public setAuthTypes(authTypes: EndpointAuthTypeConfig[]) {
// Can only be set once
if (!this.definition.authTypes || this.definition.authTypes.length === 0) {
(this.definition as any).authTypes = authTypes;
}
}

}

Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import {
EndpointListDetailsComponent,
} from '../../../core/src/shared/components/list/list-types/endpoint/endpoint-list.helpers';
import { EntitySchema } from '../helpers/entity-schema';
import { endpointEntityType, stratosEntityFactory } from '../helpers/stratos-entity-factory';
import { TestEntityCatalog } from './entity-catalog';
Expand All @@ -18,7 +15,7 @@ describe('EntityCatalogService', () => {
iconFont: 'stratos-icons',
logoUrl: '/core/assets/endpoint-icons/cloudfoundry.png',
authTypes: [],
listDetailsComponent: EndpointListDetailsComponent,
listDetailsComponent: 'Test Component',
} as IStratosEndpointDefinition;
}
function getDefaultSchema() {
Expand Down Expand Up @@ -136,7 +133,7 @@ describe('EntityCatalogService', () => {
...subtypeDefinition,
icon: 'cloud_foundry',
iconFont: 'stratos-icons',
listDetailsComponent: EndpointListDetailsComponent,
listDetailsComponent: 'Test Component',
schema: {
default: stratosEntityFactory(endpointEntityType)
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { TestBed, inject } from '@angular/core/testing';
import { InternalEventMonitorFactory } from './internal-event-monitor.factory';
import { SharedModule } from '../../../core/src/shared/shared.module';
import { inject, TestBed } from '@angular/core/testing';
import { StoreModule } from '@ngrx/store';

import { InternalEventMonitorFactory } from './internal-event-monitor.factory';


describe('InternalEventMonitorFactory', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [InternalEventMonitorFactory],
imports: [
SharedModule,
StoreModule.forRoot({})
]
});
Expand Down
24 changes: 8 additions & 16 deletions src/frontend/packages/store/src/stratos-entity-generator.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
import { BaseEndpointAuth } from '../../core/src/core/endpoint-auth';
import {
MetricsEndpointDetailsComponent,
} from '../../core/src/features/metrics/metrics-endpoint-details/metrics-endpoint-details.component';
import {
StratosBaseCatalogEntity,
StratosCatalogEndpointEntity,
StratosCatalogEntity,
} from '../../store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity';
} from './entity-catalog/entity-catalog-entity/entity-catalog-entity';
import { IStratosEntityDefinition } from './entity-catalog/entity-catalog.types';
import {
endpointEntityType,
STRATOS_ENDPOINT_TYPE,
stratosEntityFactory,
systemInfoEntityType,
userFavouritesEntityType,
userProfileEntityType,
} from '../../store/src/helpers/stratos-entity-factory';
import {
addOrUpdateUserFavoriteMetadataReducer,
deleteUserFavoriteMetadataReducer,
} from '../../store/src/reducers/favorite.reducer';
import { systemEndpointsReducer } from '../../store/src/reducers/system-endpoints.reducer';
import { EndpointModel } from '../../store/src/types/endpoint.types';
import { IStratosEntityDefinition } from './entity-catalog/entity-catalog.types';
} from './helpers/stratos-entity-factory';
import { addOrUpdateUserFavoriteMetadataReducer, deleteUserFavoriteMetadataReducer } from './reducers/favorite.reducer';
import { systemEndpointsReducer } from './reducers/system-endpoints.reducer';
import {
EndpointActionBuilder,
endpointActionBuilder,
Expand All @@ -33,6 +25,7 @@ import {
userProfileActionBuilder,
} from './stratos-action-builders';
import { stratosEntityCatalog } from './stratos-entity-catalog';
import { EndpointModel } from './types/endpoint.types';
import { SystemInfo } from './types/system.types';
import { UserFavorite } from './types/user-favorites.types';
import { UserProfileInfo } from './types/user-profile.types';
Expand Down Expand Up @@ -151,9 +144,8 @@ function generateMetricsEndpoint() {
labelPlural: 'Metrics',
tokenSharing: true,
logoUrl: '/core/assets/endpoint-icons/metrics.svg',
authTypes: [BaseEndpointAuth.UsernamePassword, BaseEndpointAuth.None],
renderPriority: 1,
listDetailsComponent: MetricsEndpointDetailsComponent,
authTypes: [],
renderPriority: 1
},
metadata => `/endpoints/metrics/${metadata.guid}`
)
Expand Down

0 comments on commit 77d5a20

Please sign in to comment.