-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Single view in app function for rule actions variables and UI page (#…
…148671) Resolves: #145132. In this PR, I'm adding a new function to the server-side rule type definition called `viewInAppRelativeUrl`. This function returns a relative path to view the rule in the proper application that will provide more context. This relative path is used to build the `rule.url` mustache variable for the actions (overriding the rule details page link when defined) as well as a fallback for the UI's `View in App` button if no navigation is registered on the front-end. Follow up issues: - #149608 - #151355 ## ML to verify 1. Create an anomaly detection rule from the ML application 2. Go to stack management rule details page 3. Click "View in App" 4. Ensure it brings you to the ML app properly. 5. Repeat step 1 to 4 in a space that isn't the default Note: ML won't take advantage of the new functionality yet, but we plan to help in a follow up #149608 so that ML anomaly detection rules can provide a view in app URL within the rule action messages. ## ResponseOps to verify 1. Set `server.publicBaseUrl` to the proper value in your kibana.yml 6. Modify the [index threshold rule type](https://github.com/elastic/kibana/blob/main/x-pack/plugins/stack_alerts/server/rule_types/index_threshold/rule_type.ts#L108-L136) to have a `getViewInAppRelativeUrl` function returning `/app/management/insightsAndAlerting/triggersActionsConnectors/connectors`. 7. Create an index threshold rule that always fires. Make sure to add a a server log action that contains the `{{rule.url}}` variable. 8. Pull the printed URL from the server logs and make sure it works and brings you to the connectors page. 9. Navigate to the rule details page, click the "View in App" button and ensure it also brings you to the connectors page. 10. Create a Kibana space. 11. Go into that created space and repeat step 3 to 5. Ensure the URL and View in App keep you in the same space. --------- Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
2406ada
commit ccd78c9
Showing
25 changed files
with
156 additions
and
89 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
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 was deleted.
Oops, something went wrong.
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,35 @@ | ||
/* | ||
* 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 { AlertingPublicPlugin } from './plugin'; | ||
import { coreMock } from '@kbn/core/public/mocks'; | ||
|
||
jest.mock('./alert_api', () => ({ | ||
loadRule: jest.fn(), | ||
loadRuleType: jest.fn(), | ||
})); | ||
|
||
describe('Alerting Public Plugin', () => { | ||
describe('start()', () => { | ||
it(`should fallback to the viewInAppRelativeUrl part of the rule object if navigation isn't registered`, async () => { | ||
const { loadRule, loadRuleType } = jest.requireMock('./alert_api'); | ||
loadRule.mockResolvedValue({ | ||
alertTypeId: 'foo', | ||
consumer: 'abc', | ||
viewInAppRelativeUrl: '/my/custom/path', | ||
}); | ||
loadRuleType.mockResolvedValue({}); | ||
|
||
const plugin = new AlertingPublicPlugin(); | ||
plugin.setup(); | ||
const pluginStart = plugin.start(coreMock.createStart()); | ||
|
||
const navigationPath = await pluginStart.getNavigation('123'); | ||
expect(navigationPath).toEqual('/my/custom/path'); | ||
}); | ||
}); | ||
}); |
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
17 changes: 0 additions & 17 deletions
17
x-pack/plugins/alerting/server/rules_client/common/calculate_is_snoozed_until.ts
This file was deleted.
Oops, something went wrong.
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.