-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat(dashboards): Add All Dashboards tab and rename existing to Custom #114904
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
Open
DominikB2014
wants to merge
4
commits into
master
Choose a base branch
from
dominikbuszowiecki/dain-1637-rename-all-dashboards-tab-to-custom-dashboards
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
75608ab
feat(dashboards): Add All Dashboards tab and rename existing tab to C…
DominikB2014 f362935
ref(dashboards): Always render "Custom Dashboards" label regardless o…
DominikB2014 9f288eb
ref(dashboards): Consolidate dashboards filter state into a single ta…
DominikB2014 64bfeec
fix(dashboards): Update command palette to match new tab structure
DominikB2014 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
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1 +1,7 @@ | ||
| export type DashboardsLayout = 'grid' | 'table'; | ||
|
|
||
| export enum DashboardsTab { | ||
| CUSTOM = 'custom', | ||
| ALL = 'all', | ||
| PREBUILT = 'prebuilt', | ||
| } |
18 changes: 18 additions & 0 deletions
18
static/app/views/dashboards/manage/utils/getDashboardsTab.tsx
This file contains hidden or 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,18 @@ | ||
| import {DashboardsTab} from 'sentry/views/dashboards/manage/types'; | ||
| import {DashboardFilter} from 'sentry/views/dashboards/types'; | ||
|
|
||
| export function getDashboardsTab( | ||
| hasPrebuiltDashboards: boolean, | ||
| urlFilter: DashboardFilter | undefined | ||
| ): DashboardsTab { | ||
| if (!hasPrebuiltDashboards) { | ||
| return DashboardsTab.CUSTOM; | ||
| } | ||
| if (urlFilter === DashboardFilter.ONLY_PREBUILT) { | ||
| return DashboardsTab.PREBUILT; | ||
| } | ||
| if (urlFilter === DashboardFilter.ALL) { | ||
| return DashboardsTab.ALL; | ||
| } | ||
| return DashboardsTab.CUSTOM; | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -12,6 +12,8 @@ import {useProjects} from 'sentry/utils/useProjects'; | |
| import {useUser} from 'sentry/utils/useUser'; | ||
| import {useGetStarredDashboards} from 'sentry/views/dashboards/hooks/useGetStarredDashboards'; | ||
| import {DEFAULT_PREBUILT_SORT} from 'sentry/views/dashboards/manage/settings'; | ||
| import {DashboardsTab} from 'sentry/views/dashboards/manage/types'; | ||
| import {getDashboardsTab} from 'sentry/views/dashboards/manage/utils/getDashboardsTab'; | ||
| import {DashboardFilter, PREBUILT_DASHBOARD_LABEL} from 'sentry/views/dashboards/types'; | ||
| import type {DashboardListItem} from 'sentry/views/dashboards/types'; | ||
| import {isPrimaryNavigationLinkActive} from 'sentry/views/navigation/primary/components'; | ||
|
|
@@ -30,7 +32,7 @@ export function DashboardsSecondaryNavigation() { | |
| 'dashboards-prebuilt-insights-dashboards' | ||
| ); | ||
| const urlFilter = decodeScalar(location.query.filter) as DashboardFilter | undefined; | ||
| const isOnlyPrebuilt = urlFilter === DashboardFilter.ONLY_PREBUILT; | ||
| const dashboardsTab = getDashboardsTab(hasPrebuiltDashboards, urlFilter); | ||
| const isOnDashboardsList = isPrimaryNavigationLinkActive( | ||
| `${baseUrl}/`, | ||
| location.pathname, | ||
|
|
@@ -45,25 +47,38 @@ export function DashboardsSecondaryNavigation() { | |
| <SecondaryNavigation.Body> | ||
| <SecondaryNavigation.Section id="dashboards-all"> | ||
| <SecondaryNavigation.List> | ||
| {hasPrebuiltDashboards ? ( | ||
| <SecondaryNavigation.ListItem> | ||
| <SecondaryNavigation.Link | ||
| to={`${baseUrl}/?filter=${DashboardFilter.ALL}`} | ||
| isActive={isOnDashboardsList && dashboardsTab === DashboardsTab.ALL} | ||
| analyticsItemName="dashboards_all_combined" | ||
| > | ||
| {t('All Dashboards')} | ||
| </SecondaryNavigation.Link> | ||
| </SecondaryNavigation.ListItem> | ||
| ) : null} | ||
| <SecondaryNavigation.ListItem> | ||
| <SecondaryNavigation.Link | ||
| to={`${baseUrl}/`} | ||
| end | ||
| isActive={ | ||
| hasPrebuiltDashboards | ||
| ? isOnDashboardsList && !isOnlyPrebuilt | ||
| ? isOnDashboardsList && dashboardsTab === DashboardsTab.CUSTOM | ||
| : undefined | ||
| } | ||
| analyticsItemName="dashboards_all" | ||
| > | ||
| {t('All Dashboards')} | ||
| {t('Custom Dashboards')} | ||
|
DominikB2014 marked this conversation as resolved.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same note as above, I think if someone doesn't have pre-built dashboards it should continue to say "All Dashboards", but not a big deal |
||
| </SecondaryNavigation.Link> | ||
| </SecondaryNavigation.ListItem> | ||
| {hasPrebuiltDashboards ? ( | ||
| <SecondaryNavigation.ListItem> | ||
| <SecondaryNavigation.Link | ||
| to={`${baseUrl}/?filter=${DashboardFilter.ONLY_PREBUILT}&sort=${DEFAULT_PREBUILT_SORT}`} | ||
| isActive={isOnDashboardsList && isOnlyPrebuilt} | ||
| isActive={ | ||
| isOnDashboardsList && dashboardsTab === DashboardsTab.PREBUILT | ||
| } | ||
| analyticsItemName="dashboards_sentry_built" | ||
| > | ||
| {PREBUILT_DASHBOARD_LABEL} | ||
|
|
||
Oops, something went wrong.
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.
Maybe a bit more precise here to do something like