Skip to content

Commit

Permalink
Merge pull request #4379 from cloudfoundry/store-core-2
Browse files Browse the repository at this point in the history
Remove more store -> core dependencies
  • Loading branch information
richard-cox authored Jun 18, 2020
2 parents 304d172 + 2b12099 commit f1b99b0
Show file tree
Hide file tree
Showing 35 changed files with 64 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
StratosTabType,
} from '../../../../../../core/src/core/extension/extension-service';
import { CurrentUserPermissionsService } from '../../../../../../core/src/core/permissions/current-user-permissions.service';
import { getFavoriteFromEntity } from '../../../../../../core/src/core/user-favorite-helpers';
import { safeUnsubscribe } from '../../../../../../core/src/core/utils.service';
import { IPageSideNavTab } from '../../../../../../core/src/features/dashboard/page-side-nav/page-side-nav.component';
import {
Expand All @@ -31,6 +30,7 @@ import { ActionState } from '../../../../../../store/src/reducers/api-request-re
import { endpointEntitiesSelector } from '../../../../../../store/src/selectors/endpoint.selectors';
import { APIResource } from '../../../../../../store/src/types/api.types';
import { EndpointModel } from '../../../../../../store/src/types/endpoint.types';
import { getFavoriteFromEntity } from '../../../../../../store/src/user-favorite-helpers';
import { UpdateExistingApplication } from '../../../../actions/application.actions';
import { IApp, IOrganization, ISpace } from '../../../../cf-api.types';
import { CF_ENDPOINT_TYPE } from '../../../../cf-types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
StratosActionType,
StratosTabType,
} from '../../../../../../../core/src/core/extension/extension-service';
import { getFavoriteFromEntity } from '../../../../../../../core/src/core/user-favorite-helpers';
import { environment } from '../../../../../../../core/src/environments/environment.prod';
import { IPageSideNavTab } from '../../../../../../../core/src/features/dashboard/page-side-nav/page-side-nav.component';
import {
Expand All @@ -20,6 +19,7 @@ import {
import { IHeaderBreadcrumb } from '../../../../../../../core/src/shared/components/page-header/page-header.types';
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';
import { cfEntityFactory } from '../../../../../cf-entity-factory';
import { CF_ENDPOINT_TYPE } from '../../../../../cf-types';
import { CfUserService } from '../../../../../shared/data-services/cf-user.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
StratosActionType,
StratosTabType,
} from '../../../../../../../../core/src/core/extension/extension-service';
import { getFavoriteFromEntity } from '../../../../../../../../core/src/core/user-favorite-helpers';
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';
Expand All @@ -23,6 +22,7 @@ import {
import { IHeaderBreadcrumb } from '../../../../../../../../core/src/shared/components/page-header/page-header.types';
import { RouterNav } from '../../../../../../../../store/src/actions/router.actions';
import { UserFavorite } from '../../../../../../../../store/src/types/user-favorites.types';
import { getFavoriteFromEntity } from '../../../../../../../../store/src/user-favorite-helpers';
import { cfEntityFactory } from '../../../../../../cf-entity-factory';
import { CF_ENDPOINT_TYPE } from '../../../../../../cf-types';
import { CfUserService } from '../../../../../../shared/data-services/cf-user.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ 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 { getFavoriteFromEntity } from '../../../../../../../../core/src/core/user-favorite-helpers';
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 { APIResource } from '../../../../../../../../store/src/types/api.types';
import { UserFavorite } from '../../../../../../../../store/src/types/user-favorites.types';
import { getFavoriteFromEntity } from '../../../../../../../../store/src/user-favorite-helpers';
import { IApp, ISpace } from '../../../../../../cf-api.types';
import { cfEntityFactory } from '../../../../../../cf-entity-factory';
import { CF_ENDPOINT_TYPE } from '../../../../../../cf-types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { organizationEntityType } from '../../../../../../../../cloud-foundry/sr
import {
CurrentUserPermissionsService,
} from '../../../../../../../../core/src/core/permissions/current-user-permissions.service';
import { getFavoriteFromEntity } from '../../../../../../../../core/src/core/user-favorite-helpers';
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';
Expand All @@ -26,6 +25,7 @@ import { PaginationMonitorFactory } from '../../../../../../../../store/src/moni
import { APIResource } from '../../../../../../../../store/src/types/api.types';
import { EndpointUser } from '../../../../../../../../store/src/types/endpoint.types';
import { IFavoriteMetadata, UserFavorite } from '../../../../../../../../store/src/types/user-favorites.types';
import { getFavoriteFromEntity } from '../../../../../../../../store/src/user-favorite-helpers';
import { IApp, IOrganization } from '../../../../../../cf-api.types';
import { cfEntityFactory } from '../../../../../../cf-entity-factory';
import { getStartedAppInstanceCount } from '../../../../../../cf.helpers';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { ISpaceFavMetadata } from '../../../../../../../../cloud-foundry/src/cf-
import {
CurrentUserPermissionsService,
} from '../../../../../../../../core/src/core/permissions/current-user-permissions.service';
import { getFavoriteFromEntity } from '../../../../../../../../core/src/core/user-favorite-helpers';
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';
Expand All @@ -27,6 +26,7 @@ import { PaginationMonitorFactory } from '../../../../../../../../store/src/moni
import { APIResource } from '../../../../../../../../store/src/types/api.types';
import { EndpointUser } from '../../../../../../../../store/src/types/endpoint.types';
import { UserFavorite } from '../../../../../../../../store/src/types/user-favorites.types';
import { getFavoriteFromEntity } from '../../../../../../../../store/src/user-favorite-helpers';
import { IApp, ISpace } from '../../../../../../cf-api.types';
import { cfEntityFactory } from '../../../../../../cf-entity-factory';
import { CF_ENDPOINT_TYPE } from '../../../../../../cf-types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Action, Store } from '@ngrx/store';
import { combineLatest, Observable, of } from 'rxjs';
import { catchError, first, map, pairwise, share, skipWhile, switchMap, tap } from 'rxjs/operators';

import { LoggerService } from '../../../core/src/core/logger.service';
import { AppState } from '../../../store/src/app-state';
import { entityCatalog } from '../../../store/src/entity-catalog/entity-catalog';
import {
Expand Down Expand Up @@ -50,7 +49,6 @@ const createEndpointArray = (store: Store<AppState>, endpoints: string[] | Entit
export const cfUserRolesFetch: EntityUserRolesFetch = (
endpoints: string[] | EntityUserRolesEndpoint[],
store: Store<AppState>,
logService: LoggerService,
httpClient: HttpClient
) => {
return createEndpointArray(store, endpoints).pipe(
Expand All @@ -61,7 +59,7 @@ export const cfUserRolesFetch: EntityUserRolesFetch = (
cfEndpoints.forEach(endpoint => store.dispatch(new GetCfUserRelations(endpoint.guid, GET_CURRENT_CF_USER_RELATIONS_SUCCESS)))
} else {
// If some endpoints are not connected as admin, go out and fetch the current user's specific roles
const flagsAndRoleRequests = dispatchRoleRequests(cfEndpoints, store, logService, httpClient);
const flagsAndRoleRequests = dispatchRoleRequests(cfEndpoints, store, httpClient);
const allRequestsCompleted = handleCfRequests(flagsAndRoleRequests);
return combineLatest(allRequestsCompleted).pipe(
map(succeeds => succeeds.every(succeeded => !!succeeded)),
Expand All @@ -84,7 +82,6 @@ interface IEndpointConnectionInfo {
function dispatchRoleRequests(
endpoints: EntityUserRolesEndpoint[],
store: Store<AppState>,
logService: LoggerService,
httpClient: HttpClient
): CfsRequestState {
const requests: CfsRequestState = {};
Expand Down Expand Up @@ -117,7 +114,7 @@ function dispatchRoleRequests(
);
}),
catchError(err => {
logService.warn('Failed to fetch current user permissions for a cf: ', err);
console.warn('Failed to fetch current user permissions for a cf: ', err);
store.dispatch(new GetCfUserRelations(endpoint.guid, GET_CURRENT_CF_USER_RELATIONS_FAILED));
return of(err);
})
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/packages/core/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { recentlyVisitedSelector } from '../../store/src/selectors/recently-visi
import { AppStoreModule } from '../../store/src/store.module';
import { EndpointModel } from '../../store/src/types/endpoint.types';
import { IFavoriteMetadata, UserFavorite } from '../../store/src/types/user-favorites.types';
import { UserFavoriteManager } from '../../store/src/user-favorite-manager';
import { TabNavService } from '../tab-nav.service';
import { XSRFModule } from '../xsrf.module';
import { AppComponent } from './app.component';
Expand All @@ -36,7 +37,6 @@ import { DynamicExtensionRoutes } from './core/extension/dynamic-extension-route
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 { UserFavoriteManager } from './core/user-favorite-manager';
import { CustomImportModule } from './custom-import.module';
import { AboutModule } from './features/about/about.module';
import { DashboardModule } from './features/dashboard/dashboard.module';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { BehaviorSubject, of } from 'rxjs';

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 { UserFavoriteManager } from '../user-favorite-manager';
import { EntityFavoriteStarComponent } from './entity-favorite-star.component';

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

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';
import { UserFavoriteManager } from '../user-favorite-manager';

@Component({
selector: 'app-entity-favorite-star',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { cfAPIVersion, proxyAPIVersion } from '../../../store/src/jetstream';
import { LogLevel } from './../../../store/src/actions/log.actions';

export const environment = {
production: true,
logLevel: LogLevel.WARN,
proxyAPIVersion: 'v1',
cfAPIVersion: 'v2',
proxyAPIVersion,
cfAPIVersion,
logToConsole: true,
logEnableConsoleActions: false,
showObsDebug: false,
Expand Down
5 changes: 3 additions & 2 deletions src/frontend/packages/core/src/environments/environment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { LogLevel } from '../../../store/src/actions/log.actions';
import { cfAPIVersion, proxyAPIVersion } from '../../../store/src/jetstream';

// The file contents for the current environment will overwrite these during build.
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
Expand All @@ -7,8 +8,8 @@ import { LogLevel } from '../../../store/src/actions/log.actions';

export const environment = {
production: false,
proxyAPIVersion: 'v1',
cfAPIVersion: 'v2',
proxyAPIVersion,
cfAPIVersion,
logLevel: LogLevel.DEBUG,
logToConsole: true,
logEnableConsoleActions: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { first, map } from 'rxjs/operators';

import { RouterNav } from '../../../../../store/src/actions/router.actions';
import { AppState, IRequestEntityTypeState } from '../../../../../store/src/app-state';
import { EntityCatalogHelpers } from '../../../../../store/src/entity-catalog/entity-catalog.helper';
import { IUserFavoritesGroups } from '../../../../../store/src/types/favorite-groups.types';
import { UserFavorite } from '../../../../../store/src/types/user-favorites.types';
import { UserFavoriteManager } from '../../../../../store/src/user-favorite-manager';
import { EndpointsService } from '../../../core/endpoints.service';
import { LoggerService } from '../../../core/logger.service';
import { UserFavoriteManager } from '../../../core/user-favorite-manager';
import { EntityCatalogHelpers } from '../../../../../store/src/entity-catalog/entity-catalog.helper';

@Component({
selector: 'app-home-page',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, Input, OnInit } from '@angular/core';
import { combineLatest, Observable, ReplaySubject, Subject } from 'rxjs';
import { distinctUntilChanged, map, scan, startWith } from 'rxjs/operators';

import { IFavoriteEntity } from '../../../core/user-favorite-manager';
import { IFavoriteEntity } from '../../../../../store/src/user-favorite-manager';
import { FavoritesConfigMapper, IFavoriteTypes } from '../favorites-meta-card/favorite-config-mapper';


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
IFavoritesInfo,
IGroupedFavorites,
UserFavoriteManager,
} from '../../../core/user-favorite-manager';
} from '../../../../../store/src/user-favorite-manager';


@Component({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { userFavoritesEntitySchema } from '../../../../../store/src/base-entity-
import { entityCatalog } from '../../../../../store/src/entity-catalog/entity-catalog';
import { endpointEntitiesSelector } from '../../../../../store/src/selectors/endpoint.selectors';
import { IFavoriteMetadata, UserFavorite } from '../../../../../store/src/types/user-favorites.types';
import { IFavoriteEntity } from '../../../core/user-favorite-manager';
import { IFavoriteEntity } from '../../../../../store/src/user-favorite-manager';
import { isEndpointConnected } from '../../../features/endpoints/connect.service';
import { ComponentEntityMonitorConfig, StratosStatus } from '../../shared.types';
import { ConfirmationDialogConfig } from '../confirmation-dialog.config';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { Observable, of } from 'rxjs';
import { EntitySchema } from '../../../../../../../../store/src/helpers/entity-schema';
import { EntityMonitorFactory } from '../../../../../../../../store/src/monitors/entity-monitor.factory.service';
import { IFavoriteMetadata, UserFavorite } from '../../../../../../../../store/src/types/user-favorites.types';
import * as favoriteHelpers from '../../../../../../../../store/src/user-favorite-helpers';
import { UserFavoriteManager } from '../../../../../../../../store/src/user-favorite-manager';
import { CoreTestingModule } from '../../../../../../../test-framework/core-test.modules';
import * as favoriteHelpers from '../../../../../../core/user-favorite-helpers';
import { UserFavoriteManager } from '../../../../../../core/user-favorite-manager';
import { SharedModule } from '../../../../../shared.module';
import { ComponentEntityMonitorConfig, StratosStatus } from '../../../../../shared.types';
import { FavoritesConfigMapper } from '../../../../favorites-meta-card/favorite-config-mapper';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { first, map, tap } from 'rxjs/operators';

import { EntityMonitorFactory } from '../../../../../../../../store/src/monitors/entity-monitor.factory.service';
import { IFavoriteMetadata, UserFavorite } from '../../../../../../../../store/src/types/user-favorites.types';
import { getFavoriteFromEntity } from '../../../../../../core/user-favorite-helpers';
import { getFavoriteFromEntity } from '../../../../../../../../store/src/user-favorite-helpers';
import { safeUnsubscribe } from '../../../../../../core/utils.service';
import { ComponentEntityMonitorConfig, StratosStatus } from '../../../../../shared.types';
import { FavoritesConfigMapper } from '../../../../favorites-meta-card/favorite-config-mapper';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { Action } from '@ngrx/store';

import { environment } from '../../../core/src/environments/environment';
import { proxyAPIVersion } from '../jetstream';

export const METRIC_API_START = '[Metrics] API Start';
export const METRIC_API_SUCCESS = '[Metrics] API Success';
export const METRIC_API_FAILED = '[Metrics] API Failed';

const { proxyAPIVersion } = environment;

export const MetricAPIQueryTypes = {
TARGETS: 'targets',
Expand Down
4 changes: 1 addition & 3 deletions src/frontend/packages/store/src/actions/metrics.actions.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { environment } from '../../../core/src/environments/environment';
import { MetricQueryType } from '../../../core/src/shared/services/metrics-range-selector.types';
import { metricEntityType } from '../base-entity-schemas';
import { proxyAPIVersion } from '../jetstream';
import { EntityRequestAction } from '../types/request.types';

export const METRICS_START = '[Metrics] Fetch Start';
export const METRICS_START_SUCCESS = '[Metrics] Fetch Succeeded';
export const METRICS_START_FAILED = '[Metrics] Fetch Failed';

const { proxyAPIVersion } = environment;

export interface IMetricQueryConfigParams {
window?: string;
[key: string]: string | number;
Expand Down
4 changes: 1 addition & 3 deletions src/frontend/packages/store/src/effects/auth.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Actions, Effect, ofType } from '@ngrx/effects';
import { Store } from '@ngrx/store';
import { catchError, map, mergeMap, switchMap, tap } from 'rxjs/operators';

import { LoggerService } from '../../../core/src/core/logger.service';
import { BrowserStandardEncoder } from '../../../core/src/helper';
import {
InvalidSession,
Expand Down Expand Up @@ -44,7 +43,6 @@ export class AuthEffect {
private http: HttpClient,
private actions$: Actions,
private store: Store<DispatchOnlyAppState>,
private logger: LoggerService
) { }

@Effect() loginRequest$ = this.actions$.pipe(
Expand Down Expand Up @@ -164,7 +162,7 @@ export class AuthEffect {
const dashboardData = JSON.parse(storage.getItem(sessionId));
store.dispatch(new HydrateDashboardStateAction(dashboardData));
} catch (e) {
this.logger.warn('Failed to parse user settings from session storage, consider clearing them manually', e);
console.warn('Failed to parse user settings from session storage, consider clearing them manually', e);
}
}
}
Expand Down
Loading

0 comments on commit f1b99b0

Please sign in to comment.