-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [M3-6731] – Add VPC and Firewall sections in Linode Create flow (…
- Loading branch information
1 parent
df005bc
commit d642c62
Showing
20 changed files
with
904 additions
and
46 deletions.
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.