use locator in osquery plugin (#125698)

This commit is contained in:
Vadim Kibana 2022-02-15 20:23:11 +01:00 committed by GitHub
parent 7d186f945b
commit f0e5e2db05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View file

@ -18,14 +18,14 @@ export const useDiscoverLink = ({ filters }: UseDiscoverLink) => {
const {
application: { navigateToUrl },
} = useKibana().services;
const urlGenerator = useKibana().services.discover?.urlGenerator;
const locator = useKibana().services.discover?.locator;
const [discoverUrl, setDiscoverUrl] = useState<string>('');
useEffect(() => {
const getDiscoverUrl = async () => {
if (!urlGenerator?.createUrl) return;
if (!locator) return;
const newUrl = await urlGenerator.createUrl({
const newUrl = await locator.getUrl({
indexPatternId: 'logs-*',
filters: filters.map((filter) => ({
meta: {
@ -44,7 +44,7 @@ export const useDiscoverLink = ({ filters }: UseDiscoverLink) => {
setDiscoverUrl(newUrl);
};
getDiscoverUrl();
}, [filters, urlGenerator]);
}, [filters, locator]);
const onClick = useCallback(
(event: React.MouseEvent) => {

View file

@ -264,12 +264,12 @@ const ViewResultsInDiscoverActionComponent: React.FC<ViewResultsInDiscoverAction
endDate,
startDate,
}) => {
const urlGenerator = useKibana().services.discover?.urlGenerator;
const locator = useKibana().services.discover?.locator;
const [discoverUrl, setDiscoverUrl] = useState<string>('');
useEffect(() => {
const getDiscoverUrl = async () => {
if (!urlGenerator?.createUrl) return;
if (!locator) return;
const agentIdsQuery = agentIds?.length
? {
@ -280,7 +280,7 @@ const ViewResultsInDiscoverActionComponent: React.FC<ViewResultsInDiscoverAction
}
: null;
const newUrl = await urlGenerator.createUrl({
const newUrl = await locator.getUrl({
indexPatternId: 'logs-*',
filters: [
{
@ -334,7 +334,7 @@ const ViewResultsInDiscoverActionComponent: React.FC<ViewResultsInDiscoverAction
setDiscoverUrl(newUrl);
};
getDiscoverUrl();
}, [actionId, agentIds, endDate, startDate, urlGenerator]);
}, [actionId, agentIds, endDate, startDate, locator]);
if (buttonType === ViewResultsActionButtonType.button) {
return (