Skip to content

Commit

Permalink
Merge pull request #125 from auth0/actions-show-to-key-value-list
Browse files Browse the repository at this point in the history
  • Loading branch information
Widcket authored Mar 5, 2021
2 parents e579921 + 69bfae0 commit 5042e68
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 9 deletions.
14 changes: 7 additions & 7 deletions internal/cli/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func testActionCmd(cli *cli) *cobra.Command {
Use: "test",
Args: cobra.MaximumNArgs(1),
Short: "Test an action draft against a payload",
Long: `Test an action draft against a payload:
Long: `Test an action draft against a payload:
auth0 actions test <id> --file payload.json`,
PreRun: func(cmd *cobra.Command, args []string) {
Expand Down Expand Up @@ -193,8 +193,8 @@ func deployActionCmd(cli *cli) *cobra.Command {
Use: "deploy",
Args: cobra.MaximumNArgs(1),
Short: "Deploy the action version",
Long: `Deploy the action version:
Long: `Deploy the action version:
auth0 actions deploy <id> --version version-id`,
PreRun: func(cmd *cobra.Command, args []string) {
prepareInteractivity(cmd)
Expand Down Expand Up @@ -290,7 +290,7 @@ func downloadActionCmd(cli *cli) *cobra.Command {
Use: "download",
Args: cobra.MaximumNArgs(1),
Short: "Download an action",
Long: `Download an action:
Long: `Download an action:
auth0 actions download <id> --version <version-id | draft>`,
PreRun: func(cmd *cobra.Command, args []string) {
Expand Down Expand Up @@ -383,7 +383,7 @@ func listActionVersionsCmd(cli *cli) *cobra.Command {
Use: "versions",
Args: cobra.MaximumNArgs(1),
Short: "List the action versions",
Long: `List the action versions:
Long: `List the action versions:
auth0 actions versions <id>`,
PreRun: func(cmd *cobra.Command, args []string) {
Expand Down Expand Up @@ -756,7 +756,7 @@ func updateFlowCmd(cli *cli) *cobra.Command {
Use: "update",
Args: cobra.MaximumNArgs(1),
Short: "Update actions by flow",
Long: `Update actions by flow:
Long: `Update actions by flow:
auth0 actions flows update <trigger> --file bindings.json`,
PreRun: func(cmd *cobra.Command, args []string) {
Expand Down Expand Up @@ -837,7 +837,7 @@ func bindActionCmd(cli *cli) *cobra.Command {
Use: "bind",
Args: cobra.MaximumNArgs(1),
Short: "Bind an action to a flow",
Long: `Bind an action to a flow:
Long: `Bind an action to a flow:
auth0 actions bind <id> --trigger post-login`,
PreRun: func(cmd *cobra.Command, args []string) {
Expand Down
39 changes: 37 additions & 2 deletions internal/display/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type actionView struct {
Name string
CreatedAt string
Type string
raw interface{}
}

func (v *actionView) AsTableHeader() []string {
Expand All @@ -24,6 +25,19 @@ func (v *actionView) AsTableRow() []string {
return []string{v.ID, v.Name, v.Type, v.CreatedAt}
}

func (v *actionView) KeyValues() [][]string {
return [][]string{
[]string{"ID", v.ID},
[]string{"NAME", v.Name},
[]string{"TYPE", v.Type},
[]string{"CREATED AT", v.CreatedAt},
}
}

func (v *actionView) Object() interface{} {
return v.raw
}

type triggerView struct {
ID string
ActionID string
Expand All @@ -47,6 +61,8 @@ type actionVersionView struct {
Status string
Deployed string
CreatedAt string

raw interface{}
}

func (v *actionVersionView) AsTableHeader() []string {
Expand All @@ -57,6 +73,23 @@ func (v *actionVersionView) AsTableRow() []string {
return []string{v.Number, v.getID(), v.ActionID, v.ActionName, v.Runtime, v.Status, v.CreatedAt, v.Deployed}
}

func (v *actionVersionView) KeyValues() [][]string {
return [][]string{
[]string{"Number", v.Number},
[]string{"ID", v.getID()},
[]string{"ActionID", v.ActionID},
[]string{"ActionName", v.ActionName},
[]string{"RUNTIME", v.ActionName},
[]string{"STATUS", v.Status},
[]string{"CREATED AT", v.CreatedAt},
[]string{"DEPLOYED", v.Deployed},
}
}

func (v *actionVersionView) Object() interface{} {
return v.raw
}

func (v *actionVersionView) getID() string {
// draft versions don't have a unique id
if v.ID == "" {
Expand All @@ -78,9 +111,9 @@ func (r *Renderer) ActionList(actions []*management.Action) {
res = append(res, &actionView{
ID: auth0.StringValue(a.ID),
Name: auth0.StringValue(a.Name),
CreatedAt: timeAgo(auth0.TimeValue(a.CreatedAt)),
Type: strings.Join(triggers, ", "),
// Runtime: auth0.StringValue(a.Runtime),
CreatedAt: timeAgo(auth0.TimeValue(a.CreatedAt)),
raw: a,
})

}
Expand All @@ -106,6 +139,7 @@ func (r *Renderer) Action(action *management.Action) {
Name: auth0.StringValue(action.Name),
CreatedAt: timeAgo(auth0.TimeValue(action.CreatedAt)),
Type: strings.Join(triggers, ", "),
raw: action,
}

r.Results([]View{v})
Expand Down Expand Up @@ -142,6 +176,7 @@ func ActionVersionView(version *management.ActionVersion) *actionVersionView {
Status: string(version.Status),
Deployed: deployed,
CreatedAt: timeAgo(auth0.TimeValue(version.CreatedAt)),
raw: version,
}
}

Expand Down

0 comments on commit 5042e68

Please sign in to comment.