11'use client'
22
3- import type { ReactNode } from 'react'
43import { Avatar } from '@sim/emcn/avatar'
4+ import { Button } from '@sim/emcn/button'
55import { BarChart , TrendChart } from '@sim/emcn/chart/charts'
66import { DataTable , MetricGroup , TableLabel } from '@sim/emcn/data-display'
77import { EmptyState } from '@sim/emcn/empty-state'
88import { ChoiceMenu } from '@sim/emcn/menu/choice-menu'
99import { OverflowText } from '@sim/emcn/overflow-text'
1010import { Pagination } from '@sim/emcn/pagination'
1111import { FailureNotice } from '@sim/emcn/status'
12- import {
13- DetailHeader ,
14- SectionToolbar ,
15- } from '@/app/(product)/_components/settings-parts/settings-parts'
16- import { UsageBlock } from '@/app/(product)/o/[organizationId]/settings/_components/sections/usage/usage-block'
1712import styles from '@/app/(product)/o/[organizationId]/settings/_components/sections/usage/usage-section.module.css'
1813import {
1914 type OrganizationUsageWindowKey ,
@@ -31,7 +26,8 @@ interface ActivityOverviewProps {
3126
3227function SummaryView ( { summary } : { summary : ReturnType < typeof useActivitySummary > } ) {
3328 return (
34- < UsageBlock title = 'Activity' >
29+ < section className = { styles . block } aria-label = 'Activity' >
30+ < h2 data-type = 'T093' > Activity</ h2 >
3531 { summary . failed ? (
3632 < FailureNotice message = 'Couldn’t load activity.' onRetry = { summary . retry } />
3733 ) : summary . pending ? null : (
@@ -45,14 +41,14 @@ function SummaryView({ summary }: { summary: ReturnType<typeof useActivitySummar
4541 series = { summary . outcomeSeries }
4642 />
4743 < p className = { styles . quiet } data-type = 'T060' >
48- Other includes cancelled, paused, and unfinished runs
44+ Other includes cancelled, paused, and unfinished runs.
4945 </ p >
5046 </ div >
5147 < TrendChart title = 'Chat runs' points = { summary . chatPoints } />
5248 </ div >
5349 </ >
5450 ) }
55- </ UsageBlock >
51+ </ section >
5652 )
5753}
5854
@@ -91,13 +87,7 @@ const COLUMNS_BY_DIMENSION = {
9187 ] ,
9288} as const
9389
94- interface ActivityPanelProps {
95- organizationId : string
96- /** The period menu a drilled-into workspace shows under its own header. */
97- period ?: ReactNode
98- }
99-
100- export function ActivityPanel ( { organizationId, period } : ActivityPanelProps ) {
90+ export function ActivityPanel ( { organizationId } : { organizationId : string } ) {
10191 const view = useUsageView ( )
10292 const { window, workspace, activityDimension, activitySort, activityPage, setState } = view
10393 const workspaceId = workspace ?? undefined
@@ -111,32 +101,30 @@ export function ActivityPanel({ organizationId, period }: ActivityPanelProps) {
111101 activityPage ,
112102 workspaceId
113103 )
114- const header = workspace && (
115- < >
116- < DetailHeader
117- backLabel = 'Activity'
118- title = { summary . workspaceName ?? 'Workspace activity' }
119- onBack = { ( ) =>
120- void setState ( { workspace : null , activityDimension : 'workspace' , activityPage : 0 } )
121- }
122- />
123- { period && < SectionToolbar > { period } </ SectionToolbar > }
124- </ >
125- )
104+ const toAllWorkspaces = ( ) =>
105+ void setState ( { workspace : null , activityDimension : 'workspace' , activityPage : 0 } )
126106 if ( workspace && summary . unavailable )
127107 return (
128- < >
129- { header }
130- < EmptyState title = 'Workspace unavailable' />
131- < />
108+ < EmptyState
109+ title = 'Workspace unavailable.'
110+ action = { < Button onClick = { toAllWorkspaces } > All workspaces </ Button > }
111+ />
132112 )
133113 const member = activityDimension === 'member'
134114 return (
135115 < >
136- { header }
116+ { workspace && (
117+ < div className = { styles . toolbar } >
118+ < Button variant = 'quiet' icon = 'I093' onClick = { toAllWorkspaces } >
119+ All workspaces
120+ </ Button >
121+ < span data-type = 'T067' > { summary . workspaceName ?? 'Workspace activity' } </ span >
122+ </ div >
123+ ) }
137124 < SummaryView summary = { summary } />
138- < UsageBlock title = 'Breakdown' >
139- < SectionToolbar >
125+ < section className = { styles . block } aria-label = 'Breakdown' >
126+ < h2 data-type = 'T093' > Breakdown</ h2 >
127+ < div className = { styles . toolbar } >
140128 < ChoiceMenu
141129 label = 'Group activity by'
142130 options = { ACTIVITY_DIMENSIONS }
@@ -158,11 +146,11 @@ export function ActivityPanel({ organizationId, period }: ActivityPanelProps) {
158146 }
159147 />
160148 ) }
161- </ SectionToolbar >
149+ </ div >
162150 { breakdown . failed ? (
163151 < FailureNotice message = 'Couldn’t load the breakdown.' onRetry = { breakdown . retry } />
164152 ) : ! breakdown . rows ? null : breakdown . rows . length === 0 ? (
165- < EmptyState title = 'No activity in this period' />
153+ < EmptyState title = 'No activity in this period. ' />
166154 ) : (
167155 < DataTable
168156 title = 'Activity breakdown'
@@ -221,7 +209,7 @@ export function ActivityPanel({ organizationId, period }: ActivityPanelProps) {
221209 onPageChange = { ( page ) => void setState ( { activityPage : page - 1 } ) }
222210 />
223211 ) }
224- </ UsageBlock >
212+ </ section >
225213 </ >
226214 )
227215}
0 commit comments