Skip to content

Commit

Permalink
[Security Solution] ensure that license is preserved when loading pol…
Browse files Browse the repository at this point in the history
…icy details (#87780)
  • Loading branch information
kevinlog authored Jan 11, 2021
1 parent f384c48 commit 379f9c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { fullPolicy, isOnPolicyDetailsPage } from './selectors';
import { fullPolicy, isOnPolicyDetailsPage, license } from './selectors';
import {
Immutable,
PolicyConfig,
Expand Down Expand Up @@ -45,7 +45,6 @@ export const initialPolicyDetailsState: () => Immutable<PolicyDetailsState> = ()
total: 0,
other: 0,
},
license: undefined,
});

export const policyDetailsReducer: ImmutableReducer<PolicyDetailsState, AppAction> = (
Expand Down Expand Up @@ -108,6 +107,7 @@ export const policyDetailsReducer: ImmutableReducer<PolicyDetailsState, AppActio
};
const isCurrentlyOnDetailsPage = isOnPolicyDetailsPage(newState);
const wasPreviouslyOnDetailsPage = isOnPolicyDetailsPage(state);
const currentLicense = license(newState);

if (isCurrentlyOnDetailsPage) {
// Did user just enter the Detail page? if so, then
Expand All @@ -126,6 +126,7 @@ export const policyDetailsReducer: ImmutableReducer<PolicyDetailsState, AppActio
return {
...initialPolicyDetailsState(),
location: action.payload,
license: currentLicense,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ export const isOnPolicyDetailsPage = (state: Immutable<PolicyDetailsState>) => {
);
};

/** Returns the license info fetched from the license service */
export const license = (state: Immutable<PolicyDetailsState>) => {
return state.license;
};

/** Returns the policyId from the url */
export const policyIdFromParams: (state: Immutable<PolicyDetailsState>) => string = createSelector(
(state) => state.location,
Expand Down

0 comments on commit 379f9c9

Please sign in to comment.