-
Notifications
You must be signed in to change notification settings - Fork 137
feat(ui): add temporary ui for connectors #1702
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
6 commits
Select commit
Hold shift + click to select a range
4897cdf
refactor(ui): create a common TableViewWithSearch component
PetrBulanek a387a6b
refactor(ui): connectors api functions
PetrBulanek 4b4d892
feat(ui): add connectors modal
PetrBulanek ccd80c2
fixup! feat(ui): add connectors modal
PetrBulanek 7f2c252
fixup! fixup! feat(ui): add connectors modal
PetrBulanek 7a11666
fixup! fixup! fixup! feat(ui): add connectors modal
PetrBulanek 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 |
|---|---|---|
|
|
@@ -3,6 +3,6 @@ | |
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| .source { | ||
| .name { | ||
| overflow-wrap: anywhere; | ||
| } | ||
48 changes: 48 additions & 0 deletions
48
apps/agentstack-ui/src/components/DeleteButton/DeleteButton.tsx
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,48 @@ | ||
| /** | ||
| * Copyright 2025 © BeeAI a Series of LF Projects, LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { TrashCan } from '@carbon/icons-react'; | ||
| import { IconButton } from '@carbon/react'; | ||
|
|
||
| import { Spinner } from '#components/Spinner/Spinner.tsx'; | ||
| import { useModal } from '#contexts/Modal/index.tsx'; | ||
|
|
||
| import classes from './DeleteButton.module.scss'; | ||
|
|
||
| interface Props { | ||
| entityName: string; | ||
| entityLabel: string; | ||
| isPending: boolean; | ||
| onSubmit: () => void; | ||
| } | ||
|
|
||
| export function DeleteButton({ entityName, entityLabel, isPending, onSubmit }: Props) { | ||
| const { openConfirmation } = useModal(); | ||
|
|
||
| return ( | ||
| <IconButton | ||
| label="Delete" | ||
| kind="ghost" | ||
| size="sm" | ||
| align="left" | ||
| onClick={() => | ||
| openConfirmation({ | ||
| title: ( | ||
| <> | ||
| Delete <span className={classes.name}>{entityName}</span>? | ||
| </> | ||
| ), | ||
| body: `Are you sure you want to delete this ${entityLabel}? It can’t be undone.`, | ||
| primaryButtonText: 'Delete', | ||
| danger: true, | ||
| onSubmit, | ||
| }) | ||
| } | ||
| disabled={isPending} | ||
| > | ||
| {isPending ? <Spinner center /> : <TrashCan />} | ||
| </IconButton> | ||
| ); | ||
| } |
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 |
|---|---|---|
|
|
@@ -5,4 +5,6 @@ | |
|
|
||
| .root { | ||
| margin: -$spacing-03; | ||
| display: flex; | ||
| justify-content: flex-end; | ||
| } | ||
99 changes: 99 additions & 0 deletions
99
apps/agentstack-ui/src/components/TableView/TableViewWithSearch.tsx
|
Contributor
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 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,99 @@ | ||
| /** | ||
| * Copyright 2025 © BeeAI a Series of LF Projects, LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import type { DataTableHeader } from '@carbon/react'; | ||
| import { | ||
| DataTable, | ||
| DataTableSkeleton, | ||
| Table, | ||
| TableBody, | ||
| TableCell, | ||
| TableHead, | ||
| TableHeader, | ||
| TableRow, | ||
| } from '@carbon/react'; | ||
| import type { ReactNode } from 'react'; | ||
|
|
||
| import { useTableSearch } from '#hooks/useTableSearch.ts'; | ||
|
|
||
| import { TableView } from './TableView.tsx'; | ||
| import { TableViewToolbar } from './TableViewToolbar.tsx'; | ||
|
|
||
| interface Props<T> { | ||
| headers: (DataTableHeader & { className?: string })[]; | ||
| entries: T[]; | ||
| searchFields: (keyof T)[]; | ||
| toolbarButton: ReactNode; | ||
| isPending: boolean; | ||
| description?: string; | ||
| emptyText?: ReactNode; | ||
| className?: string; | ||
| } | ||
|
|
||
| export function TableViewWithSearch<T extends { id: string }>({ | ||
PetrBulanek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| headers, | ||
| entries, | ||
| searchFields, | ||
| toolbarButton, | ||
| isPending, | ||
| description, | ||
| emptyText = 'No results found.', | ||
| className, | ||
| }: Props<T>) { | ||
| const { items: rows, onSearch } = useTableSearch({ entries, fields: searchFields }); | ||
|
|
||
| const columnCount = headers.length; | ||
| const hasRows = rows.length > 0; | ||
|
|
||
| return ( | ||
| <TableView description={description} className={className}> | ||
| <DataTable headers={headers} rows={rows}> | ||
| {({ rows, getTableProps, getHeaderProps, getRowProps }) => ( | ||
| <> | ||
| <TableViewToolbar searchProps={{ onChange: onSearch, disabled: isPending }} button={toolbarButton} /> | ||
|
|
||
| {isPending ? ( | ||
| <DataTableSkeleton headers={headers} columnCount={columnCount} showToolbar={false} showHeader={false} /> | ||
| ) : ( | ||
| <Table {...getTableProps()}> | ||
| <TableHead> | ||
| <TableRow> | ||
| {headers.map((header) => ( | ||
| <TableHeader {...getHeaderProps({ header })} key={header.key} className={header.className}> | ||
| {header.header} | ||
| </TableHeader> | ||
| ))} | ||
| </TableRow> | ||
| </TableHead> | ||
|
|
||
| <TableBody> | ||
| {hasRows ? ( | ||
| rows.map((row) => ( | ||
| <TableRow {...getRowProps({ row })} key={row.id}> | ||
| {row.cells.map((cell) => { | ||
| const header = headers.find(({ key }) => key === cell.info.header); | ||
|
|
||
| return ( | ||
| <TableCell key={cell.id} className={header?.className}> | ||
| {cell.value} | ||
| </TableCell> | ||
| ); | ||
| })} | ||
| </TableRow> | ||
| )) | ||
| ) : ( | ||
| <TableRow> | ||
| <TableCell colSpan={columnCount}>{emptyText}</TableCell> | ||
| </TableRow> | ||
| )} | ||
| </TableBody> | ||
| </Table> | ||
| )} | ||
| </> | ||
| )} | ||
| </DataTable> | ||
| </TableView> | ||
| ); | ||
| } | ||
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,70 +7,42 @@ import { api } from '#api/index.ts'; | |
| import { ensureData } from '#api/utils.ts'; | ||
| import { BASE_URL } from '#utils/constants.ts'; | ||
|
|
||
| import type { CreateConnectorRequest, ListConnectorsResponse } from './types'; | ||
| import type { | ||
| ConnectConnectorPath, | ||
| CreateConnectorRequest, | ||
| DeleteConnectorPath, | ||
| DisconnectConnectorPath, | ||
| } from './types'; | ||
|
|
||
| export async function createConnector(body: CreateConnectorRequest) { | ||
| const response = await api.POST('/api/v1/connectors', { body }); | ||
| return ensureData(response); | ||
| } | ||
|
|
||
| export async function deleteConnector(connectorId: string) { | ||
| const response = await api.DELETE('/api/v1/connectors/{connector_id}', { | ||
| params: { path: { connector_id: connectorId } }, | ||
| }); | ||
| return ensureData(response); | ||
| } | ||
|
|
||
| export async function disconnectConnector(connectorId: string) { | ||
| const response = await api.POST('/api/v1/connectors/{connector_id}/disconnect', { | ||
| params: { path: { connector_id: connectorId } }, | ||
| }); | ||
| return ensureData(response); | ||
| } | ||
|
|
||
| export async function connectConnector(connectorId: string) { | ||
| export async function connectConnector(path: ConnectConnectorPath) { | ||
| const response = await api.POST('/api/v1/connectors/{connector_id}/connect', { | ||
| params: { path: { connector_id: connectorId } }, | ||
| body: { | ||
| redirect_url: `${BASE_URL}/oauth-callback`, | ||
| }, | ||
| params: { path }, | ||
| body: { redirect_url: `${BASE_URL}/oauth-callback` }, | ||
| }); | ||
PetrBulanek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return ensureData(response) as AuthRequired; | ||
| return ensureData(response); | ||
| } | ||
|
|
||
| interface AuthRequired { | ||
| id: string; | ||
| url: string; | ||
| state: 'auth_required'; | ||
| auth_request: { | ||
| authorization_endpoint: string; | ||
| type: string; | ||
| }; | ||
| } | ||
| export async function disconnectConnector(path: DisconnectConnectorPath) { | ||
| const response = await api.POST('/api/v1/connectors/{connector_id}/disconnect', { params: { path } }); | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| interface Connected { | ||
| id: string; | ||
| url: string; | ||
| state: 'connected'; | ||
| return ensureData(response); | ||
| } | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| interface Disconnected { | ||
| id: string; | ||
| url: string; | ||
| state: 'disconnected'; | ||
| } | ||
| export async function deleteConnector(path: DeleteConnectorPath) { | ||
| const response = await api.DELETE('/api/v1/connectors/{connector_id}', { params: { path } }); | ||
|
Contributor
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. I think we want to implement all api calls in the SDK and use them from there from now on. But we can leave that for #1692 . |
||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| interface Created { | ||
| id: string; | ||
| url: string; | ||
| state: 'created'; | ||
| return ensureData(response); | ||
| } | ||
|
|
||
| export async function listConnectors(): Promise<ListConnectorsResponse | undefined> { | ||
| const response = await api.GET('/api/v1/connectors', {}); | ||
| export async function listConnectors() { | ||
| const response = await api.GET('/api/v1/connectors'); | ||
|
|
||
| return ensureData(response); | ||
| } | ||
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
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.