mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-27 02:16:18 +00:00
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
This commit is contained in:
parent
962866a30e
commit
ba1a7ca3b7
@ -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 = (
|
||||
|
@ -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 && (
|
||||
<ManageButton
|
||||
isRecursiveDelete
|
||||
afterDeleteAction={afterDeleteAction}
|
||||
allowSoftDelete={!currentTeam.deleted}
|
||||
buttonClassName="tw-p-4"
|
||||
@ -889,6 +893,14 @@ const TeamDetailsV1 = ({
|
||||
}
|
||||
entityType="team"
|
||||
extraDropdownContent={extraDropdownContent}
|
||||
hardDeleteMessagePostFix={getDeleteMessagePostFix(
|
||||
currentTeam.fullyQualifiedName || currentTeam.name,
|
||||
'permanently'
|
||||
)}
|
||||
softDeleteMessagePostFix={getDeleteMessagePostFix(
|
||||
currentTeam.fullyQualifiedName || currentTeam.name,
|
||||
'soft'
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
</Space>
|
||||
|
@ -16,6 +16,8 @@ export interface DeleteWidgetModalProps {
|
||||
onCancel: () => void;
|
||||
allowSoftDelete?: boolean;
|
||||
deleteMessage?: string;
|
||||
softDeleteMessagePostFix?: string;
|
||||
hardDeleteMessagePostFix?: string;
|
||||
entityName: string;
|
||||
entityType: string;
|
||||
isAdminUser?: boolean;
|
||||
|
@ -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) {
|
||||
|
@ -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<Props> = ({
|
||||
afterDeleteAction,
|
||||
buttonClassName,
|
||||
deleteMessage,
|
||||
softDeleteMessagePostFix,
|
||||
hardDeleteMessagePostFix,
|
||||
entityName,
|
||||
entityType,
|
||||
canDelete,
|
||||
@ -157,7 +161,9 @@ const ManageButton: FC<Props> = ({
|
||||
entityId={entityId || ''}
|
||||
entityName={entityName || ''}
|
||||
entityType={entityType || ''}
|
||||
hardDeleteMessagePostFix={hardDeleteMessagePostFix}
|
||||
isRecursiveDelete={isRecursiveDelete}
|
||||
softDeleteMessagePostFix={softDeleteMessagePostFix}
|
||||
visible={isDelete}
|
||||
onCancel={() => setIsDelete(false)}
|
||||
/>
|
||||
|
@ -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.`;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user