@ssa-ui-kit/infra-dash 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/LICENSE +21 -0
  2. package/dist/components/BasePanel/BasePanel.d.ts +4 -0
  3. package/dist/components/BasePanel/index.d.ts +1 -0
  4. package/dist/components/DashboardError/DashboardError.d.ts +4 -0
  5. package/dist/components/DashboardError/index.d.ts +1 -0
  6. package/dist/components/ErrorPanel/ErrorPanel.d.ts +5 -0
  7. package/dist/components/ErrorPanel/index.d.ts +1 -0
  8. package/dist/components/LoadingDashboard/LoadingDashboard.d.ts +4 -0
  9. package/dist/components/LoadingDashboard/index.d.ts +1 -0
  10. package/dist/components/LoadingPanel/LoadingPanel.d.ts +5 -0
  11. package/dist/components/LoadingPanel/index.d.ts +1 -0
  12. package/dist/entities/dashboard/index.d.ts +71 -0
  13. package/dist/entities/grafana-dashboard/index.d.ts +25 -0
  14. package/dist/entities/grafana-panel/index.d.ts +25 -0
  15. package/dist/entities/panel/index.d.ts +2 -0
  16. package/dist/entities/panel/usePanelData.d.ts +29 -0
  17. package/dist/entities/panel/withPanelData.d.ts +17 -0
  18. package/dist/features/DashboardPanelGrid.d.ts +19 -0
  19. package/dist/index.d.ts +7 -0
  20. package/dist/index.js +2971 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/panels/BarGaugePanel/BarGaugePanel.d.ts +11 -0
  23. package/dist/panels/BarGaugePanel/data-adapters/grafana.d.ts +16 -0
  24. package/dist/panels/BarGaugePanel/index.d.ts +1 -0
  25. package/dist/panels/GaugePanel/GaugePanel.d.ts +9 -0
  26. package/dist/panels/GaugePanel/data-adapters/grafana.d.ts +17 -0
  27. package/dist/panels/GaugePanel/index.d.ts +1 -0
  28. package/dist/panels/TimeseriesPanel/TimeseriesPanel.d.ts +9 -0
  29. package/dist/panels/TimeseriesPanel/data-adapters/grafana.d.ts +18 -0
  30. package/dist/panels/TimeseriesPanel/index.d.ts +1 -0
  31. package/dist/panels/index.d.ts +3 -0
  32. package/dist/provider.d.ts +11 -0
  33. package/dist/shared/context.d.ts +13 -0
  34. package/dist/shared/dashboard.d.ts +22 -0
  35. package/dist/shared/dataAdapter.d.ts +14 -0
  36. package/dist/shared/exception.d.ts +1 -0
  37. package/dist/shared/grafana.d.ts +50 -0
  38. package/dist/shared/icons/DashboardIcon.d.ts +2 -0
  39. package/dist/shared/icons/ErrorIcon.d.ts +1 -0
  40. package/dist/shared/icons/SidebarIcon.d.ts +2 -0
  41. package/dist/shared/icons/index.d.ts +3 -0
  42. package/dist/shared/panel.d.ts +96 -0
  43. package/dist/shared/panelRegistry.d.ts +9 -0
  44. package/dist/shared/query/index.d.ts +4 -0
  45. package/dist/shared/query/key.d.ts +4 -0
  46. package/dist/shared/query/mutation.d.ts +35 -0
  47. package/dist/shared/query/query.d.ts +52 -0
  48. package/dist/shared/query/useMutation.d.ts +11 -0
  49. package/dist/shared/query/useQuery.d.ts +22 -0
  50. package/dist/shared/transport/baseTransport.d.ts +35 -0
  51. package/dist/shared/transport/index.d.ts +3 -0
  52. package/dist/shared/transport/restTransport.d.ts +29 -0
  53. package/dist/shared/transport/useTransport.d.ts +2 -0
  54. package/dist/widgets/DashboardEditor/DashboardEditor.d.ts +15 -0
  55. package/dist/widgets/DashboardEditor/__mock__/index.d.ts +20 -0
  56. package/dist/widgets/DashboardEditor/components/DashboardSelectorDrawer.d.ts +6 -0
  57. package/dist/widgets/DashboardEditor/components/ExternalDashboardsList.d.ts +5 -0
  58. package/dist/widgets/DashboardEditor/components/PanelControl.d.ts +8 -0
  59. package/dist/widgets/DashboardEditor/components/PanelSettings.d.ts +7 -0
  60. package/dist/widgets/DashboardEditor/components/PanelSettingsDrawer.d.ts +6 -0
  61. package/dist/widgets/DashboardEditor/helpers.d.ts +39 -0
  62. package/dist/widgets/DashboardEditor/index.d.ts +1 -0
  63. package/dist/widgets/DashboardViewer/DashboardViewer.d.ts +7 -0
  64. package/dist/widgets/DashboardViewer/__mock__/index.d.ts +16 -0
  65. package/dist/widgets/DashboardViewer/index.d.ts +1 -0
  66. package/package.json +70 -0
@@ -0,0 +1,22 @@
1
+ import { Panel } from './panel';
2
+ /**
3
+ * Represents the configuration data for a dashboard.
4
+ */
5
+ export type DashboardDefinition = {
6
+ version: 1;
7
+ };
8
+ /**
9
+ * Represents a complete dashboard with its metadata and associated panels.
10
+ * Combines dashboard identity, display information, configuration, and
11
+ * the collection of panels that make up the dashboard content.
12
+ */
13
+ export type Dashboard = {
14
+ /** Unique numeric identifier for the dashboard */
15
+ id: number;
16
+ /** Display title of the dashboard shown in the UI */
17
+ title: string;
18
+ /** Dashboard-specific configuration and settings */
19
+ dashboardDefinition: DashboardDefinition;
20
+ /** Array of panels that belong to this dashboard */
21
+ panels: Panel[];
22
+ };
@@ -0,0 +1,14 @@
1
+ import { Panel, PanelData } from './panel';
2
+ /**
3
+ * Configuration options for data adapters that transform panel data.
4
+ * Data adapters are responsible for converting raw panel data into formats
5
+ * suitable for specific visualization components.
6
+ *
7
+ * @template T - The type of panel data, constrained to extend PanelData['data']
8
+ */
9
+ export type DataAdapterOptions<T extends PanelData['data']> = {
10
+ /** The panel configuration and metadata */
11
+ panel: Panel;
12
+ /** The panel data to be adapted/transformed */
13
+ data: T;
14
+ };
@@ -0,0 +1 @@
1
+ export declare const tryCatch: <T, E = Error>(promise: T | Promise<T>) => Promise<readonly [null, Awaited<T>] | readonly [E, null]>;
@@ -0,0 +1,50 @@
1
+ import type { Panel as PanelSchema } from '@grafana/schema';
2
+ import type { DataFrameJSON } from '@grafana/data';
3
+ /**
4
+ * Represents a Grafana dashboard with its basic metadata.
5
+ * Contains the essential information needed to identify and display a dashboard.
6
+ */
7
+ export type GrafanaDashboard = {
8
+ /** Unique string identifier for the dashboard */
9
+ id: string;
10
+ /** Display title of the dashboard */
11
+ title: string;
12
+ };
13
+ /**
14
+ * Represents a Grafana panel with its configuration and potential sub-panels.
15
+ */
16
+ export type GrafanaPanel = {
17
+ /** Unique numeric identifier for the panel */
18
+ id: number;
19
+ /** Display title of the panel */
20
+ title: string;
21
+ /** Grafana panel schema configuration, null if not available */
22
+ panelSchema: PanelSchema | null;
23
+ /** Array of nested panels, null if the panel has no sub-panels */
24
+ subPanels: GrafanaPanel[] | null;
25
+ };
26
+ /**
27
+ * Represents Grafana panel data with query results and metadata.
28
+ * Contains the actual data returned from Grafana queries along with
29
+ * information about the panel type and structure.
30
+ */
31
+ export type GrafanaPanelData = {
32
+ source: 'grafana';
33
+ data: {
34
+ /**
35
+ * Query results indexed by query reference ID.
36
+ * Each result contains status information and data frames.
37
+ */
38
+ results: Record<string, {
39
+ status: number;
40
+ /** Array of data frames containing the actual query results */
41
+ frames: DataFrameJSON[];
42
+ }>;
43
+ };
44
+ };
45
+ /**
46
+ * Type alias for Grafana panel schema.
47
+ * Re-exports the Panel schema from @grafana/schema for convenience
48
+ * and to maintain consistent naming conventions in the codebase.
49
+ */
50
+ export type GrafanaPanelSchema = PanelSchema;
@@ -0,0 +1,2 @@
1
+ import { SVGProps } from '@ssa-ui-kit/core';
2
+ export declare const DashboardIcon: ({ fill, size, tooltip, ...props }: SVGProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare const ErrorIcon: () => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { SVGProps } from '@ssa-ui-kit/core';
2
+ export declare const SidebarIcon: ({ fill, size, tooltip, ...props }: SVGProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ export * from './ErrorIcon';
2
+ export * from './DashboardIcon';
3
+ export * from './SidebarIcon';
@@ -0,0 +1,96 @@
1
+ import { RJSFSchema, UiSchema } from '@rjsf/utils';
2
+ import { GrafanaPanelData, GrafanaPanelSchema } from './grafana';
3
+ /**
4
+ * Defines the configuration and positioning information for a dashboard panel.
5
+ * Contains both the component configuration and grid layout positioning.
6
+ */
7
+ export type PanelDefinition = {
8
+ source: {
9
+ type: typeof PANEL_DATA_SOURCE.GRAFANA;
10
+ /** Unique identifier for the Grafana dashboard */
11
+ dashboardUid: string;
12
+ /** Unique identifier for the Grafana panel within the dashboard */
13
+ panelId: number;
14
+ };
15
+ component: {
16
+ /** Unique identifier for the component type */
17
+ id: string;
18
+ /** Dynamic properties passed to the component instance */
19
+ props: Record<string, unknown>;
20
+ };
21
+ /** Grid positioning and sizing information */
22
+ gridPos: Record<'h' | 'w' | 'x' | 'y', number>;
23
+ /** Version of the panel definition schema */
24
+ version: 1;
25
+ };
26
+ /**
27
+ * Represents a complete dashboard panel with its metadata, schema, and definition.
28
+ * Combines panel identity, display information, data schema, and component configuration.
29
+ */
30
+ export type Panel = {
31
+ /** Unique numeric identifier for the panel */
32
+ id: number;
33
+ /** Display title shown in the panel header */
34
+ title: string;
35
+ /** Grafana-specific panel schema configuration */
36
+ panelSchema: GrafanaPanelSchema;
37
+ /** Component and layout definition for the panel */
38
+ panelDefinition: PanelDefinition;
39
+ };
40
+ /**
41
+ * Optional schema defining the structure of props this component expects.
42
+ * Used for validation and form generation in configuration UIs.
43
+ */
44
+ type PanelConfigProps<T> = object extends T ? {
45
+ defaultProps?: T;
46
+ propsSchema?: RJSFSchema;
47
+ } : {
48
+ defaultProps: T;
49
+ propsSchema: RJSFSchema;
50
+ };
51
+ /**
52
+ * Configuration object for registering a panel component type.
53
+ * Defines how a specific component should be rendered and what panel types it supports.
54
+ */
55
+ export type PanelConfig<T extends Record<string, unknown> | undefined> = {
56
+ /** Unique identifier for this component type */
57
+ componentId: string;
58
+ /** React component that will render the panel */
59
+ Component: React.ComponentType<{
60
+ panel: Panel;
61
+ }>;
62
+ /** Human-readable name for this panel type */
63
+ name: string;
64
+ /** Array of Grafana panel types this component can handle */
65
+ supportedTypes: string[];
66
+ uiSchema?: UiSchema;
67
+ } & PanelConfigProps<Omit<T, 'panel' | 'panelData'>>;
68
+ /**
69
+ * Constant object defining available panel data sources.
70
+ * Currently only supports Grafana as a data source.
71
+ */
72
+ export declare const PANEL_DATA_SOURCE: {
73
+ readonly GRAFANA: "grafana";
74
+ };
75
+ export type PanelDataSource = (typeof PANEL_DATA_SOURCE)[keyof typeof PANEL_DATA_SOURCE];
76
+ /**
77
+ * Pattern matching utility function for handling different panel data sources.
78
+ * Provides type-safe way to handle operations based on the data source type.
79
+ *
80
+ * @param source - The panel data source to match against
81
+ * @param handlers - Object containing handler functions for each data source type
82
+ */
83
+ export declare const matchPanelDataSource: <Grafana>(source: PanelDataSource, handlers: {
84
+ grafana: () => Grafana;
85
+ }) => Grafana;
86
+ /**
87
+ * Represents panel data with its source and associated data.
88
+ * Currently only supports Grafana as a data source.
89
+ */
90
+ export type PanelData = {
91
+ /** The data source type identifier */
92
+ source: typeof PANEL_DATA_SOURCE.GRAFANA;
93
+ /** The actual panel data from Grafana */
94
+ data: GrafanaPanelData;
95
+ };
96
+ export {};
@@ -0,0 +1,9 @@
1
+ import { PanelConfig } from './panel';
2
+ type AnyProps = Record<string, unknown> | undefined;
3
+ export declare class PanelRegistry {
4
+ private panels;
5
+ registerPanel(panelConfig: PanelConfig<AnyProps>): void;
6
+ getPanelConfig(componentId: string): PanelConfig<AnyProps>;
7
+ findPanelConfigsByType(type: string): PanelConfig<AnyProps>[];
8
+ }
9
+ export {};
@@ -0,0 +1,4 @@
1
+ export * from './query';
2
+ export * from './useQuery';
3
+ export * from './mutation';
4
+ export * from './useMutation';
@@ -0,0 +1,4 @@
1
+ export type MutationKey = unknown[];
2
+ export type QueryKey = unknown[];
3
+ export declare const hashKey: (queryKey: QueryKey | MutationKey) => string;
4
+ export declare function partialMatchKey(a: QueryKey, b: QueryKey): boolean;
@@ -0,0 +1,35 @@
1
+ import { MutationKey } from './key';
2
+ export type MutationState<T> = {
3
+ data?: T;
4
+ error?: unknown;
5
+ isLoading: boolean;
6
+ };
7
+ type Subscriber<T> = (state: MutationState<T>) => void;
8
+ export type MutationFn<T, V> = (variables: V, signal: AbortSignal) => Promise<T>;
9
+ export type MutationOptions<T, V> = {
10
+ onSuccess?: (data: T, variables: V) => void;
11
+ onError?: (error: unknown, variables: V) => void;
12
+ onSettled?: (error: unknown | undefined, data: T | undefined, variables: V) => void;
13
+ };
14
+ export declare class MutationEntry<T, V> {
15
+ key: MutationKey;
16
+ mutationFn: MutationFn<T, V>;
17
+ options: MutationOptions<T, V> | undefined;
18
+ state: MutationState<T>;
19
+ promise: Promise<T | undefined> | null;
20
+ subscribers: Set<Subscriber<T>>;
21
+ private controller;
22
+ constructor(key: MutationKey, mutationFn: MutationFn<T, V>, options?: MutationOptions<T, V>);
23
+ private notify;
24
+ updateEntity(mutationFn: MutationFn<T, V>, options?: MutationOptions<T, V>): void;
25
+ mutate(...args: V extends undefined ? [] : [V]): Promise<T | undefined>;
26
+ subscribe(sub: Subscriber<T>): () => void;
27
+ cancel(): void;
28
+ reset(): void;
29
+ }
30
+ export declare class MutationClient {
31
+ private cache;
32
+ fetchMutation<T, V>(key: MutationKey, mutationFn: MutationFn<T, V>, options?: MutationOptions<T, V>): MutationEntry<T, V>;
33
+ }
34
+ export declare const mutationClient: MutationClient;
35
+ export {};
@@ -0,0 +1,52 @@
1
+ import { QueryKey } from './key';
2
+ export type QueryState<T> = {
3
+ isLoaded: false;
4
+ isFetching: boolean;
5
+ data: undefined;
6
+ error: null;
7
+ } | {
8
+ isLoaded: true;
9
+ isFetching: boolean;
10
+ data: T;
11
+ error: null;
12
+ } | {
13
+ isLoaded: true;
14
+ isFetching: boolean;
15
+ data: undefined;
16
+ error: Error;
17
+ };
18
+ type Subscriber<T> = (state: QueryState<T>) => void;
19
+ export type Fetcher<T> = (signal: AbortSignal) => Promise<T>;
20
+ export type QueryOptions = {
21
+ enabled?: boolean;
22
+ };
23
+ export declare class QueryEntry<T> {
24
+ key: QueryKey;
25
+ fetcher: Fetcher<T>;
26
+ options: QueryOptions;
27
+ state: QueryState<T>;
28
+ promise: Promise<T | undefined> | null;
29
+ subscribers: Set<Subscriber<T>>;
30
+ private controller;
31
+ constructor(key: QueryKey, fetcher: Fetcher<T>, options?: QueryOptions);
32
+ private notify;
33
+ updateEntity(fetcher: Fetcher<T>, options?: QueryOptions): QueryEntry<T>;
34
+ fetch(): Promise<T | undefined>;
35
+ subscribe(sub: Subscriber<T>): () => void;
36
+ setData(data: T): void;
37
+ invalidate(reset?: boolean): void;
38
+ cancel(): void;
39
+ }
40
+ export declare class QueryClient {
41
+ private cache;
42
+ get<T>(key: QueryKey): QueryEntry<T> | undefined;
43
+ fetchQuery<T>(key: QueryKey, fetcher: Fetcher<T>, options?: QueryOptions): QueryEntry<T>;
44
+ invalidateQueries({ key, exact, reset, }: {
45
+ key: QueryKey;
46
+ exact?: boolean;
47
+ reset?: boolean;
48
+ }): void;
49
+ setQueryData<T>(key: QueryKey, data: T): void;
50
+ }
51
+ export declare const queryClient: QueryClient;
52
+ export {};
@@ -0,0 +1,11 @@
1
+ import { MutationFn, MutationOptions } from './mutation';
2
+ import { MutationKey } from './key';
3
+ export declare const useMutationClient: () => import("./mutation").MutationClient;
4
+ export declare const useMutation: <T, V = unknown>(key: MutationKey, mutationFn: MutationFn<T, V>, options?: MutationOptions<T, V>) => {
5
+ mutate: (...args: Parameters<(...args: V extends undefined ? [] : [V]) => Promise<T | undefined>>) => Promise<T | undefined>;
6
+ data: T | undefined;
7
+ error: unknown;
8
+ isLoading: boolean;
9
+ reset: () => void;
10
+ cancel: () => void;
11
+ };
@@ -0,0 +1,22 @@
1
+ import { Fetcher, QueryOptions } from './query';
2
+ import { QueryKey } from './key';
3
+ export declare const useQueryClient: () => import("./query").QueryClient;
4
+ export declare const useQuery: <T>(key: QueryKey, fetcher: Fetcher<T>, options?: QueryOptions) => {
5
+ refetch: () => void;
6
+ isLoaded: false;
7
+ isFetching: boolean;
8
+ data: undefined;
9
+ error: null;
10
+ } | {
11
+ refetch: () => void;
12
+ isLoaded: true;
13
+ isFetching: boolean;
14
+ data: undefined;
15
+ error: Error;
16
+ } | {
17
+ refetch: () => void;
18
+ isLoaded: true;
19
+ isFetching: boolean;
20
+ data: T;
21
+ error: null;
22
+ };
@@ -0,0 +1,35 @@
1
+ import { Dashboard, DashboardDefinition } from '../dashboard';
2
+ import { GrafanaDashboard, GrafanaPanel, GrafanaPanelData } from '../grafana';
3
+ import { PanelDefinition } from '../panel';
4
+ export type CreateDashboardPayload = {
5
+ title: string;
6
+ dashboardUid: string;
7
+ dashboardDefinition: DashboardDefinition;
8
+ panels: {
9
+ id: number;
10
+ panelDefinition: PanelDefinition;
11
+ }[];
12
+ };
13
+ export type UpdateDashboardPayload = {
14
+ dashboardId: number;
15
+ title: string;
16
+ dashboardDefinition: DashboardDefinition;
17
+ panels: {
18
+ id: number;
19
+ panelDefinition: PanelDefinition;
20
+ }[];
21
+ };
22
+ export interface InfraDashTransport {
23
+ getGrafanaDashboards: (signal?: AbortSignal) => Promise<GrafanaDashboard[]>;
24
+ getGrafanaPanels: (grafanaDashboardUid: string, signal?: AbortSignal) => Promise<GrafanaPanel[]>;
25
+ getGrafanaPanelData: ({ dashboardUid, panelId, }: {
26
+ dashboardUid: string;
27
+ panelId: number;
28
+ }, signal?: AbortSignal) => Promise<GrafanaPanelData>;
29
+ getPanelData: (panelId: number, signal?: AbortSignal) => Promise<GrafanaPanelData>;
30
+ getDashboards: (signal?: AbortSignal) => Promise<Pick<Dashboard, 'id' | 'title'>[]>;
31
+ getDashboard: (dashboardUid: number, signal?: AbortSignal) => Promise<Dashboard>;
32
+ createDashboard: (payload: CreateDashboardPayload, signal?: AbortSignal) => Promise<unknown>;
33
+ updateDashboard: (payload: UpdateDashboardPayload, signal?: AbortSignal) => Promise<unknown>;
34
+ deleteDashboard: (dashboardId: number, signal?: AbortSignal) => Promise<unknown>;
35
+ }
@@ -0,0 +1,3 @@
1
+ export * from './baseTransport';
2
+ export * from './restTransport';
3
+ export * from './useTransport';
@@ -0,0 +1,29 @@
1
+ import { Dashboard } from '../dashboard';
2
+ import { GrafanaDashboard, GrafanaPanel, GrafanaPanelData } from '../grafana';
3
+ import { CreateDashboardPayload, InfraDashTransport, UpdateDashboardPayload } from './baseTransport';
4
+ export type RestInfraDashTransportConfig = {
5
+ baseUrl: string;
6
+ authMiddleware?: (request: Request) => Promise<Request> | Request;
7
+ unwrapResponse?: <T>(response: unknown) => Promise<T> | T;
8
+ };
9
+ export declare class RestInfraDashTransport implements InfraDashTransport {
10
+ protected baseUrl: string;
11
+ protected authMiddleware?: (request: Request) => Promise<Request> | Request;
12
+ protected unwrapResponse?: <T>(response: unknown) => Promise<T> | T;
13
+ constructor({ baseUrl, authMiddleware, unwrapResponse, }: RestInfraDashTransportConfig);
14
+ getUrl(path: string): string;
15
+ applyMiddlewares(request: Request): Promise<Request>;
16
+ protected makeRequest<T = unknown>(request: Request, parseResponse?: boolean): Promise<T>;
17
+ getGrafanaDashboards(signal?: AbortSignal): Promise<GrafanaDashboard[]>;
18
+ getGrafanaPanels(grafanaDashboardUid: string, signal?: AbortSignal): Promise<GrafanaPanel[]>;
19
+ getGrafanaPanelData({ dashboardUid, panelId, }: {
20
+ dashboardUid: string;
21
+ panelId: number;
22
+ }, signal?: AbortSignal): Promise<GrafanaPanelData>;
23
+ getPanelData(panelId: number, signal?: AbortSignal): Promise<GrafanaPanelData>;
24
+ getDashboards(signal?: AbortSignal): Promise<Pick<Dashboard, "title" | "id">[]>;
25
+ getDashboard(dashboardUid: number, signal?: AbortSignal): Promise<Dashboard>;
26
+ createDashboard(payload: CreateDashboardPayload, signal?: AbortSignal): Promise<unknown>;
27
+ updateDashboard(payload: UpdateDashboardPayload, signal?: AbortSignal): Promise<unknown>;
28
+ deleteDashboard(dashboardId: number, signal?: AbortSignal): Promise<unknown>;
29
+ }
@@ -0,0 +1,2 @@
1
+ import { InfraDashTransport } from './baseTransport';
2
+ export declare const useTransport: (transport?: InfraDashTransport) => InfraDashTransport;
@@ -0,0 +1,15 @@
1
+ import { DashboardPanelGridProps } from '../../features/DashboardPanelGrid';
2
+ import { Dashboard } from '../../shared/dashboard';
3
+ export type DashboardEditorProps = {
4
+ dashboard?: Dashboard;
5
+ defaultDashboard?: Dashboard;
6
+ gridProps?: DashboardPanelGridProps;
7
+ onChange?: (dashboard: Dashboard) => void;
8
+ onSaved?: (dashboard: Dashboard) => void;
9
+ onCreate?: () => void;
10
+ onError?: (error: Error) => void;
11
+ } & Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'onError'>;
12
+ export declare const DashboardEditorInternal: ({ dashboard: controlledDashboard, defaultDashboard, gridProps, onChange, onSaved, onCreate, onError, ...divProps }: DashboardEditorProps) => import("@emotion/react/jsx-runtime").JSX.Element;
13
+ export declare const DashboardEditor: ({ dashboardId, ...props }: DashboardEditorProps & {
14
+ dashboardId?: number;
15
+ }) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,20 @@
1
+ import { Dashboard } from '../../../shared/dashboard';
2
+ import { GrafanaDashboard, GrafanaPanel, GrafanaPanelData } from '../../../shared/grafana';
3
+ import { CreateDashboardPayload, RestInfraDashTransport, UpdateDashboardPayload } from '../../../shared/transport';
4
+ export declare const timeseriesData: GrafanaPanelData;
5
+ export declare const bargaugeData: GrafanaPanelData;
6
+ export declare const gaugeData: GrafanaPanelData;
7
+ export declare const dashboard: Dashboard;
8
+ export declare class MockTransport extends RestInfraDashTransport {
9
+ constructor();
10
+ protected makeRequest<T = unknown>(request: Request): Promise<T>;
11
+ getDashboard(): Promise<Dashboard>;
12
+ getGrafanaDashboards(): Promise<GrafanaDashboard[]>;
13
+ getGrafanaPanels(grafanaDashboardUid: string): Promise<GrafanaPanel[]>;
14
+ getGrafanaPanelData({ dashboardUid, panelId, }: {
15
+ dashboardUid: string;
16
+ panelId: number;
17
+ }): Promise<GrafanaPanelData>;
18
+ createDashboard(payload: CreateDashboardPayload): Promise<unknown>;
19
+ updateDashboard(payload: UpdateDashboardPayload): Promise<unknown>;
20
+ }
@@ -0,0 +1,6 @@
1
+ import { useDrawer } from '@ssa-ui-kit/core';
2
+ export type DashboardSelectorDrawerProps = {
3
+ drawer: ReturnType<typeof useDrawer>;
4
+ children?: React.ReactNode;
5
+ };
6
+ export declare const DashboardSelectorDrawer: ({ drawer, children, }: DashboardSelectorDrawerProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { GrafanaDashboard, GrafanaPanel } from '../../../shared/grafana';
2
+ export type ExternalDashboardsListProps = {
3
+ onPanelClick?: (dashboard: GrafanaDashboard, panel: GrafanaPanel) => void;
4
+ } & React.HTMLAttributes<HTMLDivElement>;
5
+ export declare const ExternalDashboardsList: ({ onPanelClick, ...divProps }: ExternalDashboardsListProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { Panel } from '../../../shared/panel';
2
+ export type PanelControlProps = {
3
+ panel: Panel;
4
+ onRemove?: (panel: Panel) => void;
5
+ onEdit?: (panel: Panel) => void;
6
+ };
7
+ export declare const PanelControlContent: ({ panel, onEdit, onRemove, }: PanelControlProps) => import("@emotion/react/jsx-runtime").JSX.Element;
8
+ export declare const PanelControl: (props: PanelControlProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { Panel } from '../../../shared/panel';
2
+ export type PanelSettingsProps = {
3
+ panel: Panel;
4
+ onChange?: (panel: Panel) => void;
5
+ onSave?: () => void;
6
+ };
7
+ export declare const PanelSettings: ({ panel, onChange, onSave, }: PanelSettingsProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { useDrawer } from '@ssa-ui-kit/core';
2
+ export type PanelSettingsDrawerProps = {
3
+ drawer: ReturnType<typeof useDrawer>;
4
+ children?: React.ReactNode;
5
+ };
6
+ export declare const PanelSettingsDrawer: ({ drawer, children, }: PanelSettingsDrawerProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,39 @@
1
+ import { Dashboard } from '../../shared/dashboard';
2
+ import { GrafanaDashboard, GrafanaPanel } from '../../shared/grafana';
3
+ import { Panel } from '../../shared/panel';
4
+ import { PanelRegistry } from '../../shared/panelRegistry';
5
+ export type AppendPanelParams = {
6
+ dashboard: Dashboard;
7
+ panelRegistry: PanelRegistry;
8
+ source: {
9
+ type: 'grafana';
10
+ grafanaDashboard: GrafanaDashboard;
11
+ grafanaPanel: GrafanaPanel;
12
+ };
13
+ };
14
+ export declare const appendPanel: (params: AppendPanelParams) => Dashboard;
15
+ export type UpdatePanelParams = {
16
+ dashboard: Dashboard;
17
+ panel: Panel;
18
+ };
19
+ export declare const updatePanel: ({ dashboard, panel }: UpdatePanelParams) => {
20
+ panels: Panel[];
21
+ id: number;
22
+ title: string;
23
+ dashboardDefinition: import("../../shared/dashboard").DashboardDefinition;
24
+ };
25
+ export type RemovePanelParams = {
26
+ dashboard: Dashboard;
27
+ panel: Panel;
28
+ };
29
+ export declare const removePanel: ({ dashboard, panel }: RemovePanelParams) => {
30
+ panels: Panel[];
31
+ id: number;
32
+ title: string;
33
+ dashboardDefinition: import("../../shared/dashboard").DashboardDefinition;
34
+ };
35
+ export type ApplyNewLayoutParams = {
36
+ dashboard: Dashboard;
37
+ newLayout: ReactGridLayout.Layout[];
38
+ };
39
+ export declare const applyNewLayout: ({ dashboard, newLayout, }: ApplyNewLayoutParams) => Dashboard;
@@ -0,0 +1 @@
1
+ export * from './DashboardEditor';
@@ -0,0 +1,7 @@
1
+ import { Dashboard } from '../../shared/dashboard';
2
+ import { DashboardPanelGridProps } from '../../features/DashboardPanelGrid';
3
+ export type DashboardViewerProps = {
4
+ dashboardId?: number;
5
+ dashboard?: Dashboard;
6
+ } & Omit<DashboardPanelGridProps, 'dashboard'>;
7
+ export declare const DashboardViewer: ({ dashboard, dashboardId, ...props }: DashboardViewerProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { Dashboard } from '../../../shared/dashboard';
2
+ import { GrafanaPanelData } from '../../../shared/grafana';
3
+ import { RestInfraDashTransport } from '../../../shared/transport';
4
+ export declare const timeseriesData: GrafanaPanelData;
5
+ export declare const bargaugeData: GrafanaPanelData;
6
+ export declare const gaugeData: GrafanaPanelData;
7
+ export declare const dashboard: Dashboard;
8
+ export declare class MockTransport extends RestInfraDashTransport {
9
+ constructor();
10
+ protected makeRequest<T = unknown>(request: Request): Promise<T>;
11
+ getDashboard(): Promise<Dashboard>;
12
+ getGrafanaPanelData({ dashboardUid, panelId, }: {
13
+ dashboardUid: string;
14
+ panelId: number;
15
+ }): Promise<GrafanaPanelData>;
16
+ }
@@ -0,0 +1 @@
1
+ export * from './DashboardViewer';
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@ssa-ui-kit/infra-dash",
3
+ "version": "0.0.2",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "private": false,
7
+ "sideEffects": false,
8
+ "author": "SSA Group",
9
+ "license": "MIT",
10
+ "description": "SSA UI Kit",
11
+ "keywords": [
12
+ "react",
13
+ "SSA UI Kit",
14
+ "ui",
15
+ "monitoring"
16
+ ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/ssagroup/ui-kit.git",
20
+ "directory": "packages/infra-dash"
21
+ },
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "browserslist": [
26
+ ">0.1%",
27
+ "not dead",
28
+ "not op_mini all"
29
+ ],
30
+ "dependencies": {
31
+ "@grafana/data": "^12.0.1",
32
+ "react-error-boundary": "^6.0.0",
33
+ "react-grid-layout": "^1.5.1",
34
+ "react-resizable": "^3.0.5",
35
+ "@rjsf/validator-ajv8": "^5.24.11",
36
+ "@rjsf/utils": "^5.24.11",
37
+ "@ssa-ui-kit/core": "^2.23.2",
38
+ "@ssa-ui-kit/hooks": "^2.23.2"
39
+ },
40
+ "devDependencies": {
41
+ "@emotion/css": "^11.13.5",
42
+ "@emotion/jest": "^11.13.0",
43
+ "@emotion/react": "^11.14.0",
44
+ "@emotion/styled": "^11.14.0",
45
+ "@playwright/test": "^1.48.0",
46
+ "@grafana/schema": "^12.0.1",
47
+ "@types/react-grid-layout": "^1.3.5"
48
+ },
49
+ "peerDependencies": {
50
+ "@emotion/css": "^11.13.5",
51
+ "@emotion/react": "^11.14.0",
52
+ "@emotion/styled": "^11.14.0",
53
+ "react": "18.x",
54
+ "react-dom": "18.x"
55
+ },
56
+ "peerDependenciesMeta": {
57
+ "@types/react": {
58
+ "optional": true
59
+ }
60
+ },
61
+ "scripts": {
62
+ "test": "jest -i --no-cache",
63
+ "build": "webpack --mode=production --node-env=production && tsc --build --force ./tsconfig.build.json && resolve-tspaths -p ./tsconfig.build.json",
64
+ "sb:dev": "storybook dev -p 6009",
65
+ "sb:build": "storybook build",
66
+ "test:e2e": "pnpm exec playwright test --project=chromium",
67
+ "test:e2e:ui": "pnpm exec playwright test --project=chromium --ui",
68
+ "test:e2e:debug": "pnpm exec playwright test --project=chromium --debug"
69
+ }
70
+ }