Skip to content

Commit

Permalink
DCJ-542: Fully deprecate old dataset registration page (#2635)
Browse files Browse the repository at this point in the history
  • Loading branch information
rushtong authored Jul 30, 2024
1 parent d08051f commit bdfd380
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1,504 deletions.
3 changes: 0 additions & 3 deletions src/Routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import ManageEditDac from './pages/manage_dac/ManageEditDac';
import AdminManageUsers from './pages/AdminManageUsers';
import DataAccessRequestApplication from './pages/dar_application/DataAccessRequestApplication';
import DACDatasets from './pages/DACDatasets';
import DatasetRegistration from './pages/DatasetRegistration';
import Home from './pages/Home';
import NotFound from './pages/NotFound';
import NIHICWebform from './pages/NIHicWebform';
Expand Down Expand Up @@ -94,9 +93,7 @@ const Routes = (props) => (
<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, false, 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]} />
<AuthenticatedRoute path="/data_submission_form" component={DataSubmissionForm} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.chairperson, USER_ROLES.dataSubmitter]} />
<AuthenticatedRoute path="/study_update/:studyId" component={StudyUpdateForm} props={props} rolesAllowed={[USER_ROLES.admin, USER_ROLES.chairperson, USER_ROLES.dataSubmitter]} />
<AuthenticatedRoute path="/admin_manage_lc/" component={AdminManageLC} props={props} rolesAllowed={[USER_ROLES.admin]} />
Expand Down
14 changes: 8 additions & 6 deletions src/components/dac_dataset_table/DACDatasetApprovalStatus.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ export default function DACDatasetApprovalStatus(props) {

const dacAccepted = (dataset) => <div style={{color: '#1ea371', fontWeight: 'bold'}}>
<span>ACCEPTED</span>
<Link
style={{marginLeft: '15px'}}
id={`${dataset.dataSetId}_edit`}
className={'glyphicon glyphicon-pencil'}
to={dataset.study?.studyId === undefined ? `dataset_registration/${dataset.dataSetId}` : `study_update/${dataset.study.studyId}`}
/>
{dataset.study?.studyId &&
<Link
style={{marginLeft: '15px'}}
id={`${dataset.dataSetId}_edit`}
className={'glyphicon glyphicon-pencil'}
to={`study_update/${dataset.study.studyId}`}
/>
}
{dataset.deletable &&
<>
<Link
Expand Down
49 changes: 1 addition & 48 deletions src/libs/ajax/DataSet.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as fp from 'lodash/fp';
import { Config } from '../config';
import axios from 'axios';
import { getApiUrl, fetchOk, getFileNameFromHttpResponse, fetchAny } from '../ajax';
import { getApiUrl, fetchOk } from '../ajax';


export const DataSet = {
Expand All @@ -17,24 +17,12 @@ export const DataSet = {
return await res.data;
},

postDatasetForm: async (form) => {
const url = `${await getApiUrl()}/api/dataset/v2`;
const res = await fetchOk(url, fp.mergeAll([Config.authOpts(), Config.jsonBody(form), { method: 'POST' }]));
return await res.json();
},

registerDataset: async (registration) => {
const url = `${await getApiUrl()}/api/dataset/v3`;
const res = await axios.post(url, registration, Config.multiPartOpts());
return res.data;
},

getDatasets: async () => {
const url = `${await getApiUrl()}/api/dataset/v2`;
const res = await fetchOk(url, Config.authOpts());
return await res.json();
},

getDatasetsByIds: async (ids) => {
const url = `${await getApiUrl()}/api/dataset/batch?ids=${ids.join('&ids=')}`;
const res = await fetchOk(url, Config.authOpts());
Expand All @@ -59,53 +47,18 @@ export const DataSet = {
return await res.json();
},

downloadDataSets: async (objectIdList, fileName) => {
const url = `${await getApiUrl()}/api/dataset/download`;
const res = await fetchOk(url, fp.mergeAll([Config.jsonBody(objectIdList), Config.fileOpts(), { method: 'POST' }]));

fileName = fileName === null ? getFileNameFromHttpResponse(res) : fileName;
const responseObj = await res.json();

let blob = new Blob([responseObj.datasets], { type: 'text/plain' });
const urlBlob = window.URL.createObjectURL(blob);
let a = document.createElement('a');
a.href = urlBlob;
a.download = fileName;
a.click();
},

deleteDataset: async (datasetObjectId) => {
const url = `${await getApiUrl()}/api/dataset/${datasetObjectId}`;
const res = await fetchOk(url, fp.mergeAll([Config.authOpts(), { method: 'DELETE' }]));
return await res;
},

updateDataset: async (datasetId, dataSetObject) => {
const url = `${await getApiUrl()}/api/dataset/${datasetId}`;
return await fetchOk(url, fp.mergeAll([Config.authOpts(), Config.jsonBody(dataSetObject), { method: 'PUT' }]));
},

updateDatasetV3: async (datasetId, datasetAndFiles) => {
const url = `${await getApiUrl()}/api/dataset/v3/${datasetId}`;
const res = await axios.put(url, datasetAndFiles, Config.multiPartOpts());
return res.data;
},

validateDatasetName: async (name) => {
const url = `${await getApiUrl()}/api/dataset/validate?name=${name}`;
try {
// We expect a 404 in the case where the dataset name does not exist
const res = await fetchAny(url, fp.mergeAll([Config.authOpts(), { method: 'GET' }]));
if (res.status === 404) {
return -1;
}
return await res.json();
}
catch (err) {
return -1;
}
},

getStudyById: async (studyId) => {
const url = `${await getApiUrl()}/api/dataset/study/${studyId}`;
const res = await fetchOk(url, Config.authOpts());
Expand Down
Loading

0 comments on commit bdfd380

Please sign in to comment.