@jbrowse/plugin-config 1.6.4 → 1.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-config",
3
- "version": "1.6.4",
3
+ "version": "1.6.7",
4
4
  "description": "JBrowse 2 config utilities",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -55,5 +55,5 @@
55
55
  "publishConfig": {
56
56
  "access": "public"
57
57
  },
58
- "gitHead": "7f157fbb2302d8825f99d01bcc0fd0616116c5d2"
58
+ "gitHead": "02012ec299c36647f755316571775d36b0fee5ec"
59
59
  }
@@ -47,9 +47,10 @@ function CallbackEditor({ slot }) {
47
47
  jexlDebouncedCode,
48
48
  getEnv(slot).pluginManager?.jexl,
49
49
  )
50
- slot.set(jexlDebouncedCode) // slot.set `jexl:${debouncedCode}`
50
+ slot.set(jexlDebouncedCode)
51
51
  setCodeError(null)
52
52
  } catch (e) {
53
+ console.error({ e })
53
54
  setCodeError(e)
54
55
  }
55
56
  }, [debouncedCode, slot])
@@ -65,13 +66,16 @@ function CallbackEditor({ slot }) {
65
66
  <Editor
66
67
  className={classes.callbackEditor}
67
68
  value={code.startsWith('jexl:') ? code.split('jexl:')[1] : code}
68
- onValueChange={newCode => {
69
- setCode(newCode)
70
- }}
69
+ onValueChange={newCode => setCode(newCode)}
71
70
  highlight={newCode => newCode}
72
71
  padding={10}
73
72
  style={{ background: error ? '#fdd' : undefined }}
74
73
  />
74
+ {error ? (
75
+ <FormHelperText
76
+ style={{ color: '#f00' }}
77
+ >{`${error}`}</FormHelperText>
78
+ ) : null}
75
79
  <FormHelperText>{slot.description}</FormHelperText>
76
80
  </FormControl>
77
81
  <Tooltip
@@ -1,49 +1,62 @@
1
+ import React from 'react'
1
2
  import {
2
3
  readConfObject,
3
4
  getTypeNamesFromExplicitlyTypedUnion,
4
5
  isConfigurationSchemaType,
5
6
  isConfigurationSlotType,
6
7
  } from '@jbrowse/core/configuration'
7
-
8
- import { iterMap } from '@jbrowse/core/util'
9
- import FormGroup from '@material-ui/core/FormGroup'
10
- import FormLabel from '@material-ui/core/FormLabel'
11
- import { makeStyles } from '@material-ui/core/styles'
8
+ import {
9
+ FormGroup,
10
+ Accordion,
11
+ AccordionDetails,
12
+ AccordionSummary,
13
+ Typography,
14
+ makeStyles,
15
+ } from '@material-ui/core'
12
16
  import { observer } from 'mobx-react'
13
17
  import { getMembers } from 'mobx-state-tree'
14
18
  import { singular } from 'pluralize'
15
- import React from 'react'
19
+
20
+ // icons
21
+ import ExpandMoreIcon from '@material-ui/icons/ExpandMore'
22
+
23
+ // locals
16
24
  import SlotEditor from './SlotEditor'
17
25
  import TypeSelector from './TypeSelector'
18
26
 
19
27
  const useStyles = makeStyles(theme => ({
20
- subSchemaContainer: {
21
- marginLeft: theme.spacing(1),
22
- borderLeft: `1px solid ${theme.palette.secondary.main}`,
23
- paddingLeft: theme.spacing(1),
24
- marginBottom: theme.spacing(1),
28
+ expandIcon: {
29
+ color: '#fff',
25
30
  },
26
31
  root: {
27
32
  padding: theme.spacing(1, 3, 1, 1),
28
- background: theme.palette.background.default,
29
- overflowX: 'hidden',
33
+ },
34
+ expansionPanelDetails: {
35
+ display: 'block',
36
+ padding: theme.spacing(1),
37
+ },
38
+
39
+ accordion: {
40
+ border: `1px solid ${theme.palette.text.primary}`,
30
41
  },
31
42
  }))
32
43
 
33
44
  const Member = observer(props => {
34
45
  const classes = useStyles()
35
- const { slotName, slotSchema, schema, slot = schema[slotName] } = props
46
+ const {
47
+ slotName,
48
+ slotSchema,
49
+ schema,
50
+ slot = schema[slotName],
51
+ path = [],
52
+ } = props
36
53
  let typeSelector
37
54
  if (isConfigurationSchemaType(slotSchema)) {
38
55
  if (slot.length) {
39
- return (
40
- <>
41
- {slot.map((subslot, slotIndex) => {
42
- const key = `${singular(slotName)} ${slotIndex + 1}`
43
- return <Member {...props} key={key} slot={subslot} slotName={key} />
44
- })}
45
- </>
46
- )
56
+ return slot.map((subslot, slotIndex) => {
57
+ const key = `${singular(slotName)} ${slotIndex + 1}`
58
+ return <Member {...props} key={key} slot={subslot} slotName={key} />
59
+ })
47
60
  }
48
61
  // if this is an explicitly typed schema, make a type-selecting dropdown
49
62
  // that can be used to change its type
@@ -63,15 +76,23 @@ const Member = observer(props => {
63
76
  )
64
77
  }
65
78
  return (
66
- <>
67
- <FormLabel>{slotName}</FormLabel>
68
- <div className={classes.subSchemaContainer}>
79
+ <Accordion
80
+ defaultExpanded
81
+ className={classes.accordion}
82
+ TransitionProps={{ unmountOnExit: true, timeout: 150 }}
83
+ >
84
+ <AccordionSummary
85
+ expandIcon={<ExpandMoreIcon className={classes.expandIcon} />}
86
+ >
87
+ <Typography>{[...path, slotName].join('🡒')}</Typography>
88
+ </AccordionSummary>
89
+ <AccordionDetails className={classes.expansionPanelDetails}>
69
90
  {typeSelector}
70
91
  <FormGroup>
71
- <Schema schema={slot} />
92
+ <Schema schema={slot} path={[...path, slotName]} />
72
93
  </FormGroup>
73
- </div>
74
- </>
94
+ </AccordionDetails>
95
+ </Accordion>
75
96
  )
76
97
  }
77
98
 
@@ -83,13 +104,17 @@ const Member = observer(props => {
83
104
  return null
84
105
  })
85
106
 
86
- const Schema = observer(({ schema }) => {
87
- return iterMap(
88
- Object.entries(getMembers(schema).properties),
89
- ([slotName, slotSchema]) => (
90
- <Member key={slotName} {...{ slotName, slotSchema, schema }} />
91
- ),
92
- )
107
+ const Schema = observer(({ schema, path = [] }) => {
108
+ const properties = getMembers(schema).properties
109
+ return Object.entries(properties).map(([slotName, slotSchema]) => (
110
+ <Member
111
+ key={slotName}
112
+ slotName={slotName}
113
+ slotSchema={slotSchema}
114
+ path={path}
115
+ schema={schema}
116
+ />
117
+ ))
93
118
  })
94
119
 
95
120
  const ConfigurationEditor = observer(({ model }) => {
@@ -98,10 +123,26 @@ const ConfigurationEditor = observer(({ model }) => {
98
123
  // for different tracks since only the backing model changes for example
99
124
  // see pr #804
100
125
  const key = model.target && readConfObject(model.target, 'trackId')
126
+ const name = model.target && readConfObject(model.target, 'name')
101
127
  return (
102
- <div className={classes.root} key={key} data-testid="configEditor">
103
- {!model.target ? 'no target set' : <Schema schema={model.target} />}
104
- </div>
128
+ <Accordion
129
+ key={key}
130
+ defaultExpanded
131
+ className={classes.accordion}
132
+ TransitionProps={{ unmountOnExit: true, timeout: 150 }}
133
+ >
134
+ <AccordionSummary
135
+ expandIcon={<ExpandMoreIcon className={classes.expandIcon} />}
136
+ >
137
+ <Typography>{name ? name : 'Configuration'}</Typography>
138
+ </AccordionSummary>
139
+ <AccordionDetails
140
+ className={classes.expansionPanelDetails}
141
+ data-testid="configEditor"
142
+ >
143
+ {!model.target ? 'no target set' : <Schema schema={model.target} />}
144
+ </AccordionDetails>
145
+ </Accordion>
105
146
  )
106
147
  })
107
148
 
@@ -370,12 +370,9 @@ export const useSlotEditorStyles = makeStyles(theme => ({
370
370
  display: 'flex',
371
371
  marginBottom: theme.spacing(2),
372
372
  position: 'relative',
373
- overflow: 'visible',
374
373
  },
375
374
  paperContent: {
376
- flex: 'auto',
377
- padding: theme.spacing(1),
378
- overflow: 'auto',
375
+ width: '100%',
379
376
  },
380
377
  slotModeSwitch: {
381
378
  width: 24,