From e3c7dddf0d7f690db45c0debb1d4e9ba3d54c630 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Mon, 21 Aug 2023 14:47:33 -0400 Subject: [PATCH] refact: remove mentions of tables --- src/components/ServiceContent.js | 1 - src/components/datasets/Dataset.js | 3 - .../manager/ManagerDropBoxContent.js | 20 +-- src/components/manager/projects/Project.js | 2 - .../manager/projects/RoutedProject.js | 36 ++--- src/modules/auth/actions.js | 1 - src/modules/metadata/actions.js | 7 - src/modules/metadata/reducers.js | 108 -------------- src/modules/services/actions.js | 27 ---- src/modules/services/reducers.js | 140 ------------------ src/propTypes.js | 1 - src/reducers.js | 2 - 12 files changed, 20 insertions(+), 328 deletions(-) diff --git a/src/components/ServiceContent.js b/src/components/ServiceContent.js index 381173995..30d365aea 100644 --- a/src/components/ServiceContent.js +++ b/src/components/ServiceContent.js @@ -40,7 +40,6 @@ const ServiceContent = () => { /> - {/* TODO: Tables */} Services diff --git a/src/components/datasets/Dataset.js b/src/components/datasets/Dataset.js index f48925b98..da8ce9976 100644 --- a/src/components/datasets/Dataset.js +++ b/src/components/datasets/Dataset.js @@ -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, @@ -87,7 +86,6 @@ class Dataset extends Component { }, selectedTab: "overview", - selectedTable: null, }; this.handleFieldSetDeletion = this.handleFieldSetDeletion.bind(this); @@ -294,7 +292,6 @@ Dataset.propTypes = { mode: PropTypes.oneOf(["public", "private"]), project: projectPropTypesShape, - strayTables: PropTypes.arrayOf(PropTypes.object), value: datasetPropTypesShape, diff --git a/src/components/manager/ManagerDropBoxContent.js b/src/components/manager/ManagerDropBoxContent.js index 8d08f6aa5..9807640db 100644 --- a/src/components/manager/ManagerDropBoxContent.js +++ b/src/components/manager/ManagerDropBoxContent.js @@ -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), []); @@ -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; @@ -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. @@ -535,7 +535,7 @@ const ManagerDropBoxContent = () => { {ingestionWorkflows.map(w => ( w2.id === w.id) === -1} - onClick={() => showTableSelectionModal(w)}> + onClick={() => showDatasetSelectionModal(w)}> Ingest with Workflow “{w.name}” ))} @@ -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); @@ -647,9 +647,9 @@ const ManagerDropBoxContent = () => { diff --git a/src/components/manager/projects/Project.js b/src/components/manager/projects/Project.js index 64d222603..ed1cfcddb 100644 --- a/src/components/manager/projects/Project.js +++ b/src/components/manager/projects/Project.js @@ -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, diff --git a/src/components/manager/projects/RoutedProject.js b/src/components/manager/projects/RoutedProject.js index 2dc256e5a..22a2536ab 100644 --- a/src/components/manager/projects/RoutedProject.js +++ b/src/components/manager/projects/RoutedProject.js @@ -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); } @@ -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) { @@ -101,16 +104,6 @@ class RoutedProject extends Component { const project = this.props.projectsByID[this.props.match.params.project]; if (!project) return ; - /** - * @typedef {Object} ProjectTable - * @property {string} table_id - * @property {string} service_id - * @property {string} dataset - * @property {string} data_type - * @property {string} sample - * @type {ProjectTable[]} - */ - return <> ({ serviceDataTypesByServiceID: state.serviceDataTypes.dataTypesByServiceID, - serviceTables: state.serviceTables.items, - serviceTablesByServiceID: state.serviceTables.itemsByServiceID, - projects: state.projects.items, projectsByID: state.projects.itemsByID, diff --git a/src/modules/auth/actions.js b/src/modules/auth/actions.js index bd5a8c9f0..c954f8256 100644 --- a/src/modules/auth/actions.js +++ b/src/modules/auth/actions.js @@ -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)(); diff --git a/src/modules/metadata/actions.js b/src/modules/metadata/actions.js index 8ba0e83e0..43602e8fb 100644 --- a/src/modules/metadata/actions.js +++ b/src/modules/metadata/actions.js @@ -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"); @@ -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"); @@ -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?? }; @@ -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) => { diff --git a/src/modules/metadata/reducers.js b/src/modules/metadata/reducers.js index bf5e8004c..6f012a102 100644 --- a/src/modules/metadata/reducers.js +++ b/src/modules/metadata/reducers.js @@ -2,7 +2,6 @@ import {objectWithoutProp} from "../../utils/misc"; import { FETCH_PROJECTS, - FETCH_PROJECT_TABLES, CREATE_PROJECT, DELETE_PROJECT, @@ -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, @@ -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, @@ -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: {}, diff --git a/src/modules/services/actions.js b/src/modules/services/actions.js index 24902062e..038c4d3cd 100644 --- a/src/modules/services/actions.js +++ b/src/modules/services/actions.js @@ -15,7 +15,6 @@ import { * @property {string} artifact * @property {string} url * @property {boolean} data_service - * @property {?boolean} manageable_tables */ @@ -27,35 +26,10 @@ export const FETCH_SERVICES = createNetworkActionTypes("FETCH_SERVICES"); export const FETCH_SERVICE_DATA_TYPES = createNetworkActionTypes("FETCH_SERVICE_DATA_TYPES"); export const LOADING_SERVICE_DATA_TYPES = createFlowActionTypes("LOADING_SERVICE_DATA_TYPES"); -export const FETCH_SERVICE_TABLES = createNetworkActionTypes("FETCH_SERVICE_TABLES"); -export const LOADING_SERVICE_TABLES = createFlowActionTypes("LOADING_SERVICE_TABLES"); - -export const FETCH_SERVICE_DATASETS = createNetworkActionTypes("FETCH_SERVICE_DATASETS"); -export const LOADING_SERVICE_DATASETS = createFlowActionTypes("LOADING_SERVICE_DATASETS"); - -export const ADDING_SERVICE_TABLE = createFlowActionTypes("ADDING_SERVICE_TABLE"); -export const DELETING_SERVICE_TABLE = createFlowActionTypes("DELETING_SERVICE_TABLE"); - export const FETCH_SERVICE_WORKFLOWS = createNetworkActionTypes("FETCH_SERVICE_WORKFLOWS"); export const LOADING_SERVICE_WORKFLOWS = createFlowActionTypes("LOADING_SERVICE_WORKFLOWS"); -export const endAddingServiceTable = (serviceInfo, dataTypeID, table) => ({ - type: ADDING_SERVICE_TABLE.END, - serviceInfo, - dataTypeID, - table, -}); - - -export const endDeletingServiceTable = (serviceInfo, dataTypeID, tableID) => ({ - type: DELETING_SERVICE_TABLE.END, - serviceInfo, - dataTypeID, - tableID, -}); - - export const fetchBentoServices = networkAction(() => ({ types: FETCH_BENTO_SERVICES, url: `${BENTO_PUBLIC_URL}/api/service-registry/bento-services`, @@ -82,7 +56,6 @@ export const fetchDataServiceWorkflows = networkAction((serviceInfo) => ({ })); -// TODO: remove tables export const fetchServicesWithMetadataAndDataTypes = (onServiceFetchFinish) => async (dispatch, getState) => { dispatch(beginFlow(LOADING_ALL_SERVICE_DATA)); diff --git a/src/modules/services/reducers.js b/src/modules/services/reducers.js index 7198ce73c..ed1f7c810 100644 --- a/src/modules/services/reducers.js +++ b/src/modules/services/reducers.js @@ -1,5 +1,3 @@ -import {objectWithoutProp} from "../../utils/misc"; - import { LOADING_ALL_SERVICE_DATA, @@ -9,12 +7,6 @@ import { FETCH_SERVICE_DATA_TYPES, LOADING_SERVICE_DATA_TYPES, - FETCH_SERVICE_TABLES, - LOADING_SERVICE_TABLES, - - ADDING_SERVICE_TABLE, - DELETING_SERVICE_TABLE, - FETCH_SERVICE_WORKFLOWS, LOADING_SERVICE_WORKFLOWS, } from "./actions"; @@ -241,138 +233,6 @@ export const serviceDataTypes = ( } }; -export const serviceTables = ( - state = { - isFetchingAll: false, - isCreating: false, - isDeleting: false, - items: [], - itemsByServiceID: {}, - }, - action, -) => { - switch (action.type) { - case LOADING_SERVICE_TABLES.BEGIN: - return {...state, isFetchingAll: true}; - - case LOADING_SERVICE_TABLES.END: - case LOADING_SERVICE_TABLES.TERMINATE: - return {...state, isFetchingAll: false}; - - case FETCH_SERVICE_TABLES.REQUEST: { - const {serviceInfo} = action; - return { - ...state, - itemsByServiceID: { - ...state.itemsByServiceID, - [serviceInfo.id]: { - ...(state.itemsByServiceID[serviceInfo.id] ?? {}), - isFetching: true, - }, - }, - }; - } - - case FETCH_SERVICE_TABLES.RECEIVE: { - const {serviceInfo: {id: serviceID}, data, dataTypeID} = action; - - const newTables = data.map(t => ({ - ...t, - service_id: serviceID, - data_type: dataTypeID, - })).filter(t => - !(state.itemsByServiceID[serviceID]?.tablesByID ?? {}).hasOwnProperty(t.id)); - - return { - ...state, - items: [...state.items, ...newTables], - itemsByServiceID: { - ...state.itemsByServiceID, - [serviceID]: { - ...(state.itemsByServiceID[serviceID] ?? {}), - isFetching: false, - tables: [ - ...(state.itemsByServiceID[serviceID]?.tables ?? []), - ...data, - ], - tablesByID: { - ...(state.itemsByServiceID[serviceID]?.tablesByID ?? {}), - ...Object.fromEntries(newTables.map(t => [t.id, t])), - }, - }, - }, - }; - } - - case FETCH_SERVICE_TABLES.ERROR: { - const {serviceInfo: {id: serviceID}} = action; - return { - ...state, - itemsByServiceID: { - ...state.itemsByServiceID, - [serviceID]: { - ...(state.itemsByServiceID[serviceID] ?? {}), - isFetching: false, - }, - }, - }; - } - - case ADDING_SERVICE_TABLE.BEGIN: - return {...state, isCreating: true}; - - case ADDING_SERVICE_TABLE.END: { - const {serviceInfo: {id: serviceID}, table} = action; - return { - ...state, - itemsByServiceID: { - ...state.itemsByServiceID, - [serviceID]: { - ...(state.itemsByServiceID[serviceID] ?? {}), - tables: [...(state.itemsByServiceID[serviceID]?.tables ?? []), table], - tablesByID: { - ...(state.itemsByServiceID[serviceID]?.tablesByID ?? {}), - [table.id]: table, - }, - }, - }, - }; - } - - case ADDING_SERVICE_TABLE.TERMINATE: - return {...state, isCreating: false}; - - case DELETING_SERVICE_TABLE.BEGIN: - return {...state, isDeleting: true}; - - case DELETING_SERVICE_TABLE.END: { - const {serviceInfo: {id: serviceID}, tableID} = action; - return { - ...state, - isDeleting: false, - itemsByServiceID: { - ...state.itemsByServiceID, - [serviceID]: { - ...(state.itemsByServiceID[serviceID] ?? {}), - tables: (state.itemsByServiceID[serviceID]?.tables ?? []) - .filter(t => t.id !== tableID), - tablesByID: objectWithoutProp( - (state.itemsByServiceID[serviceID]?.tablesByID ?? {}), - tableID, - ), - }, - }, - }; - } - - case DELETING_SERVICE_TABLE.TERMINATE: - return {...state, isDeleting: false}; - - default: - return state; - } -}; - export const serviceWorkflows = ( state = { isFetchingAll: false, diff --git a/src/propTypes.js b/src/propTypes.js index 72f3eca03..26b22b285 100644 --- a/src/propTypes.js +++ b/src/propTypes.js @@ -38,7 +38,6 @@ export const bentoServicePropTypesMixin = { artifact: PropTypes.string, repository: PropTypes.string, data_service: PropTypes.bool, - manageable_tables: PropTypes.bool, disabled: PropTypes.bool, url_template: PropTypes.string, url: PropTypes.string, diff --git a/src/reducers.js b/src/reducers.js index 63d4087ce..c5a25689b 100644 --- a/src/reducers.js +++ b/src/reducers.js @@ -18,7 +18,6 @@ import { bentoServices, services, serviceDataTypes, - serviceTables, serviceWorkflows, } from "./modules/services/reducers"; import {datasetDataTypes, datasetSummaries} from "./modules/datasets/reducers"; @@ -56,7 +55,6 @@ const rootReducer = combineReducers({ bentoServices, services, serviceDataTypes, - serviceTables, serviceWorkflows, // Dataset module