Skip to content

Commit

Permalink
WIP - active pages...
Browse files Browse the repository at this point in the history
  • Loading branch information
mvollmer committed Sep 19, 2024
1 parent ae6af7c commit b5f4113
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
23 changes: 12 additions & 11 deletions pkg/shell/active-pages-modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,16 @@ const _ = cockpit.gettext;
export const ActivePagesDialog = ({ dialogResult, frames }) => {
function get_pages() {
const result = [];
for (const address in frames.iframes) {
for (const component in frames.iframes[address]) {
const iframe = frames.iframes[address][component];
for (const f of frames) {
if (f) {
result.push({
frame: iframe,
component,
address,
name: iframe.getAttribute("name"),
active: iframe.getAttribute("data-active") === 'true',
selected: iframe.getAttribute("data-active") === 'true',
displayName: address === "localhost" ? "/" + component : address + ":/" + component
frame: f,
component: f.fullpath,
address: f.host,
name: f.name,
active: f.active,
selected: f.active,
displayName: f.host === "localhost" ? "/" + f.fullpath : f.host + ":/" + f.fullpath,
});
}
}
Expand All @@ -61,8 +60,10 @@ export const ActivePagesDialog = ({ dialogResult, frames }) => {

function onRemove() {
pages.forEach(element => {
if (element.selected)
if (element.selected) {
// XXX
frames.remove(element.host, element.component);
}
});
dialogResult.resolve();
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/shell/shell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ function ShellState(machines, loader) {

function update() {
self.frames = index.frames.frame_array;
self.has_oops = index.has_oops;
self.dispatchEvent("update");
}

Expand Down Expand Up @@ -610,7 +611,7 @@ const Shell = ({ state, machines, loader }) => {
</div>

<div id="topnav" className="header">
<TopNav index={state.index}
<TopNav state={state}
loading={current_frame && !current_frame.ready}
machine={machine}
fullpath={fullpath}
Expand Down
4 changes: 2 additions & 2 deletions pkg/shell/topnav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export class TopNav extends React.Component {
if (this.state.showActivePages)
main_menu.push(
<DropdownItem key="frames" id="active-pages" component="button"
onClick={() => Dialogs.run(ActivePagesDialog, { frames: this.props.index.frames })}>
onClick={() => Dialogs.run(ActivePagesDialog, { frames: this.props.state.frames })}>
{_("Active pages")}
</DropdownItem>);

Expand Down Expand Up @@ -217,7 +217,7 @@ export class TopNav extends React.Component {
<SuperuserIndicator proxy={this.superuser} host={this.props.machine.connection_string} />
</ToolbarItem>
}
{ this.props.index.has_oops &&
{ this.props.state.has_oops &&
<ToolbarItem>
<Button id="navbar-oops" variant="link" size="lg" isDanger
onClick={() => Dialogs.run(OopsModal, {})}>{_("Ooops!")}</Button>
Expand Down

0 comments on commit b5f4113

Please sign in to comment.