-
Notifications
You must be signed in to change notification settings - Fork 20
Internet gateways modal tweak #2607
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
david-crespo
merged 1 commit into
internet-gateways-2
from
internet-gateways-modal-tweak
Dec 6, 2024
Merged
Changes from all commits
Commits
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
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 |
|---|---|---|
|
|
@@ -7,18 +7,23 @@ | |
| */ | ||
|
|
||
| import { useQuery } from '@tanstack/react-query' | ||
| import { useForm } from 'react-hook-form' | ||
| import { useNavigate, type LoaderFunctionArgs } from 'react-router-dom' | ||
|
|
||
| import { Gateway16Icon } from '@oxide/design-system/icons/react' | ||
|
|
||
| import { apiQueryClient, getListQFn, queryClient, usePrefetchedApiQuery } from '~/api' | ||
| import { SideModalForm } from '~/components/form/SideModalForm' | ||
| import { getInternetGatewaySelector, useInternetGatewaySelector } from '~/hooks/use-params' | ||
| import { DescriptionCell } from '~/table/cells/DescriptionCell' | ||
| import { EmptyCell } from '~/table/cells/EmptyCell' | ||
| import { IpPoolCell } from '~/table/cells/IpPoolCell' | ||
| import { Button } from '~/ui/lib/Button' | ||
| import { CopyableIp } from '~/ui/lib/CopyableIp' | ||
| import { LinkCell } from '~/table/cells/LinkCell' | ||
| import { FormDivider } from '~/ui/lib/Divider' | ||
| import { Message } from '~/ui/lib/Message' | ||
| import { PropertiesTable } from '~/ui/lib/PropertiesTable' | ||
| import { SideModal } from '~/ui/lib/SideModal' | ||
| import { ResourceLabel, SideModal } from '~/ui/lib/SideModal' | ||
| import { Table } from '~/ui/lib/Table' | ||
| import { Truncate } from '~/ui/lib/Truncate' | ||
| import { pb } from '~/util/path-builder' | ||
|
|
||
| type GatewayParams = { project: string; vpc: string; gateway: string } | ||
|
|
@@ -57,84 +62,96 @@ export function EditInternetGatewayForm() { | |
| gatewayIpAddressList({ project, vpc, gateway }).optionsFn() | ||
| ) | ||
|
|
||
| const form = useForm({}) | ||
|
|
||
| return ( | ||
| <SideModal title={internetGateway.name} onDismiss={onDismiss} isOpen> | ||
| <SideModal.Body> | ||
| <div className="flex flex-col gap-6"> | ||
| <Message | ||
| variant="info" | ||
| className="text-balance" | ||
| content={ | ||
| <> | ||
| This is a read-only copy of this internet gateway. Use the CLI to create and | ||
| update internet gateways. More functionality for internet gateways will be | ||
| included in future releases of the Oxide console. | ||
| </> | ||
| } | ||
| /> | ||
| <PropertiesTable key={internetGateway.id}> | ||
| <PropertiesTable.Row label="Name">{internetGateway.name}</PropertiesTable.Row> | ||
| <PropertiesTable.Row label="Description"> | ||
| <DescriptionCell text={internetGateway.description} /> | ||
| </PropertiesTable.Row> | ||
| {/* insert routes that are associated with this gateway */} | ||
| </PropertiesTable> | ||
| <div> | ||
| <SideModal.Heading title="Internet Gateway" className="mb-2"> | ||
| Internet Gateway IP Address | ||
| </SideModal.Heading> | ||
| <div className="flex flex-col gap-4"> | ||
| {gatewayIpAddresses ? ( | ||
| gatewayIpAddresses.map((gatewayAddress) => ( | ||
| <PropertiesTable key={gatewayAddress.id}> | ||
| <PropertiesTable.Row label="Name"> | ||
| {gatewayAddress.name} | ||
| </PropertiesTable.Row> | ||
| <PropertiesTable.Row label="Description"> | ||
| <DescriptionCell text={gatewayAddress.description} /> | ||
| </PropertiesTable.Row> | ||
| <PropertiesTable.Row label="IP Address"> | ||
| <CopyableIp ip={gatewayAddress.address} /> | ||
| </PropertiesTable.Row> | ||
| </PropertiesTable> | ||
| )) | ||
| ) : ( | ||
| <EmptyCell /> | ||
| )} | ||
| </div> | ||
| </div> | ||
| <div> | ||
| <SideModal.Heading title="Internet Gateway" className="mb-2"> | ||
| Internet Gateway IP Pool | ||
| {gatewayIpPools && gatewayIpPools.length > 1 ? 's' : ''} | ||
| </SideModal.Heading> | ||
| <div className="flex flex-col gap-4"> | ||
| {gatewayIpPools ? ( | ||
| gatewayIpPools.map((gatewayPool) => ( | ||
| <PropertiesTable key={gatewayPool.id}> | ||
| <PropertiesTable.Row label="Name"> | ||
| {gatewayPool.name} | ||
| </PropertiesTable.Row> | ||
| <PropertiesTable.Row label="Description"> | ||
| <DescriptionCell text={gatewayPool.description} /> | ||
| </PropertiesTable.Row> | ||
| <PropertiesTable.Row label="IP Pool"> | ||
| <IpPoolCell ipPoolId={gatewayPool.ipPoolId} /> | ||
| </PropertiesTable.Row> | ||
| </PropertiesTable> | ||
| )) | ||
| ) : ( | ||
| <EmptyCell /> | ||
| )} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </SideModal.Body> | ||
| <SideModal.Footer> | ||
| <Button variant="ghost" onClick={onDismiss}> | ||
| Close | ||
| </Button> | ||
| </SideModal.Footer> | ||
| </SideModal> | ||
| <SideModalForm | ||
| title="Internet Gateway" | ||
| formType="edit" | ||
| resourceName="Internet Gateway" | ||
| onDismiss={onDismiss} | ||
| subtitle={ | ||
| <ResourceLabel> | ||
| <Gateway16Icon /> {internetGateway.name} | ||
| </ResourceLabel> | ||
| } | ||
| form={form} | ||
| // TODO: pass actual error when this form is hooked up | ||
| submitError={null} | ||
| loading={false} | ||
| > | ||
| <PropertiesTable key={internetGateway.id}> | ||
| <PropertiesTable.Row label="Name">{internetGateway.name}</PropertiesTable.Row> | ||
| <PropertiesTable.Row label="Description"> | ||
| <DescriptionCell text={internetGateway.description} /> | ||
| </PropertiesTable.Row> | ||
| </PropertiesTable> | ||
| <Message | ||
| variant="info" | ||
| className="text-balance" | ||
| content={ | ||
| <> | ||
| This is a read-only copy of this internet gateway. Use the CLI to create and | ||
| update internet gateways. More functionality for internet gateways will be | ||
| included in future releases of the Oxide console. | ||
| </> | ||
| } | ||
| /> | ||
| <FormDivider /> | ||
| <SideModal.Heading title="Internet Gateway">IP Addresses</SideModal.Heading> | ||
|
|
||
| {gatewayIpAddresses ? ( | ||
| <Table aria-label="Port filters"> | ||
| <Table.Header> | ||
| <Table.HeadCell>Name</Table.HeadCell> | ||
| <Table.HeadCell>Address</Table.HeadCell> | ||
| </Table.Header> | ||
| <Table.Body> | ||
| {gatewayIpAddresses.map((gatewayIpAddress) => ( | ||
| <Table.Row key={gatewayIpAddress.id}> | ||
| <Table.Cell className="w-1/2"> | ||
| <Truncate text={gatewayIpAddress.name} maxLength={24} /> | ||
| </Table.Cell> | ||
| <Table.Cell className="w-1/2"> | ||
| <Truncate text={gatewayIpAddress.address} maxLength={24} /> | ||
| </Table.Cell> | ||
| </Table.Row> | ||
| ))} | ||
| </Table.Body> | ||
| </Table> | ||
| ) : ( | ||
| <EmptyCell /> | ||
| )} | ||
| <FormDivider /> | ||
|
|
||
| <SideModal.Heading title="Internet Gateway">IP Pools</SideModal.Heading> | ||
|
|
||
| {gatewayIpPools ? ( | ||
| <Table aria-label="Port filters"> | ||
| <Table.Header> | ||
| <Table.HeadCell>Name</Table.HeadCell> | ||
| <Table.HeadCell>Description</Table.HeadCell> | ||
| </Table.Header> | ||
| <Table.Body> | ||
| {gatewayIpPools.map((gatewayIpPool) => ( | ||
| <Table.Row key={gatewayIpPool.id}> | ||
| <Table.Cell className="w-1/2"> | ||
| <LinkCell to={pb.ipPool({ pool: gatewayIpPool.name })}> | ||
| <Truncate text={gatewayIpPool.name} maxLength={24} /> | ||
| </LinkCell> | ||
| </Table.Cell> | ||
| <Table.Cell className="w-1/2"> | ||
| <Truncate text={gatewayIpPool.description} maxLength={24} /> | ||
| </Table.Cell> | ||
| </Table.Row> | ||
| ))} | ||
| </Table.Body> | ||
| </Table> | ||
| ) : ( | ||
| <EmptyCell /> | ||
|
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. Need to add a proper empty state |
||
| )} | ||
|
|
||
| {/* insert routes that are associated with this gateway */} | ||
| </SideModalForm> | ||
| ) | ||
| } | ||
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.
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.
Could get rid of this and let the table be scrollable, but I think we need an action col on the end to stop it looking funky