Skip to content

Commit

Permalink
Merge pull request #475 from xchem/staging
Browse files Browse the repository at this point in the history
Push to production
  • Loading branch information
mwinokan authored Jan 28, 2025
2 parents 33f9bf7 + 9e58751 commit 6681d51
Show file tree
Hide file tree
Showing 17 changed files with 542 additions and 1,455 deletions.
27 changes: 23 additions & 4 deletions js/components/common/Components/SearchField/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useMemo } from 'react';
import { makeStyles, TextField, InputAdornment } from '@material-ui/core';
import { makeStyles, TextField, InputAdornment, IconButton } from '@material-ui/core';
import { Search } from '@material-ui/icons';
import classNames from 'classnames';
import { debounce } from 'lodash';
Expand Down Expand Up @@ -31,9 +31,18 @@ const useStyles = makeStyles(theme => ({
}
}));

const SearchField = ({ className, id, placeholder, size, onChange, disabled, searchString }) => {
const SearchField = ({
className,
id,
placeholder,
size,
onChange,
disabled,
searchString,
searchIconAction = null
}) => {
const classes = useStyles();
let value = searchString ?? '';
let value = searchString ?? '';

const debounced = useMemo(
() =>
Expand All @@ -57,7 +66,17 @@ const SearchField = ({ className, id, placeholder, size, onChange, disabled, sea
InputProps={{
startAdornment: (
<InputAdornment position="start">
<Search color="inherit" />
{searchIconAction ? (
<IconButton
color="inherit"
sx={{ pointerEvents: 'auto', cursor: 'pointer' }}
onClick={() => searchIconAction(true)}
>
<Search color="inherit" />
</IconButton>
) : (
<Search color="inherit" />
)}
</InputAdornment>
),
className: classes.input
Expand Down
3 changes: 2 additions & 1 deletion js/components/direct/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ export const URL_TOKENS = {
molecules: 'mols',
exact: 'exact',
tag: 'tag',
target_access_string: 'tas'
target_access_string: 'tas',
compound: 'compound'
};
20 changes: 16 additions & 4 deletions js/components/direct/directDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ export const DirectDisplay = memo(props => {
useEffect(() => {
// 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
// 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
// based on the issues #431, #448, #447
// in two cases above we are searching for molecules using shortcode
// Now the search term is looked up in the `shortcode`, `compound ID` and all of the `aliases` (I can change this pretty quickly)
// `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`
// 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,
// 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`
const param = match.params[0];
if (!directAccessProcessed && param && param.startsWith(URL_TOKENS.target)) {
let withoutKeyword = param.split(URL_TOKENS.target);
Expand Down Expand Up @@ -63,7 +67,13 @@ export const DirectDisplay = memo(props => {
}
}
}
if (rest && rest.length > 1 && rest[0] === URL_TOKENS.molecules) {
if (rest && rest.length > 1 && (rest[0] === URL_TOKENS.molecules || rest[0] === URL_TOKENS.compound)) {
let searchSettings = { searchBy: {} };
if (rest[0] === URL_TOKENS.molecules) {
searchSettings = { searchBy: { shortcode: true, aliases: false, compoundId: false } };
} else if (rest[0] === URL_TOKENS.compound) {
searchSettings = { searchBy: { shortcode: true, aliases: true, compoundId: true } };
}
rest = rest.slice(1);
let i;
let currentMolecule;
Expand Down Expand Up @@ -105,7 +115,8 @@ export const DirectDisplay = memo(props => {
C: false,
S: false,
V: false,
exact: false
exact: false,
searchSettings: searchSettings
};
molecules.push(currentMolecule);
}
Expand All @@ -119,7 +130,8 @@ export const DirectDisplay = memo(props => {
C: false,
S: false,
V: false,
exact: false
exact: false,
searchSettings: searchSettings
};
molecules.push(currentMolecule);
}
Expand Down
2 changes: 1 addition & 1 deletion js/components/preview/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,5 +354,5 @@ const Preview = memo(({ isStateLoaded, hideProjects, isSnapshot = false }) => {
});

export default withLoadingJobSpecs(
withSnapshotManagement(withUpdatingTarget(withLoadingProtein(withLoadingProjects(Preview))))
withLoadingProjects(withSnapshotManagement(withUpdatingTarget(withLoadingProtein(Preview))))
);
1 change: 0 additions & 1 deletion js/components/preview/molecule/hitNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Created by abradley on 14/03/2018.
*/
import React, { memo } from 'react';
import { MoleculeList } from './moleculeList';
import { ObservationCmpList } from './observationCmpList';

const HitNavigator = memo(({ hideProjects }) => {
Expand Down
Loading

0 comments on commit 6681d51

Please sign in to comment.