2024-08-02 17:23:27 +02:00
|
|
|
import {Card, Divider, Popconfirm, Table, theme} from "antd";
|
2024-07-29 19:37:17 +02:00
|
|
|
import {t} from "ttag";
|
|
|
|
|
import {DeleteFilled} from "@ant-design/icons";
|
|
|
|
|
import React from "react";
|
|
|
|
|
import {Connector, deleteConnector} from "../../utils/api/connectors";
|
2024-08-02 17:23:27 +02:00
|
|
|
import useBreakpoint from "../../hooks/useBreakpoint";
|
2024-07-29 19:37:17 +02:00
|
|
|
|
2024-08-02 16:17:55 +02:00
|
|
|
const {useToken} = theme;
|
|
|
|
|
|
|
|
|
|
|
2024-07-29 19:37:17 +02:00
|
|
|
type ConnectorElement = Connector & { id: string }
|
|
|
|
|
|
|
|
|
|
export function ConnectorsList({connectors, onDelete}: { connectors: ConnectorElement[], onDelete: () => void }) {
|
2024-08-02 16:17:55 +02:00
|
|
|
const {token} = useToken()
|
2024-08-02 17:23:27 +02:00
|
|
|
const sm = useBreakpoint('sm')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const columns = [
|
|
|
|
|
{
|
|
|
|
|
title: t`Provider`,
|
|
|
|
|
dataIndex: 'provider'
|
|
|
|
|
}
|
|
|
|
|
]
|
2024-08-02 16:17:55 +02:00
|
|
|
|
2024-07-29 19:37:17 +02:00
|
|
|
return <>
|
|
|
|
|
{connectors.map(connector =>
|
|
|
|
|
<>
|
2024-08-02 17:23:27 +02:00
|
|
|
<Card title={t`Connector`}
|
|
|
|
|
size='small'
|
|
|
|
|
extra={<Popconfirm title={t`Delete the Connector`}
|
|
|
|
|
description={t`Are you sure to delete this Connector?`}
|
|
|
|
|
onConfirm={() => deleteConnector(connector.id).then(onDelete)}
|
|
|
|
|
okText={t`Yes`}
|
|
|
|
|
cancelText={t`No`}
|
|
|
|
|
><DeleteFilled style={{color: token.colorError}}/></Popconfirm>}>
|
|
|
|
|
<Card.Meta description={connector.id} style={{marginBottom: '1em'}}/>
|
|
|
|
|
<Table
|
|
|
|
|
columns={columns}
|
|
|
|
|
pagination={false}
|
|
|
|
|
dataSource={[
|
|
|
|
|
{
|
|
|
|
|
provider: connector.provider
|
|
|
|
|
}
|
|
|
|
|
]}
|
|
|
|
|
{...(sm ? {scroll: {y: 'max-content'}} : {scroll: {y: 240}})}
|
|
|
|
|
/>
|
2024-07-29 19:37:17 +02:00
|
|
|
</Card>
|
|
|
|
|
<Divider/>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
|
|
|
|
}
|