Skip to content

Commit

Permalink
Use undefined featureData by default instead of empty object
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Dec 21, 2020
1 parent 6521039 commit 2eaf1c2
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
4 changes: 4 additions & 0 deletions packages/core/BaseFeatureWidget/BaseFeatureDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,10 @@ const Subfeature = (props: BaseProps) => {
export const BaseFeatureDetails = observer((props: BaseInputProps) => {
const classes = useStyles()
const { model } = props

if (!model.featureData) {
return null
}
const feature = JSON.parse(JSON.stringify(model.featureData))
return (
<Paper className={classes.paperRoot}>
Expand Down
4 changes: 2 additions & 2 deletions packages/core/BaseFeatureWidget/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ const stateModel = types
.model('BaseFeatureWidget', {
id: ElementId,
type: types.literal('BaseFeatureWidget'),
featureData: types.frozen({}),
featureData: types.frozen(),
})
.actions(self => ({
setFeatureData(data: Record<string, unknown>) {
self.featureData = data
},
clearFeatureData() {
self.featureData = {}
self.featureData = undefined
},
}))

Expand Down
4 changes: 2 additions & 2 deletions plugins/alignments/src/AlignmentsFeatureDetail/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ const stateModel = types
.model('AlignmentsFeatureWidget', {
id: ElementId,
type: types.literal('AlignmentsFeatureWidget'),
featureData: types.frozen({}),
featureData: types.frozen(),
})
.actions(self => ({
setFeatureData(data) {
self.featureData = data
},
clearFeatureData() {
self.featureData = {}
self.featureData = undefined
},
}))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import ReactComponent from './AlignmentsFeatureDetail'

test('open up a widget', () => {
const model = stateModel.create({ type: 'AlignmentsFeatureWidget' })
const { container, getByText } = render(<ReactComponent model={model} />)
model.setFeatureData({
seq:
'TTGTTGCGGAGTTGAACAACGGCATTAGGAACACTTCCGTCTCTCACTTTTATACGATTATGATTGGTTCTTTAGCCTTGGTTTAGATTGGTAGTAGTAG',
Expand All @@ -29,6 +28,7 @@ test('open up a widget', () => {
refName: 'ctgA',
type: 'match',
})
const { container, getByText } = render(<ReactComponent model={model} />)
expect(container.firstChild).toMatchSnapshot()
expect(getByText('ctgA:3..102 (+)')).toBeTruthy()
})
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ const stateModel = types
.model('BreakpointAlignmentsWidget', {
id: ElementId,
type: types.literal('BreakpointAlignmentsWidget'),
featureData: types.frozen({}),
featureData: types.frozen(),
})
.actions(self => ({
setFeatureData(data) {
self.featureData = data
},
clearFeatureData() {
self.featureData = {}
self.featureData = undefined
},
}))

Expand Down
4 changes: 2 additions & 2 deletions plugins/variants/src/VariantFeatureWidget/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ export const stateModel = types
.model('VariantFeatureWidget', {
id: ElementId,
type: types.literal('VariantFeatureWidget'),
featureData: types.frozen({}),
featureData: types.frozen(),
})
.actions(self => ({
setFeatureData(data) {
self.featureData = data
},
clearFeatureData() {
self.featureData = {}
self.featureData = undefined
},
}))

Expand Down

0 comments on commit 2eaf1c2

Please sign in to comment.