Skip to content

Commit

Permalink
[DUOS-2641][risk=no] Submitted Datasets Subtab (#2322)
Browse files Browse the repository at this point in the history
* data submitter sub nav in researcher console
  • Loading branch information
rushtong authored Sep 19, 2023
1 parent 277f58d commit 57bd68d
Show file tree
Hide file tree
Showing 8 changed files with 449 additions and 101 deletions.
4 changes: 3 additions & 1 deletion src/Routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Home from './pages/Home';
import NotFound from './pages/NotFound';
import NIHICWebform from './pages/NIHicWebform';
import PrivacyPolicy from './pages/PrivacyPolicy';
import ResearcherConsole from './pages/ResearcherConsole';
import ResearcherConsole from './pages/researcher_console/ResearcherConsole';
import UserProfile from './pages/user_profile/UserProfile';
import RequestRole from './pages/user_profile/RequestRole';
import SigningOfficialResearchers from './pages/signing_official_console/SigningOfficialResearchers';
Expand All @@ -33,6 +33,7 @@ import AdminManageDarCollections from './pages/AdminManageDarCollections';
import {AdminEditUser} from './pages/AdminEditUser';
import ChairConsole from './pages/ChairConsole';
import MemberConsole from './pages/MemberConsole';
import DatasetSubmissions from './pages/researcher_console/DatasetSubmissions';
import TermsOfService from './pages/TermsOfService';
import TermsOfServiceAcceptance from './pages/TermsOfServiceAcceptance';
import {HealthCheck} from './pages/HealthCheck';
Expand Down Expand Up @@ -87,6 +88,7 @@ const Routes = (props) => (
<AuthenticatedRoute path="/signing_official_console/researchers" component={ensureSoHasDaaAcknowledgement(SigningOfficialResearchers)} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.signingOfficial]} />
<AuthenticatedRoute path="/signing_official_console/dar_requests" component={ensureSoHasDaaAcknowledgement(SigningOfficialDarRequests)} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.signingOfficial]} />
{checkEnv(envGroups.NON_STAGING) && <AuthenticatedRoute path="/signing_official_console/data_submitters" component={ensureSoHasDaaAcknowledgement(SigningOfficialDataSubmitters, true)} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.signingOfficial]} />}
<AuthenticatedRoute path="/dataset_submissions" component={DatasetSubmissions} props={props} rolesAllowed={[USER_ROLES.dataSubmitter]}/>
<AuthenticatedRoute path="/dataset_registration/:datasetId" component={DatasetRegistration} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.chairperson]} />
<AuthenticatedRoute path="/dataset_update/:datasetId" component={DatasetUpdateForm} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.chairperson]} />
<AuthenticatedRoute path="/dataset_registration" component={DatasetRegistration} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.chairperson]} />
Expand Down
17 changes: 6 additions & 11 deletions src/components/DuosHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,22 +125,14 @@ export const headerTabsConfig = [
],
isRendered: (user) => user.isMember
},
{
label: 'DS Console',
link: '/data_submission_form',
search: 'data_submission_form',
children: [
{ label: 'Datasets', link: '/data_submission_form' }
],
isRendered: (user) => user.isDataSubmitter
},
{
label: 'Researcher Console',
link: '/dataset_catalog',
search: 'dataset_catalog',
children: [
{ label: 'Data Catalog', link: '/dataset_catalog' },
{ label: 'DAR Requests', link: '/researcher_console' }
{ label: 'DAR Requests', link: '/researcher_console' },
{ label: 'Submitted Datasets', link: '/dataset_submissions', isRenderedForUser: (user) => user?.isDataSubmitter }
],
isRendered: (user) => user.isResearcher && !isOnlySigningOfficial(user)
}
Expand Down Expand Up @@ -321,7 +313,10 @@ const NavigationTabsComponent = (props) => {
const isRendered = (!isFunction(tab.isRendered) || isNil(tab.isRendered())) ?
true :
tab.isRendered();
return isRendered ? h(Tab, {
const isRenderedForUser = (!isFunction(tab.isRenderedForUser) || isNil(tab.isRenderedForUser(currentUser))) ?
true :
tab.isRenderedForUser(currentUser);
return (isRendered && isRenderedForUser) ? h(Tab, {
key: `${tab.link}_${tabIndex}`,
label: tab.label,
style: selectedSubTab === tabIndex ? styles.subTabActive : styles.subTab,
Expand Down
20 changes: 11 additions & 9 deletions src/components/sortable_table/SortableTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Step 3: Pass both arrays into the headCells and rows props
*/

import React from 'react';
import React, {useState, useMemo} from 'react';
import Box from '@mui/material/Box';
import Table from '@mui/material/Table';
import TableBody from '@mui/material/TableBody';
Expand Down Expand Up @@ -84,14 +84,16 @@ export default function SortableTable(props) {

const {
rows,
headCells
headCells,
defaultSort = 'darCode',
cellAlignment = 'center'
} = props;

const [order, setOrder] = React.useState('asc');
const [orderBy, setOrderBy] = React.useState('darCode');
const [selected, setSelected] = React.useState([]);
const [page, setPage] = React.useState(0);
const [rowsPerPage, setRowsPerPage] = React.useState(10);
const [order, setOrder] = useState('asc');
const [orderBy, setOrderBy] = useState(defaultSort);
const [selected, setSelected] = useState([]);
const [page, setPage] = useState(0);
const [rowsPerPage, setRowsPerPage] = useState(10);

const handleRequestSort = (event, property) => {
const isAsc = orderBy === property && order === 'asc';
Expand Down Expand Up @@ -135,7 +137,7 @@ export default function SortableTable(props) {
const emptyRows =
page > 0 ? Math.max(0, (1 + page) * rowsPerPage - rows.length) : 0;

const visibleRows = React.useMemo(
const visibleRows = useMemo(
() =>
stableSort(rows, getComparator(order, orderBy)).slice(
page * rowsPerPage,
Expand Down Expand Up @@ -187,7 +189,7 @@ export default function SortableTable(props) {
id={labelId}
scope='row'
padding='none'
align='center'>
align={cellAlignment}>
{row[category]}
</TableCell>
))}
Expand Down
Loading

0 comments on commit 57bd68d

Please sign in to comment.