Skip to content

Commit

Permalink
Fix storage issues (#1003)
Browse files Browse the repository at this point in the history
## Problem

The cockpit proxy for the storage issues is not correctly created,
making the storage section to get stucked like "loading".

## Solution

Similar problems have 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.

## Testing

* Tested manually
  • Loading branch information
imobachgs authored Jan 16, 2024
2 parents d805b37 + 4a2b1cb commit 35740d4
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 36 deletions.
6 changes: 6 additions & 0 deletions web/package/cockpit-agama.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue Jan 16 15:27:28 UTC 2024 - José Iván López González <jlopez@suse.com>

- 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 <igonzalezsosa@suse.com>

Expand Down
78 changes: 42 additions & 36 deletions web/src/client/mixins.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -72,16 +88,21 @@ 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.issues = this.client.proxy(ISSUES_IFACE, object_path);
}

/**
* Returns the issues
*
* @return {Promise<Issue[]>}
*/
async getIssues() {
const proxy = await this.client.proxy(ISSUES_IFACE, object_path);
const proxy = await this.proxies.issues;
return proxy.All.map(buildIssue);
}

Expand Down Expand Up @@ -112,37 +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
*/

/**
* Extends the given class with methods to get and track the progress over D-Bus
*
Expand Down Expand Up @@ -176,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
Expand Down Expand Up @@ -224,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
Expand All @@ -232,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
Expand Down
2 changes: 2 additions & 0 deletions web/src/client/software.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class BaseProductManager {
*/
constructor(client) {
this.client = client;
this.proxies = {};
}

/**
Expand Down Expand Up @@ -219,6 +220,7 @@ class SoftwareBaseClient {
constructor(address = undefined) {
this.client = new DBusClient(SOFTWARE_SERVICE, address);
this.product = new ProductManager(this.client);
this.proxies = {};
}

/**
Expand Down

0 comments on commit 35740d4

Please sign in to comment.