Skip to content

Commit

Permalink
Merge pull request #48 from mareklibra/add.id
Browse files Browse the repository at this point in the history
Add element IDs to simplify tests
  • Loading branch information
Jiri Tomasek authored Jun 26, 2020
2 parents 56a673f + 9fa220c commit 1a4c2cc
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 9 deletions.
6 changes: 5 additions & 1 deletion src/components/clusterConfiguration/discoveryImageModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ export const DiscoveryImageModalButton: React.FC<DiscoveryImageModalButtonProps>

return (
<>
<ButtonComponent variant={ButtonVariant.primary} onClick={() => setIsModalOpen(true)}>
<ButtonComponent
variant={ButtonVariant.primary}
onClick={() => setIsModalOpen(true)}
id="button-download-discovery-iso"
>
Download discovery ISO
</ButtonComponent>
{isModalOpen && <DiscoveryImageModal closeModal={closeModal} imageInfo={imageInfo} />}
Expand Down
2 changes: 1 addition & 1 deletion src/components/clusters/ClusterStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const ClusterStatus: React.FC<ClusterStatusProps> = ({ cluster }) => {
minWidth="30rem"
maxWidth="50rem"
>
<Button variant={ButtonVariant.link} isInline>
<Button variant={ButtonVariant.link} isInline id={`button-cluster-status-${cluster.name}`}>
{icon} {title}
</Button>
</Popover>
Expand Down
1 change: 1 addition & 0 deletions src/components/clusters/ClustersTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const ClustersTable: React.FC<ClustersTableProps> = ({ rows, deleteCluster }) =>
(rowData) => [
{
title: 'Delete',
id: `button-delete-${rowData.props.name}`,
isDisabled:
getClusterTableStatusCell(rowData).sortableValue === CLUSTER_STATUS_LABELS.installing,
onClick: (event: React.MouseEvent, rowIndex: number, rowData: IRowData) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/clusters/newClusterModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const NewClusterModalButton: React.FC<NewClusterModalButtonProps> = ({
ButtonComponent = Button,
onClick,
}) => (
<ButtonComponent variant={ButtonVariant.primary} onClick={onClick}>
<ButtonComponent variant={ButtonVariant.primary} onClick={onClick} id="button-create-new-cluster">
Create New Cluster
</ButtonComponent>
);
Expand Down
16 changes: 11 additions & 5 deletions src/components/hosts/HostsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ const hostToHostTableRow = (openRows: OpenRows) => (host: Host): IRow => {
fullWidth: true,
cells: [{ title: <HostDetail key={id} inventory={inventory} /> }],
key: `${host.id}-detail`,
extraData: host,
inventory,
},
];
};
Expand Down Expand Up @@ -234,7 +236,9 @@ const HostsTable: React.FC<HostsTableProps> = ({ cluster }) => {

const actionResolver = React.useCallback(
(rowData: IRowData) => {
const host = rowData.extraData;
const host: Host = rowData.extraData;
const hostname = rowData.inventory?.hostname;

if (!host) {
// I.e. row with detail
return [];
Expand All @@ -244,26 +248,28 @@ const HostsTable: React.FC<HostsTableProps> = ({ cluster }) => {
if (host.status === 'disabled') {
actions.push({
title: 'Enable in cluster',
id: `button-enable-in-cluster-${hostname}`,
onClick: onHostEnable,
});
}
if (['discovering', 'disconnected', 'known', 'insufficient'].includes(host.status)) {
actions.push({
title: 'Disable in cluster',
id: `button-disable-in-cluster-${hostname}`,
onClick: onHostDisable,
});
}
actions.push({
title: 'View Host Events History',
id: `button-view-host-events-${hostname}`,
onClick: onViewHostEvents,
});
if (!['installing', 'installing-in-progress', 'error', 'installed'].includes(host.status)) {
actions.push({
title: 'Delete',
onClick: (event: React.MouseEvent, rowIndex: number, rowData: IRowData) => {
const hostId = rowData.extraData.id;
const hostname = rowData.inventory.hostname;
setHostToDelete({ id: hostId, hostname });
id: `button-delete-host-${hostname}`,
onClick: () => {
setHostToDelete({ id: host.id, hostname });
},
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/selectors/clusters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const clusterToClusterTableRow = (cluster: Cluster): IRow => {
cells: [
{
title: (
<Link key={name} to={`/clusters/${id}`}>
<Link key={name} to={`/clusters/${id}`} id={`cluster-link-${name}`}>
{name}
</Link>
),
Expand Down

0 comments on commit 1a4c2cc

Please sign in to comment.