From 7a66b1417c8ca3bdb52d5b4b125956df815fa6b1 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Wed, 20 Jul 2022 17:08:37 -0400 Subject: [PATCH] fix(striker-ui): add network with button --- striker-ui/components/NetworkInitForm.tsx | 66 ++++++++++------------- 1 file changed, 29 insertions(+), 37 deletions(-) diff --git a/striker-ui/components/NetworkInitForm.tsx b/striker-ui/components/NetworkInitForm.tsx index 03531f33..7ac9fe76 100644 --- a/striker-ui/components/NetworkInitForm.tsx +++ b/striker-ui/components/NetworkInitForm.tsx @@ -19,7 +19,7 @@ import { import { v4 as uuidv4 } from 'uuid'; import API_BASE_URL from '../lib/consts/API_BASE_URL'; -import { BLUE, GREY, TEXT } from '../lib/consts/DEFAULT_THEME'; +import { BLUE, GREY } from '../lib/consts/DEFAULT_THEME'; import BriefNetworkInterface from './BriefNetworkInterface'; import Decorator from './Decorator'; @@ -31,6 +31,7 @@ import SelectWithLabel from './SelectWithLabel'; import Spinner from './Spinner'; import sumstring from '../lib/sumstring'; import { BodyText, DataGridCellText } from './Text'; +import IconButton from './IconButton'; export type NetworkInterfaceInputMap = Record< string, @@ -256,6 +257,19 @@ const NetworkInitForm: FC = () => { setNetworkInterfaceHeld(undefined); }; + const createNetwork = () => { + networkInputs.unshift({ + inputUUID: uuidv4(), + interfaces: [], + ipAddress: '', + name: '', + subnetMask: '', + type: '', + }); + + setNetworkInputs([...networkInputs]); + }; + const getNetworkTypeCount = (targetType: string, lastIndex = 0) => { let count = 0; @@ -272,7 +286,6 @@ const NetworkInitForm: FC = () => { interfaces: NetworkInterfaceOverviewMetadata[], ) => MUIBoxProps['onMouseUp']; let floatingNetworkInterface: JSX.Element = <>; - let handleCreateNetworkMouseUp: MUIBoxProps['onMouseUp']; let handleDragAreaMouseLeave: MUIBoxProps['onMouseLeave']; let handleDragAreaMouseMove: MUIBoxProps['onMouseMove']; let handleDragAreaMouseUp: MUIBoxProps['onMouseUp']; @@ -301,19 +314,6 @@ const NetworkInitForm: FC = () => { /> ); - handleCreateNetworkMouseUp = () => { - networkInputs.unshift({ - inputUUID: uuidv4(), - interfaces: [networkInterfaceHeld], - ipAddress: '', - name: '', - subnetMask: '', - type: '', - }); - - networkInterfaceInputMap[networkInterfaceUUID].isApplied = true; - }; - handleDragAreaMouseLeave = () => { clearNetworkInterfaceHeld(); }; @@ -376,7 +376,7 @@ const NetworkInitForm: FC = () => { display: 'flex', flexDirection: 'column', - '& > :not(:first-child, :nth-child(2))': { + '& > :not(:first-child, :last-child)': { marginTop: '1em', }, }} @@ -405,9 +405,22 @@ const NetworkInitForm: FC = () => { /> + + + + + *': { marginBottom: '1em', @@ -421,27 +434,6 @@ const NetworkInitForm: FC = () => { }, }} > - - - - {networkInputs.map((networkInput, networkIndex) => { const { inputUUID, interfaces, ipAddress, subnetMask, type } = networkInput;