-
Notifications
You must be signed in to change notification settings - Fork 73
feat: add read-only Gateway TUI #1956
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
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
02b2608
feat: add read-only Gateway TUI
aidandaly24 5c05742
test: cover non-Connector Gateway route
aidandaly24 7be3607
fix(gateway): align read-only TUI with command routes
aidandaly24 dd5bc0b
refactor(gateway): extract scoped resource pickers
aidandaly24 c27f00f
refactor(gateway): centralize connector reads in core
aidandaly24 956f488
refactor(gateway): align TUI menus and tests
aidandaly24 827fdfa
refactor(gateway): use shared TUI support
aidandaly24 81e2b4a
fix(gateway): fill connector pages
aidandaly24 24f49f8
fix(gateway): bound connector pagination
aidandaly24 9d530a5
test(gateway): assert TUI command support
aidandaly24 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 |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import type { TargetSummary } from "@aws-sdk/client-bedrock-agentcore-control"; | ||
| import { useNavigate } from "react-router"; | ||
| import type { ScreenProps } from "../handlers/types"; | ||
| import { coreOptsFromCtx } from "../handlers/utils"; | ||
| import { formatTimestamp } from "./formatTimestamp"; | ||
| import { PaginatedTablePicker } from "./PaginatedTablePicker"; | ||
| import type { DataTableColumn } from "./ui/data-table"; | ||
|
|
||
| interface GatewayConnectorRow extends Record<string, unknown> { | ||
| targetId: string; | ||
| name: string; | ||
| status: string; | ||
| updatedAt: string; | ||
| } | ||
|
|
||
| export const gatewayConnectorColumns = [ | ||
| { key: "name", header: "name", flex: true }, | ||
| { key: "status", header: "status", width: 18 }, | ||
| { | ||
| key: "updatedAt", | ||
| header: "updated UTC", | ||
| width: 16, | ||
| render: formatTimestamp, | ||
| }, | ||
| ] satisfies DataTableColumn<GatewayConnectorRow>[]; | ||
|
|
||
| function toRow(target: TargetSummary): GatewayConnectorRow { | ||
| return { | ||
| targetId: target.targetId ?? "", | ||
| name: target.name ?? target.targetId ?? "", | ||
| status: target.status ?? "-", | ||
| updatedAt: target.updatedAt?.toISOString() ?? "-", | ||
| }; | ||
| } | ||
|
|
||
| export interface GatewayConnectorPickerProps extends ScreenProps { | ||
| gatewayId: string; | ||
| breadcrumb: string[]; | ||
| description?: string; | ||
| onSelect: (targetId: string) => void; | ||
| } | ||
|
|
||
| export function GatewayConnectorPicker({ | ||
| ctx, | ||
| core, | ||
| gatewayId, | ||
| breadcrumb, | ||
| description, | ||
| onSelect, | ||
| }: GatewayConnectorPickerProps) { | ||
| const opts = coreOptsFromCtx(ctx); | ||
| const navigate = useNavigate(); | ||
|
|
||
| return ( | ||
| <PaginatedTablePicker | ||
| breadcrumb={breadcrumb} | ||
| description={description} | ||
| queryKey={["gateway-connectors", opts.region, gatewayId]} | ||
| loadPage={async (token, pageSize) => { | ||
| const response = await core.gateway.listGatewayConnectors(gatewayId, token, pageSize, opts); | ||
| return { | ||
| items: response.items ?? [], | ||
| nextToken: response.nextToken, | ||
| }; | ||
| }} | ||
| toRow={toRow} | ||
| columns={gatewayConnectorColumns} | ||
| getValue={(row) => row.targetId} | ||
| onSelect={onSelect} | ||
| onBack={() => navigate(-1)} | ||
| loadingMessage={`Loading Connectors for Gateway ${gatewayId}…`} | ||
| errorMessage={(error) => | ||
| `Error loading Connectors for Gateway ${gatewayId}: ${error.message}` | ||
| } | ||
| emptyMessage="This Gateway has no Connectors." | ||
| emptyPageMessage="No Connectors on this page." | ||
| /> | ||
| ); | ||
| } |
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,81 @@ | ||
| import type { GatewaySummary } from "@aws-sdk/client-bedrock-agentcore-control"; | ||
| import { useNavigate } from "react-router"; | ||
| import type { ScreenProps } from "../handlers/types"; | ||
| import { coreOptsFromCtx } from "../handlers/utils"; | ||
| import { formatTimestamp } from "./formatTimestamp"; | ||
| import { PaginatedTablePicker } from "./PaginatedTablePicker"; | ||
| import type { DataTableColumn } from "./ui/data-table"; | ||
|
|
||
| interface GatewayRow extends Record<string, unknown> { | ||
| gatewayId: string; | ||
| name: string; | ||
| status: string; | ||
| protocol: string; | ||
| authorizer: string; | ||
| updatedAt: string; | ||
| } | ||
|
|
||
| export const gatewayColumns = [ | ||
| { key: "name", header: "name", flex: true }, | ||
| { key: "status", header: "status", width: 16 }, | ||
| { key: "protocol", header: "protocol", width: 12 }, | ||
| { key: "authorizer", header: "authorizer", width: 18 }, | ||
| { | ||
| key: "updatedAt", | ||
| header: "updated UTC", | ||
| width: 16, | ||
| render: formatTimestamp, | ||
| }, | ||
| ] satisfies DataTableColumn<GatewayRow>[]; | ||
|
|
||
| function toRow(gateway: GatewaySummary): GatewayRow { | ||
| return { | ||
| gatewayId: gateway.gatewayId ?? "", | ||
| name: gateway.name ?? gateway.gatewayId ?? "", | ||
| status: gateway.status ?? "-", | ||
| protocol: gateway.protocolType ?? "unrestricted", | ||
| authorizer: gateway.authorizerType ?? "-", | ||
| updatedAt: gateway.updatedAt?.toISOString() ?? "-", | ||
| }; | ||
| } | ||
|
|
||
| export interface GatewayPickerProps extends ScreenProps { | ||
| breadcrumb: string[]; | ||
| description?: string; | ||
| onSelect: (gatewayId: string) => void; | ||
| } | ||
|
|
||
| export function GatewayPicker({ | ||
| ctx, | ||
| core, | ||
| breadcrumb, | ||
| description, | ||
| onSelect, | ||
| }: GatewayPickerProps) { | ||
| const opts = coreOptsFromCtx(ctx); | ||
| const navigate = useNavigate(); | ||
|
|
||
| return ( | ||
| <PaginatedTablePicker | ||
| breadcrumb={breadcrumb} | ||
| description={description} | ||
| queryKey={["gateways", opts.region]} | ||
| loadPage={async (token, pageSize) => { | ||
| const response = await core.gateway.listGateways(token, pageSize, opts); | ||
| return { | ||
| items: response.items ?? [], | ||
| nextToken: response.nextToken, | ||
| }; | ||
| }} | ||
| toRow={toRow} | ||
| columns={gatewayColumns} | ||
| getValue={(row) => row.gatewayId} | ||
| onSelect={onSelect} | ||
| onBack={() => navigate("/" + breadcrumb.slice(0, -1).join("/"))} | ||
| loadingMessage="Loading Gateways…" | ||
| errorMessage={(error) => `Error: ${error.message}`} | ||
| emptyMessage="No Gateways found in this Region." | ||
| emptyPageMessage="No Gateways on this page." | ||
| /> | ||
| ); | ||
| } |
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,77 @@ | ||
| import type { GatewayRuleDetail } from "@aws-sdk/client-bedrock-agentcore-control"; | ||
| import { useNavigate } from "react-router"; | ||
| import type { ScreenProps } from "../handlers/types"; | ||
| import { coreOptsFromCtx } from "../handlers/utils"; | ||
| import { PaginatedTablePicker } from "./PaginatedTablePicker"; | ||
| import type { DataTableColumn } from "./ui/data-table"; | ||
|
|
||
| interface GatewayRuleRow extends Record<string, unknown> { | ||
| ruleId: string; | ||
| priority: string; | ||
| status: string; | ||
| description: string; | ||
| } | ||
|
|
||
| export const gatewayRuleColumns = [ | ||
| { key: "priority", header: "priority", width: 10 }, | ||
| { key: "status", header: "status", width: 13 }, | ||
| { key: "description", header: "description", flex: true }, | ||
| { | ||
| key: "ruleId", | ||
| header: "id suffix", | ||
| width: 10, | ||
| render: (value: unknown) => String(value ?? "").slice(-8), | ||
| }, | ||
| ] satisfies DataTableColumn<GatewayRuleRow>[]; | ||
|
|
||
| function toRow(rule: GatewayRuleDetail): GatewayRuleRow { | ||
| return { | ||
| ruleId: rule.ruleId ?? "", | ||
| priority: rule.priority?.toString() ?? "-", | ||
| status: rule.status ?? "-", | ||
| description: rule.description ?? "-", | ||
| }; | ||
| } | ||
|
|
||
| export interface GatewayRulePickerProps extends ScreenProps { | ||
| gatewayId: string; | ||
| breadcrumb: string[]; | ||
| description?: string; | ||
| onSelect: (ruleId: string) => void; | ||
| } | ||
|
|
||
| export function GatewayRulePicker({ | ||
| ctx, | ||
| core, | ||
| gatewayId, | ||
| breadcrumb, | ||
| description, | ||
| onSelect, | ||
| }: GatewayRulePickerProps) { | ||
| const opts = coreOptsFromCtx(ctx); | ||
| const navigate = useNavigate(); | ||
|
|
||
| return ( | ||
| <PaginatedTablePicker | ||
| breadcrumb={breadcrumb} | ||
| description={description} | ||
| queryKey={["gateway-rules", opts.region, gatewayId]} | ||
| loadPage={async (token, pageSize) => { | ||
| const response = await core.gateway.listGatewayRules(gatewayId, token, pageSize, opts); | ||
| return { | ||
| items: response.gatewayRules ?? [], | ||
| nextToken: response.nextToken, | ||
| }; | ||
| }} | ||
| toRow={toRow} | ||
| columns={gatewayRuleColumns} | ||
| getValue={(row) => row.ruleId} | ||
| onSelect={onSelect} | ||
| onBack={() => navigate(-1)} | ||
| loadingMessage={`Loading Rules for Gateway ${gatewayId}…`} | ||
| errorMessage={(error) => `Error loading Rules for Gateway ${gatewayId}: ${error.message}`} | ||
| emptyMessage="This Gateway has no Rules." | ||
| emptyPageMessage={`No Rules on this page for Gateway ${gatewayId}.`} | ||
| /> | ||
| ); | ||
| } | ||
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,80 @@ | ||
| import type { TargetSummary } from "@aws-sdk/client-bedrock-agentcore-control"; | ||
| import { useNavigate } from "react-router"; | ||
| import type { ScreenProps } from "../handlers/types"; | ||
| import { coreOptsFromCtx } from "../handlers/utils"; | ||
| import { formatTimestamp } from "./formatTimestamp"; | ||
| import { PaginatedTablePicker } from "./PaginatedTablePicker"; | ||
| import type { DataTableColumn } from "./ui/data-table"; | ||
|
|
||
| interface GatewayTargetRow extends Record<string, unknown> { | ||
| targetId: string; | ||
| name: string; | ||
| type: string; | ||
| status: string; | ||
| updatedAt: string; | ||
| } | ||
|
|
||
| export const gatewayTargetColumns = [ | ||
| { key: "name", header: "name", flex: true }, | ||
| { key: "type", header: "type", width: 18 }, | ||
| { key: "status", header: "status", width: 18 }, | ||
| { | ||
| key: "updatedAt", | ||
| header: "updated UTC", | ||
| width: 16, | ||
| render: formatTimestamp, | ||
| }, | ||
| ] satisfies DataTableColumn<GatewayTargetRow>[]; | ||
|
|
||
| function toRow(target: TargetSummary): GatewayTargetRow { | ||
| return { | ||
| targetId: target.targetId ?? "", | ||
| name: target.name ?? target.targetId ?? "", | ||
| type: target.targetType ?? "-", | ||
| status: target.status ?? "-", | ||
| updatedAt: target.updatedAt?.toISOString() ?? "-", | ||
| }; | ||
| } | ||
|
|
||
| export interface GatewayTargetPickerProps extends ScreenProps { | ||
| gatewayId: string; | ||
| breadcrumb: string[]; | ||
| description?: string; | ||
| onSelect: (targetId: string) => void; | ||
| } | ||
|
|
||
| export function GatewayTargetPicker({ | ||
| ctx, | ||
| core, | ||
| gatewayId, | ||
| breadcrumb, | ||
| description, | ||
| onSelect, | ||
| }: GatewayTargetPickerProps) { | ||
| const opts = coreOptsFromCtx(ctx); | ||
| const navigate = useNavigate(); | ||
|
|
||
| return ( | ||
| <PaginatedTablePicker | ||
| breadcrumb={breadcrumb} | ||
| description={description} | ||
| queryKey={["gateway-targets", opts.region, gatewayId]} | ||
| loadPage={async (token, pageSize) => { | ||
| const response = await core.gateway.listGatewayTargets(gatewayId, token, pageSize, opts); | ||
| return { | ||
| items: response.items ?? [], | ||
| nextToken: response.nextToken, | ||
| }; | ||
| }} | ||
| toRow={toRow} | ||
| columns={gatewayTargetColumns} | ||
| getValue={(row) => row.targetId} | ||
| onSelect={onSelect} | ||
| onBack={() => navigate(-1)} | ||
| loadingMessage={`Loading Targets for Gateway ${gatewayId}…`} | ||
| errorMessage={(error) => `Error loading Targets for Gateway ${gatewayId}: ${error.message}`} | ||
| emptyMessage="This Gateway has no Targets." | ||
| emptyPageMessage={`No Targets on this page for Gateway ${gatewayId}.`} | ||
| /> | ||
| ); | ||
| } |
Oops, something went wrong.
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.
wow, all these common components make this so easy to read!