Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove callbacks from app list [CLI-36] #110

Merged
merged 5 commits into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/cli/apps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
},
)
}
50 changes: 40 additions & 10 deletions internal/display/clients.go → internal/display/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (
quickstartsGeneric = "https://auth0.com/docs/quickstarts"
)

type clientView struct {
type applicationView struct {
Name string
Type string
ClientID string
Expand All @@ -26,15 +26,14 @@ 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"}
}
return []string{"Name", "Type", "Client ID", "Callbacks"}

}

func (v *clientView) AsTableRow() []string {
func (v *applicationView) AsTableRow() []string {
if v.revealSecret {
return []string{
v.Name,
Expand All @@ -53,19 +52,52 @@ func (v *clientView) AsTableRow() []string {

}

// applicationListView is a slimmed down view of a client for displaying
// larger numbers of applications
type applicationListView struct {
Name string
Type string
ClientID string
ClientSecret string
revealSecret bool
}

func (v *applicationListView) AsTableHeader() []string {
if v.revealSecret {
return []string{"Name", "Type", "ClientID", "Client Secret"}
}
return []string{"Name", "Type", "Client ID"}

}

func (v *applicationListView) 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) ApplicationList(clients []*management.Client) {
r.Heading(ansi.Bold(r.Tenant), "applications\n")
var res []View
for _, c := range clients {
if auth0.StringValue(c.Name) == deprecatedAppName {
continue
}
res = append(res, &clientView{
res = append(res, &applicationListView{
Name: auth0.StringValue(c.Name),
Type: appTypeFor(c.AppType),
ClientID: auth0.StringValue(c.ClientID),
ClientSecret: auth0.StringValue(c.ClientSecret),
Callbacks: callbacksFor(c.Callbacks),
})
}

Expand All @@ -75,9 +107,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")

// note(jfatta): list and create uses the same view for now,
// eventually we might want to show different columns for each command:
v := &clientView{
v := &applicationView{
revealSecret: revealSecrets,
Name: auth0.StringValue(client.Name),
Type: appTypeFor(client.AppType),
Expand All @@ -94,7 +124,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),
Expand Down