UNPKG

@kinvolk/headlamp-plugin

Version:

The needed infrastructure for building Headlamp plugins.

79 lines (78 loc) 3.58 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 { useTranslation } from 'react-i18next'; import { useParams } from 'react-router-dom'; import { LimitRange } from '../../lib/k8s/limitRange'; import Namespace from '../../lib/k8s/namespace'; import ResourceQuota from '../../lib/k8s/resourceQuota'; import { StatusLabel } from '../common/Label'; import { ConditionsSection, DetailsGrid, OwnedPodsSection } from '../common/Resource'; import DetailsViewSection from '../DetailsViewSection'; import { LimitRangeRenderer } from '../limitRange/List'; import { ResourceQuotaRenderer } from '../resourceQuota/List'; export default function NamespaceDetails(props) { const params = useParams(); const { name = params.name, cluster } = props; const { t } = useTranslation(['glossary', 'translation']); function makeStatusLabel(namespace) { const status = namespace?.status.phase; return _jsx(StatusLabel, { status: status === 'Active' ? 'success' : 'error', children: status }); } return (_jsx(DetailsGrid, { resourceType: Namespace, name: name, cluster: cluster, withEvents: true, extraInfo: item => item && [ { name: t('translation|Status'), value: makeStatusLabel(item), }, ], extraSections: item => item && [ { id: 'headlamp.namespace-conditions', section: item?.status?.conditions && _jsx(ConditionsSection, { resource: item }), }, { id: 'headlamp.namespace-owned-resourcequotas', section: _jsx(NamespacedResourceQuotasSection, { resource: item }), }, { id: 'headlamp.namespace-owned-limitranges', section: _jsx(NamespacedLimitRangesSection, { resource: item }), }, { id: 'headlamp.namespace-owned-pods', section: _jsx(OwnedPodsSection, { hideColumns: ['namespace'], resource: item, noSearch: true }), }, { id: 'headlamp.namespace-details-view', section: _jsx(DetailsViewSection, { resource: item }), }, ] })); } export function NamespacedLimitRangesSection(props) { const { resource } = props; const { items: limitRanges, errors } = LimitRange.useList({ namespace: resource.metadata.name, cluster: resource.cluster, }); return (_jsx(LimitRangeRenderer, { hideColumns: ['namespace'], limitRanges: limitRanges, errors: errors, noNamespaceFilter: true })); } export function NamespacedResourceQuotasSection(props) { const { resource } = props; const { items: resourceQuotas, errors } = ResourceQuota.useList({ namespace: resource.metadata.name, cluster: resource.cluster, }); return (_jsx(ResourceQuotaRenderer, { hideColumns: ['namespace'], resourceQuotas: resourceQuotas, errors: errors, noNamespaceFilter: true })); }