Skip to content
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

[ML] Maps integration: add empty state prompt when no supported jobs exist #125878

Merged

Conversation

alvarezmelissa87
Copy link
Contributor

@alvarezmelissa87 alvarezmelissa87 commented Feb 16, 2022

Summary

Related meta issue: #123492

When there are no ML jobs available for selection in the wizard shows a prompt with a link to ML job management page.

image

Checklist

Delete any items that are not applicable to this PR.

@alvarezmelissa87 alvarezmelissa87 added :ml release_note:skip Skip the PR/issue when compiling release notes v8.2.0 labels Feb 16, 2022
@alvarezmelissa87 alvarezmelissa87 requested a review from a team as a code owner February 16, 2022 22:01
@alvarezmelissa87 alvarezmelissa87 self-assigned this Feb 16, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

@@ -45,18 +46,23 @@ export class AnomalyLayerWizardFactory {
this.canGetJobs = canGetJobs;
}

private async getServices(): Promise<{ mlJobsService: MlApiServices['jobs'] }> {
const [coreStart] = await this.getStartServices();
private async getServices(): Promise<{ mlJobsService: MlApiServices['jobs']; mlLocator: any }> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can update mlLocator here to use MlLocator type from ml/common/types/locator. Note that locators.get() can return undefined as well 👀

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated type from any in cb6ff5f3e2f81603a2a34444a7f777206e504896

}

public async create(): Promise<LayerWizard> {
const { mlJobsService } = await this.getServices();
const { mlJobsService, mlLocator } = await this.getServices();
const jobsManagementPath = await mlLocator.getUrl({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since locators.get() can return undefined, would be good to handle the scenario for when mlLocator is undefined. Suggestion to console.error/throw error if that's the case.

Also should we be checking if user has permission to create jobs or not before showing the Create jobs prompt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call - added canCreateJob check and disabled the creation prompt if user doesn't have creation permission in cb6ff5f3e2f81603a2a34444a7f777206e504896

Also added undefined mlLocator check in this change. Now the user will only see the empty prompt if the locator is defined.

@lcawl lcawl added the ui-copy Review of UI copy with docs team is recommended label Feb 17, 2022
Copy link
Contributor

@lcawl lcawl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UI text LGTM

@alvarezmelissa87
Copy link
Contributor Author

This has been updated and is ready for another look when you get a chance. 🙏 cc @qn895, @jgowdyelastic

@qn895
Copy link
Member

qn895 commented Feb 17, 2022

Tested and LGTM 🎉 Unrelated to this PR but I realized after navigating to our ML job management, it wasn't clear/obvious right away where the Create job is since the button is to the right and is quite small. Perhaps we can bring the button to more front and center, or redirect to the create job right away based on the selected index pattern selected in Maps. Just thoughts for possible future enhancements :)

@alvarezmelissa87 alvarezmelissa87 force-pushed the ml-maps-integration-updates branch from cb6ff5f to 212fb40 Compare February 17, 2022 19:43
Copy link
Member

@jgowdyelastic jgowdyelastic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some small comments, on the whole LGTM

}

return (
const supportedJobsExist = this.state.jobIdList?.length && this.state.jobIdList?.length > 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit pick, this could be !!this.state.jobIdList?.length

</h2>
}
body={
<>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fragment isn't needed

@@ -177,7 +177,8 @@ export class MlPlugin implements Plugin<MlPluginSetup, MlPluginStart> {
if (pluginsSetup.maps) {
// Pass capabilites.ml.canGetJobs as minimum permission to show anomalies card in maps layers
const canGetJobs = capabilities.ml?.canGetJobs === true || false;
await registerMapExtension(pluginsSetup.maps, core, canGetJobs);
const canCreateJobs = capabilities.ml?.canCreateJob === true || false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might be worth changing both of these checks to use ??

@alvarezmelissa87 alvarezmelissa87 force-pushed the ml-maps-integration-updates branch from 212fb40 to ffd40cb Compare February 23, 2022 16:12
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
ml 1612 1613 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
ml 3.5MB 3.5MB +1.6KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
ml 39.1KB 39.2KB +86.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
ml 97 98 +1

Total ESLint disabled count

id before after diff
ml 99 100 +1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @alvarezmelissa87

@alvarezmelissa87 alvarezmelissa87 merged commit c5a1a90 into elastic:main Feb 23, 2022
@alvarezmelissa87 alvarezmelissa87 deleted the ml-maps-integration-updates branch February 23, 2022 22:11
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 125878 or prevent reminders by adding the backport:skip label.

@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Feb 25, 2022
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 125878 or prevent reminders by adding the backport:skip label.

@peteharverson peteharverson added the backport:skip This commit does not require backporting label Mar 1, 2022
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Mar 1, 2022
lucasfcosta pushed a commit to lucasfcosta/kibana that referenced this pull request Mar 2, 2022
…exist (elastic#125878)

* add empty state prompt when no supported jobs exist

* fix formatting

* check creation permission. update types

* remove unnecessary fragment and update permission check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting :ml release_note:skip Skip the PR/issue when compiling release notes ui-copy Review of UI copy with docs team is recommended v8.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants