-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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] WIP - Extend MlUrlGenerator & convert ML urls to non-hash #74985
Conversation
@@ -22,6 +22,23 @@ import { stringify, ParsedQuery } from 'query-string'; | |||
import { parseUrl, parseUrlHash } from './parse'; | |||
import { url as urlUtils } from '../../../common'; | |||
|
|||
export function replaceUrlQuery( |
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 don't think you should change the content of kibana_utils
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.
That change is now merged in here #74955.
@@ -65,40 +163,214 @@ export class MlUrlGenerator implements UrlGeneratorsDefinition<typeof ML_APP_URL | |||
public readonly id = ML_APP_URL_GENERATOR; | |||
|
|||
public readonly createUrl = async ({ page, ...params }: MlUrlGeneratorState): Promise<string> => { | |||
if (page === 'explorer') { | |||
return this.createExplorerUrl(params); | |||
if (page === ML_TABS.ANOMALY_DETECTION) { |
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.
Please remove destructuring from the function arguments, and change to something like
if (page === ML_TABS.ANOMALY_DETECTION) { | |
public readonly createUrl = async (mlUrlGeneratorState: MlUrlGeneratorState): Promise<string> => { | |
switch(mlUrlGeneratorState) { | |
case mlUrlGeneratorState.page === ML_TABS.ANOMALY_DETECTION: | |
return this.createAnomalyDetectionJobManagementUrl(mlUrlGeneratorState) | |
} |
in that case, TS will take care of typecasting and there is no need to do it manually.
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 is a good spot. And with this way it's much cleaner too! Thanks 🙏
Pinging @elastic/ml-ui (:ml) |
3c21d70
to
98dd2e5
Compare
💔 Build Failed
Failed CI StepsTest FailuresX-Pack Jest Tests.x-pack/plugins/lens/public/app_plugin.Lens App sets originatingApp breadcrumb when the document title changesStandard Out
Stack Trace
Build metrics@kbn/optimizer bundle module count
async chunks size
page load bundle size
History
To update your PR or re-run it, just comment with: |
Summary
Part of #69265
This DRAFT PR is a WIP attempt to consolidate the url generating service within the ML plugin.
Current it's contingent on this PR #74955 being merged in, but the original commit from that PR is being included here to prevent typescript from breaking.
It's not currently replacing everything yet, just snippets to see how it would work if replaced. For example, it can be used by other team's with Kibana's
navigateToUrl
or our own Ml's
navigateToPath
which can optionally preserve the search queries