-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create UI for alerting and actions plugin #48959
Merged
Merged
Changes from all commits
Commits
Show all changes
360 commits
Select commit
Hold shift + click to select a range
f570e42
Merge remote-tracking branch 'upstream/master' into feature/alerting_ui
YulNaumenko 6bf1baa
Refactored reducers type definitions
YulNaumenko cda5c24
Fixed dependancy objects
YulNaumenko 68c1958
Merge branch 'master' into feature/alerting_ui
YulNaumenko d47238e
Fixed action add
YulNaumenko 298ee20
Fixed logging app icon
YulNaumenko 9c4abbb
Added action types params fields
YulNaumenko b656a49
Added fields for check and re-notify alert
YulNaumenko 1a631a2
Add tags to alert list
mikecote bf85dee
Adjusted threshold expression with validation, added visualization
YulNaumenko 5243ebe
Merge branch 'feature/alerting_ui' of github.com:elastic/kibana into …
YulNaumenko e5c43d4
Merge branch 'master' of github.com:elastic/kibana into feature/alert…
YulNaumenko d181322
Move delete button to the left and hide when no selection
mikecote ff24e96
Rename action list title column to name
mikecote 91d28f1
Merge branch 'feature/alerting_ui' of github.com:elastic/kibana into …
mikecote 4ca5289
fixed request
YulNaumenko 00a7e46
Merge branch 'feature/alerting_ui' of github.com:elastic/kibana into …
YulNaumenko a6ec116
Removed watcher labels
YulNaumenko 9b41eb1
Design cleanup
snide 5973bfb
Added expression default values
YulNaumenko 4ee5a27
Merge branch 'feature/alerting_ui' of github.com:elastic/kibana into …
YulNaumenko 2bad656
Added visualization for index threshold alert
YulNaumenko 9b83805
Merge branch 'master' of github.com:elastic/kibana into feature/alert…
mikecote cb64de5
Merge branch 'feature/alerting_ui' of github.com:elastic/kibana into …
mikecote ae9757a
Rename Actions tab to Connectors
mikecote 155f38e
Rename "create action" to "create connector"
mikecote 5ed0b68
Remove actions column name
mikecote 3fb9efd
Add count per action type
mikecote 84e90cc
Hide checkboxes when user can't delete
mikecote 3d57815
Add title to home, rename Alerting UI breadcrumb (remove UI part)
mikecote f3f55b8
Added correct binding for interval and throttle
YulNaumenko d3b37e9
Added tags support for create Alert UI
YulNaumenko 04443a2
Added server error display in UI on save alert
YulNaumenko 5473f02
Added connectors for action forms
YulNaumenko 4fd6783
Update button styles
mdefazio c6f2218
Switch inputs to compressed forms
mdefazio ba3172e
Fixed some fields for add alert form
YulNaumenko 2b3cb2d
Fixed updating action by index
YulNaumenko 88ee52e
Fixed filter for index/fields api requests
YulNaumenko a0560dd
Remove the test alert type that was in the init function
mikecote bb43d39
Fixed action type icon on add connector form and did small refactorin…
YulNaumenko 2281c23
Rename alerting UI plugin to triggers and actions UI (or something el…
YulNaumenko 966352c
Implemented action connector edit UI
YulNaumenko 577806e
Add bulk actions to alerts list
mikecote 2a4a8b4
Merge branch 'master' of github.com:elastic/kibana into feature/alert…
mikecote 13531c3
Update home title spacing
mdefazio abb18d1
Fixed editing secrets action property
YulNaumenko 2c0dfe1
Changing behaviour of bulk actions and disable buttons during request
mikecote dfb44e4
Merge branch 'feature/alerting_ui' of github.com:elastic/kibana into …
mikecote 01dcba6
Refactored plugin definition with appdependency interface
YulNaumenko 13372fa
Moved add dependencies to the separate file
YulNaumenko c59868c
Enable visualization if only hasExpressionErrors passed
YulNaumenko dc9c442
Fixed add action twice on click card
YulNaumenko 09f5701
Fix actions column in alert list
mikecote fcc6e4a
Fixed action canSave capability
YulNaumenko ee04144
Renamed Actions to ActionConnectors in appropriate UI files
YulNaumenko dcaa961
Renamed alertTypeParams to params in UI code
YulNaumenko 303ed70
Add filter for tags
mikecote c0c82e8
Merge branch 'feature/alerting_ui' of github.com:elastic/kibana into …
mikecote a9785aa
Cleanup previous commit
mikecote ce60ff8
Fix alert type filter
mikecote 59655bc
Refactored edit form to use ActionTableItem
YulNaumenko 7abe75e
Renamed ActionTableItem to ActionConnectorTableItem
YulNaumenko 114b4f1
Fixed missing button key error for alerts list filter
YulNaumenko c00175c
Renamed translation labels for connectors
YulNaumenko a60f5e1
Merge branch 'master' of github.com:elastic/kibana into feature/alert…
mikecote c2a3a64
Merge branch 'master' of github.com:elastic/kibana into feature/alert…
mikecote 9f2dfba
Enable UI plugin by default
mikecote 2b70b71
Rename buildin to builtin
mikecote 4a24c94
Fix some type checks
mikecote b9d8804
Add API tests
mikecote 466f847
Split API file into smaller files
mikecote f6daeb3
Rename plugin id
mikecote d567dae
Remove dependency on actions plugin (should be optional dep in NP)
mikecote e1f7095
Fix some translation ids
mikecote c059b15
Merge branch 'master' of github.com:elastic/kibana into feature/alert…
mikecote 48fd098
Revert "Rename plugin id"
mikecote 75679d2
Rename method for loading connectors
YulNaumenko 5a91c86
Added functional tests base
YulNaumenko 5bd6278
Fix functional test type filter
mikecote 9fc0bfb
Add test alert type for now
mikecote c86e99e
Initial connectors functional tests
mikecote b3cdc17
Merge branch 'master' of github.com:elastic/kibana into feature/alert…
mikecote 570a358
Rename description to name
mikecote b043787
Use unique connector names to allow re-running tests
mikecote fba026f
Assert on more things
mikecote a48bb41
Update alert/action menu items. Flyout width. Add index.scss file
mdefazio fbb80f9
Merge branch 'feature/alerting_ui' of github.com:elastic/kibana into …
mdefazio 3c9ddb8
Added action connector list unit tests
YulNaumenko 365367e
Add bulk delete functional test
mikecote 27bd7f1
Move tests to SSL functional environment
mikecote ef3ae58
Merge branch 'feature/alerting_ui' of github.com:elastic/kibana into …
mikecote e3cf18b
Fix tests
mikecote cbafbee
Added unit tests for actionTypeRegistry and alertTypeRegistry
YulNaumenko 5751d38
Fixed update connector with only properties
YulNaumenko baed2f6
Added some functional tests for alerts with TODOs
mikecote 0d36eee
Merge branch 'feature/alerting_ui' of github.com:elastic/kibana into …
mikecote ffb7e70
Merge branch 'master' of github.com:elastic/kibana into feature/alert…
mikecote f3531f4
connectors list page cleanup
snide 16fbe36
empty state cleanup
snide 01d9141
Added connector edit flyout unit test
YulNaumenko 411fee5
Fix functional tests
mikecote 898efbe
text cleanup
snide 6b0cbf4
zindex fix for index threshold trigger
snide be93011
Merge with master
mikecote 40f10e6
Expand the functional tests, add assertions
mikecote 2dc2ec6
Fixed edit connector from the Name column, and removed pencil button
YulNaumenko d6e46fb
Remove tags filter, use search bar instead
mikecote b182b7c
Finalize functional tests
mikecote 55bf039
Merge branch 'master' of github.com:elastic/kibana into feature/alert…
mikecote ec93614
Support filtering alerts by action type
mikecote 072c171
Rename plugin name for translations
mikecote a142566
Rename default breadcrumb title to alerts and actions
mikecote ac30692
Added unit tests for connectors empty prompt, fixed api tests
YulNaumenko b1a398a
Added unit test for select action type menu for create connector; Fix…
YulNaumenko eb3663b
Added unit test for edit connector flyout
YulNaumenko 4a7af57
Added alerts list unit tests
YulNaumenko 0c4bbe8
Added connector form unit tests
YulNaumenko e4dfa1a
Added connector reducer unit tests
YulNaumenko 1e59182
Fixed some failing unit tests
YulNaumenko b6d5f4e
Fixed alerts list unit tests
YulNaumenko da11d0a
Set alert tab default if it is available
YulNaumenko 8ecccba
Added doc_title and get_time_units unit tests
YulNaumenko 9d01113
Added some test fixes
YulNaumenko bc39d52
Fixed index threshold expression to display only index and fields
YulNaumenko c839bd2
Added email building action unit tests
YulNaumenko 68f7f55
Added unit tests for builtin action types
YulNaumenko 6e74238
Remove test alert type
mikecote a6b482c
Merge branch 'feature/alerting_ui' of github.com:elastic/kibana into …
mikecote e193caa
Move create alert UI behind feature flag 'createAlertUiEnabled'
mikecote 1ff33bd
Merge branch 'master' of github.com:elastic/kibana into feature/alert…
mikecote 80deb10
Merge with master
mikecote 8bf5e45
Fix functional tests
mikecote 5b32203
Update codeowners
mikecote 800b2de
Update codeowners for tests
mikecote 976b9e6
Merge with master
mikecote 9afd07a
Revert watcher changes
mikecote 283da53
Fix type check failure
mikecote cafd43a
Fix unit test failures
mikecote 7a8f191
Fixed typecheck failures
YulNaumenko dfe9adf
Fixed language check errors
YulNaumenko 95a16e2
Merge
mikecote b7710c7
Did some text/type fixes
YulNaumenko b81cefb
Fixed typecheck
YulNaumenko 17500c0
Fixed unit tests warning
YulNaumenko f5b6bce
Merge remote-tracking branch 'upstream/master' into feature/alerting_ui
YulNaumenko 5eae8c4
Merge branch 'master' of github.com:elastic/kibana into feature/alert…
mikecote 62dd2ba
Fix failing functional tests
mikecote 1eb9730
Merge branch 'feature/alerting_ui' of github.com:elastic/kibana into …
mikecote 476c7e4
Merge branch 'master' into feature/alerting_ui
elasticmachine 2175d2f
Merge with master
mikecote 91ef622
Merge branch 'feature/alerting_ui' of github.com:elastic/kibana into …
mikecote 8717324
Fix registry tests to have cleaner diff when it fails
mikecote b47e464
Make DEFAULT_SECTION a Section type
mikecote 3ed00b9
Remove unused constructor
mikecote 731de1f
Make app dependency error string same line
mikecote 6b23551
Remove unused error pages
mikecote 79b0e3f
Set interface to alerts context
mikecote bd68e93
Fix action_connector_form.tsx label
mikecote 87e35e8
Fix label in connector_add_flyout.tsx
mikecote f484f39
Fix label in alert_add.tsx
mikecote 016442f
Move alert_types to builtin_alert_types
mikecote 2a77efe
Move some threshold constants into threshold folder
mikecote 391659d
Move api.ts within threshold folder
mikecote 7e6c7ce
Removed duplication logic from action type and alert type registry list
YulNaumenko 8eadea7
Fixed email action type test and adjusted validation to support array…
YulNaumenko c505ec5
Added missing connector fields for email action type
YulNaumenko 9c252ce
Fixed building action types issues due to comments
YulNaumenko cc92af3
Merge remote-tracking branch 'upstream/master' into feature/alerting_ui
YulNaumenko fe88d50
Refactored with more new platform structure; fixed some comments from…
YulNaumenko 44e10ab
Capitalize Actions in 'Alerts and Actions' labels
mikecote 6802121
Skip flaky tests
mikecote 4827d42
Fix failing functional test
mikecote e9e6a72
Fixed failing unit tests, added new deps
YulNaumenko 74ac9c7
Fixed type checks
YulNaumenko db14343
Fixed language check failing
YulNaumenko 7640f8f
Fix broken functional tests
mikecote b8bafc7
Merge branch 'feature/alerting_ui' of github.com:elastic/kibana into …
mikecote bd27411
Refactored actionConnectors and alerting context
YulNaumenko 69da968
Removed doc title service
YulNaumenko f67df65
added get time options type definitions
YulNaumenko 007bdcd
removed obsolete code
YulNaumenko 95488ea
Made generic registry type for actionTypes and alert types
YulNaumenko 6aafd1b
Fixed some enum types
YulNaumenko 23e2226
fixed type check CI
YulNaumenko e827726
Merge branch 'master' into feature/alerting_ui
elasticmachine 0b48b65
Convert EuiSearchBar to normal text field
mikecote e61c5b9
Fix typo
mikecote 3f4bdc5
Fix conditional rendering
mikecote 0b4fc6a
Fix bug where selection doesn't reset
mikecote a1ef419
Fix broken functional test, wait for ENTER key to search alerts
mikecote 986b6be
Make app section hide from menu when user doesn't have access
mikecote 84bd617
Fixed connector name validation (error due to renaming from description)
YulNaumenko e55c177
Merge branch 'master' into feature/alerting_ui
elasticmachine 7eb158b
Removed obsolete useEffect
YulNaumenko efde341
Removed unused ShareRouter
YulNaumenko 60ff7f7
Fixed key validation error
YulNaumenko 62f3fce
Mobed wrongly wrapped objects
YulNaumenko 54d44e7
Removed useEffect from connectors form
YulNaumenko db0aa95
Replaced error forms with eui controls props
YulNaumenko 70703a6
Merge remote-tracking branch 'upstream/master' into feature/alerting_ui
YulNaumenko 75de8ef
Added delete confirmation dialog for connectors list
YulNaumenko fcb6369
Fixed build errors
YulNaumenko f16b6d5
Fixed failing test
YulNaumenko 8a1e52c
Skip flaky tests
mikecote c2b6b0e
Merge remote-tracking branch 'upstream/master' into feature/alerting_ui
YulNaumenko 95006d5
Added null check for app context - render components tree only if it …
YulNaumenko 072ec10
Fixed type check eror
YulNaumenko 1d2a59a
Did changes on the UX and text/labels commnets
YulNaumenko 3618cf1
Fixed failing tests
YulNaumenko 3004376
Fixed error handling
YulNaumenko 91728db
Refactored Webhook form http headers due to the mockup
YulNaumenko 526bb77
Merge remote-tracking branch 'upstream/master' into feature/alerting_ui
YulNaumenko 5f77632
Fixed build
YulNaumenko b41fe8c
Fix labels issue
YulNaumenko f094111
Fix spacing and form row alignment
mdefazio 3e2041c
Merge branch 'feature/alerting_ui' of github.com:elastic/kibana into …
mdefazio a708f36
Merge remote-tracking branch 'upstream/master' into feature/alerting_ui
YulNaumenko b77fe1f
Fixed failing type check
YulNaumenko 5acaa1a
put ownfocus on popover in actions list
snide 3b9fdc6
fix spacing and flex
snide 38c2101
fix color on conectors list
snide 45c4349
clean up webhook headers form
snide 9f9a178
fix logic check for headers
snide dded831
Merge remote-tracking branch 'upstream/master' into feature/alerting_ui
YulNaumenko e424285
Made changes due to review comments
YulNaumenko dd816ac
Fixed delete connector test
YulNaumenko 982e840
Fixed all flaky test for delete connectors 53956
YulNaumenko 3ffa5c5
Merge remote-tracking branch 'upstream/master' into feature/alerting_ui
YulNaumenko 17f41b3
Merge remote-tracking branch 'upstream/master' into feature/alerting_ui
YulNaumenko 440f5de
Fixed type check due to NP changes
YulNaumenko 6175139
Disable plugin by default
YulNaumenko fd464ef
Added configuration props for functional tests to enable triggers and…
YulNaumenko 96eecb3
Merge remote-tracking branch 'upstream/master' into feature/alerting_ui
YulNaumenko bc68537
removed timeout from test
YulNaumenko aa3cadf
added enable triggers and actions to functional/config.js
YulNaumenko efc01b2
fix the build
YulNaumenko 9b4c918
Merge branch 'master' into feature/alerting_ui
a78ebcd
Changed ci group and disabled plugin
YulNaumenko 4d531b7
Merge remote-tracking branch 'upstream/master' into feature/alerting_ui
YulNaumenko 7352c20
changed config setting to root
YulNaumenko 6f30661
Changed disable approach
YulNaumenko be1e127
Experiment with index managment
YulNaumenko 87165be
Set back configuration settings for triggers and actions
YulNaumenko 3b9d9b8
Enable plugins
YulNaumenko 8690d22
Set index management to disabled to see the failing issue
YulNaumenko c8a1325
Merge branch 'master' into feature/alerting_ui
elasticmachine 7431dca
Revert experimental back for index_managment
YulNaumenko af3b544
Merge branch 'feature/alerting_ui' of github.com:elastic/kibana into …
YulNaumenko 14f5ab5
Fixed type check
YulNaumenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Validating CODEOWNERS rules …
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { Legacy } from 'kibana'; | ||
import { Root } from 'joi'; | ||
import { resolve } from 'path'; | ||
|
||
export function triggersActionsUI(kibana: any) { | ||
return new kibana.Plugin({ | ||
id: 'triggers_actions_ui', | ||
mikecote marked this conversation as resolved.
Show resolved
Hide resolved
|
||
configPrefix: 'xpack.triggers_actions_ui', | ||
isEnabled(config: Legacy.KibanaConfig) { | ||
return ( | ||
config.get('xpack.triggers_actions_ui.enabled') && | ||
(config.get('xpack.actions.enabled') || config.get('xpack.alerting.enabled')) | ||
); | ||
}, | ||
publicDir: resolve(__dirname, 'public'), | ||
require: ['kibana'], | ||
config(Joi: Root) { | ||
return Joi.object() | ||
.keys({ | ||
enabled: Joi.boolean().default(false), | ||
createAlertUiEnabled: Joi.boolean().default(false), | ||
}) | ||
.default(); | ||
}, | ||
uiExports: { | ||
home: ['plugins/triggers_actions_ui/hacks/register'], | ||
managementSections: ['plugins/triggers_actions_ui/legacy'], | ||
styleSheetPaths: resolve(__dirname, 'public/index.scss'), | ||
injectDefaultVars(server: Legacy.Server) { | ||
const serverConfig = server.config(); | ||
return { | ||
createAlertUiEnabled: serverConfig.get('xpack.triggers_actions_ui.createAlertUiEnabled'), | ||
}; | ||
}, | ||
}, | ||
}); | ||
} |
6 changes: 6 additions & 0 deletions
6
x-pack/legacy/plugins/triggers_actions_ui/np_ready/kibana.json
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,6 @@ | ||
{ | ||
"id": "triggers_actions_ui", | ||
"version": "kibana", | ||
"server": false, | ||
"ui": true | ||
} |
21 changes: 21 additions & 0 deletions
21
...gacy/plugins/triggers_actions_ui/np_ready/public/application/action_type_registry.mock.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,21 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { ActionTypeRegistryContract } from '../types'; | ||
|
||
const createActionTypeRegistryMock = () => { | ||
const mocked: jest.Mocked<ActionTypeRegistryContract> = { | ||
has: jest.fn(x => true), | ||
register: jest.fn(), | ||
get: jest.fn(), | ||
list: jest.fn(), | ||
}; | ||
return mocked; | ||
}; | ||
|
||
export const actionTypeRegistryMock = { | ||
create: createActionTypeRegistryMock, | ||
}; |
21 changes: 21 additions & 0 deletions
21
...egacy/plugins/triggers_actions_ui/np_ready/public/application/alert_type_registry.mock.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,21 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { AlertTypeRegistryContract } from '../types'; | ||
|
||
const createAlertTypeRegistryMock = () => { | ||
const mocked: jest.Mocked<AlertTypeRegistryContract> = { | ||
has: jest.fn(), | ||
register: jest.fn(), | ||
get: jest.fn(), | ||
list: jest.fn(), | ||
}; | ||
return mocked; | ||
}; | ||
|
||
export const alertTypeRegistryMock = { | ||
create: createAlertTypeRegistryMock, | ||
}; |
64 changes: 64 additions & 0 deletions
64
x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/app.tsx
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,64 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import React from 'react'; | ||
import { Switch, Route, Redirect, HashRouter } from 'react-router-dom'; | ||
import { | ||
ChromeStart, | ||
DocLinksStart, | ||
ToastsSetup, | ||
HttpSetup, | ||
IUiSettingsClient, | ||
} from 'kibana/public'; | ||
import { BASE_PATH, Section } from './constants'; | ||
import { TriggersActionsUIHome } from './home'; | ||
import { AppContextProvider, useAppDependencies } from './app_context'; | ||
import { hasShowAlertsCapability } from './lib/capabilities'; | ||
import { LegacyDependencies, ActionTypeModel, AlertTypeModel } from '../types'; | ||
import { TypeRegistry } from './type_registry'; | ||
|
||
export interface AppDeps { | ||
chrome: ChromeStart; | ||
docLinks: DocLinksStart; | ||
toastNotifications: ToastsSetup; | ||
injectedMetadata: any; | ||
http: HttpSetup; | ||
uiSettings: IUiSettingsClient; | ||
legacy: LegacyDependencies; | ||
actionTypeRegistry: TypeRegistry<ActionTypeModel>; | ||
alertTypeRegistry: TypeRegistry<AlertTypeModel>; | ||
} | ||
|
||
export const App = (appDeps: AppDeps) => { | ||
const sections: Section[] = ['alerts', 'connectors']; | ||
|
||
const sectionsRegex = sections.join('|'); | ||
|
||
return ( | ||
<HashRouter> | ||
<AppContextProvider appDeps={appDeps}> | ||
<AppWithoutRouter sectionsRegex={sectionsRegex} /> | ||
</AppContextProvider> | ||
</HashRouter> | ||
); | ||
}; | ||
|
||
export const AppWithoutRouter = ({ sectionsRegex }: any) => { | ||
const { | ||
legacy: { capabilities }, | ||
} = useAppDependencies(); | ||
const canShowAlerts = hasShowAlertsCapability(capabilities.get()); | ||
const DEFAULT_SECTION: Section = canShowAlerts ? 'alerts' : 'connectors'; | ||
return ( | ||
<Switch> | ||
<Route | ||
exact | ||
path={`${BASE_PATH}/:section(${sectionsRegex})`} | ||
component={TriggersActionsUIHome} | ||
/> | ||
<Redirect from={`${BASE_PATH}`} to={`${BASE_PATH}/${DEFAULT_SECTION}`} /> | ||
</Switch> | ||
); | ||
}; |
30 changes: 30 additions & 0 deletions
30
x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/app_context.tsx
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,30 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React, { createContext, useContext } from 'react'; | ||
import { AppDeps } from './app'; | ||
|
||
const AppContext = createContext<AppDeps | null>(null); | ||
|
||
export const AppContextProvider = ({ | ||
children, | ||
appDeps, | ||
}: { | ||
appDeps: AppDeps | null; | ||
children: React.ReactNode; | ||
}) => { | ||
return appDeps ? <AppContext.Provider value={appDeps}>{children}</AppContext.Provider> : null; | ||
}; | ||
|
||
export const useAppDependencies = (): AppDeps => { | ||
const ctx = useContext(AppContext); | ||
if (!ctx) { | ||
throw new Error( | ||
'The app dependencies Context has not been set. Use the "setAppDependencies()" method when bootstrapping the app.' | ||
); | ||
} | ||
return ctx; | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing stack monitoring would need the same sort of settings, but they don't actually need it right now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it was discussed here #52286 (comment) that they would take on the changes required for feature controls within their feature branch.