-
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
[ML] Maps integration: add empty state prompt when no supported jobs exist #125878
[ML] Maps integration: add empty state prompt when no supported jobs exist #125878
Conversation
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 }> { |
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 think we can update mlLocator
here to use MlLocator
type from ml/common/types/locator
. Note that locators.get() can return undefined as well 👀
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.
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({ |
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.
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?
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.
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.
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.
UI text LGTM
This has been updated and is ready for another look when you get a chance. 🙏 cc @qn895, @jgowdyelastic |
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 |
cb6ff5f
to
212fb40
Compare
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.
Added some small comments, on the whole LGTM
} | ||
|
||
return ( | ||
const supportedJobsExist = this.state.jobIdList?.length && this.state.jobIdList?.length > 0; |
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.
nit pick, this could be !!this.state.jobIdList?.length
</h2> | ||
} | ||
body={ | ||
<> |
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.
this fragment isn't needed
x-pack/plugins/ml/public/plugin.ts
Outdated
@@ -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; |
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.
it might be worth changing both of these checks to use ??
212fb40
to
ffd40cb
Compare
💚 Build SucceededMetrics [docs]Module Count
Async chunks
Page load bundle
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
…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
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.
Checklist
Delete any items that are not applicable to this PR.