-
Notifications
You must be signed in to change notification settings - Fork 365
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-6731] β Add VPC and Firewall sections in Linode Create flow #9635
Merged
dwiley-akamai
merged 26 commits into
linode:develop
from
dwiley-akamai:M3-6731-vpc-firewall-sections-linode-create
Sep 28, 2023
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
f8d5d85
Initial groundwork for VPCPanel and FirewallPanel components
DevDW ef62b27
Merge branch 'develop' into M3-6731-vpc-firewall-sections-linode-create
DevDW 2affd24
Merge branch 'develop' into M3-6731-vpc-firewall-sections-linode-create
DevDW fd3f5e1
Core functionality in place: Firewalls work well, VPC works but needsβ¦
DevDW 1d267f1
Merge in latest develop, resolve conflicts
DevDW 5b703e9
Progress: validation on VPC fields; 'Create VPC' link opens in new taβ¦
DevDW 4a9755c
Merge in latest develop and resolve conflicts
DevDW 7140d99
More error handling
DevDW cc54063
Add parenthetical IPv4 ranges to subnet options
DevDW e6ec6ac
Cleanup, move VPC data into interfaces property of Linode Create paylβ¦
DevDW e681167
Merge branch 'develop' into M3-6731-vpc-firewall-sections-linode-create
DevDW a2d5d61
FirewallPanel feedback: moved from src/features/Linodes/LinodesCreateβ¦
DevDW 022f800
Small refactors, UX interaction improvements, copy changes
DevDW 4037307
Fix firewall_id in payload (important for Create Using Command Line),β¦
DevDW af20dd2
Open 'Create Firewall' link in new tab
DevDW ed628f7
Remove now unneeded changes in src/queries/linodes/configs.ts
DevDW 8768182
Added changeset: VPCs added to region Capabilities type
DevDW 446c214
Added changeset: linodeInterfaceSchema now validates a single interfaβ¦
DevDW dc0ce51
Added changeset: VPC and Firewall assignment within Linode Create flow
DevDW 9690963
Merge branch 'develop' into M3-6731-vpc-firewall-sections-linode-create
DevDW eb43f78
linodeCreateWithFirewall feature flag logic
DevDW 9c845c8
Unit tests + some minor changes
DevDW 959f206
Merge in latest develop and resolve conflicts
DevDW 3338425
Feedback: checkbox spacing, 'Firewall Assigned' in summary paper, relβ¦
DevDW 9daf1c7
Restore conditional render logic in VPCPanel.tsx and remove it from Lβ¦
DevDW e349e3e
Feedback: cut down on unnecessary requests to /vpcs; scroll to VPC erβ¦
DevDW File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/api-v4/.changeset/pr-9635-upcoming-features-1695321404295.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/api-v4": Upcoming Features | ||
--- | ||
|
||
VPCs added to region Capabilities type ([#9635](https://github.com/linode/manager/pull/9635)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
packages/manager/.changeset/pr-9635-upcoming-features-1695321565271.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Upcoming Features | ||
--- | ||
|
||
VPC and Firewall assignment within Linode Create flow ([#9635](https://github.com/linode/manager/pull/9635)) |
34 changes: 34 additions & 0 deletions
34
packages/manager/src/components/SelectFirewallPanel/SelectFirewallPanel.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { waitFor } from '@testing-library/react'; | ||
import * as React from 'react'; | ||
import { QueryClient } from 'react-query'; | ||
|
||
import { mockMatchMedia, renderWithTheme } from 'src/utilities/testHelpers'; | ||
|
||
import { SelectFirewallPanel } from './SelectFirewallPanel'; | ||
|
||
const queryClient = new QueryClient(); | ||
|
||
beforeAll(() => mockMatchMedia()); | ||
afterEach(() => { | ||
queryClient.clear(); | ||
}); | ||
|
||
const testId = 'select-firewall-panel'; | ||
|
||
describe('SelectFirewallPanel', () => { | ||
it('should render', async () => { | ||
const wrapper = renderWithTheme( | ||
<SelectFirewallPanel | ||
handleFirewallChange={jest.fn()} | ||
helperText={<span>Testing</span>} | ||
/>, | ||
{ | ||
queryClient, | ||
} | ||
); | ||
|
||
await waitFor(() => { | ||
expect(wrapper.getByTestId(testId)).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |
63 changes: 63 additions & 0 deletions
63
packages/manager/src/components/SelectFirewallPanel/SelectFirewallPanel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import Stack from '@mui/material/Stack'; | ||
import * as React from 'react'; | ||
|
||
import Select from 'src/components/EnhancedSelect'; | ||
import { Paper } from 'src/components/Paper'; | ||
import { Typography } from 'src/components/Typography'; | ||
import { APP_ROOT } from 'src/constants'; | ||
import { useFirewallsQuery } from 'src/queries/firewalls'; | ||
|
||
import { StyledCreateLink } from '../../features/Linodes/LinodesCreate/LinodeCreate.styles'; | ||
|
||
interface Props { | ||
handleFirewallChange: (firewallID: number) => void; | ||
helperText: JSX.Element; | ||
} | ||
|
||
export const SelectFirewallPanel = (props: Props) => { | ||
const { handleFirewallChange, helperText } = props; | ||
|
||
const { data: firewallsData, error, isLoading } = useFirewallsQuery(); | ||
|
||
const firewalls = firewallsData?.data ?? []; | ||
const firewallsDropdownOptions = firewalls.map((firewall) => ({ | ||
label: firewall.label, | ||
value: firewall.id, | ||
})); | ||
|
||
firewallsDropdownOptions.unshift({ | ||
label: 'None', | ||
value: -1, | ||
}); | ||
|
||
return ( | ||
<Paper | ||
data-testid="select-firewall-panel" | ||
sx={(theme) => ({ marginTop: theme.spacing(3) })} | ||
> | ||
<Typography | ||
sx={(theme) => ({ marginBottom: theme.spacing(2) })} | ||
variant="h2" | ||
> | ||
Firewall | ||
</Typography> | ||
<Stack> | ||
{helperText} | ||
<Select | ||
defaultValue={firewallsDropdownOptions[0]} | ||
errorText={error?.[0].reason} | ||
isClearable={false} | ||
isLoading={isLoading} | ||
label="Assign Firewall" | ||
noOptionsMessage={() => 'Create a Firewall to assign to this Linode.'} | ||
onChange={(selection) => handleFirewallChange(selection.value)} | ||
options={firewallsDropdownOptions} | ||
placeholder={''} | ||
/> | ||
<StyledCreateLink to={`${APP_ROOT}/firewalls/create`}> | ||
Create Firewall | ||
</StyledCreateLink> | ||
</Stack> | ||
</Paper> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Account } from '@linode/api-v4/lib'; | ||
import { APIError } from '@linode/api-v4/lib/types'; | ||
import * as React from 'react'; | ||
import { UseQueryResult } from 'react-query'; | ||
|
||
import { useAccount } from 'src/queries/account'; | ||
|
||
export interface WithAccountProps { | ||
account: UseQueryResult<Account, APIError[]>; | ||
} | ||
|
||
export const withAccount = <Props>( | ||
Component: React.ComponentType<Props & WithAccountProps> | ||
) => { | ||
return (props: Props) => { | ||
const account = useAccount(); | ||
|
||
return React.createElement(Component, { | ||
...props, | ||
account, | ||
}); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
APP_ROOT
is used to ensure the link opens up in a new tab (can't be done with a relative path without adding theexternal
prop which would be misleading)