From 5d176a87022db9fe70fb4fbf7cb4448572df7410 Mon Sep 17 00:00:00 2001 From: Martin Sottnik Date: Fri, 14 Jan 2022 12:55:05 +0100 Subject: [PATCH] Deallocate id from workflow (#318) * allocating ids from workflows * deallocate ids via workflows * deallocate pools on discard * add parameters to free allocation workflows --- .../src/components/forms/connection-form.tsx | 6 +++--- .../create-evc-attachment/create-evc-attachment.tsx | 11 ++++++++++- .../create-site-network-access.tsx | 11 ++++++++++- .../pages/create-vpn-service/create-vpn-service.tsx | 13 ++++++++++++- .../frinx-gamma/src/pages/evc-list/evc-table.tsx | 4 ++-- packages/frinx-gamma/src/uniflow-callback-utils.ts | 2 +- 6 files changed, 38 insertions(+), 9 deletions(-) diff --git a/packages/frinx-gamma/src/components/forms/connection-form.tsx b/packages/frinx-gamma/src/components/forms/connection-form.tsx index 1299cfae2..443d4488d 100644 --- a/packages/frinx-gamma/src/components/forms/connection-form.tsx +++ b/packages/frinx-gamma/src/components/forms/connection-form.tsx @@ -1,7 +1,7 @@ import React, { FC } from 'react'; import { Input, Select, FormControl, FormErrorMessage, FormLabel } from '@chakra-ui/react'; -import { FormikErrors, FormikValues } from 'formik'; -import { Connection, VpnBearer } from './bearer-types'; +import { FormikErrors } from 'formik'; +import { Connection } from './bearer-types'; import { getSelectOptions } from './options.helper'; type Props = { @@ -79,7 +79,7 @@ const ConnectionForm: FC = ({ connection, errors, onChange }) => { })} - + MTU = ({ onSuccess, onCa } }; - const handleCancel = () => { + const handleCancel = async () => { + const uniflowCallbacks = uniflowCallbackUtils.getCallbacks; + await uniflowCallbacks.executeWorkflow({ + name: 'Free_SvlanId', + version: 1, + input: { + sp_bearer_reference: unwrap(selectedBearer?.spBearerReference), // eslint-disable-line @typescript-eslint/naming-convention + vlan: unwrap(svlanId), + }, + }); // eslint-disable-next-line no-console console.log('cancel clicked'); onCancel(unwrap(selectedBearer?.spBearerReference)); diff --git a/packages/frinx-gamma/src/pages/create-site-network-access/create-site-network-access.tsx b/packages/frinx-gamma/src/pages/create-site-network-access/create-site-network-access.tsx index c1c34d912..a945545f1 100644 --- a/packages/frinx-gamma/src/pages/create-site-network-access/create-site-network-access.tsx +++ b/packages/frinx-gamma/src/pages/create-site-network-access/create-site-network-access.tsx @@ -152,7 +152,16 @@ const CreateSiteNetAccessPage: VoidFunctionComponent = ({ onSuccess, onCa } }; - const handleCancel = () => { + const handleCancel = async () => { + const uniflowCallbacks = uniflowCallbackUtils.getCallbacks; + await uniflowCallbacks.executeWorkflow({ + name: 'Free_CustomerAddress', + version: 1, + input: { + site: siteId, + customer_address: unwrap(customerAddress), // eslint-disable-line @typescript-eslint/naming-convention + }, + }); // eslint-disable-next-line no-console console.log('cancel clicked'); onCancel(unwrap(selectedSite?.siteId)); diff --git a/packages/frinx-gamma/src/pages/create-vpn-service/create-vpn-service.tsx b/packages/frinx-gamma/src/pages/create-vpn-service/create-vpn-service.tsx index 7f2f3c960..3b2fb2d77 100644 --- a/packages/frinx-gamma/src/pages/create-vpn-service/create-vpn-service.tsx +++ b/packages/frinx-gamma/src/pages/create-vpn-service/create-vpn-service.tsx @@ -35,6 +35,7 @@ type Props = { const CreateVpnServicePage: VoidFunctionComponent = ({ onSuccess, onCancel }) => { const [workflowId, setWorkflowId] = useState(null); const [vpnId, setVpnId] = useState(null); + const [counter, setCounter] = useState(null); const [vpnServices, setVpnServices] = useState(null); const [submitError, setSubmitError] = useState(null); @@ -76,7 +77,16 @@ const CreateVpnServicePage: VoidFunctionComponent = ({ onSuccess, onCance } }; - const handleCancel = () => { + const handleCancel = async () => { + const uniflowCallbacks = uniflowCallbackUtils.getCallbacks; + await uniflowCallbacks.executeWorkflow({ + name: 'Free_VpnServiceId', + version: 1, + input: { + text: unwrap(vpnId), + counter: unwrap(counter), + }, + }); // eslint-disable-next-line no-console console.log('cancel clicked'); onCancel(); @@ -89,6 +99,7 @@ const CreateVpnServicePage: VoidFunctionComponent = ({ onSuccess, onCance // eslint-disable-next-line @typescript-eslint/naming-convention const { response_body }: VpnServiceWorkflowData = JSON.parse(data); setVpnId(response_body.text); + setCounter(response_body.counter); }; if (!workflowId) { diff --git a/packages/frinx-gamma/src/pages/evc-list/evc-table.tsx b/packages/frinx-gamma/src/pages/evc-list/evc-table.tsx index 0b3f07bf4..06adf6253 100644 --- a/packages/frinx-gamma/src/pages/evc-list/evc-table.tsx +++ b/packages/frinx-gamma/src/pages/evc-list/evc-table.tsx @@ -1,4 +1,4 @@ -import { Flex, HStack, Icon, IconButton, Table, Tbody, Td, Text, Th, Thead, Tr, Tooltip } from '@chakra-ui/react'; +import { HStack, Icon, IconButton, Table, Tbody, Td, Text, Th, Thead, Tr, Tooltip } from '@chakra-ui/react'; import { ChevronDownIcon, ChevronUpIcon } from '@chakra-ui/icons'; import FeatherIcon from 'feather-icons-react'; import React, { VoidFunctionComponent } from 'react'; @@ -32,7 +32,7 @@ const EvcTable: VoidFunctionComponent = ({ - + BMT Circuit Reference Carrier Reference Svlan Id diff --git a/packages/frinx-gamma/src/uniflow-callback-utils.ts b/packages/frinx-gamma/src/uniflow-callback-utils.ts index 9b3f48e84..9b2167f9e 100644 --- a/packages/frinx-gamma/src/uniflow-callback-utils.ts +++ b/packages/frinx-gamma/src/uniflow-callback-utils.ts @@ -1,5 +1,5 @@ export type WorkflowPayload = { - input: Record; + input: Record; name: string; version: number; };