fix: explicit error message on connector delete

This commit is contained in:
Maël Gangloff 2024-08-20 13:23:50 +02:00
parent d7232dad62
commit 92106a15a2
No known key found for this signature in database
GPG Key ID: 11FDC81C24A7F629
2 changed files with 19 additions and 7 deletions

View File

@ -1,4 +1,4 @@
import {Card, Divider, Popconfirm, theme, Typography} from "antd"; import {Card, Divider, message, Popconfirm, theme, Typography} from "antd";
import {t} from "ttag"; import {t} from "ttag";
import {DeleteFilled} from "@ant-design/icons"; import {DeleteFilled} from "@ant-design/icons";
import React from "react"; import React from "react";
@ -11,17 +11,23 @@ export type ConnectorElement = Connector & { id: string, createdAt: string }
export function ConnectorsList({connectors, onDelete}: { connectors: ConnectorElement[], onDelete: () => void }) { export function ConnectorsList({connectors, onDelete}: { connectors: ConnectorElement[], onDelete: () => void }) {
const {token} = useToken() const {token} = useToken()
const [messageApi, contextHolder] = message.useMessage()
const onConnectorDelete = (connector: ConnectorElement) => deleteConnector(connector.id)
.then(onDelete)
.catch(() => messageApi.error(t`An error occurred while deleting the Connector. Make sure it is not used in any Watchlist`))
return <> return <>
{connectors.map(connector => {connectors.map(connector =>
<> <>
{contextHolder}
<Card hoverable title={<Typography.Text <Card hoverable title={<Typography.Text
title={new Date(connector.createdAt).toLocaleString()}>{t`Connector ${connector.provider}`}</Typography.Text>} title={new Date(connector.createdAt).toLocaleString()}>{t`Connector ${connector.provider}`}</Typography.Text>}
size='small' size='small'
style={{width: '100%'}} style={{width: '100%'}}
extra={<Popconfirm title={t`Delete the Connector`} extra={<Popconfirm title={t`Delete the Connector`}
description={t`Are you sure to delete this Connector?`} description={t`Are you sure to delete this Connector?`}
onConfirm={() => deleteConnector(connector.id).then(onDelete)} onConfirm={() => onConnectorDelete(connector)}
okText={t`Yes`} okText={t`Yes`}
cancelText={t`No`} cancelText={t`No`}
><DeleteFilled style={{color: token.colorError}}/></Popconfirm>}> ><DeleteFilled style={{color: token.colorError}}/></Popconfirm>}>

View File

@ -213,25 +213,31 @@ msgstr ""
msgid "Reset" msgid "Reset"
msgstr "" msgstr ""
#: assets/components/tracking/connector/ConnectorsList.tsx:19 #: assets/components/tracking/connector/ConnectorsList.tsx:18
msgid ""
"An error occurred while deleting the Connector. Make sure it is not used in "
"any Watchlist"
msgstr ""
#: assets/components/tracking/connector/ConnectorsList.tsx:25
#, javascript-format #, javascript-format
msgid "Connector ${ connector.provider }" msgid "Connector ${ connector.provider }"
msgstr "" msgstr ""
#: assets/components/tracking/connector/ConnectorsList.tsx:22 #: assets/components/tracking/connector/ConnectorsList.tsx:28
msgid "Delete the Connector" msgid "Delete the Connector"
msgstr "" msgstr ""
#: assets/components/tracking/connector/ConnectorsList.tsx:23 #: assets/components/tracking/connector/ConnectorsList.tsx:29
msgid "Are you sure to delete this Connector?" msgid "Are you sure to delete this Connector?"
msgstr "" msgstr ""
#: assets/components/tracking/connector/ConnectorsList.tsx:25 #: assets/components/tracking/connector/ConnectorsList.tsx:31
#: assets/components/tracking/watchlist/DeleteWatchlistButton.tsx:15 #: assets/components/tracking/watchlist/DeleteWatchlistButton.tsx:15
msgid "Yes" msgid "Yes"
msgstr "" msgstr ""
#: assets/components/tracking/connector/ConnectorsList.tsx:26 #: assets/components/tracking/connector/ConnectorsList.tsx:32
#: assets/components/tracking/watchlist/DeleteWatchlistButton.tsx:16 #: assets/components/tracking/watchlist/DeleteWatchlistButton.tsx:16
msgid "No" msgid "No"
msgstr "" msgstr ""