From 24e6d11a7671ad06501b14d41f547f33e0b88bf0 Mon Sep 17 00:00:00 2001 From: Will Vedder Date: Mon, 13 Nov 2023 11:18:45 -0500 Subject: [PATCH 1/5] Adding active column to auth0 tenants list --- internal/cli/root.go | 2 +- internal/display/tenants.go | 19 +++++++++++-------- test/integration/test-cases.yaml | 12 +++++++++--- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/internal/cli/root.go b/internal/cli/root.go index e4d39d2ff..b6d467058 100644 --- a/internal/cli/root.go +++ b/internal/cli/root.go @@ -86,6 +86,7 @@ func buildRootCmd(cli *cli) *cobra.Command { PersistentPreRunE: func(cmd *cobra.Command, args []string) error { ansi.Initialize(cli.noColor) prepareInteractivity(cmd) + cli.configureRenderer() if !commandRequiresAuthentication(cmd.CommandPath()) { return nil @@ -105,7 +106,6 @@ func buildRootCmd(cli *cli) *cobra.Command { return err } - cli.configureRenderer() return nil }, } diff --git a/internal/display/tenants.go b/internal/display/tenants.go index e6faa165f..863f2524c 100644 --- a/internal/display/tenants.go +++ b/internal/display/tenants.go @@ -1,16 +1,20 @@ package display type tenantView struct { - Name string - raw interface{} + Active bool + Name string + raw interface{} } func (v *tenantView) AsTableHeader() []string { - return []string{"Available tenants"} + return []string{"Active", "Tenant"} } func (v *tenantView) AsTableRow() []string { - return []string{v.Name} + return []string{ + boolean(v.Active), + v.Name, + } } func (v *tenantView) Object() interface{} { @@ -18,8 +22,6 @@ func (v *tenantView) Object() interface{} { } func (r *Renderer) TenantList(data []string) { - r.Heading() - if len(data) == 0 { r.EmptyState("tenants", "Use 'auth0 login' to add one") return @@ -28,8 +30,9 @@ func (r *Renderer) TenantList(data []string) { var results []View for _, item := range data { results = append(results, &tenantView{ - Name: item, - raw: item, + Active: item == r.Tenant, + Name: item, + raw: item, }) } diff --git a/test/integration/test-cases.yaml b/test/integration/test-cases.yaml index d3076199c..45ae2f1b4 100644 --- a/test/integration/test-cases.yaml +++ b/test/integration/test-cases.yaml @@ -3,9 +3,6 @@ config: retries: 1 tests: - auth0 tenants list: - exit-code: 0 - auth0 completion bash: exit-code: 0 @@ -100,6 +97,15 @@ tests: - STAGE_PRE_USER_REGISTRATION_RATE exit-code: 0 + tenants list: + command: auth0 tenants list + exit-code: 0 + stdout: + contains: + - ACTIVE + - NAME + - ✓ + tenants use: command: auth0 tenants use $AUTH0_DOMAIN exit-code: 0 From 7e3c8ae3ed903a285cb49e475a9242bb76eab932 Mon Sep 17 00:00:00 2001 From: Will Vedder Date: Mon, 13 Nov 2023 12:03:31 -0500 Subject: [PATCH 2/5] Fixing test case --- test/integration/test-cases.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/test-cases.yaml b/test/integration/test-cases.yaml index 45ae2f1b4..af30fc6b4 100644 --- a/test/integration/test-cases.yaml +++ b/test/integration/test-cases.yaml @@ -103,7 +103,7 @@ tests: stdout: contains: - ACTIVE - - NAME + - TENANT - ✓ tenants use: From 8187d4e8d5bf992e41a537beb5034caf844f731a Mon Sep 17 00:00:00 2001 From: Will Vedder Date: Mon, 13 Nov 2023 13:45:12 -0500 Subject: [PATCH 3/5] Removing red X for inactive tenant --- internal/display/tenants.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/display/tenants.go b/internal/display/tenants.go index 863f2524c..01bb4f637 100644 --- a/internal/display/tenants.go +++ b/internal/display/tenants.go @@ -11,8 +11,13 @@ func (v *tenantView) AsTableHeader() []string { } func (v *tenantView) AsTableRow() []string { + activeText := "" + if v.Active { + activeText = boolean(v.Active) + } + return []string{ - boolean(v.Active), + activeText, v.Name, } } From 714b90211a40d1a253149ee8fe7547f89350a339 Mon Sep 17 00:00:00 2001 From: Will Vedder Date: Tue, 14 Nov 2023 10:30:28 -0500 Subject: [PATCH 4/5] Changing checkmark to arrwo --- internal/display/tenants.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/display/tenants.go b/internal/display/tenants.go index 01bb4f637..69f2802a9 100644 --- a/internal/display/tenants.go +++ b/internal/display/tenants.go @@ -1,5 +1,7 @@ package display +import "github.com/auth0/auth0-cli/internal/ansi" + type tenantView struct { Active bool Name string @@ -13,7 +15,7 @@ func (v *tenantView) AsTableHeader() []string { func (v *tenantView) AsTableRow() []string { activeText := "" if v.Active { - activeText = boolean(v.Active) + activeText = ansi.Green("→") } return []string{ From ff2e3a45891cfe22cf29fc89152373d84e5b9f16 Mon Sep 17 00:00:00 2001 From: Will Vedder Date: Tue, 14 Nov 2023 12:11:47 -0500 Subject: [PATCH 5/5] Updating test case --- test/integration/test-cases.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/test-cases.yaml b/test/integration/test-cases.yaml index af30fc6b4..4461a0320 100644 --- a/test/integration/test-cases.yaml +++ b/test/integration/test-cases.yaml @@ -104,7 +104,7 @@ tests: contains: - ACTIVE - TENANT - - ✓ + - → tenants use: command: auth0 tenants use $AUTH0_DOMAIN