-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Insight URL cleanup #7201
Insight URL cleanup #7201
Conversation
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 ready for a look.
let logic: ReturnType<typeof renameModalLogic.build> | ||
let relevantEntityFilterLogic: ReturnType<typeof entityFilterLogic.build> |
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 file is a kind of flyby cleanup 🤷
@@ -65,7 +65,7 @@ export const insightDateFilterLogic = kea<insightDateFilterLogicType>({ | |||
}, | |||
}), | |||
urlToAction: ({ actions, values }) => ({ | |||
'/insights': (_: any, { date_from, date_to }: UrlParams) => { | |||
'/insights/': (_: any, { date_from, date_to }: UrlParams) => { |
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.
With /
in the end to catch /insights/1
and not catch /insights
. This will be refactored very soon (the filters shouldn't talk through the url, but with the insight directly), so keeping as a quick fix.
(!loadedFromAnotherLogic && !objectsEqual(cleanSearchParams, values.filters)) || | ||
insightModeFromUrl !== values.insightMode | ||
) { | ||
actions.setFilters(cleanSearchParams, insightModeFromUrl) |
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 had to merge setFilters
and setInsightMode
, since otherwise they would change the URL in multiple steps (go back/forward between e.g. /insights/12
and /insights/23/edit
would cause a lot of url noise with first the edit and then the filters being added)
if ( | ||
[ | ||
`api/projects/${MOCK_TEAM_ID}/insights/path`, | ||
`api/projects/${MOCK_TEAM_ID}/insights/paths/`, | ||
`api/projects/${MOCK_TEAM_ID}/insights/123`, | ||
`api/projects/${MOCK_TEAM_ID}/insights`, | ||
].includes(pathname) |
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.
Flyby change with the goal of reducing noise in jest tests.
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.
Overall looks great! Just a couple of details I think it'd be good to hash out
if (hashParams.fromItem) { | ||
// `fromItem` for legacy /insights url redirect support |
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 gives us backwards compatibility for fromItem
URLs, but those without fromItem
don't work anymore. I think it may be worth retaining support for this to avoid frustrating users who have old links. Though that would probably require creating a new insight record every time such a link is accessed (createAndRedirectToNewInsight
-style), which is not ideal. Your call, let's just make the decision explicit.
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.
Fixed!
Any thoughts on using |
As for the last commit, that's fixed in |
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.
There's just one thing: "Save as new insight" results in a new insight that's a blank slate (this is also the case on #7259). I looked into it for a bit but not sure why.
I didn't understand the issue initially. This is probably the fix you wanted to see: @Twixes anything else blocking here? |
0719343
to
a6d210b
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.
Yup! All is well now
* convert a bunch of things to user short_id instead of id * fix more TS errors * fix test * fix jest tests * various fixes * add wise words * type InsightShortId-s to make life easier * reduce a bit of test noise * use the InsightShortId in the URL * fix type * fix test * fix insight url preloading * pass dive dashboards as having insight short ids * fix short url redirect * mock scenelogic api * better types and tests * type fixes * fix bug of linking to ourselves * add back "id" * get rid of some "getInsightId" calls * two more * few more * refactor last usage of getInsightId * move files around and improve errors * make it simpler * small fixes * redirect to new url from old hashParam=42 * fix regression * alert the user if we could not find an insight with the old ID format * switch to a simpler scene * fix another test * Fix annotation creation * Make short ID friendlier * remove comments * simplify insight links from dashboards and saved insights * remove insight router * fix TS * Revert "remove insight router" This reverts commit e52f474. Co-authored-by: Michael Matloka <dev@twixes.com>
Changes
/insights
==urls.savedInsights()
/insights/new
==urls.newInsight()
-- redirects after creation to the edit page/insights/123
==urls.insightsView(123)
/insights/123?insight=TRENDS
==urls.insightsView(123, { insight: 'TRENDS' })
/insights/123/edit
==urls.insightsEdit(123)
/insights/123/edit?insight=TRENDS
==urls.insightsEdit(123, { insight: 'TRENDS' })
newInsight
vsinsightNew
vsinsightsNew
? What to use?For another PR
/insights/123#q={insight:'TRENDS'}
How did you test this code?