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

Typed access to actions and entities via catalog entity #4247

Merged
merged 21 commits into from
May 15, 2020
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { NgModule } from '@angular/core';

import { generateCFEntities } from '../../cloud-foundry/src/cf-entity-generator';
import { CATALOGUE_ENTITIES, EntityCatalogFeatureModule } from '../../store/src/entity-catalog.module';
import { entityCatalog, TestEntityCatalog } from '../../store/src/entity-catalog/entity-catalog.service';
import { entityCatalog, TestEntityCatalog } from '../../store/src/entity-catalog/entity-catalog';
import { generateASEntities } from './store/autoscaler-entity-generator';

@NgModule({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ConfirmationDialogConfig } from '../../../../core/src/shared/components
import { ConfirmationDialogService } from '../../../../core/src/shared/components/confirmation-dialog.service';
import { RouterNav } from '../../../../store/src/actions/router.actions';
import { AppState } from '../../../../store/src/app-state';
import { entityCatalog } from '../../../../store/src/entity-catalog/entity-catalog.service';
import { entityCatalog } from '../../../../store/src/entity-catalog/entity-catalog';
import { EntityService } from '../../../../store/src/entity-service';
import { EntityServiceFactory } from '../../../../store/src/entity-service-factory.service';
import { PaginationMonitorFactory } from '../../../../store/src/monitors/pagination-monitor.factory';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { inject, TestBed } from '@angular/core/testing';
import { createEmptyStoreModule } from '@stratos/store/testing';

import { ApplicationsModule } from '../../../../cloud-foundry/src/features/applications/applications.module';
import { EntityServiceFactory } from '../../../../store/src/entity-service-factory.service';
import { createEmptyStoreModule } from '@stratos/store/testing';
import { EntityMonitorFactory } from '../../../../store/src/monitors/entity-monitor.factory.service';
import { EditAutoscalerPolicyService } from './edit-autoscaler-policy-service';

describe('EditAutoscalerPolicyService', () => {
Expand All @@ -11,6 +12,7 @@ describe('EditAutoscalerPolicyService', () => {
providers: [
EditAutoscalerPolicyService,
EntityServiceFactory,
EntityMonitorFactory
],
imports: [
ApplicationsModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import { CommonModule } from '@angular/common';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { createEmptyStoreModule } from '@stratos/store/testing';

import { ApplicationService } from '../../../../cloud-foundry/src/features/applications/application.service';
import {
RunningInstancesComponent,
} from '../../../../cloud-foundry/src/shared/components/running-instances/running-instances.component';
import { CoreModule } from '../../../../core/src/core/core.module';
import { ApplicationStateService } from '../../../../core/src/shared/components/application-state/application-state.service';
import {
CopyToClipboardComponent,
} from '../../../../core/src/shared/components/copy-to-clipboard/copy-to-clipboard.component';
import { MetadataItemComponent } from '../../../../core/src/shared/components/metadata-item/metadata-item.component';
import { ApplicationServiceMock } from '../../../../core/test-framework/application-service-helper';
import { AppTestModule } from '../../../../core/test-framework/core-test.helper';
import { EntityCatalogHelper } from '../../../../store/src/entity-catalog/entity-catalog-entity/entity-catalog.service';
import { EntityMonitorFactory } from '../../../../store/src/monitors/entity-monitor.factory.service';
import { PaginationMonitorFactory } from '../../../../store/src/monitors/pagination-monitor.factory';
import { ApplicationServiceMock } from '../../../../core/test-framework/application-service-helper';
import { createEmptyStoreModule } from '@stratos/store/testing';
import { CfAutoscalerTestingModule } from '../../cf-autoscaler-testing.module';
import { CardAutoscalerDefaultComponent } from './card-autoscaler-default.component';
import { CopyToClipboardComponent } from '../../../../core/src/shared/components/copy-to-clipboard/copy-to-clipboard.component';

describe('CardAutoscalerDefaultComponent', () => {
let component: CardAutoscalerDefaultComponent;
Expand All @@ -35,12 +39,14 @@ describe('CardAutoscalerDefaultComponent', () => {
CommonModule,
NoopAnimationsModule,
createEmptyStoreModule(),
AppTestModule
],
providers: [
{ provide: ApplicationService, useClass: ApplicationServiceMock },
ApplicationStateService,
EntityMonitorFactory,
PaginationMonitorFactory,
EntityCatalogHelper
]
})
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ import { HttpBackend, HttpClient, HttpClientModule } from '@angular/common/http'
import { HttpTestingController } from '@angular/common/http/testing';
import { inject, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { createEmptyStoreModule } from '@stratos/store/testing';

import { GetApplication } from '../../../../../cloud-foundry/src/actions/application.actions';
import { cfEntityFactory } from '../../../../../cloud-foundry/src/cf-entity-factory';
import { applicationEntityType } from '../../../../../cloud-foundry/src/cf-entity-types';
import { ApplicationsModule } from '../../../../../cloud-foundry/src/features/applications/applications.module';
import { CoreModule } from '../../../../../core/src/core/core.module';
import { EntityServiceFactory } from '../../../../../store/src/entity-service-factory.service';
import { SharedModule } from '../../../../../core/src/shared/shared.module';
import { generateTestApplicationServiceProvider } from '../../../../../core/test-framework/application-service-helper';
import { AppTestModule } from '../../../../../core/test-framework/core-test.helper';
import { generateTestEntityServiceProvider } from '../../../../../core/test-framework/entity-service.helper';
import { createEmptyStoreModule } from '@stratos/store/testing';
import { EntityCatalogHelper } from '../../../../../store/src/entity-catalog/entity-catalog-entity/entity-catalog.service';
import { EntityServiceFactory } from '../../../../../store/src/entity-service-factory.service';
import { EntityMonitorFactory } from '../../../../../store/src/monitors/entity-monitor.factory.service';
import { CfAutoscalerTestingModule } from '../../../cf-autoscaler-testing.module';
import { CfAppAutoscalerEventsConfigService } from './cf-app-autoscaler-events-config.service';

Expand All @@ -28,6 +31,8 @@ describe('CfAppAutoscalerEventsConfigService', () => {
{ provide: HttpBackend, useClass: HttpTestingController },
CfAppAutoscalerEventsConfigService,
EntityServiceFactory,
EntityMonitorFactory,
EntityCatalogHelper,
generateTestEntityServiceProvider(
appGuid,
cfEntityFactory(applicationEntityType),
Expand All @@ -45,6 +50,7 @@ describe('CfAppAutoscalerEventsConfigService', () => {
ApplicationsModule,
createEmptyStoreModule(),
RouterTestingModule,
AppTestModule
]
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* tslint:disable:max-line-length */
import { DatePipe } from '@angular/common';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { createEmptyStoreModule } from '@stratos/store/testing';
import { NgxChartsModule } from '@swimlane/ngx-charts';

import {
Expand All @@ -14,15 +14,19 @@ import {
ApplicationStateService,
} from '../../../../../../core/src/shared/components/application-state/application-state.service';
import { ConfirmationDialogService } from '../../../../../../core/src/shared/components/confirmation-dialog.service';
import { generateTestApplicationServiceProvider } from '../../../../../../core/test-framework/application-service-helper';
import { AppTestModule } from '../../../../../../core/test-framework/core-test.helper';
import {
EntityCatalogHelper,
} from '../../../../../../store/src/entity-catalog/entity-catalog-entity/entity-catalog.service';
import { EntityMonitorFactory } from '../../../../../../store/src/monitors/entity-monitor.factory.service';
import { PaginationMonitorFactory } from '../../../../../../store/src/monitors/pagination-monitor.factory';
import { generateTestApplicationServiceProvider } from '../../../../../../core/test-framework/application-service-helper';
import { createEmptyStoreModule } from '@stratos/store/testing';
import { CfAutoscalerTestingModule } from '../../../../cf-autoscaler-testing.module';
import { AppAutoscalerMetricChartCardComponent } from './app-autoscaler-metric-chart-card.component';
import { AppAutoscalerComboChartComponent } from './combo-chart/combo-chart.component';
import { AppAutoscalerComboSeriesVerticalComponent } from './combo-chart/combo-series-vertical.component';

/* tslint:disable:max-line-length */
/* tslint:enable:max-line-length */

describe('AppAutoscalerMetricChartCardComponent', () => {
Expand All @@ -40,9 +44,11 @@ describe('AppAutoscalerMetricChartCardComponent', () => {
createEmptyStoreModule(),
CoreModule,
NgxChartsModule,
AppTestModule
],
providers: [
EntityMonitorFactory,
EntityCatalogHelper,
generateTestApplicationServiceProvider('1', '1'),
ApplicationEnvVarsHelper,
ApplicationStateService,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
/* tslint:disable:max-line-length */
import { DatePipe } from '@angular/common';
import { inject, TestBed } from '@angular/core/testing';
import { createEmptyStoreModule } from '@stratos/store/testing';

import {
ApplicationEnvVarsHelper,
} from '../../../../../cloud-foundry/src/features/applications/application/application-tabs-base/tabs/build-tab/application-env-vars.service';
import { EntityServiceFactory } from '../../../../../store/src/entity-service-factory.service';
import {
ApplicationStateService,
} from '../../../../../core/src/shared/components/application-state/application-state.service';
import { EntityMonitorFactory } from '../../../../../store/src/monitors/entity-monitor.factory.service';
import { PaginationMonitorFactory } from '../../../../../store/src/monitors/pagination-monitor.factory';
import { MetricsRangeSelectorService } from '../../../../../core/src/shared/services/metrics-range-selector.service';
import { generateTestApplicationServiceProvider } from '../../../../../core/test-framework/application-service-helper';
import { createEmptyStoreModule } from '@stratos/store/testing';
import { AppTestModule } from '../../../../../core/test-framework/core-test.helper';
import { EntityCatalogHelper } from '../../../../../store/src/entity-catalog/entity-catalog-entity/entity-catalog.service';
import { EntityServiceFactory } from '../../../../../store/src/entity-service-factory.service';
import { EntityMonitorFactory } from '../../../../../store/src/monitors/entity-monitor.factory.service';
import { PaginationMonitorFactory } from '../../../../../store/src/monitors/pagination-monitor.factory';
import { CfAutoscalerTestingModule } from '../../../cf-autoscaler-testing.module';
import { AppAutoscalerMetricChartListConfigService } from './app-autoscaler-metric-chart-list-config.service';

/* tslint:disable:max-line-length */

/* tslint:enable:max-line-length */

Expand All @@ -30,13 +32,15 @@ describe('AppAutoscalerMetricChartListConfigService', () => {
DatePipe,
EntityServiceFactory,
EntityMonitorFactory,
EntityCatalogHelper,
ApplicationStateService,
PaginationMonitorFactory,
MetricsRangeSelectorService
],
imports: [
CfAutoscalerTestingModule,
createEmptyStoreModule(),
AppTestModule
]
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { IOrganization } from '../../../core/src/core/cf-api.types';
import {
StratosBaseCatalogEntity,
StratosCatalogEntity,
} from '../../../store/src/entity-catalog/entity-catalog-entity';
} from '../../../store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity';
import { IStratosEndpointDefinition } from '../../../store/src/entity-catalog/entity-catalog.types';
import { APIResource } from '../../../store/src/types/api.types';
import { IFavoriteMetadata } from '../../../store/src/types/user-favorites.types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Observable } from 'rxjs';
import { catchError, mergeMap, withLatestFrom } from 'rxjs/operators';

import { PaginationResponse } from '../../../cloud-foundry/src/store/types/cf-api.types';
import { entityCatalog } from '../../../store/src/entity-catalog/entity-catalog.service';
import { entityCatalog } from '../../../store/src/entity-catalog/entity-catalog';
import { environment } from '../../../core/src/environments/environment';
import { isHttpErrorResponse } from '../../../core/src/jetstream.helpers';
import { AppState } from '../../../store/src/app-state';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Action } from '@ngrx/store';

import { UpdateApplication } from './application.actions';
import { ListAppEnvVar } from '../shared/components/list/list-types/app-variables/cf-app-variables-data-source';
import { UpdateApplication } from './application.actions';

export const AppVariables = {
UPDATE: '[Application Variables] Update',
Expand All @@ -12,7 +12,9 @@ export class AppVariablesUpdate implements Action {
type = AppVariables.UPDATE;
updatedApplication: UpdateApplication;

constructor(public cfGuid: string, public appGuid: string) { }
constructor(public cfGuid: string, public appGuid: string) {
this.guid = 'n/a' // No such thing as an individual app variable guid
}

protected createUpdateApplication(allEnvVars: ListAppEnvVar[], selectedItems: ListAppEnvVar[]): UpdateApplication {
const updateApp: UpdateApplication = {
Expand All @@ -26,6 +28,7 @@ export class AppVariablesUpdate implements Action {
}
return updateApp;
}
guid: string;
}

export class AppVariablesDelete extends AppVariablesUpdate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ICFAction } from '../../../store/src/types/request.types';
import { cfEntityFactory } from '../cf-entity-factory';
import { applicationEntityType, appStatsEntityType } from '../cf-entity-types';
import { CF_ENDPOINT_TYPE } from '../cf-types';
import { EntityInlineParentAction } from '../entity-relations/entity-relations.types';
import { createEntityRelationPaginationKey, EntityInlineParentAction } from '../entity-relations/entity-relations.types';
import { AppMetadataTypes } from './app-metadata.actions';
import { CFStartAction } from './cf-action.types';

Expand Down Expand Up @@ -55,6 +55,7 @@ export class GetAllApplications extends CFStartAction implements PaginatedAction
'GET',
'apps'
);
this.paginationKey = this.paginationKey || createEntityRelationPaginationKey('cf', endpointGuid)
}
actions = [GET_ALL, GET_ALL_SUCCESS, GET_ALL_FAILED];
entity = [applicationEntitySchema];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { CF_ENDPOINT_TYPE } from '../cf-types';
import { cfInfoEntityType } from '../cf-entity-types';
import { EntityRequestAction } from '../../../store/src/types/request.types';
import { cfInfoEntityType } from '../cf-entity-types';
import { CF_ENDPOINT_TYPE } from '../cf-types';

export const GET_CF_INFO = '[CF Endpoint] Get Info';

export class GetCFInfo implements EntityRequestAction {
constructor(public cfGuid: string) { }
constructor(public guid: string) { }
type = GET_CF_INFO;
endpointType = CF_ENDPOINT_TYPE;
entityType = cfInfoEntityType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Action } from '@ngrx/store';
import { GitSCM } from '../../../core/src/shared/data-services/scm/scm';
import { PaginatedAction } from '../../../store/src/types/pagination.types';
import { EntityRequestAction } from '../../../store/src/types/request.types';
import { CF_ENDPOINT_TYPE } from '../cf-types';
import { gitBranchesEntityType, gitCommitEntityType } from '../cf-entity-types';
import { CF_ENDPOINT_TYPE } from '../cf-types';
import { DockerAppDetails, GitAppDetails, OverrideAppDetails, SourceType } from '../store/types/deploy-application.types';
import { GitBranch, GitCommit } from '../store/types/git.types';

Expand All @@ -14,6 +14,7 @@ export const PROJECT_DOESNT_EXIST = '[Deploy App] Project Doesn\'t exist';
export const PROJECT_FETCH_FAILED = '[Deploy App] Project Fetch Failed';
export const PROJECT_EXISTS = '[Deploy App] Project exists';
export const FETCH_BRANCHES_FOR_PROJECT = '[Deploy App] Fetch branches';
export const FETCH_BRANCH_FOR_PROJECT = '[Deploy App] Fetch branch';
export const SAVE_APP_DETAILS = '[Deploy App] Save app details';
export const SAVE_APP_OVERRIDE_DETAILS = '[Deploy App] Save app override details';
export const FETCH_COMMIT = '[Deploy App] Fetch commit';
Expand All @@ -29,6 +30,10 @@ export const FETCH_BRANCH_START = '[GitHub] Fetch branch start';
export const FETCH_BRANCH_SUCCESS = '[GitHub] Fetch branch succeeded';
export const FETCH_BRANCH_FAILED = '[GitHub] Fetch branch failed';

export const FETCH_BRANCHES_START = '[GitHub] Fetch branches start';
export const FETCH_BRANCHES_SUCCESS = '[GitHub] Fetch branches succeeded';
export const FETCH_BRANCHES_FAILED = '[GitHub] Fetch branches failed';

export class SetAppSourceDetails implements Action {
constructor(public sourceType: SourceType) { }
type = SET_APP_SOURCE_DETAILS;
Expand All @@ -54,16 +59,30 @@ export class ProjectExists implements Action {
type = PROJECT_EXISTS;
}

export class FetchBranchesForProject implements PaginatedAction {
constructor(public scm: GitSCM, public projectName: string) {
this.paginationKey = FetchBranchesForProject.createPaginationKey(scm, projectName);
export class FetchBranchForProject implements EntityRequestAction {
constructor(public scm: GitSCM, public projectName: string, public guid: string, public branchName: string) {
this.guid = this.guid || `${scm.getType()}-${this.projectName}-${this.branchName}`
}
actions = [
FETCH_BRANCH_START,
FETCH_BRANCH_SUCCESS,
FETCH_BRANCH_FAILED
];
public endpointType = CF_ENDPOINT_TYPE;
type = FETCH_BRANCH_FOR_PROJECT;
entityType = gitBranchesEntityType;
}

export class FetchBranchesForProject implements PaginatedAction {
constructor(public scm: GitSCM, public projectName: string) {
this.paginationKey = FetchBranchesForProject.createPaginationKey(scm, projectName);
}
actions = [
FETCH_BRANCHES_START,
FETCH_BRANCHES_SUCCESS,
FETCH_BRANCHES_FAILED
];
public endpointType = CF_ENDPOINT_TYPE;
type = FETCH_BRANCHES_FOR_PROJECT;
entityType = gitBranchesEntityType;
paginationKey: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { HttpRequest } from '@angular/common/http';

import { getActions } from '../../../store/src/actions/action.helper';
import { endpointSchemaKey } from '../../../store/src/helpers/entity-factory';
import { PaginatedAction } from '../../../store/src/types/pagination.types';
import { RequestEntityLocation } from '../../../store/src/types/request.types';
import { cfEntityFactory } from '../cf-entity-factory';
import { featureFlagEntityType } from '../cf-entity-types';
import { createEntityRelationPaginationKey } from '../entity-relations/entity-relations.types';
import { CFStartAction } from './cf-action.types';

export class GetAllFeatureFlags extends CFStartAction implements PaginatedAction {
constructor(public endpointGuid: string, public paginationKey: string) {
constructor(public endpointGuid: string, public paginationKey: string = null) {
super();
this.paginationKey = this.paginationKey || createEntityRelationPaginationKey(endpointSchemaKey, this.endpointGuid);
this.options = new HttpRequest(
'GET',
`config/feature_flags`
Expand All @@ -21,7 +24,7 @@ export class GetAllFeatureFlags extends CFStartAction implements PaginatedAction
entity = [cfEntityFactory(featureFlagEntityType)];
actions = getActions('Feature Flags', 'Fetch all');
options: HttpRequest<any>;
flattenPagination = false;
flattenPagination = true;
entityLocation = RequestEntityLocation.ARRAY;
initialParams = {
page: 1,
Expand Down
Loading