Skip to content

Commit 7cd6428

Browse files
committed
shell: Use a top-level React component
And rewrite much of the state handling to make it easier to understand. Specifically, the old Index and MachineIndex classes and their complicated interactions have been replaced with a hopefully much more straightforward ShellState class. However, the existing React components such as CockpitHosts and TopNav have not been significantly touched. The API for launching the HostModal dialogs has been changed to make it more suitable for a later rewrite with Dialogs.run() ala pkg/lib/cockpit-connect-ssh.
1 parent 4559fca commit 7cd6428

22 files changed

+2229
-1961
lines changed

files.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const info = {
2828
"playground/remote.tsx",
2929

3030
"selinux/selinux.js",
31-
"shell/shell.js",
31+
"shell/shell.jsx",
3232
"sosreport/sosreport.jsx",
3333
"static/login.js",
3434
"storaged/storaged.jsx",

pkg/shell/active-pages-modal.jsx

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,18 @@ import { useInit } from "hooks";
2929

3030
const _ = cockpit.gettext;
3131

32-
export const ActivePagesDialog = ({ dialogResult, frames }) => {
32+
export const ActivePagesDialog = ({ dialogResult, state }) => {
3333
function get_pages() {
3434
const result = [];
35-
for (const address in frames.iframes) {
36-
for (const component in frames.iframes[address]) {
37-
const iframe = frames.iframes[address][component];
35+
for (const frame of Object.values(state.frames)) {
36+
if (frame.url) {
37+
const active = (frame == state.current_frame ||
38+
state.most_recent_path_for_host(frame.host) == frame.path);
3839
result.push({
39-
frame: iframe,
40-
component,
41-
address,
42-
name: iframe.getAttribute("name"),
43-
active: iframe.getAttribute("data-active") === 'true',
44-
selected: iframe.getAttribute("data-active") === 'true',
45-
displayName: address === "localhost" ? "/" + component : address + ":/" + component
40+
frame,
41+
active,
42+
selected: active,
43+
displayName: frame.host === "localhost" ? "/" + frame.path : frame.host + ":/" + frame.path,
4644
});
4745
}
4846
}
@@ -61,8 +59,9 @@ export const ActivePagesDialog = ({ dialogResult, frames }) => {
6159

6260
function onRemove() {
6361
pages.forEach(element => {
64-
if (element.selected)
65-
frames.remove(element.host, element.component);
62+
if (element.selected) {
63+
state.remove_frame(element.frame.name);
64+
}
6665
});
6766
dialogResult.resolve();
6867
}
@@ -80,8 +79,8 @@ export const ActivePagesDialog = ({ dialogResult, frames }) => {
8079
}];
8180
return ({
8281
props: {
83-
key: page.name,
84-
'data-row-id': page.name
82+
key: page.frame.name,
83+
'data-row-id': page.frame.name
8584
},
8685
columns,
8786
selected: page.selected,

0 commit comments

Comments
 (0)