Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@

import type {VisibilityState} from '@tanstack/react-table';
import {createContext, type ReactNode, useCallback, useContext, useMemo, useState} from 'react';
import type {DashboardState, FilterOption, ResourceType, TimePeriod, ViewColumn} from './types';
import type {
DashboardState,
FilterOption,
ResourceType,
ResourceTypeOption,
TimePeriod,
ViewColumn,
} from './types';
import {updateViewColumnsFromVisibility, viewColumnsToVisibilityState} from './utils';

const DashboardContext = createContext<DashboardState | undefined>(undefined);
Expand Down Expand Up @@ -38,6 +45,32 @@ const DEFAULT_FILTERS: FilterOption[] = [
{id: 'running', label: 'Running', checked: false},
];

export const RESOURCE_TYPES: Array<ResourceType> = [
'ci.pipeline',
'ci.job',
'ci.step',
'test.run',
'test.suite',
'test.case',
] as const;

export const RESOURCE_TYPE_LABELS: Record<ResourceType, string> = {
'ci.pipeline': 'CI Pipeline',
'ci.job': 'CI Job',
'ci.step': 'CI Step',
'test.run': 'Test Run',
'test.suite': 'Test Suite',
'test.case': 'Test Case',
};

export const RESOURCE_TYPE_OPTIONS: ResourceTypeOption[] = [
...RESOURCE_TYPES.map((type) => ({
id: type,
label: RESOURCE_TYPE_LABELS[type],
disabled: type.startsWith('test.'),
})),
];

export interface DashboardProviderProps {
children: ReactNode;
/**
Expand All @@ -62,7 +95,7 @@ export interface DashboardProviderProps {
initialActiveSidebarItem?: string;
/**
* Initial resource type
* @default 'ci-pipeline'
* @default 'ci.pipeline'
*/
initialResourceType?: ResourceType;
/**
Expand Down Expand Up @@ -90,7 +123,7 @@ export function DashboardProvider({
initialFilters = DEFAULT_FILTERS,
initialTimePeriod = '2days',
initialActiveSidebarItem = 'reliability',
initialResourceType = 'ci-pipeline',
initialResourceType = 'ci.pipeline',
columnMapping,
}: DashboardProviderProps) {
// State management
Expand Down
17 changes: 15 additions & 2 deletions libs/react/ui/src/components/dashboard/context/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,21 @@
*/

export type {DashboardProviderProps} from './dashboard-context';
export {DashboardProvider, useDashboardContext} from './dashboard-context';
export type {DashboardState, FilterOption, ResourceType, TimePeriod, ViewColumn} from './types';
export {
DashboardProvider,
RESOURCE_TYPE_LABELS,
RESOURCE_TYPE_OPTIONS,
RESOURCE_TYPES,
useDashboardContext,
} from './dashboard-context';
export type {
DashboardState,
FilterOption,
ResourceType,
ResourceTypeOption,
TimePeriod,
ViewColumn,
} from './types';
export {
DEFAULT_COLUMN_ID_TO_ACCESSOR_KEY,
updateViewColumnsFromVisibility,
Expand Down
14 changes: 13 additions & 1 deletion libs/react/ui/src/components/dashboard/context/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,22 @@ export interface FilterOption {
*/
export type TimePeriod = '1hour' | '1day' | '2days' | '7days' | '30days';

export type ResourceType =
| 'ci.pipeline'
| 'ci.job'
| 'ci.step'
| 'test.run'
| 'test.suite'
| 'test.case';

/**
* Resource type option
*/
export type ResourceType = 'ci-pipeline' | 'ci-jobs' | 'ci-steps' | 'runners' | 'suite' | 'cases';
export interface ResourceTypeOption {
id: ResourceType;
label: string;
disabled?: boolean;
}

/**
* Dashboard context state
Expand Down

This file was deleted.

6 changes: 0 additions & 6 deletions libs/react/ui/src/components/dashboard/filters/index.ts

This file was deleted.

3 changes: 1 addition & 2 deletions libs/react/ui/src/components/dashboard/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ export type {
export {
DashboardProvider,
DEFAULT_COLUMN_ID_TO_ACCESSOR_KEY,
RESOURCE_TYPE_OPTIONS,
updateViewColumnsFromVisibility,
useDashboardContext,
viewColumnsToVisibilityState,
} from './context';
export type {DashboardProps} from './dashboard';
export {Dashboard} from './dashboard';
export type {ExpressionFilterBarProps, ResourceTypeOption} from './filters';
export {ExpressionFilterBar} from './filters';
export {AnalyticsPage, JobsPage} from './pages';
export type {TableWrapperProps} from './table';
export {TableWrapper} from './table';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {type KpiCardProps, KpiCardsGroup} from '../components/kpi-card';
import {MobileSidebar} from '../components/mobile-sidebar';
import {defaultSidebarItems, Sidebar} from '../components/sidebar';
import {useDashboardContext} from '../context';
import {ExpressionFilterBar} from '../filters';
import {TableWrapper} from '../table';
import {PageToolbar, ToolbarActions} from '../toolbar';

Expand Down Expand Up @@ -118,8 +117,6 @@ export function AnalyticsPage() {
updateColumnVisibility,
activeSidebarItem,
setActiveSidebarItem,
resourceType,
setResourceType,
} = useDashboardContext();

const isDesktop = useMediaQuery('(min-width: 1024px)');
Expand Down Expand Up @@ -169,8 +166,6 @@ export function AnalyticsPage() {
secondaryAction={{label: 'Dismiss', onClick: () => undefined}}
/>

<ExpressionFilterBar value={resourceType} onValueChange={setResourceType} />

<ToolbarActions />

<KpiCardsGroup cards={kpiCards} />
Expand Down
Loading
Loading