From 1dcd462fd709755b406768e0bf716dcbb779abd5 Mon Sep 17 00:00:00 2001 From: Nikita Karetnikov Date: Mon, 8 Jan 2024 03:29:18 +0100 Subject: [PATCH] Get back to using `formatCode` The custom pretty-printer is there to avoid printing `[]` when no data is available, which is not very user-friendly. --- .../Specification/SpecificationCreate.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/features/environmentCreate/components/Specification/SpecificationCreate.tsx b/src/features/environmentCreate/components/Specification/SpecificationCreate.tsx index 02c2ffd5..d7b14a24 100644 --- a/src/features/environmentCreate/components/Specification/SpecificationCreate.tsx +++ b/src/features/environmentCreate/components/Specification/SpecificationCreate.tsx @@ -81,6 +81,21 @@ export const SpecificationCreate = ({ onCreateEnvironment }: any) => { setShow(value); }; + const formatCode = ( + channels: string[], + dependencies: string[], + variables: Record + ) => { + if ( + channels.length === 0 && + dependencies.length === 0 && + Object.keys(variables).length === 0 + ) { + return "channels:\n -\ndependencies:\n -\nvariables: {}"; + } + return stringify({ channels, dependencies, variables }); + }; + const handleSubmit = () => { const code = show ? editorContent @@ -104,7 +119,7 @@ export const SpecificationCreate = ({ onCreateEnvironment }: any) => { {show ? ( ) : (