-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SecuritySolution] Setup dashboard view page #153040
Merged
Merged
Changes from 32 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
1cc4ff5
init dashboards
angorayc 8b1e905
rm unused types
angorayc ec52aa2
unit tests
angorayc 3c78f16
rm unused i18n keys
angorayc 6ccc33f
show dashboard name in breadcrumbs
angorayc 53e2aa0
search bar
angorayc 4ac3d81
add page title
angorayc adb3e98
fix url state
angorayc 82a67cc
Unified Search Integration
angorayc 65b564e
sync url state
angorayc 3a22755
update query and filter
angorayc 7aaf4c7
bread crumb
angorayc f575159
edit dashboard in dashboard app
angorayc a13fbaf
fix update timerange by brushing on charts
angorayc fb6a2db
edit button
angorayc 09e38f3
unit tests
angorayc 1047fd5
types
angorayc 658cb9c
update reducer on query changed
angorayc 42afcb0
pass onTimeRangeChange to search bar
angorayc 910a843
update unit test
angorayc cd3c99d
remove configs for dashboard view
angorayc 901660f
rename dashboardLanding to dashboards
angorayc e1f7f51
revert unused changes
angorayc ef8be93
add comments
angorayc 362d97a
revert change
angorayc a5afb37
clean up
angorayc 1d8f408
rm kbnUrlStateStorage
angorayc b7f15c4
Update src/plugins/unified_search/public/search_bar/search_bar.tsx
angorayc 9be878c
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine 4d2a572
add dashboard view links' entries
angorayc 7c70a98
update edit link
angorayc 7e48271
Merge branch 'main' of github.com:elastic/kibana into dashboard-setup
angorayc d92fd7f
review
angorayc 54472ed
Merge branch 'dashboard-setup' of github.com:angorayc/kibana into das…
angorayc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...plugins/security_solution/public/common/components/dashboards/dashboard_renderer.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import { render } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { TestProviders } from '../../mock'; | ||
import { DashboardRenderer } from './dashboard_renderer'; | ||
|
||
jest.mock('@kbn/dashboard-plugin/public', () => { | ||
const actual = jest.requireActual('@kbn/dashboard-plugin/public'); | ||
return { | ||
...actual, | ||
LazyDashboardContainerRenderer: jest | ||
.fn() | ||
.mockImplementation(() => <div data-test-subj="dashboardRenderer" />), | ||
}; | ||
}); | ||
|
||
jest.mock('react-router-dom', () => { | ||
const actual = jest.requireActual('react-router-dom'); | ||
return { | ||
...actual, | ||
useParams: jest.fn().mockReturnValue({ | ||
detailName: '2d50f100-be6f-11ed-964a-ffa67304840e', | ||
}), | ||
}; | ||
}); | ||
|
||
describe('DashboardRenderer', () => { | ||
const props = { | ||
canReadDashboard: true, | ||
id: 'dashboard-savedObjectId', | ||
savedObjectId: 'savedObjectId', | ||
timeRange: { | ||
from: '2023-03-10T00:00:00.000Z', | ||
to: '2023-03-10T23:59:59.999Z', | ||
}, | ||
}; | ||
|
||
it('renders', () => { | ||
const { queryByTestId } = render(<DashboardRenderer {...props} />, { wrapper: TestProviders }); | ||
expect(queryByTestId(`dashboardRenderer`)).toBeInTheDocument(); | ||
}); | ||
|
||
it('does not render when No Read Permission', () => { | ||
const testProps = { | ||
...props, | ||
canReadDashboard: false, | ||
}; | ||
const { queryByTestId } = render(<DashboardRenderer {...testProps} />, { | ||
wrapper: TestProviders, | ||
}); | ||
expect(queryByTestId(`dashboardRenderer`)).not.toBeInTheDocument(); | ||
}); | ||
}); |
91 changes: 91 additions & 0 deletions
91
x-pack/plugins/security_solution/public/common/components/dashboards/dashboard_renderer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import React, { useCallback, useEffect, useState } from 'react'; | ||
import type { DashboardContainer } from '@kbn/dashboard-plugin/public'; | ||
import { LazyDashboardContainerRenderer } from '@kbn/dashboard-plugin/public'; | ||
import { ViewMode } from '@kbn/embeddable-plugin/public'; | ||
import type { Filter, Query } from '@kbn/es-query'; | ||
|
||
import { useDispatch } from 'react-redux'; | ||
import { InputsModelId } from '../../store/inputs/constants'; | ||
import { inputsActions } from '../../store/inputs'; | ||
|
||
const DashboardRendererComponent = ({ | ||
canReadDashboard, | ||
filters, | ||
id, | ||
inputId = InputsModelId.global, | ||
onDashboardContainerLoaded, | ||
query, | ||
savedObjectId, | ||
timeRange, | ||
}: { | ||
canReadDashboard: boolean; | ||
filters?: Filter[]; | ||
id: string; | ||
inputId?: InputsModelId.global | InputsModelId.timeline; | ||
onDashboardContainerLoaded?: (dashboardContainer: DashboardContainer) => void; | ||
query?: Query; | ||
savedObjectId: string | undefined; | ||
timeRange: { | ||
from: string; | ||
fromStr?: string | undefined; | ||
to: string; | ||
toStr?: string | undefined; | ||
}; | ||
}) => { | ||
const dispatch = useDispatch(); | ||
const [dashboardContainer, setDashboardContainer] = useState<DashboardContainer>(); | ||
|
||
const getCreationOptions = useCallback( | ||
() => | ||
Promise.resolve({ | ||
overrideInput: { timeRange, viewMode: ViewMode.VIEW, query, filters }, | ||
}), | ||
[filters, query, timeRange] | ||
); | ||
|
||
const refetchByForceRefresh = useCallback(() => { | ||
dashboardContainer?.forceRefresh(); | ||
}, [dashboardContainer]); | ||
|
||
useEffect(() => { | ||
dispatch( | ||
inputsActions.setQuery({ | ||
inputId, | ||
id, | ||
refetch: refetchByForceRefresh, | ||
loading: false, | ||
inspect: null, | ||
}) | ||
); | ||
return () => { | ||
dispatch(inputsActions.deleteOneQuery({ inputId, id })); | ||
}; | ||
}, [dispatch, id, inputId, refetchByForceRefresh]); | ||
|
||
useEffect(() => { | ||
dashboardContainer?.updateInput({ timeRange, query, filters }); | ||
}, [dashboardContainer, filters, query, timeRange]); | ||
|
||
const handleDashboardLoaded = useCallback( | ||
(container: DashboardContainer) => { | ||
setDashboardContainer(container); | ||
onDashboardContainerLoaded?.(container); | ||
}, | ||
[onDashboardContainerLoaded] | ||
); | ||
return savedObjectId && canReadDashboard ? ( | ||
<LazyDashboardContainerRenderer | ||
savedObjectId={savedObjectId} | ||
getCreationOptions={getCreationOptions} | ||
onDashboardContainerLoaded={handleDashboardLoaded} | ||
/> | ||
) : null; | ||
}; | ||
DashboardRendererComponent.displayName = 'DashboardRendererComponent'; | ||
export const DashboardRenderer = React.memo(DashboardRendererComponent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 0 additions & 33 deletions
33
x-pack/plugins/security_solution/public/common/components/page_route/pageroute.test.tsx
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
x-pack/plugins/security_solution/public/common/components/page_route/pageroute.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this because the time range of the Visualization wouldn't update after brushing on a time-based histogram / area chart.
brushing_on_chart.mov
After:
Screen.Recording.2023-03-27.at.11.35.47.mov