mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Security Solution][Exceptions] - Make exceptions read only when displaying deleted rule details (#142258) (#142387)
### Summary
Addresses 141899.
(cherry picked from commit f415b3b98f
)
Co-authored-by: Yara Tercero <yctercero@users.noreply.github.com>
This commit is contained in:
parent
09e0fe85a8
commit
f5dbe3a8c6
4 changed files with 14 additions and 3 deletions
|
@ -109,6 +109,7 @@ describe('ExceptionsViewer', () => {
|
|||
],
|
||||
}}
|
||||
listType={ExceptionListTypeEnum.DETECTION}
|
||||
isViewReadOnly={false}
|
||||
/>
|
||||
</TestProviders>
|
||||
);
|
||||
|
@ -146,6 +147,7 @@ describe('ExceptionsViewer', () => {
|
|||
],
|
||||
}}
|
||||
listType={ExceptionListTypeEnum.DETECTION}
|
||||
isViewReadOnly={false}
|
||||
/>
|
||||
</TestProviders>
|
||||
);
|
||||
|
@ -183,6 +185,7 @@ describe('ExceptionsViewer', () => {
|
|||
],
|
||||
}}
|
||||
listType={ExceptionListTypeEnum.ENDPOINT}
|
||||
isViewReadOnly={false}
|
||||
/>
|
||||
</TestProviders>
|
||||
);
|
||||
|
@ -226,6 +229,7 @@ describe('ExceptionsViewer', () => {
|
|||
],
|
||||
}}
|
||||
listType={ExceptionListTypeEnum.DETECTION}
|
||||
isViewReadOnly={false}
|
||||
/>
|
||||
</TestProviders>
|
||||
);
|
||||
|
@ -268,6 +272,7 @@ describe('ExceptionsViewer', () => {
|
|||
],
|
||||
}}
|
||||
listType={ExceptionListTypeEnum.DETECTION}
|
||||
isViewReadOnly={false}
|
||||
/>
|
||||
);
|
||||
|
||||
|
@ -301,6 +306,7 @@ describe('ExceptionsViewer', () => {
|
|||
],
|
||||
}}
|
||||
listType={ExceptionListTypeEnum.DETECTION}
|
||||
isViewReadOnly={false}
|
||||
/>
|
||||
);
|
||||
|
||||
|
|
|
@ -75,12 +75,15 @@ export interface GetExceptionItemProps {
|
|||
interface ExceptionsViewerProps {
|
||||
rule: Rule | null;
|
||||
listType: ExceptionListTypeEnum;
|
||||
/* Used for when displaying exceptions for a rule that has since been deleted, forcing read only view */
|
||||
isViewReadOnly: boolean;
|
||||
onRuleChange?: () => void;
|
||||
}
|
||||
|
||||
const ExceptionsViewerComponent = ({
|
||||
rule,
|
||||
listType,
|
||||
isViewReadOnly,
|
||||
onRuleChange,
|
||||
}: ExceptionsViewerProps): JSX.Element => {
|
||||
const { services } = useKibana();
|
||||
|
@ -337,8 +340,8 @@ const ExceptionsViewerComponent = ({
|
|||
|
||||
// User privileges checks
|
||||
useEffect((): void => {
|
||||
setReadOnly(!canUserCRUD || !hasIndexWrite);
|
||||
}, [setReadOnly, canUserCRUD, hasIndexWrite]);
|
||||
setReadOnly(isViewReadOnly || !canUserCRUD || !hasIndexWrite);
|
||||
}, [setReadOnly, isViewReadOnly, canUserCRUD, hasIndexWrite]);
|
||||
|
||||
useEffect(() => {
|
||||
if (exceptionListsToQuery.length > 0) {
|
||||
|
|
|
@ -157,7 +157,7 @@ export const referenceErrorMessage = (referenceCount: number) =>
|
|||
export const EXCEPTION_LIST_SEARCH_PLACEHOLDER = i18n.translate(
|
||||
'xpack.securitySolution.detectionEngine.rules.all.exceptions.searchPlaceholder',
|
||||
{
|
||||
defaultMessage: 'Search by name or list_id',
|
||||
defaultMessage: 'Search by name or list id',
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -871,6 +871,7 @@ const RuleDetailsPageComponent: React.FC<DetectionEngineComponentProps> = ({
|
|||
rule={rule}
|
||||
listType={ExceptionListTypeEnum.DETECTION}
|
||||
onRuleChange={refreshRule}
|
||||
isViewReadOnly={!isExistingRule}
|
||||
data-test-subj="exceptionTab"
|
||||
/>
|
||||
</Route>
|
||||
|
@ -881,6 +882,7 @@ const RuleDetailsPageComponent: React.FC<DetectionEngineComponentProps> = ({
|
|||
rule={rule}
|
||||
listType={ExceptionListTypeEnum.ENDPOINT}
|
||||
onRuleChange={refreshRule}
|
||||
isViewReadOnly={!isExistingRule}
|
||||
data-test-subj="endpointExceptionsTab"
|
||||
/>
|
||||
</Route>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue