From 7ca321822aed4e2b997104b5ea5f6d6ecbbfc407 Mon Sep 17 00:00:00 2001 From: Andy Herzog Date: Thu, 25 Feb 2021 15:51:59 -0700 Subject: [PATCH 1/4] refactor: remove callbacks from app list --- internal/cli/clients_test.go | 4 ++-- internal/display/clients.go | 38 ++++++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/internal/cli/clients_test.go b/internal/cli/clients_test.go index 9157c12f6..1ca3c295c 100644 --- a/internal/cli/clients_test.go +++ b/internal/cli/clients_test.go @@ -49,9 +49,9 @@ func TestClientsListCmd(t *testing.T) { } expectTable(t, stdout.String(), - []string{"NAME", "TYPE", "CLIENT ID", "CALLBACKS"}, + []string{"NAME", "TYPE", "CLIENT ID"}, [][]string{ - {"some-name", "generic", "some-id", "http://localhost"}, + {"some-name", "generic", "some-id"}, }, ) } diff --git a/internal/display/clients.go b/internal/display/clients.go index 25391fcb1..8e33ca34e 100644 --- a/internal/display/clients.go +++ b/internal/display/clients.go @@ -53,6 +53,41 @@ func (v *clientView) AsTableRow() []string { } +// listClientView is a slimmed down view of a client for displaying +// larger numbers of clients +type listClientView struct { + Name string + Type string + ClientID string + ClientSecret string + revealSecret bool +} + +func (v *listClientView) AsTableHeader() []string { + if v.revealSecret { + return []string{"Name", "Type", "ClientID", "Client Secret"} + } + return []string{"Name", "Type", "Client ID"} + +} + +func (v *listClientView) AsTableRow() []string { + if v.revealSecret { + return []string{ + v.Name, + v.Type, + ansi.Faint(v.ClientID), + ansi.Italic(v.ClientSecret), + } + } + return []string{ + v.Name, + v.Type, + ansi.Faint(v.ClientID), + } + +} + func (r *Renderer) ClientList(clients []*management.Client) { r.Heading(ansi.Bold(r.Tenant), "clients\n") var res []View @@ -60,12 +95,11 @@ func (r *Renderer) ClientList(clients []*management.Client) { if auth0.StringValue(c.Name) == deprecatedAppName { continue } - res = append(res, &clientView{ + res = append(res, &listClientView{ Name: auth0.StringValue(c.Name), Type: appTypeFor(c.AppType), ClientID: auth0.StringValue(c.ClientID), ClientSecret: auth0.StringValue(c.ClientSecret), - Callbacks: callbacksFor(c.Callbacks), }) } From 9c6ee16d69c9f97f4c17382a2881b768c3f4b1c0 Mon Sep 17 00:00:00 2001 From: Andy Herzog Date: Thu, 25 Feb 2021 16:27:49 -0700 Subject: [PATCH 2/4] style: remove comment --- internal/display/clients.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/internal/display/clients.go b/internal/display/clients.go index 8e33ca34e..de652107f 100644 --- a/internal/display/clients.go +++ b/internal/display/clients.go @@ -109,8 +109,6 @@ func (r *Renderer) ClientList(clients []*management.Client) { func (r *Renderer) ClientCreate(client *management.Client, revealSecrets bool) { r.Heading(ansi.Bold(r.Tenant), "client created\n") - // note(jfatta): list and create uses the same view for now, - // eventually we might want to show different columns for each command: v := &clientView{ revealSecret: revealSecrets, Name: auth0.StringValue(client.Name), From aa49a01e6f8f2bbb1f958cde05021009ff5f665b Mon Sep 17 00:00:00 2001 From: Rita Zerrizuela Date: Fri, 26 Feb 2021 16:16:00 -0300 Subject: [PATCH 3/4] Rename clientView to applicationView --- internal/display/clients.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/display/clients.go b/internal/display/clients.go index cbe75c65d..23f41f61e 100644 --- a/internal/display/clients.go +++ b/internal/display/clients.go @@ -17,7 +17,7 @@ const ( quickstartsGeneric = "https://auth0.com/docs/quickstarts" ) -type clientView struct { +type applicationView struct { Name string Type string ClientID string @@ -26,7 +26,7 @@ type clientView struct { revealSecret bool } -func (v *clientView) AsTableHeader() []string { +func (v *applicationView) AsTableHeader() []string { if v.revealSecret { return []string{"Name", "Type", "ClientID", "Client Secret", "Callbacks"} } @@ -34,7 +34,7 @@ func (v *clientView) AsTableHeader() []string { } -func (v *clientView) AsTableRow() []string { +func (v *applicationView) AsTableRow() []string { if v.revealSecret { return []string{ v.Name, @@ -108,7 +108,7 @@ func (r *Renderer) ApplicationList(clients []*management.Client) { func (r *Renderer) ApplicationCreate(client *management.Client, revealSecrets bool) { r.Heading(ansi.Bold(r.Tenant), "application created\n") - v := &clientView{ + v := &applicationView{ revealSecret: revealSecrets, Name: auth0.StringValue(client.Name), Type: appTypeFor(client.AppType), @@ -125,7 +125,7 @@ func (r *Renderer) ApplicationCreate(client *management.Client, revealSecrets bo func (r *Renderer) ApplicationUpdate(client *management.Client, revealSecrets bool) { r.Heading(ansi.Bold(r.Tenant), "application updated\n") - v := &clientView{ + v := &applicationView{ revealSecret: revealSecrets, Name: auth0.StringValue(client.Name), Type: appTypeFor(client.AppType), From ebb5ed4ca22f55cae3a2331c27755ca2f2d46112 Mon Sep 17 00:00:00 2001 From: Rita Zerrizuela Date: Fri, 26 Feb 2021 16:24:53 -0300 Subject: [PATCH 4/4] Rename display/clients.go to display/apps.go --- internal/display/{clients.go => apps.go} | 1 - 1 file changed, 1 deletion(-) rename internal/display/{clients.go => apps.go} (99%) diff --git a/internal/display/clients.go b/internal/display/apps.go similarity index 99% rename from internal/display/clients.go rename to internal/display/apps.go index 23f41f61e..ecc588ac6 100644 --- a/internal/display/clients.go +++ b/internal/display/apps.go @@ -31,7 +31,6 @@ func (v *applicationView) AsTableHeader() []string { return []string{"Name", "Type", "ClientID", "Client Secret", "Callbacks"} } return []string{"Name", "Type", "Client ID", "Callbacks"} - } func (v *applicationView) AsTableRow() []string {