From 922297bf58c7d3b0ab9db181e6efd153685b8dd8 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 18 Oct 2023 03:00:17 +0200 Subject: [PATCH] [Extensions UI] Support for initializing an extension from URL. --- .../src/components/panels/Extensions/Index.vue | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/platypush/backend/http/webapp/src/components/panels/Extensions/Index.vue b/platypush/backend/http/webapp/src/components/panels/Extensions/Index.vue index 3a311f4a7d..46b63284a4 100644 --- a/platypush/backend/http/webapp/src/components/panels/Extensions/Index.vue +++ b/platypush/backend/http/webapp/src/components/panels/Extensions/Index.vue @@ -93,19 +93,24 @@ export default { }, methods: { - onInput(input, setFilter = true) { + onInput(input, setFilter = true, setUrlArgs = true) { if (setFilter) { this.filter = input } const name = input?.toLowerCase()?.trim() - if (name?.length && name !== this.selectedExtension && this.extensions[name]) { + if (name?.length && this.extensions[name]) { this.selectedExtension = name + if (setUrlArgs) + this.setUrlArgs({extension: name}) + const el = this.$el.querySelector(`.extensions-container .item[data-name="${name}"]`) if (el) el.scrollIntoView({behavior: 'smooth'}) } else { this.selectedExtension = null + if (setUrlArgs) + this.setUrlArgs({}) } }, @@ -129,11 +134,20 @@ export default { } finally { this.loading = false } + + this.loadExtensionFromUrl() + this.$watch('$route.hash', () => this.loadExtensionFromUrl()) }, async loadConfigFile() { this.configFile = await this.request('config.get_config_file') }, + + loadExtensionFromUrl() { + const extension = this.getUrlArgs().extension + if (extension) + this.$nextTick(() => this.onInput(extension, false, false)) + }, }, mounted() {