Skip to content

Commit 6681d51

Browse files
authored
Merge pull request #475 from xchem/staging
Push to production
2 parents 33f9bf7 + 9e58751 commit 6681d51

17 files changed

+542
-1455
lines changed

js/components/common/Components/SearchField/index.js

+23-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useMemo } from 'react';
2-
import { makeStyles, TextField, InputAdornment } from '@material-ui/core';
2+
import { makeStyles, TextField, InputAdornment, IconButton } from '@material-ui/core';
33
import { Search } from '@material-ui/icons';
44
import classNames from 'classnames';
55
import { debounce } from 'lodash';
@@ -31,9 +31,18 @@ const useStyles = makeStyles(theme => ({
3131
}
3232
}));
3333

34-
const SearchField = ({ className, id, placeholder, size, onChange, disabled, searchString }) => {
34+
const SearchField = ({
35+
className,
36+
id,
37+
placeholder,
38+
size,
39+
onChange,
40+
disabled,
41+
searchString,
42+
searchIconAction = null
43+
}) => {
3544
const classes = useStyles();
36-
let value = searchString ?? '';
45+
let value = searchString ?? '';
3746

3847
const debounced = useMemo(
3948
() =>
@@ -57,7 +66,17 @@ const SearchField = ({ className, id, placeholder, size, onChange, disabled, sea
5766
InputProps={{
5867
startAdornment: (
5968
<InputAdornment position="start">
60-
<Search color="inherit" />
69+
{searchIconAction ? (
70+
<IconButton
71+
color="inherit"
72+
sx={{ pointerEvents: 'auto', cursor: 'pointer' }}
73+
onClick={() => searchIconAction(true)}
74+
>
75+
<Search color="inherit" />
76+
</IconButton>
77+
) : (
78+
<Search color="inherit" />
79+
)}
6180
</InputAdornment>
6281
),
6382
className: classes.input

js/components/direct/constants.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ export const URL_TOKENS = {
33
molecules: 'mols',
44
exact: 'exact',
55
tag: 'tag',
6-
target_access_string: 'tas'
6+
target_access_string: 'tas',
7+
compound: 'compound'
78
};

js/components/direct/directDisplay.js

+16-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ export const DirectDisplay = memo(props => {
3434
useEffect(() => {
3535
// example url http://127.0.0.1:8080/viewer/react/preview/direct/target/MID2A/tas/lb00000/mols/X0301_0A/L/P/S/X0393_0B/L/P
3636
// example url with 'exact' https://fragalysis-tibor-default.xchem-dev.diamond.ac.uk/viewer/react/preview/direct/target/NUDT7A_CRUDE/mols/NUDT7A_CRUDE-X0156_1/exact/L/P
37-
// based on the issues #431, #448, #447
37+
// in two cases above we are searching for molecules using shortcode
38+
// Now the search term is looked up in the `shortcode`, `compound ID` and all of the `aliases` (I can change this pretty quickly)
39+
// `http://127.0.0.1:8080/viewer/react/preview/direct/target/A71EV2A/tas/lb18145-1/compound/7516/L/S/nonsense-45/L/P/exact/Z4/L/C/A0853a/L/P`
40+
// URL above shows `L` and `S` for observation which contains substring `7516`, `L` and `P` for observation which exactly has string `nonsense-45` as a shortcode,
41+
// compound ID or one of the aliases, `L` and `C` for all observations which contain substring `Z4`, and `L` and `P` for observations which contains substring `A0853a`
3842
const param = match.params[0];
3943
if (!directAccessProcessed && param && param.startsWith(URL_TOKENS.target)) {
4044
let withoutKeyword = param.split(URL_TOKENS.target);
@@ -63,7 +67,13 @@ export const DirectDisplay = memo(props => {
6367
}
6468
}
6569
}
66-
if (rest && rest.length > 1 && rest[0] === URL_TOKENS.molecules) {
70+
if (rest && rest.length > 1 && (rest[0] === URL_TOKENS.molecules || rest[0] === URL_TOKENS.compound)) {
71+
let searchSettings = { searchBy: {} };
72+
if (rest[0] === URL_TOKENS.molecules) {
73+
searchSettings = { searchBy: { shortcode: true, aliases: false, compoundId: false } };
74+
} else if (rest[0] === URL_TOKENS.compound) {
75+
searchSettings = { searchBy: { shortcode: true, aliases: true, compoundId: true } };
76+
}
6777
rest = rest.slice(1);
6878
let i;
6979
let currentMolecule;
@@ -105,7 +115,8 @@ export const DirectDisplay = memo(props => {
105115
C: false,
106116
S: false,
107117
V: false,
108-
exact: false
118+
exact: false,
119+
searchSettings: searchSettings
109120
};
110121
molecules.push(currentMolecule);
111122
}
@@ -119,7 +130,8 @@ export const DirectDisplay = memo(props => {
119130
C: false,
120131
S: false,
121132
V: false,
122-
exact: false
133+
exact: false,
134+
searchSettings: searchSettings
123135
};
124136
molecules.push(currentMolecule);
125137
}

js/components/preview/Preview.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -354,5 +354,5 @@ const Preview = memo(({ isStateLoaded, hideProjects, isSnapshot = false }) => {
354354
});
355355

356356
export default withLoadingJobSpecs(
357-
withSnapshotManagement(withUpdatingTarget(withLoadingProtein(withLoadingProjects(Preview))))
357+
withLoadingProjects(withSnapshotManagement(withUpdatingTarget(withLoadingProtein(Preview))))
358358
);

js/components/preview/molecule/hitNavigator.js

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* Created by abradley on 14/03/2018.
33
*/
44
import React, { memo } from 'react';
5-
import { MoleculeList } from './moleculeList';
65
import { ObservationCmpList } from './observationCmpList';
76

87
const HitNavigator = memo(({ hideProjects }) => {

0 commit comments

Comments
 (0)