UNPKG

@kinvolk/headlamp-plugin

Version:

The needed infrastructure for building Headlamp plugins.

39 lines (38 loc) 2.84 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; /* * Copyright 2025 The Kubernetes Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { Box, Button, styled, Typography } from '@mui/material'; import { Trans } from 'react-i18next'; import { KubeIcon } from '../resourceMap/kubeIcon/KubeIcon'; const StyledPre = styled('pre')({ margin: 0, }); function QueryExample({ children, resources, onSelect, }) { return (_jsxs(Button, { variant: "contained", color: "secondary", onClick: () => onSelect(resources, children), sx: { display: 'flex', flexDirection: 'column', alignItems: 'flex-start', }, children: [resources.length === 1 ? (_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 0.5 }, children: [_jsx(KubeIcon, { kind: resources[0].kind, width: "24px", height: "24px" }), ' ', resources[0].kind, ' '] })) : (_jsx(Trans, { children: "All Resources" })), _jsx(Box, { children: _jsx(StyledPre, { children: children }) })] })); } /** * Placeholder for when there are no results */ export function EmptyResults({ resources, onQuerySelected, }) { const pod = resources.find(it => it.kind === 'Pod'); const configMap = resources.find(it => it.kind === 'ConfigMap'); const job = resources.find(it => it.kind === 'Job'); return (_jsxs(Box, { sx: { p: 2, display: 'flex', alignItems: 'center', flexDirection: 'column', gap: 1 }, children: [_jsx(Typography, { variant: "body1", sx: { marginTop: 3 }, children: _jsx(Trans, { children: "Examples" }) }), _jsxs(Box, { sx: { display: 'flex', gap: 1, flexWrap: 'wrap', justifyContent: 'center' }, children: [pod && (_jsx(QueryExample, { onSelect: onQuerySelected, resources: [pod], children: "status.phase !== \"Running\"" })), _jsx(QueryExample, { onSelect: onQuerySelected, resources: resources, children: "metadata.labels[\"kubernetes.io/cluster-service\"] === \"true\"" }), configMap && (_jsx(QueryExample, { onSelect: onQuerySelected, resources: [configMap], children: "!!data" })), _jsx(QueryExample, { onSelect: onQuerySelected, resources: resources, children: `metadata.annotations["deployment.kubernetes.io/revision"] > 10` }), job && (_jsx(QueryExample, { onSelect: onQuerySelected, resources: [job], children: `spec.suspend === false && status.succeeded > 0` }))] })] })); }