@kinvolk/headlamp-plugin
Version:
The needed infrastructure for building Headlamp plugins.
82 lines (81 loc) • 5.34 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } 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 { useLocation, useParams } from 'react-router-dom';
import { ResourceClasses } from '../../lib/k8s';
import Endpoints from '../../lib/k8s/endpoints';
import { Link, SectionHeader } from '../common';
import Empty from '../common/EmptyContent';
import { DetailsGrid } from '../common/Resource';
import { SectionBox } from '../common/SectionBox';
import SimpleTable from '../common/SimpleTable';
export default function EndpointDetails(props) {
const params = useParams();
const { name = params.name, namespace = params.namespace, cluster } = props;
const location = useLocation();
const { t } = useTranslation(['glossary', 'translation']);
return (_jsx(DetailsGrid, { resourceType: Endpoints, name: name, namespace: namespace, cluster: cluster, title: t('Endpoint'), withEvents: true, extraSections: (item) => item && [
{
id: 'headlamp.endpoint-subsets',
section: (_jsxs(_Fragment, { children: [_jsx(SectionBox, { title: t('Subsets') }), _jsx(_Fragment, { children: !item.subsets?.length ? (_jsx(SectionBox, { children: _jsx(Empty, { children: t('translation|No data to be shown.') }) })) : (item.subsets?.map((subset, i) => (_jsxs(SectionBox, { outterBoxProps: { pb: 3 }, children: [_jsx(SectionHeader, { noPadding: true, title: t('translation|Addresses'), headerStyle: "label" }), _jsx(SimpleTable, { data: subset?.addresses || [], columns: [
{
label: t('IP'),
getter: address => address.ip,
},
{
label: t('Hostname'),
getter: address => address.hostname,
},
{
label: t('Target'),
getter: address => {
const targetRefClass = !!address.targetRef?.kind
? ResourceClasses[address.targetRef?.kind]
: null;
if (!!targetRefClass) {
return (_jsx(Link, { routeName: targetRefClass.detailsRoute, params: {
name: address.targetRef.name,
namespace: address.targetRef.namespace,
}, state: {
backLink: location,
}, children: address.targetRef.name }));
}
else {
return address.targetRef?.name || '';
}
},
},
], reflectInURL: "addresses" }), _jsx(SectionHeader, { noPadding: true, title: t('Ports'), headerStyle: "label" }), _jsx(SimpleTable, { data: subset?.ports || [], columns: [
{
label: t('translation|Name'),
datum: 'name',
sort: true,
},
{
label: t('Port'),
datum: 'port',
sort: true,
},
{
label: t('Protocol'),
datum: 'protocol',
sort: true,
},
], defaultSortingColumn: 1, reflectInURL: "ports" })] }, `subsetDetails_${i}`)))) })] })),
},
] }));
}