mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[SecuritySolution] Hide create dashboard button from listing (#164476)
## Summary original issue: https://github.com/elastic/kibana/issues/163459 **Before** - Two Create Dashboard buttons on Security Dashboard  **After** - Create dashboard button from listing is removed. <img width="2542" alt="Screenshot 2023-08-22 at 16 45 56" src="ff9bc785
-de2a-40b7-b414-829c8913d997"> ### Checklist Delete any items that are not applicable to this PR. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
This commit is contained in:
parent
aa27425663
commit
d63dd9df2d
6 changed files with 25 additions and 2 deletions
|
@ -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(
|
||||
|
|
|
@ -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(() =>
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -146,6 +146,7 @@ export const DashboardsLandingPage = () => {
|
|||
goToDashboard={goToDashboard}
|
||||
initialFilter={initialFilter}
|
||||
urlStateEnabled={false}
|
||||
showCreateDashboardButton={false}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
|
|
@ -30,7 +30,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => {
|
|||
|
||||
await testSubjects.click('solutionSideNavItemLink-dashboards');
|
||||
|
||||
await dashboard.clickNewDashboard();
|
||||
await testSubjects.click('createDashboardButton');
|
||||
|
||||
await lens.createAndAddLensFromDashboard({});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue