diff --git a/openmetadata-ui/src/main/resources/ui/src/components/DashboardDetails/DashboardDetails.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/DashboardDetails/DashboardDetails.component.tsx
index 4782fb9ddef..2506bbb7611 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/DashboardDetails/DashboardDetails.component.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/components/DashboardDetails/DashboardDetails.component.tsx
@@ -663,8 +663,12 @@ const DashboardDetails = ({
{activeTab === 4 && !deleted && (
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ManageTab/ManageTab.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ManageTab/ManageTab.component.tsx
index 253b28020de..b9f1f5cecb1 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/ManageTab/ManageTab.component.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/components/ManageTab/ManageTab.component.tsx
@@ -191,6 +191,92 @@ const ManageTab: FunctionComponent
= ({
}
};
+ const getDeleteEntityWidget = () => {
+ return allowDelete && entityId && entityName && entityType ? (
+
+
+
+
+
+ Delete {entityType} {entityName}
+
+
+ {`Once you delete this ${entityType}, it would be removed permanently`}
+
+
+
+
+
+ ) : null;
+ };
+
+ const getTierCards = () => {
+ if (!hideTier) {
+ return isLoadingTierData ? (
+
+ ) : (
+
+ {tierData.map((card, i) => (
+
+ You need to be owner to perform this action
+ Claim ownership from above
+
+ }
+ isOwner={hasEditAccess || Boolean(owner && !currentUser)}
+ key={i}
+ permission={Operation.UpdateTags}
+ position="left">
+
+
+ ))}
+
+ );
+ } else {
+ return null;
+ }
+ };
+
+ const getJoinableWidget = () => {
+ const isActionAllowed =
+ isAdminUser ||
+ isAuthDisabled ||
+ userPermissions[Operation.UpdateTeam] ||
+ !hasEditAccess;
+
+ const joinableSwitch = isActionAllowed ? (
+
+
+
setTeamJoinable((prev) => !prev)}>
+
+
+
+ ) : null;
+
+ return !isUndefined(isJoinable) ? (
+ {joinableSwitch}
+ ) : null;
+ };
+
+ const ownerName = getOwnerById();
const getTierData = () => {
setIsLoadingTierData(true);
getCategory('Tier')
@@ -225,8 +311,6 @@ const ManageTab: FunctionComponent = ({
});
};
- const ownerName = getOwnerById();
-
useEffect(() => {
if (!hideTier) {
getTierData();
@@ -328,55 +412,9 @@ const ManageTab: FunctionComponent = ({
)}
- {!isUndefined(isJoinable) ? (
-
- {isAdminUser ||
- isAuthDisabled ||
- userPermissions[Operation.UpdateTeam] ||
- !hasEditAccess ? (
-
-
-
setTeamJoinable((prev) => !prev)}>
-
-
-
- ) : null}
-
- ) : null}
+ {getJoinableWidget()}
- {!hideTier &&
- (isLoadingTierData ? (
-
- ) : (
-
- {tierData.map((card, i) => (
-
- You need to be owner to perform this action
- Claim ownership from above
- >
- }
- isOwner={hasEditAccess || Boolean(owner && !currentUser)}
- key={i}
- permission={Operation.UpdateTags}
- position="left">
-
-
- ))}
-
- ))}
+ {getTierCards()}
)}
- {allowDelete ? (
-
-
-
-
-
- Delete {entityType} {entityName}
-
-
- {`Once you delete this ${entityType}, it would be removed permanently`}
-
-
-
-
-
- ) : null}
+ {getDeleteEntityWidget()}
{getDeleteModal()}
);
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ManageTab/ManageTab.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ManageTab/ManageTab.test.tsx
index 05c8ada2f4e..9c3eeb162fa 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/ManageTab/ManageTab.test.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/components/ManageTab/ManageTab.test.tsx
@@ -153,9 +153,16 @@ describe('Test Manage tab Component', () => {
expect(isJoinableSwitch).toBeInTheDocument();
});
- it('Should render danger zone if allowDelete is present', async () => {
+ it('Should render danger zone if allowDelete, entityId, entityName and entityType is present', async () => {
const { container } = render(
-
+
);
const dangerZone = await findByTestId(container, 'danger-zone');
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Modals/EntityDeleteModal/EntityDeleteModal.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Modals/EntityDeleteModal/EntityDeleteModal.test.tsx
index ca02c4888e8..e2a7448f4bc 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/Modals/EntityDeleteModal/EntityDeleteModal.test.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/components/Modals/EntityDeleteModal/EntityDeleteModal.test.tsx
@@ -11,7 +11,7 @@
* limitations under the License.
*/
-import { findByTestId, render } from '@testing-library/react';
+import { findByTestId, fireEvent, render } from '@testing-library/react';
import React from 'react';
import { MemoryRouter } from 'react-router-dom';
import EntityDeleteModal from './EntityDeleteModal';
@@ -42,11 +42,11 @@ describe('Test EntityDelete Modal Component', () => {
expect(await findByTestId(container, 'body-text')).toBeInTheDocument();
expect(
- await findByTestId(container, 'confirmation-text')
+ await findByTestId(container, 'confirmation-text-input')
).toBeInTheDocument();
});
- it('Should initially render confirm button as disable component', async () => {
+ it('Should initially render confirm button as disable', async () => {
const { container } = render(, {
wrapper: MemoryRouter,
});
@@ -56,6 +56,21 @@ describe('Test EntityDelete Modal Component', () => {
expect(confirmButton).toBeDisabled();
});
+ it('Should render discard button and input box as disable if loading state is wating', async () => {
+ const { container } = render(
+ ,
+ {
+ wrapper: MemoryRouter,
+ }
+ );
+
+ const discardButton = await findByTestId(container, 'discard-button');
+ const inputBox = await findByTestId(container, 'confirmation-text-input');
+
+ expect(discardButton).toBeDisabled();
+ expect(inputBox).toBeDisabled();
+ });
+
it('Should show loading button if loading state is waiting', async () => {
const { container } = render(
,
@@ -68,4 +83,38 @@ describe('Test EntityDelete Modal Component', () => {
expect(loadingButton).toBeDisabled();
});
+
+ it('Confirm button should be enable if confirm text matches', async () => {
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+
+ const confirmButton = await findByTestId(container, 'confirm-button');
+
+ expect(confirmButton).toBeDisabled();
+
+ const inputBox = await findByTestId(container, 'confirmation-text-input');
+
+ fireEvent.change(inputBox, {
+ target: { value: `${mockProp.entityType}/${mockProp.entityName}` },
+ });
+
+ expect(confirmButton).not.toBeDisabled();
+
+ fireEvent.click(confirmButton);
+
+ expect(onConfirm).toHaveBeenCalled();
+ });
+
+ it('Should call onCancel on click of discard button', async () => {
+ const { container } = render(, {
+ wrapper: MemoryRouter,
+ });
+
+ const discardButton = await findByTestId(container, 'discard-button');
+
+ fireEvent.click(discardButton);
+
+ expect(onCancel).toHaveBeenCalled();
+ });
});
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Modals/EntityDeleteModal/EntityDeleteModal.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Modals/EntityDeleteModal/EntityDeleteModal.tsx
index 1a837628bfd..9546b45e6aa 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/Modals/EntityDeleteModal/EntityDeleteModal.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/components/Modals/EntityDeleteModal/EntityDeleteModal.tsx
@@ -71,7 +71,7 @@ const EntityDeleteModal: FC = ({
= ({