Skip to content

Commit

Permalink
Merge branch 'main' into task/WG-432-rework-state-regarding-feature-c…
Browse files Browse the repository at this point in the history
…hanges-filter-changes
  • Loading branch information
nathanfranklin authored Mar 4, 2025
2 parents 09b9b85 + d423351 commit 3d4bba9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
2 changes: 1 addition & 1 deletion react/src/components/AssetDetail/AssetButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const AssetButton: React.FC<AssetButtonProps> = ({
},
onError: (error) => {
setIsModalOpen(false);
notification.success({
notification.error({
description: `There was an error importing your asset for feature ${selectedFeature.id}. Error: ${error}`,
});
},
Expand Down
13 changes: 6 additions & 7 deletions react/src/components/CreateMapModal/CreateMapModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { useAuthenticatedUser, useCreateProject } from '@hazmapper/hooks';
import { ProjectRequest } from '@hazmapper/types';
import { FileListing } from '@hazmapper/components/Files';
import { truncateMiddle } from '@hazmapper/utils/truncateMiddle';
import { renderFilePathLabel } from '@hazmapper/utils/fileUtils';
import styles from './CreateMapModal.module.css';

type CreateMapModalProps = {
Expand Down Expand Up @@ -99,13 +100,11 @@ const CreateMapModal = ({ isOpen, closeModal }: CreateMapModalProps) => {

const handleDirectoryChange = (directory: string) => {
const systemId = getValues('systemId');
const saveLocationDisplay =
systemId === 'designsafe.storage.default'
? directory.replace(
new RegExp(`^${userData?.username}(/)?`),
'My Data/'
)
: directory.replace(new RegExp(`^(/)?`), 'Project Root/');
const saveLocationDisplay = renderFilePathLabel(
directory,
userData?.username || '',
systemId
);
setValue('saveLocationDisplay', saveLocationDisplay);
setValue('systemPath', directory);
};
Expand Down
14 changes: 12 additions & 2 deletions react/src/components/ManageMapProjectPanel/SaveTabContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import React, { useMemo } from 'react';
import { Project } from '@hazmapper/types';
import { List, Button } from 'antd';
import { LoadingSpinner, SectionMessage } from '@tacc/core-components';
import { useAppConfiguration, useDesignSafeProjects } from '@hazmapper/hooks';
import {
useAppConfiguration,
useDesignSafeProjects,
useAuthenticatedUser,
} from '@hazmapper/hooks';
import { renderFilePathLabel } from '@hazmapper/utils/fileUtils';

interface SaveTabProps {
project: Project;
Expand All @@ -16,6 +21,7 @@ const SaveTabContent: React.FC<SaveTabProps> = ({ project }) => {
isLoading,
error,
} = useDesignSafeProjects();
const { data: userData } = useAuthenticatedUser();
const dsDataDepotUrl = `${config.designsafePortalUrl}/data/browser/`;
const dsProj = designSafeProjects?.result?.find(
(ds_project) =>
Expand Down Expand Up @@ -79,7 +85,11 @@ const SaveTabContent: React.FC<SaveTabProps> = ({ project }) => {
rel="noreferrer"
style={{ padding: 0 }}
>
{project.system_path}
{renderFilePathLabel(
project.system_path,
userData?.username || '',
project.system_id
)}
</Button>
</>
}
Expand Down
11 changes: 10 additions & 1 deletion react/src/utils/fileUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const IMPORTABLE_FEATURE_TYPES = [
export const IMPORTABLE_FEATURE_ASSET_TYPES = [
'jpeg',
'jpg',
'png',
'mp4',
'mov',
'mpeg4',
Expand Down Expand Up @@ -59,3 +58,13 @@ export const convertFilesToTapisPaths = (files: File[]): TapisFilePath[] => {
};
});
};

export const renderFilePathLabel = (
path: string,
username: string,
systemId: string
) => {
return systemId === 'designsafe.storage.default'
? path.replace(new RegExp(`^${username}(/)?`), 'My Data/')
: path.replace(new RegExp(`^(/)?`), 'Project Root/');
};

0 comments on commit 3d4bba9

Please sign in to comment.