Simplify UX of compliance access management

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2026-02-10 11:32:20 +01:00
parent 09b6934c04
commit 5f7d4689aa
23 changed files with 323 additions and 190 deletions

View File

@@ -0,0 +1,14 @@
CREATE TYPE trust_center_access_state AS ENUM ('ACTIVE', 'INACTIVE');
ALTER TABLE trust_center_accesses
ADD COLUMN state trust_center_access_state NOT NULL DEFAULT 'INACTIVE';
UPDATE trust_center_accesses
SET state = 'ACTIVE'
WHERE active = true;
ALTER TABLE trust_center_accesses
DROP COLUMN active;
ALTER TABLE trust_center_accesses
ALTER COLUMN state DROP DEFAULT;

View File

@@ -32,18 +32,18 @@ import (
type (
TrustCenterAccess struct {
ID gid.GID `db:"id"`
OrganizationID gid.GID `db:"organization_id"`
TenantID gid.TenantID `db:"tenant_id"`
TrustCenterID gid.GID `db:"trust_center_id"`
Email mail.Addr `db:"email"`
Name string `db:"name"`
Active bool `db:"active"`
HasAcceptedNonDisclosureAgreement bool `db:"has_accepted_non_disclosure_agreement"`
HasAcceptedNonDisclosureAgreementMetadata json.RawMessage `db:"has_accepted_non_disclosure_agreement_metadata"`
NDAFileID *gid.GID `db:"nda_file_id"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
ID gid.GID `db:"id"`
OrganizationID gid.GID `db:"organization_id"`
TenantID gid.TenantID `db:"tenant_id"`
TrustCenterID gid.GID `db:"trust_center_id"`
Email mail.Addr `db:"email"`
Name string `db:"name"`
State TrustCenterAccessState `db:"state"`
HasAcceptedNonDisclosureAgreement bool `db:"has_accepted_non_disclosure_agreement"`
HasAcceptedNonDisclosureAgreementMetadata json.RawMessage `db:"has_accepted_non_disclosure_agreement_metadata"`
NDAFileID *gid.GID `db:"nda_file_id"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
TrustCenterAccesses []*TrustCenterAccess
@@ -86,7 +86,7 @@ SELECT
trust_center_id,
email,
name,
active,
state,
has_accepted_non_disclosure_agreement,
has_accepted_non_disclosure_agreement_metadata,
nda_file_id,
@@ -139,7 +139,7 @@ SELECT
trust_center_id,
email,
name,
active,
state,
has_accepted_non_disclosure_agreement,
has_accepted_non_disclosure_agreement_metadata,
nda_file_id,
@@ -194,7 +194,7 @@ INSERT INTO trust_center_accesses (
trust_center_id,
email,
name,
active,
state,
has_accepted_non_disclosure_agreement,
created_at,
updated_at
@@ -205,7 +205,7 @@ INSERT INTO trust_center_accesses (
@trust_center_id,
@email,
@name,
@active,
@state,
@has_accepted_non_disclosure_agreement,
@created_at,
@updated_at
@@ -219,7 +219,7 @@ INSERT INTO trust_center_accesses (
"trust_center_id": tca.TrustCenterID,
"email": tca.Email,
"name": tca.Name,
"active": tca.Active,
"state": tca.State,
"has_accepted_non_disclosure_agreement": tca.HasAcceptedNonDisclosureAgreement,
"created_at": tca.CreatedAt,
"updated_at": tca.UpdatedAt,
@@ -247,7 +247,7 @@ func (tca *TrustCenterAccess) Update(
q := `
UPDATE trust_center_accesses SET
name = @name,
active = @active,
state = @state,
updated_at = @updated_at,
has_accepted_non_disclosure_agreement = @has_accepted_non_disclosure_agreement,
has_accepted_non_disclosure_agreement_metadata = @has_accepted_non_disclosure_agreement_metadata,
@@ -262,7 +262,7 @@ WHERE
args := pgx.StrictNamedArgs{
"id": tca.ID,
"name": tca.Name,
"active": tca.Active,
"state": tca.State,
"updated_at": tca.UpdatedAt,
"has_accepted_non_disclosure_agreement": tca.HasAcceptedNonDisclosureAgreement,
"has_accepted_non_disclosure_agreement_metadata": tca.HasAcceptedNonDisclosureAgreementMetadata,
@@ -320,7 +320,7 @@ SELECT
trust_center_id,
email,
name,
active,
state,
has_accepted_non_disclosure_agreement,
has_accepted_non_disclosure_agreement_metadata,
nda_file_id,

View File

@@ -0,0 +1,57 @@
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package coredata
import (
"database/sql/driver"
"fmt"
)
type TrustCenterAccessState string
const (
TrustCenterAccessStateActive TrustCenterAccessState = "ACTIVE"
TrustCenterAccessStateInactive TrustCenterAccessState = "INACTIVE"
)
func (s TrustCenterAccessState) String() string {
return string(s)
}
func (s *TrustCenterAccessState) Scan(value any) error {
var str string
switch v := value.(type) {
case string:
str = v
case []byte:
str = string(v)
default:
return fmt.Errorf("unsupported type for TrustCenterAccessState: %T", value)
}
switch str {
case "ACTIVE":
*s = TrustCenterAccessStateActive
case "INACTIVE":
*s = TrustCenterAccessStateInactive
default:
return fmt.Errorf("invalid TrustCenterAccessState value: %q", str)
}
return nil
}
func (s TrustCenterAccessState) Value() (driver.Value, error) {
return s.String(), nil
}