forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution] Remove warning for rule filter (elastic#201776)
**Resolves: elastic#178908** ## Summary This PR fixes a warning displayed for the rule when certain filter is present. I followed the suggestion from @nikitaindik in the original ticket and pulled his fix and tested that it works, but it also needed some modification borrowed from QueryBar component, namely to update the filters before displaying the FilterItems component. Note: This PR only covers the Rule Creation / Rules Details page. Two new tickets have been created to cover issues found in other places: elastic#203600 and elastic#203615 # BEFORE <img width="899" alt="image" src="https://github.com/user-attachments/assets/62b300b4-bc70-481f-8042-dc9d7c4b3ff0"> # AFTER <img width="901" alt="image" src="https://github.com/user-attachments/assets/6c2915f8-e2e1-477d-bf6c-4ededf1a6907"> ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] [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 - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed --------- Co-authored-by: Nikita Indik <[email protected]> (cherry picked from commit 2e3a748) # Conflicts: # x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx # x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_edit/fields/hooks/use_data_view.ts
- Loading branch information
Showing
2 changed files
with
89 additions
and
12 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
60 changes: 60 additions & 0 deletions
60
...anagement/components/rule_details/three_way_diff/final_edit/fields/hooks/use_data_view.ts
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,60 @@ | ||
/* | ||
* 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 { useEffect, useState } from 'react'; | ||
import type { DataView } from '@kbn/data-views-plugin/common'; | ||
import { useKibana } from '../../../../../../../../common/lib/kibana'; | ||
|
||
export type UseDataViewParams = | ||
| { indexPatterns: string[]; dataViewId?: never } | ||
| { indexPatterns?: never; dataViewId: string }; | ||
|
||
interface UseDataViewResult { | ||
dataView: DataView | undefined; | ||
isLoading: boolean; | ||
} | ||
|
||
export function useDataView(indexPatternsOrDataViewId: UseDataViewParams): UseDataViewResult { | ||
const { | ||
data: { dataViews: dataViewsService }, | ||
} = useKibana().services; | ||
const [dataView, setDataView] = useState<DataView | undefined>(); | ||
const [isLoading, setIsLoading] = useState(false); | ||
|
||
useEffect(() => { | ||
setIsLoading(true); | ||
|
||
(async () => { | ||
try { | ||
if (indexPatternsOrDataViewId.indexPatterns) { | ||
const indexPatternsDataView = await dataViewsService.create({ | ||
title: indexPatternsOrDataViewId.indexPatterns.join(','), | ||
id: indexPatternsOrDataViewId.indexPatterns.join(','), | ||
allowNoIndex: true, | ||
}); | ||
|
||
setDataView(indexPatternsDataView); | ||
return; | ||
} | ||
|
||
if (indexPatternsOrDataViewId.dataViewId) { | ||
const ruleDataView = await dataViewsService.get(indexPatternsOrDataViewId.dataViewId); | ||
|
||
setDataView(ruleDataView); | ||
} | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
})(); | ||
}, [ | ||
dataViewsService, | ||
indexPatternsOrDataViewId.indexPatterns, | ||
indexPatternsOrDataViewId.dataViewId, | ||
]); | ||
|
||
return { dataView, isLoading }; | ||
} |