diff --git a/src/plugins/dashboard/public/dashboard_listing/dashboard_listing_table.tsx b/src/plugins/dashboard/public/dashboard_listing/dashboard_listing_table.tsx index 196fd04cddf6c..2386b414c3209 100644 --- a/src/plugins/dashboard/public/dashboard_listing/dashboard_listing_table.tsx +++ b/src/plugins/dashboard/public/dashboard_listing/dashboard_listing_table.tsx @@ -34,6 +34,7 @@ export const DashboardListingTable = ({ getDashboardUrl, useSessionStorageIntegration, urlStateEnabled, + showCreateDashboardButton = true, }: DashboardListingProps) => { const { application, @@ -61,6 +62,7 @@ export const DashboardListingTable = ({ urlStateEnabled, useSessionStorageIntegration, initialFilter, + showCreateDashboardButton, }); const savedObjectsTaggingFakePlugin = useMemo( diff --git a/src/plugins/dashboard/public/dashboard_listing/hooks/use_dashboard_listing_table.test.tsx b/src/plugins/dashboard/public/dashboard_listing/hooks/use_dashboard_listing_table.test.tsx index 7716981e34942..602ac6a1f4a3c 100644 --- a/src/plugins/dashboard/public/dashboard_listing/hooks/use_dashboard_listing_table.test.tsx +++ b/src/plugins/dashboard/public/dashboard_listing/hooks/use_dashboard_listing_table.test.tsx @@ -105,6 +105,22 @@ describe('useDashboardListingTable', () => { expect(result.current.unsavedDashboardIds).toEqual([]); }); + test('should not render the create dashboard button when showCreateDashboardButton is false', () => { + const initialFilter = 'myFilter'; + const { result } = renderHook(() => + useDashboardListingTable({ + getDashboardUrl, + goToDashboard, + initialFilter, + urlStateEnabled: false, + showCreateDashboardButton: false, + }) + ); + + const tableListViewTableProps = result.current.tableListViewTableProps; + expect(tableListViewTableProps.createItem).toBeUndefined(); + }); + test('should return the correct tableListViewTableProps', () => { const initialFilter = 'myFilter'; const { result } = renderHook(() => diff --git a/src/plugins/dashboard/public/dashboard_listing/hooks/use_dashboard_listing_table.tsx b/src/plugins/dashboard/public/dashboard_listing/hooks/use_dashboard_listing_table.tsx index aefa45500b450..8f2fb7ac76cc9 100644 --- a/src/plugins/dashboard/public/dashboard_listing/hooks/use_dashboard_listing_table.tsx +++ b/src/plugins/dashboard/public/dashboard_listing/hooks/use_dashboard_listing_table.tsx @@ -70,6 +70,7 @@ export const useDashboardListingTable = ({ initialFilter, urlStateEnabled, useSessionStorageIntegration, + showCreateDashboardButton = true, }: { dashboardListingId?: string; disableCreateDashboardButton?: boolean; @@ -79,6 +80,7 @@ export const useDashboardListingTable = ({ initialFilter?: string; urlStateEnabled?: boolean; useSessionStorageIntegration?: boolean; + showCreateDashboardButton?: boolean; }): UseDashboardListingTableReturnType => { const { dashboardSessionStorage, @@ -274,7 +276,7 @@ export const useDashboardListingTable = ({ onSave: updateItemMeta, customValidators: contentEditorValidators, }, - createItem: !showWriteControls ? undefined : createItem, + createItem: !showWriteControls || !showCreateDashboardButton ? undefined : createItem, deleteItems: !showWriteControls ? undefined : deleteItems, editItem: !showWriteControls ? undefined : editItem, emptyPrompt, @@ -308,6 +310,7 @@ export const useDashboardListingTable = ({ initialPageSize, listingLimit, onFetchSuccess, + showCreateDashboardButton, showWriteControls, title, updateItemMeta, diff --git a/src/plugins/dashboard/public/dashboard_listing/types.ts b/src/plugins/dashboard/public/dashboard_listing/types.ts index c92344d4e778a..18767c1c75c32 100644 --- a/src/plugins/dashboard/public/dashboard_listing/types.ts +++ b/src/plugins/dashboard/public/dashboard_listing/types.ts @@ -17,6 +17,7 @@ export type DashboardListingProps = PropsWithChildren<{ goToDashboard: (dashboardId?: string, viewMode?: ViewMode) => void; getDashboardUrl: (dashboardId: string, usesTimeRestore: boolean) => string; urlStateEnabled?: boolean; + showCreateDashboardButton?: boolean; }>; // because the type of `application.capabilities.advancedSettings` is so generic, the provider diff --git a/x-pack/plugins/security_solution/public/dashboards/pages/landing_page/index.tsx b/x-pack/plugins/security_solution/public/dashboards/pages/landing_page/index.tsx index e72e38429f35d..7d579c66e8191 100644 --- a/x-pack/plugins/security_solution/public/dashboards/pages/landing_page/index.tsx +++ b/x-pack/plugins/security_solution/public/dashboards/pages/landing_page/index.tsx @@ -146,6 +146,7 @@ export const DashboardsLandingPage = () => { goToDashboard={goToDashboard} initialFilter={initialFilter} urlStateEnabled={false} + showCreateDashboardButton={false} /> )} diff --git a/x-pack/test_serverless/functional/test_suites/security/ftr/cases/attachment_framework.ts b/x-pack/test_serverless/functional/test_suites/security/ftr/cases/attachment_framework.ts index a35787cff6aad..6b76503531d3c 100644 --- a/x-pack/test_serverless/functional/test_suites/security/ftr/cases/attachment_framework.ts +++ b/x-pack/test_serverless/functional/test_suites/security/ftr/cases/attachment_framework.ts @@ -30,7 +30,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { await testSubjects.click('solutionSideNavItemLink-dashboards'); - await dashboard.clickNewDashboard(); + await testSubjects.click('createDashboardButton'); await lens.createAndAddLensFromDashboard({});