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 05b5507 commit f50e97d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
9 changes: 8 additions & 1 deletion internal/display/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,14 @@ func (r *Renderer) ApplicationCreate(client *management.Client, revealSecrets bo

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 Down
16 changes: 15 additions & 1 deletion 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 Expand Up @@ -105,7 +109,17 @@ func (r *Renderer) Result(data View) {
// many changes in other places. In the future we should
// enforce `KeyValues` on all `View` types.
if v, ok := data.(interface{ KeyValues() [][]string }); ok {
writeTable(r.ResultWriter, nil, v.KeyValues())
var kvs [][]string
for _, pair := range v.KeyValues() {
k := pair[0]
v := pair[1]

// NOTE(cyx): We can either nuke it or annotate with `<none>`. For now we're choosing to nuke it.
if v != "" {
kvs = append(kvs, []string{k, v})
}
}
writeTable(r.ResultWriter, nil, kvs)
}
}
}
Expand Down

0 comments on commit f50e97d

Please sign in to comment.