-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Search: Query string syntax help #1828
Merged
Merged
Changes from 54 commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
eb1a1ee
add popup with brief help on search syntax
fiskus 330ea2d
set app theme for help popup
fiskus 698984a
minor changes to make code similar
fiskus 989e728
refactor
fiskus b341dfc
move texts to json file
fiskus 85adb5c
use Box instead of Popper
fiskus 5993c58
rename suggest to help
fiskus 71532bd
minor text addition
fiskus 5244043
consistent coding style
fiskus 8733700
add note to docs
fiskus edc1715
use toggle button and tune icon to open up search box help
fiskus d65f919
remove title and move caption to the bottom
fiskus b139485
use TreeView for syntax help
fiskus 92e8aef
improve mobile view
fiskus 4f2d1e0
highlight code samples
fiskus 7654ce7
add help dropdown to bucket page, restore focus/blur behavior
fiskus 8e66667
fix column width for mobile
fiskus b99d7de
add examples
fiskus faf455e
update text
fiskus 6d48ed1
add package/object note
fiskus 32ad174
move Help to component file
fiskus 280533c
prepare to use react-intl
fiskus 6d5c209
use react-intl for messages
fiskus 1a48cff
divide into small components, reuse them for i18n
fiskus b4cb6dc
sort css alphabetically, fix syntax delivering to input box
fiskus 9c5865b
code formatting for code sample inside title
fiskus cff2c18
improve visual for mobile
fiskus 2109852
cosmetic naming changes
fiskus 76d6e3c
move positioning styles outside of component
fiskus e18cfa1
stick legend and docs link
fiskus c6868cf
Merge branch 'master' of https://github.com/quiltdata/quilt into sear…
fiskus 483543f
adjust color for code
fiskus ac15c01
use List instead of TreeItems, remove regex part and more small tweaks
fiskus c3b2d66
add table header
fiskus 99da15c
fix focus state
fiskus 28bfcfd
remove examples title if no examples
fiskus 4a14ff3
fix mistyping
fiskus 038cab0
change legend
fiskus ac9b2d0
unstick sticky footer
fiskus fde3491
argument is mandatory
fiskus bdd5b66
use MUI attributes
fiskus 3e5d71b
constants scope
fiskus 16bd905
remove extra element
fiskus 60d79c6
set dependency
fiskus 767c439
cosmetic changes
fiskus 757b106
use syntax as a data, not i18n string
fiskus 6134399
use more convinient link title
fiskus 7fd28c7
get rid of react-intl, use more examples
fiskus a47b5e5
hide examples for mobile
fiskus b1216fd
space for last example
fiskus 63fdd47
text update
fiskus 3b97732
add total files and total bytes
fiskus 5ec19ae
update titles
fiskus e100f29
Apply suggestions from code review
fiskus e3477ca
fix spaced bug
fiskus be0cad3
minor cosmetic changes
fiskus 9731a08
add exhaustive deps to react callbacks, also minor cosmetic changes
fiskus 8170d0b
remove animation
fiskus 9b5f475
Merge branch 'master' of https://github.com/quiltdata/quilt into sear…
fiskus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,313 @@ | ||
import cx from 'classnames' | ||
import * as Lab from '@material-ui/lab' | ||
import * as M from '@material-ui/core' | ||
import * as React from 'react' | ||
|
||
import StyledLink from 'utils/StyledLink' | ||
|
||
const ES_V = '6.7' | ||
const ES_REF = `https://www.elastic.co/guide/en/elasticsearch/reference/${ES_V}/query-dsl-query-string-query.html#query-string-syntax` | ||
|
||
const useStyles = M.makeStyles((t) => ({ | ||
fiskus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
root: { | ||
padding: `0 ${t.spacing(4)}px`, | ||
overflowY: 'auto', | ||
|
||
[t.breakpoints.down('xs')]: { | ||
padding: `0 ${t.spacing(1)}px`, | ||
}, | ||
}, | ||
group: { | ||
marginTop: t.spacing(2), | ||
}, | ||
headerLabel: { | ||
background: 'transparent !important', | ||
}, | ||
item: { | ||
borderBottom: `1px solid ${t.palette.divider}`, | ||
|
||
'&:last-child': { | ||
border: 0, | ||
}, | ||
}, | ||
list: { | ||
marginBottom: t.spacing(1), | ||
}, | ||
subList: { | ||
marginLeft: '-12px', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}, | ||
})) | ||
|
||
const useCodeStyles = M.makeStyles((t) => ({ | ||
fiskus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
root: { | ||
nl0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
background: t.palette.grey['300'], | ||
fiskus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
color: t.palette.info.contrastText, | ||
font: t.typography.monospace, | ||
fiskus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
padding: '0 3px', | ||
whiteSpace: 'pre-wrap', | ||
}, | ||
})) | ||
|
||
const useItemsHeaderStyles = M.makeStyles((t) => ({ | ||
root: { | ||
borderBottom: `1px solid ${t.palette.divider}`, | ||
padding: `0 ${t.spacing(2)}px ${t.spacing(1)}px`, | ||
}, | ||
})) | ||
|
||
const useDocsExternalLinkStyles = M.makeStyles((t) => ({ | ||
root: { | ||
marginTop: t.spacing(2), | ||
marginBottom: t.spacing(4), | ||
}, | ||
})) | ||
|
||
const syntaxHelpRows = [ | ||
{ | ||
namespace: 'Fields', | ||
rows: [ | ||
{ | ||
example: 'comment: TODO', | ||
id: 'comment', | ||
fiskus marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doesnt seem like |
||
syntax: 'comment:', | ||
title: 'Package comment', | ||
}, | ||
{ | ||
example: 'content: Hello', | ||
id: 'content', | ||
syntax: 'content:', | ||
title: 'Object content', | ||
}, | ||
{ | ||
example: 'ext: *.fastq.gz', | ||
id: 'ext', | ||
syntax: 'ext:', | ||
title: 'Object extension', | ||
}, | ||
{ | ||
example: 'handle: "user/*"', | ||
id: 'handle', | ||
syntax: 'handle:', | ||
title: 'Package name', | ||
}, | ||
{ | ||
example: 'hash: 3192ac1*', | ||
id: 'hash', | ||
syntax: 'hash:', | ||
title: 'Package hash', | ||
}, | ||
{ | ||
example: 'key: "bar/"', | ||
id: 'key', | ||
syntax: 'key:', | ||
title: 'Object key', | ||
}, | ||
{ | ||
example: 'metadata: dapi', | ||
id: 'metadata', | ||
syntax: 'metadata:', | ||
title: 'Package metadata', | ||
}, | ||
{ | ||
example: 'size: >=4096', | ||
id: 'size', | ||
syntax: 'size:', | ||
title: 'Object size in bytes', | ||
}, | ||
{ | ||
example: 'version_id: t.LVVCx*', | ||
id: 'versionId', | ||
syntax: 'version_id:', | ||
title: 'Object version id', | ||
}, | ||
{ | ||
example: 'package_stats\n .total_files: >100', | ||
id: 'totalFiles', | ||
syntax: 'package_stats\n .total_files:', | ||
title: 'Package total files', | ||
}, | ||
{ | ||
example: 'package_stats\n .total_bytes: <100', | ||
id: 'totalBytes', | ||
syntax: 'package_stats\n .total_bytes:', | ||
title: 'Package total bytes', | ||
}, | ||
], | ||
}, | ||
|
||
{ | ||
namespace: 'Logical operators and grouping', | ||
rows: [ | ||
{ | ||
example: 'a AND b', | ||
id: 'and', | ||
syntax: 'AND', | ||
title: 'Conjunction', | ||
}, | ||
{ | ||
example: 'a OR b', | ||
id: 'or', | ||
syntax: 'OR', | ||
title: 'Disjunction', | ||
}, | ||
{ | ||
example: 'NOT a', | ||
id: 'not', | ||
syntax: 'NOT', | ||
title: 'Negation', | ||
}, | ||
{ | ||
example: '_exists_: content', | ||
id: 'exists', | ||
syntax: '_exists_:', | ||
title: 'Matches any non-null value for the given field', | ||
}, | ||
{ | ||
example: '(a OR b)', | ||
id: 'group', | ||
syntax: '()', | ||
title: 'Group terms', | ||
}, | ||
], | ||
}, | ||
|
||
{ | ||
namespace: 'Wildcards and regular expressions', | ||
rows: [ | ||
{ | ||
example: 'config.y*ml', | ||
id: 'asterisk', | ||
syntax: '*', | ||
title: 'Zero or more characters, avoid leading * (slow)', | ||
}, | ||
{ | ||
example: 'React.?sx', | ||
id: 'question', | ||
syntax: '?', | ||
title: 'Exactly one character', | ||
}, | ||
{ | ||
example: '/lmnb[12]/', | ||
id: 'regex', | ||
syntax: '//', | ||
title: 'Regular expression (slows search)', | ||
}, | ||
], | ||
}, | ||
] | ||
|
||
function Code({ children }) { | ||
const classes = useCodeStyles() | ||
|
||
return <code className={classes.root}>{children}</code> | ||
} | ||
|
||
function Item({ item }) { | ||
const t = M.useTheme() | ||
const sm = M.useMediaQuery(t.breakpoints.up('sm')) | ||
|
||
const { example, syntax, title } = item | ||
return ( | ||
<M.Grid container> | ||
<M.Grid item xs={6} sm={3}> | ||
<M.Typography variant="body2"> | ||
<Code>{syntax}</Code> | ||
</M.Typography> | ||
</M.Grid> | ||
<M.Grid item xs> | ||
<M.Typography variant="body2">{title}</M.Typography> | ||
</M.Grid> | ||
{sm && ( | ||
<M.Grid item xs={4}> | ||
<M.Typography variant="body2"> | ||
<Code>{example}</Code> | ||
</M.Typography> | ||
</M.Grid> | ||
)} | ||
</M.Grid> | ||
) | ||
} | ||
|
||
function ItemsHeader() { | ||
const t = M.useTheme() | ||
const sm = M.useMediaQuery(t.breakpoints.up('sm')) | ||
|
||
const classes = useItemsHeaderStyles() | ||
|
||
return ( | ||
<M.Grid container className={classes.root}> | ||
<M.Grid item xs={6} sm={3}> | ||
<M.Typography variant="subtitle2">Command</M.Typography> | ||
</M.Grid> | ||
<M.Grid item xs> | ||
<M.Typography variant="subtitle2">Description</M.Typography> | ||
</M.Grid> | ||
{sm && ( | ||
<M.Grid item xs sm={4}> | ||
<M.Typography variant="subtitle2">Example</M.Typography> | ||
</M.Grid> | ||
)} | ||
</M.Grid> | ||
) | ||
} | ||
|
||
function DocsExternalLink() { | ||
const classes = useDocsExternalLinkStyles() | ||
|
||
return ( | ||
<M.Typography variant="body2" component="p" className={classes.root}> | ||
Quilt uses ElasticSearch 6.7 query string queries.{' '} | ||
fiskus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<StyledLink href={ES_REF} target="_blank"> | ||
Learn more | ||
</StyledLink> | ||
. | ||
</M.Typography> | ||
) | ||
} | ||
|
||
function Help({ className, onQuery }) { | ||
fiskus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const classes = useStyles() | ||
|
||
return ( | ||
<M.Paper className={cx(classes.root, className)}> | ||
<Lab.TreeView | ||
defaultCollapseIcon={<M.Icon>arrow_drop_down</M.Icon>} | ||
defaultExpandIcon={<M.Icon>arrow_right</M.Icon>} | ||
defaultExpanded={syntaxHelpRows.map(({ namespace }) => namespace)} | ||
disableSelection | ||
className={classes.list} | ||
> | ||
{syntaxHelpRows.map(({ namespace, rows }) => ( | ||
<Lab.TreeItem | ||
className={classes.group} | ||
label={<M.Typography variant="subtitle2">{namespace}</M.Typography>} | ||
nodeId={namespace} | ||
key={namespace} | ||
classes={{ | ||
label: classes.headerLabel, | ||
}} | ||
> | ||
<M.List className={classes.subList}> | ||
<ItemsHeader /> | ||
|
||
{rows.map((item) => ( | ||
<M.ListItem | ||
key={item.id} | ||
className={classes.item} | ||
button | ||
onClick={() => onQuery(item.syntax)} | ||
> | ||
<Item item={item} /> | ||
</M.ListItem> | ||
))} | ||
</M.List> | ||
</Lab.TreeItem> | ||
))} | ||
</Lab.TreeView> | ||
|
||
<DocsExternalLink /> | ||
</M.Paper> | ||
) | ||
} | ||
|
||
export default Help |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lab
should come aftercore
(A-Z) and scoped packages should come after non-scopedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. I think that sorting rule should be operated by eslint https://eslint.org/docs/rules/sort-imports