Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typed access to actions and entities via catalog entity: Core Stratos Entities #4387

Merged
merged 17 commits into from
Jun 24, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/master' into stratos-entity-access
  • Loading branch information
richard-cox committed Jun 18, 2020
commit 3accc92eab6e3b87fc76421b5fe391e33ac89d8f
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Schema, schema } from 'normalizr';

import { getAPIResourceGuid } from '../../../cloud-foundry/src/store/selectors/api.selectors';
import { metricEntityType } from '../../../core/src/base-entity-schemas';
import { metricEntityType } from '../../../store/src/base-entity-schemas';
import { EntitySchema } from '../../../store/src/helpers/entity-schema';

export const appAutoscalerInfoEntityType = 'autoscalerInfo';
@@ -10,7 +10,7 @@ export const appAutoscalerPolicyEntityType = 'autoscalerPolicy';
export const appAutoscalerPolicyTriggerEntityType = 'autoscalerPolicyTrigger';
export const appAutoscalerScalingHistoryEntityType = 'autoscalerScalingHistory';
export const appAutoscalerAppMetricEntityType = 'autoscalerAppMetric';
export const appAutoscalerCredentialEntityType = 'autoscalerCredential'
export const appAutoscalerCredentialEntityType = 'autoscalerCredential';

export const AUTOSCALER_ENDPOINT_TYPE = 'autoscaler';

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IOrgFavMetadata } from '../../../cloud-foundry/src/cf-metadata-types';
import { metricEntityType } from '../../../core/src/base-entity-schemas';
import { metricEntityType } from '../../../store/src/base-entity-schemas';
import {
StratosBaseCatalogEntity,
StratosCatalogEntity,
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { metricEntityType } from '../../core/src/base-entity-schemas';
import { metricEntityType } from '../../store/src/base-entity-schemas';
import { EntitySchema } from '../../store/src/helpers/entity-schema';
import { APIResource } from '../../store/src/types/api.types';
import {
Original file line number Diff line number Diff line change
@@ -4,10 +4,10 @@ import { combineLatest, Observable, of } from 'rxjs';
import { first, map } from 'rxjs/operators';

import { EndpointHealthCheck } from '../../core/endpoints-health-checks';
import { metricEntityType } from '../../core/src/base-entity-schemas';
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 {
StratosBaseCatalogEntity,
StratosCatalogEndpointEntity,
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import { EffectsModule } from '@ngrx/effects';
import { generateASEntities } from '../../cf-autoscaler/src/store/autoscaler-entity-generator';
import { getGitHubAPIURL, GITHUB_API_URL } from '../../core/src/core/github.helpers';
import { LoggerService } from '../../core/src/core/logger.service';
import { generateStratosEntities } from '../../core/src/stratos-entity-generator';
import { generateStratosEntities } from '../../store/src/base-entity-types';
import { CATALOGUE_ENTITIES, EntityCatalogFeatureModule } from '../../store/src/entity-catalog.module';
import { entityCatalog, TestEntityCatalog } from '../../store/src/entity-catalog/entity-catalog';
import { testSCFEndpointGuid } from '../../store/testing/public-api';
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@ import { ActivatedRoute } from '@angular/router';
import { Store } from '@ngrx/store';
import { testSCFEndpoint, testSCFEndpointGuid } from '@stratosui/store/testing';

import { endpointEntitySchema } from '../../../../../core/src/base-entity-schemas';
import { TabNavService } from '../../../../../core/tab-nav.service';
import { endpointEntitySchema } from '../../../../../store/src/base-entity-schemas';
import { EntityCatalogHelpers } from '../../../../../store/src/entity-catalog/entity-catalog.helper';
import { EntityCatalogEntityConfig } from '../../../../../store/src/entity-catalog/entity-catalog.types';
import { NormalizedResponse } from '../../../../../store/src/types/api.types';
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@ import { Component } from '@angular/core';
import { Observable } from 'rxjs';
import { first, map } from 'rxjs/operators';

import { metricEntityType } from '../../../../../../../../core/src/base-entity-schemas';
import { IPageSideNavTab } from '../../../../../../../../core/src/features/dashboard/page-side-nav/page-side-nav.component';
import { IHeaderBreadcrumb } from '../../../../../../../../core/src/shared/components/page-header/page-header.types';
import { metricEntityType } from '../../../../../../../../store/src/base-entity-schemas';
import { cfEntityFactory } from '../../../../../../cf-entity-factory';
import { getActiveRouteCfCellProvider } from '../../../../cf.helpers';
import { CloudFoundryEndpointService } from '../../../../services/cloud-foundry-endpoint.service';
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@ import {
CloudFoundrySpaceService,
} from '../../../../../../cloud-foundry/src/features/cloud-foundry/services/cloud-foundry-space.service';
import { safeUnsubscribe } from '../../../../../../core/src/core/utils.service';
import { SnackBarService } from '../../../../../../core/src/shared/services/snackbar.service';
import { RouterNav } from '../../../../../../store/src/actions/router.actions';
import { ShowReturnSnackBar } from '../../../../../../store/src/actions/snackBar.actions';
import { AppState } from '../../../../../../store/src/app-state';

@Component({
@@ -24,7 +24,8 @@ export class CardCfSpaceDetailsComponent implements OnDestroy {
constructor(
public cfSpaceService: CloudFoundrySpaceService,
private store: Store<AppState>,
private router: Router
private router: Router,
private snackBarService: SnackBarService
) {
this.allowSshStatus$ = cfSpaceService.allowSsh$.pipe(
map(status => status === 'false' ? 'Disabled' : 'Enabled')
@@ -34,7 +35,7 @@ export class CardCfSpaceDetailsComponent implements OnDestroy {
goToOrgQuota() {
this.quotaLinkSub = this.cfSpaceService.quotaLink$.subscribe(quotaLink => {
this.store.dispatch(new RouterNav({ path: quotaLink }));
this.store.dispatch(new ShowReturnSnackBar('You were switched to an organization', this.router.url, 'Return to space'));
this.snackBarService.showReturn('You were switched to an organization', this.router.url, 'Return to space');
});
}

Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

import { CFAppState } from '../../../../cloud-foundry/src/cf-app-state';
import { endpointEntitySchema } from '../../../../core/src/base-entity-schemas';
import { endpointEntitySchema } from '../../../../store/src/base-entity-schemas';
import { PaginationMonitor } from '../../../../store/src/monitors/pagination-monitor';
import { APIResource, EntityInfo } from '../../../../store/src/types/api.types';
import { endpointListKey, EndpointModel } from '../../../../store/src/types/endpoint.types';
Original file line number Diff line number Diff line change
@@ -2,37 +2,40 @@ import { Injectable } from '@angular/core';
import { Store } from '@ngrx/store';

import { LongRunningOperationsService } from '../../../../core/src/shared/services/long-running-op.service';
import { ShowSnackBar } from '../../../../store/src/actions/snackBar.actions';
import { SnackBarService } from '../../../../core/src/shared/services/snackbar.service';
import { AppState } from '../../../../store/src/app-state';
import { GetServiceInstance } from '../../actions/service-instances.actions';

@Injectable()
export class LongRunningCfOperationsService extends LongRunningOperationsService {

constructor(store: Store<AppState>) {
constructor(
store: Store<AppState>,
private snackBarService: SnackBarService
) {
super(store);
}

handleLongRunningCreateService(bindApp: boolean) {
const message = `The operation to create the service instance is taking a long time and will continue in the background.
Please refresh the service instance list to check it's status
${bindApp ? ` and then bind the application via the Application page.` : '.'}`;
this.store.dispatch(new ShowSnackBar(message, 'Dismiss'));
this.snackBarService.show(message, 'Dismiss');
}

handleLongRunningUpdateService(serviceInstanceGuid: string, cfGuid: string) {
const message = `The operation to update the service instance is taking a long time and will continue in the background.
Please refresh the service instance list to check it's status`;
this.store.dispatch(new ShowSnackBar(message, 'Dismiss'));
// Also attempt to fetch the service instance, this will update the `last operation` value to `update` and `in progress`
this.snackBarService.show(message, 'Dismiss');
// TODO: RC FIX
this.store.dispatch(new GetServiceInstance(serviceInstanceGuid, cfGuid));
}

handleLongRunningDeleteService(serviceInstanceGuid: string, cfGuid: string) {
const message = `The operation to delete the service instance is taking a long time and will continue in the background.
Please refresh the service instance list to check it's status`;
this.store.dispatch(new ShowSnackBar(message, 'Dismiss'));
this.snackBarService.show(message, 'Dismiss');
// Also attempt to fetch the service instance, this will update the `last operation` value to `delete` and `in progress`
// TODO: RC FIX
this.store.dispatch(new GetServiceInstance(serviceInstanceGuid, cfGuid));
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import { Store } from '@ngrx/store';
import { combineLatest, Observable } from 'rxjs';
import { filter, first, map } from 'rxjs/operators';

import { STRATOS_ENDPOINT_TYPE } from '../../../../core/src/base-entity-schemas';
import { STRATOS_ENDPOINT_TYPE } from '../../../../store/src/base-entity-schemas';
import { entityCatalog } from '../../../../store/src/entity-catalog/entity-catalog';
import { endpointSchemaKey } from '../../../../store/src/helpers/stratos-entity-factory';
import { selectEntity } from '../../../../store/src/selectors/api.selectors';
Original file line number Diff line number Diff line change
@@ -12,15 +12,15 @@ import {
CfPermissionTypes,
CfScopeStrings,
} from '../../../../cloud-foundry/src/user-permissions/cf-user-permissions-checkers';
import { endpointEntitySchema } from '../../../../core/src/base-entity-schemas';
import { PermissionConfig } from '../../../../core/src/core/permissions/current-user-permissions.config';
import { CurrentUserPermissionsService } from '../../../../core/src/core/permissions/current-user-permissions.service';
import { StratosScopeStrings } from '../../../../core/src/core/permissions/stratos-user-permissions.checker';
import { generateStratosEntities } from '../../../../core/src/stratos-entity-generator';
import { AppTestModule } from '../../../../core/test-framework/core-test.helper';
import { AppState } from '../../../../store/src/app-state';
import { generateStratosEntities } from '../../../../store/src/base-entity-types';
import { EntityCatalogTestModule, TEST_CATALOGUE_ENTITIES } from '../../../../store/src/entity-catalog-test.module';
import { EntityCatalogEntityConfig } from '../../../../store/src/entity-catalog/entity-catalog.types';
import { endpointSchemaKey, stratosEntityFactory } from '../../../../store/src/helpers/stratos-entity-factory';
import { APIResource } from '../../../../store/src/types/api.types';
import { EndpointModel } from '../../../../store/src/types/endpoint.types';
import { BaseEntityValues } from '../../../../store/src/types/entity.types';
@@ -588,7 +588,7 @@ describe('CurrentUserPermissionsService with CF checker', () => {
// Create request and requestData sections
const entityMap = new Map<EntityCatalogEntityConfig, Array<TestStoreEntity | string>>([
[
endpointEntitySchema,
stratosEntityFactory(endpointSchemaKey),
endpoints.map(endpoint => ({
guid: endpoint.guid,
data: endpoint
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { generateStratosEntities } from '../../core/src/stratos-entity-generator';
import { BaseTestModules } from '../../core/test-framework/core-test.helper';
import { generateStratosEntities } from '../../store/src/base-entity-types';
import { EntityCatalogTestModule, TEST_CATALOGUE_ENTITIES } from '../../store/src/entity-catalog-test.module';
import { generateCFEntities } from '../src/cf-entity-generator';

5 changes: 2 additions & 3 deletions src/frontend/packages/core/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -13,11 +13,12 @@ import {
UpdateUserFavoriteMetadataAction,
} from '../../store/src/actions/user-favourites-actions/update-user-favorite-metadata-action';
import { GeneralEntityAppState, GeneralRequestDataState } from '../../store/src/app-state';
import { generateStratosEntities } from '../../store/src/base-entity-types';
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 { endpointSchemaKey } from '../../store/src/helpers/stratos-entity-factory';
import { endpointSchemaKey, STRATOS_ENDPOINT_TYPE } from '../../store/src/helpers/stratos-entity-factory';
import { getAPIRequestDataState, selectEntity } from '../../store/src/selectors/api.selectors';
import { internalEventStateSelector } from '../../store/src/selectors/internal-events.selectors';
import { recentlyVisitedSelector } from '../../store/src/selectors/recently-visitied.selectors';
@@ -28,7 +29,6 @@ import { TabNavService } from '../tab-nav.service';
import { XSRFModule } from '../xsrf.module';
import { AppComponent } from './app.component';
import { RouteModule } from './app.routing';
import { STRATOS_ENDPOINT_TYPE } from './base-entity-schemas';
import { CoreModule } from './core/core.module';
import { CustomizationService } from './core/customizations.types';
import { DynamicExtensionRoutes } from './core/extension/dynamic-extension-routes';
@@ -49,7 +49,6 @@ import { FavoritesConfigMapper } from './shared/components/favorites-meta-card/f
import { endpointEventKey, GlobalEventData, GlobalEventService } from './shared/global-events.service';
import { SidePanelService } from './shared/services/side-panel.service';
import { SharedModule } from './shared/shared.module';
import { generateStratosEntities } from './stratos-entity-generator';

// Create action for router navigation. See
// - https://github.com/ngrx/platform/issues/68
Original file line number Diff line number Diff line change
@@ -3,14 +3,14 @@ import { createBasicStoreModule, createEntityStoreState, TestStoreEntity } from
import { first, tap } from 'rxjs/operators';

import { AppState } from '../../../../store/src/app-state';
import { generateStratosEntities } from '../../../../store/src/base-entity-types';
import { EntityCatalogTestModule, TEST_CATALOGUE_ENTITIES } from '../../../../store/src/entity-catalog-test.module';
import { EntityCatalogEntityConfig } from '../../../../store/src/entity-catalog/entity-catalog.types';
import { endpointSchemaKey, stratosEntityFactory } from '../../../../store/src/helpers/stratos-entity-factory';
import { EndpointModel } from '../../../../store/src/types/endpoint.types';
import { BaseEntityValues } from '../../../../store/src/types/entity.types';
import { PaginationState } from '../../../../store/src/types/pagination.types';
import { AppTestModule } from '../../../test-framework/core-test.helper';
import { endpointEntitySchema } from '../../base-entity-schemas';
import { generateStratosEntities } from '../../stratos-entity-generator';
import { PermissionConfig } from './current-user-permissions.config';
import { CurrentUserPermissionsService } from './current-user-permissions.service';
import { StratosPermissionStrings, StratosPermissionTypes, StratosScopeStrings } from './stratos-user-permissions.checker';
@@ -138,7 +138,7 @@ describe('CurrentUserPermissionsService', () => {
// Create request and requestData sections
const entityMap = new Map<EntityCatalogEntityConfig, Array<TestStoreEntity | string>>([
[
endpointEntitySchema,
stratosEntityFactory(endpointSchemaKey),
endpoints.map(endpoint => ({
guid: endpoint.guid,
data: endpoint
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ import {
import { StratosUserPermissionsChecker } from './stratos-user-permissions.checker';


export const CUSTOM_USER_PERMISSION_CHECKERS = 'custom_user_perm_checkers'
export const CUSTOM_USER_PERMISSION_CHECKERS = 'custom_user_perm_checkers';

@Injectable()
export class CurrentUserPermissionsService {
@@ -35,7 +35,7 @@ export class CurrentUserPermissionsService {
this.allCheckers = [
new StratosUserPermissionsChecker(store),
...nullSafeCustomCheckers
]
];
}
/**
* @param action The action we're going to check the user's access to.
@@ -53,13 +53,13 @@ export class CurrentUserPermissionsService {
): Observable<boolean> {
let actionConfig;
if (typeof action === 'string') {
let permConfigType = this.getPermissionConfig(action);
const permConfigType = this.getPermissionConfig(action);
if (!permConfigType) {
return of(false); // Logging handled in getPermissionConfig
}
actionConfig = this.getConfig(permConfigType);
} else {
actionConfig = this.getConfig(action)
actionConfig = this.getConfig(action);
}
const obs$ = this.getCanObservable(actionConfig, endpointGuid, ...args);
return obs$ ?
@@ -93,7 +93,7 @@ export class CurrentUserPermissionsService {
'permissions check',
actionConfig.type,
of(false)
)
);
}

private getComplexPermission(permissionConfig: PermissionConfig[], endpointGuid?: string, ...args: any[]) {
@@ -113,7 +113,7 @@ export class CurrentUserPermissionsService {
[{
checks: [of(false)]
}]
)
);
}

private getConfig(config: PermissionConfigType, tries = 0): PermissionConfig[] | PermissionConfig {
@@ -149,7 +149,7 @@ export class CurrentUserPermissionsService {
'fallback permission',
'N/A',
of(null)
)
);
}

private getPermissionConfig(key: CurrentUserPermissions): PermissionConfigType {
@@ -158,7 +158,7 @@ export class CurrentUserPermissionsService {
'permissions checker',
key,
null
)
);
}

/**
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { FormGroup } from '@angular/forms';
import { Component, Input } from '@angular/core';
import { IAuthForm } from '../../../../core/extension/extension-types';
import { FormGroup } from '@angular/forms';

import { IAuthForm } from '../../../../../../store/src/extension-types';

@Component({
selector: 'app-credentials-auth-form',
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, Input } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { IAuthForm } from '../../../../core/extension/extension-types';

import { IAuthForm } from '../../../../../../store/src/extension-types';

@Component({
selector: 'app-none-auth-form',
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, Input } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { IAuthForm } from '../../../../core/extension/extension-types';

import { IAuthForm } from '../../../../../../store/src/extension-types';

@Component({
selector: 'app-sso-auth-form',
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.