Skip to content

Commit

Permalink
feat(dashboards): Load dashboard items in a sensible order (#20158)
Browse files Browse the repository at this point in the history
feat(dashboards): Load dashboards in a sensible order
  • Loading branch information
robbie-c authored Feb 6, 2024
1 parent 2808a29 commit 1803fe6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions frontend/src/lib/components/Cards/InsightCard/InsightCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ export interface InsightCardProps extends Resizeable, React.HTMLAttributes<HTMLD
/** buttons to add to the "more" menu on the card**/
moreButtons?: JSX.Element | null
placement: DashboardPlacement | 'SavedInsightGrid'
/** Priority for loading the insight, lower is earlier. */
loadPriority?: number
}

function VizComponentFallback(): JSX.Element {
Expand Down Expand Up @@ -246,6 +248,7 @@ function InsightCardInternal(
children,
moreButtons,
placement,
loadPriority,
...divProps
}: InsightCardProps,
ref: React.Ref<HTMLDivElement>
Expand All @@ -254,6 +257,7 @@ function InsightCardInternal(
dashboardItemId: insight.short_id,
dashboardId: dashboardId,
cachedInsight: insight,
loadPriority,
}

const { insightLoading } = useValues(insightLogic(insightLogicProps))
Expand Down
1 change: 1 addition & 0 deletions frontend/src/queries/nodes/DataNode/dataNodeLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
const response = await concurrencyController.run({
debugTag: props.query.kind,
abortController,
priority: props.loadPriority,
fn: async (): Promise<{ duration: number; data: Record<string, any> }> => {
const now = performance.now()
try {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/scenes/dashboard/DashboardItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ export function DashboardItems(): JSX.Element {
>
{tiles?.map((tile: DashboardTile) => {
const { insight, text } = tile
const smLayout = layouts['sm']?.find((l) => {
return l.i == tile.id.toString()
})

const commonTileProps = {
dashboardId: dashboard?.id,
Expand Down Expand Up @@ -140,6 +143,7 @@ export function DashboardItems(): JSX.Element {
duplicate={() => duplicateInsight(insight)}
showDetailsControls={placement != DashboardPlacement.Export}
placement={placement}
loadPriority={smLayout ? smLayout.y * 1000 + smLayout.x : undefined}
{...commonTileProps}
/>
)
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/scenes/insights/insightDataLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ export const insightDataLogic = kea<insightDataLogicType>([
values: [
insightLogic,
['filters', 'insight', 'savedInsight'],
dataNodeLogic({ key: insightVizDataNodeKey(props) } as DataNodeLogicProps),
dataNodeLogic({
key: insightVizDataNodeKey(props),
loadPriority: props.loadPriority,
} as DataNodeLogicProps),
[
'query as insightQuery',
'response as insightDataRaw',
Expand Down

0 comments on commit 1803fe6

Please sign in to comment.