Skip to content

Commit

Permalink
Merge branch 'task/digital-rocks' into bug/WC-17--drp-project-search-…
Browse files Browse the repository at this point in the history
…case
  • Loading branch information
shayanaijaz authored Dec 10, 2024
2 parents cfb0c3f + 271ce8c commit 00d6d90
Show file tree
Hide file tree
Showing 81 changed files with 3,215 additions and 440 deletions.
15 changes: 15 additions & 0 deletions client/src/components/DataFiles/DataFiles.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import DataFilesModals from './DataFilesModals/DataFilesModals';
import DataFilesProjectsList from './DataFilesProjectsList/DataFilesProjectsList';
import DataFilesProjectFileListing from './DataFilesProjectFileListing/DataFilesProjectFileListing';
import { useSystemRole } from './DataFilesProjectMembers/_cells/SystemRoleSelector';
import DataFilesPublicationsList from './DataFilesPublicationsList/DataFilesPublicationsList';
import DataFilesReviewProjectList from './DataFilesReviewProjectsList/DataFilesReviewProjectList';

const DefaultSystemRedirect = () => {
const systems = useSelector(
Expand Down Expand Up @@ -56,6 +58,11 @@ const DataFilesSwitch = React.memo(() => {
const { DataFilesProjectPublish, DataFilesProjectReview } =
useAddonComponents({ portalName });

const systems = useSelector(
(state) => state.systems.storage.configuration.filter((s) => !s.hidden),
shallowEqual
);

return (
<Switch>
{DataFilesProjectPublish && (
Expand Down Expand Up @@ -92,6 +99,14 @@ const DataFilesSwitch = React.memo(() => {
exact
path={`${path}/tapis/projects/:system`}
render={({ match: { params } }) => {
const system = systems.find((s) => s.system === params.system);

if (system.publicationProject) {
return <DataFilesPublicationsList rootSystem={params.system} />;
} else if (system.reviewProject) {
return <DataFilesReviewProjectList rootSystem={params.system} />;
}

return <DataFilesProjectsList rootSystem={params.system} />;
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const DataFilesBreadcrumbs = ({
});
};

const { fetchSelectedSystem } = useSystems();
const { fetchSelectedSystem, isRootProjectSystem } = useSystems();

const selectedSystem = fetchSelectedSystem({ scheme, system, path });

Expand Down Expand Up @@ -183,9 +183,7 @@ const DataFilesBreadcrumbs = ({
<div className="breadcrumb-container">
<div className={`breadcrumbs ${className}`}>
{currentDirectory.length === 0 ? (
<span className="system-name">
{truncateMiddle(systemName || 'Shared Workspaces', 30)}
</span>
<span className="system-name">{truncateMiddle(systemName, 30)}</span>
) : (
currentDirectory.map((pathComp, i) => {
if (i === fullPath.length - 1) {
Expand All @@ -194,11 +192,13 @@ const DataFilesBreadcrumbs = ({
})
)}
</div>
{systemName && api === 'tapis' && (
<Button type="link" onClick={openFullPathModal}>
View Full Path
</Button>
)}
{systemName &&
api === 'tapis' &&
!isRootProjectSystem(selectedSystem ?? '') && (
<Button type="link" onClick={openFullPathModal}>
View Full Path
</Button>
)}
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ const BreadcrumbsDropdown = ({

const location = useLocation();
const pathParts = location.pathname.split('/');

const projectId = pathParts.includes('projects')
? pathParts[pathParts.indexOf('projects') + 2]
: null;

const rootProjectSystem = pathParts.includes('projects')
? pathParts[pathParts.indexOf('projects') + 1]
: null;

Expand All @@ -35,13 +40,15 @@ const BreadcrumbsDropdown = ({
let url;

if (scheme === 'projects' && targetPath === systemName) {
url = `${basePath}/${api}/projects/${projectId}/`;
url = `${basePath}/${api}/projects/${rootProjectSystem}/${projectId}/`;
} else if (scheme === 'projects' && !targetPath) {
url = `${basePath}/${api}/projects/`;
url = `${basePath}/${api}/projects/${rootProjectSystem}`;
} else if (api === 'googledrive' && !targetPath) {
url = `${basePath}/${api}/${scheme}/${system}/`;
} else if (api === 'tapis' && scheme !== 'projects' && !targetPath) {
url = `${basePath}/${api}/${scheme}/${system}/`;
} else if (scheme === 'projects') {
url = `${basePath}/${api}/projects/${rootProjectSystem}/${system}${targetPath}`;
} else {
url = `${basePath}/${api}/${scheme}/${system}${targetPath}/`;
}
Expand Down Expand Up @@ -69,7 +76,7 @@ const BreadcrumbsDropdown = ({
);

const sharedWorkspacesDisplayName = systems.find(
(e) => e.scheme === 'projects'
(e) => e.scheme === 'projects' && e.system === rootProjectSystem
)?.name;

let currentPath = startingPath;
Expand All @@ -81,7 +88,7 @@ const BreadcrumbsDropdown = ({
const fullPath = paths.reverse();
const displayPaths =
scheme === 'projects' ? [...fullPath, systemName] : fullPath;
const sliceStart = scheme === 'projects' && systemName ? 0 : 1;
const sliceStart = 1;
return (
<div id="path-button-wrapper">
<ButtonDropdown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,24 @@ const DataFilesListing = ({
width: 0.2,
});
}

if (scheme === 'projects' && rootSystem) {
const projectSystem = systems.find(
(s) => s.scheme === 'projects' && s.system === rootSystem
);

if (projectSystem && projectSystem.publicationProject) {
const index = cells.findIndex(
(cell) => cell.Header === 'Last Modified'
);
cells.splice(index, 1);
['Name', 'Size'].forEach((header) => {
const column = cells.find((col) => col.Header === header);
column.width += 0.1;
});
}
}

return cells;
}, [api, showViewPath, fileNavCellCallback]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,17 @@ const DataFilesFormModal = () => {
const validationSchema = Yup.object().shape({
...(form?.form_fields ?? []).reduce((schema, field) => {
if (field.validation?.required) {
schema[field.name] = Yup.string().required(
schema[field.name] = (schema[field.name] || Yup.string()).required(
`${field.label} is required`
);
}

if (field.type === 'link') {
schema[field.name] = (schema[field.name] || Yup.string())
.url(`${field.label} must be a valid URL`)
.matches(/^https:\/\//, `${field.label} must start with https://`);
}

return schema;
}, {}),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Button, Message } from '_common';
import { Modal, ModalHeader, ModalBody } from 'reactstrap';
import DataFilesProjectMembers from '../DataFilesProjectMembers/DataFilesProjectMembers';
import styles from './DataFilesManageProject.module.scss';
import { useAddonComponents } from 'hooks/datafiles';

const DataFilesManageProjectModal = () => {
const dispatch = useDispatch();
Expand Down Expand Up @@ -40,6 +41,12 @@ const DataFilesManageProjectModal = () => {
return projectSystem?.readOnly || !canEditSystem;
});

const portalName = useSelector((state) => state.workbench.portalName);

const { DataFilesManageProjectModalAddon } = useAddonComponents({
portalName,
});

const toggle = useCallback(() => {
setTransferMode(false);
dispatch({
Expand Down Expand Up @@ -154,6 +161,9 @@ const DataFilesManageProjectModal = () => {
</Button>
) : null}
</div>
{DataFilesManageProjectModalAddon && (
<DataFilesManageProjectModalAddon projectId={projectId} />
)}
</ModalBody>
</Modal>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ import DataFilesDownloadMessageModal from './DataFilesDownloadMessageModal';
import './DataFilesModals.scss';
import DataFilesFormModal from './DataFilesFormModal';
import DataFilesPublicationRequestModal from './DataFilesPublicationRequestModal';
import DataFilesProjectTreeModal from './DataFilesProjectTreeModal';
import DataFilesProjectDescriptionModal from './DataFilesProjectDescriptionModal';
import DataFilesViewDataModal from './DataFilesViewDataModal';
import DataFilesProjectCitationModal from './DataFilesProjectCitationModal';
import DataFilesPublicationAuthorsModal from './DataFilesPublicationAuthorsModal';

export default function DataFilesModals() {
return (
Expand All @@ -41,7 +46,12 @@ export default function DataFilesModals() {
<DataFilesMakePublicModal />
<DataFilesDownloadMessageModal />
<DataFilesFormModal />
<DataFilesProjectTreeModal />
<DataFilesPublicationRequestModal />
<DataFilesProjectDescriptionModal />
<DataFilesViewDataModal />
<DataFilesProjectCitationModal />
<DataFilesPublicationAuthorsModal />
</>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React, { useCallback } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { Modal, ModalHeader, ModalBody } from 'reactstrap';
import styles from './DataFilesProjectCitationModal.module.scss';
import { Citations } from '_custom/drp/DataFilesProjectPublish/DataFilesProjectPublishWizardSteps/ReviewAuthors';

const DataFilesProjectCitationModal = () => {
const dispatch = useDispatch();

const isOpen = useSelector((state) => state.files.modals.projectCitation);
const props = useSelector((state) => state.files.modalProps.projectCitation);

const toggle = useCallback(() => {
dispatch({
type: 'DATA_FILES_TOGGLE_MODAL',
payload: { operation: 'projectCitation', props: {} },
});
}, []);

return (
<>
{props?.project && (
<Modal
size="lg"
isOpen={isOpen}
toggle={toggle}
className={styles['modal-dialog']}
>
<ModalHeader toggle={toggle} charCode="&#xe912;">
Citations
</ModalHeader>
<ModalBody className={styles['modal-body']}>
<Citations
project={props.project}
authors={props.project.authors}
/>
</ModalBody>
</Modal>
)}
</>
);
};

export default DataFilesProjectCitationModal;
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React, { useCallback } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { Modal, ModalHeader, ModalBody } from 'reactstrap';
import styles from './DataFilesProjectDescriptionModal.module.scss';

const DataFilesProjectDescriptionModal = () => {
const dispatch = useDispatch();

const isOpen = useSelector((state) => state.files.modals.projectDescription);
const props = useSelector(
(state) => state.files.modalProps.projectDescription
);

const toggle = useCallback(() => {
dispatch({
type: 'DATA_FILES_TOGGLE_MODAL',
payload: { operation: 'projectDescription', props: {} },
});
}, []);

return (
<>
<Modal
size="lg"
isOpen={isOpen}
toggle={toggle}
className={styles['modal-dialog']}
>
<ModalHeader toggle={toggle} charCode="&#xe912;">
{props?.title}
</ModalHeader>
<ModalBody className={styles['modal-body']}>
<p>{props?.description}</p>
</ModalBody>
</Modal>
</>
);
};

export default DataFilesProjectDescriptionModal;
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const DataFilesProjectEditDescriptionModal = () => {
description: values.description || '',
metadata: DataFilesProjectEditDescriptionModalAddon ? values : null,
},
modal: 'editproject',
},
});
},
Expand Down Expand Up @@ -89,7 +90,7 @@ const DataFilesProjectEditDescriptionModal = () => {
{({ isValid, dirty }) => (
<Form>
<ModalHeader toggle={toggle} charCode="&#xe912;">
Edit Project
Edit Dataset
</ModalHeader>
<ModalBody className={styles['modal-body']}>
<FormField
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React, { useCallback } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { Modal, ModalHeader, ModalBody } from 'reactstrap';
import styles from './DataFilesProjectTreeModal.module.scss';
import { ProjectTreeView } from '_custom/drp/DataFilesProjectPublish/DataFilesProjectPublishWizardSteps/ProjectTreeView';

const DataFilesProjectTreeModal = () => {
const { projectId } = useSelector((state) => state.projects.metadata);

const isOpen = useSelector((state) => state.files.modals.projectTree);
const props = useSelector((state) => state.files.modalProps['projectTree']);

const toggle = useCallback(() => {
dispatch({
type: 'DATA_FILES_TOGGLE_MODAL',
payload: { operation: 'projectTree', props: {} },
});
}, []);

const dispatch = useDispatch();

return (
<>
<Modal
size="lg"
isOpen={isOpen}
toggle={toggle}
className={styles['modal-dialog']}
>
<ModalHeader toggle={toggle} charCode="&#xe912;">
Project Tree
</ModalHeader>
<ModalBody className={styles['modal-body']}>
{' '}
<ProjectTreeView
projectId={projectId}
readOnly={props?.readOnly ?? true}
/>
</ModalBody>
</Modal>
</>
);
};

export default DataFilesProjectTreeModal;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.modal-body {
overflow: auto;
max-height: 80vh;
}
Loading

0 comments on commit 00d6d90

Please sign in to comment.