Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Commit

Permalink
issue18392 gcr 2.4.z (#899)
Browse files Browse the repository at this point in the history
Signed-off-by: John Swanke <jswanke@redhat.com>
  • Loading branch information
jeswanke committed Jul 6, 2022
1 parent d1999e9 commit 855ed35
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,27 +248,28 @@ export const getTemplateSource = (reverse, parsed) => {

// dig out the yaml and the object that points to it
const yaml = _.get(parsed, `${pathBase}.$yml`)
const baseRow = _.get(parsed, `${pathBase}.$synced`, {$r:0}).$r
const pathReformat = path.length>0 ? pathBase + `.$synced.${pathArray.join('.$v.')}.$v` : pathBase
const synced = _.get(parsed, pathReformat)
if (yaml && synced) {
// capture the source lines
const lines = yaml.split('\n')
// the templates are an array, so we need to iterate over each
if (synced.constructor === Array) {
// the templates are an array, so we need to iterate over each
if (synced.constructor === Array) {
for (let i = 0; i < synced.length; i++) {
const syncItem = synced[i]
if (i+1 < synced.length) {
ret = [...ret, ...lines.slice(syncItem.$r, synced[i+1].$r).join('\n')]
} else {
ret = [...ret, ...lines.slice(syncItem.$r, syncItem.$r+syncItem.$l).join('\n')]
ret = [...ret, ...lines.slice(syncItem.$r-baseRow, synced[i+1].$r-baseRow).join('\n')]
} else {
ret = [...ret, ...lines.slice(syncItem.$r-baseRow, syncItem.$r-baseRow+syncItem.$l).join('\n')]
}
}
// Handle any object that's given and make it an array to try to save it for the user
} else if (synced.constructor === Object) {
for (const key in synced) {
if (Object.prototype.hasOwnProperty.call(synced, key)) {
const syncItem = synced[key]
ret = [...ret, ...` - ${lines.slice(syncItem.$r, syncItem.$r+syncItem.$l).join('\n').trim()}`]
ret = [...ret, ...` - ${lines.slice(syncItem.$r-baseRow, syncItem.$r-baseRow+syncItem.$l).join('\n').trim()}`]
}
}
// Turn any string provided into an array to try to save it for the user
Expand Down
2 changes: 1 addition & 1 deletion src-web/components/common/YamlEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const YamlEditor = ({ onYamlChange, setEditor, yaml, width='49.5vw', height='50v
wordWrap: 'wordWrapColumn',
wordWrapColumn: 132,
wordWrapMinified: false,
scrollBeyondLastLine: false,
scrollBeyondLastLine: true,
smoothScrolling: true,
glyphMargin: true,
tabSize: 2,
Expand Down

0 comments on commit 855ed35

Please sign in to comment.