Skip to content

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
- Added additional comments
- Tidied up some parts
- Display endpoint create directly rather than via custom component
- Added new doc to website menu
  • Loading branch information
richard-cox committed Apr 16, 2021
1 parent 98b91f3 commit 3422bb2
Show file tree
Hide file tree
Showing 17 changed files with 53 additions and 152 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,11 @@ export class UserInviteService {
map(v => v.entity.metadata && v.entity.metadata.userInviteAllowed === 'true')
);

this.canConfigure$ = combineLatest([
this.canConfigure$ = combineLatest(
waitForCFPermissions(this.store, this.activeRouteCfOrgSpace.cfGuid),
this.store.select('auth'),
cfEndpointService.endpoint$
]).pipe(
map(([cf, auth, endpoint]) =>
this.store.select('auth')
).pipe(
map(([cf, auth]) =>
cf.global.isAdmin &&
auth.sessionData['plugin-config'] && auth.sessionData['plugin-config'].userInvitationsEnabled === 'true')
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { AfterContentInit, Component, Input } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ActivatedRoute } from '@angular/router';
import { StratosCurrentUserPermissions } from '../../../../core/permissions/stratos-user-permissions.checker';
import { Observable } from 'rxjs';
import { filter, map, pairwise } from 'rxjs/operators';

Expand All @@ -12,13 +11,14 @@ import {
} from '../../../../../../store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity';
import { ActionState } from '../../../../../../store/src/reducers/api-request-reducer/types';
import { stratosEntityCatalog } from '../../../../../../store/src/stratos-entity-catalog';
import { StratosCurrentUserPermissions } from '../../../../core/permissions/stratos-user-permissions.checker';
import { getIdFromRoute } from '../../../../core/utils.service';
import { IStepperStep, StepOnNextFunction } from '../../../../shared/components/stepper/step/step.component';
import { SessionService } from '../../../../shared/services/session.service';
import { SnackBarService } from '../../../../shared/services/snackbar.service';
import { ConnectEndpointConfig } from '../../connect.service';
import { getSSOClientRedirectURI } from '../../endpoint-helpers';
import { SessionService } from '../../../../shared/services/session.service';
import { CreateEndpointHelperComponent } from '../create-endpoint-helper/create-endpoint-helper.component';
import { CreateEndpointHelperComponent } from '../create-endpoint-helper';


@Component({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import { Component } from '@angular/core';
import { StratosCurrentUserPermissions } from '../../../../core/permissions/stratos-user-permissions.checker';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

import { getFullEndpointApiUrl } from '../../../../../../store/src/endpoint-utils';
import { stratosEntityCatalog } from '../../../../../../store/src/stratos-entity-catalog';
import { SessionService } from '../../../../shared/services/session.service';
import { getFullEndpointApiUrl } from '../../../../../store/src/endpoint-utils';
import { stratosEntityCatalog } from '../../../../../store/src/stratos-entity-catalog';
import { StratosCurrentUserPermissions } from '../../../core/permissions/stratos-user-permissions.checker';
import { SessionService } from '../../../shared/services/session.service';

type EndpointObservable = Observable<{
names: string[],
urls: string[],
}>;

@Component({
selector: 'app-create-endpoint-helper',
template: ''
})
export class CreateEndpointHelperComponent {

overwritePermission: Observable<StratosCurrentUserPermissions[]>;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { CreateEndpointBaseStepComponent } from './create-endpoint-base-step/cre
import { CreateEndpointCfStep1Component } from './create-endpoint-cf-step-1/create-endpoint-cf-step-1.component';
import { CreateEndpointConnectComponent } from './create-endpoint-connect/create-endpoint-connect.component';
import { CreateEndpointComponent } from './create-endpoint.component';
import { CreateEndpointHelperComponent } from './create-endpoint-helper/create-endpoint-helper.component';

@NgModule({
imports: [
Expand All @@ -22,14 +21,12 @@ import { CreateEndpointHelperComponent } from './create-endpoint-helper/create-e
CreateEndpointBaseStepComponent,
CreateEndpointConnectComponent,
ConnectEndpointComponent,
CreateEndpointHelperComponent
],
exports: [
CreateEndpointComponent,
CreateEndpointCfStep1Component,
CreateEndpointConnectComponent,
ConnectEndpointComponent,
CreateEndpointHelperComponent
]
})
export class CreateEndpointModule { }
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { isNgTemplate } from '@angular/compiler';
import { ComponentFactoryResolver, ComponentRef, Injectable, ViewContainerRef } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { Store } from '@ngrx/store';
Expand All @@ -16,13 +15,13 @@ import { StratosCurrentUserPermissions } from '../../../../../core/permissions/s
import {
ConnectEndpointDialogComponent,
} from '../../../../../features/endpoints/connect-endpoint-dialog/connect-endpoint-dialog.component';
import { SessionService } from '../../../../../shared/services/session.service';
import { SnackBarService } from '../../../../services/snackbar.service';
import { ConfirmationDialogConfig } from '../../../confirmation-dialog.config';
import { ConfirmationDialogService } from '../../../confirmation-dialog.service';
import { createMetaCardMenuItemSeparator } from '../../list-cards/meta-card/meta-card-base/meta-card.component';
import { IListAction } from '../../list.component.types';
import { TableCellCustom } from '../../list.types';
import { SessionService } from '../../../../../shared/services/session.service';

interface EndpointDetailsContainerRefs {
componentRef: ComponentRef<EndpointListDetailsComponent>;
Expand Down Expand Up @@ -111,9 +110,9 @@ export class EndpointListHelper {
label: 'Disconnect',
description: ``, // Description depends on console user permission
createVisible: (row$: Observable<EndpointModel>) => combineLatest([
this.currentUserPermissionsService.can(StratosCurrentUserPermissions.EDIT_ADMIN_ENDPOINT),
row$
]).pipe(
this.currentUserPermissionsService.can(StratosCurrentUserPermissions.EDIT_ADMIN_ENDPOINT),
row$
]).pipe(
map(([isAdmin, row]) => {
const isConnected = row.connectionStatus === 'connected';
return isConnected && (!row.system_shared_token || row.system_shared_token && isAdmin);
Expand Down Expand Up @@ -142,9 +141,11 @@ export class EndpointListHelper {
row$
]).pipe(
map(([userEndpointsEnabled, isAdmin, row]) => {
if (userEndpointsEnabled && !row.creator.admin && isAdmin){
if (userEndpointsEnabled && !row.creator.admin && isAdmin) {
// Disable connect for admins if the endpoint was not created by them. Otherwise this could result in an admin connecting to
// multiple user endpoints that all have the same url.
return false;
}else{
} else {
const endpoint = entityCatalog.getEndpoint(row.cnsi_type, row.sub_type);
const ep = endpoint ? endpoint.definition : { unConnectable: false };
return !ep.unConnectable && row.connectionStatus === 'disconnected';
Expand Down Expand Up @@ -178,9 +179,9 @@ export class EndpointListHelper {
row$
]).pipe(
map(([userEndpointsEnabled, isAdmin, isEndpointAdmin, row]) => {
if (!userEndpointsEnabled || row.creator.admin){
if (!userEndpointsEnabled || row.creator.admin) {
return isAdmin;
}else{
} else {
return isEndpointAdmin || isAdmin;
}
})
Expand All @@ -202,9 +203,9 @@ export class EndpointListHelper {
row$
]).pipe(
map(([userEndpointsEnabled, isAdmin, isEndpointAdmin, row]) => {
if (!userEndpointsEnabled || row.creator.admin){
if (!userEndpointsEnabled || row.creator.admin) {
return isAdmin;
}else{
} else {
return isEndpointAdmin || isAdmin;
}
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable, OnDestroy } from '@angular/core';
import { Injectable } from '@angular/core';
import { Store } from '@ngrx/store';
import { BehaviorSubject, combineLatest, of, Subscription } from 'rxjs';
import { debounceTime, filter, map } from 'rxjs/operators';
import { BehaviorSubject, combineLatest, of } from 'rxjs';
import { debounceTime, filter, first, map } from 'rxjs/operators';

import { ListView } from '../../../../../../../store/src/actions/list.actions';
import { SetClientFilter } from '../../../../../../../store/src/actions/pagination.actions';
Expand Down Expand Up @@ -29,15 +29,14 @@ import { EndpointCardComponent } from './endpoint-card/endpoint-card.component';
import { EndpointListHelper } from './endpoint-list.helpers';
import { EndpointsDataSource } from './endpoints-data-source';
import { TableCellEndpointAddressComponent } from './table-cell-endpoint-address/table-cell-endpoint-address.component';
import { TableCellEndpointCreatorComponent } from './table-cell-endpoint-creator/table-cell-endpoint-creator.component';
import { TableCellEndpointDetailsComponent } from './table-cell-endpoint-details/table-cell-endpoint-details.component';
import { TableCellEndpointNameComponent } from './table-cell-endpoint-name/table-cell-endpoint-name.component';
import { TableCellEndpointStatusComponent } from './table-cell-endpoint-status/table-cell-endpoint-status.component';



@Injectable()
export class EndpointsListConfigService implements IListConfig<EndpointModel>, OnDestroy {
export class EndpointsListConfigService implements IListConfig<EndpointModel> {
cardComponent = EndpointCardComponent;

private singleActions: IListAction<EndpointModel>[];
Expand Down Expand Up @@ -109,7 +108,6 @@ export class EndpointsListConfigService implements IListConfig<EndpointModel>, O
filter: 'Filter Endpoints'
};
enableTextFilter = true;
userEndpointsSubscription: Subscription;

constructor(
private store: Store<AppState>,
Expand All @@ -125,12 +123,14 @@ export class EndpointsListConfigService implements IListConfig<EndpointModel>, O
(row: EndpointModel) => userFavoriteManager.getFavoriteEndpointFromEntity(row)
);
this.columns.push(favoriteCell);
this.userEndpointsSubscription = sessionService.userEndpointsNotDisabled().subscribe(enabled => {
if (enabled){
sessionService.userEndpointsNotDisabled().pipe(first()).subscribe(enabled => {
if (enabled) {
this.columns.splice(4, 0, {
columnId: 'creator',
headerCell: () => 'Creator',
cellComponent: TableCellEndpointCreatorComponent,
cellDefinition: {
valuePath: 'creator.name'
},
sort: {
type: 'sort',
orderKey: 'creator',
Expand Down Expand Up @@ -221,7 +221,4 @@ export class EndpointsListConfigService implements IListConfig<EndpointModel>, O
}
}

ngOnDestroy() {
this.userEndpointsSubscription.unsubscribe();
}
}

This file was deleted.

Empty file.

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions src/frontend/packages/core/src/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ import { LongRunningOperationsService } from './services/long-running-op.service
import { MetricsRangeSelectorService } from './services/metrics-range-selector.service';
import { SessionService } from './services/session.service';
import { UserPermissionDirective } from './user-permission.directive';
import { TableCellEndpointCreatorComponent } from './components/list/list-types/endpoint/table-cell-endpoint-creator/table-cell-endpoint-creator.component';


@NgModule({
Expand Down Expand Up @@ -222,7 +221,6 @@ import { TableCellEndpointCreatorComponent } from './components/list/list-types/
CardProgressOverlayComponent,
MaxListMessageComponent,
ProfileSettingsComponent,
TableCellEndpointCreatorComponent,
],
exports: [
ApplicationStateIconPipe,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import { Component, OnDestroy } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ActivatedRoute } from '@angular/router';
import {
CreateEndpointHelperComponent,
} from 'frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-helper';
import { Observable, Subscription } from 'rxjs';
import { filter, first, map, pairwise } from 'rxjs/operators';

import { SessionService } from '../../../../../core/src/shared/services/session.service';
import { EndpointsService } from '../../../../../core/src/core/endpoints.service';
import { getIdFromRoute } from '../../../../../core/src/core/utils.service';
import { ConnectEndpointConfig } from '../../../../../core/src/features/endpoints/connect.service';
import { StepOnNextFunction } from '../../../../../core/src/shared/components/stepper/step/step.component';
import { SessionService } from '../../../../../core/src/shared/services/session.service';
import { SnackBarService } from '../../../../../core/src/shared/services/snackbar.service';
import { getFullEndpointApiUrl } from '../../../../../store/src/endpoint-utils';
import { entityCatalog } from '../../../../../store/src/public-api';
import { ActionState } from '../../../../../store/src/reducers/api-request-reducer/types';
import { stratosEntityCatalog } from '../../../../../store/src/stratos-entity-catalog';
import { GIT_ENDPOINT_SUB_TYPES, GIT_ENDPOINT_TYPE } from '../../../store/git-entity-factory';
import { GitSCMService } from '../../scm/scm.service';
import { CreateEndpointHelperComponent } from 'frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-helper/create-endpoint-helper.component';

interface EndpointSubTypes {
[subType: string]: GithubTypes;
Expand Down
9 changes: 9 additions & 0 deletions src/frontend/packages/store/src/types/auth.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,17 @@ export enum APIKeysEnabled {
ALL_USERS = 'all_users'
}
export enum UserEndpointsEnabled {
/**
* No users can see or create their own endpoints. Admins cannot see any previously created user endpoints.
*/
DISABLED = 'disabled',
/**
* No users can see or create their own endpoints. Admins can manage previously created user endpoints
*/
ADMIN_ONLY = 'admin_only',
/**
* Endpoint Admins can see and create their own endpoints. Admins can manage all user endpoints
*/
ENABLED = 'enabled'
}
export interface SessionDataConfig {
Expand Down
Loading

0 comments on commit 3422bb2

Please sign in to comment.