-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: unify message related to error fetching data of data source
- Loading branch information
Showing
18 changed files
with
260 additions
and
249 deletions.
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
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
131 changes: 68 additions & 63 deletions
131
plugins/main/public/components/overview/github/panel/config/drilldown-data-grid.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 |
---|---|---|
@@ -1,77 +1,82 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { EuiFlexItem } from '@elastic/eui'; | ||
import { ModuleConfigProps } from './module-config'; | ||
import { ErrorFactory, HttpError, ErrorHandler } from '../../../../../react-services/error-management'; | ||
import { | ||
ErrorFactory, | ||
HttpError, | ||
ErrorHandler, | ||
} from '../../../../../react-services/error-management'; | ||
import WazuhDataGrid from '../../../../common/wazuh-data-grid/wz-data-grid'; | ||
import { tDataGridColumn } from '../../../../common/data-grid'; | ||
|
||
type tDrillDownDataGridProps = { | ||
defaultTableColumns: tDataGridColumn[] | ||
defaultTableColumns: tDataGridColumn[]; | ||
} & ModuleConfigProps; | ||
|
||
export default function DrillDownDataGrid(props: tDrillDownDataGridProps) { | ||
const [results, setResults] = useState<any>([]); | ||
const [pagination, setPagination] = useState({ | ||
pageIndex: 0, | ||
pageSize: 15, | ||
pageSizeOptions: [15, 25, 50, 100], | ||
}) | ||
const [sorting, setSorting] = useState<any[]>([]); | ||
const [results, setResults] = useState<any>([]); | ||
const [pagination, setPagination] = useState({ | ||
pageIndex: 0, | ||
pageSize: 15, | ||
pageSizeOptions: [15, 25, 50, 100], | ||
}); | ||
const [sorting, setSorting] = useState<any[]>([]); | ||
|
||
const { | ||
fetchData, | ||
searchBarProps, | ||
indexPattern, | ||
fetchFilters, | ||
defaultTableColumns, | ||
} = props; | ||
const { | ||
fetchData, | ||
searchBarProps, | ||
indexPattern, | ||
fetchFilters, | ||
defaultTableColumns, | ||
} = props; | ||
|
||
useEffect(() => { | ||
if (!indexPattern) { | ||
return; | ||
} | ||
fetchData({ | ||
query: searchBarProps.query, | ||
filters: fetchFilters, | ||
pagination, | ||
sorting, | ||
dateRange: { | ||
from: searchBarProps.dateRangeFrom || '', | ||
to: searchBarProps.dateRangeTo || '', | ||
}, | ||
}) | ||
.then(results => { | ||
setResults(results); | ||
}) | ||
.catch(error => { | ||
const searchError = ErrorFactory.create(HttpError, { | ||
error, | ||
message: 'Error fetching actions', | ||
}); | ||
ErrorHandler.handleError(searchError); | ||
}); | ||
}, [ | ||
JSON.stringify(fetchFilters), | ||
JSON.stringify(searchBarProps.query), | ||
JSON.stringify(pagination), | ||
JSON.stringify(sorting), | ||
searchBarProps.dateRangeFrom, | ||
searchBarProps.dateRangeTo, | ||
]) | ||
useEffect(() => { | ||
if (!indexPattern) { | ||
return; | ||
} | ||
fetchData({ | ||
query: searchBarProps.query, | ||
filters: fetchFilters, | ||
pagination, | ||
sorting, | ||
dateRange: { | ||
from: searchBarProps.dateRangeFrom || '', | ||
to: searchBarProps.dateRangeTo || '', | ||
}, | ||
}) | ||
.then(results => { | ||
setResults(results); | ||
}) | ||
.catch(error => { | ||
const searchError = ErrorFactory.create(HttpError, { | ||
error, | ||
message: 'Error fetching data', | ||
}); | ||
ErrorHandler.handleError(searchError); | ||
}); | ||
}, [ | ||
JSON.stringify(fetchFilters), | ||
JSON.stringify(searchBarProps.query), | ||
JSON.stringify(pagination), | ||
JSON.stringify(sorting), | ||
searchBarProps.dateRangeFrom, | ||
searchBarProps.dateRangeTo, | ||
]); | ||
|
||
return ( | ||
<EuiFlexItem> | ||
<WazuhDataGrid | ||
results={results} | ||
defaultColumns={defaultTableColumns} | ||
indexPattern={indexPattern} | ||
isLoading={false} | ||
exportFilters={fetchFilters} | ||
defaultPagination={pagination} | ||
onChangePagination={(pagination) => setPagination(pagination)} | ||
onChangeSorting={(sorting) => { | ||
setSorting(sorting); | ||
}} | ||
/> | ||
</EuiFlexItem>); | ||
return ( | ||
<EuiFlexItem> | ||
<WazuhDataGrid | ||
results={results} | ||
defaultColumns={defaultTableColumns} | ||
indexPattern={indexPattern} | ||
isLoading={false} | ||
exportFilters={fetchFilters} | ||
defaultPagination={pagination} | ||
onChangePagination={pagination => setPagination(pagination)} | ||
onChangeSorting={sorting => { | ||
setSorting(sorting); | ||
}} | ||
/> | ||
</EuiFlexItem> | ||
); | ||
} |
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.