From b6dbe237fba963617bbc24ede81eb16d25c2c4d3 Mon Sep 17 00:00:00 2001 From: Jan Saidl Date: Thu, 3 Oct 2024 22:45:03 +0200 Subject: [PATCH] fix: report error if selections are empty --- CHANGELOG.md | 5 +++++ src/i18n/en.go | 2 +- src/uxHelpers/org.go | 4 +--- src/uxHelpers/project.go | 4 +--- src/uxHelpers/service.go | 4 +--- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e17a667f..de74c2d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v1.0.27] - 2024-10-03 + +### Fixed +- report error if selections are empty + ## [v1.0.26] - 2024-09-10 ### Changed diff --git a/src/i18n/en.go b/src/i18n/en.go index 957cde63..ff80c19e 100644 --- a/src/i18n/en.go +++ b/src/i18n/en.go @@ -301,7 +301,7 @@ at https://docs.zerops.io/references/cli for further details.`, ProjectSelectorListEmpty: "You don't have any projects yet. Create a new project using `zcli project import` command.", ProjectSelectorPrompt: "Please, select a project", ProjectSelectorOutOfRangeError: "We couldn't find a project with the index you entered. Please, try again or contact our support team.", - ServiceSelectorListEmpty: "Project doesn't have any services yet. Create a new service using `zcli service import` command", + ServiceSelectorListEmpty: "Project doesn't have any services yet. Create a new service using `zcli project service-import` command", ServiceSelectorPrompt: "Please, select a service", ServiceSelectorOutOfRangeError: "We couldn't find a service with the index you entered. Please, try again or contact our support team.", OrgSelectorListEmpty: "You don't belong to any organization yet. Please, contact our support team.", diff --git a/src/uxHelpers/org.go b/src/uxHelpers/org.go index 7a8b3462..73c0d00c 100644 --- a/src/uxHelpers/org.go +++ b/src/uxHelpers/org.go @@ -8,7 +8,6 @@ import ( "github.com/zeropsio/zcli/src/entity/repository" "github.com/zeropsio/zcli/src/i18n" "github.com/zeropsio/zcli/src/uxBlock" - "github.com/zeropsio/zcli/src/uxBlock/styles" "github.com/zeropsio/zcli/src/zeropsRestApiClient" ) @@ -23,8 +22,7 @@ func PrintOrgSelector( } if len(orgs) == 0 { - uxBlocks.PrintWarning(styles.WarningLine(i18n.T(i18n.OrgSelectorListEmpty))) - return nil, nil + return nil, errors.New(i18n.T(i18n.OrgSelectorListEmpty)) } header, tableBody := createOrgTableRows(orgs) diff --git a/src/uxHelpers/project.go b/src/uxHelpers/project.go index 3d7dcde1..6c2a1ffe 100644 --- a/src/uxHelpers/project.go +++ b/src/uxHelpers/project.go @@ -8,7 +8,6 @@ import ( "github.com/zeropsio/zcli/src/entity/repository" "github.com/zeropsio/zcli/src/i18n" "github.com/zeropsio/zcli/src/uxBlock" - "github.com/zeropsio/zcli/src/uxBlock/styles" "github.com/zeropsio/zcli/src/zeropsRestApiClient" ) @@ -23,8 +22,7 @@ func PrintProjectSelector( } if len(projects) == 0 { - uxBlocks.PrintWarning(styles.WarningLine(i18n.T(i18n.ProjectSelectorListEmpty))) - return nil, nil + return nil, errors.New(i18n.T(i18n.ProjectSelectorPrompt)) } header, tableBody := createProjectTableRows(projects) diff --git a/src/uxHelpers/service.go b/src/uxHelpers/service.go index 86772b67..5f4a7a7f 100644 --- a/src/uxHelpers/service.go +++ b/src/uxHelpers/service.go @@ -8,7 +8,6 @@ import ( "github.com/zeropsio/zcli/src/entity/repository" "github.com/zeropsio/zcli/src/i18n" "github.com/zeropsio/zcli/src/uxBlock" - "github.com/zeropsio/zcli/src/uxBlock/styles" "github.com/zeropsio/zcli/src/zeropsRestApiClient" ) @@ -24,8 +23,7 @@ func PrintServiceSelector( } if len(services) == 0 { - uxBlocks.PrintWarning(styles.WarningLine(i18n.T(i18n.ServiceSelectorListEmpty))) - return nil, nil + return nil, errors.New(i18n.T(i18n.ServiceSelectorListEmpty)) } header, rows := createServiceTableRows(services)