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

Routing for surrounding doc link should work without a question mark appending to the end #5776

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/plugins/discover/public/migrate_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function migrateUrlState(oldPath: string, newPath = '/'): string {
let path = newPath;
const pathPatterns = [
{
pattern: '#/context/:indexPattern/:id\\?:appState?',
pattern: '#/context/:indexPattern/:id?:appState?',
Copy link
Member

Choose a reason for hiding this comment

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

This works because the a route like #/context/ip/abcd results in indexPattern = ip, id = a and appState = bcd

But it looks like we dont need the appState so lets just change the paths to

    {
      pattern: '#/context/:indexPattern/:id',
      extraState: { docView: 'context' },
      path: `context`,
    },
    {
      pattern: '#/doc/:indexPattern/:index',
      extraState: { docView: 'doc' },
      path: `doc`,
    },

Also you forgot to add the break statement after line 101

Copy link
Member Author

Choose a reason for hiding this comment

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

I dont think we need to add the break statement on line 101? since it will return path anyway @ashwin-pc

Copy link
Member

@ashwin-pc ashwin-pc Feb 2, 2024

Choose a reason for hiding this comment

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

So the way a switch statement works is that once it matches a particular switch case, everything under that is executed until it hits a break or a default statement. So in this case, once the doc or context parts are matched, all commands under that are executed until it hits the final break statement, which means that everything inside the discover path is also executed. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch

Copy link
Member

Choose a reason for hiding this comment

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

Can you also remove the appstate from the doc route?

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

extraState: { docView: 'context' },
path: `context`,
},
Expand Down
Loading