Merge pull request #222 from buster-so/evals

Evals
This commit is contained in:
Nate Kelley 2025-04-22 17:22:54 -06:00 committed by GitHub
commit c9ccc191df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 49 additions and 22 deletions

View File

@ -33,12 +33,13 @@ export default async function Layout({
const userInfo = queryClient.getQueryData(queryKeys.userGetUserMyself.queryKey);
const newUserRoute = createBusterRoute({ route: BusterRoutes.NEW_USER });
const loginRoute = createBusterRoute({ route: BusterRoutes.AUTH_LOGIN });
if (
(!userInfo?.organizations?.[0]?.id || !userInfo?.user?.name) &&
!supabaseContext.user?.is_anonymous &&
pathname !== newUserRoute
) {
if (supabaseContext.user?.is_anonymous && pathname !== loginRoute) {
return <ClientRedirect to={loginRoute} />;
}
if ((!userInfo?.organizations?.[0]?.id || !userInfo?.user?.name) && pathname !== newUserRoute) {
return <ClientRedirect to={newUserRoute} />;
}

View File

@ -35,7 +35,10 @@ export const assetTypeToRoute = (assetType: ShareAssetType, assetId: string) =>
return createBusterRoute({ route: BusterRoutes.APP_DASHBOARD_ID, dashboardId: assetId });
case ShareAssetType.COLLECTION:
return createBusterRoute({ route: BusterRoutes.APP_COLLECTIONS_ID, collectionId: assetId });
case ShareAssetType.CHAT:
return createBusterRoute({ route: BusterRoutes.APP_CHAT_ID, chatId: assetId });
default:
console.warn('Asset type to route not found', assetType, assetId);
return '';
}
};

View File

@ -3,7 +3,8 @@ import { AvatarUserButton } from './AvatarUserButton';
const defaultUser = {
username: 'John Doe',
avatarUrl: 'https://i.pravatar.cc/200',
avatarUrl:
'https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=200&h=200&q=80',
email: 'john.doe@example.com'
};

View File

@ -9016,8 +9016,6 @@ export const scatterDataProblematic1 = {
}
};
console.log(scatterDataProblematic1);
export const scatterConfig_problematic1 = {
selectedChartType: ChartType.Scatter,
columnLabelFormats: {

View File

@ -7,6 +7,8 @@ import { dashboardQueryKeys } from '@/api/query_keys/dashboard';
import { compareObjectsByKeys } from '@/lib/objects';
import { useMemo } from 'react';
import { create } from 'mutative';
import { canEdit } from '@/lib/share';
import last from 'lodash/last';
export const useIsDashboardChanged = ({ dashboardId }: { dashboardId: string | undefined }) => {
const queryClient = useQueryClient();
@ -19,11 +21,18 @@ export const useIsDashboardChanged = ({ dashboardId }: { dashboardId: string | u
name: x.dashboard.name,
description: x.dashboard.description,
config: x.dashboard.config,
file: x.dashboard.file
file: x.dashboard.file,
permission: x.permission,
versions: x.versions,
version_number: x.dashboard.version_number
})
}
);
const isLatestVersion = useMemo(() => {
return currentDashboard?.version_number === last(currentDashboard?.versions)?.version_number;
}, [currentDashboard]);
const onResetDashboardToOriginal = useMemoizedFn(() => {
const options = dashboardQueryKeys.dashboardGetDashboard(
dashboardId || '',
@ -39,7 +48,10 @@ export const useIsDashboardChanged = ({ dashboardId }: { dashboardId: string | u
refetchCurrentDashboard();
});
const isEditor = canEdit(currentDashboard?.permission);
const isDashboardChanged = useMemo(() => {
if (!isEditor || !isLatestVersion || !currentDashboard || !originalDashboard) return false;
return (
!originalDashboard ||
!currentDashboard ||
@ -50,7 +62,7 @@ export const useIsDashboardChanged = ({ dashboardId }: { dashboardId: string | u
'file'
])
);
}, [originalDashboard, currentDashboard]);
}, [originalDashboard, isEditor, currentDashboard, isLatestVersion]);
return {
onResetDashboardToOriginal,

View File

@ -1,5 +1,5 @@
import { useGetDashboard } from '@/api/buster_rest/dashboards';
import { canEdit } from '@/lib/share';
import { canEdit, getIsOwner } from '@/lib/share';
import { useMemo } from 'react';
import last from 'lodash/last';
import { useChatLayoutContextSelector } from '@/layouts/ChatLayout';
@ -44,11 +44,14 @@ export const useIsDashboardReadOnly = ({
return false;
}, [isError, isFetched, dashboardData, isVersionHistoryMode, isViewingOldVersion]);
const isEditor = canEdit(dashboardData?.permission);
return {
isVersionHistoryMode,
isReadOnly,
isViewingOldVersion,
isFetched,
isError
isError,
isEditor
};
};

View File

@ -6,6 +6,7 @@ import { useGetMetric } from '@/api/buster_rest/metrics';
import { compareObjectsByKeys } from '@/lib/objects';
import { useMemo } from 'react';
import last from 'lodash/last';
import { canEdit } from '@/lib/share';
export const useIsMetricChanged = ({ metricId }: { metricId: string | undefined }) => {
const queryClient = useQueryClient();
@ -25,7 +26,8 @@ export const useIsMetricChanged = ({ metricId }: { metricId: string | undefined
chart_config: x.chart_config,
file: x.file,
version_number: x.version_number,
versions: x.versions
versions: x.versions,
permission: x.permission
})
}
);
@ -44,8 +46,10 @@ export const useIsMetricChanged = ({ metricId }: { metricId: string | undefined
refetchCurrentMetric();
});
const isEditor = canEdit(currentMetric?.permission);
const isMetricChanged = useMemo(() => {
if (!originalMetric || !isLatestVersion) return false;
if (!isEditor || !originalMetric || !isLatestVersion || !currentMetric) return false;
return (
!currentMetric ||
@ -57,7 +61,7 @@ export const useIsMetricChanged = ({ metricId }: { metricId: string | undefined
'version_number'
])
);
}, [originalMetric, currentMetric, isLatestVersion]);
}, [originalMetric, currentMetric, isLatestVersion, isEditor]);
return {
onResetMetricToOriginal,

View File

@ -51,11 +51,14 @@ export const useIsMetricReadOnly = ({
isViewingOldVersion
]);
const isEditor = canEdit(metricData?.permission);
return {
isFetched,
isError,
isVersionHistoryMode,
isReadOnly,
isViewingOldVersion
isViewingOldVersion,
isEditor
};
};

View File

@ -63,7 +63,7 @@ export const DashboardViewDashboardController: React.FC<{
readOnly={isReadOnly}
/>
{!isVersionHistoryMode && !isViewingOldVersion && (
{!isReadOnly && !isVersionHistoryMode && !isViewingOldVersion && (
<DashboardSaveFilePopup dashboardId={dashboardId} />
)}
</div>

View File

@ -57,10 +57,12 @@ export const MetricViewChart: React.FC<{
const { name, description, time_frame, evaluation_score, evaluation_summary } = metric || {};
const isTable = metric?.chart_config.selectedChartType === ChartType.Table;
const { isReadOnly, isVersionHistoryMode, isViewingOldVersion } = useIsMetricReadOnly({
const { isReadOnly, isEditor, isVersionHistoryMode, isViewingOldVersion } = useIsMetricReadOnly(
{
metricId,
readOnly: readOnlyProp
});
}
);
const loadingData = !isFetchedMetricData;
const errorData = !!metricDataError;
const showEvaluation = !!evaluation_score && !!evaluation_summary;
@ -109,7 +111,7 @@ export const MetricViewChart: React.FC<{
/>
</AnimatePresenceWrapper>
{!isVersionHistoryMode && !isViewingOldVersion && (
{!isReadOnly && !isVersionHistoryMode && !isViewingOldVersion && (
<MetricSaveFilePopup metricId={metricId} />
)}
</div>