Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into home-page-configura…
Browse files Browse the repository at this point in the history
…ble-view
  • Loading branch information
richard-cox committed Dec 1, 2020
2 parents 68035f3 + 4aec384 commit caf2ec2
Show file tree
Hide file tree
Showing 21 changed files with 50 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ import {
userProvidedServiceInstanceEntityType,
} from './cf-entity-types';
import { CfErrorResponse, getCfError } from './cf-error-helpers';
import { getFavoriteFromCfEntity } from './cf-favorites-helpers';
import { ISpaceFavMetadata } from './cf-metadata-types';
import { CF_ENDPOINT_TYPE } from './cf-types';
import {
Expand Down Expand Up @@ -164,7 +163,7 @@ import { routeReducer, updateAppSummaryRoutesReducer } from './store/reducers/ro
import { serviceInstanceReducer } from './store/reducers/service-instance.reducer';
import { updateSpaceQuotaReducer } from './store/reducers/space-quota.reducer';
import { AppStat } from './store/types/app-metadata.types';
import { CFResponse } from './store/types/cf-api.types';
import { CfAPIResource, CFResponse } from './store/types/cf-api.types';
import { CfUser } from './store/types/cf-user.types';
import { cfUserRolesFetch } from './user-permissions/cf-user-roles-fetch';

Expand Down Expand Up @@ -274,7 +273,7 @@ export function generateCFEntities(): StratosBaseCatalogEntity[] {
listDetailsComponent: CfEndpointDetailsComponent,
renderPriority: 1,
healthCheck: new EndpointHealthCheck(CF_ENDPOINT_TYPE, (endpoint) => cfEntityCatalog.cfInfo.api.get(endpoint.guid)),
favoriteFromEntity: getFavoriteFromCfEntity,
getEndpointIdFromEntity: (entity: CfAPIResource) => entity.entity.cfGuid,
globalPreRequest: (request, action) => {
return addCfRelationParams(request, action);
},
Expand Down Expand Up @@ -1198,4 +1197,3 @@ function generateCFMetrics(endpointDefinition: StratosEndpointExtensionDefinitio
);
return cfEntityCatalog.metric;
}

25 changes: 0 additions & 25 deletions src/frontend/packages/cloud-foundry/src/cf-favorites-helpers.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { endpointEntitiesSelector } from '../../../../../../store/src/selectors/
import { APIResource } from '../../../../../../store/src/types/api.types';
import { EndpointModel } from '../../../../../../store/src/types/endpoint.types';
import { IFavoriteMetadata } from '../../../../../../store/src/types/user-favorites.types';
import { getFavoriteFromEntity } from '../../../../../../store/src/user-favorite-helpers';
import { UserFavoriteManager } from '../../../../../../store/src/user-favorite-manager';
import { UpdateExistingApplication } from '../../../../actions/application.actions';
import { IApp, IOrganization, ISpace } from '../../../../cf-api.types';
Expand All @@ -48,7 +47,7 @@ export class ApplicationTabsBaseComponent implements OnInit, OnDestroy {

public favorite$ = this.applicationService.app$.pipe(
filter(app => !!app),
map(app => getFavoriteFromEntity<IFavoriteMetadata>(app.entity, applicationEntityType, this.userFavoriteManager, CF_ENDPOINT_TYPE))
map(app => this.userFavoriteManager.getFavorite<IFavoriteMetadata>(app.entity, applicationEntityType, CF_ENDPOINT_TYPE))
);

isBusyUpdating$: Observable<{ updating: boolean; }>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class LogStreamTabComponent implements OnInit {
msgColour = 'red';
bold = true;
}
const messageString = this.colorizer.colorize(atob(messageObj.message), msgColour, bold) + '\n';
const messageString = this.colorizer.colorize(decodeURIComponent(escape(atob(messageObj.message))), msgColour, bold) + '\n';
return timeStamp + ': ' + messageSource + ' ' + messageString;
} catch (error) {
console.error('Failed to filter jsonMessage from WebSocket: ' + JSON.stringify(error));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { IPageSideNavTab } from '../../../../../../../core/src/features/dashboar
import { IHeaderBreadcrumb } from '../../../../../../../core/src/shared/components/page-header/page-header.types';
import { EntitySchema } from '../../../../../../../store/src/helpers/entity-schema';
import { IFavoriteMetadata, UserFavorite } from '../../../../../../../store/src/types/user-favorites.types';
import { getFavoriteFromEntity } from '../../../../../../../store/src/user-favorite-helpers';
import { UserFavoriteManager } from '../../../../../../../store/src/user-favorite-manager';
import { cfEntityFactory } from '../../../../../cf-entity-factory';
import { organizationEntityType } from '../../../../../cf-entity-types';
Expand Down Expand Up @@ -98,7 +97,7 @@ export class CloudFoundryOrganizationBaseComponent {
this.schema = cfEntityFactory(organizationEntityType);
this.favorite$ = cfOrgService.org$.pipe(
first(),
map(org => getFavoriteFromEntity<IFavoriteMetadata>(org.entity, organizationEntityType, userFavoriteManager, CF_ENDPOINT_TYPE))
map(org => userFavoriteManager.getFavorite<IFavoriteMetadata>(org.entity, organizationEntityType, CF_ENDPOINT_TYPE))
);
this.name$ = cfOrgService.org$.pipe(
map(org => org.entity.entity.name),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { ConfirmationDialogService } from '../../../../../../../../core/src/shar
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 { UserFavoriteManager } from '../../../../../../../../store/src/user-favorite-manager';
import { CFAppState } from '../../../../../../cf-app-state';
import { cfEntityFactory } from '../../../../../../cf-entity-factory';
Expand Down Expand Up @@ -115,7 +114,7 @@ export class CloudFoundrySpaceBaseComponent implements OnDestroy {
userFavoriteManager: UserFavoriteManager
) {
this.favorite$ = cfSpaceService.space$.pipe(
map(space => getFavoriteFromEntity<ISpaceFavMetadata>(space.entity, spaceEntityType, userFavoriteManager, CF_ENDPOINT_TYPE))
map(space => userFavoriteManager.getFavorite<ISpaceFavMetadata>(space.entity, spaceEntityType, CF_ENDPOINT_TYPE))
);
this.isFetching$ = cfSpaceService.space$.pipe(
map(space => space.entityRequestInfo.fetching)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { CardCell } from '../../../../../../../../core/src/shared/components/lis
import { APIResource } from '../../../../../../../../store/src/types/api.types';
import { ComponentEntityMonitorConfig, StratosStatus } from '../../../../../../../../store/src/types/shared.types';
import { IFavoriteMetadata, UserFavorite } from '../../../../../../../../store/src/types/user-favorites.types';
import { getFavoriteFromEntity } from '../../../../../../../../store/src/user-favorite-helpers';
import { UserFavoriteManager } from '../../../../../../../../store/src/user-favorite-manager';
import { IApp, ISpace } from '../../../../../../cf-api.types';
import { cfEntityFactory } from '../../../../../../cf-entity-factory';
Expand Down Expand Up @@ -50,7 +49,7 @@ export class CardAppComponent extends CardCell<APIResource<IApp>> implements OnI
this.row.entity.space_guid
);

this.favorite = getFavoriteFromEntity(this.row, applicationEntityType, this.userFavoriteManager, CF_ENDPOINT_TYPE);
this.favorite = this.userFavoriteManager.getFavorite(this.row, applicationEntityType, CF_ENDPOINT_TYPE);

const initState = this.appStateService.get(this.row.entity, null);
this.applicationState$ = ApplicationService.getApplicationState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { EndpointUser } from '../../../../../../../../store/src/types/endpoint.t
import { MenuItem } from '../../../../../../../../store/src/types/menu-item.types';
import { ComponentEntityMonitorConfig, StratosStatus } from '../../../../../../../../store/src/types/shared.types';
import { IFavoriteMetadata, UserFavorite } from '../../../../../../../../store/src/types/user-favorites.types';
import { getFavoriteFromEntity } from '../../../../../../../../store/src/user-favorite-helpers';
import { UserFavoriteManager } from '../../../../../../../../store/src/user-favorite-manager';
import { IApp, IOrganization } from '../../../../../../cf-api.types';
import { cfEntityFactory } from '../../../../../../cf-entity-factory';
Expand Down Expand Up @@ -96,7 +95,7 @@ export class CfOrgCardComponent extends CardCell<APIResource<IOrganization>> imp
refCount()
);

this.favorite = getFavoriteFromEntity(this.row, organizationEntityType, this.userFavoriteManager, CF_ENDPOINT_TYPE);
this.favorite = this.userFavoriteManager.getFavorite(this.row, organizationEntityType, CF_ENDPOINT_TYPE);

const allApps$: Observable<APIResource<IApp>[]> = this.cfEndpointService.appsPagObs.hasEntities$.pipe(
switchMap(hasAll => hasAll ? this.cfEndpointService.getAppsInOrgViaAllApps(this.row) : observableOf(null))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { EndpointUser } from '../../../../../../../../store/src/types/endpoint.t
import { MenuItem } from '../../../../../../../../store/src/types/menu-item.types';
import { ComponentEntityMonitorConfig, StratosStatus } from '../../../../../../../../store/src/types/shared.types';
import { UserFavorite } from '../../../../../../../../store/src/types/user-favorites.types';
import { getFavoriteFromEntity } from '../../../../../../../../store/src/user-favorite-helpers';
import { UserFavoriteManager } from '../../../../../../../../store/src/user-favorite-manager';
import { IApp, ISpace } from '../../../../../../cf-api.types';
import { cfEntityFactory } from '../../../../../../cf-entity-factory';
Expand Down Expand Up @@ -77,7 +76,7 @@ export class CfSpaceCardComponent extends CardCell<APIResource<ISpace>> implemen
this.spaceGuid = this.row.metadata.guid;
this.entityConfig = new ComponentEntityMonitorConfig(this.spaceGuid, cfEntityFactory(spaceEntityType));
this.orgGuid = this.cfOrgService.orgGuid;
this.favorite = getFavoriteFromEntity(this.row, spaceEntityType, this.userFavoriteManager, CF_ENDPOINT_TYPE);
this.favorite = this.userFavoriteManager.getFavorite(this.row, spaceEntityType, CF_ENDPOINT_TYPE);
this.cardMenu = [
{
label: 'Edit',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ <h1>Home</h1>
<mat-menu #appMenu="matMenu" xPosition="before">
<div *ngFor="let layout of layouts">
<button *ngIf="layout" (click)="onChangeLayout(layout)" mat-menu-item class="layout-menu">
<div [ngClass]="{'layout-menu__tick' : layout.id === layoutID}" class="layout-menu__label">{{ layout.title }}</div>
<mat-icon [ngClass]="{'layout-menu__tick' : layout.id === layoutID}" class="layout-menu__icon">done</mat-icon>
<div [ngClass]="{'layout-menu__tick' : layout.id === layoutID}" class="layout-menu__label">
{{ layout.title }}</div>
<mat-icon [ngClass]="{'layout-menu__tick' : layout.id === layoutID}" class="layout-menu__icon">done
</mat-icon>
</button>
<div *ngIf="!layout" class="layout-menu__sep"></div>
</div>
Expand All @@ -24,18 +26,21 @@ <h1>Home</h1>
</div>
</app-page-header>
<div class="home-page" *ngIf="haveThingsToShow$ | async ; else noEndpoints">
<div class="home-page__list" [ngClass]="{'home-page__list-2': columns === 2, 'home-page__list-3': columns === 3}" #endpointsPanel>
<div class="home-page__list" [ngClass]="{'home-page__list-2': columns === 2, 'home-page__list-3': columns === 3}"
#endpointsPanel>
<div *ngFor="let ep of endpoints$ | async" class="home-page__card" #endpointCard>
<app-home-page-endpoint-card (loaded)="cardLoaded()" [layout]="layout$ | async" [endpoint]="ep"></app-home-page-endpoint-card>
<app-home-page-endpoint-card (loaded)="cardLoaded()" [layout]="layout$ | async" [endpoint]="ep">
</app-home-page-endpoint-card>
</div>
</div>
</div>
<ng-template #noEndpoints>
<div class="home-page" *ngIf="haveRegistered$ | async; else noneRegistered">
<app-no-content-message [icon]="noneAvailableMsg.icon" [firstLine]="noneAvailableMsg.firstLine" [secondLine]="noneAvailableMsg.secondLine"></app-no-content-message>
<app-no-content-message [icon]="noneAvailableMsg.icon" [firstLine]="noneAvailableMsg.firstLine"
[secondLine]="noneAvailableMsg.secondLine"></app-no-content-message>
</div>
</ng-template>

<ng-template #noneRegistered>
<app-endpoints-missing class="home-page" [showToolbarHint]="false"></app-endpoints-missing>
</ng-template>
</ng-template>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { EntitySchema } from '../../../../../../../../store/src/helpers/entity-s
import { EntityMonitorFactory } from '../../../../../../../../store/src/monitors/entity-monitor.factory.service';
import { ComponentEntityMonitorConfig, StratosStatus } from '../../../../../../../../store/src/types/shared.types';
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 { SharedModule } from '../../../../../shared.module';
Expand Down Expand Up @@ -146,14 +145,6 @@ describe('MetaCardComponent', () => {
expect(element.querySelector('app-entity-favorite-star')).toBeTruthy();
});

it('should set favorite from entityConfig if not set', () => {
spyOn(favoriteHelpers, 'getFavoriteFromEntity').and.returnValue(favorite);
component.entityConfig = entityConfig;
fixture.detectChanges();

expect(element.querySelector('app-entity-favorite-star')).toBeTruthy();
});

it('should show app state icon if status', () => {
expect(element.querySelector('app-application-state-icon')).toBeFalsy();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { EntityMonitorFactory } from '../../../../../../../../store/src/monitors
import { MenuItem } from '../../../../../../../../store/src/types/menu-item.types';
import { ComponentEntityMonitorConfig, StratosStatus } from '../../../../../../../../store/src/types/shared.types';
import { IFavoriteMetadata, UserFavorite } from '../../../../../../../../store/src/types/user-favorites.types';
import { getFavoriteFromEntity } from '../../../../../../../../store/src/user-favorite-helpers';
import { UserFavoriteManager } from '../../../../../../../../store/src/user-favorite-manager';
import { safeUnsubscribe } from '../../../../../../core/utils.service';
import { MetaCardItemComponent } from '../meta-card-item/meta-card-item.component';
Expand Down Expand Up @@ -72,10 +71,9 @@ export class MetaCardComponent implements OnDestroy {
if (!this.favorite) {
this.entityMonitorSub = entityMonitor.entity$.pipe(
first(),
tap(entity => this.favorite = getFavoriteFromEntity(
tap(entity => this.favorite = this.userFavoriteManager.getFavorite(
entity,
entityConfig.schema.entityType,
this.userFavoriteManager,
entityConfig.schema.endpointType
))
).subscribe();
Expand Down
6 changes: 5 additions & 1 deletion src/frontend/packages/devkit/src/build/extensions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from 'fs';
import * as path from 'path';
import { NormalModuleReplacementPlugin } from 'webpack';
import { NormalModuleReplacementPlugin, WatchIgnorePlugin } from 'webpack';

import { StratosConfig } from '../lib/stratos.config';

Expand Down Expand Up @@ -63,6 +63,10 @@ export class ExtensionsHandler {
regex = importModuleRegex;
}

// Ignore changed in the overrides file - otherwise with ng serve we will build twice
// The user needs to restart `ng serve` anyway if new extensions are added
webpackConfig.plugins.push(new WatchIgnorePlugin([overrideFile]));

webpackConfig.plugins.push(new NormalModuleReplacementPlugin(
regex,
overrideFile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ import {
StratosCatalogEntity,
} from '../../../store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity';
import {
IEntityMetadata,
IStratosEntityDefinition,
StratosEndpointExtensionDefinition,
} from '../../../store/src/entity-catalog/entity-catalog.types';
import { EndpointAuthTypeConfig, EndpointType } from '../../../store/src/extension-types';
import { metricEntityType } from '../../../store/src/helpers/stratos-entity-factory';
import { IFavoriteMetadata, UserFavorite } from '../../../store/src/types/user-favorites.types';
import { IFavoriteMetadata } from '../../../store/src/types/user-favorites.types';
import { UserFavoriteManager } from '../../../store/src/user-favorite-manager';
import { KubernetesAWSAuthFormComponent } from './auth-forms/kubernetes-aws-auth-form/kubernetes-aws-auth-form.component';
import {
Expand Down Expand Up @@ -179,7 +178,7 @@ export function generateKubernetesEntities(): StratosBaseCatalogEntity[] {
BaseEndpointAuth.UsernamePassword,
kubeAuthTypeMap[KubeEndpointAuthTypes.TOKEN],
],
favoriteFromEntity: getFavoriteFromKubeEntity,
getEndpointIdFromEntity: (entity) => entity.kubeGuid,
renderPriority: 4,
subTypes: [
{
Expand Down Expand Up @@ -385,16 +384,3 @@ function generateMetricEntity(endpointDefinition: StratosEndpointExtensionDefini
};
return new StratosCatalogEntity(definition);
}

function getFavoriteFromKubeEntity<T extends IEntityMetadata = IEntityMetadata>(
entity,
entityType: string,
userFavoriteManager: UserFavoriteManager
): UserFavorite<T> {
return userFavoriteManager.getFavoriteFromEntity<T>(
entityType,
KUBERNETES_ENDPOINT_TYPE,
entity.kubeGuid,
entity
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Observable } from 'rxjs';
import { filter, map } from 'rxjs/operators';

import { IHeaderBreadcrumb } from '../../../../core/src/shared/components/page-header/page-header.types';
import { getFavoriteFromEntity } from '../../../../store/src/user-favorite-helpers';
import { UserFavoriteManager } from '../../../../store/src/user-favorite-manager';
import { kubernetesNamespacesEntityType } from '../kubernetes-entity-factory';
import { BaseKubeGuid } from '../kubernetes-page.types';
Expand Down Expand Up @@ -67,14 +66,13 @@ export class KubernetesNamespaceComponent {

public favorite$ = this.kubeNamespaceService.namespace$.pipe(
filter(app => !!app),
map(namespace => getFavoriteFromEntity<IFavoriteMetadata>(
map(namespace => this.userFavoriteManager.getFavorite<IFavoriteMetadata>(
{
kubeGuid: this.kubeEndpointService.baseKube.guid,
...namespace,
prettyText: 'Kubernetes Namespace',
},
kubernetesNamespacesEntityType,
this.userFavoriteManager,
KUBERNETES_ENDPOINT_TYPE
))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ export interface IStratosEndpointDefinition<T = EntityCatalogSchemas | EntitySch
readonly globalPrePaginationRequest?: PrePaginationApiRequest;
readonly globalErrorMessageHandler?: ApiErrorMessageHandler;
readonly healthCheck?: EndpointHealthCheck;
// Used for favorites - given an entity, get the endpoint ID of the endpoint it belongs to
readonly getEndpointIdFromEntity?: (entity: any) => string;
readonly favoriteFromEntity?: <M extends IEntityMetadata = IEntityMetadata>(
entity: any, entityKey: string, userFavoriteManager: UserFavoriteManager
) => UserFavorite<M>;
Expand Down
Loading

0 comments on commit caf2ec2

Please sign in to comment.