[Security Solution] Fix edit not working due to state management overwrite in Host isolation exceptions (#116676)

* Fix edit not working due to state management overwrite

* clear the form after a succesfull update

* Preserve order after editing and adding
This commit is contained in:
Esteban Beltran 2021-10-29 23:01:14 +02:00 committed by GitHub
parent 7130d6eb45
commit 5afa164ab9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 3 deletions

View file

@ -42,8 +42,8 @@ export async function getHostIsolationExceptionItems({
http,
perPage,
page,
sortField,
sortOrder,
sortField = 'created_at',
sortOrder = 'desc',
filter,
}: {
http: HttpStart;

View file

@ -239,10 +239,18 @@ async function updateHostIsolationExceptionsItem(
http,
entry
);
// notify the update was correct
dispatch({
type: 'hostIsolationExceptionsFormStateChanged',
payload: createLoadedResourceState(response),
});
// clear the form
dispatch({
type: 'hostIsolationExceptionsFormEntryChanged',
payload: undefined,
});
} catch (error) {
dispatch({
type: 'hostIsolationExceptionsFormStateChanged',

View file

@ -94,7 +94,7 @@ export const HostIsolationExceptionsFormFlyout: React.FC<{}> = memo(() => {
type: 'hostIsolationExceptionsMarkToEdit',
payload: { id: location.id },
});
} else {
} else if (exception === undefined) {
setException(exceptionToEdit);
}
}