Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change: [M3-7289] – Payload refinements in "Assign Linodes" flow #9845

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

Refine payload in subnet "Assign Linodes" drawer ([#9845](https://github.com/linode/manager/pull/9845))
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ export class LinodeCreate extends React.PureComponent<
];
}

const defaultPublicInterface: InterfacePayload = {
export const defaultPublicInterface: InterfacePayload = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I briefly considered moving this to src/constants.ts, but it felt out of place there and I didn't see a better spot so I just exported it from here for now.

ipam_address: '',
label: '',
purpose: 'public',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Link } from 'src/components/Link';
import { Notice } from 'src/components/Notice/Notice';
import { RemovableSelectionsList } from 'src/components/RemovableSelectionsList/RemovableSelectionsList';
import { TextField } from 'src/components/TextField';
import { defaultPublicInterface } from 'src/features/Linodes/LinodesCreate/LinodeCreate';
import { useFormattedDate } from 'src/hooks/useFormattedDate';
import { useUnassignLinode } from 'src/hooks/useUnassignLinode';
import { useAllLinodesQuery } from 'src/queries/linodes/linodes';
Expand Down Expand Up @@ -139,16 +140,31 @@ export const SubnetAssignLinodesDrawer = (

const configId = getConfigId(linodeConfigs, selectedConfig);

const configToBeModified = linodeConfigs.find(
(config) => config.id === configId
);

const interfacePayload: InterfacePayload = {
ipam_address: null,
label: null,
primary: true,
purpose: 'vpc',
subnet_id: subnet?.id,
vpc_id: vpcId,
...(!autoAssignIPv4 && { ipv4: { vpc: chosenIP } }),
...(!autoAssignIPv4 && { ipv4: { nat_1_1: 'any', vpc: chosenIP } }),
};

try {
// If the config has only an implicit public interface, make it explicit and
// add it in eth0
if (configToBeModified?.interfaces.length === 0) {
dwiley-akamai marked this conversation as resolved.
Show resolved Hide resolved
appendConfigInterface(
selectedLinode?.id ?? -1,
configId,
defaultPublicInterface
);
}

const newInterface = await appendConfigInterface(
selectedLinode?.id ?? -1,
configId,
Expand Down