Skip to content

Commit

Permalink
#1483 - final fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
boriskovar-m2ms committed Nov 26, 2024
1 parent 50c3eca commit 58c2039
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 97 deletions.
10 changes: 0 additions & 10 deletions js/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,16 +514,6 @@ export default memo(
</Grid>
</>
)}
<Grid item>
<Button
startIcon={<Timeline />}
variant="text"
size="small"
onClick={() => setOpenTrackingModal(true)}
>
Timeline
</Button>
</Grid>
<Grid item>
<IssueReport />
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ const MoleculeView = memo(
if (isDensityOn === false && isDensityCustomOn === false) {
dispatch(getDensityMapData(data)).then(r => {
if (r) {
dispatch(setDensityModalOpen(true));
setDensityModalOpen(true);
} else {
addNewDensity();
}
Expand Down
53 changes: 1 addition & 52 deletions js/components/preview/molecule/redux/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -868,22 +868,6 @@ export const removeSelectedMolTypes = (majorViewStage, molecules, skipTracking,
});
};

// export const searchMoleculeGroupByMoleculeID = moleculeID => (dispatch, getState) =>
// api({ url: `${base_url}/api/molgroup/?mol_id=${moleculeID}` }).then(response => {
// let resultMolGroupID = null;
// const molGroupID = response?.data?.results[0]?.id;
// const mol_group_list = getState().apiReducers.mol_group_list;

// if (mol_group_list && Array.isArray(mol_group_list) && molGroupID) {
// mol_group_list.forEach((item, index) => {
// if (item.id === molGroupID) {
// resultMolGroupID = index + 1;
// }
// });
// }
// return Promise.resolve(resultMolGroupID);
// });

export const applyDirectSelection = stage => (dispatch, getState) => {
const state = getState();

Expand Down Expand Up @@ -947,44 +931,9 @@ export const getQualityInformation = (data, molType, width, height) => (dispatch
export const getProteinData = molecule => dispatch => {
return new Promise((resolve, reject) => {
resolve(molecule.proteinData);
}); /*dispatch(getProteinDataByMolId(molecule.id, molecule.code));*/
});
};

// export const getProteinDataByMolId = (molId, proteinCode) => (dispatch, getState) => {
// const state = getState();
// const proteindDataCache = state.previewReducers.molecule.proteinDataCache;

// const molIdStr = molId.toString();
// if (proteindDataCache.hasOwnProperty(molIdStr)) {
// return new Promise((resolve, reject) => {
// resolve(proteindDataCache[molIdStr]);
// });
// } else {
// return loadProteinData(proteinCode).then(i => {
// if (!proteindDataCache.hasOwnProperty(molIdStr)) {
// dispatch(addProteindDataToCache(molId.toString(), i));
// }
// return i;
// });
// }
// };

// const loadProteinData = code => {
// if (code) {
// let url = new URL(`${base_url}/api/proteins/?code=${code}`);
// let onCancel = () => {};
// return api({
// url,
// onCancel
// }).then(response => {
// return response.data.results;
// });
// } else {
// console.error('Trying to load protein data for unknown molecule protein code.');
// return Promise.resolve();
// }
// };

export const getMolImage = (molId, molType, width, height) => (dispatch, getState) => {
const state = getState();

Expand Down
52 changes: 24 additions & 28 deletions js/components/preview/projectHistoryPanel/editSnapshotDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { base_url } from '../../routes/constants';
import { api, METHOD } from '../../../utils/api';
import { addToastMessage } from '../../../reducers/selection/actions';
import { TOAST_LEVELS } from '../../toast/constants';
import { InputFieldAvatar } from '../../projects/projectModal/inputFieldAvatar';
import { Description, Title } from '@material-ui/icons';

const useStyles = makeStyles(theme => ({
body: {
Expand All @@ -25,8 +27,8 @@ const useStyles = makeStyles(theme => ({
margin: theme.spacing(1),
width: 400
},
renameTargetPopup: {
width: '300px',
editSnashotPopup: {
width: '600px',
borderRadius: '5px',
border: '1px solid #000',
display: 'flex',
Expand Down Expand Up @@ -116,7 +118,7 @@ export const EditSnapshotDialog = () => {
return (
snapshotToBeEdited && (
<Modal open={isSnapshotEditDialogOpen} onClose={onClose}>
<div className={classes.renameTargetPopup}>
<div className={classes.editSnashotPopup}>
<div className={classes.topPopup}>
<span>Edit target</span>
<button className={classes.popUpButton} onClick={onClose}>
Expand All @@ -133,34 +135,28 @@ export const EditSnapshotDialog = () => {
validate={validate}
>
{({ submitForm, isSubmitting }) => (
<Form /*className={classes.flexRow}*/>
<Form>
<Grid container direction="column" className={classes.body}>
<Grid item style={{ display: 'flex', alignItems: 'center' }}>
<label htmlFor="name" style={{ marginRight: '1rem' }}>
Name:
</label>
<Field
component={TextField}
type="text"
name="name"
variant="standard"
margin="none"
disabled={isSubmitting}
autoComplete="off"
<Grid item>
<InputFieldAvatar
icon={<Title />}
field={
<Field component={TextField} className={classes.input} name="name" label="Name" required />
}
/>
</Grid>
<Grid item style={{ display: 'flex', alignItems: 'center' }}>
<label htmlFor="name" style={{ marginRight: '1rem' }}>
Description:
</label>
<Field
component={TextField}
type="text"
name="description"
variant="standard"
margin="none"
disabled={isSubmitting}
autoComplete="off"
<Grid item>
<InputFieldAvatar
icon={<Description />}
field={
<Field
component={TextField}
className={classes.input}
name="description"
label="Description"
required
/>
}
/>
</Grid>
</Grid>
Expand Down
3 changes: 2 additions & 1 deletion js/components/preview/redux/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const loadProtein = nglView => (dispatch, getState) => {
targetData = thisTarget;
}
});
if (!targetData.template_protein) return;
const targObject = generateProteinObject(targetData);
if (targObject) {
let newParams = { display_div: nglView.id };
Expand All @@ -36,7 +37,7 @@ const loadProtein = nglView => (dispatch, getState) => {
return dispatch(loadObject({ target: Object.assign({}, targObject, newParams), stage: nglView.stage }));
}
}
return Promise.reject('Cannot load Protein to NGL View ID ', nglView.id);
// return Promise.reject('Cannot load Protein to NGL View ID ', nglView.id);
};

export const shouldLoadProtein = ({
Expand Down
7 changes: 5 additions & 2 deletions js/components/projects/addProjectDetail/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,11 @@ export const AddProjectDetail = memo(({}) => {
});
} else {
dispatch(createProjectFromSnapshotDialog(data))
.then(() => dispatch(createNewSnapshot({ ...snapshotData, session_project: data.projectID })))
.then(() => handleCloseModal())
.then(() => {
dispatch(createNewSnapshot({ ...snapshotData, session_project: data.projectID }));
handleCloseModal();
})
// .then(() => handleCloseModal())
.catch(error => {
setState(() => {
throw error;
Expand Down
4 changes: 1 addition & 3 deletions js/components/projects/redux/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,7 @@ export const loadSnapshotTree = projectID => (dispatch, getState) => {
dispatch(setCurrentSnapshotTree(null));
return api({ url: `${base_url}/api/snapshots/?session_project=${projectID}&type=INIT` })
.then(response => {
if (response.data.count === 0) {
return Promise.reject('Not found INITIAL snapshot');
} else if (response.data.count === 1) {
if (response.data.count > 0) {
const tree = parseSnapshotAttributes(response.data.results[0]);
dispatch(setCurrentSnapshotTree(tree));
return dispatch(populateChildren([tree.id]));
Expand Down
2 changes: 2 additions & 0 deletions js/components/snapshot/redux/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ export const createNewSnapshot = ({
newType = SnapshotType.INIT;
// Without this, the snapshot tree wouldnt work
dispatch(setForceProjectCreated(false));
//if it's INIT snapshot than it's a root snapshot of a project so parent MUST be null
parent = null;
}

return api({
Expand Down

0 comments on commit 58c2039

Please sign in to comment.