mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[8.6] [RAM] Add ability to toggle new rule status UI via experimental features flag (#145630) (#145767)
# Backport This will backport the following commits from `main` to `8.6`: - [[RAM] Add ability to toggle new rule status UI via experimental features flag (#145630)](https://github.com/elastic/kibana/pull/145630) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Jiawei Wu","email":"74562234+JiaweiWu@users.noreply.github.com"},"sourceCommit":{"committedDate":"2022-11-18T18:44:41Z","message":"[RAM] Add ability to toggle new rule status UI via experimental features flag (#145630)\n\n## Summary\r\nResolves: https://github.com/elastic/kibana/issues/145300\r\n\r\nAllows the new last run outcome UI in the rules list and rule details\r\nview to be turned off via an experimental flag.\r\n\r\nTo test:\r\n- Add the following: `xpack.trigger_actions_ui.enableExperimental:\r\n[\"ruleUseExecutionStatus\"]` to your `kibana.dev.yml`\r\n- Rule management UI should revert back to using execution status\r\n\r\n### Checklist\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>","sha":"9a0622bb2ea86400aad5a8f367cd31d104a53778","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:ResponseOps","Feature:Alerting/RulesManagement","backport:prev-minor","v8.6.0","v8.7.0"],"number":145630,"url":"https://github.com/elastic/kibana/pull/145630","mergeCommit":{"message":"[RAM] Add ability to toggle new rule status UI via experimental features flag (#145630)\n\n## Summary\r\nResolves: https://github.com/elastic/kibana/issues/145300\r\n\r\nAllows the new last run outcome UI in the rules list and rule details\r\nview to be turned off via an experimental flag.\r\n\r\nTo test:\r\n- Add the following: `xpack.trigger_actions_ui.enableExperimental:\r\n[\"ruleUseExecutionStatus\"]` to your `kibana.dev.yml`\r\n- Rule management UI should revert back to using execution status\r\n\r\n### Checklist\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>","sha":"9a0622bb2ea86400aad5a8f367cd31d104a53778"}},"sourceBranch":"main","suggestedTargetBranches":["8.6"],"targetPullRequestStates":[{"branch":"8.6","label":"v8.6.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/145630","number":145630,"mergeCommit":{"message":"[RAM] Add ability to toggle new rule status UI via experimental features flag (#145630)\n\n## Summary\r\nResolves: https://github.com/elastic/kibana/issues/145300\r\n\r\nAllows the new last run outcome UI in the rules list and rule details\r\nview to be turned off via an experimental flag.\r\n\r\nTo test:\r\n- Add the following: `xpack.trigger_actions_ui.enableExperimental:\r\n[\"ruleUseExecutionStatus\"]` to your `kibana.dev.yml`\r\n- Rule management UI should revert back to using execution status\r\n\r\n### Checklist\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>","sha":"9a0622bb2ea86400aad5a8f367cd31d104a53778"}}]}] BACKPORT--> Co-authored-by: Jiawei Wu <74562234+JiaweiWu@users.noreply.github.com>
This commit is contained in:
parent
dec5dbc8cc
commit
36d67972a4
19 changed files with 91 additions and 91 deletions
|
@ -88,7 +88,7 @@ export const StorybookContextDecorator: React.FC<StorybookContextDecoratorProps>
|
|||
ruleTagFilter: true,
|
||||
ruleStatusFilter: true,
|
||||
rulesDetailLogs: true,
|
||||
ruleLastRunOutcome: true,
|
||||
ruleUseExecutionStatus: false,
|
||||
},
|
||||
});
|
||||
return (
|
||||
|
|
|
@ -17,7 +17,7 @@ export const allowedExperimentalValues = Object.freeze({
|
|||
ruleTagFilter: true,
|
||||
ruleStatusFilter: true,
|
||||
rulesDetailLogs: true,
|
||||
ruleLastRunOutcome: true,
|
||||
ruleUseExecutionStatus: false,
|
||||
});
|
||||
|
||||
type ExperimentalConfigKeys = Array<keyof ExperimentalFeatures>;
|
||||
|
|
|
@ -320,6 +320,8 @@ describe('alertToListItem', () => {
|
|||
|
||||
describe('execution duration overview', () => {
|
||||
it('render last execution status', async () => {
|
||||
(getIsExperimentalFeatureEnabled as jest.Mock<any, any>).mockImplementation(() => true);
|
||||
|
||||
const rule = mockRule({
|
||||
executionStatus: { status: 'ok', lastExecutionDate: new Date('2020-08-20T19:23:38Z') },
|
||||
});
|
||||
|
|
|
@ -175,7 +175,7 @@ export const RuleEventLogDataGrid = (props: RuleEventLogDataGrid) => {
|
|||
|
||||
const { euiTheme } = useEuiTheme();
|
||||
|
||||
const isRuleLastRunOutcomeEnabled = getIsExperimentalFeatureEnabled('ruleLastRunOutcome');
|
||||
const isRuleUsingExecutionStatus = getIsExperimentalFeatureEnabled('ruleUseExecutionStatus');
|
||||
|
||||
const getPaginatedRowIndex = useCallback(
|
||||
(rowIndex: number) => {
|
||||
|
@ -624,7 +624,7 @@ export const RuleEventLogDataGrid = (props: RuleEventLogDataGrid) => {
|
|||
dateFormat={dateFormat}
|
||||
ruleId={ruleId}
|
||||
spaceIds={spaceIds}
|
||||
lastRunOutcomeEnabled={isRuleLastRunOutcomeEnabled}
|
||||
useExecutionStatus={isRuleUsingExecutionStatus}
|
||||
/>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
|
|
|
@ -32,7 +32,7 @@ interface RuleEventLogListCellRendererProps {
|
|||
dateFormat?: string;
|
||||
ruleId?: string;
|
||||
spaceIds?: string[];
|
||||
lastRunOutcomeEnabled?: boolean;
|
||||
useExecutionStatus?: boolean;
|
||||
}
|
||||
|
||||
export const RuleEventLogListCellRenderer = (props: RuleEventLogListCellRendererProps) => {
|
||||
|
@ -43,7 +43,7 @@ export const RuleEventLogListCellRenderer = (props: RuleEventLogListCellRenderer
|
|||
dateFormat = DEFAULT_DATE_FORMAT,
|
||||
ruleId,
|
||||
spaceIds,
|
||||
lastRunOutcomeEnabled = false,
|
||||
useExecutionStatus = true,
|
||||
} = props;
|
||||
const spacesData = useSpacesData();
|
||||
const { http } = useKibana().services;
|
||||
|
@ -99,7 +99,7 @@ export const RuleEventLogListCellRenderer = (props: RuleEventLogListCellRenderer
|
|||
return (
|
||||
<RuleEventLogListStatus
|
||||
status={value as RuleAlertingOutcome}
|
||||
lastRunOutcomeEnabled={lastRunOutcomeEnabled}
|
||||
useExecutionStatus={useExecutionStatus}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ export const RuleEventLogListKPI = (props: RuleEventLogListKPIProps) => {
|
|||
} = useKibana().services;
|
||||
|
||||
const isInitialized = useRef(false);
|
||||
const isRuleLastRunOutcomeEnabled = getIsExperimentalFeatureEnabled('ruleLastRunOutcome');
|
||||
const isRuleUsingExecutionStatus = getIsExperimentalFeatureEnabled('ruleUseExecutionStatus');
|
||||
|
||||
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||
const [kpi, setKpi] = useState<IExecutionKPIResult>();
|
||||
|
@ -173,7 +173,7 @@ export const RuleEventLogListKPI = (props: RuleEventLogListKPIProps) => {
|
|||
description={getStatDescription(
|
||||
<RuleEventLogListStatus
|
||||
status="success"
|
||||
lastRunOutcomeEnabled={isRuleLastRunOutcomeEnabled}
|
||||
useExecutionStatus={isRuleUsingExecutionStatus}
|
||||
/>
|
||||
)}
|
||||
titleSize="s"
|
||||
|
@ -187,7 +187,7 @@ export const RuleEventLogListKPI = (props: RuleEventLogListKPIProps) => {
|
|||
description={getStatDescription(
|
||||
<RuleEventLogListStatus
|
||||
status="warning"
|
||||
lastRunOutcomeEnabled={isRuleLastRunOutcomeEnabled}
|
||||
useExecutionStatus={isRuleUsingExecutionStatus}
|
||||
/>
|
||||
)}
|
||||
titleSize="s"
|
||||
|
@ -201,7 +201,7 @@ export const RuleEventLogListKPI = (props: RuleEventLogListKPIProps) => {
|
|||
description={getStatDescription(
|
||||
<RuleEventLogListStatus
|
||||
status="failure"
|
||||
lastRunOutcomeEnabled={isRuleLastRunOutcomeEnabled}
|
||||
useExecutionStatus={isRuleUsingExecutionStatus}
|
||||
/>
|
||||
)}
|
||||
titleSize="s"
|
||||
|
|
|
@ -17,7 +17,7 @@ import {
|
|||
|
||||
interface RuleEventLogListStatusProps {
|
||||
status: RuleAlertingOutcome;
|
||||
lastRunOutcomeEnabled?: boolean;
|
||||
useExecutionStatus?: boolean;
|
||||
}
|
||||
|
||||
const statusContainerStyles = {
|
||||
|
@ -45,15 +45,15 @@ const STATUS_TO_OUTCOME: Record<RuleAlertingOutcome, string> = {
|
|||
};
|
||||
|
||||
export const RuleEventLogListStatus = (props: RuleEventLogListStatusProps) => {
|
||||
const { status, lastRunOutcomeEnabled = false } = props;
|
||||
const { status, useExecutionStatus = true } = props;
|
||||
const color = STATUS_TO_COLOR[status] || 'gray';
|
||||
|
||||
const statusString = useMemo(() => {
|
||||
if (lastRunOutcomeEnabled) {
|
||||
return STATUS_TO_OUTCOME[status].toLocaleLowerCase();
|
||||
if (useExecutionStatus) {
|
||||
return status;
|
||||
}
|
||||
return status;
|
||||
}, [lastRunOutcomeEnabled, status]);
|
||||
return STATUS_TO_OUTCOME[status].toLocaleLowerCase();
|
||||
}, [useExecutionStatus, status]);
|
||||
|
||||
return (
|
||||
<div style={statusContainerStyles}>
|
||||
|
|
|
@ -22,7 +22,7 @@ interface RuleEventLogListStatusFilterProps {
|
|||
export const RuleEventLogListStatusFilter = (props: RuleEventLogListStatusFilterProps) => {
|
||||
const { selectedOptions = [], onChange = () => {} } = props;
|
||||
|
||||
const isRuleLastRunOutcomeEnabled = getIsExperimentalFeatureEnabled('ruleLastRunOutcome');
|
||||
const isRuleUsingExecutionStatus = getIsExperimentalFeatureEnabled('ruleUseExecutionStatus');
|
||||
|
||||
const [isPopoverOpen, setIsPopoverOpen] = useState<boolean>(false);
|
||||
|
||||
|
@ -73,7 +73,7 @@ export const RuleEventLogListStatusFilter = (props: RuleEventLogListStatusFilter
|
|||
>
|
||||
<RuleEventLogListStatus
|
||||
status={status}
|
||||
lastRunOutcomeEnabled={isRuleLastRunOutcomeEnabled}
|
||||
useExecutionStatus={isRuleUsingExecutionStatus}
|
||||
/>
|
||||
</EuiFilterSelectItem>
|
||||
);
|
||||
|
|
|
@ -359,7 +359,7 @@ describe('rules_list component with props', () => {
|
|||
|
||||
describe('Last response filter', () => {
|
||||
beforeEach(() => {
|
||||
(getIsExperimentalFeatureEnabled as jest.Mock<any, any>).mockImplementation(() => true);
|
||||
// (getIsExperimentalFeatureEnabled as jest.Mock<any, any>).mockImplementation(() => true);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
@ -1029,7 +1029,7 @@ describe('rules_list component with items', () => {
|
|||
expect(wrapper.find('[data-test-subj="rulesListAutoRefresh"]').exists()).toBeTruthy();
|
||||
|
||||
expect(wrapper.find('EuiHealth[data-test-subj="ruleStatus-failed"]').first().text()).toEqual(
|
||||
'Error'
|
||||
'Failed'
|
||||
);
|
||||
expect(wrapper.find('EuiHealth[data-test-subj="ruleStatus-failed"]').last().text()).toEqual(
|
||||
'License Error'
|
||||
|
@ -1280,7 +1280,7 @@ describe('rules_list component with items', () => {
|
|||
});
|
||||
|
||||
it('renders brief', async () => {
|
||||
(getIsExperimentalFeatureEnabled as jest.Mock<any, any>).mockImplementation(() => true);
|
||||
(getIsExperimentalFeatureEnabled as jest.Mock<any, any>).mockImplementation(() => false);
|
||||
await setup();
|
||||
|
||||
// ruleLastRunOutcome: {
|
||||
|
|
|
@ -198,7 +198,7 @@ export const RulesList = ({
|
|||
|
||||
const isRuleTagFilterEnabled = getIsExperimentalFeatureEnabled('ruleTagFilter');
|
||||
const isRuleStatusFilterEnabled = getIsExperimentalFeatureEnabled('ruleStatusFilter');
|
||||
const isRuleLastRunOutcomeEnabled = getIsExperimentalFeatureEnabled('ruleLastRunOutcome');
|
||||
const isRuleUsingExecutionStatus = getIsExperimentalFeatureEnabled('ruleUseExecutionStatus');
|
||||
|
||||
const cloneRuleId = useRef<null | string>(null);
|
||||
|
||||
|
@ -586,20 +586,20 @@ export const RulesList = ({
|
|||
};
|
||||
|
||||
const getRuleOutcomeOrStatusFilter = () => {
|
||||
if (isRuleLastRunOutcomeEnabled) {
|
||||
if (isRuleUsingExecutionStatus) {
|
||||
return [
|
||||
<RuleLastRunOutcomeFilter
|
||||
key="rule-last-run-outcome-filter"
|
||||
selectedOutcomes={ruleLastRunOutcomesFilter}
|
||||
onChange={setRuleLastRunOutcomesFilter}
|
||||
<RuleExecutionStatusFilter
|
||||
key="rule-status-filter"
|
||||
selectedStatuses={ruleExecutionStatusesFilter}
|
||||
onChange={setRuleExecutionStatusesFilter}
|
||||
/>,
|
||||
];
|
||||
}
|
||||
return [
|
||||
<RuleExecutionStatusFilter
|
||||
key="rule-status-filter"
|
||||
selectedStatuses={ruleExecutionStatusesFilter}
|
||||
onChange={setRuleExecutionStatusesFilter}
|
||||
<RuleLastRunOutcomeFilter
|
||||
key="rule-last-run-outcome-filter"
|
||||
selectedOutcomes={ruleLastRunOutcomesFilter}
|
||||
onChange={setRuleLastRunOutcomesFilter}
|
||||
/>,
|
||||
];
|
||||
};
|
||||
|
|
|
@ -36,8 +36,7 @@ export type RulesListVisibleColumns =
|
|||
| 'ruleExecutionPercentile'
|
||||
| 'ruleExecutionSuccessRatio'
|
||||
| 'ruleExecutionStatus'
|
||||
| 'ruleExecutionState'
|
||||
| 'ruleLastRunOutcome';
|
||||
| 'ruleExecutionState';
|
||||
|
||||
const OriginalRulesListVisibleColumns: RulesListVisibleColumns[] = [
|
||||
'ruleName',
|
||||
|
|
|
@ -21,11 +21,11 @@ export const RulesListErrorBanner = (props: RulesListErrorBannerProps) => {
|
|||
props;
|
||||
|
||||
const onClick = () => {
|
||||
const isRuleLastRunOutcomeEnabled = getIsExperimentalFeatureEnabled('ruleLastRunOutcome');
|
||||
if (isRuleLastRunOutcomeEnabled) {
|
||||
setRuleLastRunOutcomesFilter(['failed']);
|
||||
} else {
|
||||
const isRuleUsingExecutionStatus = getIsExperimentalFeatureEnabled('ruleUseExecutionStatus');
|
||||
if (isRuleUsingExecutionStatus) {
|
||||
setRuleExecutionStatusesFilter(['error']);
|
||||
} else {
|
||||
setRuleLastRunOutcomesFilter(['failed']);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -29,24 +29,39 @@ interface RulesListStatusesProps {
|
|||
export const RulesListStatuses = (props: RulesListStatusesProps) => {
|
||||
const { rulesStatuses, rulesLastRunOutcomes } = props;
|
||||
|
||||
const isRuleLastRunOutcomeEnabled = getIsExperimentalFeatureEnabled('ruleLastRunOutcome');
|
||||
const isRuleUsingExecutionStatus = getIsExperimentalFeatureEnabled('ruleUseExecutionStatus');
|
||||
|
||||
if (isRuleLastRunOutcomeEnabled) {
|
||||
if (isRuleUsingExecutionStatus) {
|
||||
return (
|
||||
<EuiFlexGroup alignItems="center" gutterSize="none">
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiHealth color="success" data-test-subj="totalSucceededRulesCount">
|
||||
{RULE_LAST_RUN_OUTCOME_SUCCEEDED_DESCRIPTION(rulesLastRunOutcomes.succeeded)}
|
||||
<EuiHealth color="success" data-test-subj="totalActiveRulesCount">
|
||||
{RULE_STATUS_ACTIVE(rulesStatuses.active)}
|
||||
</EuiHealth>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiHealth color="danger" data-test-subj="totalFailedRulesCount">
|
||||
{RULE_LAST_RUN_OUTCOME_FAILED_DESCRIPTION(rulesLastRunOutcomes.failed)}
|
||||
<EuiHealth color="danger" data-test-subj="totalErrorRulesCount">
|
||||
{RULE_STATUS_ERROR(rulesStatuses.error)}
|
||||
</EuiHealth>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiHealth color="warning" data-test-subj="totalWarningRulesCount">
|
||||
{RULE_LAST_RUN_OUTCOME_WARNING_DESCRIPTION(rulesLastRunOutcomes.warning)}
|
||||
{RULE_STATUS_WARNING(rulesStatuses.warning)}
|
||||
</EuiHealth>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiHealth color="primary" data-test-subj="totalOkRulesCount">
|
||||
{RULE_STATUS_OK(rulesStatuses.ok)}
|
||||
</EuiHealth>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiHealth color="accent" data-test-subj="totalPendingRulesCount">
|
||||
{RULE_STATUS_PENDING(rulesStatuses.pending)}
|
||||
</EuiHealth>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiHealth color="subdued" data-test-subj="totalUnknownRulesCount">
|
||||
{RULE_STATUS_UNKNOWN(rulesStatuses.unknown)}
|
||||
</EuiHealth>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
|
@ -56,33 +71,18 @@ export const RulesListStatuses = (props: RulesListStatusesProps) => {
|
|||
return (
|
||||
<EuiFlexGroup alignItems="center" gutterSize="none">
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiHealth color="success" data-test-subj="totalActiveRulesCount">
|
||||
{RULE_STATUS_ACTIVE(rulesStatuses.active)}
|
||||
<EuiHealth color="success" data-test-subj="totalSucceededRulesCount">
|
||||
{RULE_LAST_RUN_OUTCOME_SUCCEEDED_DESCRIPTION(rulesLastRunOutcomes.succeeded)}
|
||||
</EuiHealth>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiHealth color="danger" data-test-subj="totalErrorRulesCount">
|
||||
{RULE_STATUS_ERROR(rulesStatuses.error)}
|
||||
<EuiHealth color="danger" data-test-subj="totalFailedRulesCount">
|
||||
{RULE_LAST_RUN_OUTCOME_FAILED_DESCRIPTION(rulesLastRunOutcomes.failed)}
|
||||
</EuiHealth>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiHealth color="warning" data-test-subj="totalWarningRulesCount">
|
||||
{RULE_STATUS_WARNING(rulesStatuses.warning)}
|
||||
</EuiHealth>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiHealth color="primary" data-test-subj="totalOkRulesCount">
|
||||
{RULE_STATUS_OK(rulesStatuses.ok)}
|
||||
</EuiHealth>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiHealth color="accent" data-test-subj="totalPendingRulesCount">
|
||||
{RULE_STATUS_PENDING(rulesStatuses.pending)}
|
||||
</EuiHealth>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiHealth color="subdued" data-test-subj="totalUnknownRulesCount">
|
||||
{RULE_STATUS_UNKNOWN(rulesStatuses.unknown)}
|
||||
{RULE_LAST_RUN_OUTCOME_WARNING_DESCRIPTION(rulesLastRunOutcomes.warning)}
|
||||
</EuiHealth>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
|
|
|
@ -215,7 +215,7 @@ export const RulesListTable = (props: RulesListTableProps) => {
|
|||
const [currentlyOpenNotify, setCurrentlyOpenNotify] = useState<string>();
|
||||
const [isLoadingMap, setIsLoadingMap] = useState<Record<string, boolean>>({});
|
||||
|
||||
const isRuleLastRunOutcomeEnabled = getIsExperimentalFeatureEnabled('ruleLastRunOutcome');
|
||||
const isRuleUsingExecutionStatus = getIsExperimentalFeatureEnabled('ruleUseExecutionStatus');
|
||||
|
||||
const [defaultNumberFormat] = useUiSetting$<string>(DEFAULT_NUMBER_FORMAT);
|
||||
const { euiTheme } = useEuiTheme();
|
||||
|
@ -329,11 +329,11 @@ export const RulesListTable = (props: RulesListTableProps) => {
|
|||
}, [isPageSelected, onSelectPage, onSelectRow, isRowSelected]);
|
||||
|
||||
const ruleOutcomeColumnField = useMemo(() => {
|
||||
if (isRuleLastRunOutcomeEnabled) {
|
||||
return 'lastRun.outcome';
|
||||
if (isRuleUsingExecutionStatus) {
|
||||
return 'executionStatus.status';
|
||||
}
|
||||
return 'executionStatus.status';
|
||||
}, [isRuleLastRunOutcomeEnabled]);
|
||||
return 'lastRun.outcome';
|
||||
}, [isRuleUsingExecutionStatus]);
|
||||
|
||||
const getRulesTableColumns = useCallback((): RulesListColumns[] => {
|
||||
return [
|
||||
|
|
|
@ -44,7 +44,7 @@ const ComponentWithLocale = (props: RulesListTableStatusCellProps) => {
|
|||
|
||||
describe('RulesListTableStatusCell', () => {
|
||||
beforeEach(() => {
|
||||
(getIsExperimentalFeatureEnabled as jest.Mock<any, any>).mockImplementation(() => true);
|
||||
(getIsExperimentalFeatureEnabled as jest.Mock<any, any>).mockImplementation(() => false);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
|
|
@ -20,7 +20,7 @@ describe('getIsExperimentalFeatureEnabled', () => {
|
|||
rulesDetailLogs: true,
|
||||
ruleTagFilter: true,
|
||||
ruleStatusFilter: true,
|
||||
ruleLastRunOutcome: true,
|
||||
ruleUseExecutionStatus: false,
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -44,9 +44,9 @@ describe('getIsExperimentalFeatureEnabled', () => {
|
|||
|
||||
expect(result).toEqual(true);
|
||||
|
||||
result = getIsExperimentalFeatureEnabled('ruleLastRunOutcome');
|
||||
result = getIsExperimentalFeatureEnabled('ruleUseExecutionStatus');
|
||||
|
||||
expect(result).toEqual(true);
|
||||
expect(result).toEqual(false);
|
||||
|
||||
expect(() => getIsExperimentalFeatureEnabled('doesNotExist' as any)).toThrowError(
|
||||
`Invalid enable value doesNotExist. Allowed values are: ${allowedExperimentalValueKeys.join(
|
||||
|
|
|
@ -65,7 +65,7 @@ const licenseErrorRule = {
|
|||
} as RuleTableItem;
|
||||
|
||||
beforeEach(() => {
|
||||
(getIsExperimentalFeatureEnabled as jest.Mock<any, any>).mockImplementation(() => true);
|
||||
(getIsExperimentalFeatureEnabled as jest.Mock<any, any>).mockImplementation(() => false);
|
||||
});
|
||||
|
||||
describe('getRuleHealthColor', () => {
|
||||
|
@ -73,7 +73,7 @@ describe('getRuleHealthColor', () => {
|
|||
let color = getRuleHealthColor(mockRule);
|
||||
expect(color).toEqual('success');
|
||||
|
||||
(getIsExperimentalFeatureEnabled as jest.Mock<any, any>).mockImplementation(() => false);
|
||||
(getIsExperimentalFeatureEnabled as jest.Mock<any, any>).mockImplementation(() => true);
|
||||
|
||||
color = getRuleHealthColor(mockRule);
|
||||
expect(color).toEqual('success');
|
||||
|
@ -83,7 +83,7 @@ describe('getRuleHealthColor', () => {
|
|||
let color = getRuleHealthColor(warningRule);
|
||||
expect(color).toEqual('warning');
|
||||
|
||||
(getIsExperimentalFeatureEnabled as jest.Mock<any, any>).mockImplementation(() => false);
|
||||
(getIsExperimentalFeatureEnabled as jest.Mock<any, any>).mockImplementation(() => true);
|
||||
|
||||
color = getRuleHealthColor(warningRule);
|
||||
expect(color).toEqual('warning');
|
||||
|
@ -93,7 +93,7 @@ describe('getRuleHealthColor', () => {
|
|||
let color = getRuleHealthColor(failedRule);
|
||||
expect(color).toEqual('danger');
|
||||
|
||||
(getIsExperimentalFeatureEnabled as jest.Mock<any, any>).mockImplementation(() => false);
|
||||
(getIsExperimentalFeatureEnabled as jest.Mock<any, any>).mockImplementation(() => true);
|
||||
|
||||
color = getRuleHealthColor(failedRule);
|
||||
expect(color).toEqual('danger');
|
||||
|
@ -110,7 +110,7 @@ describe('getRuleStatusMessage', () => {
|
|||
});
|
||||
expect(statusMessage).toEqual('Succeeded');
|
||||
|
||||
(getIsExperimentalFeatureEnabled as jest.Mock<any, any>).mockImplementation(() => false);
|
||||
(getIsExperimentalFeatureEnabled as jest.Mock<any, any>).mockImplementation(() => true);
|
||||
statusMessage = getRuleStatusMessage({
|
||||
rule: mockRule,
|
||||
licenseErrorText: ALERT_STATUS_LICENSE_ERROR,
|
||||
|
@ -129,7 +129,7 @@ describe('getRuleStatusMessage', () => {
|
|||
});
|
||||
expect(statusMessage).toEqual('Warning');
|
||||
|
||||
(getIsExperimentalFeatureEnabled as jest.Mock<any, any>).mockImplementation(() => false);
|
||||
(getIsExperimentalFeatureEnabled as jest.Mock<any, any>).mockImplementation(() => true);
|
||||
statusMessage = getRuleStatusMessage({
|
||||
rule: warningRule,
|
||||
licenseErrorText: ALERT_STATUS_LICENSE_ERROR,
|
||||
|
@ -148,7 +148,7 @@ describe('getRuleStatusMessage', () => {
|
|||
});
|
||||
expect(statusMessage).toEqual('Failed');
|
||||
|
||||
(getIsExperimentalFeatureEnabled as jest.Mock<any, any>).mockImplementation(() => false);
|
||||
(getIsExperimentalFeatureEnabled as jest.Mock<any, any>).mockImplementation(() => true);
|
||||
statusMessage = getRuleStatusMessage({
|
||||
rule: failedRule,
|
||||
licenseErrorText: ALERT_STATUS_LICENSE_ERROR,
|
||||
|
@ -167,7 +167,7 @@ describe('getRuleStatusMessage', () => {
|
|||
});
|
||||
expect(statusMessage).toEqual('License Error');
|
||||
|
||||
(getIsExperimentalFeatureEnabled as jest.Mock<any, any>).mockImplementation(() => false);
|
||||
(getIsExperimentalFeatureEnabled as jest.Mock<any, any>).mockImplementation(() => true);
|
||||
statusMessage = getRuleStatusMessage({
|
||||
rule: licenseErrorRule,
|
||||
licenseErrorText: ALERT_STATUS_LICENSE_ERROR,
|
||||
|
|
|
@ -43,11 +43,11 @@ export const getExecutionStatusHealthColor = (status: RuleExecutionStatuses) =>
|
|||
};
|
||||
|
||||
export const getRuleHealthColor = (rule: Rule) => {
|
||||
const isRuleLastRunOutcomeEnabled = getIsExperimentalFeatureEnabled('ruleLastRunOutcome');
|
||||
if (isRuleLastRunOutcomeEnabled) {
|
||||
return (rule.lastRun && getOutcomeHealthColor(rule.lastRun.outcome)) || 'subdued';
|
||||
const isRuleUsingExecutionStatus = getIsExperimentalFeatureEnabled('ruleUseExecutionStatus');
|
||||
if (isRuleUsingExecutionStatus) {
|
||||
return getExecutionStatusHealthColor(rule.executionStatus.status);
|
||||
}
|
||||
return getExecutionStatusHealthColor(rule.executionStatus.status);
|
||||
return (rule.lastRun && getOutcomeHealthColor(rule.lastRun.outcome)) || 'subdued';
|
||||
};
|
||||
|
||||
export const getIsLicenseError = (rule: Rule) => {
|
||||
|
@ -69,13 +69,13 @@ export const getRuleStatusMessage = ({
|
|||
executionStatusTranslations: Record<string, string>;
|
||||
}) => {
|
||||
const isLicenseError = getIsLicenseError(rule);
|
||||
const isRuleLastRunOutcomeEnabled = getIsExperimentalFeatureEnabled('ruleLastRunOutcome');
|
||||
const isRuleUsingExecutionStatus = getIsExperimentalFeatureEnabled('ruleUseExecutionStatus');
|
||||
|
||||
if (isLicenseError) {
|
||||
return licenseErrorText;
|
||||
}
|
||||
if (isRuleLastRunOutcomeEnabled) {
|
||||
return rule.lastRun && lastOutcomeTranslations[rule.lastRun.outcome];
|
||||
if (isRuleUsingExecutionStatus) {
|
||||
return executionStatusTranslations[rule.executionStatus.status];
|
||||
}
|
||||
return executionStatusTranslations[rule.executionStatus.status];
|
||||
return rule.lastRun && lastOutcomeTranslations[rule.lastRun.outcome];
|
||||
};
|
||||
|
|
|
@ -93,7 +93,6 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
|
|||
'internalAlertsTable',
|
||||
'ruleTagFilter',
|
||||
'ruleStatusFilter',
|
||||
'ruleLastRunOutcome',
|
||||
])}`,
|
||||
`--xpack.alerting.rules.minimumScheduleInterval.value="2s"`,
|
||||
`--xpack.actions.enabledActionTypes=${JSON.stringify(enabledActionTypes)}`,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue