forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RAM] Bring back toggle column on alert table (elastic#168158)
FIX -> elastic#155243 - [x] [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 --------- Co-authored-by: PhilippeOberti <philippe.oberti@elastic.co> (cherry picked from commit 44a9d28)
- Loading branch information
Showing
26 changed files
with
461 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
.../security_solution/public/common/lib/triggers_actions_ui/alert_table_scope_config.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { TableId } from '@kbn/securitysolution-data-table'; | ||
import { ALERTS_TABLE_REGISTRY_CONFIG_IDS } from '../../../../common/constants'; | ||
import { getAlertConfigIdByScopeId } from './alert_table_scope_config'; | ||
|
||
describe('getAlertConfigIdByScopeId', () => { | ||
it('should return an alert configuration ID when the scope is valid', async () => { | ||
expect(getAlertConfigIdByScopeId(TableId.alertsOnAlertsPage)).toEqual( | ||
ALERTS_TABLE_REGISTRY_CONFIG_IDS.ALERTS_PAGE | ||
); | ||
expect(getAlertConfigIdByScopeId(TableId.alertsOnRuleDetailsPage)).toEqual( | ||
ALERTS_TABLE_REGISTRY_CONFIG_IDS.RULE_DETAILS | ||
); | ||
expect(getAlertConfigIdByScopeId(TableId.alertsOnCasePage)).toEqual( | ||
ALERTS_TABLE_REGISTRY_CONFIG_IDS.CASE | ||
); | ||
expect(getAlertConfigIdByScopeId(TableId.alertsRiskInputs)).toEqual( | ||
ALERTS_TABLE_REGISTRY_CONFIG_IDS.RISK_INPUTS | ||
); | ||
}); | ||
|
||
it('should return undefined when the scope is NOT valid', async () => { | ||
expect(getAlertConfigIdByScopeId(TableId.test)).toEqual(undefined); | ||
expect(getAlertConfigIdByScopeId('hereWeGo')).toEqual(undefined); | ||
}); | ||
}); |
38 changes: 38 additions & 0 deletions
38
...ugins/security_solution/public/common/lib/triggers_actions_ui/alert_table_scope_config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { TableId } from '@kbn/securitysolution-data-table'; | ||
import { ALERTS_TABLE_REGISTRY_CONFIG_IDS } from '../../../../common/constants'; | ||
|
||
type PickKey<T, K extends keyof T> = Extract<keyof T, K>; | ||
type KeysAlertTableId = PickKey< | ||
typeof TableId, | ||
'alertsOnAlertsPage' | 'alertsOnRuleDetailsPage' | 'alertsOnCasePage' | 'alertsRiskInputs' | ||
>; | ||
|
||
type ValuesAlertTableId = typeof TableId[KeysAlertTableId]; | ||
|
||
type KeysAlertTableConfiguration = keyof typeof ALERTS_TABLE_REGISTRY_CONFIG_IDS; | ||
type ValuesAlertTableConfiguration = | ||
typeof ALERTS_TABLE_REGISTRY_CONFIG_IDS[KeysAlertTableConfiguration]; | ||
|
||
const ScopeIdLinkToAlertTableConfiguration: Record< | ||
ValuesAlertTableId, | ||
ValuesAlertTableConfiguration | ||
> = { | ||
[TableId.alertsOnAlertsPage]: ALERTS_TABLE_REGISTRY_CONFIG_IDS.ALERTS_PAGE, | ||
[TableId.alertsOnRuleDetailsPage]: ALERTS_TABLE_REGISTRY_CONFIG_IDS.RULE_DETAILS, | ||
[TableId.alertsOnCasePage]: ALERTS_TABLE_REGISTRY_CONFIG_IDS.CASE, | ||
[TableId.alertsRiskInputs]: ALERTS_TABLE_REGISTRY_CONFIG_IDS.RISK_INPUTS, | ||
}; | ||
|
||
export const getAlertConfigIdByScopeId = (scopeId: string) => { | ||
if (ScopeIdLinkToAlertTableConfiguration[scopeId as ValuesAlertTableId]) { | ||
return ScopeIdLinkToAlertTableConfiguration[scopeId as ValuesAlertTableId]; | ||
} | ||
return undefined; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.