From 53f029cc14828a1c2fb9b44593e0be89497c962c Mon Sep 17 00:00:00 2001 From: Rita Zerrizuela Date: Thu, 8 Jul 2021 10:50:46 -0300 Subject: [PATCH] Fix branding update (#326) * Fix branding update * Update docs --- docs/auth0_branding_update.md | 4 ++-- internal/cli/branding.go | 30 ++++++++++++++++-------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/docs/auth0_branding_update.md b/docs/auth0_branding_update.md index 0ea985d18..39fbe75d1 100644 --- a/docs/auth0_branding_update.md +++ b/docs/auth0_branding_update.md @@ -17,8 +17,8 @@ auth0 branding update [flags] ``` auth0 branding update -auth0 branding update --accent '#B24592' --background '#F2DDEC' -auth0 branding update -a '#B24592' -b '#F2DDEC --logo 'https://example.com/logo.png +auth0 branding update --accent "#FF4F40" --background "#2A2E35" +auth0 branding update -a "#FF4F40" -b "#2A2E35" --logo "https://example.com/logo.png" ``` ### Options diff --git a/internal/cli/branding.go b/internal/cli/branding.go index 9c0e22670..088e08be0 100644 --- a/internal/cli/branding.go +++ b/internal/cli/branding.go @@ -114,7 +114,6 @@ func emailTemplateCmd(cli *cli) *cobra.Command { return cmd } - func showBrandingCmd(cli *cli) *cobra.Command { cmd := &cobra.Command{ Use: "show", @@ -157,8 +156,8 @@ func updateBrandingCmd(cli *cli) *cobra.Command { 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 '#B24592' --background '#F2DDEC' -auth0 branding update -a '#B24592' -b '#F2DDEC --logo 'https://example.com/logo.png`, +auth0 branding update --accent "#FF4F40" --background "#2A2E35" +auth0 branding update -a "#FF4F40" -b "#2A2E35" --logo "https://example.com/logo.png"`, RunE: func(cmd *cobra.Command, args []string) error { var current *management.Branding @@ -182,21 +181,24 @@ auth0 branding update -a '#B24592' -b '#F2DDEC --logo 'https://example.com/logo. // Load updated values into a fresh branding instance b := &management.Branding{} + isAccentColorSet := len(inputs.AccentColor) > 0 + isBackgroundColorSet := len(inputs.BackgroundColor) > 0 + currentHasColors := current.Colors != nil - if b.Colors == nil { + if isAccentColorSet || isBackgroundColorSet || currentHasColors { b.Colors = &management.BrandingColors{} - } - if len(inputs.AccentColor) == 0 { - b.Colors.Primary = current.GetColors().Primary - } else { - b.Colors.Primary = &inputs.AccentColor - } + if isAccentColorSet { + b.Colors.Primary = &inputs.AccentColor + } else if currentHasColors { + b.Colors.Primary = current.Colors.Primary + } - if len(inputs.BackgroundColor) == 0 { - b.Colors.PageBackground = current.GetColors().PageBackground - } else { - b.Colors.PageBackground = &inputs.BackgroundColor + if isBackgroundColorSet { + b.Colors.PageBackground = &inputs.BackgroundColor + } else if currentHasColors { + b.Colors.PageBackground = current.Colors.PageBackground + } } if len(inputs.LogoURL) == 0 {