Skip to content

Commit 287009e

Browse files
authored
Fix regressions caused by wrong YAML library usage (#2300)
Regression from #2267. In #2267 the YAML library was upgraded to a new version, but the usage of the library was not adjusted to breaking changes. This PR fixes all issues discouvered in the browser console. --------- Signed-off-by: Florian Hotze <[email protected]>
1 parent 1c03c60 commit 287009e

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

bundles/org.openhab.ui/web/src/components/config/controls/script-editor.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,10 @@ export default {
294294
if (parsed.errors.length > 0) {
295295
parsed.errors.forEach((e) => {
296296
const message = e.message
297-
e.makePretty()
298297
found.push({
299298
message: message,
300-
from: (e.linePos.end) ? { line: e.linePos.start.line - 1, ch: e.linePos.start.col - 1 } : undefined,
301-
to: (e.linePos.end) ? { line: e.linePos.end.line - 1, ch: e.linePos.end.col - 1 } : undefined
299+
from: (e.linePos[0]) ? { line: e.linePos[0].line - 1, ch: e.linePos[0].col - 1 } : undefined,
300+
to: (e.linePos[1]) ? { line: e.linePos[1].line - 1, ch: e.linePos[1].col - 1 } : undefined
302301
})
303302
})
304303
}

bundles/org.openhab.ui/web/src/pages/developer/blocks/blocks-edit.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@
101101
</style>
102102

103103
<script>
104-
import YAML, { Schema } from 'yaml'
104+
import YAML from 'yaml'
105105
106106
import BlocklyEditor from '@/components/config/controls/blockly-editor.vue'
107107
import BlockPreview from './block-preview.vue'
108108
import DirtyMixin from '@/pages/settings/dirty-mixin'
109109
110-
Schema.toStringDefaults.lineWidth = 0
110+
const toStringOptions = { toStringDefaults: { lineWidth: 0 } }
111111
112112
export default {
113113
mixins: [DirtyMixin],
@@ -138,7 +138,7 @@ export default {
138138
blocks () {
139139
try {
140140
if (!this.blocksDefinition) return {}
141-
return YAML.parse(this.blocksDefinition, { prettyErrors: true })
141+
return YAML.parse(this.blocksDefinition, { prettyErrors: true, toStringOptions })
142142
} catch (e) {
143143
return { component: 'Error', config: { error: e.message } }
144144
}
@@ -281,14 +281,14 @@ export default {
281281
}
282282
]
283283
}
284-
})
284+
}, { toStringOptions })
285285
this.$nextTick(() => {
286286
this.loading = false
287287
this.ready = true
288288
})
289289
} else {
290290
this.$oh.api.get('/rest/ui/components/ui:blocks/' + this.uid).then((data) => {
291-
this.$set(this, 'blocksDefinition', YAML.stringify(data))
291+
this.$set(this, 'blocksDefinition', YAML.stringify(data, { toStringOptions }))
292292
this.$nextTick(() => {
293293
this.loading = false
294294
this.ready = true

bundles/org.openhab.ui/web/src/pages/developer/widgets/widget-edit.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@
100100
</style>
101101

102102
<script>
103-
import YAML, { Schema } from 'yaml'
103+
import YAML from 'yaml'
104104
105105
import ConfigSheet from '@/components/config/config-sheet.vue'
106106
import DirtyMixin from '@/pages/settings/dirty-mixin'
107107
108108
import * as StandardListWidgets from '@/components/widgets/standard/list'
109109
110-
Schema.toStringDefaults.lineWidth = 0
110+
const toStringOptions = { toStringDefaults: { lineWidth: 0 } }
111111
112112
export default {
113113
mixins: [DirtyMixin],
@@ -152,7 +152,7 @@ export default {
152152
widget () {
153153
try {
154154
if (!this.widgetDefinition) return {}
155-
return YAML.parse(this.widgetDefinition, { prettyErrors: true })
155+
return YAML.parse(this.widgetDefinition, { prettyErrors: true, toStringOptions })
156156
} catch (e) {
157157
return { component: 'Error', config: { error: e.message } }
158158
}
@@ -235,14 +235,14 @@ export default {
235235
footer: '=props.prop1',
236236
content: '=items[props.item].displayState || items[props.item].state'
237237
}
238-
})
238+
}, { toStringOptions })
239239
this.$nextTick(() => {
240240
this.loading = false
241241
this.ready = true
242242
})
243243
} else {
244244
this.$oh.api.get('/rest/ui/components/ui:widget/' + this.uid).then((data) => {
245-
this.$set(this, 'widgetDefinition', YAML.stringify(data))
245+
this.$set(this, 'widgetDefinition', YAML.stringify(data, { toStringOptions }))
246246
this.$nextTick(() => {
247247
this.loading = false
248248
this.ready = true

0 commit comments

Comments
 (0)