From 11a740cbca185e4adba9c5abb06fd2055baf3dc7 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Wed, 18 Dec 2024 16:18:41 +0200 Subject: [PATCH] shell: Use Status type from pkg/lib/notifications --- pkg/shell/nav.tsx | 9 +++++---- pkg/shell/state.tsx | 15 ++++----------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/pkg/shell/nav.tsx b/pkg/shell/nav.tsx index 2e102d21d39d..790a720b5bfb 100644 --- a/pkg/shell/nav.tsx +++ b/pkg/shell/nav.tsx @@ -27,8 +27,9 @@ import { SearchInput } from "@patternfly/react-core/dist/esm/components/SearchIn import { Tooltip, TooltipPosition } from "@patternfly/react-core/dist/esm/components/Tooltip/index.js"; import { ContainerNodeIcon, ExclamationCircleIcon, ExclamationTriangleIcon, InfoCircleIcon } from '@patternfly/react-icons'; +import { Status } from "notifications"; import { Location, encode_location, ManifestItem } from "./util.jsx"; -import { ShellState, PageStatus } from "./state"; +import { ShellState } from "./state"; import { ManifestKeyword } from "./manifests"; const _ = cockpit.gettext; @@ -227,10 +228,10 @@ export class CockpitNav extends React.Component { } } -function PageStatus({ status, name } : { status: PageStatus, name: string }) { +function PageStatus({ status, name } : { status: Status, name: string }) { // Generate name for the status const desc_parts = name.toLowerCase().split(" "); - desc_parts.push(status.type); + desc_parts.push(status.type || ""); const desc = desc_parts.join("-"); return ( @@ -265,7 +266,7 @@ export function CockpitNavItem(props : { header?: string; className?: string; active: boolean; - status: PageStatus | null; + status: Status | null; keyword: string; term: string; href: string; diff --git a/pkg/shell/state.tsx b/pkg/shell/state.tsx index 4328e0c0bce8..92c754e2befd 100644 --- a/pkg/shell/state.tsx +++ b/pkg/shell/state.tsx @@ -20,6 +20,7 @@ import cockpit from "cockpit"; import { EventEmitter } from "cockpit/event"; +import { Status } from "notifications"; import { Router } from "./router.jsx"; import { @@ -55,14 +56,6 @@ export interface ShellStateEvents { connect: () => void; } -// NOTE - this is defined in pkg/lib/notifications.js and should be -// imported from there once that file has been typed. -// -export interface PageStatus { - type: string; - title: string; -} - export class ShellState extends EventEmitter { constructor() { super(); @@ -316,13 +309,13 @@ export class ShellState extends EventEmitter { * individual pages have access to all collected statuses. */ - page_status: { [host: string]: { [page: string]: PageStatus } } = { }; + page_status: { [host: string]: { [page: string]: Status } } = { }; #init_page_status() { sessionStorage.removeItem("cockpit:page_status"); } - #notify_page_status(host: string, page: string, status: PageStatus) { + #notify_page_status(host: string, page: string, status: Status) { if (!this.page_status[host]) this.page_status[host] = { }; this.page_status[host][page] = status; @@ -400,7 +393,7 @@ export class ShellState extends EventEmitter { * "well-known name" of a page, such as "system", * "network/firewall", or "updates". */ - handle_notifications: (host: string, page: string, data: { page_status?: PageStatus }) => { + handle_notifications: (host: string, page: string, data: { page_status?: Status }) => { if (data.page_status !== undefined) this.#notify_page_status(host, page, data.page_status); },