UNPKG

@kinvolk/headlamp-plugin

Version:

The needed infrastructure for building Headlamp plugins.

76 lines (75 loc) 3.18 kB
import { jsx as _jsx } 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 from '@mui/material/Box'; import Chip from '@mui/material/Chip'; import { styled } from '@mui/system'; import { useTranslation } from 'react-i18next'; import ResourceQuota from '../../lib/k8s/resourceQuota'; import { useNamespaces } from '../../redux/filterSlice'; import ResourceListView from '../common/Resource/ResourceListView'; const WrappingBox = styled(Box)(({ theme }) => ({ display: 'flex', justifyContent: 'left', flexWrap: 'wrap', '& > *': { margin: theme.spacing(0.5), }, })); const PaddedChip = styled(Chip)({ paddingTop: '2px', paddingBottom: '2px', }); export function ResourceQuotaRenderer(props) { const { resourceQuotas, errors, hideColumns = [], reflectTableInURL = 'resourcequotas', noNamespaceFilter, } = props; const { t } = useTranslation(['glossary', 'translation']); return (_jsx(ResourceListView, { title: t('glossary|Resource Quotas'), hideColumns: hideColumns, columns: [ 'name', 'namespace', 'cluster', { id: 'requests', label: t('translation|Request'), getValue: item => item.requests.join(', '), render: item => { const requests = []; item.requests.forEach((request) => { requests.push(_jsx(PaddedChip, { label: request, variant: "outlined", size: "small" })); }); return _jsx(WrappingBox, { children: requests }); }, }, { id: 'limits', label: t('translation|Limit'), getValue: item => item?.limits?.join(', '), render: item => { const limits = []; item.limits.forEach((limit) => { limits.push(_jsx(PaddedChip, { label: limit, variant: "outlined", size: "small" })); }); return _jsx(WrappingBox, { children: limits }); }, }, 'age', ], headerProps: { noNamespaceFilter, }, errors: errors, data: resourceQuotas, reflectInURL: reflectTableInURL, id: "headlamp-resourcequotas" })); } export default function ResourceQuotaList() { const { items: resourceQuotas, errors } = ResourceQuota.useList({ namespace: useNamespaces() }); return (_jsx(ResourceQuotaRenderer, { resourceQuotas: resourceQuotas, errors: errors, reflectTableInURL: true })); }