UI rename Endpoints to Listener Addresses

Listener Addresses is a better name to
emphasize these are routable addresses to
reach a listener service on the node.

Also removed expand toggle on the listener
addresses list items, as the expanded mode
had no additional information.

Signed-off-by: Seth Foster <fosterbseth@gmail.com>
This commit is contained in:
Seth Foster
2024-02-01 13:35:54 -05:00
committed by Seth Foster
parent 21fd6af0f9
commit 6dcaa09dfb
6 changed files with 42 additions and 56 deletions

View File

@@ -12,7 +12,7 @@ import { SettingsAPI } from 'api';
import ContentLoading from 'components/ContentLoading'; import ContentLoading from 'components/ContentLoading';
import InstanceDetail from './InstanceDetail'; import InstanceDetail from './InstanceDetail';
import InstancePeerList from './InstancePeers'; import InstancePeerList from './InstancePeers';
import InstanceEndPointList from './InstanceEndPointList'; import InstanceListenerAddressList from './InstanceListenerAddressList';
function Instance({ setBreadcrumb }) { function Instance({ setBreadcrumb }) {
const { me } = useConfig(); const { me } = useConfig();
@@ -56,8 +56,8 @@ function Instance({ setBreadcrumb }) {
if (isK8s) { if (isK8s) {
tabsArray.push({ tabsArray.push({
name: t`Endpoints`, name: t`Listener Addresses`,
link: `${match.url}/endpoints`, link: `${match.url}/listener_addresses`,
id: 1, id: 1,
}); });
tabsArray.push({ name: t`Peers`, link: `${match.url}/peers`, id: 2 }); tabsArray.push({ name: t`Peers`, link: `${match.url}/peers`, id: 2 });
@@ -79,8 +79,11 @@ function Instance({ setBreadcrumb }) {
<InstanceDetail isK8s={isK8s} setBreadcrumb={setBreadcrumb} /> <InstanceDetail isK8s={isK8s} setBreadcrumb={setBreadcrumb} />
</Route> </Route>
{isK8s && ( {isK8s && (
<Route path="/instances/:id/endpoints" key="endpoints"> <Route
<InstanceEndPointList setBreadcrumb={setBreadcrumb} /> path="/instances/:id/listener_addresses"
key="listener_addresses"
>
<InstanceListenerAddressList setBreadcrumb={setBreadcrumb} />
</Route> </Route>
)} )}
{isK8s && ( {isK8s && (

View File

@@ -1 +0,0 @@
export { default } from './InstanceEndPointList';

View File

@@ -13,9 +13,8 @@ import { useParams } from 'react-router-dom';
import useRequest from 'hooks/useRequest'; import useRequest from 'hooks/useRequest';
import DataListToolbar from 'components/DataListToolbar'; import DataListToolbar from 'components/DataListToolbar';
import { InstancesAPI, ReceptorAPI } from 'api'; import { InstancesAPI, ReceptorAPI } from 'api';
import useExpanded from 'hooks/useExpanded';
import useSelected from 'hooks/useSelected'; import useSelected from 'hooks/useSelected';
import InstanceEndPointListItem from './InstanceEndPointListItem'; import InstanceListenerAddressListItem from './InstanceListenerAddressListItem';
const QS_CONFIG = getQSConfig('peer', { const QS_CONFIG = getQSConfig('peer', {
page: 1, page: 1,
@@ -23,16 +22,16 @@ const QS_CONFIG = getQSConfig('peer', {
order_by: 'pk', order_by: 'pk',
}); });
function InstanceEndPointList({ setBreadcrumb }) { function InstanceListenerAddressList({ setBreadcrumb }) {
const { id } = useParams(); const { id } = useParams();
const { Toast, toastProps } = useToast(); const { Toast, toastProps } = useToast();
const { const {
isLoading, isLoading,
error: contentError, error: contentError,
request: fetchEndpoints, request: fetchListenerAddresses,
result: { result: {
instance, instance,
endpoints, listenerAddresses,
count, count,
relatedSearchableKeys, relatedSearchableKeys,
searchableKeys, searchableKeys,
@@ -51,21 +50,21 @@ function InstanceEndPointList({ setBreadcrumb }) {
InstancesAPI.readOptions(), InstancesAPI.readOptions(),
]); ]);
const endpoint_list = []; const listenerAddress_list = [];
for (let q = 0; q < results.length; q++) { for (let q = 0; q < results.length; q++) {
const receptor = results[q]; const receptor = results[q];
if (receptor.managed === true) continue; if (receptor.managed === true) continue;
if (id.toString() === receptor.instance.toString()) { if (id.toString() === receptor.instance.toString()) {
receptor.name = detail.hostname; receptor.name = detail.hostname;
endpoint_list.push(receptor); listenerAddress_list.push(receptor);
} }
} }
return { return {
instance: detail, instance: detail,
endpoints: endpoint_list, listenerAddresses: listenerAddress_list,
count: endpoint_list.length, count: listenerAddress_list.length,
relatedSearchableKeys: (actions?.data?.related_search_fields || []).map( relatedSearchableKeys: (actions?.data?.related_search_fields || []).map(
(val) => val.slice(0, -8) (val) => val.slice(0, -8)
), ),
@@ -74,7 +73,7 @@ function InstanceEndPointList({ setBreadcrumb }) {
}, [id]), }, [id]),
{ {
instance: {}, instance: {},
endpoints: [], listenerAddresses: [],
count: 0, count: 0,
relatedSearchableKeys: [], relatedSearchableKeys: [],
searchableKeys: [], searchableKeys: [],
@@ -82,8 +81,8 @@ function InstanceEndPointList({ setBreadcrumb }) {
); );
useEffect(() => { useEffect(() => {
fetchEndpoints(); fetchListenerAddresses();
}, [fetchEndpoints]); }, [fetchListenerAddresses]);
useEffect(() => { useEffect(() => {
if (instance) { if (instance) {
@@ -91,19 +90,17 @@ function InstanceEndPointList({ setBreadcrumb }) {
} }
}, [instance, setBreadcrumb]); }, [instance, setBreadcrumb]);
const { expanded, isAllExpanded, handleExpand, expandAll } =
useExpanded(endpoints);
const { selected, isAllSelected, handleSelect, clearSelected, selectAll } = const { selected, isAllSelected, handleSelect, clearSelected, selectAll } =
useSelected(endpoints); useSelected(listenerAddresses);
return ( return (
<CardBody> <CardBody>
<PaginatedTable <PaginatedTable
contentError={contentError} contentError={contentError}
hasContentLoading={isLoading} hasContentLoading={isLoading}
items={endpoints} items={listenerAddresses}
itemCount={count} itemCount={count}
pluralizedItemName={t`Endpoints`} pluralizedItemName={t`Listener Addresses`}
qsConfig={QS_CONFIG} qsConfig={QS_CONFIG}
onRowClick={handleSelect} onRowClick={handleSelect}
clearSelected={clearSelected} clearSelected={clearSelected}
@@ -123,7 +120,7 @@ function InstanceEndPointList({ setBreadcrumb }) {
}, },
]} ]}
headerRow={ headerRow={
<HeaderRow qsConfig={QS_CONFIG} isExpandable> <HeaderRow qsConfig={QS_CONFIG}>
<HeaderCell sortKey="address">{t`Address`}</HeaderCell> <HeaderCell sortKey="address">{t`Address`}</HeaderCell>
<HeaderCell sortKey="port">{t`Port`}</HeaderCell> <HeaderCell sortKey="port">{t`Port`}</HeaderCell>
<HeaderCell sortKey="protocol">{t`Protocol`}</HeaderCell> <HeaderCell sortKey="protocol">{t`Protocol`}</HeaderCell>
@@ -135,20 +132,16 @@ function InstanceEndPointList({ setBreadcrumb }) {
{...props} {...props}
isAllSelected={isAllSelected} isAllSelected={isAllSelected}
onSelectAll={selectAll} onSelectAll={selectAll}
isAllExpanded={isAllExpanded}
onExpandAll={expandAll}
qsConfig={QS_CONFIG} qsConfig={QS_CONFIG}
additionalControls={[]} additionalControls={[]}
/> />
)} )}
renderRow={(endpoint, index) => ( renderRow={(listenerAddress, index) => (
<InstanceEndPointListItem <InstanceListenerAddressListItem
isSelected={selected.some((row) => row.id === endpoint.id)} isSelected={selected.some((row) => row.id === listenerAddress.id)}
onSelect={() => handleSelect(endpoint)} onSelect={() => handleSelect(listenerAddress)}
isExpanded={expanded.some((row) => row.id === endpoint.id)} key={listenerAddress.id}
onExpand={() => handleExpand(endpoint)} peerListenerAddress={listenerAddress}
key={endpoint.id}
peerEndpoint={endpoint}
rowIndex={index} rowIndex={index}
/> />
)} )}
@@ -158,4 +151,4 @@ function InstanceEndPointList({ setBreadcrumb }) {
); );
} }
export default InstanceEndPointList; export default InstanceListenerAddressList;

View File

@@ -3,28 +3,18 @@ import { t } from '@lingui/macro';
import 'styled-components/macro'; import 'styled-components/macro';
import { Tr, Td } from '@patternfly/react-table'; import { Tr, Td } from '@patternfly/react-table';
function InstanceEndPointListItem({ function InstanceListenerAddressListItem({
peerEndpoint, peerListenerAddress,
isSelected, isSelected,
onSelect, onSelect,
isExpanded,
onExpand,
rowIndex, rowIndex,
}) { }) {
const labelId = `check-action-${peerEndpoint.id}`; const labelId = `check-action-${peerListenerAddress.id}`;
return ( return (
<Tr <Tr
id={`peerEndpoint-row-${peerEndpoint.id}`} id={`peerListenerAddress-row-${peerListenerAddress.id}`}
ouiaId={`peerEndpoint-row-${peerEndpoint.id}`} ouiaId={`peerListenerAddress-row-${peerListenerAddress.id}`}
> >
<Td
expand={{
rowIndex,
isExpanded,
onToggle: onExpand,
}}
/>
<Td <Td
select={{ select={{
rowIndex, rowIndex,
@@ -35,22 +25,22 @@ function InstanceEndPointListItem({
/> />
<Td id={labelId} dataLabel={t`Address`}> <Td id={labelId} dataLabel={t`Address`}>
{peerEndpoint.address} {peerListenerAddress.address}
</Td> </Td>
<Td id={labelId} dataLabel={t`Port`}> <Td id={labelId} dataLabel={t`Port`}>
{peerEndpoint.port} {peerListenerAddress.port}
</Td> </Td>
<Td id={labelId} dataLabel={t`Protocol`}> <Td id={labelId} dataLabel={t`Protocol`}>
{peerEndpoint.protocol} {peerListenerAddress.protocol}
</Td> </Td>
<Td id={labelId} dataLabel={t`Canonical`}> <Td id={labelId} dataLabel={t`Canonical`}>
{peerEndpoint.canonical.toString()} {peerListenerAddress.canonical.toString()}
</Td> </Td>
</Tr> </Tr>
); );
} }
export default InstanceEndPointListItem; export default InstanceListenerAddressListItem;

View File

@@ -0,0 +1 @@
export { default } from './InstanceListenerAddressList';

View File

@@ -25,7 +25,7 @@ function Instances() {
[`/instances/${instance.id}`]: `${instance.hostname}`, [`/instances/${instance.id}`]: `${instance.hostname}`,
[`/instances/${instance.id}/details`]: t`Details`, [`/instances/${instance.id}/details`]: t`Details`,
[`/instances/${instance.id}/peers`]: t`Peers`, [`/instances/${instance.id}/peers`]: t`Peers`,
[`/instances/${instance.id}/endpoints`]: t`Endpoints`, [`/instances/${instance.id}/listener_addresses`]: t`Listener Addresses`,
[`/instances/${instance.id}/edit`]: t`Edit Instance`, [`/instances/${instance.id}/edit`]: t`Edit Instance`,
}); });
}, []); }, []);