mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: David Sánchez <davidsansol92@gmail.com>
This commit is contained in:
parent
a5fa683afc
commit
c5896807b5
3 changed files with 30 additions and 7 deletions
|
@ -120,15 +120,34 @@ export const CreateTrustedAppFlyout = memo<CreateTrustedAppFlyoutProps>(
|
|||
'trustedAppsByPolicyEnabled'
|
||||
);
|
||||
|
||||
const [wasByPolicy, setWasByPolicy] = useState(!isGlobalEffectScope(formValues.effectScope));
|
||||
// set initial state of `wasByPolicy` that checks if the initial state of the exception was by policy or not
|
||||
useEffect(() => {
|
||||
if (!isFormDirty && formValues.effectScope) {
|
||||
setWasByPolicy(!isGlobalEffectScope(formValues.effectScope));
|
||||
}
|
||||
}, [isFormDirty, formValues.effectScope]);
|
||||
|
||||
const isGlobal = useMemo(() => {
|
||||
return isGlobalEffectScope((formValues as NewTrustedApp).effectScope);
|
||||
}, [formValues]);
|
||||
|
||||
const showExpiredLicenseBanner = useMemo(() => {
|
||||
return (
|
||||
isTrustedAppsByPolicyEnabled && !isPlatinumPlus && isEditMode && (!isGlobal || isFormDirty)
|
||||
isTrustedAppsByPolicyEnabled &&
|
||||
!isPlatinumPlus &&
|
||||
isEditMode &&
|
||||
wasByPolicy &&
|
||||
(!isGlobal || isFormDirty)
|
||||
);
|
||||
}, [isTrustedAppsByPolicyEnabled, isPlatinumPlus, isEditMode, isGlobal, isFormDirty]);
|
||||
}, [
|
||||
isTrustedAppsByPolicyEnabled,
|
||||
isPlatinumPlus,
|
||||
isEditMode,
|
||||
isGlobal,
|
||||
isFormDirty,
|
||||
wasByPolicy,
|
||||
]);
|
||||
|
||||
// If there was a failure trying to retrieve the Trusted App for edit item,
|
||||
// then redirect back to the list ++ show toast message.
|
||||
|
@ -197,7 +216,7 @@ export const CreateTrustedAppFlyout = memo<CreateTrustedAppFlyoutProps>(
|
|||
id="xpack.securitySolution.trustedapps.createTrustedAppFlyout.expiredLicenseMessage"
|
||||
defaultMessage="Your Kibana license has been downgraded. Future policy configurations will now be globally assigned to all policies. For more information, see our "
|
||||
/>
|
||||
<EuiLink external href={`${docLinks.links.securitySolution.trustedApps}`}>
|
||||
<EuiLink target="_blank" href={`${docLinks.links.securitySolution.trustedApps}`}>
|
||||
<FormattedMessage
|
||||
id="xpack.securitySolution.trustedapps.docsLink"
|
||||
defaultMessage="Trusted applications documentation."
|
||||
|
@ -228,6 +247,7 @@ export const CreateTrustedAppFlyout = memo<CreateTrustedAppFlyoutProps>(
|
|||
isInvalid={!!creationErrors}
|
||||
isEditMode={isEditMode}
|
||||
isDirty={isFormDirty}
|
||||
wasByPolicy={wasByPolicy}
|
||||
error={creationErrorsMessage}
|
||||
policies={policies}
|
||||
trustedApp={formValues}
|
||||
|
|
|
@ -136,6 +136,7 @@ describe('When using the Trusted App Form', () => {
|
|||
trustedApp: latestUpdatedTrustedApp,
|
||||
isEditMode: false,
|
||||
isDirty: false,
|
||||
wasByPolicy: false,
|
||||
onChange: jest.fn((updates) => {
|
||||
latestUpdatedTrustedApp = updates.item;
|
||||
}),
|
||||
|
|
|
@ -216,6 +216,7 @@ export type CreateTrustedAppFormProps = Pick<
|
|||
trustedApp: MaybeImmutable<NewTrustedApp>;
|
||||
isEditMode: boolean;
|
||||
isDirty: boolean;
|
||||
wasByPolicy: boolean;
|
||||
onChange: (state: TrustedAppFormState) => void;
|
||||
/** Setting passed on to the EffectedPolicySelect component */
|
||||
policies: Pick<EffectedPolicySelectProps, 'options' | 'isLoading'>;
|
||||
|
@ -227,6 +228,7 @@ export const CreateTrustedAppForm = memo<CreateTrustedAppFormProps>(
|
|||
fullWidth,
|
||||
isEditMode,
|
||||
isDirty,
|
||||
wasByPolicy,
|
||||
onChange,
|
||||
trustedApp: _trustedApp,
|
||||
policies = { options: [] },
|
||||
|
@ -246,9 +248,9 @@ export const CreateTrustedAppForm = memo<CreateTrustedAppFormProps>(
|
|||
return isGlobalEffectScope(trustedApp.effectScope);
|
||||
}, [trustedApp]);
|
||||
|
||||
const hideAssignmentSection = useMemo(() => {
|
||||
return !isPlatinumPlus && (!isEditMode || (isGlobal && !isDirty));
|
||||
}, [isEditMode, isGlobal, isDirty, isPlatinumPlus]);
|
||||
const showAssignmentSection = useMemo(() => {
|
||||
return isPlatinumPlus || (isEditMode && (!isGlobal || (wasByPolicy && isGlobal && isDirty)));
|
||||
}, [isEditMode, isGlobal, isDirty, isPlatinumPlus, wasByPolicy]);
|
||||
|
||||
const osOptions: Array<EuiSuperSelectOption<OperatingSystem>> = useMemo(
|
||||
() => OPERATING_SYSTEMS.map((os) => ({ value: os, inputDisplay: OS_TITLES[os] })),
|
||||
|
@ -575,7 +577,7 @@ export const CreateTrustedAppForm = memo<CreateTrustedAppFormProps>(
|
|||
data-test-subj={getTestId('conditionsBuilder')}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
{isTrustedAppsByPolicyEnabled && !hideAssignmentSection ? (
|
||||
{isTrustedAppsByPolicyEnabled && showAssignmentSection ? (
|
||||
<>
|
||||
<EuiHorizontalRule />
|
||||
<EuiFormRow fullWidth={fullWidth} data-test-subj={getTestId('policySelection')}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue