mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
# Backport This will backport the following commits from `main` to `8.6`: - [fix Exception lists are shared between different spaces (#146889)](https://github.com/elastic/kibana/pull/146889) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Wafaa Nasr","email":"wafaa.nasr@elastic.co"},"sourceCommit":{"committedDate":"2022-12-02T20:59:53Z","message":"fix Exception lists are shared between different spaces (#146889)\n\n## Summary\r\n\r\n- Addresses https://github.com/elastic/kibana/issues/146461 \r\n- Fix transition state when `Add to shared list is loading`","sha":"f677b3b135b9f2a93fb6d73ee24f2779edb92f39","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Security Solution Platform","backport:prev-minor","ci:cloud-deploy","v8.7.0"],"number":146889,"url":"https://github.com/elastic/kibana/pull/146889","mergeCommit":{"message":"fix Exception lists are shared between different spaces (#146889)\n\n## Summary\r\n\r\n- Addresses https://github.com/elastic/kibana/issues/146461 \r\n- Fix transition state when `Add to shared list is loading`","sha":"f677b3b135b9f2a93fb6d73ee24f2779edb92f39"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/146889","number":146889,"mergeCommit":{"message":"fix Exception lists are shared between different spaces (#146889)\n\n## Summary\r\n\r\n- Addresses https://github.com/elastic/kibana/issues/146461 \r\n- Fix transition state when `Add to shared list is loading`","sha":"f677b3b135b9f2a93fb6d73ee24f2779edb92f39"}}]}] BACKPORT--> Co-authored-by: Wafaa Nasr <wafaa.nasr@elastic.co>
This commit is contained in:
parent
e10d203951
commit
3372c87ea3
2 changed files with 14 additions and 14 deletions
|
@ -47,7 +47,6 @@ export const useAddToSharedListTable = ({
|
|||
onListSelectionChange,
|
||||
}: ExceptionsAddToListsComponentProps) => {
|
||||
const [listsToDisplay, setListsToDisplay] = useState<ExceptionListRuleReferencesSchema[]>([]);
|
||||
const [exceptionListReferences, setExceptionListReferences] = useState<RuleReferences>({});
|
||||
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||
|
||||
const listsToFetch = useMemo(() => {
|
||||
|
@ -68,28 +67,29 @@ export const useAddToSharedListTable = ({
|
|||
const getReferences = useCallback(async () => {
|
||||
try {
|
||||
setIsLoading(true);
|
||||
const result = await getExceptionItemsReferences(
|
||||
return getExceptionItemsReferences(
|
||||
(!listsToFetch.length
|
||||
? [{ namespace_type: 'single' }, { namespace_type: 'agnostic' }] // TODO remove 'agnostic' when using `single` only
|
||||
? [{ namespace_type: 'single' }]
|
||||
: listsToFetch) as ExceptionListSchema[]
|
||||
);
|
||||
setExceptionListReferences(result as RuleReferences);
|
||||
} catch (err) {
|
||||
setError(i18n.REFERENCES_FETCH_ERROR);
|
||||
}
|
||||
}, [listsToFetch]);
|
||||
|
||||
const fillListsToDisplay = useCallback(async () => {
|
||||
await getReferences();
|
||||
if (exceptionListReferences) {
|
||||
const lists: ExceptionListRuleReferencesSchema[] = [];
|
||||
for (const [_, value] of Object.entries(exceptionListReferences))
|
||||
if (value.type === ExceptionListTypeEnum.DETECTION) lists.push(value);
|
||||
|
||||
setListsToDisplay(lists);
|
||||
setIsLoading(false);
|
||||
const result = (await getReferences()) as RuleReferences;
|
||||
if (!result) {
|
||||
return setIsLoading(false);
|
||||
}
|
||||
}, [exceptionListReferences, getReferences]);
|
||||
const lists: ExceptionListRuleReferencesSchema[] = [];
|
||||
|
||||
for (const value of Object.values(result))
|
||||
if (value.type === ExceptionListTypeEnum.DETECTION) lists.push(value);
|
||||
|
||||
setListsToDisplay(lists);
|
||||
setIsLoading(false);
|
||||
}, [getReferences]);
|
||||
|
||||
useEffect(() => {
|
||||
fillListsToDisplay();
|
||||
|
|
|
@ -60,7 +60,7 @@ export const createSharedExceptionListRoute = (router: SecuritySolutionPluginRou
|
|||
listId: uuid.v4(),
|
||||
meta: undefined,
|
||||
name,
|
||||
namespaceType: 'agnostic',
|
||||
namespaceType: 'single',
|
||||
tags: [],
|
||||
type: 'detection',
|
||||
version: 1,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue