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

feat: [M3-6729] - Add VPC column to Linodes landing table #9485

Merged
merged 23 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5ad2576
add vpc column to linode landing pg table
coliu-akamai Aug 1, 2023
7c7aeac
Merge branch 'develop' into feat-m3-6729
coliu-akamai Aug 1, 2023
fd54d0d
roundabout way to get vpcs associated with a linode
coliu-akamai Aug 2, 2023
75fdffc
Merge branch 'develop' into feat-m3-6729
coliu-akamai Aug 2, 2023
c5cbae0
add comments and todos
coliu-akamai Aug 2, 2023
1701322
sortable table row for vpcs now
coliu-akamai Aug 3, 2023
5284cd0
remove unneeded comment
coliu-akamai Aug 3, 2023
8356a4d
...fix comment
coliu-akamai Aug 3, 2023
d146bbe
changeset and update test
coliu-akamai Aug 3, 2023
db8aa49
linode row trying to test for vpc column wip
coliu-akamai Aug 3, 2023
faf21e1
test vpc column shows up with feature flag
coliu-akamai Aug 3, 2023
2d653e1
updated linode row vpc column
coliu-akamai Aug 11, 2023
379b9cd
Added changeset: Update linode config interface return object as per …
coliu-akamai Aug 11, 2023
ef9c477
Merge branch 'develop' into feat-m3-6729
coliu-akamai Aug 11, 2023
17ad18f
Update packages/api-v4/.changeset/pr-9485-upcoming-features-169176419…
coliu-akamai Aug 11, 2023
87f492c
Update packages/manager/src/features/Linodes/LinodesLanding/LinodeRow…
coliu-akamai Aug 11, 2023
8451e7d
address feedback
coliu-akamai Aug 11, 2023
3a1c207
Added changeset: Update validation for `linodeInterfaceSchema`: inclu…
coliu-akamai Aug 11, 2023
20cfb48
Update packages/manager/src/features/Linodes/LinodesLanding/LinodeRow…
coliu-akamai Aug 14, 2023
f3fe379
address feedback @bnussman-akamai
coliu-akamai Aug 14, 2023
14d3938
Merge branch 'develop' into feat-m3-6729
coliu-akamai Aug 14, 2023
62577fa
update cypress test
coliu-akamai Aug 14, 2023
091181e
remove vpc_id from linode interface schema
coliu-akamai Aug 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Linode } from '@linode/api-v4/lib/linodes';
import { SxProps } from '@mui/system';
import * as React from 'react';
import { Link } from 'react-router-dom';
import { VPC } from '@linode/api-v4';

import Flag from 'src/assets/icons/flag.svg';
import { BackupStatus } from 'src/components/BackupStatus/BackupStatus';
Expand All @@ -22,6 +23,8 @@ import { notificationContext as _notificationContext } from 'src/features/Notifi
import { useAllAccountMaintenanceQuery } from 'src/queries/accountMaintenance';
import { useNotificationsQuery } from 'src/queries/accountNotifications';
import { useTypeQuery } from 'src/queries/types';
import { useFlags } from 'src/hooks/useFlags';
import { useVPCsQuery } from 'src/queries/vpcs';
import { useRecentEventForLinode } from 'src/store/selectors/recentEventForLinode';
import { capitalizeAllWords } from 'src/utilities/capitalize';
import { formatStorageUnits } from 'src/utilities/formatStorageUnits';
Expand All @@ -41,6 +44,7 @@ import {
type Props = Linode & { handlers: LinodeHandlers };

export const LinodeRow = (props: Props) => {
const flags = useFlags();
const { backups, handlers, id, ipv4, label, region, status, type } = props;

const notificationContext = React.useContext(_notificationContext);
Expand All @@ -52,6 +56,17 @@ export const LinodeRow = (props: Props) => {
{ status: { '+or': ['pending, started'] } }
);

// TODO: VPC - currently the only way to know what VPC a linode is associated with is to get all
// vpcs, and then loop through each vpc's subnets, and then through each of the subnets' linode IDs
// to see if that subnet contains this linode id. There is some discussion about an endpoint
// that will directly get vpcs associated with a linode ID, and if that happens, we can
// replace this query
// Can also put react query this in Linodes/index instead, so that getting all vpcs is only done once
// (but if react query caches the data from this call it should be ok either way?)
const { data: vpcs } = useVPCsQuery({}, {});
// query is paginated -- does not passing in any params mean that it will get all vpcs?
const vpc = findAssociatedVPC(vpcs?.data ?? [], id);

const maintenance = accountMaintenanceData?.find(
(m) => m.entity.id === id && m.entity.type === 'linode'
);
Expand Down Expand Up @@ -166,6 +181,17 @@ export const LinodeRow = (props: Props) => {
<RegionIndicator region={region} />
</TableCell>
</Hidden>
{flags.vpc && (
<Hidden lgDown>
<TableCell>
{vpc && (
<Link tabIndex={0} to={`/vpc/${vpc.id}`}>
{vpc.label}
</Link>
)}
</TableCell>
</Hidden>
)}
</Hidden>
<Hidden lgDown>
<TableCell>
Expand Down Expand Up @@ -199,6 +225,20 @@ export const LinodeRow = (props: Props) => {
);
};

const findAssociatedVPC = (vpcs: VPC[], linodeId: number) => {
for (const vpc of vpcs) {
for (const subnet of vpc.subnets) {
if (subnet.linodes.includes(linodeId)) {
// a linode should have only one vpc associated with it (?) so we can
// short circuit once we find the associated vpc
return vpc;
}
}
}

return undefined;
};

export const RenderFlag: React.FC<{
linodeNotifications: Notification[];
mutationAvailable: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { TableHead } from 'src/components/TableHead';
import { TableRow } from 'src/components/TableRow';
import { TableSortCell } from 'src/components/TableSortCell';
import { Tooltip } from 'src/components/Tooltip';
import { useFlags } from 'src/hooks/useFlags';

import { StyledToggleButton } from './DisplayLinodes.styles';

Expand All @@ -27,6 +28,7 @@ interface Props {
type CombinedProps<T> = Props & Omit<OrderByProps<T>, 'data'>;

const SortableTableHead = <T extends unknown>(props: CombinedProps<T>) => {
const flags = useFlags();
const theme = useTheme();

const {
Expand Down Expand Up @@ -115,7 +117,7 @@ const SortableTableHead = <T extends unknown>(props: CombinedProps<T>) => {
handleClick={handleOrderChange}
label="ipv4[0]" // we want to sort by the first ipv4
>
IP Address
Public IP Address
</TableSortCell>
<Hidden lgDown>
<TableSortCell
Expand All @@ -135,6 +137,19 @@ const SortableTableHead = <T extends unknown>(props: CombinedProps<T>) => {
Region
</TableSortCell>
</Hidden>
{flags.vpc && ( // do we this to still show up even if isVlan is true?
<Hidden lgDown>
<TableSortCell
// TODO: VPC - figure out the orderBy (cannot use label, as that will order via linode label)
active={isActive('vpc')}
direction={order}
handleClick={handleOrderChange}
label="vpc"
>
VPC
</TableSortCell>
</Hidden>
)}
</Hidden>
<Hidden lgDown>
<TableSortCell
Expand Down