-
Notifications
You must be signed in to change notification settings - Fork 399
fix: [M3-7262] - Create Firewall Drawer opens in the same tab in the Linode Create Flow #9785
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
Merged
tyler-akamai
merged 13 commits into
linode:develop
from
tyler-akamai:M3-7262-firewall-create-drawer-opens-in-same-tab
Oct 23, 2023
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
670386d
initial commit
TylerWJ bc1e043
resolved merge conflicts
TylerWJ 0b9b3a8
Added changeset: Firewall Create Drawer opens in the same tab in the β¦
TylerWJ d06ae5c
Added 'Additional Linodes (Optional)' to Firewall Drawer
TylerWJ 3118f7d
added unit test
TylerWJ a6c7d51
updated unit tests
TylerWJ bb627e8
addressed PR feedback
TylerWJ d268aa2
Merge remote-tracking branch 'upstream/develop' into M3-7262-firewallβ¦
TylerWJ 0120421
removed commented code
TylerWJ 577011b
addressed PR feedback
TylerWJ 836a827
improved selectedFirewall functionality
TylerWJ 7b41447
addressed feedback
TylerWJ da2cf0a
Merge remote-tracking branch 'upstream/develop' into M3-7262-firewallβ¦
TylerWJ 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
This file contains hidden or 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": Fixed | ||
| --- | ||
|
|
||
| Firewall Create Drawer opens in the same tab in the Linode Create Flow ([#9785](https://github.com/linode/manager/pull/9785)) | ||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,21 +1,35 @@ | ||
| import { Firewall } from '@linode/api-v4'; | ||
| 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 { CreateFirewallDrawer } from 'src/features/Firewalls/FirewallLanding/CreateFirewallDrawer'; | ||
| import { useFirewallsQuery } from 'src/queries/firewalls'; | ||
|
|
||
| import { StyledCreateLink } from '../../features/Linodes/LinodesCreate/LinodeCreate.styles'; | ||
| import { Autocomplete } from '../Autocomplete/Autocomplete'; | ||
| import { LinkButton } from '../LinkButton'; | ||
|
|
||
| interface Props { | ||
| handleFirewallChange: (firewallID: number) => void; | ||
| helperText: JSX.Element; | ||
| selectedFirewallId: number; | ||
| } | ||
|
|
||
| export const createFirewallLabel = 'Additional Linodes (Optional)'; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. UX wanted to ensure the user:
|
||
|
|
||
| export const SelectFirewallPanel = (props: Props) => { | ||
| const { handleFirewallChange, helperText } = props; | ||
| const { handleFirewallChange, helperText, selectedFirewallId } = props; | ||
|
|
||
| const [isDrawerOpen, setIsDrawerOpen] = React.useState(false); | ||
|
|
||
| const handleCreateFirewallClick = () => { | ||
| setIsDrawerOpen(true); | ||
| }; | ||
|
|
||
| const handleFirewallCreated = (firewall: Firewall) => { | ||
| handleFirewallChange(firewall.id); | ||
| }; | ||
|
|
||
| const { data: firewallsData, error, isLoading } = useFirewallsQuery(); | ||
|
|
||
|
|
@@ -25,10 +39,12 @@ export const SelectFirewallPanel = (props: Props) => { | |
| value: firewall.id, | ||
| })); | ||
|
|
||
| firewallsDropdownOptions.unshift({ | ||
| label: 'None', | ||
| value: -1, | ||
| }); | ||
| const selectedFirewall = | ||
| selectedFirewallId !== -1 | ||
| ? firewallsDropdownOptions.find( | ||
| (option) => option.value === selectedFirewallId | ||
| ) || null | ||
| : null; | ||
|
|
||
| return ( | ||
| <Paper | ||
|
|
@@ -43,20 +59,30 @@ export const SelectFirewallPanel = (props: Props) => { | |
| </Typography> | ||
| <Stack> | ||
| {helperText} | ||
| <Select | ||
| defaultValue={firewallsDropdownOptions[0]} | ||
| <Autocomplete | ||
| onChange={(_, selection) => { | ||
| handleFirewallChange(selection?.value ?? -1); | ||
| }} | ||
| 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)} | ||
| loading={isLoading} | ||
| noOptionsText="No Firewalls available" | ||
| options={firewallsDropdownOptions} | ||
| placeholder={''} | ||
| placeholder={'None'} | ||
| value={selectedFirewall} | ||
| /> | ||
| <StyledCreateLink to={`${APP_ROOT}/firewalls/create`}> | ||
| <LinkButton | ||
| onClick={handleCreateFirewallClick} | ||
| style={{ marginBottom: 16, marginTop: 12, textAlign: 'left' }} | ||
| > | ||
| Create Firewall | ||
| </StyledCreateLink> | ||
| </LinkButton> | ||
| <CreateFirewallDrawer | ||
| label={createFirewallLabel} | ||
| onClose={() => setIsDrawerOpen(false)} | ||
| onFirewallCreated={handleFirewallCreated} | ||
| open={isDrawerOpen} | ||
| /> | ||
| </Stack> | ||
| </Paper> | ||
| ); | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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
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.
Similar suggestion here with describing the thing that was fixed.