diff --git a/frontend/src/app/routes/models/model-details.tsx b/frontend/src/app/routes/models/model-details.tsx index 48f22460..c98d3f5c 100644 --- a/frontend/src/app/routes/models/model-details.tsx +++ b/frontend/src/app/routes/models/model-details.tsx @@ -32,12 +32,8 @@ export const ModelDetailsPage = () => { openDialog: openModelFilesDialog, } = useDialog(); const navigate = useNavigate(); - const { data, isPending, isError, error } = useModelDetails( - id as string, - id !== undefined, - 10000, - ); - const { isAuthenticated } = useAuth(); + const { data, isPending, isError, error } = useModelDetails(id as string, id !== undefined, 10000); + const { user } = useAuth(); useEffect(() => { if (isError) { @@ -59,6 +55,7 @@ export const ModelDetailsPage = () => { if (isPending || isError) { return ; } + const isOwner = user?.osm_id === data?.user?.osm_id; return ( <> @@ -111,7 +108,6 @@ export const ModelDetailsPage = () => { size="medium" prefixIcon={StarStackIcon} onClick={openModelEnhancementDialog} - disabled={!isAuthenticated} /> {/* mobile */} @@ -127,7 +123,7 @@ export const ModelDetailsPage = () => { size="medium" prefixIcon={StarStackIcon} onClick={openModelEnhancementDialog} - disabled={!isAuthenticated} + disabled={!isOwner} /> { content: [ `${MODEL_CREATION_CONTENT.trainingSettings.form.epoch.label}: ${formData.epoch}`, `${MODEL_CREATION_CONTENT.trainingSettings.form.batchSize.label}: ${formData.batchSize}`, - formData.baseModel === BASE_MODELS.RAMP - ? `${MODEL_CREATION_CONTENT.trainingSettings.form.contactSpacing.label}: ${formData.contactSpacing}` - : "", - formData.baseModel === BASE_MODELS.RAMP - ? `${MODEL_CREATION_CONTENT.trainingSettings.form.boundaryWidth.label}: ${formData.boundaryWidth}` - : "", + formData.baseModel === BASE_MODELS.RAMP ? `${MODEL_CREATION_CONTENT.trainingSettings.form.contactSpacing.label}: ${formData.contactSpacing}` : '', + formData.baseModel === BASE_MODELS.RAMP ? `${MODEL_CREATION_CONTENT.trainingSettings.form.boundaryWidth.label}: ${formData.boundaryWidth}` : '', ], }, ]; diff --git a/frontend/src/features/model-creation/components/progress-bar.tsx b/frontend/src/features/model-creation/components/progress-bar.tsx index b2ecd89d..ee5a68f1 100644 --- a/frontend/src/features/model-creation/components/progress-bar.tsx +++ b/frontend/src/features/model-creation/components/progress-bar.tsx @@ -1,8 +1,6 @@ -import { useModelsContext } from "@/app/providers/models-provider"; import CheckIcon from "@/components/ui/icons/check-icon"; import { cn } from "@/utils"; import { memo } from "react"; -import { useNavigate } from "react-router-dom"; type ProgressBarProps = { currentPath: string; @@ -12,21 +10,14 @@ type ProgressBarProps = { const ProgressBar: React.FC = memo( ({ currentPath, currentPageIndex, pages }) => { - const navigate = useNavigate(); - const { getFullPath, isEditMode } = useModelsContext(); return ( - {pages.map((step, index) => { + {pages.map((step) => { const activeStep = currentPath.includes(step.path); - const isLastPage = index === pages.length - 1; return ( - isEditMode && !isLastPage && navigate(getFullPath(step.path)) - } > {step.id < currentPageIndex + 1 ? ( diff --git a/frontend/src/features/models/api/factory.ts b/frontend/src/features/models/api/factory.ts index 2285603b..b416db41 100644 --- a/frontend/src/features/models/api/factory.ts +++ b/frontend/src/features/models/api/factory.ts @@ -46,15 +46,12 @@ export const getModelsQueryOptions = ({ }); }; -export const getModelDetailsQueryOptions = ( - id: string, - refetchInterval: boolean | number, -) => { +export const getModelDetailsQueryOptions = (id: string, refetchInterval: boolean | number) => { return queryOptions({ queryKey: [queryKeys.MODEL_DETAILS(id)], queryFn: () => getModelDetails(id), //@ts-expect-error bad type definition - refetchInterval: refetchInterval, + refetchInterval: refetchInterval }); }; diff --git a/frontend/src/features/models/components/dialogs/model-files-dialog.tsx b/frontend/src/features/models/components/dialogs/model-files-dialog.tsx index d1ce6ded..4a2de107 100644 --- a/frontend/src/features/models/components/dialogs/model-files-dialog.tsx +++ b/frontend/src/features/models/components/dialogs/model-files-dialog.tsx @@ -20,12 +20,7 @@ const ModelFilesDialog: React.FC = ({ closeDialog={closeDialog} label={APP_CONTENT.models.modelsDetailsCard.modelFilesDialog.dialogTitle} > - - { - APP_CONTENT.models.modelsDetailsCard.modelFilesDialog - .dialogDescription - } - + {APP_CONTENT.models.modelsDetailsCard.modelFilesDialog.dialogDescription} {isOpened && ( = ({ const fetchDirectoryRecursive = async ( currentDirectory: string = "", currentDepth: number = 0, - maxDepth: number = 2, + maxDepth: number = 2 ): Promise => { if (currentDepth >= maxDepth) { + return {}; } @@ -135,24 +136,24 @@ const DirectoryTree: React.FC = ({ const subdirectories = dir && currentDepth < maxDepth ? await Promise.all( - Object.keys(dir).map(async (key: string) => { - const fullPath = currentDirectory - ? `${currentDirectory}/${key}` - : key; - const subDirData = await fetchDirectoryRecursive( - fullPath, - currentDepth + 1, - maxDepth, - ); - return { - [key]: { - ...subDirData, - size: dir[key]?.size || 0, - length: dir[key]?.len || 0, - }, - }; - }), - ) + Object.keys(dir).map(async (key: string) => { + const fullPath = currentDirectory + ? `${currentDirectory}/${key}` + : key; + const subDirData = await fetchDirectoryRecursive( + fullPath, + currentDepth + 1, + maxDepth + ); + return { + [key]: { + ...subDirData, + size: dir[key]?.size || 0, + length: dir[key]?.len || 0, + }, + }; + }) + ) : []; return { diff --git a/frontend/src/features/models/hooks/use-models.ts b/frontend/src/features/models/hooks/use-models.ts index 576670a5..2606cb0d 100644 --- a/frontend/src/features/models/hooks/use-models.ts +++ b/frontend/src/features/models/hooks/use-models.ts @@ -39,11 +39,7 @@ export const useModels = ({ }); }; -export const useModelDetails = ( - id: string, - enabled: boolean = true, - refetchInterval: boolean | number = false, -) => { +export const useModelDetails = (id: string, enabled: boolean = true, refetchInterval: boolean | number = false) => { return useQuery({ ...getModelDetailsQueryOptions(id, refetchInterval), //@ts-expect-error bad type definition
- { - APP_CONTENT.models.modelsDetailsCard.modelFilesDialog - .dialogDescription - } -
{APP_CONTENT.models.modelsDetailsCard.modelFilesDialog.dialogDescription}