Skip to content

Commit

Permalink
fix: Revert "split arrays in yaml to fix ambiguous collapse when arra…
Browse files Browse the repository at this point in the history
…y items have nested objects (argoproj#21064)" (argoproj#22099) (argoproj#22128)

Signed-off-by: Andrii Korotkov <[email protected]>
  • Loading branch information
andrii-korotkov-verkada authored Mar 3, 2025
1 parent c71dd1a commit f542ae5
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions ui/src/app/shared/components/yaml-editor/yaml-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,6 @@ import {MonacoEditor} from '../monaco-editor';
const jsonMergePatch = require('json-merge-patch');
require('./yaml-editor.scss');

const formatYamlWithArrays = (input: any): string => {
// First, get the basic YAML
let yaml = jsYaml.dump(input, {
indent: 2,
lineWidth: -1,
noArrayIndent: false
});

// Format nested arrays to improve readability when collapsed
yaml = yaml.replace(/(\s+)(-\s*)(\w+):/g, (match, indent, dash, key) => {
return `${indent}-${indent} ${key}:`;
});

return yaml;
};

export class YamlEditor<T> extends React.Component<
{
input: T;
Expand All @@ -49,7 +33,7 @@ export class YamlEditor<T> extends React.Component<

public render() {
const props = this.props;
const yaml = props.input ? formatYamlWithArrays(props.input) : '';
const yaml = props.input ? jsYaml.dump(props.input) : '';

return (
<div className='yaml-editor'>
Expand Down

0 comments on commit f542ae5

Please sign in to comment.