From 7c8b204d13dfc1500daee0026360bc08ea98ace3 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Wed, 26 Jun 2024 21:42:57 -0400 Subject: [PATCH] Remove network tab --- .../server/network/AllocationRow.tsx | 119 ------------------ .../server/network/DeleteAllocationButton.tsx | 61 --------- .../server/network/NetworkContainer.tsx | 84 ------------- resources/scripts/routers/routes.ts | 7 -- 4 files changed, 271 deletions(-) delete mode 100644 resources/scripts/components/server/network/AllocationRow.tsx delete mode 100644 resources/scripts/components/server/network/DeleteAllocationButton.tsx delete mode 100644 resources/scripts/components/server/network/NetworkContainer.tsx diff --git a/resources/scripts/components/server/network/AllocationRow.tsx b/resources/scripts/components/server/network/AllocationRow.tsx deleted file mode 100644 index e68bc3359..000000000 --- a/resources/scripts/components/server/network/AllocationRow.tsx +++ /dev/null @@ -1,119 +0,0 @@ -import React, { memo, useCallback, useState } from 'react'; -import isEqual from 'react-fast-compare'; -import tw from 'twin.macro'; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { faNetworkWired } from '@fortawesome/free-solid-svg-icons'; -import InputSpinner from '@/components/elements/InputSpinner'; -import { Textarea } from '@/components/elements/Input'; -import Can from '@/components/elements/Can'; -import { Button } from '@/components/elements/button/index'; -import GreyRowBox from '@/components/elements/GreyRowBox'; -import { Allocation } from '@/api/server/getServer'; -import styled from 'styled-components/macro'; -import { debounce } from 'debounce'; -import setServerAllocationNotes from '@/api/server/network/setServerAllocationNotes'; -import { useFlashKey } from '@/plugins/useFlash'; -import { ServerContext } from '@/state/server'; -import CopyOnClick from '@/components/elements/CopyOnClick'; -import DeleteAllocationButton from '@/components/server/network/DeleteAllocationButton'; -import setPrimaryServerAllocation from '@/api/server/network/setPrimaryServerAllocation'; -import getServerAllocations from '@/api/swr/getServerAllocations'; -import { ip } from '@/lib/formatters'; -import Code from '@/components/elements/Code'; - -const Label = styled.label` - ${tw`uppercase text-xs mt-1 text-neutral-400 block px-1 select-none transition-colors duration-150`} -`; - -interface Props { - allocation: Allocation; -} - -const AllocationRow = ({ allocation }: Props) => { - const [loading, setLoading] = useState(false); - const { clearFlashes, clearAndAddHttpError } = useFlashKey('server:network'); - const uuid = ServerContext.useStoreState((state) => state.server.data!.uuid); - const { mutate } = getServerAllocations(); - - const onNotesChanged = useCallback((id: number, notes: string) => { - mutate((data) => data?.map((a) => (a.id === id ? { ...a, notes } : a)), false); - }, []); - - const setAllocationNotes = debounce((notes: string) => { - setLoading(true); - clearFlashes(); - - setServerAllocationNotes(uuid, allocation.id, notes) - .then(() => onNotesChanged(allocation.id, notes)) - .catch((error) => clearAndAddHttpError(error)) - .then(() => setLoading(false)); - }, 750); - - const setPrimaryAllocation = () => { - clearFlashes(); - mutate((data) => data?.map((a) => ({ ...a, isDefault: a.id === allocation.id })), false); - - setPrimaryServerAllocation(uuid, allocation.id).catch((error) => { - clearAndAddHttpError(error); - mutate(); - }); - }; - - return ( - -
-
- -
-
- {allocation.alias ? ( - - - {allocation.alias} - - - ) : ( - - {ip(allocation.ip)} - - )} - -
-
- {allocation.port} - -
-
-
- -