Skip to content

Commit

Permalink
Rename branding cmd to universal-login
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught committed Dec 3, 2022
1 parent b55545f commit 5ede670
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,56 +37,58 @@ var (
}
)

type brandingTextsInputs struct {
type promptsTextInput struct {
Prompt string
Language string
Body string
}

func textsCmd(cli *cli) *cobra.Command {
func universalLoginPromptsTextCmd(cli *cli) *cobra.Command {
cmd := &cobra.Command{
Use: "texts",
Short: "Manage custom text for prompts",
Long: "Manage custom text for prompts.",
Use: "prompts",
Short: "Manage custom text for prompts",
Long: fmt.Sprintf("Manage custom [text for prompts](%s).", textDocsURL),
Aliases: []string{"texts"},
}

cmd.SetUsageTemplate(resourceUsageTemplate())
cmd.AddCommand(showBrandingTextCmd(cli))
cmd.AddCommand(updateBrandingTextCmd(cli))

cmd.AddCommand(showPromptsTextCmd(cli))
cmd.AddCommand(updatePromptsTextCmd(cli))

return cmd
}

func showBrandingTextCmd(cli *cli) *cobra.Command {
var inputs brandingTextsInputs
func showPromptsTextCmd(cli *cli) *cobra.Command {
var inputs promptsTextInput

cmd := &cobra.Command{
Use: "show",
Args: cobra.ExactArgs(1),
Short: "Show the custom texts for a prompt",
Long: "Show the custom texts for a prompt.",
Short: "Show the custom text for a prompt",
Long: "Show the custom text for a prompt.",
Example: `
auth0 branding texts show <prompt> --language es
auth0 branding texts show <prompt> -l es`,
RunE: showBrandingTexts(cli, &inputs),
auth0 universal-login prompts show <prompt> --language es
auth0 universal-login prompts show <prompt> -l es`,
RunE: showPromptsText(cli, &inputs),
}

textLanguage.RegisterString(cmd, &inputs.Language, textLanguageDefault)

return cmd
}

func updateBrandingTextCmd(cli *cli) *cobra.Command {
var inputs brandingTextsInputs
func updatePromptsTextCmd(cli *cli) *cobra.Command {
var inputs promptsTextInput

cmd := &cobra.Command{
Use: "update",
Args: cobra.ExactArgs(1),
Short: "Update the custom texts for a prompt",
Long: "Update the custom texts for a prompt.",
Short: "Update the custom text for a prompt",
Long: "Update the custom text for a prompt.",
Example: `
auth0 branding texts update <prompt> --language es
auth0 branding texts update <prompt> -l es`,
auth0 universal-login prompts update <prompt> --language es
auth0 universal-login prompts update <prompt> -l es`,
RunE: updateBrandingText(cli, &inputs),
}

Expand All @@ -95,7 +97,7 @@ auth0 branding texts update <prompt> -l es`,
return cmd
}

func showBrandingTexts(cli *cli, inputs *brandingTextsInputs) func(cmd *cobra.Command, args []string) error {
func showPromptsText(cli *cli, inputs *promptsTextInput) func(cmd *cobra.Command, args []string) error {
return func(cmd *cobra.Command, args []string) error {
inputs.Prompt = args[0]
brandingText := make(map[string]interface{})
Expand Down Expand Up @@ -123,7 +125,7 @@ func showBrandingTexts(cli *cli, inputs *brandingTextsInputs) func(cmd *cobra.Co
}
}

func updateBrandingText(cli *cli, inputs *brandingTextsInputs) func(cmd *cobra.Command, args []string) error {
func updateBrandingText(cli *cli, inputs *promptsTextInput) func(cmd *cobra.Command, args []string) error {
return func(cmd *cobra.Command, args []string) error {
inputs.Prompt = args[0]
inputs.Body = string(iostream.PipedInput())
Expand Down Expand Up @@ -160,7 +162,7 @@ func updateBrandingText(cli *cli, inputs *brandingTextsInputs) func(cmd *cobra.C
}
}

func fetchBrandingTextContentToEdit(cli *cli, inputs *brandingTextsInputs) (string, error) {
func fetchBrandingTextContentToEdit(cli *cli, inputs *promptsTextInput) (string, error) {
contentToEdit := map[string]interface{}{textDocsKey: textDocsURL}

if err := ansi.Waiting(func() error {
Expand Down Expand Up @@ -276,7 +278,7 @@ func mergeBrandingTextTranslations(
func fetchEditedBrandingTextContent(
cmd *cobra.Command,
cli *cli,
inputs *brandingTextsInputs,
inputs *promptsTextInput,
brandingTextToEdit string,
) (map[string]interface{}, error) {
tempFileName := fmt.Sprintf("%s-prompt-%s.json", inputs.Prompt, inputs.Language)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestBrandingTextsShowCmd(t *testing.T) {
api: &auth0.API{Prompt: brandingTextsAPI},
}

cmd := showBrandingTextCmd(cli)
cmd := showPromptsTextCmd(cli)
cmd.SetArgs([]string{test.inputPrompt, "--language=" + test.inputLanguage})

err := cmd.Execute()
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func addSubcommands(rootCmd *cobra.Command, cli *cli) {
rootCmd.AddCommand(apisCmd(cli))
rootCmd.AddCommand(rolesCmd(cli))
rootCmd.AddCommand(organizationsCmd(cli))
rootCmd.AddCommand(brandingCmd(cli))
rootCmd.AddCommand(universalLoginCmd(cli))
rootCmd.AddCommand(emailCmd(cli))
rootCmd.AddCommand(customDomainsCmd(cli))
rootCmd.AddCommand(ipsCmd(cli))
Expand Down
38 changes: 20 additions & 18 deletions internal/cli/branding.go → internal/cli/universal_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,26 +73,28 @@ var (
errNotAllowed = errors.New("this feature requires at least one custom domain to be configured for the tenant")
)

func brandingCmd(cli *cli) *cobra.Command {
func universalLoginCmd(cli *cli) *cobra.Command {
cmd := &cobra.Command{
Use: "branding",
Short: "Manage branding options",
Long: "Manage branding options.",
Use: "universal-login",
Short: "Manage the Universal Login experience",
Long: "Manage a consistent, branded Universal Login experience that can handle all of your authentication flows.",
Aliases: []string{"ul"},
}

cmd.SetUsageTemplate(resourceUsageTemplate())
cmd.AddCommand(showBrandingCmd(cli))
cmd.AddCommand(updateBrandingCmd(cli))
cmd.AddCommand(templateCmd(cli))
cmd.AddCommand(textsCmd(cli))

cmd.AddCommand(showUniversalLoginCmd(cli))
cmd.AddCommand(updateUniversalLoginCmd(cli))
cmd.AddCommand(universalLoginTemplatesCmd(cli))
cmd.AddCommand(universalLoginPromptsTextCmd(cli))

return cmd
}

func templateCmd(cli *cli) *cobra.Command {
func universalLoginTemplatesCmd(cli *cli) *cobra.Command {
cmd := &cobra.Command{
Use: "templates",
Short: "Manage custom page templates",
Short: "Manage custom Universal Login templates",
Long: `Manage custom [page templates](https://auth0.com/docs/universal-login/new-experience/universal-login-page-templates). This requires a custom domain to be configured for the tenant.
This command will open two windows:
Expand All @@ -117,13 +119,13 @@ Once you close the window, you’ll be asked if you want to save the template. I
return cmd
}

func showBrandingCmd(cli *cli) *cobra.Command {
func showUniversalLoginCmd(cli *cli) *cobra.Command {
cmd := &cobra.Command{
Use: "show",
Args: cobra.NoArgs,
Short: "Display the custom branding settings for Universal Login",
Long: "Display the custom branding settings for Universal Login.",
Example: "auth0 branding show",
Example: "auth0 universal-login show",
RunE: func(cmd *cobra.Command, args []string) error {
var myBranding *management.Branding // Load app by id

Expand All @@ -144,7 +146,7 @@ func showBrandingCmd(cli *cli) *cobra.Command {
return cmd
}

func updateBrandingCmd(cli *cli) *cobra.Command {
func updateUniversalLoginCmd(cli *cli) *cobra.Command {
var inputs struct {
AccentColor string
BackgroundColor string
Expand All @@ -158,9 +160,9 @@ func updateBrandingCmd(cli *cli) *cobra.Command {
Args: cobra.NoArgs,
Short: "Update the custom branding settings for Universal Login",
Long: "Update the custom branding settings for Universal Login.",
Example: `auth0 branding update
auth0 branding update --accent "#FF4F40" --background "#2A2E35"
auth0 branding update -a "#FF4F40" -b "#2A2E35" --logo "https://example.com/logo.png"`,
Example: `auth0 universal-login update
auth0 universal-login update --accent "#FF4F40" --background "#2A2E35"
auth0 universal-login update -a "#FF4F40" -b "#2A2E35" --logo "https://example.com/logo.png"`,
RunE: func(cmd *cobra.Command, args []string) error {
var current *management.Branding

Expand Down Expand Up @@ -258,7 +260,7 @@ func showBrandingTemplateCmd(cli *cli) *cobra.Command {
Args: cobra.NoArgs,
Short: "Display the custom template for Universal Login",
Long: "Display the custom template for Universal Login.",
Example: "auth0 branding templates show",
Example: "auth0 universal-login templates show",
RunE: func(cmd *cobra.Command, args []string) error {
var template *management.BrandingUniversalLogin // Load app by id

Expand Down Expand Up @@ -286,7 +288,7 @@ func updateBrandingTemplateCmd(cli *cli) *cobra.Command {
Args: cobra.NoArgs,
Short: "Update the custom template for Universal Login",
Long: "Update the custom template for Universal Login.",
Example: "auth0 branding templates update",
Example: "auth0 universal-login templates update",
RunE: func(cmd *cobra.Command, args []string) error {
var templateData *branding.TemplateData
err := ansi.Waiting(func() error {
Expand Down

0 comments on commit 5ede670

Please sign in to comment.