Skip to content
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 59 commits into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
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 Sep 24, 2020
330ea2d
set app theme for help popup
fiskus Sep 24, 2020
698984a
minor changes to make code similar
fiskus Sep 24, 2020
989e728
refactor
fiskus Sep 28, 2020
b341dfc
move texts to json file
fiskus Sep 28, 2020
85adb5c
use Box instead of Popper
fiskus Sep 28, 2020
5993c58
rename suggest to help
fiskus Sep 28, 2020
71532bd
minor text addition
fiskus Sep 28, 2020
5244043
consistent coding style
fiskus Sep 28, 2020
8733700
add note to docs
fiskus Sep 28, 2020
edc1715
use toggle button and tune icon to open up search box help
fiskus Sep 28, 2020
d65f919
remove title and move caption to the bottom
fiskus Sep 29, 2020
b139485
use TreeView for syntax help
fiskus Sep 29, 2020
92e8aef
improve mobile view
fiskus Sep 29, 2020
4f2d1e0
highlight code samples
fiskus Sep 29, 2020
7654ce7
add help dropdown to bucket page, restore focus/blur behavior
fiskus Sep 29, 2020
8e66667
fix column width for mobile
fiskus Sep 29, 2020
b99d7de
add examples
fiskus Sep 29, 2020
faf455e
update text
fiskus Sep 29, 2020
6d48ed1
add package/object note
fiskus Sep 29, 2020
32ad174
move Help to component file
fiskus Sep 30, 2020
280533c
prepare to use react-intl
fiskus Sep 30, 2020
6d5c209
use react-intl for messages
fiskus Sep 30, 2020
1a48cff
divide into small components, reuse them for i18n
fiskus Sep 30, 2020
b4cb6dc
sort css alphabetically, fix syntax delivering to input box
fiskus Sep 30, 2020
9c5865b
code formatting for code sample inside title
fiskus Sep 30, 2020
cff2c18
improve visual for mobile
fiskus Sep 30, 2020
2109852
cosmetic naming changes
fiskus Sep 30, 2020
76d6e3c
move positioning styles outside of component
fiskus Sep 30, 2020
e18cfa1
stick legend and docs link
fiskus Sep 30, 2020
c6868cf
Merge branch 'master' of https://github.com/quiltdata/quilt into sear…
fiskus Sep 30, 2020
483543f
adjust color for code
fiskus Oct 1, 2020
ac15c01
use List instead of TreeItems, remove regex part and more small tweaks
fiskus Oct 1, 2020
c3b2d66
add table header
fiskus Oct 1, 2020
99da15c
fix focus state
fiskus Oct 1, 2020
28bfcfd
remove examples title if no examples
fiskus Oct 1, 2020
4a14ff3
fix mistyping
fiskus Oct 1, 2020
038cab0
change legend
fiskus Oct 1, 2020
ac9b2d0
unstick sticky footer
fiskus Oct 1, 2020
fde3491
argument is mandatory
fiskus Oct 1, 2020
bdd5b66
use MUI attributes
fiskus Oct 1, 2020
3e5d71b
constants scope
fiskus Oct 1, 2020
16bd905
remove extra element
fiskus Oct 1, 2020
60d79c6
set dependency
fiskus Oct 1, 2020
767c439
cosmetic changes
fiskus Oct 1, 2020
757b106
use syntax as a data, not i18n string
fiskus Oct 1, 2020
6134399
use more convinient link title
fiskus Oct 1, 2020
7fd28c7
get rid of react-intl, use more examples
fiskus Oct 1, 2020
a47b5e5
hide examples for mobile
fiskus Oct 1, 2020
b1216fd
space for last example
fiskus Oct 1, 2020
63fdd47
text update
fiskus Oct 1, 2020
3b97732
add total files and total bytes
fiskus Oct 1, 2020
5ec19ae
update titles
fiskus Oct 1, 2020
e100f29
Apply suggestions from code review
fiskus Oct 1, 2020
e3477ca
fix spaced bug
fiskus Oct 1, 2020
be0cad3
minor cosmetic changes
fiskus Oct 2, 2020
9731a08
add exhaustive deps to react callbacks, also minor cosmetic changes
fiskus Oct 2, 2020
8170d0b
remove animation
fiskus Oct 2, 2020
9b5f475
Merge branch 'master' of https://github.com/quiltdata/quilt into sear…
fiskus Oct 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion catalog/app/containers/NavBar/Controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@ function BucketDisplay({ bucket, select, locked = false, ...props }) {
}

const Container = (props) => (
<M.Box display="flex" alignItems="center" position="relative" flexGrow={1} {...props} />
<M.Box
height="36px"
display="flex"
alignItems="center"
position="relative"
flexGrow={1}
{...props}
/>
)

function GlobalControls({ iconized, disableSearch }) {
Expand Down
313 changes: 313 additions & 0 deletions catalog/app/containers/NavBar/Help.js
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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lab should come after core (A-Z) and scoped packages should come after non-scoped

Copy link
Member Author

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

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',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-t.spacing(1.5) ot t.spacing(-1.5)

},
}))

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesnt seem like ids are necessary anymore, you can drop them and use syntax as keys (since it has unique values)

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
Loading