/* * Copyright (C) 2019 Red Hat, Inc. * SPDX-License-Identifier: LGPL-2.1-or-later */ import cockpit from "cockpit"; import React from "react"; import { Button } from "@patternfly/react-core/dist/esm/components/Button/index.js"; import { Flex } from "@patternfly/react-core/dist/esm/layouts/Flex/index.js"; import { Spinner } from "@patternfly/react-core/dist/esm/components/Spinner/index.js"; import { Icon } from "@patternfly/react-core/dist/esm/components/Icon/index.js"; import { BugIcon, CheckIcon, EnhancementIcon, ExclamationCircleIcon, InfoCircleIcon, SecurityIcon, ExclamationTriangleIcon, } from '@patternfly/react-icons'; import "./page-status.scss"; import { page_status } from "notifications"; function icon_for_type(type) { if (type == "error") return ( ); else if (type == "warning") return ( ); else return ( ); } function get_pficon(name) { // set data-pficon for the tests if (name == "security") return ; if (name == "enhancement") return ; if (name == "bug") return ; if (name == "check") return ; if (name == "spinner") return ; throw new Error(`get_pficon(): unknown icon name ${name}`); } export class PageStatusNotifications extends React.Component { constructor() { super(); this.state = { }; this.on_page_status_changed = () => this.setState({ }); } componentDidMount() { page_status.addEventListener("changed", this.on_page_status_changed); } componentWillUnmount() { page_status.removeEventListener("changed", this.on_page_status_changed); } render() { // Explicit allowlist for now, until we can get a dynamic list return ["system/services", "updates"].map(page => { const status = page_status.get(page); if (status && (status.type || status.details) && status.title) { let action; if (status.details && status.details.link !== undefined) { if (status.details.link) action = ; else action = {status.title}; // no link } else { action = ; } let icon; if (status.details && status.details.icon) icon = ; else if (status.details && status.details.pficon) icon = get_pficon(status.details.pficon); else icon = icon_for_type(status.type); return (
  • {icon} {action}
  • ); } else { return null; } }); } }