Skip to content

Commit

Permalink
lint fixes - core
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-cox committed Feb 25, 2019
1 parent 15295c5 commit 5ebe64f
Show file tree
Hide file tree
Showing 137 changed files with 981 additions and 971 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"test-frontend:store": "ng test store --code-coverage --watch=false",
"posttest": "istanbul report json && node build/combine-coverage.js",
"codecov": "codecov -f coverage/coverage-final.json",
"lint": "ng lint",
"lint": "ng lint --format stylish",
"sass-lint": "sass-lint -v",
"e2e": "ng e2e",
"e2e-dev": "ng e2e --dev-server-target= --base-url=https://127.0.0.1:4200",
Expand Down
56 changes: 56 additions & 0 deletions src/frontend/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8">
<title>Stratos</title>
<base href="/">

<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="stratos_git_project" content="https://github.com/cloudfoundry-incubator/stratos.git">
<meta name="stratos_git_branch" content="fix-visible-space-roles">
<meta name="stratos_git_commit" content="bf11dc43edb32f86cfa52368128072f61c6d4b50">
<meta name="stratos_build_date" content="Wed Feb 20 2019 14:35:01 GMT+0000 (GMT)">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<noscript>
<style>
.stratos {
height: 100vh;
margin: 0;
width: 100vw;
}
.no-javascript {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100%;
width: 100%;
}
.message {
font-family: Arial, Helvetica;
font-size: 24px;
margin-bottom: 24px;
}
.title {
font-size: 36px;
font-weight: bold;
text-transform: uppercase;
}
</style>
</noscript>

</head>

<body class="stratos">
<app-root></app-root>
<noscript>
<div class="no-javascript">
<div class="message title">Stratos</div>
<div class="message">Javascript is required to run Stratos</div>
<div class="message">Please enable Javascript in your browser and refresh this page</div>
</div>
</noscript>
</body>

</html>
5 changes: 2 additions & 3 deletions src/frontend/packages/core/src/core/cf-api.types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { IRoute } from './cf-api.types';
import { APIResource } from '../../../store/src/types/api.types';
import { IServiceBinding, IService } from './cf-api-svc.types';
import { CfUser } from '../../../store/src/types/user.types';
import { IService, IServiceBinding } from './cf-api-svc.types';

export interface IRoute {
host: string;
Expand Down Expand Up @@ -138,7 +137,7 @@ export interface IDockercredentials {
}

export interface IEnvironmentjson {
[any: string]: string;
[key: string]: string;
}

export interface IDeveloper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ import { Store } from '@ngrx/store';
import { combineLatest, Observable, of as observableOf } from 'rxjs';
import { distinctUntilChanged, filter, map, switchMap } from 'rxjs/operators';

import { CFFeatureFlagTypes } from '../shared/components/cf-auth/cf-auth.types';
import {
createCFFeatureFlagPaginationKey,
} from '../shared/components/list/list-types/cf-feature-flags/cf-feature-flags-data-source.helpers';
import { PaginationMonitor } from '../shared/monitors/pagination-monitor';
import { AppState } from '../../../store/src/app-state';
import { entityFactory, featureFlagSchemaKey } from '../../../store/src/helpers/entity-factory';
import {
Expand All @@ -19,6 +14,11 @@ import {
import { endpointsRegisteredEntitiesSelector } from '../../../store/src/selectors/endpoint.selectors';
import { APIResource } from '../../../store/src/types/api.types';
import { IOrgRoleState, ISpaceRoleState, ISpacesRoleState } from '../../../store/src/types/current-user-roles.types';
import { CFFeatureFlagTypes } from '../shared/components/cf-auth/cf-auth.types';
import {
createCFFeatureFlagPaginationKey,
} from '../shared/components/list/list-types/cf-feature-flags/cf-feature-flags-data-source.helpers';
import { PaginationMonitor } from '../shared/monitors/pagination-monitor';
import { IFeatureFlag } from './cf-api.types';
import {
PermissionConfig,
Expand Down Expand Up @@ -78,11 +78,7 @@ export class CurrentUserPermissionsChecker {
);
}
/**
*
* @param permissionConfig Single permission to be checked
* @param endpointGuid
* @param orgOrSpaceGuid
* @param spaceGuid
*/
public getSimpleCheck(permissionConfig: PermissionConfig, endpointGuid?: string, orgOrSpaceGuid?: string, spaceGuid?: string) {
switch (permissionConfig.type) {
Expand Down Expand Up @@ -208,7 +204,7 @@ export class CurrentUserPermissionsChecker {
}

public checkFeatureFlag(featureFlags: APIResource<IFeatureFlag>[], permission: CFFeatureFlagTypes) {
const flag = featureFlags.find(_flag => _flag.entity.name === permission.toString());
const flag = featureFlags.find(ff => ff.entity.name === permission.toString());
if (!flag) {
return false;
}
Expand All @@ -231,8 +227,8 @@ export class CurrentUserPermissionsChecker {
}

/**
* Includes read only admins, global auditors and users that don't have the cloud_controller.write scope
*/
* Includes read only admins, global auditors and users that don't have the cloud_controller.write scope
*/
public getReadOnlyCheck(endpointGuid: string) {
return this.getEndpointState(endpointGuid).pipe(
map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ const initialState = {
currentPage: 1,
totalResults: 2,
ids: {
'1': [
1: [
'0e934dc8-7ad4-40ff-b85c-53c1b61d2abb',
'c80420ca-204b-4879-bf69-b6b7a202ad87'
]
},
pageRequests: {
'1': {
1: {
busy: false,
error: false,
message: ''
Expand Down Expand Up @@ -73,7 +73,7 @@ const initialState = {
currentPage: 1,
totalResults: 13,
ids: {
'1': [
1: [
'0e934dc8-7ad4-40ff-b85c-53c1b61d2abb-0',
'0e934dc8-7ad4-40ff-b85c-53c1b61d2abb-1',
'0e934dc8-7ad4-40ff-b85c-53c1b61d2abb-2',
Expand All @@ -90,7 +90,7 @@ const initialState = {
]
},
pageRequests: {
'1': {
1: {
busy: false,
error: false,
message: ''
Expand All @@ -112,7 +112,7 @@ const initialState = {
currentPage: 1,
totalResults: 13,
ids: {
'1': [
1: [
'c80420ca-204b-4879-bf69-b6b7a202ad87-0',
'c80420ca-204b-4879-bf69-b6b7a202ad87-1',
'c80420ca-204b-4879-bf69-b6b7a202ad87-2',
Expand All @@ -129,7 +129,7 @@ const initialState = {
]
},
pageRequests: {
'1': {
1: {
busy: false,
error: false,
message: ''
Expand Down Expand Up @@ -695,7 +695,7 @@ const initialState = {
}
}
},
'READ_ONLY_ADMIN': {
READ_ONLY_ADMIN: {
global: {
isAdmin: false,
isReadOnlyAdmin: true,
Expand Down Expand Up @@ -759,7 +759,7 @@ const initialState = {
}
}
},
'READ_ONLY_USER': {
READ_ONLY_USER: {
global: {
isAdmin: false,
isReadOnlyAdmin: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,21 @@ export class CurrentUserPermissionsService {
}
}

private getConfig(config: PermissionConfigType, _tries = 0): PermissionConfig[] | PermissionConfig {
private getConfig(config: PermissionConfigType, tries = 0): PermissionConfig[] | PermissionConfig {
const linkConfig = config as PermissionConfigLink;
if (linkConfig.link) {
if (_tries >= 20) {
if (tries >= 20) {
// Tried too many times to get permission config, circular reference very likely.
return;
}
++_tries;
return this.getLinkedPermissionConfig(linkConfig, _tries);
++tries;
return this.getLinkedPermissionConfig(linkConfig, tries);
} else {
return config as PermissionConfig[] | PermissionConfig;
}
}

private getLinkedPermissionConfig(linkConfig: PermissionConfigLink, _tries = 0) {
private getLinkedPermissionConfig(linkConfig: PermissionConfigLink, tries = 0) {
return this.getConfig(permissionConfigs[linkConfig.link]);
}

Expand Down
19 changes: 9 additions & 10 deletions src/frontend/packages/core/src/core/dispatch-sequencer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Action, Store } from '@ngrx/store';
import { from, Observable, of as observableOf } from 'rxjs';
import { bufferTime, concatMap, delay, filter, map, mergeMap, switchMap, tap } from 'rxjs/operators';

import { AppState } from '../../../store/src/app-state';


Expand All @@ -16,20 +17,18 @@ export class DispatchSequencer {
} = {};

/**
* @param {Store<AppState>} store
* @param {number} [batchSize=5]
* @param [batchSize=5]
* Multiple requests will be split up into batches of this size
* @param {number} [batchDelayInMs=5000]
* @param [batchDelayInMs=5000]
* Delay to apply between each batch
* @param {number} [debounceInMs=5000]
* @param [debounceInMs=5000]
* Ignore repeat request made within this time period
* @memberof DispatchSequencer
*/
constructor(private store: Store<AppState>, private batchSize = 5, private batchDelayInMs = 5000, private debounceInMs = 5000) { }

/**
* Filter out recently dispatched actions
*/
* Filter out recently dispatched actions
*/
private filter(actions: DispatchSequencerAction[]): DispatchSequencerAction[] {
if (this.debounceInMs) {
const now = new Date().getTime();
Expand All @@ -49,9 +48,9 @@ export class DispatchSequencer {
}

/**
* Dispatch actions in groups of `batchSize` such that there are no duplicate actions dispatched within `debounceInMs`. Each batch dispatch
* will be separated by `batchDelayInMs`.
*/
* Dispatch actions in groups of `batchSize` such that there are no duplicate actions dispatched within `debounceInMs`. Each batch
* dispatch will be separated by `batchDelayInMs`.
*/
public sequence(obs: Observable<DispatchSequencerAction[]>): Observable<any> {
return obs.pipe(switchMap(actions => this.innerSequence(actions)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ export class EntityFavoriteStarComponent {
this.confirmationDialogConfig.message =
`Are you sure you would you like to unfavorite this ${name ? name.toLocaleLowerCase() : 'favorite'}?`;
this.isFavorite$ = this.userFavoriteManager.getIsFavoriteObservable(favorite);
this._favorite = favorite;
this.pFavourite = favorite;
}
private _favorite: UserFavorite<IFavoriteMetadata>;
private pFavourite: UserFavorite<IFavoriteMetadata>;

@Input()
private confirmRemoval = false;
Expand All @@ -48,18 +48,18 @@ export class EntityFavoriteStarComponent {
first(),
tap(is => {
if (is) {
this.confirmDialog.open(this.confirmationDialogConfig, this._toggleFavorite);
this.confirmDialog.open(this.confirmationDialogConfig, this.pToggleFavorite);
} else {
this._toggleFavorite();
this.pToggleFavorite();
}
})
).subscribe();
} else {
this._toggleFavorite();
this.pToggleFavorite();
}
}

private _toggleFavorite = () => {
this.userFavoriteManager.toggleFavorite(this._favorite);
private pToggleFavorite = (res?: any) => {
this.userFavoriteManager.toggleFavorite(this.pFavourite);
}
}
19 changes: 12 additions & 7 deletions src/frontend/packages/core/src/core/entity-service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,27 @@ import { HttpModule, XHRBackend } from '@angular/http';
import { MockBackend } from '@angular/http/testing';
import { Store } from '@ngrx/store';
import { schema as normalizrSchema } from 'normalizr';
import { filter, first, tap, pairwise, map } from 'rxjs/operators';
import { ENTITY_SERVICE } from '../shared/entity.tokens';
import { EntityMonitor } from '../shared/monitors/entity-monitor';
import { EntityMonitorFactory } from '../shared/monitors/entity-monitor.factory.service';
import { filter, first, map, pairwise, tap } from 'rxjs/operators';

import { GetApplication } from '../../../store/src/actions/application.actions';
import { APIResponse } from '../../../store/src/actions/request.actions';
import { AppState } from '../../../store/src/app-state';
import { applicationSchemaKey, entityFactory } from '../../../store/src/helpers/entity-factory';
import { completeApiRequest, startApiRequest, failApiRequest } from '../../../store/src/reducers/api-request-reducer/request-helpers';
import {
completeApiRequest,
failApiRequest,
startApiRequest,
} from '../../../store/src/reducers/api-request-reducer/request-helpers';
import { RequestSectionKeys } from '../../../store/src/reducers/api-request-reducer/types';
import { NormalizedResponse } from '../../../store/src/types/api.types';
import { ICFAction, IRequestAction } from '../../../store/src/types/request.types';
import { EntityService } from './entity-service';
import { EntityServiceFactory } from './entity-service-factory.service';
import { generateTestEntityServiceProvider } from '../../test-framework/entity-service.helper';
import { createBasicStoreModule } from '../../test-framework/store-test-helper';
import { ENTITY_SERVICE } from '../shared/entity.tokens';
import { EntityMonitor } from '../shared/monitors/entity-monitor';
import { EntityMonitorFactory } from '../shared/monitors/entity-monitor.factory.service';
import { EntityService } from './entity-service';
import { EntityServiceFactory } from './entity-service-factory.service';


const appId = '4e4858c4-24ab-4caf-87a8-7703d1da58a0';
Expand Down
Loading

0 comments on commit 5ebe64f

Please sign in to comment.