Skip to content

Commit

Permalink
Handle current data not existing
Browse files Browse the repository at this point in the history
  • Loading branch information
ewanharris committed Mar 30, 2023
1 parent 9db44e2 commit 71ee57d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
24 changes: 9 additions & 15 deletions internal/cli/universal_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func updateUniversalLoginCmd(cli *cli) *cobra.Command {
b := &management.Branding{}
isAccentColorSet := len(inputs.AccentColor) > 0
isBackgroundColorSet := len(inputs.BackgroundColor) > 0
currentHasColors := current.Colors != nil
currentHasColors := current.GetColors() != nil

if isAccentColorSet || isBackgroundColorSet || currentHasColors {
b.Colors = &management.BrandingColors{}
Expand All @@ -196,15 +196,17 @@ func updateUniversalLoginCmd(cli *cli) *cobra.Command {
}
}

if len(inputs.LogoURL) == 0 {
b.LogoURL = current.LogoURL
} else {
logoURL := current.GetLogoURL()
if len(inputs.LogoURL) == 0 && logoURL != "" {
b.LogoURL = &logoURL
} else if len(inputs.LogoURL) != 0 {
b.LogoURL = &inputs.LogoURL
}

if len(inputs.FaviconURL) == 0 {
b.FaviconURL = current.FaviconURL
} else {
favIconURL := current.GetFaviconURL()
if len(inputs.FaviconURL) == 0 && favIconURL != "" {
b.FaviconURL = &favIconURL
} else if len(inputs.FaviconURL) != 0 {
b.FaviconURL = &inputs.FaviconURL
}

Expand All @@ -213,14 +215,6 @@ func updateUniversalLoginCmd(cli *cli) *cobra.Command {
b.Font = &management.BrandingFont{URL: &inputs.CustomFontURL}
}

if b.Font != nil {
if len(inputs.CustomFontURL) == 0 {
b.Font.URL = current.Font.URL
} else {
b.Font.URL = &inputs.CustomFontURL
}
}

// Update branding
if err := ansi.Waiting(func() error {
return cli.api.Branding.Update(b)
Expand Down
2 changes: 1 addition & 1 deletion test/integration/universal-login-test-cases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ tests:
colors.page_background: "#FF4F40"
favicon_url: "https://example.com/favicon-updated-2.png"
logo_url: "https://example.com/logo-updated-2.png"
font.url: "https://example.com/font-updated-2.woff"
font.url: "https://example.com/font-updated-2.woff"

0 comments on commit 71ee57d

Please sign in to comment.