From ba1a7ca3b77dbe416299cf50e4c8f5dee01ac14c Mon Sep 17 00:00:00 2001
From: Aniket Katkar <51777795+aniketkatkar97@users.noreply.github.com>
Date: Wed, 28 Sep 2022 17:29:41 +0530
Subject: [PATCH] UI: Added recursive param for soft deleting teams. (#7766)
* Changes made to soft delete request for teams with recursive param
* changed soft delete message for team delete
* Worked on comments
* Worked on comments
---
.../resources/ui/src/axiosAPIs/miscAPI.ts | 27 ++++++-------------
.../components/TeamDetails/TeamDetailsV1.tsx | 14 +++++++++-
.../DeleteWidget/DeleteWidget.interface.ts | 2 ++
.../common/DeleteWidget/DeleteWidgetModal.tsx | 12 ++++++---
.../ManageButton/ManageButton.tsx | 6 +++++
.../main/resources/ui/src/utils/TeamUtils.ts | 7 +++++
6 files changed, 44 insertions(+), 24 deletions(-)
diff --git a/openmetadata-ui/src/main/resources/ui/src/axiosAPIs/miscAPI.ts b/openmetadata-ui/src/main/resources/ui/src/axiosAPIs/miscAPI.ts
index 1d4a20e6bc4..223747c77e0 100644
--- a/openmetadata-ui/src/main/resources/ui/src/axiosAPIs/miscAPI.ts
+++ b/openmetadata-ui/src/main/resources/ui/src/axiosAPIs/miscAPI.ts
@@ -12,7 +12,6 @@
*/
import { AxiosRequestConfig, AxiosResponse } from 'axios';
-import { isUndefined } from 'lodash';
import { Edge } from '../components/EntityLineage/EntityLineage.interface';
import { WILD_CARD_CHAR } from '../constants/char.constants';
import { SearchIndex } from '../enums/search.enum';
@@ -20,7 +19,6 @@ import { AirflowConfiguration } from '../generated/configuration/airflowConfigur
import { AuthenticationConfiguration } from '../generated/configuration/authenticationConfiguration';
import { EntitiesCount } from '../generated/entity/utils/entitiesCount';
import { Paging } from '../generated/type/paging';
-import { getURLWithQueryFields } from '../utils/APIUtils';
import { getCurrentUserId } from '../utils/CommonUtils';
import { getSearchAPIQuery } from '../utils/SearchUtils';
import APIClient from './index';
@@ -222,25 +220,16 @@ export const deleteEntity = async (
entityType: string,
entityId: string,
isRecursive: boolean,
- isSoftDelete = false
+ isHardDelete = true
) => {
- let path = '';
+ const params = {
+ hardDelete: isHardDelete,
+ recursive: isRecursive,
+ };
- if (isSoftDelete) {
- path = getURLWithQueryFields(`/${entityType}/${entityId}`);
- } else {
- const searchParams = new URLSearchParams({ hardDelete: `true` });
- if (!isUndefined(isRecursive)) {
- searchParams.set('recursive', `${isRecursive}`);
- }
- path = getURLWithQueryFields(
- `/${entityType}/${entityId}`,
- '',
- `${searchParams.toString()}`
- );
- }
-
- return APIClient.delete(path);
+ return APIClient.delete(`/${entityType}/${entityId}`, {
+ params,
+ });
};
export const getAdvancedFieldOptions = (
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/TeamDetails/TeamDetailsV1.tsx b/openmetadata-ui/src/main/resources/ui/src/components/TeamDetails/TeamDetailsV1.tsx
index bcb991bf3d6..0f8705fcb90 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/TeamDetails/TeamDetailsV1.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/components/TeamDetails/TeamDetailsV1.tsx
@@ -69,7 +69,10 @@ import {
} from '../../utils/PermissionsUtils';
import { getTeamsWithFqnPath } from '../../utils/RouterUtils';
import SVGIcons, { Icons } from '../../utils/SvgUtils';
-import { filterChildTeams } from '../../utils/TeamUtils';
+import {
+ filterChildTeams,
+ getDeleteMessagePostFix,
+} from '../../utils/TeamUtils';
import { showErrorToast } from '../../utils/ToastUtils';
import { Button } from '../buttons/Button/Button';
import Description from '../common/description/Description';
@@ -879,6 +882,7 @@ const TeamDetailsV1 = ({
)}
{entityPermissions.EditAll && (
)}
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/DeleteWidget/DeleteWidget.interface.ts b/openmetadata-ui/src/main/resources/ui/src/components/common/DeleteWidget/DeleteWidget.interface.ts
index 54288b1a2e3..f35452c9109 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/common/DeleteWidget/DeleteWidget.interface.ts
+++ b/openmetadata-ui/src/main/resources/ui/src/components/common/DeleteWidget/DeleteWidget.interface.ts
@@ -16,6 +16,8 @@ export interface DeleteWidgetModalProps {
onCancel: () => void;
allowSoftDelete?: boolean;
deleteMessage?: string;
+ softDeleteMessagePostFix?: string;
+ hardDeleteMessagePostFix?: string;
entityName: string;
entityType: string;
isAdminUser?: boolean;
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/DeleteWidget/DeleteWidgetModal.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/DeleteWidget/DeleteWidgetModal.tsx
index 4b3d9b9d7a0..e1f6fc8032b 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/common/DeleteWidget/DeleteWidgetModal.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/components/common/DeleteWidget/DeleteWidgetModal.tsx
@@ -31,6 +31,8 @@ const DeleteWidgetModal = ({
allowSoftDelete = true,
visible,
deleteMessage,
+ softDeleteMessagePostFix = '',
+ hardDeleteMessagePostFix = '',
entityName,
entityType,
onCancel,
@@ -48,7 +50,7 @@ const DeleteWidgetModal = ({
);
const prepareDeleteMessage = (softDelete = false) => {
- const softDeleteText = `Soft deleting will deactivate the ${entityName}. This will disable any discovery, read or write operations on ${entityName}`;
+ const softDeleteText = `Soft deleting will deactivate the ${entityName}. This will disable any discovery, read or write operations on ${entityName}.`;
const hardDeleteText = getEntityDeleteMessage(getTitleCase(entityType), '');
return softDelete ? softDeleteText : hardDeleteText;
@@ -57,13 +59,15 @@ const DeleteWidgetModal = ({
const DELETE_OPTION = [
{
title: `Delete ${entityType} “${entityName}”`,
- description: prepareDeleteMessage(true),
+ description: `${prepareDeleteMessage(true)} ${softDeleteMessagePostFix}`,
type: DeleteType.SOFT_DELETE,
isAllowd: allowSoftDelete,
},
{
title: `Permanently Delete ${entityType} “${entityName}”`,
- description: deleteMessage || prepareDeleteMessage(),
+ description: `${
+ deleteMessage || prepareDeleteMessage()
+ } ${hardDeleteMessagePostFix}`,
type: DeleteType.HARD_DELETE,
isAllowd: true,
},
@@ -115,7 +119,7 @@ const DeleteWidgetModal = ({
prepareType ? prepareEntityType() : entityType,
entityId ?? '',
Boolean(isRecursiveDelete),
- entityDeleteState.softDelete
+ !entityDeleteState.softDelete
)
.then((res) => {
if (res.status === 200) {
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/entityPageInfo/ManageButton/ManageButton.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/entityPageInfo/ManageButton/ManageButton.tsx
index 4b4714a172d..22447ea6480 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/common/entityPageInfo/ManageButton/ManageButton.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/components/common/entityPageInfo/ManageButton/ManageButton.tsx
@@ -33,6 +33,8 @@ interface Props {
entityFQN?: string;
isRecursiveDelete?: boolean;
deleteMessage?: string;
+ softDeleteMessagePostFix?: string;
+ hardDeleteMessagePostFix?: string;
canDelete?: boolean;
extraDropdownContent?: ItemType[];
onAnnouncementClick?: () => void;
@@ -43,6 +45,8 @@ const ManageButton: FC = ({
afterDeleteAction,
buttonClassName,
deleteMessage,
+ softDeleteMessagePostFix,
+ hardDeleteMessagePostFix,
entityName,
entityType,
canDelete,
@@ -157,7 +161,9 @@ const ManageButton: FC = ({
entityId={entityId || ''}
entityName={entityName || ''}
entityType={entityType || ''}
+ hardDeleteMessagePostFix={hardDeleteMessagePostFix}
isRecursiveDelete={isRecursiveDelete}
+ softDeleteMessagePostFix={softDeleteMessagePostFix}
visible={isDelete}
onCancel={() => setIsDelete(false)}
/>
diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/TeamUtils.ts b/openmetadata-ui/src/main/resources/ui/src/utils/TeamUtils.ts
index 0438d55426e..842cd7c3a9e 100644
--- a/openmetadata-ui/src/main/resources/ui/src/utils/TeamUtils.ts
+++ b/openmetadata-ui/src/main/resources/ui/src/utils/TeamUtils.ts
@@ -27,3 +27,10 @@ export const filterChildTeams = (
teamsList: Team[],
showDeletedTeams: boolean
) => teamsList.filter((d) => d.deleted === showDeletedTeams);
+
+export const getDeleteMessagePostFix = (
+ teamName: string,
+ deleteType: string
+) => {
+ return `Any teams under "${teamName}" will be ${deleteType} deleted as well.`;
+};