Skip to content

Commit

Permalink
refact: remove mentions of tables
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Aug 21, 2023
1 parent 38ab0cd commit e3c7ddd
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 328 deletions.
1 change: 0 additions & 1 deletion src/components/ServiceContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const ServiceContent = () => {
/>
</Spin>
</Col>
{/* TODO: Tables */}
</Row>
<Typography.Title level={3}>Services</Typography.Title>
<ServiceList />
Expand Down
3 changes: 0 additions & 3 deletions src/components/datasets/Dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class Dataset extends Component {
contact_info: value.contact_info || "",
data_use: simpleDeepCopy(value.data_use || INITIAL_DATA_USE_VALUE),
linked_field_sets: value.linked_field_sets || [],
tables: value.tables || [],

fieldSetAdditionModalVisible: false,

Expand All @@ -87,7 +86,6 @@ class Dataset extends Component {
},

selectedTab: "overview",
selectedTable: null,
};

this.handleFieldSetDeletion = this.handleFieldSetDeletion.bind(this);
Expand Down Expand Up @@ -294,7 +292,6 @@ Dataset.propTypes = {
mode: PropTypes.oneOf(["public", "private"]),

project: projectPropTypesShape,
strayTables: PropTypes.arrayOf(PropTypes.object),

value: datasetPropTypesShape,

Expand Down
20 changes: 10 additions & 10 deletions src/components/manager/ManagerDropBoxContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ const ManagerDropBoxContent = () => {
const [fileDeleteModal, setFileDeleteModal] = useState(false);

const [selectedWorkflow, setSelectedWorkflow] = useState(null);
const [tableSelectionModal, setTableSelectionModal] = useState(false);
const [datasetSelectionModal, setDatasetSelectionModal] = useState(false);

const showUploadModal = useCallback(() => setUploadModal(true), []);
const hideUploadModal = useCallback(() => setUploadModal(false), []);
Expand All @@ -468,11 +468,11 @@ const ManagerDropBoxContent = () => {
const showFileContentsModal = useCallback(() => setFileContentsModal(true), []);
const hideFileContentsModal = useCallback(() => setFileContentsModal(false), []);

const showTableSelectionModal = useCallback(workflow => {
const showDatasetSelectionModal = useCallback(workflow => {
setSelectedWorkflow(workflow);
setTableSelectionModal(true);
setDatasetSelectionModal(true);
}, []);
const hideTableSelectionModal = useCallback(() => setTableSelectionModal(false), []);
const hideDatasetSelectionModal = useCallback(() => setDatasetSelectionModal(false), []);

const getWorkflowFit = useCallback(w => {
let workflowSupported = true;
Expand All @@ -482,7 +482,7 @@ const ManagerDropBoxContent = () => {
for (const i of w.inputs.filter(i => i.type.startsWith("file"))) {
const isFileArray = i.type.endsWith("[]");

// Find tables that support the data type
// Find datasets that support the data type
// TODO

// Find files where 1+ of the valid extensions (e.g. jpeg or jpg) match.
Expand Down Expand Up @@ -535,7 +535,7 @@ const ManagerDropBoxContent = () => {
{ingestionWorkflows.map(w => (
<Menu.Item key={w.id}
disabled={workflowsSupported.findIndex(w2 => w2.id === w.id) === -1}
onClick={() => showTableSelectionModal(w)}>
onClick={() => showDatasetSelectionModal(w)}>
Ingest with Workflow &ldquo;{w.name}&rdquo;
</Menu.Item>
))}
Expand All @@ -544,7 +544,7 @@ const ManagerDropBoxContent = () => {

const handleIngest = useCallback(() => {
if (workflowsSupported.length !== 1) return;
showTableSelectionModal(workflowsSupported[0]);
showDatasetSelectionModal(workflowsSupported[0]);
}, [workflowsSupported]);

const hasUploadPermission = permissions.includes(ingestDropBox);
Expand Down Expand Up @@ -647,9 +647,9 @@ const ManagerDropBoxContent = () => {

<DatasetSelectionModal
dataType={selectedWorkflow?.data_type || null}
visible={tableSelectionModal}
title="Select a Table to Ingest Into"
onCancel={hideTableSelectionModal}
visible={datasetSelectionModal}
title="Select a Dataset to Ingest Into"
onCancel={hideDatasetSelectionModal}
onOk={ingestIntoDataset}
/>

Expand Down
2 changes: 0 additions & 2 deletions src/components/manager/projects/Project.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,6 @@ class Project extends Component {

Project.propTypes = {
value: projectPropTypesShape,
tables: PropTypes.arrayOf(PropTypes.object), // TODO: shape
strayTables: PropTypes.arrayOf(PropTypes.object), // TODO: shape (this is currently heterogeneous)

editing: PropTypes.bool,
saving: PropTypes.bool,
Expand Down
36 changes: 10 additions & 26 deletions src/components/manager/projects/RoutedProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class RoutedProject extends Component {
this.showDatasetAdditionModal = this.showDatasetAdditionModal.bind(this);
this.hideDatasetAdditionModal = this.hideDatasetAdditionModal.bind(this);
this.hideDatasetEditModal = this.hideDatasetEditModal.bind(this);
this.ingestIntoTable = this.ingestIntoDataset.bind(this);
this.ingestIntoDataset = this.ingestIntoDataset.bind(this);
this.handleDeleteProject = this.handleDeleteProject.bind(this);
}

Expand All @@ -41,13 +41,16 @@ class RoutedProject extends Component {
}

ingestIntoDataset(p, d, dt) {
this.props.history.push("/admin/data/manager/ingestion",
{workflowSelectionValues: {
selectedProject: p.identifier,
selectedDataset: d.identifier,
selectedDataType: dt.id,
this.props.history.push(
"/admin/data/manager/ingestion",
{
workflowSelectionValues: {
selectedProject: p.identifier,
selectedDataset: d.identifier,
selectedDataType: dt.id,
},
},
});
);
}

handleProjectSave(project) {
Expand Down Expand Up @@ -101,16 +104,6 @@ class RoutedProject extends Component {
const project = this.props.projectsByID[this.props.match.params.project];
if (!project) return <ProjectSkeleton />;

/**
* @typedef {Object} ProjectTable
* @property {string} table_id
* @property {string} service_id
* @property {string} dataset
* @property {string} data_type
* @property {string} sample
* @type {ProjectTable[]}
*/

return <>
<DatasetFormModal mode={FORM_MODE_ADD}
project={project}
Expand Down Expand Up @@ -163,15 +156,9 @@ RoutedProject.propTypes = {
isFetching: PropTypes.bool,
})),

serviceTables: PropTypes.arrayOf(PropTypes.object), // TODO: Shape
serviceTablesByServiceID: PropTypes.objectOf(PropTypes.object), // TODO: Shape

projects: PropTypes.arrayOf(projectPropTypesShape),
projectsByID: PropTypes.objectOf(projectPropTypesShape),

projectTables: PropTypes.arrayOf(PropTypes.object), // TODO: Shape
projectTablesByProjectID: PropTypes.objectOf(PropTypes.arrayOf(PropTypes.object)), // TODO: Shape

loadingProjects: PropTypes.bool,

isDeletingProject: PropTypes.bool,
Expand All @@ -193,9 +180,6 @@ const mapStateToProps = state => ({

serviceDataTypesByServiceID: state.serviceDataTypes.dataTypesByServiceID,

serviceTables: state.serviceTables.items,
serviceTablesByServiceID: state.serviceTables.itemsByServiceID,

projects: state.projects.items,
projectsByID: state.projects.itemsByID,

Expand Down
1 change: 0 additions & 1 deletion src/modules/auth/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export const fetchUserDependentData = (servicesCb) => async (dispatch, getState)
try {
if (idTokenContents) {
// If we're newly authenticated as an owner, we run all actions that need authentication (via the callback).
// TODO: refactor to remove tables
await dispatch(fetchServicesWithMetadataAndDataTypesIfNeeded(
() => dispatch(fetchServiceDependentData())));
await (servicesCb || nop)();
Expand Down
7 changes: 0 additions & 7 deletions src/modules/metadata/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {jsonRequest} from "../../utils/requests";


export const FETCH_PROJECTS = createNetworkActionTypes("FETCH_PROJECTS");
export const FETCH_PROJECT_TABLES = createNetworkActionTypes("FETCH_PROJECT_TABLES");

export const CREATE_PROJECT = createNetworkActionTypes("CREATE_PROJECT");
export const DELETE_PROJECT = createNetworkActionTypes("DELETE_PROJECT");
Expand All @@ -27,9 +26,6 @@ export const ADD_DATASET_LINKED_FIELD_SET = createNetworkActionTypes("ADD_DATASE
export const SAVE_DATASET_LINKED_FIELD_SET = createNetworkActionTypes("SAVE_DATASET_LINKED_FIELD_SET");
export const DELETE_DATASET_LINKED_FIELD_SET = createNetworkActionTypes("DELETE_DATASET_LINKED_FIELD_SET");

export const PROJECT_TABLE_ADDITION = createFlowActionTypes("PROJECT_TABLE_ADDITION");
export const PROJECT_TABLE_DELETION = createFlowActionTypes("PROJECT_TABLE_DELETION");

export const FETCH_INDIVIDUAL = createNetworkActionTypes("FETCH_INDIVIDUAL");
export const FETCH_OVERVIEW_SUMMARY = createNetworkActionTypes("FETCH_OVERVIEW_SUMMARY");

Expand Down Expand Up @@ -121,8 +117,6 @@ export const deleteProject = networkAction(project => (dispatch, getState) => ({
export const deleteProjectIfPossible = project => (dispatch, getState) => {
if (getState().projects.isDeleting) return;
return dispatch(deleteProject(project));

// TODO: Do we need to delete project tables as well? What to do here??
};


Expand Down Expand Up @@ -174,7 +168,6 @@ export const deleteProjectDataset = networkAction((project, dataset) => (dispatc
url: `${getState().services.metadataService.url}/api/datasets/${dataset.identifier}`,
req: {method: "DELETE"},
err: `Error deleting dataset '${dataset.title}'`,
// TODO: Do we need to delete project tables as well? What to do here??
}));

export const deleteProjectDatasetIfPossible = (project, dataset) => (dispatch, getState) => {
Expand Down
108 changes: 0 additions & 108 deletions src/modules/metadata/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {objectWithoutProp} from "../../utils/misc";

import {
FETCH_PROJECTS,
FETCH_PROJECT_TABLES,

CREATE_PROJECT,
DELETE_PROJECT,
Expand All @@ -16,9 +15,6 @@ import {
SAVE_DATASET_LINKED_FIELD_SET,
DELETE_DATASET_LINKED_FIELD_SET,

PROJECT_TABLE_ADDITION,
PROJECT_TABLE_DELETION,

FETCH_INDIVIDUAL,

FETCH_OVERVIEW_SUMMARY,
Expand All @@ -33,7 +29,6 @@ const projectSort = (a, b) => a.title.localeCompare(b.title);
export const projects = (
state = {
isFetching: false,
isFetchingWithTables: false,
isCreating: false,
isDeleting: false,
isSaving: false,
Expand Down Expand Up @@ -249,109 +244,6 @@ export const projects = (
};


export const projectTables = (
state = {
isFetching: false,
isFetchingAll: false,
isAdding: false,
isDeleting: false,
items: [],
itemsByProjectID: {},
},
action,
) => {
switch (action.type) {
case CREATE_PROJECT.RECEIVE:
// TODO: Might want to re-fetch upon project creation instead...
return {
...state,
itemsByProjectID: {
...state.itemsByProjectID,
[action.data.id]: [],
},
};

case DELETE_PROJECT.RECEIVE:
return {
...state,
items: state.items.filter(t => t.project_id !== action.project.identifier),
itemsByProjectID: objectWithoutProp(state.itemsByProjectID, action.project.identifier),
};

case FETCH_PROJECT_TABLES.REQUEST:
return {...state, isFetching: true};

case FETCH_PROJECT_TABLES.RECEIVE:
return {
...state,
isFetching: false,
items: [
...state.items,
...action.data
.map(t => ({
...t,
project_id: (Object.entries(action.projectsByID)
.filter(([_, project]) => project.datasets.map(d => d.identifier)
.includes(t.dataset))[0] || [])[0] || null,
}))
.filter(t => t.project_id !== null && !state.items.map(t => t.table_id).includes(t.table_id)),
],
itemsByProjectID: { // TODO: Improve performance by maybe returning project ID on server side?
...state.itemsByProjectID,
...Object.fromEntries(Object.entries(action.projectsByID).map(([projectID, project]) =>
[projectID, action.data.filter(t => project.datasets
.map(d => d.identifier)
.includes(t.dataset))],
)),
},
};

case FETCH_PROJECT_TABLES.FINISH:
return {...state, isFetching: false};

case PROJECT_TABLE_ADDITION.BEGIN:
return {...state, isAdding: true};

case PROJECT_TABLE_ADDITION.END:
// TODO
return {
...state,
isAdding: false,
items: [...state.items, action.table],
itemsByProjectID: {
...state.itemsByProjectID,
[action.project.identifier]: [...(state.itemsByProjectID[action.project.identifier] || []),
action.table],
},
};

case PROJECT_TABLE_ADDITION.TERMINATE:
return {...state, isAdding: false};

case PROJECT_TABLE_DELETION.BEGIN:
return {...state, isDeleting: true};

case PROJECT_TABLE_DELETION.END:
return {
...state,
isDeleting: false,
items: state.items.filter(t => t.table_id !== action.tableID),
itemsByProjectID: {
...state.itemsByProjectID,
[action.project.identifier]: (state.itemsByProjectID[action.project.identifier] || [])
.filter(t => t.id !== action.tableID),
},
};

case PROJECT_TABLE_DELETION.TERMINATE:
return {...state, isDeleting: false};

default:
return state;
}
};


export const biosamples = (
state = {
itemsByID: {},
Expand Down
Loading

0 comments on commit e3c7ddd

Please sign in to comment.