metric version number assosicated with report

This commit is contained in:
Nate Kelley 2025-09-10 15:09:44 -06:00
parent e471e75514
commit 4f4326dbea
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
6 changed files with 23 additions and 7 deletions

View File

@ -85,6 +85,13 @@ export const prefetchGetReport = async (
return existingData || queryClient.getQueryData(queryKey); return existingData || queryClient.getQueryData(queryKey);
}; };
export const usePrefetchGetReportClient = () => {
const queryClient = useQueryClient();
return (reportId: string, versionNumber?: number) => {
return prefetchGetReport(reportId, versionNumber, queryClient);
};
};
/** /**
* Hook to get an individual report by ID * Hook to get an individual report by ID
*/ */

View File

@ -50,11 +50,12 @@ export function MetricToolbar({
}, []); }, []);
const handleAddMetrics = React.useCallback( const handleAddMetrics = React.useCallback(
async (metrics: { id: string; name: string }[]) => { async (metrics: { id: string; name: string; versionNumber: number | undefined }[]) => {
const id = metrics?.[0]?.id; const id = metrics?.[0]?.id;
const versionNumber = metrics?.[0]?.versionNumber;
const at = editor.api.findPath(element); const at = editor.api.findPath(element);
if (!id || !at) return onCloseEdit(); if (!id || !at) return onCloseEdit();
plugin.api.metric.updateMetric(id, { at }); plugin.api.metric.updateMetric(id, versionNumber, { at });
onCloseEdit(); onCloseEdit();
}, },
[editor, element, onCloseEdit, plugin.api.metric] [editor, element, onCloseEdit, plugin.api.metric]
@ -85,7 +86,7 @@ export function MetricToolbar({
</div> </div>
</PopoverContent> </PopoverContent>
<AddMetricModal {/* <AddMetricModal
open={openEditModal} open={openEditModal}
loading={false} loading={false}
initialSelectedMetrics={preselectedMetrics} initialSelectedMetrics={preselectedMetrics}
@ -93,7 +94,7 @@ export function MetricToolbar({
onAddMetrics={handleAddMetrics} onAddMetrics={handleAddMetrics}
selectionMode="single" selectionMode="single"
saveButtonText="Update metric" saveButtonText="Update metric"
/> /> */}
</PopoverBase> </PopoverBase>
); );
} }

View File

@ -25,7 +25,7 @@ export const metricSerializer: MetricMdNode = {
return { return {
type: 'html', type: 'html',
value: `<metric metricId="${metricId}" width="${hasWidth ? width : '100%'}" caption="${captionText}"></metric>`, value: `<metric metricId="${metricId}" versionNumber="${node.versionNumber}" width="${hasWidth ? width : '100%'}" caption="${captionText}"></metric>`,
}; };
}, },
deserialize: (node): MetricElement => { deserialize: (node): MetricElement => {

View File

@ -50,8 +50,12 @@ export const MetricPlugin = createPlatePlugin<
closeAddMetricModal: () => { closeAddMetricModal: () => {
setOption('openMetricModal', false); setOption('openMetricModal', false);
}, },
updateMetric: (metricId: string, options?: SetNodesOptions<TMetricElement[]>) => { updateMetric: (
tf.setNodes<TMetricElement>({ metricId }, options); metricId: string,
versionNumber: number | undefined,
options?: SetNodesOptions<TMetricElement[]>
) => {
tf.setNodes<TMetricElement>({ metricId, versionNumber }, options);
}, },
}; };
}); });

View File

@ -17,6 +17,9 @@ export const ChatResponseMessage_StandardFile: React.FC<{
const selectedIcon = useMemo(() => { const selectedIcon = useMemo(() => {
if (file_type === 'metric') return <ASSET_ICONS.metrics />; if (file_type === 'metric') return <ASSET_ICONS.metrics />;
if (file_type === 'dashboard') return <ASSET_ICONS.dashboards />; if (file_type === 'dashboard') return <ASSET_ICONS.dashboards />;
if (file_type === 'report') return <ASSET_ICONS.reports />;
if (file_type === 'reasoning') return null;
const _exhaustiveCheck: never = file_type;
return null; return null;
}, [file_type]); }, [file_type]);

View File

@ -365,6 +365,7 @@ export const MetricElementSchema = z.object({
type: z.literal('metric'), type: z.literal('metric'),
id: z.string().optional(), //THIS IS A UNIQUE ID THAT PLATEJS USES. WE SHOULD NOT SET IT. id: z.string().optional(), //THIS IS A UNIQUE ID THAT PLATEJS USES. WE SHOULD NOT SET IT.
metricId: z.string(), metricId: z.string(),
versionNumber: z.number().optional(),
width: z.union([z.number(), z.string().regex(/^(?:\d+px|\d+%)$/)]).optional(), width: z.union([z.number(), z.string().regex(/^(?:\d+px|\d+%)$/)]).optional(),
children: z.array(VoidTextSchema).default([]), children: z.array(VoidTextSchema).default([]),
caption: z caption: z