@jbrowse/plugin-config 1.7.11 → 2.0.0
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/dist/ConfigurationEditorWidget/components/CallbackEditor.d.ts +10 -7
- package/dist/ConfigurationEditorWidget/components/CallbackEditor.js +108 -115
- package/dist/ConfigurationEditorWidget/components/CallbackEditor.js.map +1 -0
- package/dist/ConfigurationEditorWidget/components/CodeEditor.d.ts +4 -3
- package/dist/ConfigurationEditorWidget/components/CodeEditor.js +78 -73
- package/dist/ConfigurationEditorWidget/components/CodeEditor.js.map +1 -0
- package/dist/ConfigurationEditorWidget/components/ColorEditor.d.ts +9 -33
- package/dist/ConfigurationEditorWidget/components/ColorEditor.js +82 -116
- package/dist/ConfigurationEditorWidget/components/ColorEditor.js.map +1 -0
- package/dist/ConfigurationEditorWidget/components/ColorPicker.d.ts +0 -7
- package/dist/ConfigurationEditorWidget/components/ColorPicker.js +64 -67
- package/dist/ConfigurationEditorWidget/components/ColorPicker.js.map +1 -0
- package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.d.ts +7 -3
- package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.js +113 -160
- package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.js.map +1 -0
- package/dist/ConfigurationEditorWidget/components/JsonEditor.js +74 -75
- package/dist/ConfigurationEditorWidget/components/JsonEditor.js.map +1 -0
- package/dist/ConfigurationEditorWidget/components/SlotEditor.d.ts +11 -1
- package/dist/ConfigurationEditorWidget/components/SlotEditor.js +229 -373
- package/dist/ConfigurationEditorWidget/components/SlotEditor.js.map +1 -0
- package/dist/ConfigurationEditorWidget/components/StringArrayEditor.js +76 -105
- package/dist/ConfigurationEditorWidget/components/StringArrayEditor.js.map +1 -0
- package/dist/ConfigurationEditorWidget/components/TypeSelector.d.ts +8 -6
- package/dist/ConfigurationEditorWidget/components/TypeSelector.js +16 -46
- package/dist/ConfigurationEditorWidget/components/TypeSelector.js.map +1 -0
- package/dist/ConfigurationEditorWidget/index.js +25 -42
- package/dist/ConfigurationEditorWidget/index.js.map +1 -0
- package/dist/ConfigurationEditorWidget/model.js +18 -26
- package/dist/ConfigurationEditorWidget/model.js.map +1 -0
- package/dist/FromConfigAdapter/FromConfigAdapter.js +172 -204
- package/dist/FromConfigAdapter/FromConfigAdapter.js.map +1 -0
- package/dist/FromConfigAdapter/FromConfigRegionsAdapter.js +151 -142
- package/dist/FromConfigAdapter/FromConfigRegionsAdapter.js.map +1 -0
- package/dist/FromConfigAdapter/FromConfigSequenceAdapter.js +182 -181
- package/dist/FromConfigAdapter/FromConfigSequenceAdapter.js.map +1 -0
- package/dist/FromConfigAdapter/configSchema.js +33 -49
- package/dist/FromConfigAdapter/configSchema.js.map +1 -0
- package/dist/FromConfigAdapter/index.js +16 -50
- package/dist/FromConfigAdapter/index.js.map +1 -0
- package/dist/RefNameAliasAdapter/RefNameAliasAdapter.js +111 -125
- package/dist/RefNameAliasAdapter/RefNameAliasAdapter.js.map +1 -0
- package/dist/RefNameAliasAdapter/configSchema.js +16 -25
- package/dist/RefNameAliasAdapter/configSchema.js.map +1 -0
- package/dist/RefNameAliasAdapter/index.js +10 -22
- package/dist/RefNameAliasAdapter/index.js.map +1 -0
- package/dist/index.d.ts +9 -3
- package/dist/index.js +129 -144
- package/dist/index.js.map +1 -0
- package/esm/ConfigurationEditorWidget/components/CallbackEditor.d.ts +12 -0
- package/esm/ConfigurationEditorWidget/components/CallbackEditor.js +71 -0
- package/esm/ConfigurationEditorWidget/components/CallbackEditor.js.map +1 -0
- package/esm/ConfigurationEditorWidget/components/CodeEditor.d.ts +5 -0
- package/esm/ConfigurationEditorWidget/components/CodeEditor.js +42 -0
- package/esm/ConfigurationEditorWidget/components/CodeEditor.js.map +1 -0
- package/esm/ConfigurationEditorWidget/components/ColorEditor.d.ts +20 -0
- package/esm/ConfigurationEditorWidget/components/ColorEditor.js +37 -0
- package/esm/ConfigurationEditorWidget/components/ColorEditor.js.map +1 -0
- package/esm/ConfigurationEditorWidget/components/ColorPicker.d.ts +7 -0
- package/esm/ConfigurationEditorWidget/components/ColorPicker.js +26 -0
- package/esm/ConfigurationEditorWidget/components/ColorPicker.js.map +1 -0
- package/esm/ConfigurationEditorWidget/components/ConfigurationEditor.d.ts +8 -0
- package/esm/ConfigurationEditorWidget/components/ConfigurationEditor.js +83 -0
- package/esm/ConfigurationEditorWidget/components/ConfigurationEditor.js.map +1 -0
- package/esm/ConfigurationEditorWidget/components/JsonEditor.d.ts +9 -0
- package/esm/ConfigurationEditorWidget/components/JsonEditor.js +39 -0
- package/esm/ConfigurationEditorWidget/components/JsonEditor.js.map +1 -0
- package/esm/ConfigurationEditorWidget/components/SlotEditor.d.ts +16 -0
- package/esm/ConfigurationEditorWidget/components/SlotEditor.js +176 -0
- package/esm/ConfigurationEditorWidget/components/SlotEditor.js.map +1 -0
- package/esm/ConfigurationEditorWidget/components/StringArrayEditor.d.ts +12 -0
- package/esm/ConfigurationEditorWidget/components/StringArrayEditor.js +36 -0
- package/esm/ConfigurationEditorWidget/components/StringArrayEditor.js.map +1 -0
- package/esm/ConfigurationEditorWidget/components/TypeSelector.d.ts +9 -0
- package/esm/ConfigurationEditorWidget/components/TypeSelector.js +12 -0
- package/esm/ConfigurationEditorWidget/components/TypeSelector.js.map +1 -0
- package/esm/ConfigurationEditorWidget/index.d.ts +3 -0
- package/esm/ConfigurationEditorWidget/index.js +20 -0
- package/esm/ConfigurationEditorWidget/index.js.map +1 -0
- package/esm/ConfigurationEditorWidget/model.d.ts +8 -0
- package/esm/ConfigurationEditorWidget/model.js +16 -0
- package/esm/ConfigurationEditorWidget/model.js.map +1 -0
- package/esm/FromConfigAdapter/FromConfigAdapter.d.ts +24 -0
- package/esm/FromConfigAdapter/FromConfigAdapter.js +63 -0
- package/esm/FromConfigAdapter/FromConfigAdapter.js.map +1 -0
- package/esm/FromConfigAdapter/FromConfigRegionsAdapter.d.ts +23 -0
- package/esm/FromConfigAdapter/FromConfigRegionsAdapter.js +50 -0
- package/esm/FromConfigAdapter/FromConfigRegionsAdapter.js.map +1 -0
- package/esm/FromConfigAdapter/FromConfigSequenceAdapter.d.ts +25 -0
- package/esm/FromConfigAdapter/FromConfigSequenceAdapter.js +73 -0
- package/esm/FromConfigAdapter/FromConfigSequenceAdapter.js.map +1 -0
- package/esm/FromConfigAdapter/configSchema.d.ts +3 -0
- package/esm/FromConfigAdapter/configSchema.js +32 -0
- package/esm/FromConfigAdapter/configSchema.js.map +1 -0
- package/esm/FromConfigAdapter/index.d.ts +4 -0
- package/esm/FromConfigAdapter/index.js +5 -0
- package/esm/FromConfigAdapter/index.js.map +1 -0
- package/esm/RefNameAliasAdapter/RefNameAliasAdapter.d.ts +8 -0
- package/esm/RefNameAliasAdapter/RefNameAliasAdapter.js +24 -0
- package/esm/RefNameAliasAdapter/RefNameAliasAdapter.js.map +1 -0
- package/esm/RefNameAliasAdapter/configSchema.d.ts +2 -0
- package/esm/RefNameAliasAdapter/configSchema.js +15 -0
- package/esm/RefNameAliasAdapter/configSchema.js.map +1 -0
- package/esm/RefNameAliasAdapter/index.d.ts +2 -0
- package/esm/RefNameAliasAdapter/index.js +3 -0
- package/esm/RefNameAliasAdapter/index.js.map +1 -0
- package/esm/index.d.ts +18 -0
- package/esm/index.js +72 -0
- package/esm/index.js.map +1 -0
- package/package.json +20 -13
- package/src/ConfigurationEditorWidget/components/{CallbackEditor.js → CallbackEditor.tsx} +36 -21
- package/src/ConfigurationEditorWidget/components/CodeEditor.tsx +59 -0
- package/src/ConfigurationEditorWidget/components/ColorEditor.tsx +8 -33
- package/src/ConfigurationEditorWidget/components/ColorPicker.tsx +4 -13
- package/src/ConfigurationEditorWidget/components/ConfigurationEditor.tsx +169 -0
- package/src/ConfigurationEditorWidget/components/JsonEditor.js +4 -8
- package/src/ConfigurationEditorWidget/components/SlotEditor.js +10 -11
- package/src/ConfigurationEditorWidget/components/StringArrayEditor.tsx +2 -2
- package/src/ConfigurationEditorWidget/components/{TypeSelector.js → TypeSelector.tsx} +15 -7
- package/src/ConfigurationEditorWidget/components/__snapshots__/ConfigurationEditor.test.js.snap +877 -625
- package/src/index.ts +20 -14
- package/dist/ConfigurationEditorWidget/components/ColorEditor.test.js +0 -31
- package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.test.js +0 -121
- package/dist/FromConfigAdapter/FromConfigAdapter.test.js +0 -100
- package/dist/FromConfigAdapter/FromConfigRegionsAdapter.test.js +0 -200
- package/dist/FromConfigAdapter/FromConfigSequenceAdapter.test.js +0 -110
- package/dist/RefNameAliasAdapter/RefNameAliasAdapter.test.js +0 -41
- package/dist/index.test.js +0 -41
- package/src/ConfigurationEditorWidget/components/CodeEditor.js +0 -60
- package/src/ConfigurationEditorWidget/components/ConfigurationEditor.js +0 -154
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
|
+
import { TextField } from '@mui/material'
|
|
3
|
+
import { makeStyles } from 'tss-react/mui'
|
|
4
|
+
|
|
5
|
+
// fontSize and fontFamily have to match between Editor and SyntaxHighlighter
|
|
6
|
+
const fontSize = '12px'
|
|
7
|
+
// Optimize by using system default fonts: https://css-tricks.com/snippets/css/font-stacks/
|
|
8
|
+
const fontFamily =
|
|
9
|
+
'Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace'
|
|
10
|
+
|
|
11
|
+
const useStyles = makeStyles()(theme => ({
|
|
12
|
+
callbackEditor: {
|
|
13
|
+
fontFamily,
|
|
14
|
+
fontSize,
|
|
15
|
+
background: theme.palette.background.default,
|
|
16
|
+
overflowX: 'auto',
|
|
17
|
+
marginTop: '16px',
|
|
18
|
+
border: '1px solid rgba(0,0,0,0.42)',
|
|
19
|
+
},
|
|
20
|
+
textAreaFont: {
|
|
21
|
+
fontFamily,
|
|
22
|
+
},
|
|
23
|
+
}))
|
|
24
|
+
|
|
25
|
+
export default function CodeEditor({
|
|
26
|
+
contents,
|
|
27
|
+
setContents,
|
|
28
|
+
}: {
|
|
29
|
+
contents: string
|
|
30
|
+
setContents: (arg: string) => void
|
|
31
|
+
}) {
|
|
32
|
+
const { classes } = useStyles()
|
|
33
|
+
const [error, setCodeError] = useState<unknown>()
|
|
34
|
+
const [val, setVal] = useState(contents)
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
try {
|
|
37
|
+
JSON.parse(contents)
|
|
38
|
+
setCodeError(undefined)
|
|
39
|
+
setContents(val)
|
|
40
|
+
} catch (e) {
|
|
41
|
+
console.error({ e })
|
|
42
|
+
setCodeError(e)
|
|
43
|
+
}
|
|
44
|
+
}, [val, contents, setContents])
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<TextField
|
|
48
|
+
className={classes.callbackEditor}
|
|
49
|
+
value={contents}
|
|
50
|
+
onChange={event => setVal(event.target.value)}
|
|
51
|
+
style={{ background: error ? '#fdd' : undefined }}
|
|
52
|
+
InputProps={{
|
|
53
|
+
classes: {
|
|
54
|
+
input: classes.textAreaFont,
|
|
55
|
+
},
|
|
56
|
+
}}
|
|
57
|
+
/>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { lazy, useState } from 'react'
|
|
2
2
|
import { observer } from 'mobx-react'
|
|
3
|
-
import
|
|
4
|
-
import TextField from '@material-ui/core/TextField'
|
|
3
|
+
import { TextField } from '@mui/material'
|
|
5
4
|
import { Color, RGBColor } from 'react-color'
|
|
6
5
|
|
|
7
6
|
const ColorPicker = lazy(() => import('./ColorPicker'))
|
|
@@ -18,14 +17,14 @@ function serializeColor(color: Color) {
|
|
|
18
17
|
|
|
19
18
|
export const ColorSlot = (props: {
|
|
20
19
|
value: string
|
|
21
|
-
label
|
|
22
|
-
TextFieldProps
|
|
20
|
+
label?: string
|
|
21
|
+
TextFieldProps?: {
|
|
23
22
|
helperText: string
|
|
24
23
|
fullWidth: boolean
|
|
25
24
|
}
|
|
26
25
|
onChange: (arg: string) => void
|
|
27
26
|
}) => {
|
|
28
|
-
const { value, label, TextFieldProps, onChange } = props
|
|
27
|
+
const { value = '#000', label = '', TextFieldProps = {}, onChange } = props
|
|
29
28
|
const [displayed, setDisplayed] = useState(false)
|
|
30
29
|
|
|
31
30
|
return (
|
|
@@ -42,35 +41,20 @@ export const ColorSlot = (props: {
|
|
|
42
41
|
},
|
|
43
42
|
}}
|
|
44
43
|
onClick={() => setDisplayed(!displayed)}
|
|
45
|
-
onChange={event =>
|
|
46
|
-
onChange(event.target.value)
|
|
47
|
-
}}
|
|
44
|
+
onChange={event => onChange(event.target.value)}
|
|
48
45
|
{...TextFieldProps}
|
|
49
46
|
/>
|
|
50
47
|
{displayed ? (
|
|
51
48
|
<React.Suspense fallback={<div />}>
|
|
52
49
|
<ColorPicker
|
|
53
50
|
color={value}
|
|
54
|
-
onChange={event =>
|
|
55
|
-
onChange(serializeColor(event.rgb))
|
|
56
|
-
}}
|
|
51
|
+
onChange={event => onChange(serializeColor(event.rgb))}
|
|
57
52
|
/>
|
|
58
53
|
</React.Suspense>
|
|
59
54
|
) : null}
|
|
60
55
|
</>
|
|
61
56
|
)
|
|
62
57
|
}
|
|
63
|
-
ColorSlot.propTypes = {
|
|
64
|
-
onChange: ReactPropTypes.func.isRequired,
|
|
65
|
-
label: ReactPropTypes.string,
|
|
66
|
-
TextFieldProps: ReactPropTypes.shape({}),
|
|
67
|
-
value: ReactPropTypes.string,
|
|
68
|
-
}
|
|
69
|
-
ColorSlot.defaultProps = {
|
|
70
|
-
label: '',
|
|
71
|
-
value: '#000',
|
|
72
|
-
TextFieldProps: {},
|
|
73
|
-
}
|
|
74
58
|
|
|
75
59
|
function ColorEditorSlot(props: {
|
|
76
60
|
slot: {
|
|
@@ -85,9 +69,7 @@ function ColorEditorSlot(props: {
|
|
|
85
69
|
<ColorSlot
|
|
86
70
|
label={slot.name}
|
|
87
71
|
value={slot.value}
|
|
88
|
-
onChange={
|
|
89
|
-
slot.set(color)
|
|
90
|
-
}}
|
|
72
|
+
onChange={color => slot.set(color)}
|
|
91
73
|
TextFieldProps={{
|
|
92
74
|
helperText: slot.description,
|
|
93
75
|
fullWidth: true,
|
|
@@ -95,12 +77,5 @@ function ColorEditorSlot(props: {
|
|
|
95
77
|
/>
|
|
96
78
|
)
|
|
97
79
|
}
|
|
98
|
-
|
|
99
|
-
slot: ReactPropTypes.shape({
|
|
100
|
-
name: ReactPropTypes.string.isRequired,
|
|
101
|
-
description: ReactPropTypes.string,
|
|
102
|
-
value: ReactPropTypes.string.isRequired,
|
|
103
|
-
set: ReactPropTypes.func.isRequired,
|
|
104
|
-
}).isRequired,
|
|
105
|
-
}
|
|
80
|
+
|
|
106
81
|
export default observer(ColorEditorSlot)
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React, { useState } from 'react'
|
|
2
|
-
import { makeStyles } from '
|
|
3
|
-
import ReactPropTypes from 'prop-types'
|
|
2
|
+
import { makeStyles } from 'tss-react/mui'
|
|
4
3
|
import { ChromePicker, Color, ColorResult } from 'react-color'
|
|
5
4
|
|
|
6
|
-
const useStyles = makeStyles({
|
|
5
|
+
const useStyles = makeStyles()({
|
|
7
6
|
popover: {
|
|
8
7
|
position: 'absolute',
|
|
9
8
|
zIndex: 2,
|
|
@@ -22,12 +21,9 @@ export function ColorPicker(props: {
|
|
|
22
21
|
onChange: (color: ColorResult) => void
|
|
23
22
|
}) {
|
|
24
23
|
const { color, onChange } = props
|
|
25
|
-
const classes = useStyles()
|
|
24
|
+
const { classes } = useStyles()
|
|
26
25
|
const [displayColorPicker, setDisplayColorPicker] = useState(true)
|
|
27
26
|
|
|
28
|
-
const handleClose = () => {
|
|
29
|
-
setDisplayColorPicker(false)
|
|
30
|
-
}
|
|
31
27
|
return (
|
|
32
28
|
<div>
|
|
33
29
|
{displayColorPicker ? (
|
|
@@ -35,7 +31,7 @@ export function ColorPicker(props: {
|
|
|
35
31
|
<div
|
|
36
32
|
role="presentation"
|
|
37
33
|
className={classes.cover}
|
|
38
|
-
onClick={
|
|
34
|
+
onClick={() => setDisplayColorPicker(false)}
|
|
39
35
|
/>
|
|
40
36
|
<ChromePicker color={color} onChange={onChange} />
|
|
41
37
|
</div>
|
|
@@ -44,9 +40,4 @@ export function ColorPicker(props: {
|
|
|
44
40
|
)
|
|
45
41
|
}
|
|
46
42
|
|
|
47
|
-
ColorPicker.propTypes = {
|
|
48
|
-
color: ReactPropTypes.string.isRequired,
|
|
49
|
-
onChange: ReactPropTypes.func.isRequired,
|
|
50
|
-
}
|
|
51
|
-
|
|
52
43
|
export default ColorPicker
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import {
|
|
3
|
+
readConfObject,
|
|
4
|
+
getTypeNamesFromExplicitlyTypedUnion,
|
|
5
|
+
isConfigurationSchemaType,
|
|
6
|
+
isConfigurationSlotType,
|
|
7
|
+
AnyConfigurationModel,
|
|
8
|
+
} from '@jbrowse/core/configuration'
|
|
9
|
+
import {
|
|
10
|
+
FormGroup,
|
|
11
|
+
Accordion,
|
|
12
|
+
AccordionDetails,
|
|
13
|
+
AccordionSummary,
|
|
14
|
+
Typography,
|
|
15
|
+
} from '@mui/material'
|
|
16
|
+
import { makeStyles } from 'tss-react/mui'
|
|
17
|
+
import { observer } from 'mobx-react'
|
|
18
|
+
import { getMembers, IAnyType } from 'mobx-state-tree'
|
|
19
|
+
import { singular } from 'pluralize'
|
|
20
|
+
|
|
21
|
+
// icons
|
|
22
|
+
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'
|
|
23
|
+
|
|
24
|
+
// locals
|
|
25
|
+
import SlotEditor from './SlotEditor'
|
|
26
|
+
import TypeSelector from './TypeSelector'
|
|
27
|
+
|
|
28
|
+
const useStyles = makeStyles()(theme => ({
|
|
29
|
+
expandIcon: {
|
|
30
|
+
color: '#fff',
|
|
31
|
+
},
|
|
32
|
+
root: {
|
|
33
|
+
padding: theme.spacing(1, 3, 1, 1),
|
|
34
|
+
},
|
|
35
|
+
expansionPanelDetails: {
|
|
36
|
+
display: 'block',
|
|
37
|
+
padding: theme.spacing(1),
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
accordion: {
|
|
41
|
+
border: `1px solid ${theme.palette.text.primary}`,
|
|
42
|
+
},
|
|
43
|
+
}))
|
|
44
|
+
|
|
45
|
+
const Member = observer(
|
|
46
|
+
(props: {
|
|
47
|
+
slotName: string
|
|
48
|
+
slotSchema: IAnyType
|
|
49
|
+
schema: AnyConfigurationModel
|
|
50
|
+
slot?: AnyConfigurationModel | AnyConfigurationModel[]
|
|
51
|
+
path?: string[]
|
|
52
|
+
}) => {
|
|
53
|
+
const { classes } = useStyles()
|
|
54
|
+
const {
|
|
55
|
+
slotName,
|
|
56
|
+
slotSchema,
|
|
57
|
+
schema,
|
|
58
|
+
slot = schema[slotName],
|
|
59
|
+
path = [],
|
|
60
|
+
} = props
|
|
61
|
+
let typeSelector
|
|
62
|
+
if (isConfigurationSchemaType(slotSchema)) {
|
|
63
|
+
if (slot.length) {
|
|
64
|
+
return slot.map((subslot: AnyConfigurationModel, slotIndex: number) => {
|
|
65
|
+
const key = `${singular(slotName)} ${slotIndex + 1}`
|
|
66
|
+
return <Member {...props} key={key} slot={subslot} slotName={key} />
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
// if this is an explicitly typed schema, make a type-selecting dropdown
|
|
70
|
+
// that can be used to change its type
|
|
71
|
+
const typeNameChoices = getTypeNamesFromExplicitlyTypedUnion(slotSchema)
|
|
72
|
+
if (typeNameChoices.length) {
|
|
73
|
+
typeSelector = (
|
|
74
|
+
<TypeSelector
|
|
75
|
+
typeNameChoices={typeNameChoices}
|
|
76
|
+
slotName={slotName}
|
|
77
|
+
slot={slot}
|
|
78
|
+
onChange={evt => {
|
|
79
|
+
if (evt.target.value !== slot.type) {
|
|
80
|
+
schema.setSubschema(slotName, { type: evt.target.value })
|
|
81
|
+
}
|
|
82
|
+
}}
|
|
83
|
+
/>
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
return (
|
|
87
|
+
<Accordion defaultExpanded className={classes.accordion}>
|
|
88
|
+
<AccordionSummary
|
|
89
|
+
expandIcon={<ExpandMoreIcon className={classes.expandIcon} />}
|
|
90
|
+
>
|
|
91
|
+
<Typography>{[...path, slotName].join('🡒')}</Typography>
|
|
92
|
+
</AccordionSummary>
|
|
93
|
+
<AccordionDetails className={classes.expansionPanelDetails}>
|
|
94
|
+
{typeSelector}
|
|
95
|
+
<FormGroup>
|
|
96
|
+
<Schema schema={slot} path={[...path, slotName]} />
|
|
97
|
+
</FormGroup>
|
|
98
|
+
</AccordionDetails>
|
|
99
|
+
</Accordion>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (isConfigurationSlotType(slotSchema)) {
|
|
104
|
+
// this is a regular config slot
|
|
105
|
+
return <SlotEditor key={slotName} slot={slot} slotSchema={slotSchema} />
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return null
|
|
109
|
+
},
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
const Schema = observer(
|
|
113
|
+
({
|
|
114
|
+
schema,
|
|
115
|
+
path = [],
|
|
116
|
+
}: {
|
|
117
|
+
schema: AnyConfigurationModel
|
|
118
|
+
path?: string[]
|
|
119
|
+
}) => {
|
|
120
|
+
const properties = getMembers(schema).properties
|
|
121
|
+
return (
|
|
122
|
+
<>
|
|
123
|
+
{Object.entries(properties).map(([slotName, slotSchema]) => (
|
|
124
|
+
<Member
|
|
125
|
+
key={slotName}
|
|
126
|
+
slotName={slotName}
|
|
127
|
+
slotSchema={slotSchema}
|
|
128
|
+
path={path}
|
|
129
|
+
schema={schema}
|
|
130
|
+
/>
|
|
131
|
+
))}
|
|
132
|
+
</>
|
|
133
|
+
)
|
|
134
|
+
},
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
const ConfigurationEditor = observer(
|
|
138
|
+
({ model }: { model: { target: AnyConfigurationModel } }) => {
|
|
139
|
+
const { classes } = useStyles()
|
|
140
|
+
// key forces a re-render, otherwise the same field can end up being used
|
|
141
|
+
// for different tracks since only the backing model changes for example
|
|
142
|
+
// see pr #804
|
|
143
|
+
const { target } = model
|
|
144
|
+
const key = target && readConfObject(target, 'trackId')
|
|
145
|
+
const name = target && readConfObject(target, 'name')
|
|
146
|
+
return (
|
|
147
|
+
<>
|
|
148
|
+
<Accordion key={key} defaultExpanded className={classes.accordion}>
|
|
149
|
+
<AccordionSummary
|
|
150
|
+
expandIcon={<ExpandMoreIcon className={classes.expandIcon} />}
|
|
151
|
+
>
|
|
152
|
+
<Typography>{name ?? 'Configuration'}</Typography>
|
|
153
|
+
</AccordionSummary>
|
|
154
|
+
<AccordionDetails
|
|
155
|
+
className={classes.expansionPanelDetails}
|
|
156
|
+
data-testid="configEditor"
|
|
157
|
+
>
|
|
158
|
+
{!target ? 'no target set' : <Schema schema={target} />}
|
|
159
|
+
</AccordionDetails>
|
|
160
|
+
</Accordion>
|
|
161
|
+
|
|
162
|
+
{/* blank space at the bottom of screen allows scroll */}
|
|
163
|
+
<div style={{ height: 300 }} />
|
|
164
|
+
</>
|
|
165
|
+
)
|
|
166
|
+
},
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
export default ConfigurationEditor
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import React, { lazy, useEffect, useState } from 'react'
|
|
2
2
|
import { useDebounce } from '@jbrowse/core/util'
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
FormHelperText,
|
|
6
|
-
InputLabel,
|
|
7
|
-
makeStyles,
|
|
8
|
-
} from '@material-ui/core'
|
|
3
|
+
import { FormControl, FormHelperText, InputLabel } from '@mui/material'
|
|
4
|
+
import { makeStyles } from 'tss-react/mui'
|
|
9
5
|
import { observer, PropTypes } from 'mobx-react'
|
|
10
|
-
const useStyles = makeStyles({
|
|
6
|
+
const useStyles = makeStyles()({
|
|
11
7
|
error: {
|
|
12
8
|
color: 'red',
|
|
13
9
|
fontSize: '0.8em',
|
|
@@ -17,7 +13,7 @@ const useStyles = makeStyles({
|
|
|
17
13
|
const CodeEditor = lazy(() => import('./CodeEditor'))
|
|
18
14
|
|
|
19
15
|
function JsonEditor({ slot }) {
|
|
20
|
-
const classes = useStyles()
|
|
16
|
+
const { classes } = useStyles()
|
|
21
17
|
const [contents, setContents] = useState(
|
|
22
18
|
JSON.stringify(slot.value, null, ' '),
|
|
23
19
|
)
|
|
@@ -22,13 +22,13 @@ import {
|
|
|
22
22
|
Paper,
|
|
23
23
|
SvgIcon,
|
|
24
24
|
TextField,
|
|
25
|
-
|
|
26
|
-
} from '
|
|
25
|
+
} from '@mui/material'
|
|
26
|
+
import { makeStyles } from 'tss-react/mui'
|
|
27
27
|
|
|
28
28
|
// icons
|
|
29
|
-
import DeleteIcon from '@
|
|
30
|
-
import AddIcon from '@
|
|
31
|
-
import RadioButtonUncheckedIcon from '@
|
|
29
|
+
import DeleteIcon from '@mui/icons-material/Delete'
|
|
30
|
+
import AddIcon from '@mui/icons-material/Add'
|
|
31
|
+
import RadioButtonUncheckedIcon from '@mui/icons-material/RadioButtonUnchecked'
|
|
32
32
|
|
|
33
33
|
// locals
|
|
34
34
|
import StringArrayEditor from './StringArrayEditor'
|
|
@@ -39,7 +39,6 @@ import JsonEditor from './JsonEditor'
|
|
|
39
39
|
// adds ability to have html in helperText. note that FormHelperTextProps is
|
|
40
40
|
// div because the default is p which does not like div children
|
|
41
41
|
const MyTextField = props => {
|
|
42
|
-
// eslint-disable-next-line react/prop-types
|
|
43
42
|
const { helperText } = props
|
|
44
43
|
return (
|
|
45
44
|
<TextField
|
|
@@ -79,14 +78,14 @@ const SvgCheckbox = () => (
|
|
|
79
78
|
</SvgIcon>
|
|
80
79
|
)
|
|
81
80
|
|
|
82
|
-
const useMapEditorStyles = makeStyles(theme => ({
|
|
81
|
+
const useMapEditorStyles = makeStyles()(theme => ({
|
|
83
82
|
card: {
|
|
84
83
|
marginTop: theme.spacing(1),
|
|
85
84
|
},
|
|
86
85
|
}))
|
|
87
86
|
|
|
88
87
|
const StringArrayMapEditor = observer(({ slot }) => {
|
|
89
|
-
const classes = useMapEditorStyles()
|
|
88
|
+
const { classes } = useMapEditorStyles()
|
|
90
89
|
const [value, setValue] = useState('')
|
|
91
90
|
return (
|
|
92
91
|
<>
|
|
@@ -155,7 +154,7 @@ const StringArrayMapEditor = observer(({ slot }) => {
|
|
|
155
154
|
})
|
|
156
155
|
|
|
157
156
|
const NumberMapEditor = observer(({ slot }) => {
|
|
158
|
-
const classes = useMapEditorStyles()
|
|
157
|
+
const { classes } = useMapEditorStyles()
|
|
159
158
|
const [value, setValue] = useState('')
|
|
160
159
|
return (
|
|
161
160
|
<>
|
|
@@ -320,7 +319,7 @@ const valueComponents = {
|
|
|
320
319
|
configRelationships: JsonEditor,
|
|
321
320
|
}
|
|
322
321
|
|
|
323
|
-
export const useSlotEditorStyles = makeStyles(theme => ({
|
|
322
|
+
export const useSlotEditorStyles = makeStyles()(theme => ({
|
|
324
323
|
paper: {
|
|
325
324
|
display: 'flex',
|
|
326
325
|
marginBottom: theme.spacing(2),
|
|
@@ -339,7 +338,7 @@ export const useSlotEditorStyles = makeStyles(theme => ({
|
|
|
339
338
|
}))
|
|
340
339
|
|
|
341
340
|
const SlotEditor = observer(({ slot, slotSchema }) => {
|
|
342
|
-
const classes = useSlotEditorStyles()
|
|
341
|
+
const { classes } = useSlotEditorStyles()
|
|
343
342
|
const { type } = slot
|
|
344
343
|
let ValueComponent = slot.isCallback ? CallbackEditor : valueComponents[type]
|
|
345
344
|
if (!ValueComponent) {
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
List,
|
|
11
11
|
ListItem,
|
|
12
12
|
TextField,
|
|
13
|
-
} from '@material
|
|
13
|
+
} from '@mui/material'
|
|
14
14
|
|
|
15
15
|
// icons
|
|
16
|
-
import DeleteIcon from '@
|
|
16
|
+
import DeleteIcon from '@mui/icons-material/Delete'
|
|
17
17
|
|
|
18
18
|
const StringArrayEditor = observer(
|
|
19
19
|
({
|
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
import MenuItem from '@material-ui/core/MenuItem'
|
|
2
|
-
import Paper from '@material-ui/core/Paper'
|
|
3
|
-
import TextField from '@material-ui/core/TextField'
|
|
4
|
-
import { observer } from 'mobx-react'
|
|
5
1
|
import React from 'react'
|
|
2
|
+
import { MenuItem, Paper, TextField } from '@mui/material'
|
|
3
|
+
import { observer } from 'mobx-react'
|
|
6
4
|
import { useSlotEditorStyles } from './SlotEditor'
|
|
5
|
+
import { AnyConfigurationModel } from '@jbrowse/core/configuration'
|
|
7
6
|
|
|
8
7
|
const TypeSelector = observer(
|
|
9
|
-
({
|
|
10
|
-
|
|
8
|
+
({
|
|
9
|
+
typeNameChoices,
|
|
10
|
+
slot,
|
|
11
|
+
slotName,
|
|
12
|
+
onChange,
|
|
13
|
+
}: {
|
|
14
|
+
typeNameChoices: string[]
|
|
15
|
+
slot: AnyConfigurationModel
|
|
16
|
+
slotName: string
|
|
17
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void
|
|
18
|
+
}) => {
|
|
19
|
+
const { classes } = useSlotEditorStyles()
|
|
11
20
|
return (
|
|
12
21
|
<Paper className={classes.paper}>
|
|
13
22
|
<div className={classes.paperContent}>
|
|
@@ -15,7 +24,6 @@ const TypeSelector = observer(
|
|
|
15
24
|
value={slot.type}
|
|
16
25
|
label="Type"
|
|
17
26
|
select
|
|
18
|
-
// error={filterError}
|
|
19
27
|
helperText={`Type of ${slotName} to use`}
|
|
20
28
|
fullWidth
|
|
21
29
|
onChange={onChange}
|