Skip to content

Commit

Permalink
Fix data grid fullscreen flyout layout with docked sidenav
Browse files Browse the repository at this point in the history
  • Loading branch information
Machi3mfl committed Jan 5, 2024
1 parent d51c71f commit 08775dc
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
1 change: 1 addition & 0 deletions plugins/main/public/components/common/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ export * from './use_async_action_run_on_start';
export { useEsSearch } from './use-es-search';
export { useValueSuggestion, IValueSuggestion } from './use-value-suggestion';
export * from './use-state-storage';
export * from './useDockedSideNav';
20 changes: 20 additions & 0 deletions plugins/main/public/components/common/hooks/useDockedSideNav.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { useEffect, useState } from 'react';
import { getChrome } from '../../../kibana-services';

export const useDockedSideNav = () => {
const [sideNavDocked, setSideNavDocked] = useState<boolean>(false);

useEffect(() => {
const isNavDrawerSubscription = getChrome()
.getIsNavDrawerLocked$()
.subscribe((value: boolean) => {
setSideNavDocked(value);
});

return () => {
isNavDrawerSubscription.unsubscribe();
};
}, []);

return sideNavDocked;
};
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ import { DiscoverNoResults } from '../../overview/vulnerabilities/common/compone
import { LoadingSpinner } from '../../overview/vulnerabilities/common/components/loading_spinner';
import { useDataGrid, tDataGridColumn, exportSearchToCSV } from '../data-grid';
import { ErrorHandler, ErrorFactory, HttpError } from '../../../react-services/error-management';
import { withErrorBoundary } from '../hocs';
import { HitsCounter } from '../../../kibana-integrations/discover/application/components/hits_counter';
import { formatNumWithCommas } from '../../../kibana-integrations/discover/application/helpers';
import useSearchBar from '../search-bar/use-search-bar';
import { search } from '../search-bar';
import { getPlugins } from '../../../kibana-services';
import { getDiscoverPanels, histogramChartInput } from './config/histogram-chart';
import { histogramChartInput } from './config/histogram-chart';
import { useDockedSideNav } from '../hooks/useDockedSideNav'
const DashboardByRenderer = getPlugins().dashboard.DashboardContainerByValueRenderer;
import './discover.scss';

Expand All @@ -43,12 +43,14 @@ type WazuhDiscoverProps = {

const WazuhDiscover = (props: WazuhDiscoverProps) => {
const { indexPatternName, tableColumns: defaultTableColumns } = props
const [sidebarDocked, setSidebarDocked] = useState<boolean>(false);
const SearchBar = getPlugins().data.ui.SearchBar;
const [results, setResults] = useState<SearchResponse>({} as SearchResponse);
const [inspectedHit, setInspectedHit] = useState<any>(undefined);
const [indexPattern, setIndexPattern] = useState<IndexPattern | undefined>(undefined);
const [isSearching, setIsSearching] = useState<boolean>(false);
const [isExporting, setIsExporting] = useState<boolean>(false);
const sideNavDocked = useDockedSideNav();

const onClickInspectDoc = useMemo(() => (index: number) => {
const rowClicked = results.hits.hits[index];
Expand Down Expand Up @@ -179,6 +181,7 @@ const WazuhDiscover = (props: WazuhDiscoverProps) => {
<div className="discoverDataGrid">
<EuiDataGrid
{...dataGridProps}
className={sideNavDocked ? 'dataGridDockedNav' : ''}
toolbarVisibility={{
additionalControls: (
<>
Expand Down Expand Up @@ -231,6 +234,6 @@ const WazuhDiscover = (props: WazuhDiscoverProps) => {
</EuiPageTemplate>
</IntlProvider >
);
}
};

export default WazuhDiscover;
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { LoadingSpinner } from '../../common/components/loading_spinner';
// common components/hooks
import DocViewer from '../../../../common/doc-viewer/doc-viewer';
import useSearchBar from '../../../../common/search-bar/use-search-bar';
import { useAppConfig } from '../../../../common/hooks';
import { useAppConfig, useDockedSideNav } from '../../../../common/hooks';
import { useDataGrid } from '../../../../common/data-grid/use-data-grid';
import { useDocViewer } from '../../../../common/doc-viewer/use-doc-viewer';
import { withErrorBoundary } from '../../../../common/hocs';
Expand All @@ -56,6 +56,7 @@ const InventoryVulsComponent = () => {
);
const [isSearching, setIsSearching] = useState<boolean>(false);
const [isExporting, setIsExporting] = useState<boolean>(false);
const sideNavDocked = useDockedSideNav();

const onClickInspectDoc = useMemo(
() => (index: number) => {
Expand Down Expand Up @@ -198,6 +199,7 @@ const InventoryVulsComponent = () => {
isSuccess &&
results?.hits?.total > 0 ? (
<EuiDataGrid
className={sideNavDocked ? 'dataGridDockedNav' : ''}
{...dataGridProps}
toolbarVisibility={{
additionalControls: (
Expand Down
5 changes: 2 additions & 3 deletions plugins/main/public/styles/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1777,9 +1777,8 @@ iframe.width-changed {

/* OSD Data grid full screen with dock navigation left sidebar */


.euiDataGrid__restrictBody.euiBody--hasFlyout {
.euiDataGrid--fullScreen {
.dataGridDockedNav {
&.euiDataGrid--fullScreen {
left: 320px;

.euiDataGrid__virtualized {
Expand Down

0 comments on commit 08775dc

Please sign in to comment.