From 3af0d49dd7cc8eaf2bc2337e32d4fcce449de699 Mon Sep 17 00:00:00 2001 From: Nicolas Inchauspe Date: Fri, 23 Jun 2023 09:42:11 +0200 Subject: [PATCH] console: fix remove source cascading [DSF-437]: https://hasurahq.atlassian.net/browse/DSF-437?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9642 GitOrigin-RevId: fc18f90cc328b78124b3254783b44da6cb51022e --- .../ListConnectedDatabases/ListConnectedDatabases.tsx | 2 ++ .../lib/features/ConnectDBRedesign/hooks/useDropSource.ts | 1 + .../src/lib/new-components/Alert/AlertProvider.tsx | 8 ++++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/frontend/libs/console/legacy-ce/src/lib/features/ConnectDBRedesign/components/ListConnectedDatabases/ListConnectedDatabases.tsx b/frontend/libs/console/legacy-ce/src/lib/features/ConnectDBRedesign/components/ListConnectedDatabases/ListConnectedDatabases.tsx index df7662e07cb..2bad7e93bda 100644 --- a/frontend/libs/console/legacy-ce/src/lib/features/ConnectDBRedesign/components/ListConnectedDatabases/ListConnectedDatabases.tsx +++ b/frontend/libs/console/legacy-ce/src/lib/features/ConnectDBRedesign/components/ListConnectedDatabases/ListConnectedDatabases.tsx @@ -108,6 +108,8 @@ export const ListConnectedDatabases = (props?: { className?: string }) => { resourceName: databaseItem.dataSourceName, resourceType: 'Data Source', destroyTerm: 'remove', + appendTerm: + 'Any metadata dependent objects (relationships, permissions etc.) from other sources will also be dropped as a result.', onConfirm: async () => { let success = true; diff --git a/frontend/libs/console/legacy-ce/src/lib/features/ConnectDBRedesign/hooks/useDropSource.ts b/frontend/libs/console/legacy-ce/src/lib/features/ConnectDBRedesign/hooks/useDropSource.ts index 6b5ec8658de..100f16b7998 100644 --- a/frontend/libs/console/legacy-ce/src/lib/features/ConnectDBRedesign/hooks/useDropSource.ts +++ b/frontend/libs/console/legacy-ce/src/lib/features/ConnectDBRedesign/hooks/useDropSource.ts @@ -35,6 +35,7 @@ export const useDropSource = (props?: MetadataMigrationOptions) => { type: `${driver}_drop_source`, args: { name: dataSourceName, + cascade: true, }, }, }, diff --git a/frontend/libs/console/legacy-ce/src/lib/new-components/Alert/AlertProvider.tsx b/frontend/libs/console/legacy-ce/src/lib/new-components/Alert/AlertProvider.tsx index 93e96172d34..41458b75537 100644 --- a/frontend/libs/console/legacy-ce/src/lib/new-components/Alert/AlertProvider.tsx +++ b/frontend/libs/console/legacy-ce/src/lib/new-components/Alert/AlertProvider.tsx @@ -208,11 +208,13 @@ const useDestructiveConfirm = () => { resourceName, resourceType, destroyTerm = 'remove', + appendTerm = '', onConfirm, }: { resourceName: string; resourceType: string; destroyTerm?: 'delete' | 'remove'; + appendTerm?: string; onConfirm: () => Promise; }) => { if (!onConfirm) throw new Error('onCloseAsync() is required.'); @@ -222,7 +224,7 @@ const useDestructiveConfirm = () => { message: (
Are you sure you want to {destroyTerm} {resourceType}:{' '} - {resourceName}? + {resourceName}?{appendTerm ? ` ${appendTerm}` : ''}
), confirmText: 'Remove', @@ -255,11 +257,13 @@ const useDestructivePrompt = () => { resourceName, resourceType, destroyTerm = 'remove', + appendTerm = '', onConfirm, }: { resourceName: string; resourceType: string; destroyTerm?: 'delete' | 'remove'; + appendTerm?: string; onConfirm: () => Promise; }) => { if (!onConfirm) throw new Error('onCloseAsync() is required.'); @@ -269,7 +273,7 @@ const useDestructivePrompt = () => { message: (
Are you sure you want to {destroyTerm} {resourceType}:{' '} - {resourceName}? + {resourceName}?{appendTerm ? ` ${appendTerm}` : ''}
), confirmText: 'Remove',