Skip to content

Commit

Permalink
apps: improve UX on create and show screens
Browse files Browse the repository at this point in the history
for create / update / show, we should utilize the key value display.

Similarly, add the hint to guide the user what to do next.
  • Loading branch information
cyx committed Mar 6, 2021
1 parent 5c5a741 commit 80bf380
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
36 changes: 23 additions & 13 deletions internal/display/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,28 @@ func (v *applicationView) AsTableRow() []string {
}

func (v *applicationView) KeyValues() [][]string {
callbacks := strings.Join(v.Callbacks, ", ")

var result [][]string
if v.revealSecret {
return [][]string{
result = [][]string{
[]string{"NAME", v.Name},
[]string{"TYPE", v.Type},
[]string{"CLIENT ID", ansi.Faint(v.ClientID)},
[]string{"CLIENT SECRET", ansi.Italic(v.ClientSecret)},
[]string{"CALLBACKS", callbacks},
}

} else {
result = [][]string{
[]string{"NAME", v.Name},
[]string{"TYPE", v.Type},
[]string{"CLIENT ID", ansi.Faint(v.ClientID)},
}
}

return [][]string{
[]string{"NAME", v.Name},
[]string{"TYPE", v.Type},
[]string{"CLIENT ID", ansi.Faint(v.ClientID)},
[]string{"CALLBACKS", callbacks},
if len(v.Callbacks) > 0 {
cb := strings.Join(v.Callbacks, ", ")
result = append(result, []string{"CALLBACKS", cb})
}

return result
}

func (v *applicationView) Object() interface{} {
Expand Down Expand Up @@ -160,9 +163,16 @@ func (r *Renderer) ApplicationCreate(client *management.Client, revealSecrets bo
raw: client,
}

r.Results([]View{v})
r.Result(v)

r.Infof("\nQuickstarts: %s", quickstartsURIFor(client.AppType))
r.Newline()
r.Infof("Quickstarts: %s", quickstartsURIFor(client.AppType))

// TODO(cyx): possibly guard this with a --no-hint flag.
r.Infof("%s: You might wanna try `auth0 test login --client-id %s`",
ansi.Faint("Hint"),
client.GetClientID(),
)
}

func (r *Renderer) ApplicationUpdate(client *management.Client, revealSecrets bool) {
Expand All @@ -178,7 +188,7 @@ func (r *Renderer) ApplicationUpdate(client *management.Client, revealSecrets bo
raw: client,
}

r.Results([]View{v})
r.Result(v)
}

// TODO(cyx): determine if there's a better way to filter this out.
Expand Down
4 changes: 4 additions & 0 deletions internal/display/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ func NewRenderer() *Renderer {
}
}

func (r *Renderer) Newline() {
fmt.Fprintln(r.MessageWriter)
}

func (r *Renderer) Infof(format string, a ...interface{}) {
fmt.Fprint(r.MessageWriter, aurora.Green(" ▸ "))
fmt.Fprintf(r.MessageWriter, format+"\n", a...)
Expand Down

0 comments on commit 80bf380

Please sign in to comment.