Skip to content

Commit

Permalink
Merge pull request #4382 from cloudfoundry/store-core-more
Browse files Browse the repository at this point in the history
Fix more store -> core dependencies
  • Loading branch information
richard-cox authored Jun 23, 2020
2 parents b438b10 + 80e9745 commit 64b430d
Show file tree
Hide file tree
Showing 44 changed files with 154 additions and 185 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import * as moment from 'moment';
import { combineLatest, Observable, of } from 'rxjs';
import { first, map } from 'rxjs/operators';

import { EndpointHealthCheck } from '../../core/endpoints-health-checks';
import { urlValidationExpression } from '../../core/src/core/utils.service';
import { BaseEndpointAuth } from '../../core/src/features/endpoints/endpoint-auth';
import { AppState, GeneralEntityAppState } from '../../store/src/app-state';
import { metricEntityType } from '../../store/src/base-entity-schemas';
import { BaseEndpointAuth } from '../../store/src/endpoint-auth';
import {
StratosBaseCatalogEntity,
StratosCatalogEndpointEntity,
StratosCatalogEntity,
} from '../../store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity';
import {
EndpointHealthCheck,
IStratosEntityDefinition,
StratosEndpointExtensionDefinition,
} from '../../store/src/entity-catalog/entity-catalog.types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FavoritesConfigMapper } from '../../core/src/shared/components/favorites-meta-card/favorite-config-mapper';
import { IEntityMetadata } from '../../store/src/entity-catalog/entity-catalog.types';
import { FavoritesConfigMapper } from '../../store/src/favorite-config-mapper';
import { UserFavorite } from '../../store/src/types/user-favorites.types';
import { CfAPIResource } from './store/types/cf-api.types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ import {
import { CurrentUserPermissionsService } from '../../../../../../core/src/core/permissions/current-user-permissions.service';
import { safeUnsubscribe } from '../../../../../../core/src/core/utils.service';
import { IPageSideNavTab } from '../../../../../../core/src/features/dashboard/page-side-nav/page-side-nav.component';
import {
FavoritesConfigMapper,
} from '../../../../../../core/src/shared/components/favorites-meta-card/favorite-config-mapper';
import { IHeaderBreadcrumb } from '../../../../../../core/src/shared/components/page-header/page-header.types';
import { ENTITY_SERVICE } from '../../../../../../core/src/shared/entity.tokens';
import { RouterNav } from '../../../../../../store/src/actions/router.actions';
import { entityCatalog } from '../../../../../../store/src/entity-catalog/entity-catalog';
import { EntityService } from '../../../../../../store/src/entity-service';
import { FavoritesConfigMapper } from '../../../../../../store/src/favorite-config-mapper';
import { EntitySchema } from '../../../../../../store/src/helpers/entity-schema';
import { ActionState } from '../../../../../../store/src/reducers/api-request-reducer/types';
import { endpointEntitiesSelector } from '../../../../../../store/src/selectors/endpoint.selectors';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { CurrentUserPermissionsService } from '../../../../../core/src/core/permissions/current-user-permissions.service';
import { environment } from '../../../../../core/src/environments/environment.prod';
import { IPageSideNavTab } from '../../../../../core/src/features/dashboard/page-side-nav/page-side-nav.component';
import { FavoritesConfigMapper } from '../../../../../core/src/shared/components/favorites-meta-card/favorite-config-mapper';
import { FavoritesConfigMapper } from '../../../../../store/src/favorite-config-mapper';
import { UserFavoriteEndpoint } from '../../../../../store/src/types/user-favorites.types';
import { CfCurrentUserPermissions } from '../../../user-permissions/cf-user-permissions-checkers';
import { CloudFoundryEndpointService } from '../services/cloud-foundry-endpoint.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ import {
} from '../../../../../../../core/src/core/extension/extension-service';
import { environment } from '../../../../../../../core/src/environments/environment.prod';
import { IPageSideNavTab } from '../../../../../../../core/src/features/dashboard/page-side-nav/page-side-nav.component';
import {
FavoritesConfigMapper,
} from '../../../../../../../core/src/shared/components/favorites-meta-card/favorite-config-mapper';
import { IHeaderBreadcrumb } from '../../../../../../../core/src/shared/components/page-header/page-header.types';
import { FavoritesConfigMapper } from '../../../../../../../store/src/favorite-config-mapper';
import { EntitySchema } from '../../../../../../../store/src/helpers/entity-schema';
import { UserFavorite } from '../../../../../../../store/src/types/user-favorites.types';
import { getFavoriteFromEntity } from '../../../../../../../store/src/user-favorite-helpers';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ import {
import { environment } from '../../../../../../../../core/src/environments/environment.prod';
import { IPageSideNavTab } from '../../../../../../../../core/src/features/dashboard/page-side-nav/page-side-nav.component';
import { ConfirmationDialogService } from '../../../../../../../../core/src/shared/components/confirmation-dialog.service';
import {
FavoritesConfigMapper,
} from '../../../../../../../../core/src/shared/components/favorites-meta-card/favorite-config-mapper';
import { IHeaderBreadcrumb } from '../../../../../../../../core/src/shared/components/page-header/page-header.types';
import { RouterNav } from '../../../../../../../../store/src/actions/router.actions';
import { FavoritesConfigMapper } from '../../../../../../../../store/src/favorite-config-mapper';
import { UserFavorite } from '../../../../../../../../store/src/types/user-favorites.types';
import { getFavoriteFromEntity } from '../../../../../../../../store/src/user-favorite-helpers';
import { cfEntityFactory } from '../../../../../../cf-entity-factory';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ import { map, startWith } from 'rxjs/operators';
import { CFAppState } from '../../../../../../../../cloud-foundry/src/cf-app-state';
import { applicationEntityType } from '../../../../../../../../cloud-foundry/src/cf-entity-types';
import { IAppFavMetadata } from '../../../../../../../../cloud-foundry/src/cf-metadata-types';
import {
FavoritesConfigMapper,
} from '../../../../../../../../core/src/shared/components/favorites-meta-card/favorite-config-mapper';
import { CardCell } from '../../../../../../../../core/src/shared/components/list/list.types';
import { ComponentEntityMonitorConfig, StratosStatus } from '../../../../../../../../core/src/shared/shared.types';
import { FavoritesConfigMapper } from '../../../../../../../../store/src/favorite-config-mapper';
import { APIResource } from '../../../../../../../../store/src/types/api.types';
import { UserFavorite } from '../../../../../../../../store/src/types/user-favorites.types';
import { getFavoriteFromEntity } from '../../../../../../../../store/src/user-favorite-helpers';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ import {
import { truthyIncludingZeroString } from '../../../../../../../../core/src/core/utils.service';
import { ConfirmationDialogConfig } from '../../../../../../../../core/src/shared/components/confirmation-dialog.config';
import { ConfirmationDialogService } from '../../../../../../../../core/src/shared/components/confirmation-dialog.service';
import {
FavoritesConfigMapper,
} from '../../../../../../../../core/src/shared/components/favorites-meta-card/favorite-config-mapper';
import {
MetaCardMenuItem,
} from '../../../../../../../../core/src/shared/components/list/list-cards/meta-card/meta-card-base/meta-card.component';
import { CardCell } from '../../../../../../../../core/src/shared/components/list/list.types';
import { ComponentEntityMonitorConfig, StratosStatus } from '../../../../../../../../core/src/shared/shared.types';
import { RouterNav } from '../../../../../../../../store/src/actions/router.actions';
import { FavoritesConfigMapper } from '../../../../../../../../store/src/favorite-config-mapper';
import { EntityMonitorFactory } from '../../../../../../../../store/src/monitors/entity-monitor.factory.service';
import { PaginationMonitorFactory } from '../../../../../../../../store/src/monitors/pagination-monitor.factory';
import { APIResource } from '../../../../../../../../store/src/types/api.types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ import {
import { truthyIncludingZeroString } from '../../../../../../../../core/src/core/utils.service';
import { ConfirmationDialogConfig } from '../../../../../../../../core/src/shared/components/confirmation-dialog.config';
import { ConfirmationDialogService } from '../../../../../../../../core/src/shared/components/confirmation-dialog.service';
import {
FavoritesConfigMapper,
} from '../../../../../../../../core/src/shared/components/favorites-meta-card/favorite-config-mapper';
import {
MetaCardMenuItem,
} from '../../../../../../../../core/src/shared/components/list/list-cards/meta-card/meta-card-base/meta-card.component';
import { CardCell } from '../../../../../../../../core/src/shared/components/list/list.types';
import { ComponentEntityMonitorConfig, StratosStatus } from '../../../../../../../../core/src/shared/shared.types';
import { RouterNav } from '../../../../../../../../store/src/actions/router.actions';
import { FavoritesConfigMapper } from '../../../../../../../../store/src/favorite-config-mapper';
import { EntityMonitorFactory } from '../../../../../../../../store/src/monitors/entity-monitor.factory.service';
import { PaginationMonitorFactory } from '../../../../../../../../store/src/monitors/pagination-monitor.factory';
import { APIResource } from '../../../../../../../../store/src/types/api.types';
Expand Down
13 changes: 1 addition & 12 deletions src/frontend/packages/core/endpoints-health-checks.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
import { Injectable } from '@angular/core';

import { entityCatalog } from '../store/src/entity-catalog/entity-catalog';
import { EndpointHealthCheck } from '../store/src/entity-catalog/entity-catalog.types';
import { EndpointModel } from '../store/src/types/endpoint.types';


export class EndpointHealthCheck {
/**
* @param check To show an error, the check should either call a WrapperRequestActionFailed
* or kick off a chain that eventually calls a WrapperRequestActionFailed
*/
constructor(
public endpointType: string,
public check: (endpoint: EndpointModel) => void
) { }
}

@Injectable({
providedIn: 'root'
})
Expand Down
17 changes: 16 additions & 1 deletion src/frontend/packages/core/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { Params, RouteReuseStrategy, RouterStateSnapshot } from '@angular/router';
import { DefaultRouterStateSerializer, RouterStateSerializer, StoreRouterConnectingModule } from '@ngrx/router-store';
import { Store } from '@ngrx/store';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
import { debounceTime, filter, withLatestFrom } from 'rxjs/operators';

import { CfAutoscalerModule } from '../../cf-autoscaler/src/cf-autoscaler.module';
Expand All @@ -19,6 +20,7 @@ import { EntityCatalogModule } from '../../store/src/entity-catalog.module';
import { entityCatalog } from '../../store/src/entity-catalog/entity-catalog';
import { EntityCatalogHelper } from '../../store/src/entity-catalog/entity-catalog-entity/entity-catalog.service';
import { EntityCatalogHelpers } from '../../store/src/entity-catalog/entity-catalog.helper';
import { FavoritesConfigMapper } from '../../store/src/favorite-config-mapper';
import { endpointSchemaKey } from '../../store/src/helpers/entity-factory';
import { getAPIRequestDataState, selectEntity } from '../../store/src/selectors/api.selectors';
import { internalEventStateSelector } from '../../store/src/selectors/internal-events.selectors';
Expand All @@ -38,6 +40,7 @@ import { ExtensionService } from './core/extension/extension-service';
import { getGitHubAPIURL, GITHUB_API_URL } from './core/github.helpers';
import { CurrentUserPermissionsService } from './core/permissions/current-user-permissions.service';
import { CustomImportModule } from './custom-import.module';
import { environment } from './environments/environment';
import { AboutModule } from './features/about/about.module';
import { DashboardModule } from './features/dashboard/dashboard.module';
import { HomeModule } from './features/home/home.module';
Expand All @@ -46,7 +49,6 @@ import { NoEndpointsNonAdminComponent } from './features/no-endpoints-non-admin/
import { SetupModule } from './features/setup/setup.module';
import { LoggedInService } from './logged-in.service';
import { CustomReuseStrategy } from './route-reuse-stragegy';
import { FavoritesConfigMapper } from './shared/components/favorites-meta-card/favorite-config-mapper';
import { endpointEventKey, GlobalEventData, GlobalEventService } from './shared/global-events.service';
import { SidePanelService } from './shared/services/side-panel.service';
import { SharedModule } from './shared/shared.module';
Expand Down Expand Up @@ -80,6 +82,18 @@ export class CustomRouterStateSerializer
}
}

const storeDebugImports = environment.production ? [] : [
StoreDevtoolsModule.instrument({
maxAge: 100,
logOnly: !environment.production
})
];

@NgModule({
imports: storeDebugImports
})
class AppStoreDebugModule {}

/**
* `HttpXsrfTokenExtractor` which retrieves the token from a cookie.
*/
Expand All @@ -94,6 +108,7 @@ export class CustomRouterStateSerializer
RouteModule,
CloudFoundryPackageModule,
AppStoreModule,
AppStoreDebugModule,
BrowserModule,
SharedModule,
BrowserAnimationsModule,
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/packages/core/src/core/endpoints.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import { first, map, skipWhile, withLatestFrom } from 'rxjs/operators';
import { RouterNav } from '../../../store/src/actions/router.actions';
import { EndpointOnlyAppState, IRequestEntityTypeState } from '../../../store/src/app-state';
import { entityCatalog } from '../../../store/src/entity-catalog/entity-catalog';
import { EndpointHealthCheck } from '../../../store/src/entity-catalog/entity-catalog.types';
import { AuthState } from '../../../store/src/reducers/auth.reducer';
import { endpointEntitiesSelector, endpointStatusSelector } from '../../../store/src/selectors/endpoint.selectors';
import { EndpointModel, EndpointState } from '../../../store/src/types/endpoint.types';
import { EndpointHealthCheck, EndpointHealthChecks } from '../../endpoints-health-checks';
import { EndpointHealthChecks } from '../../endpoints-health-checks';
import { endpointHasMetricsByAvailable } from '../features/endpoints/endpoint-helpers';
import { UserService } from './user.service';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { OverlayContainer } from '@angular/cdk/overlay';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { BehaviorSubject, of } from 'rxjs';

import { FavoritesConfigMapper } from '../../../../store/src/favorite-config-mapper';
import { PaginationMonitorFactory } from '../../../../store/src/monitors/pagination-monitor.factory';
import { IFavoriteMetadata, UserFavorite } from '../../../../store/src/types/user-favorites.types';
import { UserFavoriteManager } from '../../../../store/src/user-favorite-manager';
import { BaseTestModulesNoShared } from '../../../test-framework/core-test.helper';
import { ConfirmationDialogService } from '../../shared/components/confirmation-dialog.service';
import { DialogConfirmComponent } from '../../shared/components/dialog-confirm/dialog-confirm.component';
import { FavoritesConfigMapper } from '../../shared/components/favorites-meta-card/favorite-config-mapper';
import { EntityFavoriteStarComponent } from './entity-favorite-star.component';

describe('EntityFavoriteStarComponent', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { Component, Input } from '@angular/core';
import { Observable } from 'rxjs';
import { first, tap } from 'rxjs/operators';

import { FavoritesConfigMapper } from '../../../../store/src/favorite-config-mapper';
import { IFavoriteMetadata, UserFavorite } from '../../../../store/src/types/user-favorites.types';
import { UserFavoriteManager } from '../../../../store/src/user-favorite-manager';
import { ConfirmationDialogConfig } from '../../shared/components/confirmation-dialog.config';
import { ConfirmationDialogService } from '../../shared/components/confirmation-dialog.service';
import { FavoritesConfigMapper } from '../../shared/components/favorites-meta-card/favorite-config-mapper';
import { EndpointsService } from '../endpoints.service';

@Component({
Expand Down
57 changes: 0 additions & 57 deletions src/frontend/packages/core/src/core/utils.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,56 +11,6 @@ export function getIdFromRoute(activatedRoute: ActivatedRoute, id: string) {
return null;
}

export type OptionalKeys<T extends object> = Exclude<{
[K in keyof T]: T extends Record<K, T[K]>
? K
: never
}[keyof T], undefined>


export type NonOptionalKeys<T extends object> = Exclude<{
[K in keyof T]: T extends Record<K, T[K]>
? K
: never
}[keyof T], undefined>

export type NeverKeys<T extends object> = Exclude<{
[K in keyof T]: T[K] extends never
? K
: never
}[keyof T], undefined>


/**
* Remove keys such as typed indexes (i.e. [key: string])
* For magic see
* - https://github.com/Microsoft/TypeScript/issues/25987#issuecomment-441224690
* - https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-414808995
*/
export type KnownKeys<T> = {
[K in keyof T]: string extends K ? never : number extends K ? never : K
} extends { [_ in keyof T]: infer U } ? ({} extends U ? never : U) : never;

/**
* Pick all properties who's function has the specified return type U
*/
export type FilteredByReturnType<T extends { [key: string]: (...args: any[]) => any }, U> = {
[P in keyof T]: ReturnType<T[P]> extends U ? T[P] : never
};

/**
* Pick all properties who's function do not have the specified return type U
*/
export type FilteredByNotReturnType<T extends { [key: string]: (...args: any[]) => any }, U> = {
[P in keyof T]: ReturnType<T[P]> extends U ? never : T[P]
};

// Note - Adding }[keyof T] to [P in keyof T] types should filter out properties of type `never`, however this fails with generics!
export type FilteredByValueType<T extends { [key: string]: (...args: any[]) => any }, U> = {
[P in keyof T]: T[P] extends U ? never : T[P]
};


export const urlValidationExpression =
'^' +
// protocol identifier
Expand Down Expand Up @@ -319,13 +269,6 @@ export const safeUnsubscribe = (...subs: Subscription[]) => {
export const truthyIncludingZero = (obj: any): boolean => !!obj || obj === 0;
export const truthyIncludingZeroString = (obj: any): string => truthyIncludingZero(obj) ? obj.toString() : null;

export const sortStringify = (obj: { [key: string]: string | string[] | number }): string => {
const keys = Object.keys(obj).sort();
return keys.reduce((res, key) => {
return res += `${key}-${obj[key]},`;
}, '');
};

/**
* Real basic, shallow check
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { BehaviorSubject, Observable } from 'rxjs';
import { first, map } from 'rxjs/operators';

import { GeneralEntityAppState } from '../../../../../store/src/app-state';
import { BrowserStandardEncoder } from '../../../../../store/src/browser-encoder';
import { entityCatalog } from '../../../../../store/src/entity-catalog/entity-catalog';
import { EndpointModel } from '../../../../../store/src/types/endpoint.types';
import { BrowserStandardEncoder } from '../../../helper';
import {
BackupEndpointConfigUI,
BackupEndpointConnectionTypes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { BehaviorSubject, combineLatest, Observable } from 'rxjs';
import { filter, map, switchMap } from 'rxjs/operators';

import { GeneralEntityAppState } from '../../../../../store/src/app-state';
import { BrowserStandardEncoder } from '../../../../../store/src/browser-encoder';
import { selectSessionData } from '../../../../../store/src/reducers/auth.reducer';
import { SessionData } from '../../../../../store/src/types/auth.types';
import { LoggerService } from '../../../core/logger.service';
import { BrowserStandardEncoder } from '../../../helper';

interface BackupContent {
payload: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import {
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Subscription } from 'rxjs';

import { BaseEndpointAuth } from '../../../../../store/src/endpoint-auth';
import { entityCatalog } from '../../../../../store/src/entity-catalog/entity-catalog';
import { EndpointAuthTypeConfig, IAuthForm, IEndpointAuthComponent } from '../../../../../store/src/extension-types';
import { safeUnsubscribe } from '../../../core/utils.service';
import { ConnectEndpointConfig, ConnectEndpointData, ConnectEndpointService } from '../connect.service';
import { BaseEndpointAuth } from '../endpoint-auth';

@Component({
selector: 'app-connect-endpoint',
Expand Down
Loading

0 comments on commit 64b430d

Please sign in to comment.