From 4a9b7be79bbcc8088d0239b2c15adbef8a1e8ed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Tue, 16 Jan 2024 14:37:29 +0000 Subject: [PATCH 1/4] [web] Instantiate the issues proxy earlier - For some reason, creating a proxy for issues fails. - This same error has already been detected with other proxies, for example for the storage manager interface. - Anticipating the creation of the proxies fixes the issue. - Further research is needed to understand what happens at cockpit level. --- web/src/client/mixins.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/web/src/client/mixins.js b/web/src/client/mixins.js index 78f5618b8c..d06a3252a6 100644 --- a/web/src/client/mixins.js +++ b/web/src/client/mixins.js @@ -75,13 +75,19 @@ const buildIssue = (dbusIssue) => { * @template {!WithDBusClient} T */ const WithIssues = (superclass, object_path) => class extends superclass { + constructor(...args) { + super(...args); + this.proxies ||= {}; + this.proxies.issues = this.client.proxy(ISSUES_IFACE, object_path); + } + /** * Returns the issues * * @return {Promise} */ async getIssues() { - const proxy = await this.client.proxy(ISSUES_IFACE, object_path); + const proxy = await this.proxies.issues; return proxy.All.map(buildIssue); } @@ -140,7 +146,7 @@ const STATUS_IFACE = "org.opensuse.Agama1.ServiceStatus"; */ /** - * @typedef {GConstructor<{ client: import("./dbus").default }>} WithDBusClient + * @typedef {GConstructor<{ client: import("./dbus").default, proxies: ?Object }>} WithDBusClient */ /** From e462a1a3f13f63c0345fb9963fb24ed1c6afab8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Tue, 16 Jan 2024 15:53:09 +0000 Subject: [PATCH 2/4] [web] Changelog --- web/package/cockpit-agama.changes | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web/package/cockpit-agama.changes b/web/package/cockpit-agama.changes index ff1445f980..8882dd0190 100644 --- a/web/package/cockpit-agama.changes +++ b/web/package/cockpit-agama.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Jan 16 15:27:28 UTC 2024 - José Iván López González + +- Fix error with storage issues proxy by anticipating its creation + (gh#openSUSE/agama#1003). + ------------------------------------------------------------------- Thu Jan 11 15:34:26 UTC 2024 - Imobach Gonzalez Sosa From c91f29a74dc62fc790133e7dd0cfec2ddb151e0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Tue, 16 Jan 2024 16:37:45 +0000 Subject: [PATCH 3/4] [web] Ensure the object contains proxies --- web/src/client/mixins.js | 9 ++++++--- web/src/client/software.js | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/web/src/client/mixins.js b/web/src/client/mixins.js index d06a3252a6..537af490a3 100644 --- a/web/src/client/mixins.js +++ b/web/src/client/mixins.js @@ -72,12 +72,11 @@ const buildIssue = (dbusIssue) => { * Extends the given class with methods to get the issues over D-Bus * @param {string} object_path - object_path * @param {T} superclass - superclass to extend - * @template {!WithDBusClient} T + * @template {!WithDBusProxies} T */ const WithIssues = (superclass, object_path) => class extends superclass { constructor(...args) { super(...args); - this.proxies ||= {}; this.proxies.issues = this.client.proxy(ISSUES_IFACE, object_path); } @@ -146,7 +145,11 @@ const STATUS_IFACE = "org.opensuse.Agama1.ServiceStatus"; */ /** - * @typedef {GConstructor<{ client: import("./dbus").default, proxies: ?Object }>} WithDBusClient + * @typedef {GConstructor<{ client: import("./dbus").default }>} WithDBusClient + */ + +/** + * @typedef {GConstructor<{ client: import("./dbus").default, proxies: Object }>} WithDBusProxies */ /** diff --git a/web/src/client/software.js b/web/src/client/software.js index edec2fcc21..56ca3578a8 100644 --- a/web/src/client/software.js +++ b/web/src/client/software.js @@ -62,6 +62,7 @@ class BaseProductManager { */ constructor(client) { this.client = client; + this.proxies = {}; } /** @@ -219,6 +220,7 @@ class SoftwareBaseClient { constructor(address = undefined) { this.client = new DBusClient(SOFTWARE_SERVICE, address); this.product = new ProductManager(this.client); + this.proxies = {}; } /** From 4a2b1cb26c39f08f2a0dda5ed8a63fc8deb187b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Tue, 16 Jan 2024 16:47:39 +0000 Subject: [PATCH 4/4] [web] Reorder code --- web/src/client/mixins.js | 73 +++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/web/src/client/mixins.js b/web/src/client/mixins.js index 537af490a3..30ab4e95bf 100644 --- a/web/src/client/mixins.js +++ b/web/src/client/mixins.js @@ -22,6 +22,22 @@ // @ts-check const ISSUES_IFACE = "org.opensuse.Agama1.Issues"; +const STATUS_IFACE = "org.opensuse.Agama1.ServiceStatus"; +const PROGRESS_IFACE = "org.opensuse.Agama1.Progress"; +const VALIDATION_IFACE = "org.opensuse.Agama1.Validation"; + +/** + * @typedef {new(...args: any[]) => T} GConstructor + * @template {object} T + */ + +/** + * @typedef {GConstructor<{ client: import("./dbus").default }>} WithDBusClient + */ + +/** + * @typedef {GConstructor<{ client: import("./dbus").default, proxies: Object }>} WithDBusProxies + */ /** * @typedef {[string, string, number, number]} DBusIssue @@ -117,41 +133,6 @@ const WithIssues = (superclass, object_path) => class extends superclass { } }; -const STATUS_IFACE = "org.opensuse.Agama1.ServiceStatus"; - -/** - * @typedef {object} Progress - * @property {number} total - number of steps - * @property {number} current - current step - * @property {string} message - message of the current step - * @property {boolean} finished - whether the progress already finished - */ - -/** - * @callback ProgressHandler - * @param {Progress} progress - progress status - * @return {void} - */ - -/** - * @callback ValidationErrorsHandler - * @param {ValidationError[]} errors - validation errors - * @return {void} - */ - -/** - * @typedef {new(...args: any[]) => T} GConstructor - * @template {object} T - */ - -/** - * @typedef {GConstructor<{ client: import("./dbus").default }>} WithDBusClient - */ - -/** - * @typedef {GConstructor<{ client: import("./dbus").default, proxies: Object }>} WithDBusProxies - */ - /** * Extends the given class with methods to get and track the progress over D-Bus * @@ -185,7 +166,19 @@ const WithStatus = (superclass, object_path) => class extends superclass { } }; -const PROGRESS_IFACE = "org.opensuse.Agama1.Progress"; +/** + * @typedef {object} Progress + * @property {number} total - number of steps + * @property {number} current - current step + * @property {string} message - message of the current step + * @property {boolean} finished - whether the progress already finished + */ + +/** + * @callback ProgressHandler + * @param {Progress} progress - progress status + * @return {void} + */ /** * Extends the given class with methods to get and track the progress over D-Bus @@ -233,6 +226,12 @@ const WithProgress = (superclass, object_path) => class extends superclass { * @property {string} message - Error message */ +/** + * @callback ValidationErrorsHandler + * @param {ValidationError[]} errors - validation errors + * @return {void} + */ + /** * * @param {string} message - Error message @@ -241,8 +240,6 @@ const createError = (message) => { return { message }; }; -const VALIDATION_IFACE = "org.opensuse.Agama1.Validation"; - /** * Extends the given class with methods to get validation errors over D-Bus * @param {string} object_path - object_path