-
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
fix(dashboards): Move generated dashboards to bottom by default #17070
Merged
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
480d96d
fix(dashboards): Move generated dashboards to bottom by default
neilkakkar 1cf66b1
Update UI snapshots for `chromium` (1)
github-actions[bot] 49a3c6d
fix
neilkakkar 34fd3a6
remove generated dashboards from list
neilkakkar bf371cb
merge
neilkakkar b096d47
tweak
neilkakkar 75d5a83
Update UI snapshots for `chromium` (1)
github-actions[bot] bf432f2
Update UI snapshots for `chromium` (1)
github-actions[bot] a40c399
Update UI snapshots for `chromium` (1)
github-actions[bot] 61cacc6
address
neilkakkar de2c10b
Merge branch 'gen-dash' of github.com:PostHog/posthog into gen-dash
neilkakkar fdeb00e
revert lockfile
neilkakkar 55152b1
merge
neilkakkar bbc1e35
oops
neilkakkar cf9dc75
Update UI snapshots for `chromium` (1)
github-actions[bot] 127cc00
Update UI snapshots for `chromium` (1)
github-actions[bot] ad623e8
merge
neilkakkar db54897
Update UI snapshots for `chromium` (1)
github-actions[bot] f0d727e
Update UI snapshots for `chromium` (1)
github-actions[bot] 13a8827
Update UI snapshots for `chromium` (1)
github-actions[bot] 87de9ea
Update UI snapshots for `chromium` (2)
github-actions[bot] 45b6ab3
Update UI snapshots for `chromium` (1)
github-actions[bot] 221d68e
Update UI snapshots for `chromium` (2)
github-actions[bot] a937ab9
Update UI snapshots for `chromium` (1)
github-actions[bot] fe0d65c
Update UI snapshots for `chromium` (2)
github-actions[bot] f11d5a3
Update UI snapshots for `chromium` (2)
github-actions[bot] 91b0a79
Update UI snapshots for `chromium` (1)
github-actions[bot] 9e8d3d8
Update UI snapshots for `chromium` (1)
github-actions[bot] 75e85cb
Update UI snapshots for `chromium` (1)
github-actions[bot] 71720ce
Update UI snapshots for `chromium` (1)
github-actions[bot] 36c2af6
Update UI snapshots for `chromium` (1)
github-actions[bot] a849c52
wtf
neilkakkar 4efeda0
Update UI snapshots for `chromium` (1)
github-actions[bot] 73e252f
Update UI snapshots for `chromium` (1)
github-actions[bot] c8aa57c
Update UI snapshots for `chromium` (1)
github-actions[bot] 623e455
Update UI snapshots for `chromium` (1)
github-actions[bot] 0f66cbe
Update UI snapshots for `chromium` (1)
github-actions[bot] 460011f
Merge branch 'master' of github.com:PostHog/posthog into gen-dash
neilkakkar 37eb96a
higher
neilkakkar acb5c2c
Update UI snapshots for `chromium` (1)
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file modified
BIN
+0 Bytes
(100%)
frontend/__snapshots__/lemon-ui-profile-bubbles--multiple-bubbles-at-limit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+0 Bytes
(100%)
frontend/__snapshots__/lemon-ui-profile-bubbles--multiple-bubbles-with-tooltip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
import { initKeaTests } from '~/test/init' | ||
import { expectLogic } from 'kea-test-utils' | ||
import { DashboardBasicType } from '~/types' | ||
import { useMocks } from '~/mocks/jest' | ||
import { dashboardsModel, nameCompareFunction } from './dashboardsModel' | ||
import { DashboardPrivilegeLevel, DashboardRestrictionLevel } from 'lib/constants' | ||
|
||
const dashboards: Partial<DashboardBasicType>[] = [ | ||
{ | ||
id: 1, | ||
name: 'Generated Dashboard: 123', | ||
}, | ||
{ | ||
id: 2, | ||
name: 'Generated Dashboard: 456', | ||
}, | ||
{ | ||
id: 3, | ||
name: 'Dashboard: 789', | ||
}, | ||
{ | ||
id: 4, | ||
name: 'Generated Dashboard: 101', | ||
}, | ||
{ | ||
id: 5, | ||
name: 'Dashboard: 112', | ||
}, | ||
{ | ||
id: 6, | ||
name: 'Dashboard: 131', | ||
}, | ||
{ | ||
id: 7, | ||
}, | ||
{ | ||
id: 8, | ||
name: 'k', | ||
}, | ||
] | ||
|
||
const basicDashboard: DashboardBasicType = { | ||
id: 1, | ||
name: '', | ||
description: 'This is not a generated dashboard', | ||
pinned: false, | ||
created_at: new Date().toISOString(), | ||
created_by: null, | ||
is_shared: false, | ||
deleted: false, | ||
creation_mode: 'default', | ||
restriction_level: DashboardRestrictionLevel.EveryoneInProjectCanEdit, | ||
effective_restriction_level: DashboardRestrictionLevel.EveryoneInProjectCanEdit, | ||
effective_privilege_level: DashboardPrivilegeLevel.CanEdit, | ||
} | ||
|
||
describe('the dashboards model', () => { | ||
let logic: ReturnType<typeof dashboardsModel.build> | ||
|
||
beforeEach(async () => { | ||
useMocks({ | ||
get: { | ||
'/api/projects/:team_id/dashboards/': () => { | ||
return [ | ||
200, | ||
{ | ||
count: dashboards.length, | ||
results: dashboards, | ||
next: undefined, | ||
}, | ||
] | ||
}, | ||
}, | ||
}) | ||
|
||
initKeaTests() | ||
logic = dashboardsModel() | ||
logic.mount() | ||
}) | ||
|
||
describe('sorting dashboards', () => { | ||
it('can sort dashboards correctly', async () => { | ||
await expectLogic(logic, () => { | ||
logic.actions.loadDashboards() | ||
}) | ||
.toDispatchActions(['loadDashboardsSuccess']) | ||
.toMatchValues({ | ||
nameSortedDashboards: [ | ||
{ | ||
id: 5, | ||
name: 'Dashboard: 112', | ||
}, | ||
{ | ||
id: 6, | ||
name: 'Dashboard: 131', | ||
}, | ||
{ | ||
id: 3, | ||
name: 'Dashboard: 789', | ||
}, | ||
{ | ||
id: 8, | ||
name: 'k', | ||
}, | ||
{ | ||
id: 7, | ||
}, | ||
], | ||
}) | ||
}) | ||
|
||
it('compares names correctly', async () => { | ||
const generatedDashboardA = { ...basicDashboard, id: 1, name: 'Generated Dashboard: XYZ' } | ||
const untitledDashboard = { ...basicDashboard, id: 2, name: 'Untitled' } | ||
const randomDashboard = { ...basicDashboard, id: 3, name: 'Random' } | ||
const randomDashboard2 = { ...basicDashboard, id: 3, name: 'Too Random' } | ||
expect(nameCompareFunction(generatedDashboardA, untitledDashboard)).toEqual(-1) | ||
expect(nameCompareFunction(untitledDashboard, generatedDashboardA)).toEqual(1) | ||
expect(nameCompareFunction(generatedDashboardA, randomDashboard)).toEqual(-1) | ||
expect(nameCompareFunction(randomDashboard, generatedDashboardA)).toEqual(1) | ||
expect(nameCompareFunction(generatedDashboardA, randomDashboard2)).toEqual(-1) | ||
expect(nameCompareFunction(randomDashboard2, generatedDashboardA)).toEqual(1) | ||
|
||
expect(nameCompareFunction(untitledDashboard, randomDashboard)).toEqual(1) | ||
expect(nameCompareFunction(randomDashboard, untitledDashboard)).toEqual(-1) | ||
expect(nameCompareFunction(untitledDashboard, randomDashboard2)).toEqual(1) | ||
expect(nameCompareFunction(randomDashboard2, untitledDashboard)).toEqual(-1) | ||
|
||
expect(nameCompareFunction(randomDashboard2, randomDashboard)).toEqual(1) | ||
expect(nameCompareFunction(randomDashboard, randomDashboard2)).toEqual(-1) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-21 Bytes
(100%)
...s.spec.ts-snapshots/annotations-popover-displays-correctly-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-23 Bytes
(100%)
...-app/insights.spec.ts-snapshots/tooltip-displays-correctly-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Wait, if the ones starting with
GENERATED_DASHBOARD_PREFIX
are filtered out, it doesn't make sense to sort by that prefix, right?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.
Not here, but, this isn't the only place the comparison function is used, and I wanted to keep the function standard for sorting wherever you want to sort dashboards, so if, say, you're sorting raw dashboards somewhere, they're still at the end. Seemed less error prone.
Happy to remove generated prefix from the sorting function if you feel strongly about this
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.
Right, but
nameSortedDashboards
is the source for all our lists of dashboards, so if we filtered out the generated dashboards, they won't be displayed at the bottom anymore – they will be just hidden. From the description of the PR I thought that that's not the intentionThere 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.
original intention yes, but based on Li's comment, am removing them completely from the list, and adding a link to the usage dashboard to get to the main db, will update description 😅
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.
Oh, I missed that, was still looking at the PR title 😅 In that case
nameCompareFunction
handling is unused in this PR, so would be better to revert that additionThere 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'd argue that it at least unifies the current 3 places where we manually write the same function again, would you be fine with me removing the generated prefix from it but keeping the function, or do you want me to get rid of it completely?
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.
No, yeah, the function makes sense. Just the prefix handling that's not going to be used