Make profile state filters multi-value
Address PR review feedback on the profile-state split: SAML sign-in now activates a pending profile, deactivation counts owners against the profile's own organization to close a last-owner bypass, the migration leaves historical activated_at/deactivated_at NULL rather than fabricating timestamps, and pending members are no longer rendered with the deactivated (faded) styling. Drop the single-value state filter in favor of the multi-value states across the profile and signatory surfaces. Remove ProfileFilter.state (only states[] remains) and convert the signatures profileState filter to profileStates. Turn the console people filter, the CLI "user list --state" flag, and the n8n listUsers and getAllSignatures state inputs into multi-select controls, where an empty selection means all states. Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
@@ -28,15 +28,15 @@ type (
|
||||
DocumentVersionSignatureFilter struct {
|
||||
states DocumentVersionSignatureStates
|
||||
activeContract *bool
|
||||
profileState *ProfileState
|
||||
profileStates ProfileStateValues
|
||||
}
|
||||
)
|
||||
|
||||
func NewDocumentVersionSignatureFilter(states []DocumentVersionSignatureState, activeContract *bool, profileState *ProfileState) *DocumentVersionSignatureFilter {
|
||||
func NewDocumentVersionSignatureFilter(states []DocumentVersionSignatureState, activeContract *bool, profileStates []ProfileState) *DocumentVersionSignatureFilter {
|
||||
return &DocumentVersionSignatureFilter{
|
||||
states: DocumentVersionSignatureStates(states),
|
||||
activeContract: activeContract,
|
||||
profileState: profileState,
|
||||
profileStates: ProfileStateValues(profileStates),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ func (f *DocumentVersionSignatureFilter) SQLArguments() pgx.StrictNamedArgs {
|
||||
return pgx.StrictNamedArgs{
|
||||
"states": f.states,
|
||||
"active_contract": f.activeContract,
|
||||
"profile_state": f.profileState,
|
||||
"profile_states": f.profileStates,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,13 +81,13 @@ func (f *DocumentVersionSignatureFilter) SQLFragment() string {
|
||||
END
|
||||
AND
|
||||
CASE
|
||||
WHEN @profile_state::text IS NULL
|
||||
WHEN @profile_states::membership_state[] IS NULL
|
||||
THEN TRUE
|
||||
ELSE EXISTS (
|
||||
SELECT 1
|
||||
FROM iam_membership_profiles p
|
||||
WHERE p.id = signed_by_profile_id
|
||||
AND p.state = @profile_state::membership_state
|
||||
AND p.state = ANY(@profile_states::membership_state[])
|
||||
)
|
||||
END
|
||||
)`
|
||||
|
||||
@@ -81,11 +81,6 @@ func (f *MembershipProfileFilter) WithExternalID(externalID string) *MembershipP
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *MembershipProfileFilter) WithState(state ProfileState) *MembershipProfileFilter {
|
||||
f.states = ProfileStateValues{state}
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *MembershipProfileFilter) WithStates(states ...ProfileState) *MembershipProfileFilter {
|
||||
f.states = ProfileStateValues(states)
|
||||
return f
|
||||
|
||||
@@ -46,10 +46,3 @@ WHERE state = 'DEACTIVATED'
|
||||
)
|
||||
);
|
||||
|
||||
UPDATE iam_membership_profiles
|
||||
SET activated_at = updated_at
|
||||
WHERE state = 'ACTIVE';
|
||||
|
||||
UPDATE iam_membership_profiles
|
||||
SET deactivated_at = NOW()
|
||||
WHERE state = 'DEACTIVATED';
|
||||
|
||||
Reference in New Issue
Block a user