Skip to content

Commit

Permalink
Merge branch 'task/digital-rocks' into WC-129-Dataset-form-redirect-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shayanaijaz authored Dec 10, 2024
2 parents 27dd865 + 761c23d commit 117b4f9
Show file tree
Hide file tree
Showing 42 changed files with 811 additions and 129 deletions.
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 @@ -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 @@ -23,6 +23,7 @@ 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 Down Expand Up @@ -50,6 +51,7 @@ export default function DataFilesModals() {
<DataFilesProjectDescriptionModal />
<DataFilesViewDataModal />
<DataFilesProjectCitationModal />
<DataFilesPublicationAuthorsModal />
</>
);
}
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,61 @@
import InfiniteScrollTable from '_common/InfiniteScrollTable';
import React, { useCallback, useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { Modal, ModalHeader, ModalBody } from 'reactstrap';
import styles from './DataFilesPublicationAuthorsModal.module.scss';

const DataFilesPublicationAuthorsModal = () => {
const dispatch = useDispatch();
const isOpen = useSelector((state) => state.files.modals.publicationAuthors);
const props = useSelector(
(state) => state.files.modalProps.publicationAuthors
);

const columns = [
{
Header: 'Name',
accessor: (el) => el,
Cell: (el) => {
const { first_name, last_name } = el.value;
return (
<span className={styles.content}>
{first_name} {last_name}
</span>
);
},
},
{
Header: 'Email',
accessor: 'email',
},
];

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

return (
<Modal
size="lg"
isOpen={isOpen}
toggle={toggle}
className={styles['modal-dialog']}
>
<ModalHeader toggle={toggle} charCode="&#xe912;">
Authors
</ModalHeader>
<ModalBody className={styles['modal-body']}>
<InfiniteScrollTable
tableColumns={columns}
tableData={props?.authors || []}
className={styles['author-listing']}
/>
</ModalBody>
</Modal>
);
};

export default DataFilesPublicationAuthorsModal;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.author-listing {
/* title */
th:nth-child(1),
td:nth-child(1) {
width: 50%;
}
/* date */
th:nth-child(2),
td:nth-child(2) {
width: 50%;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,23 @@ const DataFilesPublicationRequestModal = () => {
const { publicationRequests } =
useSelector((state) => state.files.modalProps.publicationRequest) || [];

const compareFn = (req1, req2) => {
// sort more recent requests first
const date1 = new Date(req1.created_at);
const date2 = new Date(req2.created_at);
if (date1 < date2) {
return 1;
}
if (date1 > date2) {
return -1;
}
return 0;
};

useEffect(() => {
const data = {};

publicationRequests?.forEach((request, index) => {
publicationRequests?.sort(compareFn).forEach((request, index) => {
const publicationRequestDataObj = {
Status: request.status,
Reviewers: request.reviewers.reduce((acc, reviewer, index) => {
Expand All @@ -27,6 +40,7 @@ const DataFilesPublicationRequestModal = () => {
);
}, ''),
Submitted: formatDateTime(new Date(request.created_at)),
_order: index,
};

const heading = `Publication Request ${index + 1}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useSelector, useDispatch, shallowEqual } from 'react-redux';
import { Modal, ModalHeader, ModalBody } from 'reactstrap';
import { TextCopyField } from '_common';
import styles from './DataFilesShowPathModal.module.scss';
import { useSystems } from 'hooks/datafiles';

const DataFilesShowPathModal = React.memo(() => {
const dispatch = useDispatch();
Expand All @@ -27,8 +28,14 @@ const DataFilesShowPathModal = React.memo(() => {
}
}, [modalParams, dispatch]);

const { isRootProjectSystem } = useSystems();

useEffect(() => {
if (params.api === 'tapis' && params.system) {
if (
params.api === 'tapis' &&
params.system &&
!isRootProjectSystem({ system: params.system })
) {
dispatch({
type: 'FETCH_SYSTEM_DEFINITION',
payload: params.system,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import {
SectionMessage,
SectionTableWrapper,
} from '_common';
import { useAddonComponents, useFileListing } from 'hooks/datafiles';
import {
useAddonComponents,
useFileListing,
useSystems,
} from 'hooks/datafiles';
import DataFilesListing from '../DataFilesListing/DataFilesListing';
import styles from './DataFilesProjectFileListing.module.scss';

const DataFilesProjectFileListing = ({ rootSystem, system, path }) => {
const dispatch = useDispatch();
const { fetchListing } = useFileListing('FilesListing');
const systems = useSelector(
(state) => state.systems.storage.configuration.filter((s) => !s.hidden),
shallowEqual
);
const [isPublicationSystem, setIsPublicationSystem] = useState(false);
const { isPublicationSystem, isReviewSystem } = useSystems();

// logic to render addonComponents for DRP
const portalName = useSelector((state) => state.workbench.portalName);
Expand All @@ -44,11 +44,6 @@ const DataFilesProjectFileListing = ({ rootSystem, system, path }) => {
fetchListing({ api: 'tapis', scheme: 'projects', system, path });
}, [system, path, fetchListing]);

useEffect(() => {
const system = systems.find((s) => s.system === rootSystem);
setIsPublicationSystem(system?.publicationProject);
}, [systems, rootSystem]);

const metadata = useSelector((state) => state.projects.metadata);
const folderMetadata = useSelector(
(state) => state.files.folderMetadata?.FilesListing
Expand Down Expand Up @@ -130,14 +125,16 @@ const DataFilesProjectFileListing = ({ rootSystem, system, path }) => {
{canEditSystem ? (
<>
<Button type="link" onClick={onEdit}>
Edit Project
Edit Dataset
</Button>
<span className={styles.separator}>|</span>
</>
) : null}
<Button type="link" onClick={onManage}>
{readOnlyTeam ? 'View' : 'Manage'} Team
</Button>
{!isPublicationSystem(rootSystem) && !isReviewSystem(rootSystem) && (
<Button type="link" onClick={onManage}>
{readOnlyTeam ? 'View' : 'Manage'} Team
</Button>
)}
{DataFilesProjectFileListingAddon && (
<DataFilesProjectFileListingAddon
rootSystem={rootSystem}
Expand All @@ -162,7 +159,7 @@ const DataFilesProjectFileListing = ({ rootSystem, system, path }) => {
folderMetadata={folderMetadata}
metadata={metadata}
path={path}
showCitation={isPublicationSystem}
showCitation={isPublicationSystem(rootSystem)}
/>
</ShowMore>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const DataFilesPublicationsList = ({ rootSystem }) => {
type: 'PUBLICATIONS_GET_PUBLICATIONS',
payload: {
queryString: query.query_string,
system: selectedSystem.system,
},
});
}, [dispatch, query.query_string]);
Expand Down
Loading

0 comments on commit 117b4f9

Please sign in to comment.