mirror of https://github.com/buster-so/buster.git
metric version number assosicated with report
This commit is contained in:
parent
e471e75514
commit
4f4326dbea
|
@ -85,6 +85,13 @@ export const prefetchGetReport = async (
|
|||
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
|
||||
*/
|
||||
|
|
|
@ -50,11 +50,12 @@ export function MetricToolbar({
|
|||
}, []);
|
||||
|
||||
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 versionNumber = metrics?.[0]?.versionNumber;
|
||||
const at = editor.api.findPath(element);
|
||||
if (!id || !at) return onCloseEdit();
|
||||
plugin.api.metric.updateMetric(id, { at });
|
||||
plugin.api.metric.updateMetric(id, versionNumber, { at });
|
||||
onCloseEdit();
|
||||
},
|
||||
[editor, element, onCloseEdit, plugin.api.metric]
|
||||
|
@ -85,7 +86,7 @@ export function MetricToolbar({
|
|||
</div>
|
||||
</PopoverContent>
|
||||
|
||||
<AddMetricModal
|
||||
{/* <AddMetricModal
|
||||
open={openEditModal}
|
||||
loading={false}
|
||||
initialSelectedMetrics={preselectedMetrics}
|
||||
|
@ -93,7 +94,7 @@ export function MetricToolbar({
|
|||
onAddMetrics={handleAddMetrics}
|
||||
selectionMode="single"
|
||||
saveButtonText="Update metric"
|
||||
/>
|
||||
/> */}
|
||||
</PopoverBase>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ export const metricSerializer: MetricMdNode = {
|
|||
|
||||
return {
|
||||
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 => {
|
||||
|
|
|
@ -50,8 +50,12 @@ export const MetricPlugin = createPlatePlugin<
|
|||
closeAddMetricModal: () => {
|
||||
setOption('openMetricModal', false);
|
||||
},
|
||||
updateMetric: (metricId: string, options?: SetNodesOptions<TMetricElement[]>) => {
|
||||
tf.setNodes<TMetricElement>({ metricId }, options);
|
||||
updateMetric: (
|
||||
metricId: string,
|
||||
versionNumber: number | undefined,
|
||||
options?: SetNodesOptions<TMetricElement[]>
|
||||
) => {
|
||||
tf.setNodes<TMetricElement>({ metricId, versionNumber }, options);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
@ -17,6 +17,9 @@ export const ChatResponseMessage_StandardFile: React.FC<{
|
|||
const selectedIcon = useMemo(() => {
|
||||
if (file_type === 'metric') return <ASSET_ICONS.metrics />;
|
||||
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;
|
||||
}, [file_type]);
|
||||
|
||||
|
|
|
@ -365,6 +365,7 @@ export const MetricElementSchema = z.object({
|
|||
type: z.literal('metric'),
|
||||
id: z.string().optional(), //THIS IS A UNIQUE ID THAT PLATEJS USES. WE SHOULD NOT SET IT.
|
||||
metricId: z.string(),
|
||||
versionNumber: z.number().optional(),
|
||||
width: z.union([z.number(), z.string().regex(/^(?:\d+px|\d+%)$/)]).optional(),
|
||||
children: z.array(VoidTextSchema).default([]),
|
||||
caption: z
|
||||
|
|
Loading…
Reference in New Issue