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

Add screenReaderText, Fix XTerm.js crash, Improve console log messages #1977

Merged
merged 3 commits into from
Jan 27, 2025
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
3 changes: 3 additions & 0 deletions src/ContainerLogs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,14 @@ class ContainerLogs extends React.Component {
}

resize(width) {
if (!this.term?._core?._renderService?.dimensions)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This added line is not executed by any test.

return;
// 24 PF padding * 4
// 3 line border
// 21 inner padding of xterm.js
// xterm.js scrollbar 20
const padding = 24 * 4 + 3 + 21 + 20;
// missing API: https://github.com/xtermjs/xterm.js/issues/702
const realWidth = this.view._core._renderService.dimensions.css.cell.width;
const cols = Math.floor((width - padding) / realWidth);
this.view.resize(cols, 24);
Expand Down
3 changes: 3 additions & 0 deletions src/ContainerTerminal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,14 @@ class ContainerTerminal extends React.Component {
}

resize(width) {
if (!this.term?._core?._renderService?.dimensions)
return;
// 24 PF padding * 4
// 3 line border
// 21 inner padding of xterm.js
// xterm.js scrollbar 20
const padding = 24 * 4 + 3 + 21 + 20;
// missing API: https://github.com/xtermjs/xterm.js/issues/702
const realWidth = this.term._core._renderService.dimensions.css.cell.width;
const cols = Math.floor((width - padding) / realWidth);
this.term.resize(cols, 24);
Expand Down
2 changes: 1 addition & 1 deletion src/Containers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ class Containers extends React.Component {
{ title: _("CPU"), sortable: true, props: { className: 'ct-numeric-column' } },
{ title: _("Memory"), sortable: true, props: { className: 'ct-numeric-column' } },
{ title: _("State"), sortable: true },
''
{ title: "", sortable: false, props: { screenReaderText: _("Actions") } },
];
const partitionedContainers = { 'no-pod': [] };
let filtered = [];
Expand Down
14 changes: 10 additions & 4 deletions src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ class Application extends React.Component {
});
this.updateContainerStats(system);
})
.catch(console.log);
.catch(e => console.warn("initContainers", system ? "system" : "user",
"getContainers failed:", e.toString()));
Comment on lines +203 to +204
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 2 added lines are not executed by any test.

}

updateImages(system) {
Expand Down Expand Up @@ -272,7 +273,8 @@ class Application extends React.Component {
details.State.Status = "restarting";
this.updateState("containers", idx, details);
})
.catch(console.log);
.catch(e => console.warn("updateContainer", system ? "system" : "user",
"inspectContainer failed:", e.toString()));
this.pendingUpdateContainer[idx] = new_wait;
new_wait.finally(() => { delete this.pendingUpdateContainer[idx] });

Expand Down Expand Up @@ -473,21 +475,25 @@ class Application extends React.Component {
this.cleanupAfterService(system);
})
.catch(e => {
console.log(e);
console.error("init", system ? "system" : "user", "streamEvents failed:", e.toString());
this.setState({ [system ? "systemServiceAvailable" : "userServiceAvailable"]: false });
this.cleanupAfterService(system);
});

// Listen if podman is still running
const ch = cockpit.channel({ superuser: system ? "require" : null, payload: "stream", unix: client.getAddress(system) });
ch.addEventListener("close", () => {
console.log("init", system ? "system" : "user", "podman service closed");
this.setState({ [system ? "systemServiceAvailable" : "userServiceAvailable"]: false });
this.cleanupAfterService(system);
});

ch.send("GET " + client.VERSION + "libpod/events HTTP/1.0\r\nContent-Length: 0\r\n\r\n");
})
.catch(() => {
.catch(err => {
if (!system || err.problem != 'access-denied')
console.warn("init", system ? "system" : "user", "getInfo failed:", err.toString());

this.setState({
[system ? "systemServiceAvailable" : "userServiceAvailable"]: false,
[system ? "systemContainersLoaded" : "userContainersLoaded"]: true,
Expand Down