-
Notifications
You must be signed in to change notification settings - Fork 138
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
Changes from 5 commits
4897cdf
a387a6b
4b4d892
ccd80c2
7f2c252
7a11666
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,4 +5,6 @@ | |
|
|
||
| .root { | ||
| margin: -$spacing-03; | ||
| display: flex; | ||
| justify-content: flex-end; | ||
| } | ||
|
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. 🙌 |
| 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> | ||
| ); | ||
| } | ||
| 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 was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| /** | ||
| * Copyright 2025 © BeeAI a Series of LF Projects, LLC | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| .stack { | ||
| display: flex; | ||
| flex-direction: column; | ||
| row-gap: $spacing-05; | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.