mirror of https://github.com/buster-so/buster.git
version query updates
This commit is contained in:
parent
486d93e826
commit
5bf24bf322
|
@ -162,7 +162,6 @@ export const DEFAULT_IBUSTER_METRIC: Required<IBusterMetric> = {
|
|||
sent_by_name: '',
|
||||
permission: ShareRole.CAN_VIEW,
|
||||
sent_by_avatar_url: null,
|
||||
draft_session_id: null,
|
||||
dashboards: [],
|
||||
collections: [],
|
||||
chart_config: DEFAULT_CHART_CONFIG,
|
||||
|
|
|
@ -26,7 +26,6 @@ export type BusterMetric = {
|
|||
sent_by_avatar_url: string | null;
|
||||
code: string | null;
|
||||
feedback: 'negative' | null;
|
||||
draft_session_id: string | null; //DO WE NEED THIS?
|
||||
dashboards: {
|
||||
id: string;
|
||||
name: string;
|
||||
|
|
|
@ -5,6 +5,7 @@ import type { ShareRequest } from '@/api/asset_interfaces/shared_interfaces';
|
|||
export interface GetMetricParams {
|
||||
id: string;
|
||||
password?: string;
|
||||
version_number?: number; //api will default to latest if not provided
|
||||
}
|
||||
|
||||
export interface ListMetricsParams {
|
||||
|
|
|
@ -131,21 +131,8 @@ export const prefetchGetMetricDataClient = async (
|
|||
* It will simply use the params passed in and not do any special logic.
|
||||
*/
|
||||
export const useSaveMetric = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: updateMetric,
|
||||
onSuccess: (data) => {
|
||||
const hasDraftSessionId = data.draft_session_id;
|
||||
const metricId = data.id;
|
||||
const options = metricsQueryKeys.metricsGetMetric(metricId);
|
||||
const currentMetric = queryClient.getQueryData(options.queryKey);
|
||||
if (hasDraftSessionId && !currentMetric?.draft_session_id && currentMetric) {
|
||||
queryClient.setQueryData(options.queryKey, {
|
||||
...currentMetric,
|
||||
draft_session_id: data.draft_session_id
|
||||
});
|
||||
}
|
||||
}
|
||||
mutationFn: updateMetric
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@ import type {
|
|||
BusterMetricListItem
|
||||
} from '@/api/asset_interfaces/metric';
|
||||
|
||||
export const getMetric = async ({ id, password }: GetMetricParams) => {
|
||||
export const getMetric = async ({ id, password, version_number }: GetMetricParams) => {
|
||||
return mainApi
|
||||
.get<BusterMetric>(`/metrics/${id}`, {
|
||||
params: { ...(password && { password }) }
|
||||
params: { password, version_number }
|
||||
})
|
||||
.then((res) => res.data);
|
||||
};
|
||||
|
|
|
@ -6,9 +6,9 @@ import type {
|
|||
} from '@/api/asset_interfaces/metric';
|
||||
import { ListMetricsParams } from '../buster_rest/metrics';
|
||||
|
||||
export const metricsGetMetric = (metricId: string) => {
|
||||
export const metricsGetMetric = (metricId: string, version_number?: number) => {
|
||||
return queryOptions<IBusterMetric>({
|
||||
queryKey: ['metrics', 'get', metricId] as const,
|
||||
queryKey: ['metrics', 'get', metricId, version_number] as const,
|
||||
staleTime: 30 * 60 * 1000
|
||||
});
|
||||
};
|
||||
|
|
|
@ -80,19 +80,23 @@ export const buttonVariants = cva(
|
|||
export const buttonIconVariants = cva('', {
|
||||
variants: {
|
||||
variant: {
|
||||
default: 'text-icon-color!',
|
||||
black: 'text-white!',
|
||||
primary: 'text-white!',
|
||||
ghost: 'text-icon-color!',
|
||||
link: 'text-icon-color!',
|
||||
danger: 'text-danger-foreground!',
|
||||
warning: 'text-warning-foreground!',
|
||||
success: 'text-success-foreground!'
|
||||
default: 'text-icon-color',
|
||||
black: 'text-white',
|
||||
primary: 'text-white',
|
||||
ghost: 'text-icon-color',
|
||||
link: 'text-icon-color',
|
||||
danger: 'text-danger-foreground',
|
||||
warning: 'text-warning-foreground',
|
||||
success: 'text-success-foreground'
|
||||
},
|
||||
size: {
|
||||
default: 'text-icon-size',
|
||||
tall: 'text-icon-size-lg',
|
||||
small: 'text-icon-size-sm'
|
||||
},
|
||||
disabled: {
|
||||
true: 'text-gray-light',
|
||||
false: ''
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -158,14 +162,14 @@ export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|||
<LoadingIcon variant={variant} size={size} />
|
||||
) : (
|
||||
prefix && (
|
||||
<span className={cn(buttonIconVariants({ variant, size }), prefixClassName)}>
|
||||
<span className={cn(buttonIconVariants({ disabled, variant, size }), prefixClassName)}>
|
||||
{prefix}
|
||||
</span>
|
||||
)
|
||||
)}
|
||||
{hasChildren && <span className="">{children}</span>}
|
||||
{suffix && (
|
||||
<span className={cn(buttonIconVariants({ variant, size }), suffixClassName)}>
|
||||
<span className={cn(buttonIconVariants({ disabled, variant, size }), suffixClassName)}>
|
||||
{suffix}
|
||||
</span>
|
||||
)}
|
||||
|
|
|
@ -154,7 +154,6 @@ export const createMockMetric = (id: string): IBusterMetric => {
|
|||
)
|
||||
SELECT * FROM records;`,
|
||||
feedback: null,
|
||||
draft_session_id: null,
|
||||
collections: [],
|
||||
dashboards: [],
|
||||
sharingKey: '',
|
||||
|
|
Loading…
Reference in New Issue