diff --git a/pkg/lib/cockpit-components-empty-state.jsx b/pkg/lib/cockpit-components-empty-state.jsx deleted file mode 100644 index 82d7b97eb9ab..000000000000 --- a/pkg/lib/cockpit-components-empty-state.jsx +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file is part of Cockpit. - * - * Copyright (C) 2019 Red Hat, Inc. - * - * Cockpit is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * Cockpit is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Cockpit; If not, see . - */ - -import React from "react"; -import PropTypes from 'prop-types'; -import { Button } from "@patternfly/react-core/dist/esm/components/Button/index.js"; -import { EmptyStateActions, EmptyState, EmptyStateBody, EmptyStateFooter, EmptyStateHeader, EmptyStateIcon, EmptyStateVariant } from "@patternfly/react-core/dist/esm/components/EmptyState/index.js"; -import { Spinner } from "@patternfly/react-core/dist/esm/components/Spinner/index.js"; -import "./cockpit-components-empty-state.css"; - -export const EmptyStatePanel = ({ title, paragraph, loading = false, icon, action, isActionInProgress = false, onAction, actionVariant = "primary", secondary, headingLevel = "h1" }) => { - const slimType = title || paragraph ? "" : "slim"; - return ( - - } /> - - {paragraph} - - {(action || secondary) && - { action && (typeof action == "string" - ? - : action)} - { secondary && {secondary} } - } - - ); -}; - -EmptyStatePanel.propTypes = { - loading: PropTypes.bool, - icon: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.func]), - title: PropTypes.string, - paragraph: PropTypes.node, - action: PropTypes.node, - actionVariant: PropTypes.string, - isActionInProgress: PropTypes.bool, - onAction: PropTypes.func, - secondary: PropTypes.node, -}; diff --git a/pkg/lib/cockpit-components-empty-state.tsx b/pkg/lib/cockpit-components-empty-state.tsx new file mode 100644 index 000000000000..9fdc27684bf8 --- /dev/null +++ b/pkg/lib/cockpit-components-empty-state.tsx @@ -0,0 +1,97 @@ +/* + * This file is part of Cockpit. + * + * Copyright (C) 2019 Red Hat, Inc. + * + * Cockpit is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * Cockpit is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Cockpit; If not, see . + */ + +import React from "react"; +import PropTypes from 'prop-types'; +import { Button, ButtonProps } from "@patternfly/react-core/dist/esm/components/Button/index.js"; +import { + EmptyStateActions, EmptyState, EmptyStateBody, EmptyStateFooter, EmptyStateHeader, EmptyStateIcon, + EmptyStateVariant, EmptyStateIconProps, EmptyStateHeaderProps +} from "@patternfly/react-core/dist/esm/components/EmptyState/index.js"; +import { Spinner } from "@patternfly/react-core/dist/esm/components/Spinner/index.js"; +import "./cockpit-components-empty-state.css"; + +export const EmptyStatePanel = ({ + title, + paragraph, + loading = false, + icon, + action, + isActionInProgress = false, + onAction, + actionVariant = "primary", + secondary, + headingLevel = "h1" +}: { + title?: EmptyStateHeaderProps["titleText"], + paragraph?: React.ReactNode, + loading?: boolean, + icon?: EmptyStateIconProps["icon"], + action?: React.ReactNode | string, + isActionInProgress?: boolean, + onAction?: ButtonProps["onClick"], + actionVariant?: ButtonProps["variant"], + secondary?: React.ReactNode, + headingLevel?: EmptyStateHeaderProps['headingLevel'], +}) => { + const slimType = title || paragraph ? "" : "slim"; + const iconFinal: EmptyStateIconProps["icon"] = icon ?? Spinner; + + const emptyStateHeader = (loading || icon) + ? } + /> + : ; + + return ( + + {emptyStateHeader} + + {paragraph} + + {(action || secondary) && + + { action && (typeof action == "string" + ? + : action)} + { secondary && {secondary} } + } + + ); +}; + +EmptyStatePanel.propTypes = { + loading: PropTypes.bool, + icon: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.func]), + title: PropTypes.string, + paragraph: PropTypes.node, + action: PropTypes.oneOfType([PropTypes.node, PropTypes.string]), + actionVariant: PropTypes.string, + isActionInProgress: PropTypes.bool, + onAction: PropTypes.func, + secondary: PropTypes.node, +}; diff --git a/pkg/lib/cockpit-components-truncate.jsx b/pkg/lib/cockpit-components-truncate.tsx similarity index 98% rename from pkg/lib/cockpit-components-truncate.jsx rename to pkg/lib/cockpit-components-truncate.tsx index 32299aed82cf..fe0101127924 100644 --- a/pkg/lib/cockpit-components-truncate.jsx +++ b/pkg/lib/cockpit-components-truncate.tsx @@ -31,6 +31,8 @@ import './cockpit-components-truncate.scss'; export const Truncate = ({ content, ...props +}: { + content: string, }) => { return (