mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 22:47:35 +00:00
feat: add attribute to only enable specific themes (#6798)
* feat: enable only specific themes in label policy * feat: enable only specific themes in label policy * feat: enable only specific themes in label policy * feat: enable only specific themes in label policy * add management in console * pass enabledTheme * render login ui based on enabled theme * add in branding / settings service and name consistently * update console to latest proto state * fix console linting * fix linting * cleanup * add translations --------- Co-authored-by: Livio Spring <livio.a@gmail.com> Co-authored-by: Tim Möhlmann <tim+github@zitadel.com>
This commit is contained in:
@@ -97,6 +97,7 @@ type InstanceSetup struct {
|
||||
HideLoginNameSuffix bool
|
||||
ErrorMsgPopup bool
|
||||
DisableWatermark bool
|
||||
ThemeMode domain.LabelPolicyThemeMode
|
||||
}
|
||||
LockoutPolicy struct {
|
||||
MaxAttempts uint64
|
||||
@@ -276,6 +277,7 @@ func (c *Commands) SetUpInstance(ctx context.Context, setup *InstanceSetup) (str
|
||||
setup.LabelPolicy.HideLoginNameSuffix,
|
||||
setup.LabelPolicy.ErrorMsgPopup,
|
||||
setup.LabelPolicy.DisableWatermark,
|
||||
setup.LabelPolicy.ThemeMode,
|
||||
),
|
||||
prepareActivateDefaultLabelPolicy(instanceAgg),
|
||||
|
||||
|
@@ -59,6 +59,7 @@ func writeModelToLabelPolicy(wm *LabelPolicyWriteModel) *domain.LabelPolicy {
|
||||
HideLoginNameSuffix: wm.HideLoginNameSuffix,
|
||||
ErrorMsgPopup: wm.ErrorMsgPopup,
|
||||
DisableWatermark: wm.DisableWatermark,
|
||||
ThemeMode: wm.ThemeMode,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,7 @@ import (
|
||||
func (c *Commands) AddDefaultLabelPolicy(
|
||||
ctx context.Context,
|
||||
primaryColor, backgroundColor, warnColor, fontColor, primaryColorDark, backgroundColorDark, warnColorDark, fontColorDark string,
|
||||
hideLoginNameSuffix, errorMsgPopup, disableWatermark bool,
|
||||
hideLoginNameSuffix, errorMsgPopup, disableWatermark bool, themeMode domain.LabelPolicyThemeMode,
|
||||
) (*domain.ObjectDetails, error) {
|
||||
instanceAgg := instance.NewAggregate(authz.GetInstance(ctx).InstanceID())
|
||||
cmds, err := preparation.PrepareCommands(ctx, c.eventstore.Filter,
|
||||
@@ -32,6 +32,7 @@ func (c *Commands) AddDefaultLabelPolicy(
|
||||
hideLoginNameSuffix,
|
||||
errorMsgPopup,
|
||||
disableWatermark,
|
||||
themeMode,
|
||||
))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -69,7 +70,8 @@ func (c *Commands) ChangeDefaultLabelPolicy(ctx context.Context, policy *domain.
|
||||
policy.FontColorDark,
|
||||
policy.HideLoginNameSuffix,
|
||||
policy.ErrorMsgPopup,
|
||||
policy.DisableWatermark)
|
||||
policy.DisableWatermark,
|
||||
policy.ThemeMode)
|
||||
if !hasChanged {
|
||||
return nil, caos_errs.ThrowPreconditionFailed(nil, "INSTANCE-28fHe", "Errors.IAM.LabelPolicy.NotChanged")
|
||||
}
|
||||
@@ -384,6 +386,7 @@ func prepareAddDefaultLabelPolicy(
|
||||
hideLoginNameSuffix,
|
||||
errorMsgPopup,
|
||||
disableWatermark bool,
|
||||
themeMode domain.LabelPolicyThemeMode,
|
||||
) preparation.Validation {
|
||||
return func() (preparation.CreateCommands, error) {
|
||||
return func(ctx context.Context, filter preparation.FilterToQueryReducer) ([]eventstore.Command, error) {
|
||||
@@ -412,6 +415,7 @@ func prepareAddDefaultLabelPolicy(
|
||||
hideLoginNameSuffix,
|
||||
errorMsgPopup,
|
||||
disableWatermark,
|
||||
themeMode,
|
||||
),
|
||||
}, nil
|
||||
}, nil
|
||||
|
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/repository/instance"
|
||||
"github.com/zitadel/zitadel/internal/repository/policy"
|
||||
@@ -97,6 +98,7 @@ func (wm *InstanceLabelPolicyWriteModel) NewChangedEvent(
|
||||
hideLoginNameSuffix,
|
||||
errorMsgPopup,
|
||||
disableWatermark bool,
|
||||
themeMode domain.LabelPolicyThemeMode,
|
||||
) (*instance.LabelPolicyChangedEvent, bool) {
|
||||
changes := make([]policy.LabelPolicyChanges, 0)
|
||||
if wm.PrimaryColor != primaryColor {
|
||||
@@ -132,6 +134,9 @@ func (wm *InstanceLabelPolicyWriteModel) NewChangedEvent(
|
||||
if wm.DisableWatermark != disableWatermark {
|
||||
changes = append(changes, policy.ChangeDisableWatermark(disableWatermark))
|
||||
}
|
||||
if wm.ThemeMode != themeMode {
|
||||
changes = append(changes, policy.ChangeThemeMode(themeMode))
|
||||
}
|
||||
if len(changes) == 0 {
|
||||
return nil, false
|
||||
}
|
||||
|
@@ -36,6 +36,7 @@ func TestCommandSide_AddDefaultLabelPolicy(t *testing.T) {
|
||||
hideLoginNameSuffix bool
|
||||
errorMsgPopup bool
|
||||
disableWatermark bool
|
||||
themeMode domain.LabelPolicyThemeMode
|
||||
}
|
||||
type res struct {
|
||||
want *domain.ObjectDetails
|
||||
@@ -67,6 +68,7 @@ func TestCommandSide_AddDefaultLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -85,6 +87,7 @@ func TestCommandSide_AddDefaultLabelPolicy(t *testing.T) {
|
||||
hideLoginNameSuffix: true,
|
||||
errorMsgPopup: true,
|
||||
disableWatermark: true,
|
||||
themeMode: domain.LabelPolicyThemeAuto,
|
||||
},
|
||||
res: res{
|
||||
err: caos_errs.IsErrorAlreadyExists,
|
||||
@@ -110,6 +113,7 @@ func TestCommandSide_AddDefaultLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeDark,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -127,6 +131,7 @@ func TestCommandSide_AddDefaultLabelPolicy(t *testing.T) {
|
||||
hideLoginNameSuffix: true,
|
||||
errorMsgPopup: true,
|
||||
disableWatermark: true,
|
||||
themeMode: domain.LabelPolicyThemeDark,
|
||||
},
|
||||
res: res{
|
||||
want: &domain.ObjectDetails{
|
||||
@@ -153,6 +158,7 @@ func TestCommandSide_AddDefaultLabelPolicy(t *testing.T) {
|
||||
tt.args.hideLoginNameSuffix,
|
||||
tt.args.errorMsgPopup,
|
||||
tt.args.disableWatermark,
|
||||
tt.args.themeMode,
|
||||
)
|
||||
if tt.res.err == nil {
|
||||
assert.NoError(t, err)
|
||||
@@ -225,6 +231,7 @@ func TestCommandSide_ChangeDefaultLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -244,6 +251,7 @@ func TestCommandSide_ChangeDefaultLabelPolicy(t *testing.T) {
|
||||
HideLoginNameSuffix: true,
|
||||
ErrorMsgPopup: true,
|
||||
DisableWatermark: true,
|
||||
ThemeMode: domain.LabelPolicyThemeAuto,
|
||||
},
|
||||
},
|
||||
res: res{
|
||||
@@ -270,6 +278,7 @@ func TestCommandSide_ChangeDefaultLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -286,7 +295,8 @@ func TestCommandSide_ChangeDefaultLabelPolicy(t *testing.T) {
|
||||
"#000000",
|
||||
false,
|
||||
false,
|
||||
false),
|
||||
false,
|
||||
domain.LabelPolicyThemeDark),
|
||||
),
|
||||
),
|
||||
},
|
||||
@@ -304,6 +314,7 @@ func TestCommandSide_ChangeDefaultLabelPolicy(t *testing.T) {
|
||||
HideLoginNameSuffix: false,
|
||||
ErrorMsgPopup: false,
|
||||
DisableWatermark: false,
|
||||
ThemeMode: domain.LabelPolicyThemeDark,
|
||||
},
|
||||
},
|
||||
res: res{
|
||||
@@ -324,6 +335,7 @@ func TestCommandSide_ChangeDefaultLabelPolicy(t *testing.T) {
|
||||
HideLoginNameSuffix: false,
|
||||
ErrorMsgPopup: false,
|
||||
DisableWatermark: false,
|
||||
ThemeMode: domain.LabelPolicyThemeDark,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -399,6 +411,7 @@ func TestCommandSide_ActivateDefaultLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -500,6 +513,7 @@ func TestCommandSide_AddLogoDefaultLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -541,6 +555,7 @@ func TestCommandSide_AddLogoDefaultLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -645,6 +660,7 @@ func TestCommandSide_RemoveLogoDefaultLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
@@ -684,6 +700,7 @@ func TestCommandSide_RemoveLogoDefaultLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
@@ -793,6 +810,7 @@ func TestCommandSide_AddIconDefaultLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -834,6 +852,7 @@ func TestCommandSide_AddIconDefaultLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -938,6 +957,7 @@ func TestCommandSide_RemoveIconDefaultLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
@@ -1049,6 +1069,7 @@ func TestCommandSide_AddLogoDarkDefaultLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1091,6 +1112,7 @@ func TestCommandSide_AddLogoDarkDefaultLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1195,6 +1217,7 @@ func TestCommandSide_RemoveLogoDarkDefaultLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
@@ -1234,6 +1257,7 @@ func TestCommandSide_RemoveLogoDarkDefaultLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
@@ -1343,6 +1367,7 @@ func TestCommandSide_AddIconDarkDefaultLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1384,6 +1409,7 @@ func TestCommandSide_AddIconDarkDefaultLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1488,6 +1514,7 @@ func TestCommandSide_RemoveIconDarkDefaultLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
@@ -1527,6 +1554,7 @@ func TestCommandSide_RemoveIconDarkDefaultLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
@@ -1636,6 +1664,7 @@ func TestCommandSide_AddFontDefaultLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1677,6 +1706,7 @@ func TestCommandSide_AddFontDefaultLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1781,6 +1811,7 @@ func TestCommandSide_RemoveFontDefaultLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
@@ -1820,6 +1851,7 @@ func TestCommandSide_RemoveFontDefaultLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
@@ -1867,7 +1899,7 @@ func TestCommandSide_RemoveFontDefaultLabelPolicy(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func newDefaultLabelPolicyChangedEvent(ctx context.Context, primaryColor, backgroundColor, warnColor, fontColor, primaryColorDark, backgroundColorDark, warnColorDark, fontColorDark string, hideLoginNameSuffix, errMsgPopup, disableWatermark bool) *instance.LabelPolicyChangedEvent {
|
||||
func newDefaultLabelPolicyChangedEvent(ctx context.Context, primaryColor, backgroundColor, warnColor, fontColor, primaryColorDark, backgroundColorDark, warnColorDark, fontColorDark string, hideLoginNameSuffix, errMsgPopup, disableWatermark bool, theme domain.LabelPolicyThemeMode) *instance.LabelPolicyChangedEvent {
|
||||
event, _ := instance.NewLabelPolicyChangedEvent(ctx,
|
||||
&instance.NewAggregate("INSTANCE").Aggregate,
|
||||
[]policy.LabelPolicyChanges{
|
||||
@@ -1882,6 +1914,7 @@ func newDefaultLabelPolicyChangedEvent(ctx context.Context, primaryColor, backgr
|
||||
policy.ChangeHideLoginNameSuffix(hideLoginNameSuffix),
|
||||
policy.ChangeErrorMsgPopup(errMsgPopup),
|
||||
policy.ChangeDisableWatermark(disableWatermark),
|
||||
policy.ChangeThemeMode(theme),
|
||||
},
|
||||
)
|
||||
return event
|
||||
|
@@ -39,7 +39,8 @@ func (c *Commands) AddLabelPolicy(ctx context.Context, resourceOwner string, pol
|
||||
policy.FontColorDark,
|
||||
policy.HideLoginNameSuffix,
|
||||
policy.ErrorMsgPopup,
|
||||
policy.DisableWatermark))
|
||||
policy.DisableWatermark,
|
||||
policy.ThemeMode))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -80,7 +81,8 @@ func (c *Commands) ChangeLabelPolicy(ctx context.Context, resourceOwner string,
|
||||
policy.FontColorDark,
|
||||
policy.HideLoginNameSuffix,
|
||||
policy.ErrorMsgPopup,
|
||||
policy.DisableWatermark)
|
||||
policy.DisableWatermark,
|
||||
policy.ThemeMode)
|
||||
if !hasChanged {
|
||||
return nil, caos_errs.ThrowPreconditionFailed(nil, "Org-8nfSr", "Errors.Org.LabelPolicy.NotChanged")
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package command
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/repository/org"
|
||||
@@ -98,6 +99,7 @@ func (wm *OrgLabelPolicyWriteModel) NewChangedEvent(
|
||||
hideLoginNameSuffix,
|
||||
errorMsgPopup,
|
||||
disableWatermark bool,
|
||||
themeMode domain.LabelPolicyThemeMode,
|
||||
) (*org.LabelPolicyChangedEvent, bool) {
|
||||
changes := make([]policy.LabelPolicyChanges, 0)
|
||||
if wm.PrimaryColor != primaryColor {
|
||||
@@ -133,6 +135,9 @@ func (wm *OrgLabelPolicyWriteModel) NewChangedEvent(
|
||||
if wm.DisableWatermark != disableWatermark {
|
||||
changes = append(changes, policy.ChangeDisableWatermark(disableWatermark))
|
||||
}
|
||||
if wm.ThemeMode != themeMode {
|
||||
changes = append(changes, policy.ChangeThemeMode(themeMode))
|
||||
}
|
||||
if len(changes) == 0 {
|
||||
return nil, false
|
||||
}
|
||||
|
@@ -75,6 +75,7 @@ func TestCommandSide_AddLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -121,6 +122,7 @@ func TestCommandSide_AddLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeDark,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -140,6 +142,7 @@ func TestCommandSide_AddLabelPolicy(t *testing.T) {
|
||||
HideLoginNameSuffix: true,
|
||||
ErrorMsgPopup: true,
|
||||
DisableWatermark: true,
|
||||
ThemeMode: domain.LabelPolicyThemeDark,
|
||||
},
|
||||
},
|
||||
res: res{
|
||||
@@ -159,6 +162,7 @@ func TestCommandSide_AddLabelPolicy(t *testing.T) {
|
||||
HideLoginNameSuffix: true,
|
||||
ErrorMsgPopup: true,
|
||||
DisableWatermark: true,
|
||||
ThemeMode: domain.LabelPolicyThemeDark,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -260,6 +264,7 @@ func TestCommandSide_ChangeLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -280,6 +285,7 @@ func TestCommandSide_ChangeLabelPolicy(t *testing.T) {
|
||||
HideLoginNameSuffix: true,
|
||||
ErrorMsgPopup: true,
|
||||
DisableWatermark: true,
|
||||
ThemeMode: domain.LabelPolicyThemeAuto,
|
||||
},
|
||||
},
|
||||
res: res{
|
||||
@@ -306,6 +312,7 @@ func TestCommandSide_ChangeLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -323,7 +330,8 @@ func TestCommandSide_ChangeLabelPolicy(t *testing.T) {
|
||||
"#000000",
|
||||
false,
|
||||
false,
|
||||
false),
|
||||
false,
|
||||
domain.LabelPolicyThemeDark),
|
||||
),
|
||||
),
|
||||
},
|
||||
@@ -342,6 +350,7 @@ func TestCommandSide_ChangeLabelPolicy(t *testing.T) {
|
||||
HideLoginNameSuffix: false,
|
||||
ErrorMsgPopup: false,
|
||||
DisableWatermark: false,
|
||||
ThemeMode: domain.LabelPolicyThemeDark,
|
||||
},
|
||||
},
|
||||
res: res{
|
||||
@@ -361,6 +370,7 @@ func TestCommandSide_ChangeLabelPolicy(t *testing.T) {
|
||||
HideLoginNameSuffix: false,
|
||||
ErrorMsgPopup: false,
|
||||
DisableWatermark: false,
|
||||
ThemeMode: domain.LabelPolicyThemeDark,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -451,6 +461,7 @@ func TestCommandSide_ActivateLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -551,6 +562,7 @@ func TestCommandSide_RemoveLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -672,6 +684,7 @@ func TestCommandSide_AddLogoLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -714,6 +727,7 @@ func TestCommandSide_AddLogoLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -838,6 +852,7 @@ func TestCommandSide_RemoveLogoLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
@@ -974,6 +989,7 @@ func TestCommandSide_AddIconLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1016,6 +1032,7 @@ func TestCommandSide_AddIconLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1138,6 +1155,7 @@ func TestCommandSide_RemoveIconLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
@@ -1273,6 +1291,7 @@ func TestCommandSide_AddLogoDarkLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1315,6 +1334,7 @@ func TestCommandSide_AddLogoDarkLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1439,6 +1459,7 @@ func TestCommandSide_RemoveLogoDarkLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
@@ -1575,6 +1596,7 @@ func TestCommandSide_AddIconDarkLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1617,6 +1639,7 @@ func TestCommandSide_AddIconDarkLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1737,6 +1760,7 @@ func TestCommandSide_RemoveIconDarkLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
@@ -1864,6 +1888,7 @@ func TestCommandSide_AddFontLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1906,6 +1931,7 @@ func TestCommandSide_AddFontLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -2026,6 +2052,7 @@ func TestCommandSide_RemoveFontLabelPolicy(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
domain.LabelPolicyThemeAuto,
|
||||
),
|
||||
),
|
||||
eventFromEventPusher(
|
||||
@@ -2074,7 +2101,7 @@ func TestCommandSide_RemoveFontLabelPolicy(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func newLabelPolicyChangedEvent(ctx context.Context, orgID, primaryColor, backgroundColor, warnColor, fontColor, primaryColorDark, backgroundColorDark, warnColorDark, fontColorDark string, hideLoginNameSuffix, errMsgPopup, disableWatermark bool) *org.LabelPolicyChangedEvent {
|
||||
func newLabelPolicyChangedEvent(ctx context.Context, orgID, primaryColor, backgroundColor, warnColor, fontColor, primaryColorDark, backgroundColorDark, warnColorDark, fontColorDark string, hideLoginNameSuffix, errMsgPopup, disableWatermark bool, theme domain.LabelPolicyThemeMode) *org.LabelPolicyChangedEvent {
|
||||
event, _ := org.NewLabelPolicyChangedEvent(ctx,
|
||||
&org.NewAggregate(orgID).Aggregate,
|
||||
[]policy.LabelPolicyChanges{
|
||||
@@ -2089,6 +2116,7 @@ func newLabelPolicyChangedEvent(ctx context.Context, orgID, primaryColor, backgr
|
||||
policy.ChangeHideLoginNameSuffix(hideLoginNameSuffix),
|
||||
policy.ChangeErrorMsgPopup(errMsgPopup),
|
||||
policy.ChangeDisableWatermark(disableWatermark),
|
||||
policy.ChangeThemeMode(theme),
|
||||
},
|
||||
)
|
||||
return event
|
||||
|
@@ -28,6 +28,7 @@ type LabelPolicyWriteModel struct {
|
||||
HideLoginNameSuffix bool
|
||||
ErrorMsgPopup bool
|
||||
DisableWatermark bool
|
||||
ThemeMode domain.LabelPolicyThemeMode
|
||||
|
||||
State domain.PolicyState
|
||||
}
|
||||
@@ -47,6 +48,7 @@ func (wm *LabelPolicyWriteModel) Reduce() error {
|
||||
wm.HideLoginNameSuffix = e.HideLoginNameSuffix
|
||||
wm.ErrorMsgPopup = e.ErrorMsgPopup
|
||||
wm.DisableWatermark = e.DisableWatermark
|
||||
wm.ThemeMode = e.ThemeMode
|
||||
wm.State = domain.PolicyStateActive
|
||||
case *policy.LabelPolicyChangedEvent:
|
||||
if e.PrimaryColor != nil {
|
||||
@@ -82,6 +84,9 @@ func (wm *LabelPolicyWriteModel) Reduce() error {
|
||||
if e.DisableWatermark != nil {
|
||||
wm.DisableWatermark = *e.DisableWatermark
|
||||
}
|
||||
if e.ThemeMode != nil {
|
||||
wm.ThemeMode = *e.ThemeMode
|
||||
}
|
||||
case *policy.LabelPolicyLogoAddedEvent:
|
||||
wm.LogoKey = e.StoreKey
|
||||
case *policy.LabelPolicyLogoRemovedEvent:
|
||||
|
Reference in New Issue
Block a user