diff --git a/x-pack/plugins/observability/public/pages/rule_details/components/rule_detail_tabs.tsx b/x-pack/plugins/observability/public/pages/rule_details/components/rule_detail_tabs.tsx index 2a07c3beb83f5..81fbeeaa7d3dc 100644 --- a/x-pack/plugins/observability/public/pages/rule_details/components/rule_detail_tabs.tsx +++ b/x-pack/plugins/observability/public/pages/rule_details/components/rule_detail_tabs.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import React, { useEffect, useRef, useState } from 'react'; +import React, { useRef, useState } from 'react'; import { useHistory } from 'react-router-dom'; import { EuiFlexGroup, @@ -29,7 +29,6 @@ import { SEARCH_BAR_URL_STORAGE_KEY, TabId, } from '../rule_details'; -import { getDefaultAlertSummaryTimeRange } from '../../../utils/alert_summary_widget'; import { fromQuery, toQuery } from '../../../utils/url'; import { observabilityFeatureId } from '../../../../common'; @@ -40,6 +39,7 @@ interface RuleDetailTabsProps { ruleId: string; ruleType: RuleType | undefined; onChangeTab: (tabId: TabId) => void; + onChangeEsQuery: (bool: { bool: BoolQuery } | undefined) => void; } export function RuleDetailTabs({ @@ -49,6 +49,7 @@ export function RuleDetailTabs({ ruleId, ruleType, onChangeTab, + onChangeEsQuery, }: RuleDetailTabsProps) { const { triggersActionsUi: { @@ -64,13 +65,6 @@ export function RuleDetailTabs({ ]); const [esQuery, setEsQuery] = useState<{ bool: BoolQuery }>(); - const [alertSummaryWidgetTimeRange, setAlertSummaryWidgetTimeRange] = useState( - getDefaultAlertSummaryTimeRange - ); - - useEffect(() => { - setAlertSummaryWidgetTimeRange(getDefaultAlertSummaryTimeRange()); - }, [esQuery]); const updateUrl = (nextQuery: { tabId: TabId }) => { const newTabId = nextQuery.tabId; @@ -88,11 +82,19 @@ export function RuleDetailTabs({ }); }; - const onTabIdChange = (newTabId: TabId) => { + const handleTabIdChange = (newTabId: TabId) => { onChangeTab(newTabId); updateUrl({ tabId: newTabId }); }; + const handleEsQueryChange = (newQuery: { bool: BoolQuery } | undefined) => { + setEsQuery(newQuery); + + if (newQuery) { + onChangeEsQuery(newQuery); + } + }; + const tabs: EuiTabbedContentTab[] = [ { id: EXECUTION_TAB, @@ -119,7 +121,7 @@ export function RuleDetailTabs({ @@ -150,8 +152,8 @@ export function RuleDetailTabs({ data-test-subj="rule-detail-tabs" tabs={tabs} selectedTab={tabs.find((tab) => tab.id === activeTab)} - onTabClick={(tab) => { - onTabIdChange(tab.id as TabId); + onTabClick={({ id }) => { + handleTabIdChange(id as TabId); }} /> ); diff --git a/x-pack/plugins/observability/public/pages/rule_details/rule_details.tsx b/x-pack/plugins/observability/public/pages/rule_details/rule_details.tsx index 43da5e130772c..2d0d2b44258d0 100644 --- a/x-pack/plugins/observability/public/pages/rule_details/rule_details.tsx +++ b/x-pack/plugins/observability/public/pages/rule_details/rule_details.tsx @@ -16,6 +16,7 @@ import { useKibana } from '../../utils/kibana_react'; import { useBreadcrumbs } from '../../hooks/use_breadcrumbs'; import { usePluginContext } from '../../hooks/use_plugin_context'; import { useFetchRule } from '../../hooks/use_fetch_rule'; +import { useGetRuleTypeDefinitionFromRuleType } from '../../hooks/use_get_rule_type_definition_from_rule_type'; import { DeleteConfirmationModal } from './components/delete_modal_confirmation'; import { CenterJustifiedSpinner } from '../../components/center_justified_spinner'; import { PageTitle } from './components/page_title'; @@ -23,6 +24,7 @@ import { NoRuleFoundPanel } from './components/no_rule_found_panel'; import { RuleDetailTabs } from './components/rule_detail_tabs'; import { HeaderActions } from './components/header_actions'; import { getHealthColor } from './helpers/get_health_color'; +import { canEditRule } from './helpers/can_edit_rule'; import { defaultTimeRange, getDefaultAlertSummaryTimeRange, @@ -32,8 +34,6 @@ import { paths } from '../../config/paths'; import { ALERT_STATUS_ALL } from '../../../common/constants'; import { ruleDetailsLocatorID } from '../../../common'; import type { AlertStatus } from '../../../common/typings'; -import { useGetRuleTypeDefinitionFromRuleType } from '../../hooks/use_get_rule_type_definition_from_rule_type'; -import { canEditRule } from './helpers/can_edit_rule'; export const EXECUTION_TAB = 'execution'; export const ALERTS_TAB = 'alerts'; @@ -140,10 +140,23 @@ export function RuleDetailsPage() { tabsRef.current?.scrollIntoView({ behavior: 'smooth' }); }; + const handleChangeTab = (newTab: TabId) => { + setActiveTab(newTab); + }; + const handleEditRule = () => { setEditRuleFlyoutVisible(true); }; + const handleCloseRuleFlyout = () => { + setEditRuleFlyoutVisible(false); + }; + + const handleDeleteRule = () => { + setRuleToDelete(rule?.id); + setEditRuleFlyoutVisible(false); + }; + const handleIsDeletingRule = () => { setIsRuleDeleting(true); }; @@ -154,13 +167,8 @@ export function RuleDetailsPage() { navigateToUrl(http.basePath.prepend(paths.observability.rules)); }; - const handleDeleteRule = () => { - setRuleToDelete(rule?.id); - setEditRuleFlyoutVisible(false); - }; - - const handleChangeTab = (newTab: TabId) => { - setActiveTab(newTab); + const handleChangeEsQuery = () => { + setAlertSummaryWidgetTimeRange(getDefaultAlertSummaryTimeRange()); }; const featureIds = ( @@ -201,10 +209,10 @@ export function RuleDetailsPage() { + + @@ -245,17 +255,12 @@ export function RuleDetailsPage() { ruleType={ruleTypeDefinition} activeTab={activeTab} onChangeTab={handleChangeTab} + onChangeEsQuery={handleChangeEsQuery} /> ) : null} {editRuleFlyoutVisible ? ( - { - setEditRuleFlyoutVisible(false); - }} - onSave={reloadRule} - /> + ) : null} {ruleToDelete ? ( diff --git a/x-pack/plugins/translations/translations/fr-FR.json b/x-pack/plugins/translations/translations/fr-FR.json index d5e92e8dc22f4..f3f4188e85f83 100644 --- a/x-pack/plugins/translations/translations/fr-FR.json +++ b/x-pack/plugins/translations/translations/fr-FR.json @@ -25503,10 +25503,6 @@ "xpack.observability.overview.exploratoryView.missingReportDefinition": "{reportDefinition} manquante", "xpack.observability.overview.exploratoryView.noDataAvailable": "Aucune donnée {dataType} disponible.", "xpack.observability.ruleDetails.ruleLoadError": "Impossible de charger la règle. Raison : {message}", - "xpack.observability.rules.deleteSelectedIdsConfirmModal.deleteButtonLabel": "Supprimer {numIdsToDelete, plural, one {{singleTitle}} other {# {multipleTitle}}} ", - "xpack.observability.rules.deleteSelectedIdsConfirmModal.descriptionText": "Vous ne pouvez pas récupérer {numIdsToDelete, plural, one {un {singleTitle} supprimé} other {des {multipleTitle} supprimés}}.", - "xpack.observability.rules.deleteSelectedIdsErrorNotification.descriptionText": "Impossible de supprimer {numErrors, number} {numErrors, plural, one {{singleTitle}} other {{multipleTitle}}}", - "xpack.observability.rules.deleteSelectedIdsSuccessNotification.descriptionText": "{numSuccesses, number} {numSuccesses, plural, one {{singleTitle}} other {{multipleTitle}}} supprimé(s)", "xpack.observability.slo.alerting.burnRate.reason": "Le taux d'avancement pour le (les) dernier(s) {longWindowDuration} est de {longWindowBurnRate} et pour le (les) dernier(s) {shortWindowDuration} est de {shortWindowBurnRate}. Alerter si supérieur à {burnRateThreshold} pour les deux fenêtres", "xpack.observability.slo.rules.burnRate.errors.invalidThresholdValue": "Le seuil du taux d'avancement doit être compris entre 1 et {maxBurnRate}.", "xpack.observability.slo.rules.errorBudgetExhaustion.text": "À ce niveau, le bilan d'erreurs de SLO sera épuisé après {formatedHours} heures.", @@ -25929,7 +25925,6 @@ "xpack.observability.ruleDetails.ruleStatusUnknown": "Inconnu", "xpack.observability.ruleDetails.ruleStatusWarning": "Avertissement", "xpack.observability.rules.addRuleButtonLabel": "Créer une règle", - "xpack.observability.rules.deleteSelectedIdsConfirmModal.cancelButtonLabel": "Annuler", "xpack.observability.rules.docsLinkText": "Documentation", "xpack.observability.rulesLinkTitle": "Règles", "xpack.observability.rulesTitle": "Règles", diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 232887a7c5996..60d659e14b399 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -25911,7 +25911,6 @@ "xpack.observability.ruleDetails.ruleStatusUnknown": "不明", "xpack.observability.ruleDetails.ruleStatusWarning": "警告", "xpack.observability.rules.addRuleButtonLabel": "ルールを作成", - "xpack.observability.rules.deleteSelectedIdsConfirmModal.cancelButtonLabel": "キャンセル", "xpack.observability.rules.docsLinkText": "ドキュメント", "xpack.observability.rulesLinkTitle": "ルール", "xpack.observability.rulesTitle": "ルール", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 83ff096102769..f3cac7905319d 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -25501,10 +25501,6 @@ "xpack.observability.overview.exploratoryView.noDataAvailable": "没有可用的 {dataType} 数据。", "xpack.observability.profilingElasticsearchPluginDescription": "{technicalPreviewLabel} 是否使用 Elasticsearch 分析器插件加载堆栈跟踪。", "xpack.observability.ruleDetails.ruleLoadError": "无法加载规则。原因:{message}", - "xpack.observability.rules.deleteSelectedIdsConfirmModal.deleteButtonLabel": "删除{numIdsToDelete, plural, one {{singleTitle}} other {# 个{multipleTitle}}}", - "xpack.observability.rules.deleteSelectedIdsConfirmModal.descriptionText": "无法恢复{numIdsToDelete, plural, one {删除的{singleTitle}} other {删除的{multipleTitle}}}。", - "xpack.observability.rules.deleteSelectedIdsErrorNotification.descriptionText": "无法删除 {numErrors, number} 个{numErrors, plural, one {{singleTitle}} other {{multipleTitle}}}", - "xpack.observability.rules.deleteSelectedIdsSuccessNotification.descriptionText": "已删除 {numSuccesses, number} 个{numSuccesses, plural, one {{singleTitle}} other {{multipleTitle}}}", "xpack.observability.slo.alerting.burnRate.reason": "过去 {longWindowDuration} 的消耗速度为 {longWindowBurnRate} 且过去 {shortWindowDuration} 为 {shortWindowBurnRate}。两个窗口超出 {burnRateThreshold} 时告警", "xpack.observability.slo.rules.burnRate.errors.invalidThresholdValue": "消耗速度阈值必须介于 1 和 {maxBurnRate} 之间。", "xpack.observability.slo.rules.errorBudgetExhaustion.text": "在此速度下,SLO 的错误预算将在 {formatedHours} 小时后耗尽。", @@ -25927,7 +25923,6 @@ "xpack.observability.ruleDetails.ruleStatusUnknown": "未知", "xpack.observability.ruleDetails.ruleStatusWarning": "警告", "xpack.observability.rules.addRuleButtonLabel": "创建规则", - "xpack.observability.rules.deleteSelectedIdsConfirmModal.cancelButtonLabel": "取消", "xpack.observability.rules.docsLinkText": "文档", "xpack.observability.rulesLinkTitle": "规则", "xpack.observability.rulesTitle": "规则",