From 06237b1b8b2405a8454ef79af1e6430d238c4535 Mon Sep 17 00:00:00 2001 From: Mira Nord Date: Sun, 16 Mar 2025 20:55:20 +0100 Subject: [PATCH] Add link to change custom web instance --- src/open/ClientView.js | 31 +++++++++++++++++++++++++++++++ src/open/ClientViewModel.js | 5 +++++ 2 files changed, 36 insertions(+) diff --git a/src/open/ClientView.js b/src/open/ClientView.js index 76c73e9..b42eb16 100644 --- a/src/open/ClientView.js +++ b/src/open/ClientView.js @@ -112,10 +112,41 @@ class InstallClientView extends TemplateView { } } +export class SetCustomWebInstanceView extends TemplateView { + render(t, vm) { + return t.div({className: "SetCustomWebInstanceView"}, [ + t.p([ + "Use a custom web instance for the ", t.strong(vm.name), " client:", + ]), + t.form({action: "#", id: "setCustomWebInstanceForm", onSubmit: evt => this._onSubmit(evt)}, [ + t.label([ + "Host name:", + t.input({ + type: "text", + className: "line", + placeholder: "chat.example.org", + name: "instanceHostname", + }) + ]) + ]) + ]); + } + + _onSubmit(evt) { + evt.preventDefault(); + this.value.continueWithSelection(this._askEveryTimeChecked); + } +} + function showBack(t, vm) { return t.p({className: {caption: true, "back": true, hidden: vm => !vm.showBack}}, [ `Continue with ${vm.name} · `, t.button({className: "text", onClick: () => vm.back()}, "Change"), + t.span({hidden: vm => !vm.showSetWebInstance}, [ + ' · ', + t.button({className: "text", onClick: () => vm.setCustomWebInstance()}, "Use Custom Web Instance"), + ]) + ]); } diff --git a/src/open/ClientViewModel.js b/src/open/ClientViewModel.js index 7059186..380512f 100644 --- a/src/open/ClientViewModel.js +++ b/src/open/ClientViewModel.js @@ -231,6 +231,10 @@ export class ClientViewModel extends ViewModel { return !!this._clientListViewModel; } + get showSetWebInstance() { + return !!this._client.supportsCustomInstances; + } + back() { if (this._clientListViewModel) { const vm = this._clientListViewModel; @@ -239,6 +243,7 @@ export class ClientViewModel extends ViewModel { // in the list with all clients, and also if we refresh, we get the list with // all clients rather than having our "change client" click reverted. this.preferences.setClient(undefined, undefined); + this.preferences.setPreferredWebInstance(this._client.id, undefined); this._update(); this.emitChange(); vm.showAll();