Skip to content

Commit

Permalink
Deallocate id from workflow (#318)
Browse files Browse the repository at this point in the history
* allocating ids from workflows

* deallocate ids via workflows

* deallocate pools on discard

* add parameters to free allocation workflows
  • Loading branch information
soson authored Jan 14, 2022
1 parent 75e2ba7 commit 5d176a8
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/frinx-gamma/src/components/forms/connection-form.tsx
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -79,7 +79,7 @@ const ConnectionForm: FC<Props> = ({ connection, errors, onChange }) => {
})}
</Select>
</FormControl>
<FormControl id="connection-mtu" my={6} isInvalid={errors && errors.mtu != undefined}>
<FormControl id="connection-mtu" my={6} isInvalid={errors && errors.mtu !== undefined}>
<FormLabel>MTU</FormLabel>
<Input
name="connection-mtu"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,16 @@ const CreateEvcAttachmentPage: VoidFunctionComponent<Props> = ({ 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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,16 @@ const CreateSiteNetAccessPage: VoidFunctionComponent<Props> = ({ 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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type Props = {
const CreateVpnServicePage: VoidFunctionComponent<Props> = ({ onSuccess, onCancel }) => {
const [workflowId, setWorkflowId] = useState<string | null>(null);
const [vpnId, setVpnId] = useState<string | null>(null);
const [counter, setCounter] = useState<number | null>(null);
const [vpnServices, setVpnServices] = useState<VpnService[] | null>(null);
const [submitError, setSubmitError] = useState<string | null>(null);

Expand Down Expand Up @@ -76,7 +77,16 @@ const CreateVpnServicePage: VoidFunctionComponent<Props> = ({ 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();
Expand All @@ -89,6 +99,7 @@ const CreateVpnServicePage: VoidFunctionComponent<Props> = ({ 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) {
Expand Down
4 changes: 2 additions & 2 deletions packages/frinx-gamma/src/pages/evc-list/evc-table.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -32,7 +32,7 @@ const EvcTable: VoidFunctionComponent<Props> = ({
<Thead>
<Tr>
<Th />
<Th></Th>
<Th />
<Th>BMT Circuit Reference</Th>
<Th>Carrier Reference</Th>
<Th>Svlan Id</Th>
Expand Down
2 changes: 1 addition & 1 deletion packages/frinx-gamma/src/uniflow-callback-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type WorkflowPayload = {
input: Record<string, string>;
input: Record<string, string | number>;
name: string;
version: number;
};
Expand Down

0 comments on commit 5d176a8

Please sign in to comment.