mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
# Backport This will backport the following commits from `main` to `8.16`: - [[Security Solution] Implement refactoring remark from PR #201731 (#204022)](https://github.com/elastic/kibana/pull/204022) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Jacek Kolezynski","email":"jacek.kolezynski@elastic.co"},"sourceCommit":{"committedDate":"2025-01-08T14:01:47Z","message":"[Security Solution] Implement refactoring remark from PR #201731 (#204022)\n\n## Summary\n\nIn the PR #201731 for ticket #180660 @banderror advised to refactor code\nin that PR to better separate the concerns (business logic from\ncomponents). This is the implementation of that review\n[remark](471a0986
-bcdb-4611-ab1a-bdcbe5151f47\n\n---------\n\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>\nCo-authored-by: Nikita Indik <nikita.indik@elastic.co>","sha":"20eb87d778a69b6b0d7132732cbea9cce44e895c","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["refactoring","release_note:skip","v9.0.0","Team:Detections and Resp","Team: SecuritySolution","Team:Detection Rule Management","Feature:Prebuilt Detection Rules","ci:cloud-deploy","ci:project-deploy-security","backport:version","v8.18.0","v8.16.3","v8.17.1"],"title":"[Security Solution] Implement refactoring remark from PR #201731","number":204022,"url":"https://github.com/elastic/kibana/pull/204022","mergeCommit":{"message":"[Security Solution] Implement refactoring remark from PR #201731 (#204022)\n\n## Summary\n\nIn the PR #201731 for ticket #180660 @banderror advised to refactor code\nin that PR to better separate the concerns (business logic from\ncomponents). This is the implementation of that review\n[remark](471a0986
-bcdb-4611-ab1a-bdcbe5151f47\n\n---------\n\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>\nCo-authored-by: Nikita Indik <nikita.indik@elastic.co>","sha":"20eb87d778a69b6b0d7132732cbea9cce44e895c"}},"sourceBranch":"main","suggestedTargetBranches":["8.x","8.16","8.17"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/204022","number":204022,"mergeCommit":{"message":"[Security Solution] Implement refactoring remark from PR #201731 (#204022)\n\n## Summary\n\nIn the PR #201731 for ticket #180660 @banderror advised to refactor code\nin that PR to better separate the concerns (business logic from\ncomponents). This is the implementation of that review\n[remark](471a0986
-bcdb-4611-ab1a-bdcbe5151f47\n\n---------\n\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>\nCo-authored-by: Nikita Indik <nikita.indik@elastic.co>","sha":"20eb87d778a69b6b0d7132732cbea9cce44e895c"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.16","label":"v8.16.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.17","label":"v8.17.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Jacek Kolezynski <jacek.kolezynski@elastic.co>
This commit is contained in:
parent
2e63133937
commit
6114bd84de
4 changed files with 22 additions and 29 deletions
|
@ -25,10 +25,9 @@ export const AddPrebuiltRulesHeaderButtons = () => {
|
|||
const {
|
||||
state: {
|
||||
selectedRules,
|
||||
loadingRules,
|
||||
isRefetching,
|
||||
isUpgradingSecurityPackages,
|
||||
isInstallingAllRules,
|
||||
isAnyRuleInstalling,
|
||||
hasRulesToInstall,
|
||||
},
|
||||
actions: { installAllRules, installSelectedRules },
|
||||
|
@ -39,8 +38,7 @@ export const AddPrebuiltRulesHeaderButtons = () => {
|
|||
const numberOfSelectedRules = selectedRules.length ?? 0;
|
||||
const shouldDisplayInstallSelectedRulesButton = numberOfSelectedRules > 0;
|
||||
|
||||
const isRuleInstalling = loadingRules.length > 0 || isInstallingAllRules;
|
||||
const isRequestInProgress = isRuleInstalling || isRefetching || isUpgradingSecurityPackages;
|
||||
const isRequestInProgress = isAnyRuleInstalling || isRefetching || isUpgradingSecurityPackages;
|
||||
|
||||
const [isOverflowPopoverOpen, setOverflowPopover] = useBoolean(false);
|
||||
|
||||
|
@ -81,7 +79,7 @@ export const AddPrebuiltRulesHeaderButtons = () => {
|
|||
data-test-subj="installSelectedRulesButton"
|
||||
>
|
||||
{i18n.INSTALL_SELECTED_RULES(numberOfSelectedRules)}
|
||||
{isRuleInstalling && <EuiLoadingSpinner size="s" />}
|
||||
{isAnyRuleInstalling && <EuiLoadingSpinner size="s" />}
|
||||
</EuiButton>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
|
@ -116,7 +114,7 @@ export const AddPrebuiltRulesHeaderButtons = () => {
|
|||
aria-label={i18n.INSTALL_ALL_ARIA_LABEL}
|
||||
>
|
||||
{i18n.INSTALL_ALL}
|
||||
{isRuleInstalling && <EuiLoadingSpinner size="s" />}
|
||||
{isAnyRuleInstalling && <EuiLoadingSpinner size="s" />}
|
||||
</EuiButton>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
|
|
|
@ -19,7 +19,10 @@ import React, { useCallback, useMemo } from 'react';
|
|||
import { useBoolean } from 'react-use';
|
||||
import type { Rule } from '../../../../rule_management/logic';
|
||||
import type { RuleSignatureId } from '../../../../../../common/api/detection_engine';
|
||||
import { type AddPrebuiltRulesTableActions } from './add_prebuilt_rules_table_context';
|
||||
import {
|
||||
useAddPrebuiltRulesTableContext,
|
||||
type AddPrebuiltRulesTableActions,
|
||||
} from './add_prebuilt_rules_table_context';
|
||||
import * as i18n from './translations';
|
||||
|
||||
export interface PrebuiltRulesInstallButtonProps {
|
||||
|
@ -28,7 +31,6 @@ export interface PrebuiltRulesInstallButtonProps {
|
|||
installOneRule: AddPrebuiltRulesTableActions['installOneRule'];
|
||||
loadingRules: RuleSignatureId[];
|
||||
isDisabled: boolean;
|
||||
isInstallingAllRules: boolean;
|
||||
}
|
||||
|
||||
export const PrebuiltRulesInstallButton = ({
|
||||
|
@ -37,8 +39,10 @@ export const PrebuiltRulesInstallButton = ({
|
|||
installOneRule,
|
||||
loadingRules,
|
||||
isDisabled,
|
||||
isInstallingAllRules,
|
||||
}: PrebuiltRulesInstallButtonProps) => {
|
||||
const {
|
||||
state: { isInstallingAllRules },
|
||||
} = useAddPrebuiltRulesTableContext();
|
||||
const isRuleInstalling = loadingRules.includes(ruleId) || isInstallingAllRules;
|
||||
const isInstallButtonDisabled = isRuleInstalling || isDisabled;
|
||||
const [isPopoverOpen, setPopover] = useBoolean(false);
|
||||
|
|
|
@ -61,11 +61,14 @@ export interface AddPrebuiltRulesTableState {
|
|||
* package in background
|
||||
*/
|
||||
isUpgradingSecurityPackages: boolean;
|
||||
|
||||
/**
|
||||
* Is true when performing Install All Rules mutation
|
||||
*/
|
||||
isInstallingAllRules: boolean;
|
||||
/**
|
||||
* Is true when any rule is currently being installed
|
||||
*/
|
||||
isAnyRuleInstalling: boolean;
|
||||
/**
|
||||
* List of rule IDs that are currently being upgraded
|
||||
*/
|
||||
|
@ -145,6 +148,8 @@ export const AddPrebuiltRulesTableContextProvider = ({
|
|||
}),
|
||||
});
|
||||
|
||||
const isAnyRuleInstalling = loadingRules.length > 0 || isInstallingAllRules;
|
||||
|
||||
const { mutateAsync: installAllRulesRequest } = usePerformInstallAllRules();
|
||||
const { mutateAsync: installSpecificRulesRequest } = usePerformInstallSpecificRules();
|
||||
|
||||
|
@ -281,6 +286,7 @@ export const AddPrebuiltRulesTableContextProvider = ({
|
|||
isRefetching,
|
||||
isUpgradingSecurityPackages,
|
||||
isInstallingAllRules,
|
||||
isAnyRuleInstalling,
|
||||
selectedRules,
|
||||
lastUpdated: dataUpdatedAt,
|
||||
},
|
||||
|
@ -297,6 +303,7 @@ export const AddPrebuiltRulesTableContextProvider = ({
|
|||
isRefetching,
|
||||
isUpgradingSecurityPackages,
|
||||
isInstallingAllRules,
|
||||
isAnyRuleInstalling,
|
||||
selectedRules,
|
||||
dataUpdatedAt,
|
||||
actions,
|
||||
|
|
|
@ -110,8 +110,7 @@ const INTEGRATIONS_COLUMN: TableColumn = {
|
|||
const createInstallButtonColumn = (
|
||||
installOneRule: AddPrebuiltRulesTableActions['installOneRule'],
|
||||
loadingRules: RuleSignatureId[],
|
||||
isDisabled: boolean,
|
||||
isInstallingAllRules: boolean
|
||||
isDisabled: boolean
|
||||
): TableColumn => ({
|
||||
field: 'rule_id',
|
||||
name: <RulesTableEmptyColumnName name={i18n.INSTALL_RULE_BUTTON} />,
|
||||
|
@ -122,7 +121,6 @@ const createInstallButtonColumn = (
|
|||
installOneRule={installOneRule}
|
||||
loadingRules={loadingRules}
|
||||
isDisabled={isDisabled}
|
||||
isInstallingAllRules={isInstallingAllRules}
|
||||
/>
|
||||
),
|
||||
width: '10%',
|
||||
|
@ -166,23 +164,9 @@ export const useAddPrebuiltRulesTableColumns = (): TableColumn[] => {
|
|||
width: '12%',
|
||||
},
|
||||
...(hasCRUDPermissions
|
||||
? [
|
||||
createInstallButtonColumn(
|
||||
installOneRule,
|
||||
loadingRules,
|
||||
isDisabled,
|
||||
isInstallingAllRules
|
||||
),
|
||||
]
|
||||
? [createInstallButtonColumn(installOneRule, loadingRules, isDisabled)]
|
||||
: []),
|
||||
],
|
||||
[
|
||||
hasCRUDPermissions,
|
||||
installOneRule,
|
||||
loadingRules,
|
||||
isDisabled,
|
||||
showRelatedIntegrations,
|
||||
isInstallingAllRules,
|
||||
]
|
||||
[hasCRUDPermissions, installOneRule, loadingRules, isDisabled, showRelatedIntegrations]
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue