Skip to content

Commit 3dd536b

Browse files
authored
Merge pull request #409 from m2ms/stagingcandidate
2 parents ad2c5d7 + 7caa384 commit 3dd536b

File tree

7 files changed

+52
-20
lines changed

7 files changed

+52
-20
lines changed

js/components/preview/ResizableLayout.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,10 @@ export const ResizableLayout = ({ gridRef, hideProjects, showHistory, onShowHist
7676
: twoRowHeight
7777
: oneRowHeight;
7878

79-
const tagDetailListHeight = preTagList.length * listTagHeight + tagDetailListLayoutHeight;
79+
// limit default tag panel height to not overflow screen by showing of area of max 10 tags
80+
const tagDetailListHeight = (preTagList.length > 10 ? 10 : preTagList.length) * listTagHeight + tagDetailListLayoutHeight;
8081
const tagDetailGridHeight =
81-
Math.ceil(preTagList.length / defaultTagDetailColumnNumber) * absoluteMaxTagLength + tagDetailGridLayoutHeight;
82+
Math.ceil((preTagList.length > 10 ? 10 : preTagList.length) / defaultTagDetailColumnNumber) * absoluteMaxTagLength + tagDetailGridLayoutHeight;
8283

8384
useEffect(() => {
8485
if (sidesOpen.LHS) {
@@ -201,12 +202,20 @@ export const ResizableLayout = ({ gridRef, hideProjects, showHistory, onShowHist
201202
},
202203
[gridRef, tagDetailsHeight]
203204
);
205+
204206
return (
205207
<div className={classes.root}>
206208
{sidesOpen.LHS && (
207209
<>
208210
<div className={classes.lhs} style={{ width: lhsWidth }}>
209-
<div style={{ height: tagDetailsHeight, overflow: 'auto' }}>
211+
<div style={{
212+
overflow: 'auto',
213+
height: tagDetailsHeight === undefined
214+
? tagDetailView?.tagDetailView === true || tagDetailView === true
215+
? tagDetailGridHeight
216+
: tagDetailListHeight
217+
: tagDetailsHeight
218+
}}>
210219
<TagDetails />
211220
</div>
212221
<Resizer orientation="horizontal" onResize={onTagDetailsResize} />
@@ -221,9 +230,9 @@ export const ResizableLayout = ({ gridRef, hideProjects, showHistory, onShowHist
221230
height:
222231
tagDetailsHeight === undefined
223232
? tagDetailView?.tagDetailView === true || tagDetailView === true
224-
? screenHeight - tagDetailGridHeight + 'px'
225-
: screenHeight - tagDetailListHeight + 'px'
226-
: screenHeight - tagDetailsHeight - 20 + 'px'
233+
? screenHeight - tagDetailGridHeight - 20
234+
: screenHeight - tagDetailListHeight - 20
235+
: screenHeight - tagDetailsHeight - 20
227236
}}
228237
>
229238
<HitNavigator hideProjects={hideProjects} />

js/components/preview/molecule/observationCmpList.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,8 +701,8 @@ export const ObservationCmpList = memo(({ hideProjects }) => {
701701
let filteredLHSCompoundsList = useMemo(() => {
702702
const compounds = [];
703703
lhsCompoundsList.forEach(compound => {
704-
const molsForCmp = joinedMoleculeLists.filter(molecule => molecule.cmpd === compound.origId);
705-
if (molsForCmp?.length > 0) {
704+
const molsForCmp = joinedMoleculeLists.some(molecule => molecule.cmpd === compound.origId);
705+
if (molsForCmp && compound.associatedObs.some(obs => joinedMoleculeLists.some(mol => mol.id === obs.id))) {
706706
compounds.push(compound);
707707
}
708708
});

js/components/preview/molecule/redux/dispatchActions.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ export const initializeMolecules = majorView => (dispatch, getState) => {
667667
} else if (noTagsReceived) {
668668
// firstMolecule = dispatch(getFirstMolecule());
669669
}
670-
firstMolecule = dispatch(getFirstMolOfFirstCompound());
670+
firstMolecule = dispatch(getFirstMolOfFirstCompound(firstTag));
671671
if (firstMolecule) {
672672
dispatch(addHitProtein(majorView, firstMolecule, colourList[firstMolecule.id % colourList.length], true)).then(
673673
() => {
@@ -705,16 +705,15 @@ export const getFirstTagAlphabetically = () => (dispatch, getState) => {
705705
return sortedTags && sortedTags.length > 0 ? sortedTags[0] : null;
706706
};
707707

708-
export const getFirstMolOfFirstCompound = () => (dispatch, getState) => {
708+
export const getFirstMolOfFirstCompound = tag => (dispatch, getState) => {
709709
const state = getState();
710710
const compoundsList = state.apiReducers.lhs_compounds_list;
711-
const firstCompound = compoundsList[0];
711+
const firstCompound = compoundsList?.find(c => c.associatedObs.some(obs => obs.tags_set.includes(tag.id)));
712712
if (firstCompound) {
713-
if (firstCompound.associatedObs?.length > 0) {
714-
return firstCompound.associatedObs[0];
715-
} else {
716-
return null;
717-
}
713+
let firstObs = null;
714+
firstObs = firstCompound.associatedObs.find(obs => obs.tags_set.includes(tag.id));
715+
716+
return firstObs;
718717
} else {
719718
return null;
720719
}

js/components/preview/tags/details/tagDetails.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import {
2222
compareTagsByCreatorAsc,
2323
compareTagsByCreatorDesc,
2424
compareTagsByDateAsc,
25-
compareTagsByDateDesc
25+
compareTagsByDateDesc,
26+
getCategoriesToBeRemovedFromTagDetails
2627
} from '../utils/tagUtils';
2728
import { UnfoldMore, KeyboardArrowDown, KeyboardArrowUp } from '@material-ui/icons';
2829
import { getMoleculeForId } from '../redux/dispatchActions';
@@ -165,6 +166,7 @@ const TagDetails = memo(() => {
165166
const displayUntaggedMolecules = useSelector(state => state.selectionReducers.displayUntaggedMolecules);
166167
let tagDetailView = useSelector(state => state.selectionReducers.tagDetailView);
167168
const resizableLayout = useSelector(state => state.selectionReducers.resizableLayout);
169+
const tagCategories = useSelector(state => state.apiReducers.categoryList);
168170

169171
const [tagList, setTagList] = useState([]);
170172
const [selectAll, setSelectAll] = useState(true);
@@ -180,8 +182,9 @@ const TagDetails = memo(() => {
180182
}, [searchString, tagList]);
181183

182184
useEffect(() => {
185+
const categoriesToRemove = getCategoriesToBeRemovedFromTagDetails(tagCategories);
183186
const newTagList = preTagList.filter(t => {
184-
if (t.additional_info?.downloadName) {
187+
if (t.additional_info?.downloadName || categoriesToRemove.some(c => c.id === t.category)) {
185188
return false;
186189
} else {
187190
return true;
@@ -191,7 +194,7 @@ const TagDetails = memo(() => {
191194
return () => {
192195
setTagList([]);
193196
};
194-
}, [preTagList]);
197+
}, [preTagList, tagCategories]);
195198

196199
const moleculesToEditIds = useSelector(state => state.selectionReducers.moleculesToEdit);
197200
const moleculesToEdit =

js/components/preview/tags/utils/tagUtils.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { is } from 'date-fns/locale';
22
import {
33
CATEGORY_TYPE_BY_ID,
44
OBSERVATION_TAG_CATEGORIES,
5-
COMPOUND_PRIO_TAG_CATEGORIES
5+
COMPOUND_PRIO_TAG_CATEGORIES,
6+
TAG_DETAILS_REMOVED_CATEGORIES
67
} from '../../../../constants/constants';
78

89
export const DEFAULT_TAG_COLOR = '#E0E0E0';
@@ -166,6 +167,19 @@ export const getAllTagsForObservation = (obs, tagList, tagCategoryList) => {
166167
return result;
167168
};
168169

170+
export const getCategoriesToBeRemovedFromTagDetails = tagCategoryList => {
171+
const result = [];
172+
173+
TAG_DETAILS_REMOVED_CATEGORIES.forEach(categName => {
174+
const categ = tagCategoryList.find(c => c.category === categName);
175+
if (categ) {
176+
result.push({ ...categ });
177+
}
178+
});
179+
180+
return result;
181+
};
182+
169183
export const getCompoundPriorityTagConfig = (tagCategoryList, isSingleObs) => {
170184
const result = [];
171185

js/components/target/redux/dispatchActions.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ export const getTargetProjectCombinations = (targets, projects) => {
170170
result.push({ updatedTarget: { ...target, project: { target_access_string: 'Legacy' } } });
171171
}
172172
});
173+
} else if (targetItems.length > 0) {
174+
targetItems.forEach(([targetId, target]) => {
175+
if (target.isLegacy) {
176+
result.push({ updatedTarget: { ...target, project: { target_access_string: 'Legacy' } } });
177+
}
178+
});
173179
}
174180

175181
return result;

js/constants/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export const CATEGORY_TYPE_BY_ID = {
5454

5555
export const OBSERVATION_TAG_CATEGORIES = ['ConformerSites', 'CrystalformSites', 'Quatassemblies', 'Crystalforms'];
5656
export const COMPOUND_PRIO_TAG_CATEGORIES = ['CanonSites'];
57+
export const TAG_DETAILS_REMOVED_CATEGORIES = ['CrystalformSites', 'ConformerSites'];
5758

5859
export const TAG_TYPE = {
5960
ALL: 'ALL',

0 commit comments

Comments
 (0)