mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 11:04:25 +00:00
4d10f3e715
* fix: import user, and label policy command side * feat: Import user and hide loginname suffix (#1464) * fix: import user * fix: label policy * fix: label policy * fix: label policy * fix: migrations * fix: migrations * fix: migrations * fix: label policy * loginSuffix in login ui * suffix * fix cursor on disabled user selection Co-authored-by: Livio Amstutz <livio.a@gmail.com> (cherry picked from commit03ddb8fc38
) * feat: Import user and hide loginname suffix (#1464) * fix: import user * fix: label policy * fix: label policy * fix: label policy * fix: migrations * fix: migrations * fix: migrations * fix: label policy * loginSuffix in login ui * suffix * fix cursor on disabled user selection Co-authored-by: Livio Amstutz <livio.a@gmail.com> (cherry picked from commit03ddb8fc38
) * feat: Import user and hide loginname suffix (#1464) * fix: import user * fix: label policy * fix: label policy * fix: label policy * fix: migrations * fix: migrations * fix: migrations * fix: label policy * loginSuffix in login ui * suffix * fix cursor on disabled user selection Co-authored-by: Livio Amstutz <livio.a@gmail.com> (cherry picked from commit03ddb8fc38
) * fix: label policy events * loginname placeholder * fix: tests * fix: tests * Update internal/command/iam_policy_label_model.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> Co-authored-by: Livio Amstutz <livio.a@gmail.com>
43 lines
1.0 KiB
Go
43 lines
1.0 KiB
Go
package command
|
|
|
|
import (
|
|
"github.com/caos/zitadel/internal/domain"
|
|
"github.com/caos/zitadel/internal/eventstore"
|
|
"github.com/caos/zitadel/internal/repository/policy"
|
|
)
|
|
|
|
type LabelPolicyWriteModel struct {
|
|
eventstore.WriteModel
|
|
|
|
PrimaryColor string
|
|
SecondaryColor string
|
|
HideLoginNameSuffix bool
|
|
|
|
State domain.PolicyState
|
|
}
|
|
|
|
func (wm *LabelPolicyWriteModel) Reduce() error {
|
|
for _, event := range wm.Events {
|
|
switch e := event.(type) {
|
|
case *policy.LabelPolicyAddedEvent:
|
|
wm.PrimaryColor = e.PrimaryColor
|
|
wm.SecondaryColor = e.SecondaryColor
|
|
wm.HideLoginNameSuffix = e.HideLoginNameSuffix
|
|
wm.State = domain.PolicyStateActive
|
|
case *policy.LabelPolicyChangedEvent:
|
|
if e.PrimaryColor != nil {
|
|
wm.PrimaryColor = *e.PrimaryColor
|
|
}
|
|
if e.SecondaryColor != nil {
|
|
wm.SecondaryColor = *e.SecondaryColor
|
|
}
|
|
if e.HideLoginNameSuffix != nil {
|
|
wm.HideLoginNameSuffix = *e.HideLoginNameSuffix
|
|
}
|
|
case *policy.LabelPolicyRemovedEvent:
|
|
wm.State = domain.PolicyStateRemoved
|
|
}
|
|
}
|
|
return wm.WriteModel.Reduce()
|
|
}
|