-
Notifications
You must be signed in to change notification settings - Fork 19
Add side modal heading #2533
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
Merged
Add side modal heading #2533
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 |
|---|---|---|
|
|
@@ -36,8 +36,10 @@ import { useVpcSelector } from '~/hooks/use-params' | |
| import { Badge } from '~/ui/lib/Badge' | ||
| import { toComboboxItems, type ComboboxItem } from '~/ui/lib/Combobox' | ||
| import { FormDivider } from '~/ui/lib/Divider' | ||
| import { FieldLabel } from '~/ui/lib/FieldLabel' | ||
| import { Message } from '~/ui/lib/Message' | ||
| import * as MiniTable from '~/ui/lib/MiniTable' | ||
| import { SideModal } from '~/ui/lib/SideModal' | ||
| import { TextInputHint } from '~/ui/lib/TextInput' | ||
| import { KEYS } from '~/ui/util/keys' | ||
| import { ALL_ISH } from '~/util/consts' | ||
|
|
@@ -415,46 +417,50 @@ export const CommonFields = ({ control, nameTaken, error }: CommonFieldsProps) = | |
|
|
||
| {/* Really this should be its own <form>, but you can't have a form inside a form, | ||
| so we just stick the submit handler in a button onClick */} | ||
| <div className="flex flex-col gap-3"> | ||
| <h3 className="mb-4 text-sans-2xl">Targets</h3> | ||
| <Message | ||
| variant="info" | ||
| content={ | ||
| <> | ||
| <SideModal.Heading>Targets</SideModal.Heading> | ||
|
|
||
| <Message | ||
| variant="info" | ||
| content={ | ||
| <> | ||
| <p> | ||
| Targets determine the instances to which this rule applies. You can target | ||
| instances directly by name, or specify a VPC, VPC subnet, IP, or IP subnet, | ||
| which will apply the rule to traffic going to all matching instances. Targets | ||
| are additive: the rule applies to instances matching{' '} | ||
| instances directly or specify a VPC, VPC subnet, IP, or IP subnet, which will | ||
| apply the rule to traffic going to all matching instances. | ||
| </p> | ||
| <p className="mt-2"> | ||
| Targets are additive: the rule applies to instances matching{' '} | ||
| <span className="underline">any</span> target. | ||
| </> | ||
| } | ||
| /> | ||
| <DynamicTypeAndValueFields | ||
| sectionType="target" | ||
| control={targetForm.control} | ||
| valueType={targetType} | ||
| items={toComboboxItems(targetItems[targetType])} | ||
| // HACK: reset the whole subform, keeping type (because we just set | ||
| // it). most importantly, this resets isSubmitted so the form can go | ||
| // back to validating on submit instead of change | ||
| onTypeChange={() => | ||
| targetForm.reset({ type: targetForm.getValues('type'), value: '' }) | ||
| } | ||
| onInputChange={(value) => targetForm.setValue('value', value)} | ||
| onSubmitTextField={submitTarget} | ||
| /> | ||
| <MiniTable.ClearAndAddButtons | ||
| addButtonCopy="Add target" | ||
| disableClear={!targetValue} | ||
| onClear={() => targetForm.reset()} | ||
| onSubmit={submitTarget} | ||
| /> | ||
| </div> | ||
| </p> | ||
| </> | ||
| } | ||
| /> | ||
|
|
||
| <DynamicTypeAndValueFields | ||
| sectionType="target" | ||
| control={targetForm.control} | ||
| valueType={targetType} | ||
| items={toComboboxItems(targetItems[targetType])} | ||
| // HACK: reset the whole subform, keeping type (because we just set | ||
| // it). most importantly, this resets isSubmitted so the form can go | ||
| // back to validating on submit instead of change | ||
| onTypeChange={() => | ||
| targetForm.reset({ type: targetForm.getValues('type'), value: '' }) | ||
| } | ||
| onInputChange={(value) => targetForm.setValue('value', value)} | ||
| onSubmitTextField={submitTarget} | ||
| /> | ||
| <MiniTable.ClearAndAddButtons | ||
| addButtonCopy="Add target" | ||
| disableClear={!targetValue} | ||
| onClear={() => targetForm.reset()} | ||
| onSubmit={submitTarget} | ||
| /> | ||
| {!!targets.value.length && <TypeAndValueTable sectionType="target" items={targets} />} | ||
|
|
||
| <FormDivider /> | ||
|
|
||
| <h3 className="mb-4 text-sans-2xl">Filters</h3> | ||
| <SideModal.Heading>Filters</SideModal.Heading> | ||
| <Message | ||
| variant="info" | ||
| content={ | ||
|
|
@@ -468,12 +474,12 @@ export const CommonFields = ({ control, nameTaken, error }: CommonFieldsProps) = | |
| /> | ||
|
|
||
| <div className="flex flex-col gap-3"> | ||
| {/* We have to blow this up instead of using TextField to get better | ||
| {/* We have to blow this up instead of using TextField to get better | ||
| text styling on the label */} | ||
| <div className="mt-2"> | ||
| <label id="portRange-label" htmlFor="portRange" className="text-sans-lg"> | ||
| <FieldLabel id="portRange-label" htmlFor="portRange"> | ||
| Port filters | ||
| </label> | ||
| </FieldLabel> | ||
| <TextInputHint id="portRange-help-text" className="mb-2"> | ||
| A single destination port (1234) or a range (1234–2345) | ||
| </TextInputHint> | ||
|
|
@@ -523,45 +529,47 @@ export const CommonFields = ({ control, nameTaken, error }: CommonFieldsProps) = | |
| )} | ||
|
|
||
| <fieldset className="space-y-0.5"> | ||
| <legend className="mb-2 mt-4 text-sans-lg">Protocol filters</legend> | ||
| {/* todo: abstract this label and checkbox pattern */} | ||
| <FieldLabel id="portRange-label" htmlFor="portRange" className="mb-2"> | ||
| Protocol filters | ||
| </FieldLabel> | ||
| <ProtocolField control={control} protocol="TCP" /> | ||
| <ProtocolField control={control} protocol="UDP" /> | ||
| <ProtocolField control={control} protocol="ICMP" /> | ||
| </fieldset> | ||
|
|
||
| <div className="flex flex-col gap-3"> | ||
|
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. This stuff is unnecessary because the overall thing already has the spacing, it also causes a bit of havok since the spacing here is different. |
||
| <h3 className="mt-4 text-sans-lg">Host filters</h3> | ||
| <Message | ||
| variant="info" | ||
| content={ | ||
| <> | ||
| Host filters match the “other end” of traffic from the | ||
| target’s perspective: for an inbound rule, they match the source of | ||
| traffic. For an outbound rule, they match the destination. | ||
| </> | ||
| } | ||
| /> | ||
| <DynamicTypeAndValueFields | ||
| sectionType="host" | ||
| control={hostForm.control} | ||
| valueType={hostType} | ||
| items={toComboboxItems(hostFilterItems[hostType])} | ||
| // HACK: reset the whole subform, keeping type (because we just set | ||
| // it). most importantly, this resets isSubmitted so the form can go | ||
| // back to validating on submit instead of change | ||
| onTypeChange={() => | ||
| hostForm.reset({ type: hostForm.getValues('type'), value: '' }) | ||
| } | ||
| onInputChange={(value) => hostForm.setValue('value', value)} | ||
| onSubmitTextField={submitHost} | ||
| /> | ||
| <MiniTable.ClearAndAddButtons | ||
| addButtonCopy="Add host filter" | ||
| disableClear={!hostValue} | ||
| onClear={() => hostForm.reset()} | ||
| onSubmit={submitHost} | ||
| /> | ||
| </div> | ||
| <FormDivider /> | ||
|
|
||
| <SideModal.Heading>Host filters</SideModal.Heading> | ||
|
|
||
| <Message | ||
| variant="info" | ||
| content={ | ||
| <> | ||
| Host filters match the “other end” of traffic from the | ||
| target’s perspective: for an inbound rule, they match the source of | ||
| traffic. For an outbound rule, they match the destination. | ||
| </> | ||
| } | ||
| /> | ||
| <DynamicTypeAndValueFields | ||
| sectionType="host" | ||
| control={hostForm.control} | ||
| valueType={hostType} | ||
| items={toComboboxItems(hostFilterItems[hostType])} | ||
| // HACK: reset the whole subform, keeping type (because we just set | ||
| // it). most importantly, this resets isSubmitted so the form can go | ||
| // back to validating on submit instead of change | ||
| onTypeChange={() => hostForm.reset({ type: hostForm.getValues('type'), value: '' })} | ||
| onInputChange={(value) => hostForm.setValue('value', value)} | ||
| onSubmitTextField={submitHost} | ||
| /> | ||
| <MiniTable.ClearAndAddButtons | ||
| addButtonCopy="Add host filter" | ||
| disableClear={!hostValue} | ||
| onClear={() => hostForm.reset()} | ||
| onSubmit={submitHost} | ||
| /> | ||
| {!!hosts.value.length && <TypeAndValueTable sectionType="host" items={hosts} />} | ||
|
|
||
| {error && ( | ||
|
|
||
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
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.
Uh oh!
There was an error while loading. Please reload this page.