From 3ccb7d314ab7776212a634b96268b0ab0c795b29 Mon Sep 17 00:00:00 2001 From: lprabhu <> Date: Thu, 13 Apr 2023 13:18:59 +0530 Subject: [PATCH] YAML import - added support for list items --- frontend/public/components/edit-yaml.jsx | 17 +++++++++++++++-- frontend/public/locales/en/public.json | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/frontend/public/components/edit-yaml.jsx b/frontend/public/components/edit-yaml.jsx index c23b68429e8..f043a613cf1 100644 --- a/frontend/public/components/edit-yaml.jsx +++ b/frontend/public/components/edit-yaml.jsx @@ -493,8 +493,21 @@ export const EditYAML_ = connect(stateToProps)( return; } if (objs.length === 1) { - this.save(); - return; + if ( + objs[0]?.apiVersion === 'v1' && + objs[0]?.kind?.includes('List') && + objs[0]?.items + ) { + if (objs[0]?.items?.length > 0) { + objs = objs[0].items; + } else { + this.handleError(t('public~"items" list is empty')); + return; + } + } else { + this.save(); + return; + } } else if (objs.length === 0) { return; } diff --git a/frontend/public/locales/en/public.json b/frontend/public/locales/en/public.json index ddea6b73385..1a57486c21e 100644 --- a/frontend/public/locales/en/public.json +++ b/frontend/public/locales/en/public.json @@ -471,6 +471,7 @@ "Cannot change resource namespace (original: \"{{namespace}}\", updated: \"{{newNamespace}}\").": "Cannot change resource namespace (original: \"{{namespace}}\", updated: \"{{newNamespace}}\").", "Cannot change resource kind (original: \"{{original}}\", updated: \"{{updated}}\").": "Cannot change resource kind (original: \"{{original}}\", updated: \"{{updated}}\").", "Cannot change API group (original: \"{{apiGroup}}\", updated: \"{{newAPIGroup}}\").": "Cannot change API group (original: \"{{apiGroup}}\", updated: \"{{newAPIGroup}}\").", + "\"items\" list is empty": "\"items\" list is empty", "Resources in the same namespace and API group must have unique names": "Resources in the same namespace and API group must have unique names", "Failed to parse YAML sample": "Failed to parse YAML sample", "An error occurred.": "An error occurred.",