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

Replace url instead of pushing when changing properties/filters #4966

Merged
merged 2 commits into from
Jul 2, 2021
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ export const chartFilterLogic = kea<chartFilterLogicType>({
searchParams.display = values.chartFilter

if (!objectsEqual(display, values.chartFilter)) {
router.actions.push(pathname, searchParams)
router.actions.replace(pathname, searchParams)
}
},
}),
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ export const compareFilterLogic = kea<compareFilterLogicType>({
searchParams.compare = values.compare

if (!objectsEqual(compare, values.compare)) {
router.actions.push(pathname, searchParams)
router.actions.replace(pathname, searchParams)
}
},
toggleCompare: () => {
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ export const intervalFilterLogic = kea<intervalFilterLogicType>({
searchParams.interval = values.interval

if (!objectsEqual(interval, values.interval)) {
router.actions.push(pathname, searchParams)
router.actions.replace(pathname, searchParams)
}
},
setDateFrom: () => {
@@ -41,7 +41,7 @@ export const intervalFilterLogic = kea<intervalFilterLogicType>({
searchParams.date_from = values.dateFrom

if (!objectsEqual(date_from, values.dateFrom)) {
router.actions.push(pathname, searchParams)
router.actions.replace(pathname, searchParams)
}
},
}),
Original file line number Diff line number Diff line change
@@ -84,7 +84,7 @@ export const propertyFilterLogic = kea<propertyFilterLogicType>({
searchParams.properties = cleanedFilters

if (!objectsEqual(properties, cleanedFilters)) {
router.actions.push(pathname, searchParams)
router.actions.replace(pathname, searchParams)
}
}
},
1 change: 1 addition & 0 deletions frontend/src/scenes/events/eventsTableLogic.js
Original file line number Diff line number Diff line change
@@ -178,6 +178,7 @@ export const eventsTableLogic = kea({
properties: values.properties,
},
window.location.hash,
{ replace: true },
]
},
}),
4 changes: 2 additions & 2 deletions frontend/src/scenes/funnels/funnelLogic.ts
Original file line number Diff line number Diff line change
@@ -247,12 +247,12 @@ export const funnelLogic = kea<funnelLogicType>({
actionToUrl: ({ values, props }) => ({
setSteps: () => {
if (!props.dashboardItemId) {
return ['/insights', values.propertiesForUrl]
return ['/insights', values.propertiesForUrl, undefined, { replace: true }]
}
},
clearFunnel: () => {
if (!props.dashboardItemId) {
return ['/insights', { insight: ViewType.FUNNELS }]
return ['/insights', { insight: ViewType.FUNNELS }, undefined, { replace: true }]
}
},
}),
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ export const insightDateFilterLogic = kea<insightDateFilterLogicType>({
(pathname === '/insights' && !objectsEqual(date_from, values.dates.dateFrom)) ||
!objectsEqual(date_to, values.dates.dateTo)
) {
router.actions.push(pathname, searchParams)
router.actions.replace(pathname, searchParams)
}
},
dateAutomaticallyChanged: async (_, breakpoint) => {
4 changes: 2 additions & 2 deletions frontend/src/scenes/paths/pathsLogic.ts
Original file line number Diff line number Diff line change
@@ -181,10 +181,10 @@ export const pathsLogic = kea<pathsLogicType<PathNode, PathResult>>({
},
actionToUrl: ({ values }) => ({
setProperties: () => {
return ['/insights', values.propertiesForUrl]
return ['/insights', values.propertiesForUrl, undefined, { replace: true }]
},
setFilter: () => {
return ['/insights', values.propertiesForUrl]
return ['/insights', values.propertiesForUrl, undefined, { replace: true }]
},
}),
urlToAction: ({ actions, values, key }) => ({
2 changes: 1 addition & 1 deletion frontend/src/scenes/persons/personsLogic.ts
Original file line number Diff line number Diff line change
@@ -177,7 +177,7 @@ export const personsLogic = kea<personsLogicType<PersonPaginatedResponse>>({
actionToUrl: ({ values, props }) => ({
setListFilters: () => {
if (props.updateURL && router.values.location.pathname.indexOf('/persons') > -1) {
return ['/persons', values.listFilters]
return ['/persons', values.listFilters, undefined, { replace: true }]
}
},
navigateToTab: () => {
4 changes: 2 additions & 2 deletions frontend/src/scenes/retention/retentionTableLogic.ts
Original file line number Diff line number Diff line change
@@ -146,13 +146,13 @@ export const retentionTableLogic = kea<retentionTableLogicType>({
if (props.dashboardItemId) {
return // don't use the URL if on the dashboard
}
return ['/insights', values.filters, router.values.hashParams]
return ['/insights', values.filters, router.values.hashParams, { replace: true }]
},
setProperties: () => {
if (props.dashboardItemId) {
return // don't use the URL if on the dashboard
}
return ['/insights', values.filters, router.values.hashParams]
return ['/insights', values.filters, router.values.hashParams, { replace: true }]
},
}),
urlToAction: ({ actions, values, key }) => ({
11 changes: 7 additions & 4 deletions frontend/src/scenes/sessions/sessionsTableLogic.ts
Original file line number Diff line number Diff line change
@@ -233,7 +233,10 @@ export const sessionsTableLogic = kea<sessionsTableLogicType<SessionRecordingId>
},
}),
actionToUrl: ({ values }) => {
const buildURL = (overrides: Partial<Params> = {}): [string, Params, Record<string, any>] => {
const buildURL = (
overrides: Partial<Params> = {},
replace = false
): [string, Params, Record<string, any>, { replace: boolean }] => {
const today = dayjs().startOf('day').format('YYYY-MM-DD')

const { properties } = router.values.searchParams
@@ -246,12 +249,12 @@ export const sessionsTableLogic = kea<sessionsTableLogicType<SessionRecordingId>
...overrides,
}

return [router.values.location.pathname, params, router.values.hashParams]
return [router.values.location.pathname, params, router.values.hashParams, { replace }]
}

return {
setFilters: () => buildURL(),
loadSessions: () => buildURL(),
setFilters: () => buildURL({}, true),
loadSessions: () => buildURL({}, true),
setSessionRecordingId: () => buildURL(),
closeSessionPlayer: () => buildURL({ sessionRecordingId: undefined }),
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, why did you chose to make an exception here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You mean the last two? They basically go from the list to a individual recording, so that's basically going to a separate page that we could go back from.

}
2 changes: 1 addition & 1 deletion frontend/src/scenes/trends/trendsLogic.ts
Original file line number Diff line number Diff line change
@@ -597,7 +597,7 @@ export const trendsLogic = kea<trendsLogicType<IndexedTrendResult, TrendPeople,
if (props.dashboardItemId) {
return // don't use the URL if on the dashboard
}
return ['/insights', values.filters, router.values.hashParams]
return ['/insights', values.filters, router.values.hashParams, { replace: true }]
},
}),

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -64,10 +64,10 @@
"fast-deep-equal": "^3.1.3",
"funnel-graph-js": "^1.4.1",
"fuse.js": "^6.4.1",
"kea": "^2.4.3",
"kea": "^2.4.5",
"kea-loaders": "^0.4.0",
"kea-localstorage": "^1.1.1",
"kea-router": "^0.5.3",
"kea-router": "^1.0.0",
"kea-window-values": "^0.0.1",
"md5": "^2.3.0",
"posthog-js": "1.11.4",
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -7530,10 +7530,10 @@ kea-localstorage@^1.1.1:
resolved "https://registry.yarnpkg.com/kea-localstorage/-/kea-localstorage-1.1.1.tgz#6edf69476779e002708fb10f2360e48333707406"
integrity sha512-YijSF33Y1QpfHAq1hGvulWWoGC9Kckd4lVa+XStHar4t7GfoaDa1aWnTeJxzz9bWnJovfk+MnG8ekP4rWIqINA==

kea-router@^0.5.3:
version "0.5.3"
resolved "https://registry.yarnpkg.com/kea-router/-/kea-router-0.5.3.tgz#f0f2719b1be4c661ad62312a6249067429d51731"
integrity sha512-adXb8oQcoR70Q8JegsauCawAsj63+/n9MeacKOa7/kbCZQYAlrjfcG83CcuRLe99MI/PSaEfeFX2doOG4Ir4xA==
kea-router@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/kea-router/-/kea-router-1.0.0.tgz#bdd82698502ead67e4b022326423e226e7c9529d"
integrity sha512-9jW8Uwc3A+5YpIuiF+opT+cXUfO6pIa22DFKTcKmVJg/GkiR5RHOziGs8uSkE9AG4snptoNkpA1iPDu/aK3dnw==
dependencies:
url-pattern "^1.0.3"

@@ -7552,10 +7552,10 @@ kea-window-values@^0.0.1:
resolved "https://registry.yarnpkg.com/kea-window-values/-/kea-window-values-0.0.1.tgz#918eee6647507e2d3d5d19466b9561261e7bc8d7"
integrity sha512-60SfOqHrmnCC8hSD2LALMJemYcohQ8tGcTHlA5u4rQy0l0wFFE4gqH1WbKd+73j9m4f6zdoOk07rwJf+P8maiQ==

kea@^2.4.3:
version "2.4.4"
resolved "https://registry.yarnpkg.com/kea/-/kea-2.4.4.tgz#94f7aa3266af980e8d2f5e0e71b033255aac95ef"
integrity sha512-gq5+jcC6w0FJVWkipA31s0WfmRSjIxTIvLtaApc/EPd0ACxKUhrApmC6Ldg9Au9Cu0ddC4g5wijoOUEmn0YyQA==
kea@^2.4.5:
version "2.4.5"
resolved "https://registry.yarnpkg.com/kea/-/kea-2.4.5.tgz#5a43a5aedf306bc7ae0a271ee5bc1ae5fedb4959"
integrity sha512-eo9o0AlnPVKyX2/qFAMxFksPjgHfc//NgzET7X3QbddKPDqCVgNfR8DGdrhnbrKlHF9lJtMQ4ERbVr9WaEEheg==

killable@^1.0.1:
version "1.0.1"