@industry-theme/principal-view-panels 0.12.91 → 0.12.93

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.
@@ -1,6 +1,13 @@
1
1
  import React from 'react';
2
2
  import type { PanelComponentProps } from '@principal-ade/panel-framework-core';
3
- import type { MetricSource, DiscoveredCanvas, DataProvider } from '@principal-ai/principal-view-core';
3
+ import type { MetricSource, DiscoveredCanvas, DiscoveredStoryboard, DiscoveredWorkflow, WorkflowTemplate, DataProvider } from '@principal-ai/principal-view-core';
4
+ /**
5
+ * Workflow with its loaded template, used for navigation from source links.
6
+ */
7
+ export interface LoadedWorkflow {
8
+ file: DiscoveredWorkflow;
9
+ template: WorkflowTemplate;
10
+ }
4
11
  export interface DashboardPanelProps extends PanelComponentProps {
5
12
  /**
6
13
  * The discovered dashboard to display.
@@ -14,6 +21,17 @@ export interface DashboardPanelProps extends PanelComponentProps {
14
21
  * For testing with sample data, pass MockDataProvider from @principal-ai/principal-view-react.
15
22
  */
16
23
  dataProvider?: DataProvider;
24
+ /**
25
+ * Discovered storyboards for navigating from source links to workflows.
26
+ * When provided, clicking a source link will emit an 'openCanvas' event
27
+ * with the matching storyboard and workflow.
28
+ */
29
+ storyboards?: DiscoveredStoryboard[];
30
+ /**
31
+ * Loaded workflows with their templates, for navigating from source links.
32
+ * Used to include the full workflow template in the 'openCanvas' event.
33
+ */
34
+ workflows?: LoadedWorkflow[];
17
35
  /**
18
36
  * Callback when a metric source link is clicked.
19
37
  * Use this to navigate to the referenced workflow/canvas.
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardPanel.d.ts","sourceRoot":"","sources":["../../src/panels/DashboardPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AACjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAI/E,OAAO,KAAK,EAEV,YAAY,EAGZ,gBAAgB,EAChB,YAAY,EAEb,MAAM,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AE/C;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAiSxD,CAAC"}
@@ -182723,7 +182723,7 @@ function MetricPanel({ metric, data, onMetricClick, onSourceClick }) {
182723
182723
  }, children: jsx("span", { style: { color: theme2.colors.textSecondary, fontSize: theme2.fontSizes[1] }, children: "Loading..." }) });
182724
182724
  }
182725
182725
  if (data.error) {
182726
- return jsxs("div", { style: {
182726
+ return jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [jsxs("div", { style: {
182727
182727
  backgroundColor: theme2.colors.surface || theme2.colors.background,
182728
182728
  border: `1px solid ${theme2.colors.error}`,
182729
182729
  borderRadius: ((_c = theme2.radii) == null ? void 0 : _c[2]) || 8,
@@ -182734,7 +182734,7 @@ function MetricPanel({ metric, data, onMetricClick, onSourceClick }) {
182734
182734
  marginBottom: ((_e4 = theme2.space) == null ? void 0 : _e4[2]) || 8,
182735
182735
  fontSize: theme2.fontSizes[1],
182736
182736
  fontWeight: theme2.fontWeights.medium
182737
- }, children: metric.name }), jsx("div", { style: { color: theme2.colors.textSecondary, fontSize: theme2.fontSizes[0] }, children: data.error })] });
182737
+ }, children: metric.name }), jsx("div", { style: { color: theme2.colors.textSecondary, fontSize: theme2.fontSizes[0] }, children: data.error })] }), metric.sources && metric.sources.length > 0 && onSourceClick && jsx("div", { style: { display: "flex", gap: 8, flexWrap: "wrap" }, children: metric.sources.map((source2, i) => jsx(SourceLink, { source: source2, onClick: onSourceClick }, i)) })] });
182738
182738
  }
182739
182739
  const handleClick = () => {
182740
182740
  onMetricClick == null ? void 0 : onMetricClick(metric.id);
@@ -206083,11 +206083,13 @@ class EmptyDataProvider {
206083
206083
  }
206084
206084
  }
206085
206085
  const DashboardPanel = ({
206086
- context: _context,
206086
+ context: context2,
206087
206087
  actions,
206088
206088
  events,
206089
206089
  selectedDashboard,
206090
206090
  dataProvider,
206091
+ storyboards: storyboardsProp,
206092
+ workflows: workflowsProp,
206091
206093
  onSourceClick,
206092
206094
  onMetricClick
206093
206095
  }) => {
@@ -206102,6 +206104,24 @@ const DashboardPanel = ({
206102
206104
  var _a2;
206103
206105
  return (_a2 = panelRef.current) == null ? void 0 : _a2.focus();
206104
206106
  });
206107
+ const typedContext = context2;
206108
+ const fileTreeSlice = typedContext == null ? void 0 : typedContext.fileTree;
206109
+ const { storyboards: discoveredStoryboards, workflows: discoveredWorkflows } = useCanvasWorkflowData({
206110
+ context: fileTreeSlice ? { fileTree: fileTreeSlice } : {
206111
+ fileTree: {
206112
+ data: null,
206113
+ loading: false,
206114
+ error: null,
206115
+ scope: "repository",
206116
+ name: "fileTree",
206117
+ refresh: async () => {
206118
+ }
206119
+ }
206120
+ },
206121
+ actions
206122
+ });
206123
+ const storyboards = storyboardsProp ?? discoveredStoryboards;
206124
+ const workflows = workflowsProp ?? discoveredWorkflows;
206105
206125
  useEffect(() => {
206106
206126
  if (!selectedDashboard) {
206107
206127
  setDashboard(null);
@@ -206132,21 +206152,64 @@ const DashboardPanel = ({
206132
206152
  (source2) => {
206133
206153
  if (onSourceClick) {
206134
206154
  onSourceClick(source2);
206135
- } else if (events == null ? void 0 : events.emit) {
206155
+ return;
206156
+ }
206157
+ if (!(events == null ? void 0 : events.emit)) return;
206158
+ const matchingStoryboard = storyboards == null ? void 0 : storyboards.find(
206159
+ (sb) => sb.basename === source2.storyboard || sb.name === source2.storyboard
206160
+ );
206161
+ if (matchingStoryboard) {
206162
+ const matchingWorkflowMeta = matchingStoryboard.workflows.find(
206163
+ (wf) => wf.name === source2.workflow || wf.id.endsWith(`/${source2.workflow}`)
206164
+ );
206165
+ if (matchingWorkflowMeta) {
206166
+ const fullWorkflow = workflows == null ? void 0 : workflows.find(
206167
+ (wf) => wf.file.path === matchingWorkflowMeta.path
206168
+ );
206169
+ events.emit({
206170
+ type: "custom",
206171
+ source: "dashboard-panel",
206172
+ timestamp: Date.now(),
206173
+ payload: {
206174
+ action: "openCanvas",
206175
+ canvasId: matchingStoryboard.canvas.id,
206176
+ canvas: matchingStoryboard.canvas,
206177
+ workflowId: matchingWorkflowMeta.id,
206178
+ workflow: fullWorkflow == null ? void 0 : fullWorkflow.template,
206179
+ openMode: "detail",
206180
+ // Include source info for potential node/event highlighting
206181
+ sourceNodes: source2.nodes,
206182
+ sourceEvent: source2.event
206183
+ }
206184
+ });
206185
+ return;
206186
+ }
206136
206187
  events.emit({
206137
- type: "dashboard:source-click",
206188
+ type: "custom",
206138
206189
  source: "dashboard-panel",
206139
206190
  timestamp: Date.now(),
206140
206191
  payload: {
206141
- source: source2,
206142
- storyboard: source2.storyboard,
206143
- workflow: source2.workflow,
206144
- nodes: source2.nodes
206192
+ action: "openCanvas",
206193
+ canvasId: matchingStoryboard.canvas.id,
206194
+ canvas: matchingStoryboard.canvas,
206195
+ openMode: "editor"
206145
206196
  }
206146
206197
  });
206198
+ return;
206147
206199
  }
206200
+ events.emit({
206201
+ type: "dashboard:source-click",
206202
+ source: "dashboard-panel",
206203
+ timestamp: Date.now(),
206204
+ payload: {
206205
+ source: source2,
206206
+ storyboard: source2.storyboard,
206207
+ workflow: source2.workflow,
206208
+ nodes: source2.nodes
206209
+ }
206210
+ });
206148
206211
  },
206149
- [onSourceClick, events]
206212
+ [onSourceClick, events, storyboards, workflows]
206150
206213
  );
206151
206214
  const handleMetricClick = useCallback(
206152
206215
  (metricId) => {