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

Userendpoints #4876

Merged
merged 101 commits into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
5b69c53
Setup project for local development (#4753)
thquad Jan 19, 2021
e667557
Allow everyone to add endpoints in the front-end for testing purposes…
thquad Jan 19, 2021
a88bba6
Add "created_by" to the cnsis table (#4753)
thquad Jan 19, 2021
818db96
Add endpointAdminMiddleware for endpoint routes (#4753)
thquad Jan 19, 2021
4be10b6
Cleanup debug log for testing (#4753)
thquad Jan 19, 2021
5286188
Filter endpoints for endpointadmins (#4753)
thquad Jan 19, 2021
728bb4c
Always filter endpoints unless user is an admin (#4753)
thquad Jan 19, 2021
e1c53fb
Change cnsiRecordExists to check for guid instead url (#4753)
thquad Jan 20, 2021
dbe2d39
Split ENDPOINT_REGISTER and add CreatorInfo to endpoints (#4753)
thquad Jan 25, 2021
cbace55
Change permissions on endpoint-list menues (#4753)
thquad Jan 25, 2021
b891707
Change endpoint middleware to check for different permissions (#4753)
thquad Jan 27, 2021
6264d08
Add another permission check to endpointMiddleware (#4753)
thquad Jan 27, 2021
4919e9f
Add env var to config and use it in the back-end (#4753)
thquad Jan 27, 2021
ee4e720
Implement env flag in front-end and consider empty creator as admin (…
thquad Jan 28, 2021
098d61c
Clean up a few lines (#4753)
thquad Jan 28, 2021
ec6cb1a
Admin can save over user endpoints (#4753)
thquad Jan 29, 2021
1d659a7
Rename created_by into creator and the id from the front-end (#4753)
thquad Feb 1, 2021
610b396
Add username to the creator in the front-end (#4753)
thquad Feb 1, 2021
245b5b3
Adjust url unique check when creating endpoints (#4753)
thquad Feb 4, 2021
f0a53bb
Prevent admins from connecting to user endpoints (#4753)
thquad Feb 5, 2021
3f9b69b
Exclude endpoint admins from no-endpoint-no-admin page (#4753)
thquad Feb 8, 2021
8bbb26c
Disallow sharing of user-endpoints through invites (#4753)
thquad Feb 9, 2021
cfa200e
Change cnsi gui generation and adjust (#4753)
thquad Feb 11, 2021
d256885
Fix endpoint creation check and update debug logs (#4753)
thquad Feb 11, 2021
124abfe
Change endpoints env var from boolean to enum (#4753)
thquad Feb 11, 2021
fa41bd3
Adjust frontend to new endpoints env var enum (#4753)
thquad Feb 11, 2021
f1c746a
Adjust mocks for tests (#4753)
thquad Feb 12, 2021
32ae343
Userendpoints config default value (#4753)
thquad Feb 12, 2021
76174b2
Adjust backend-tests and fix code (#4753)
thquad Feb 15, 2021
35ebcf9
Dont check creator account for admin scope (#4753)
thquad Feb 16, 2021
e9a2bd0
Fix Frontend Lint errors (#4753)
thquad Feb 18, 2021
2a08d2b
Split endpointMiddleware into two (#4753)
thquad Feb 18, 2021
9357fc4
Simplify buildCNSIList (#4753)
thquad Feb 18, 2021
79400cd
Simplify admin-check doing invites (#4753)
thquad Feb 18, 2021
8f12474
Add creator to frontend mock endpoints (#4753)
thquad Feb 18, 2021
5ed5d55
Fix unit tests and code (#4753)
thquad Feb 18, 2021
93bbeda
Add UserEndpointsEnabled check for middleware (#4753)
thquad Feb 18, 2021
e85cd6d
Fix frontend unit tests (#4753)
thquad Feb 19, 2021
5c6c905
E2E test debug
richard-cox Feb 19, 2021
1bf8682
E2E test debug - round 2
richard-cox Feb 19, 2021
f636f74
Fix core e2e failures
richard-cox Feb 19, 2021
74309c9
Revert "E2E test debug - round 2"
richard-cox Feb 19, 2021
8e2f495
Revert "E2E test debug"
richard-cox Feb 19, 2021
b968bd8
Fix frontend unit test (#4753)
thquad Feb 22, 2021
8cd8d61
Fix code formatting (#4753)
thquad Feb 22, 2021
5a910e5
Change disconnect permission to admin (#4876)
thquad Feb 22, 2021
7aaa68c
Remove unused function listAuthToken (#4876)
thquad Feb 22, 2021
59a1daa
Revert sys shared endpoint error msg (#4876)
thquad Feb 22, 2021
f3d0e39
Allow invites with user-endpoints (#4876)
thquad Feb 22, 2021
1b804a8
Rename json UserEndpointsEnabled (#4876)
thquad Feb 22, 2021
ba2360d
Edit config files (#4876)
thquad Feb 22, 2021
e1ff34a
Check for matching creator & user during connect (#4876)
thquad Feb 22, 2021
2ad6bb9
Simplify code in cnsi.go (#4876)
thquad Feb 22, 2021
08f0448
Create specific endpoints group for routes (#4876)
thquad Feb 22, 2021
a587f79
Start adding additional backend-tests (#4876)
thquad Feb 23, 2021
b59304a
Clean up listCNSIByAPIEndpoint (#4876)
thquad Feb 23, 2021
0bc452c
E2E test debug
thquad Feb 24, 2021
922e5a4
Optimize endpoints check during register (#4876)
thquad Feb 24, 2021
9a2bc7c
Revert "E2E test debug"
thquad Feb 24, 2021
2f2bf22
Fix overwriteEndpoint bug (#4876)
thquad Feb 25, 2021
98364a0
Fix another overwriteEndpoint bug (#4876)
thquad Feb 25, 2021
4ce5ab0
Add unit tests for registerEndpoint (#4876)
thquad Feb 25, 2021
fa45fe3
Add another check for overwriteEndpoints (#4876)
thquad Feb 25, 2021
8b4fd83
Add unit tests for listCNSI (#4876)
thquad Feb 25, 2021
1cc8021
Remove comment (#4876)
thquad Feb 25, 2021
a381d00
Create superclass for existing endpoints check (#4876)
thquad Feb 26, 2021
2041964
React to err for doUnregisterCluster (#4876)
thquad Feb 26, 2021
48c2e4f
Revert grouping endpoint routes to check e2e (#4876)
thquad Mar 1, 2021
2aa8265
Rename mock function (#4876)
thquad Mar 1, 2021
15cfc53
Rewrite error msg in middleware (#4876)
thquad Mar 1, 2021
d223a6d
Add unit tests for middleware (#4876)
thquad Mar 1, 2021
d49d99d
Add more arguments to createEndpointRowArgs (#4876)
thquad Mar 2, 2021
a3b7f50
Add endpoint connect unit tests (4876)
thquad Mar 2, 2021
ac6ab4a
Change created by to creator (#4876)
thquad Mar 2, 2021
e28003f
Add creator to endpoint table UI (#4876)
thquad Mar 2, 2021
ac80cfa
Add website documentation (#4876)
thquad Mar 3, 2021
b1ab2e7
Update desktop endpoint list functions (#4876)
thquad Mar 3, 2021
82896ac
Add dedicated endpoint group to routes (#4876)
thquad Mar 3, 2021
b5bccff
Fix group for endpoints (#4876)
thquad Mar 3, 2021
995759c
Remove space character (#4876)
thquad Mar 3, 2021
89ba665
Add pgsql unit tests (#4876)
thquad Mar 3, 2021
98b91f3
Fix endpoint path (#4876)
thquad Mar 4, 2021
3422bb2
Minor tweaks
richard-cox Mar 4, 2021
e1fa11c
Small changes
richard-cox Mar 4, 2021
4de9dec
Dont allow user to edit cnsi when admin_only (4876)
thquad Mar 5, 2021
da9bc2c
Don't let users see creator when admin_only (#4876)
thquad Mar 5, 2021
9f0ed4d
Fix log bug (#4876)
thquad Mar 5, 2021
0f13b56
Add USER_ENDPOINTS_ENABLED to helm chart values and documentation (#4…
thquad Mar 5, 2021
9b3fd3e
Add comment and clean up code (#4876)
thquad Mar 10, 2021
b26ccb0
Admin and users can create endpoint with same url (#4876)
thquad Mar 31, 2021
baa0bfc
Userendpoints hide system endpoints (#4876)
thquad Mar 31, 2021
18add26
Rename overwriteEndpoints in createUserEndpoint (#4876)
thquad Apr 1, 2021
1cad542
Admins can create personal endpoints (#4876)
thquad Apr 1, 2021
04aa4d5
Automatic disconnect by same url endpoint connect (#4876)
thquad Apr 1, 2021
46d16df
Adjust unit tests (#4876)
thquad Apr 6, 2021
e871659
Adjust front-end tests (#4876)
thquad Apr 6, 2021
5a500e2
Change createUserEndpoint checkbox & fix validation bug (#4876)
thquad Apr 13, 2021
329fdc5
Update documentation (#4876)
thquad Apr 13, 2021
7fdd7dd
Change creator visibility and fix permission bug (#4876)
thquad Apr 15, 2021
0757fba
Move docs from endpoints/cf to advanced (#4876)
thquad Apr 15, 2021
043140c
Rename global endpoints and update config file comments (#4876)
thquad Apr 15, 2021
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
1 change: 1 addition & 0 deletions deploy/kubernetes/console/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ The following table lists the configurable parameters of the Stratos Helm chart
|console.userInviteSubject|Email subject of the user invitation message||
|console.techPreview|Enable/disable Tech Preview features|false|
|console.apiKeysEnabled|Enable/disable API key-based access to Stratos API (disabled, admin_only, all_users)|admin_only|
|console.userEndpointsEnabled|Enable/disable user endpoints or let only admins view and manage user endpoints (disabled, admin_only, enabled)|disabled|
|console.ui.listMaxSize|Override the default maximum number of entities that a configured list can fetch. When a list meets this amount additional pages are not fetched||
|console.ui.listAllowLoadMaxed|If the maximum list size is met give the user the option to fetch all results|false|
|console.localAdminPassword|Use local admin user instead of UAA - set to a password to enable||
Expand Down
2 changes: 2 additions & 0 deletions deploy/kubernetes/console/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ spec:
value: {{ default "false" .Values.console.techPreview | quote }}
- name: API_KEYS_ENABLED
value: {{ default "admin_only" .Values.console.apiKeysEnabled | quote }}
- name: USER_ENDPOINTS_ENABLED
value: {{ default "disabled" .Values.console.userEndpointsEnabled | quote }}
- name: HELM_CACHE_FOLDER
value: /helm-cache
{{- if .Values.console.ui }}
Expand Down
5 changes: 5 additions & 0 deletions deploy/kubernetes/console/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
"enum": ["disabled", "admin_only", "all_users"],
"description": "Enable API keys for admins, all users or nobody"
},
"userEndpointsEnabled": {
"type": "string",
"enum": ["disabled", "admin_only", "enabled"],
"description": "Enable, disable or let only admins view and create user endpoints"
},
"autoRegisterCF": {
"type": ["string", "null"]
},
Expand Down
3 changes: 3 additions & 0 deletions deploy/kubernetes/console/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ console:
# Enable/disable API key-based access to Stratos API
apiKeysEnabled: admin_only

# Enable/disable user endpoints
userEndpointsEnabled: disabled

ui:
# Override the default maximum number of entities that a configured list can fetch. When a list meets this amount additional pages are not fetched
listMaxSize:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ describe('CurrentUserPermissionsService with CF checker', () => {
CfScopeStrings.CF_READ_SCOPE,
]
},
creator: {
name: 'admin',
admin: true,
system: false
},
metricsAvailable: false,
connectionStatus: 'connected',
system_shared_token: false,
Expand Down Expand Up @@ -102,6 +107,11 @@ describe('CurrentUserPermissionsService with CF checker', () => {
StratosScopeStrings.SCIM_READ
]
},
creator: {
name: 'admin',
admin: true,
system: false
},
metricsAvailable: false,
connectionStatus: 'connected',
system_shared_token: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createBasicStoreModule } from '@stratosui/store/testing';

import { PaginationMonitorFactory } from '../../../store/src/monitors/pagination-monitor.factory';
import { CoreTestingModule } from '../../test-framework/core-test.modules';
import { SessionService } from '../shared/services/session.service';
import { CoreModule } from './core.module';
import { EndpointsService } from './endpoints.service';
import { UtilsService } from './utils.service';
Expand All @@ -13,7 +14,8 @@ describe('EndpointsService', () => {
providers: [
EndpointsService,
UtilsService,
PaginationMonitorFactory
PaginationMonitorFactory,
SessionService
],
imports: [
CoreModule,
Expand Down
12 changes: 8 additions & 4 deletions src/frontend/packages/core/src/core/endpoints.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { endpointEntitiesSelector, endpointStatusSelector } from '../../../store
import { EndpointModel, EndpointState } from '../../../store/src/types/endpoint.types';
import { IEndpointFavMetadata, UserFavorite } from '../../../store/src/types/user-favorites.types';
import { endpointHasMetricsByAvailable } from '../features/endpoints/endpoint-helpers';
import { SessionService } from '../shared/services/session.service';
import { EndpointHealthChecks } from './endpoints-health-checks';
import { UserService } from './user.service';

Expand Down Expand Up @@ -50,7 +51,8 @@ export class EndpointsService implements CanActivate {
constructor(
private store: Store<EndpointOnlyAppState>,
private userService: UserService,
private endpointHealthChecks: EndpointHealthChecks
private endpointHealthChecks: EndpointHealthChecks,
private sessionService: SessionService
) {
this.endpoints$ = store.select(endpointEntitiesSelector);
this.haveRegistered$ = this.endpoints$.pipe(map(endpoints => !!Object.keys(endpoints).length));
Expand Down Expand Up @@ -99,17 +101,19 @@ export class EndpointsService implements CanActivate {
this.haveRegistered$,
this.haveConnected$,
this.userService.isAdmin$,
this.userService.isEndpointAdmin$,
this.sessionService.userEndpointsEnabled(),
this.disablePersistenceFeatures$
),
map(([state, haveRegistered, haveConnected, isAdmin, disablePersistenceFeatures]
: [[AuthState, EndpointState], boolean, boolean, boolean, boolean]) => {
map(([state, haveRegistered, haveConnected, isAdmin, isEndpointAdmin, userEndpointsEnabled, disablePersistenceFeatures]
: [[AuthState, EndpointState], boolean, boolean, boolean, boolean, boolean, boolean]) => {
const [authState] = state;
if (authState.sessionData.valid) {
// Redirect to endpoints if there's no connected endpoints
let redirect: string;
if (!disablePersistenceFeatures) {
if (!haveRegistered) {
redirect = isAdmin ? '/endpoints' : '/noendpoints';
redirect = isAdmin || (userEndpointsEnabled && isEndpointAdmin) ? '/endpoints' : '/noendpoints';
} else if (!haveConnected) {
redirect = '/endpoints';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ 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 { SessionService } from '../../shared/services/session.service';
import { EntityFavoriteStarComponent } from './entity-favorite-star.component';

describe('EntityFavoriteStarComponent', () => {
Expand All @@ -28,7 +29,8 @@ describe('EntityFavoriteStarComponent', () => {
overlayContainerElement = document.createElement('div');
return { getContainerElement: () => overlayContainerElement };
}
}
},
SessionService
],
declarations: [
DialogConfirmComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ describe('CurrentUserPermissionsService', () => {
StratosScopeStrings.STRATOS_CHANGE_PASSWORD,
]
},
creator: {
name: 'admin',
admin: true,
system: false
},
metricsAvailable: false,
connectionStatus: 'connected',
system_shared_token: false,
Expand Down Expand Up @@ -83,6 +88,11 @@ describe('CurrentUserPermissionsService', () => {
StratosScopeStrings.SCIM_READ
]
},
creator: {
name: 'admin',
admin: true,
system: false
},
metricsAvailable: false,
connectionStatus: 'connected',
system_shared_token: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import {


export enum StratosCurrentUserPermissions {
ENDPOINT_REGISTER = 'register.endpoint',
EDIT_ENDPOINT = 'edit-endpoint',
EDIT_ADMIN_ENDPOINT = 'edit-admin-endpoint',
PASSWORD_CHANGE = 'change-password',
EDIT_PROFILE = 'edit-profile',
/**
Expand All @@ -35,12 +36,12 @@ export enum StratosPermissionStrings {
STRATOS_ADMIN = 'isAdmin'
}


export enum StratosScopeStrings {
STRATOS_CHANGE_PASSWORD = 'password.write',
SCIM_READ = 'scim.read',
SCIM_WRITE = 'scim.write',
STRATOS_NOAUTH = 'stratos.noauth'
STRATOS_NOAUTH = 'stratos.noauth',
STRATOS_ENDPOINTADMIN = 'stratos.endpointadmin'
}

export enum StratosPermissionTypes {
Expand All @@ -53,7 +54,11 @@ export enum StratosPermissionTypes {
// Every group result must be true in order for the permission to be true. A group result is true if all or some of it's permissions are
// true (see `getCheckFromConfig`).
export const stratosPermissionConfigs: IPermissionConfigs = {
[StratosCurrentUserPermissions.ENDPOINT_REGISTER]: new PermissionConfig(
[StratosCurrentUserPermissions.EDIT_ENDPOINT]: new PermissionConfig(
StratosPermissionTypes.STRATOS_SCOPE,
StratosScopeStrings.STRATOS_ENDPOINTADMIN
),
[StratosCurrentUserPermissions.EDIT_ADMIN_ENDPOINT]: new PermissionConfig(
StratosPermissionTypes.STRATOS,
StratosPermissionStrings.STRATOS_ADMIN
),
Expand Down
8 changes: 8 additions & 0 deletions src/frontend/packages/core/src/core/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@ import { AuthOnlyAppState } from '../../../store/src/app-state';
export class UserService {

isAdmin$: Observable<boolean>;
isEndpointAdmin$: Observable<boolean>;

constructor(store: Store<AuthOnlyAppState>) {
this.isAdmin$ = store.select(s => s.auth).pipe(
map((auth: AuthState) => auth.sessionData && auth.sessionData.user && auth.sessionData.user.admin));

this.isEndpointAdmin$ = store.select(s => s.auth).pipe(
map((auth: AuthState) => {
return (auth.sessionData
&& auth.sessionData.user
&& auth.sessionData.user.scopes.find(e => e === 'stratos.endpointadmin') !== undefined);
}));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@
<h1 class="create-endpoint__section-title">{{endpoint.definition.label}} Information</h1>
<mat-form-field>
<input matInput id="name" name="name" formControlName="nameField" placeholder="Name"
[appUnique]="(existingEndpoints | async)?.names">
[appUnique]="registerForm.value.createSystemEndpointField ? (customEndpoints | async)?.names : (existingPersonalEndpoints | async)?.names">
<mat-error *ngIf="registerForm.controls.nameField.errors?.required">Name is required</mat-error>
<mat-error *ngIf="registerForm.controls.nameField.errors?.appUnique">Name is not unique</mat-error>
</mat-form-field>
<mat-form-field novalidate>
<input matInput id="url" name="url" formControlName="urlField" type="url" required placeholder="Endpoint Address"
pattern="{{urlValidation}}" [appUnique]="(existingEndpoints | async)?.urls">
pattern="{{urlValidation}}"
[appUnique]="registerForm.value.createSystemEndpointField ? (customEndpoints | async)?.urls : (existingPersonalEndpoints | async)?.urls">
<mat-error *ngIf="registerForm.controls.urlField.errors?.required">URL is required</mat-error>
<mat-error *ngIf="registerForm.controls.urlField.errors?.pattern">Invalid API URL</mat-error>
<mat-error *ngIf="registerForm.controls.urlField.errors?.appUnique">URL is not unique</mat-error>
</mat-form-field>
<mat-checkbox matInput *ngIf="userEndpointsAndIsAdmin | async" name="createSystemEndpoint"
formControlName="createSystemEndpointField" (change)="toggleCreateSystemEndpoint()"
[ngClass]="{'hide': fixedUrl, 'show': !fixedUrl}">Create a system endpoint (visible to all users)
</mat-checkbox>
<mat-checkbox matInput name="skipSll" formControlName="skipSllField"
[ngClass]="{'hide': fixedUrl, 'show': !fixedUrl}">Skip SSL validation for the
endpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { CoreTestingModule } from '../../../../../test-framework/core-test.modul
import { CoreModule } from '../../../../core/core.module';
import { SharedModule } from '../../../../shared/shared.module';
import { CreateEndpointCfStep1Component } from './create-endpoint-cf-step-1.component';
import { CurrentUserPermissionsService } from '../../../../core/permissions/current-user-permissions.service';

describe('CreateEndpointCfStep1Component', () => {
let component: CreateEndpointCfStep1Component;
Expand All @@ -29,8 +30,10 @@ describe('CreateEndpointCfStep1Component', () => {
queryParams: {},
params: { type: 'metrics' }
}
}
}]
},
},
CurrentUserPermissionsService
]
})
.compileComponents();
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { AfterContentInit, Component, Input } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs';
import { filter, map, pairwise } from 'rxjs/operators';
import { distinctUntilChanged, filter, map, pairwise } from 'rxjs/operators';

import { getFullEndpointApiUrl } from '../../../../../../store/src/endpoint-utils';
import { entityCatalog } from '../../../../../../store/src/entity-catalog/entity-catalog';
import {
StratosCatalogEndpointEntity,
Expand All @@ -13,16 +12,20 @@ import { ActionState } from '../../../../../../store/src/reducers/api-request-re
import { stratosEntityCatalog } from '../../../../../../store/src/stratos-entity-catalog';
import { getIdFromRoute } from '../../../../core/utils.service';
import { IStepperStep, StepOnNextFunction } from '../../../../shared/components/stepper/step/step.component';
import { SessionService } from '../../../../shared/services/session.service';
import { CurrentUserPermissionsService } from '../../../../core/permissions/current-user-permissions.service';
import { UserProfileService } from '../../../../core/user-profile.service';
import { SnackBarService } from '../../../../shared/services/snackbar.service';
import { ConnectEndpointConfig } from '../../connect.service';
import { getSSOClientRedirectURI } from '../../endpoint-helpers';
import { CreateEndpointHelperComponent } from '../create-endpoint-helper';

@Component({
selector: 'app-create-endpoint-cf-step-1',
templateUrl: './create-endpoint-cf-step-1.component.html',
styleUrls: ['./create-endpoint-cf-step-1.component.scss']
})
export class CreateEndpointCfStep1Component implements IStepperStep, AfterContentInit {
export class CreateEndpointCfStep1Component extends CreateEndpointHelperComponent implements IStepperStep, AfterContentInit {

registerForm: FormGroup;

Expand All @@ -42,11 +45,6 @@ export class CreateEndpointCfStep1Component implements IStepperStep, AfterConten
}
}

existingEndpoints: Observable<{
names: string[],
urls: string[],
}>;

validate: Observable<boolean>;

urlValidation: string;
Expand All @@ -63,8 +61,13 @@ export class CreateEndpointCfStep1Component implements IStepperStep, AfterConten
constructor(
private fb: FormBuilder,
activatedRoute: ActivatedRoute,
private snackBarService: SnackBarService
private snackBarService: SnackBarService,
sessionService: SessionService,
currentUserPermissionsService: CurrentUserPermissionsService,
userProfileService: UserProfileService
) {
super(sessionService, currentUserPermissionsService, userProfileService);

this.registerForm = this.fb.group({
nameField: ['', [Validators.required]],
urlField: ['', [Validators.required]],
Expand All @@ -73,15 +76,9 @@ export class CreateEndpointCfStep1Component implements IStepperStep, AfterConten
// Optional Client ID and Client Secret
clientIDField: ['', []],
clientSecretField: ['', []],
createSystemEndpointField: [true, []],
});

this.existingEndpoints = stratosEntityCatalog.endpoint.store.getAll.getPaginationMonitor().currentPage$.pipe(
map(endpoints => ({
names: endpoints.map(ep => ep.name),
urls: endpoints.map(ep => getFullEndpointApiUrl(ep)),
}))
);

const epType = getIdFromRoute(activatedRoute, 'type');
const epSubType = getIdFromRoute(activatedRoute, 'subtype');
this.endpoint = entityCatalog.getEndpoint(epType, epSubType);
Expand All @@ -102,6 +99,7 @@ export class CreateEndpointCfStep1Component implements IStepperStep, AfterConten
this.registerForm.value.clientIDField,
this.registerForm.value.clientSecretField,
this.registerForm.value.ssoAllowedField,
this.registerForm.value.createSystemEndpointField,
).pipe(
pairwise(),
filter(([oldVal, newVal]) => (oldVal.busy && !newVal.busy)),
Expand Down Expand Up @@ -151,4 +149,12 @@ export class CreateEndpointCfStep1Component implements IStepperStep, AfterConten
toggleAdvancedOptions() {
this.showAdvancedOptions = !this.showAdvancedOptions;
}

toggleCreateSystemEndpoint() {
// wait a tick for validators to adjust to new data in the directive
setTimeout(() => {
this.registerForm.controls.nameField.updateValueAndValidity();
this.registerForm.controls.urlField.updateValueAndValidity();
});
}
}
Loading