diff --git a/openmetadata-ui/src/main/resources/ui/src/components/MyData/CustomizableComponents/AddWidgetModal/AddWidgetModal.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/MyData/CustomizableComponents/AddWidgetModal/AddWidgetModal.test.tsx index 4358b86c278..1edad41f81a 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/MyData/CustomizableComponents/AddWidgetModal/AddWidgetModal.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/MyData/CustomizableComponents/AddWidgetModal/AddWidgetModal.test.tsx @@ -15,6 +15,7 @@ import { act, render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; import { PAGE_SIZE_MEDIUM } from '../../../../constants/constants'; +import { LandingPageWidgetKeys } from '../../../../enums/CustomizablePage.enum'; import { mockWidgetsData } from '../../../../mocks/AddWidgetModal.mock'; import { getAllKnowledgePanels } from '../../../../rest/DocStoreAPI'; import AddWidgetModal from './AddWidgetModal'; @@ -172,9 +173,17 @@ describe('AddWidgetModal component', () => { expect(screen.getByText('ErrorPlaceHolder')).toBeInTheDocument(); }); - it('AddWidgetModal should', async () => { + it('AddWidgetModal should not show announcement widget', async () => { + (getAllKnowledgePanels as jest.Mock).mockImplementation(() => + Promise.resolve({ + data: [{ fullyQualifiedName: LandingPageWidgetKeys.ANNOUNCEMENTS }], + }) + ); + await act(async () => { render(); }); + + expect(screen.queryByTestId('Announcements-widget-tab-label')).toBeNull(); }); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/MyData/CustomizableComponents/AddWidgetModal/AddWidgetModal.tsx b/openmetadata-ui/src/main/resources/ui/src/components/MyData/CustomizableComponents/AddWidgetModal/AddWidgetModal.tsx index 2f9fb974324..31be933b95f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/MyData/CustomizableComponents/AddWidgetModal/AddWidgetModal.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/MyData/CustomizableComponents/AddWidgetModal/AddWidgetModal.tsx @@ -22,7 +22,10 @@ import { PAGE_SIZE_MEDIUM, } from '../../../../constants/constants'; import { ERROR_PLACEHOLDER_TYPE } from '../../../../enums/common.enum'; -import { WidgetWidths } from '../../../../enums/CustomizablePage.enum'; +import { + LandingPageWidgetKeys, + WidgetWidths, +} from '../../../../enums/CustomizablePage.enum'; import { Document } from '../../../../generated/entity/docStore/document'; import { getAllKnowledgePanels } from '../../../../rest/DocStoreAPI'; import { getWidgetWidthLabelFromKey } from '../../../../utils/CustomizableLandingPageUtils'; @@ -51,12 +54,18 @@ function AddWidgetModal({ const fetchKnowledgePanels = useCallback(async () => { try { setLoading(true); - const response = await getAllKnowledgePanels({ + const { data } = await getAllKnowledgePanels({ fqnPrefix: 'KnowledgePanel', limit: PAGE_SIZE_MEDIUM, }); - setWidgetsList(response.data); + // User can't add / update / delete Announcements widget + setWidgetsList( + data.filter( + (widget) => + widget.fullyQualifiedName !== LandingPageWidgetKeys.ANNOUNCEMENTS + ) + ); } catch (error) { showErrorToast(error as AxiosError); } finally {