Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix storage issues #1003

Merged
merged 4 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <[email protected]>

- 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 <[email protected]>

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