From 7fe3df8259fb45639f19f89430c8b8b0e17dd85d Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Mon, 20 Jul 2020 16:24:52 -0700 Subject: [PATCH] Automatically fix up arc controller URL (#11177) --- .../dashboards/postgres/postgresOverviewPage.ts | 4 ++-- .../arc/src/ui/dialogs/connectControllerDialog.ts | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/extensions/arc/src/ui/dashboards/postgres/postgresOverviewPage.ts b/extensions/arc/src/ui/dashboards/postgres/postgresOverviewPage.ts index 8939279c05..ecf05e965e 100644 --- a/extensions/arc/src/ui/dashboards/postgres/postgresOverviewPage.ts +++ b/extensions/arc/src/ui/dashboards/postgres/postgresOverviewPage.ts @@ -31,7 +31,7 @@ export class PostgresOverviewPage extends DashboardPage { this.disposables.push( this._controllerModel.onEndpointsUpdated(() => this.eventuallyRunOnInitialized(() => this.handleEndpointsUpdated())), this._controllerModel.onRegistrationsUpdated(() => this.eventuallyRunOnInitialized(() => this.handleRegistrationsUpdated())), - this._postgresModel.onServiceUpdated(() => this.eventuallyRunOnInitialized(() => this.hadleServiceUpdated())), + this._postgresModel.onServiceUpdated(() => this.eventuallyRunOnInitialized(() => this.handleServiceUpdated())), this._postgresModel.onPodsUpdated(() => this.eventuallyRunOnInitialized(() => this.handlePodsUpdated()))); } @@ -353,7 +353,7 @@ export class PostgresOverviewPage extends DashboardPage { this.propertiesLoading!.loading = false; } - private hadleServiceUpdated() { + private handleServiceUpdated() { this.properties!.propertyItems = this.getProperties(); this.propertiesLoading!.loading = false; diff --git a/extensions/arc/src/ui/dialogs/connectControllerDialog.ts b/extensions/arc/src/ui/dialogs/connectControllerDialog.ts index 2ba733f485..41275b0a6b 100644 --- a/extensions/arc/src/ui/dialogs/connectControllerDialog.ts +++ b/extensions/arc/src/ui/dialogs/connectControllerDialog.ts @@ -88,8 +88,21 @@ export class ConnectToControllerDialog { if (!this.urlInputBox.value || !this.usernameInputBox.value || !this.passwordInputBox.value) { return false; } + let url = this.urlInputBox.value; + // Only support https connections + if (url.toLowerCase().startsWith('http://')) { + url = url.replace('http', 'https'); + } + // Append https if they didn't type it in + if (!url.toLowerCase().startsWith('https://')) { + url = `https://${url}`; + } + // Append default port if one wasn't specified + if (!/.*:\d*$/.test(url)) { + url = `${url}:30080`; + } const controllerInfo: ControllerInfo = { - url: this.urlInputBox.value, + url: url, username: this.usernameInputBox.value, rememberPassword: this.rememberPwCheckBox.checked ?? false, resources: []