From 9c6aa930932804c8e36283e7687a4352e0718627 Mon Sep 17 00:00:00 2001 From: Kia Lam Date: Mon, 12 Sep 2022 18:27:21 -0700 Subject: [PATCH] Remove action items from Instance peers list. --- .../InstancePeers/InstancePeerList.js | 57 +------ .../InstancePeers/InstancePeerListItem.js | 156 +----------------- 2 files changed, 6 insertions(+), 207 deletions(-) diff --git a/awx/ui/src/screens/Instances/InstancePeers/InstancePeerList.js b/awx/ui/src/screens/Instances/InstancePeers/InstancePeerList.js index d717cbcda075..a1d104d6672c 100644 --- a/awx/ui/src/screens/Instances/InstancePeers/InstancePeerList.js +++ b/awx/ui/src/screens/Instances/InstancePeers/InstancePeerList.js @@ -6,16 +6,12 @@ import PaginatedTable, { HeaderCell, HeaderRow, } from 'components/PaginatedTable'; -import useRequest, { useDismissableError } from 'hooks/useRequest'; import { getQSConfig, parseQueryString } from 'util/qs'; import { useLocation, useParams } from 'react-router-dom'; +import useRequest from 'hooks/useRequest'; import DataListToolbar from 'components/DataListToolbar'; import { InstancesAPI } from 'api'; import useExpanded from 'hooks/useExpanded'; -import ErrorDetail from 'components/ErrorDetail'; -import useSelected from 'hooks/useSelected'; -import HealthCheckButton from 'components/HealthCheckButton'; -import AlertModal from 'components/AlertModal'; import InstancePeerListItem from './InstancePeerListItem'; const QS_CONFIG = getQSConfig('peer', { @@ -65,30 +61,6 @@ function InstancePeerList() { fetchPeers(); }, [fetchPeers]); - const { selected, isAllSelected, handleSelect, clearSelected, selectAll } = - useSelected(peers.filter((i) => i.node_type !== 'hop')); - - const { - error: healthCheckError, - request: fetchHealthCheck, - isLoading: isHealthCheckLoading, - } = useRequest( - useCallback(async () => { - await Promise.all( - selected - .filter(({ node_type }) => node_type !== 'hop') - .map(({ instanceId }) => InstancesAPI.healthCheck(instanceId)) - ); - fetchPeers(); - }, [selected, fetchPeers]) - ); - const handleHealthCheck = async () => { - await fetchHealthCheck(); - clearSelected(); - }; - - const { error, dismissError } = useDismissableError(healthCheckError); - const { expanded, isAllExpanded, handleExpand, expandAll } = useExpanded(peers); @@ -96,7 +68,7 @@ function InstancePeerList() { {t`Name`} {t`Status`} {t`Node Type`} - {t`Capacity Adjustment`} - {t`Used Capacity`} - {t`Actions`} } renderToolbar={(props) => ( , - ]} /> )} renderRow={(peer, index) => ( handleSelect(peer)} - isSelected={selected.some((row) => row.id === peer.id)} isExpanded={expanded.some((row) => row.id === peer.id)} onExpand={() => handleExpand(peer)} key={peer.id} peerInstance={peer} rowIndex={index} - fetchInstance={fetchPeers} /> )} /> - {error && ( - - {t`Failed to run a health check on one or more peers.`} - - - )} ); } diff --git a/awx/ui/src/screens/Instances/InstancePeers/InstancePeerListItem.js b/awx/ui/src/screens/Instances/InstancePeers/InstancePeerListItem.js index bc3b5ad9128e..cce09300b042 100644 --- a/awx/ui/src/screens/Instances/InstancePeers/InstancePeerListItem.js +++ b/awx/ui/src/screens/Instances/InstancePeers/InstancePeerListItem.js @@ -1,104 +1,20 @@ -import React, { useState, useCallback } from 'react'; +import React from 'react'; import { Link } from 'react-router-dom'; -import { t, Plural } from '@lingui/macro'; -import styled from 'styled-components'; +import { t } from '@lingui/macro'; import 'styled-components/macro'; -import { - Progress, - ProgressMeasureLocation, - ProgressSize, - Slider, - Tooltip, -} from '@patternfly/react-core'; +import { Tooltip } from '@patternfly/react-core'; import { Tr, Td, ExpandableRowContent } from '@patternfly/react-table'; import { formatDateString } from 'util/dates'; -import computeForks from 'util/computeForks'; -import { ActionsTd, ActionItem } from 'components/PaginatedTable'; -import InstanceToggle from 'components/InstanceToggle'; import StatusLabel from 'components/StatusLabel'; -import useRequest, { useDismissableError } from 'hooks/useRequest'; -import useDebounce from 'hooks/useDebounce'; -import { InstancesAPI } from 'api'; -import { useConfig } from 'contexts/Config'; -import AlertModal from 'components/AlertModal'; -import ErrorDetail from 'components/ErrorDetail'; import { Detail, DetailList } from 'components/DetailList'; -const Unavailable = styled.span` - color: var(--pf-global--danger-color--200); -`; - -const SliderHolder = styled.div` - display: flex; - align-items: center; - justify-content: space-between; -`; - -const SliderForks = styled.div` - flex-grow: 1; - margin-right: 8px; - margin-left: 8px; - text-align: center; -`; - function InstancePeerListItem({ peerInstance, - fetchInstances, - isSelected, - onSelect, isExpanded, onExpand, rowIndex, }) { - const { me = {} } = useConfig(); - const [forks, setForks] = useState( - computeForks( - peerInstance.mem_capacity, - peerInstance.cpu_capacity, - peerInstance.capacity_adjustment - ) - ); const labelId = `check-action-${peerInstance.id}`; - - function usedCapacity(item) { - if (item.enabled) { - return ( - - ); - } - return {t`Unavailable`}; - } - - const { error: updateInstanceError, request: updateInstance } = useRequest( - useCallback( - async (values) => { - await InstancesAPI.update(peerInstance.id, values); - }, - [peerInstance] - ) - ); - - const { error: updateError, dismissError: dismissUpdateError } = - useDismissableError(updateInstanceError); - - const debounceUpdateInstance = useDebounce(updateInstance, 200); - - const handleChangeValue = (value) => { - const roundedValue = Math.round(value * 100) / 100; - setForks( - computeForks( - peerInstance.mem_capacity, - peerInstance.cpu_capacity, - roundedValue - ) - ); - debounceUpdateInstance({ capacity_adjustment: roundedValue }); - }; const isHopNode = peerInstance.node_type === 'hop'; return ( <> @@ -117,15 +33,7 @@ function InstancePeerListItem({ }} /> )} - + {peerInstance.hostname} @@ -149,51 +57,6 @@ function InstancePeerListItem({ {peerInstance.node_type} - {!isHopNode && ( - <> - - -
{t`CPU ${peerInstance.cpu_capacity}`}
- -
- -
- -
-
{t`RAM ${peerInstance.mem_capacity}`}
-
- - - - {usedCapacity(peerInstance)} - - - - - - - - - )} {!isHopNode && ( )} - {updateError && ( - - {t`Failed to update capacity adjustment.`} - - - )} ); }