@@ -8,7 +8,8 @@ import { toast } from "sonner";
88import { z } from "zod" ;
99import { defaultChartConfig } from "~/components/code/ChartConfigPanel" ;
1010import { Feedback } from "~/components/Feedback" ;
11- import { PageBody , PageContainer } from "~/components/layout/AppLayout" ;
11+ import { InfoPanel } from "~/components/primitives/InfoPanel" ;
12+ import { MainCenteredContainer , PageBody , PageContainer } from "~/components/layout/AppLayout" ;
1213import { Button , LinkButton } from "~/components/primitives/Buttons" ;
1314import {
1415 Dialog ,
@@ -55,7 +56,7 @@ import {
5556} from "~/utils/pathBuilder" ;
5657import { MetricDashboard } from "../_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.metrics.$dashboardKey/route" ;
5758import { useCurrentPlan } from "../_app.orgs.$organizationSlug/route" ;
58- import { IconEdit } from "@tabler/icons-react" ;
59+ import { IconEdit , IconLayoutDashboardFilled } from "@tabler/icons-react" ;
5960
6061const ParamSchema = EnvironmentParamSchema . extend ( {
6162 dashboardId : z . string ( ) ,
@@ -338,41 +339,42 @@ export default function Page() {
338339 < NavBar >
339340 < PageTitle title = { title } />
340341 < PageAccessories >
341- { widgetIsAtLimit ? (
342- < Dialog >
343- < DialogTrigger asChild >
344- < Button variant = "secondary/small" LeadingIcon = { PlusIcon } >
345- Add chart
346- </ Button >
347- </ DialogTrigger >
348- < DialogContent >
349- < DialogHeader > You've exceeded your widget limit</ DialogHeader >
350- < DialogDescription >
351- You've used { widgetLimits . used } /{ widgetLimits . limit } widgets on this dashboard.
352- </ DialogDescription >
353- < DialogFooter >
354- { widgetCanUpgrade ? (
355- < LinkButton variant = "primary/small" to = { v3BillingPath ( organization ) } >
356- Upgrade
357- </ LinkButton >
358- ) : (
359- < Feedback
360- button = { < Button variant = "primary/small" > Request more</ Button > }
361- defaultValue = "help"
362- />
363- ) }
364- </ DialogFooter >
365- </ DialogContent >
366- </ Dialog >
367- ) : (
368- < Button
369- variant = "secondary/small"
370- LeadingIcon = { PlusIcon }
371- onClick = { actions . openAddEditor }
372- >
373- Add chart
374- </ Button >
375- ) }
342+ { currentWidgetCount > 0 &&
343+ ( widgetIsAtLimit ? (
344+ < Dialog >
345+ < DialogTrigger asChild >
346+ < Button variant = "primary/small" LeadingIcon = { PlusIcon } >
347+ Add chart
348+ </ Button >
349+ </ DialogTrigger >
350+ < DialogContent >
351+ < DialogHeader > You've exceeded your widget limit</ DialogHeader >
352+ < DialogDescription >
353+ You've used { widgetLimits . used } /{ widgetLimits . limit } widgets on this dashboard.
354+ </ DialogDescription >
355+ < DialogFooter >
356+ { widgetCanUpgrade ? (
357+ < LinkButton variant = "primary/small" to = { v3BillingPath ( organization ) } >
358+ Upgrade
359+ </ LinkButton >
360+ ) : (
361+ < Feedback
362+ button = { < Button variant = "primary/small" > Request more</ Button > }
363+ defaultValue = "help"
364+ />
365+ ) }
366+ </ DialogFooter >
367+ </ DialogContent >
368+ </ Dialog >
369+ ) : (
370+ < Button
371+ variant = "primary/small"
372+ LeadingIcon = { PlusIcon }
373+ onClick = { actions . openAddEditor }
374+ >
375+ Add chart
376+ </ Button >
377+ ) ) }
376378 < Popover >
377379 < PopoverVerticalEllipseTrigger variant = "secondary" />
378380 < PopoverContent className = "w-fit min-w-[10rem] p-1" align = "end" >
@@ -387,19 +389,44 @@ export default function Page() {
387389 < PageBody scrollable = { false } >
388390 < div className = "flex h-full flex-col" >
389391 < div className = "min-h-0 flex-1" >
390- < MetricDashboard
391- key = { friendlyId }
392- layout = { state . layout }
393- widgets = { state . widgets }
394- defaultPeriod = { defaultPeriod }
395- editable = { true }
396- possibleTasks = { possibleTasks }
397- onLayoutChange = { actions . updateLayout }
398- onEditWidget = { actions . openEditEditor }
399- onRenameWidget = { actions . renameWidget }
400- onDeleteWidget = { actions . deleteWidget }
401- onDuplicateWidget = { actions . duplicateWidget }
402- />
392+ { currentWidgetCount === 0 ? (
393+ < MainCenteredContainer className = "max-w-md" >
394+ < InfoPanel
395+ icon = { IconLayoutDashboardFilled }
396+ iconClassName = "text-indigo-500"
397+ panelClassName = "max-full"
398+ title = "Add your first chart"
399+ accessory = {
400+ < Button
401+ variant = "primary/small"
402+ LeadingIcon = { PlusIcon }
403+ onClick = { actions . openAddEditor }
404+ >
405+ Add chart
406+ </ Button >
407+ }
408+ >
409+ < Paragraph variant = "small" >
410+ Charts let you visualize your task metrics. Write a query to pull data from your
411+ runs, then choose how to display it on this dashboard.
412+ </ Paragraph >
413+ </ InfoPanel >
414+ </ MainCenteredContainer >
415+ ) : (
416+ < MetricDashboard
417+ key = { friendlyId }
418+ layout = { state . layout }
419+ widgets = { state . widgets }
420+ defaultPeriod = { defaultPeriod }
421+ editable = { true }
422+ possibleTasks = { possibleTasks }
423+ onLayoutChange = { actions . updateLayout }
424+ onEditWidget = { actions . openEditEditor }
425+ onRenameWidget = { actions . renameWidget }
426+ onDeleteWidget = { actions . deleteWidget }
427+ onDuplicateWidget = { actions . duplicateWidget }
428+ />
429+ ) }
403430 </ div >
404431 < div className = "flex w-full items-start justify-between" >
405432 < div className = "flex h-fit w-full items-center gap-4 border-t border-grid-bright bg-background-bright p-[0.86rem] pl-4" >
0 commit comments