Skip to content

Commit 7c0922d

Browse files
efegurkankertal
authored andcommitted
[Bug] [Query Rules] Save button disable condition not working when a rule deleted (elastic#227000)
## Summary Fixes the conditional that caused save button to be disabled when a rule is deleted https://github.com/user-attachments/assets/73ddd46e-3402-4d12-866c-98e58b9a48ab ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels.
1 parent b92cc50 commit 7c0922d

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

x-pack/solutions/search/plugins/search_query_rules/public/components/query_ruleset_detail/query_rule_detail_panel.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,12 @@ export const QueryRuleDetailPanel: React.FC<QueryRuleDetailPanelProps> = ({
144144
setRuleIdToEdit(ruleId);
145145
}}
146146
tourInfo={tourInfo}
147-
deleteRule={deleteRule}
147+
deleteRule={(ruleId: string) => {
148+
if (setIsFormDirty) {
149+
setIsFormDirty(true);
150+
}
151+
deleteRule?.(ruleId);
152+
}}
148153
/>
149154
)}
150155
</EuiFlexItem>

x-pack/solutions/search/plugins/search_query_rules/public/components/query_ruleset_detail/query_rule_draggable_list/delete_ruleset_rule_modal.tsx

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77

88
import React, { useState } from 'react';
99

10-
import { EuiCheckbox, EuiConfirmModal, EuiSpacer, useGeneratedHtmlId } from '@elastic/eui';
10+
import { EuiConfirmModal, EuiText } from '@elastic/eui';
1111
import { i18n } from '@kbn/i18n';
12+
import { FormattedMessage } from '@kbn/i18n-react';
1213

1314
export interface DeleteRulesetRuleModalProps {
1415
closeDeleteModal: () => void;
@@ -27,10 +28,6 @@ export const DeleteRulesetRuleModal = ({
2728
onSuccessAction();
2829
}
2930
};
30-
const confirmCheckboxId = useGeneratedHtmlId({
31-
prefix: 'confirmCheckboxId',
32-
});
33-
const [checked, setChecked] = useState(false);
3431

3532
const deleteOperation = () => {
3633
setIsLoading(true);
@@ -50,19 +47,17 @@ export const DeleteRulesetRuleModal = ({
5047
confirmButtonText={i18n.translate('xpack.queryRules.deleteRulesetRuleModal.confirmButton', {
5148
defaultMessage: 'Delete rule',
5249
})}
53-
confirmButtonDisabled={checked === false}
5450
buttonColor="danger"
5551
isLoading={isLoading}
5652
>
57-
<EuiSpacer size="m" />
58-
<EuiCheckbox
59-
id={confirmCheckboxId}
60-
label="This rule is safe to delete"
61-
checked={checked}
62-
onChange={(e) => {
63-
setChecked(e.target.checked);
64-
}}
65-
/>
53+
<EuiText size="s">
54+
<p>
55+
<FormattedMessage
56+
id="xpack.queryRules.deleteRulesetRuleModal.description"
57+
defaultMessage="Are you sure you want to delete this rule?"
58+
/>
59+
</p>
60+
</EuiText>
6661
</EuiConfirmModal>
6762
);
6863
};

0 commit comments

Comments
 (0)