Skip to content

Commit 5a87156

Browse files
🪟 🎉 Adds extra information while deleting source or destination (#21594)
* Adds extra information while deleting source or destination * Fixes extra property to make the usage more general, not limiting with p tag * Fixes extra to additionalContent; Adds pluralization for deletion message * Add bold text for connection names * Update airbyte-webapp/src/pages/destination/DestinationSettingsPage/DestinationSettingsPage.tsx Co-authored-by: Edmundo Ruiz Ghanem <[email protected]> * Update airbyte-webapp/src/pages/SourcesPage/pages/SourceItemPage/components/SourceSettings.tsx Co-authored-by: Edmundo Ruiz Ghanem <[email protected]> * Fixes connection names rendering; Changes sources/destination deletion modal text * Fixes useDeleteModal hook usage --------- Co-authored-by: Edmundo Ruiz Ghanem <[email protected]>
1 parent c65f6ce commit 5a87156

File tree

7 files changed

+55
-9
lines changed

7 files changed

+55
-9
lines changed

airbyte-webapp/src/components/common/ConfirmationModal/ConfirmationModal.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ export interface ConfirmationModalProps {
1616
onSubmit: () => void;
1717
submitButtonDataId?: string;
1818
cancelButtonText?: string;
19+
additionalContent?: React.ReactNode;
1920
}
2021

2122
export const ConfirmationModal: React.FC<ConfirmationModalProps> = ({
2223
onClose,
2324
title,
2425
text,
26+
additionalContent,
2527
textValues,
2628
onSubmit,
2729
submitButtonText,
@@ -35,6 +37,7 @@ export const ConfirmationModal: React.FC<ConfirmationModalProps> = ({
3537
<Modal onClose={onClose} title={<FormattedMessage id={title} />} testId="confirmationModal">
3638
<div className={styles.content}>
3739
<FormattedMessage id={text} values={textValues} />
40+
{additionalContent}
3841
<div className={styles.buttonContent}>
3942
<Button
4043
className={styles.buttonWithMargin}

airbyte-webapp/src/components/common/DeleteBlock/DeleteBlock.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import styles from "./DeleteBlock.module.scss";
1212
interface IProps {
1313
type: "source" | "destination" | "connection";
1414
onDelete: () => Promise<unknown>;
15+
modalAdditionalContent?: React.ReactNode;
1516
}
1617

1718
export const DeleteBlock: React.FC<IProps> = ({ type, onDelete }) => {

airbyte-webapp/src/hooks/services/ConfirmationModal/ConfirmationModalService.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export const ConfirmationModalService = ({ children }: { children: React.ReactNo
6060
{state.isOpen && state.confirmationModal ? (
6161
<ConfirmationModal
6262
onClose={closeConfirmationModal}
63+
additionalContent={state.confirmationModal.additionalContent}
6364
title={state.confirmationModal.title}
6465
text={state.confirmationModal.text}
6566
textValues={state.confirmationModal.textValues}
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
import { useCallback } from "react";
1+
import React, { useCallback } from "react";
22
import { useNavigate } from "react-router-dom";
33

44
import { useConfirmationModalService } from "./services/ConfirmationModal";
55

6-
export function useDeleteModal(type: "source" | "destination" | "connection", onDelete: () => Promise<unknown>) {
6+
export function useDeleteModal(
7+
type: "source" | "destination" | "connection",
8+
onDelete: () => Promise<unknown>,
9+
additionalContent?: React.ReactNode
10+
) {
711
const { openConfirmationModal, closeConfirmationModal } = useConfirmationModalService();
812
const navigate = useNavigate();
913

1014
return useCallback(() => {
1115
openConfirmationModal({
1216
text: `tables.${type}DeleteModalText`,
17+
additionalContent,
1318
title: `tables.${type}DeleteConfirm`,
1419
submitButtonText: "form.delete",
1520
onSubmit: async () => {
@@ -19,5 +24,5 @@ export function useDeleteModal(type: "source" | "destination" | "connection", on
1924
},
2025
submitButtonDataId: "delete",
2126
});
22-
}, [closeConfirmationModal, onDelete, openConfirmationModal, navigate, type]);
27+
}, [openConfirmationModal, type, additionalContent, onDelete, closeConfirmationModal, navigate]);
2328
}

airbyte-webapp/src/locales/en.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,9 @@
485485
"tables.sourceDeleteConfirm": "Confirm source deletion",
486486
"tables.destinationDeleteConfirm": "Confirm destination deletion",
487487
"tables.connectionDeleteConfirm": "Confirm connection deletion",
488-
"tables.sourceDeleteModalText": "Deleting a source cannot be undone without a full re-sync. Note that:\n - All connections with this source will be deleted, including their past logs and configurations.\n - No existing data in the destination will be altered",
489-
"tables.destinationDeleteModalText": "Deleting a destination cannot be undone. Note that:\n - All connections with this destination will be deleted, including their past logs and configurations.\n - No existing data in the destination will be altered.",
488+
"tables.sourceDeleteModalText": "Deleting a source cannot be undone without a full re-sync. No existing data in the destination will be altered.",
489+
"tables.destinationDeleteModalText": "Deleting a destination cannot be undone. No existing data in the destination will be altered.",
490+
"tables.affectedConnectionsOnDeletion": "The following {count, plural, one {connection} other {connections}} will be deleted:\n",
490491
"tables.connectionDeleteModalText": "Deleting a connection cannot be undone without a full re-sync. Note that:\n - All past logs and configurations will be deleted\n - Updates of new data will stop\n - No existing data in the destination will be altered",
491492
"tables.connectionState.title": "Connection State",
492493
"tables.connectionState.noConnectionState": "This connection doesn‘t have a state (yet).",

airbyte-webapp/src/pages/SourcesPage/pages/SourceItemPage/components/SourceSettings.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback, useEffect } from "react";
1+
import React, { useCallback, useEffect, useMemo } from "react";
22
import { FormattedMessage } from "react-intl";
33

44
import { ConnectionConfiguration } from "core/domain/connection";
@@ -53,7 +53,23 @@ const SourceSettings: React.FC<SourceSettingsProps> = ({ currentSource, connecti
5353
await deleteSource({ connectionsWithSource, source: currentSource });
5454
}, [clearFormChange, connectionsWithSource, currentSource, deleteSource, formId]);
5555

56-
const onDeleteClick = useDeleteModal("source", onDelete);
56+
const modalAdditionalContent = useMemo<React.ReactNode>(() => {
57+
if (connectionsWithSource.length === 0) {
58+
return null;
59+
}
60+
return (
61+
<p>
62+
<FormattedMessage id="tables.affectedConnectionsOnDeletion" values={{ count: connectionsWithSource.length }} />
63+
{connectionsWithSource.map((connection) => (
64+
<>
65+
- <strong>{`${connection.name}\n`}</strong>
66+
</>
67+
))}
68+
</p>
69+
);
70+
}, [connectionsWithSource]);
71+
72+
const onDeleteClick = useDeleteModal("source", onDelete, modalAdditionalContent);
5773

5874
return (
5975
<div className={styles.content}>

airbyte-webapp/src/pages/destination/DestinationSettingsPage/DestinationSettingsPage.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback } from "react";
1+
import React, { useCallback, useMemo } from "react";
22
import { FormattedMessage } from "react-intl";
33
import { useParams } from "react-router-dom";
44

@@ -44,7 +44,26 @@ export const DestinationSettingsPage: React.FC = () => {
4444
});
4545
}, [clearFormChange, connectionsWithDestination, deleteDestination, destination, formId]);
4646

47-
const onDeleteClick = useDeleteModal("destination", onDelete);
47+
const modalAdditionalContent = useMemo<React.ReactNode>(() => {
48+
if (connectionsWithDestination.length === 0) {
49+
return null;
50+
}
51+
return (
52+
<p>
53+
<FormattedMessage
54+
id="tables.affectedConnectionsOnDeletion"
55+
values={{ count: connectionsWithDestination.length }}
56+
/>
57+
{connectionsWithDestination.map((connection) => (
58+
<>
59+
- <strong>{`${connection.name}\n`}</strong>
60+
</>
61+
))}
62+
</p>
63+
);
64+
}, [connectionsWithDestination]);
65+
66+
const onDeleteClick = useDeleteModal("destination", onDelete, modalAdditionalContent);
4867

4968
return (
5069
<div className={styles.content}>

0 commit comments

Comments
 (0)