Skip to content

Commit

Permalink
Filter empty value in ManifestPreview component
Browse files Browse the repository at this point in the history
#708 (comment)

Signed-off-by: Sunghoon Kang <hoon@akuity.io>
  • Loading branch information
Sunghoon Kang committed Sep 13, 2023
1 parent 1b75083 commit 8d55b12
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ui/src/features/stage/manifest-preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,14 @@ import { Stage } from '@ui/gen/v1alpha1/types_pb';
import YamlEditor from '../common/code-editor/yaml-editor-lazy';

export const ManifestPreview = ({ stage }: { stage: Stage }) => {
return <YamlEditor value={yaml.stringify(stage)} height='500px' disabled />;
const encodedStage = yaml.stringify(stage.toJson(), (_, v) => {
if (typeof v === 'string' && v === '') {
return;
}
if (Array.isArray(v) && v.length === 0) {
return;
}
return v;
});
return <YamlEditor value={encodedStage} height='500px' disabled />;
};

0 comments on commit 8d55b12

Please sign in to comment.