Simplify UX of compliance access management
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
14
pkg/coredata/migrations/20260210T120000Z.sql
Normal file
14
pkg/coredata/migrations/20260210T120000Z.sql
Normal 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;
|
||||
@@ -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,
|
||||
|
||||
57
pkg/coredata/trust_center_access_state.go
Normal file
57
pkg/coredata/trust_center_access_state.go
Normal 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
|
||||
}
|
||||
@@ -49,7 +49,7 @@ type (
|
||||
UpdateTrustCenterAccessRequest struct {
|
||||
ID gid.GID
|
||||
Name *string
|
||||
Active *bool
|
||||
State *coredata.TrustCenterAccessState
|
||||
DocumentAccesses []UpdateTrustCenterDocumentAccessRequest
|
||||
ReportAccesses []UpdateTrustCenterDocumentAccessRequest
|
||||
TrustCenterFileAccesses []UpdateTrustCenterDocumentAccessRequest
|
||||
@@ -243,7 +243,7 @@ func (s TrustCenterAccessService) Create(
|
||||
TrustCenterID: req.TrustCenterID,
|
||||
Email: req.Email,
|
||||
Name: req.FullName,
|
||||
Active: false,
|
||||
State: coredata.TrustCenterAccessStateActive,
|
||||
HasAcceptedNonDisclosureAgreement: false,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
@@ -286,12 +286,12 @@ func (s TrustCenterAccessService) Update(
|
||||
return fmt.Errorf("cannot load trust center access: %w", err)
|
||||
}
|
||||
|
||||
trustCenterAcessActivated = req.Active != nil && *req.Active && !access.Active
|
||||
trustCenterAcessActivated = req.State != nil && *req.State == coredata.TrustCenterAccessStateActive && access.State != coredata.TrustCenterAccessStateActive
|
||||
if req.Name != nil {
|
||||
access.Name = *req.Name
|
||||
}
|
||||
if req.Active != nil {
|
||||
access.Active = *req.Active
|
||||
if req.State != nil {
|
||||
access.State = *req.State
|
||||
}
|
||||
access.UpdatedAt = now
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"github.com/vektah/gqlparser/v2/gqlerror"
|
||||
"go.gearno.de/kit/httpserver"
|
||||
"go.gearno.de/kit/log"
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
"go.probo.inc/probo/pkg/server/api/authn"
|
||||
"go.probo.inc/probo/pkg/server/gqlutils"
|
||||
"go.probo.inc/probo/pkg/trust"
|
||||
@@ -61,7 +62,7 @@ func NewMembershipMiddleware(trustSvc *trust.Service, logger *log.Logger) func(n
|
||||
return
|
||||
}
|
||||
|
||||
if membership.Active {
|
||||
if membership.State == coredata.TrustCenterAccessStateActive {
|
||||
ctx = context.WithValue(ctx, complianceMembershipKey, membership)
|
||||
next.ServeHTTP(w, r.WithContext(ctx))
|
||||
return
|
||||
|
||||
@@ -1175,6 +1175,20 @@ enum TrustCenterAccessOrderField
|
||||
)
|
||||
}
|
||||
|
||||
enum TrustCenterAccessState
|
||||
@goModel(
|
||||
model: "go.probo.inc/probo/pkg/coredata.TrustCenterAccessState"
|
||||
) {
|
||||
ACTIVE
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.TrustCenterAccessStateActive"
|
||||
)
|
||||
INACTIVE
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.TrustCenterAccessStateInactive"
|
||||
)
|
||||
}
|
||||
|
||||
enum TrustCenterDocumentAccessOrderField
|
||||
@goModel(
|
||||
model: "go.probo.inc/probo/pkg/coredata.TrustCenterDocumentAccessOrderField"
|
||||
@@ -2572,7 +2586,7 @@ type TrustCenterAccess implements Node {
|
||||
id: ID!
|
||||
email: EmailAddr!
|
||||
name: String!
|
||||
active: Boolean!
|
||||
state: TrustCenterAccessState!
|
||||
hasAcceptedNonDisclosureAgreement: Boolean!
|
||||
createdAt: Datetime!
|
||||
updatedAt: Datetime!
|
||||
@@ -3458,7 +3472,6 @@ input CreateTrustCenterAccessInput {
|
||||
trustCenterId: ID!
|
||||
email: EmailAddr!
|
||||
name: String!
|
||||
active: Boolean!
|
||||
}
|
||||
|
||||
input TrustCenterDocumentAccessInput {
|
||||
@@ -3469,7 +3482,7 @@ input TrustCenterDocumentAccessInput {
|
||||
input UpdateTrustCenterAccessInput {
|
||||
id: ID!
|
||||
name: String
|
||||
active: Boolean
|
||||
state: TrustCenterAccessState
|
||||
documents: [TrustCenterDocumentAccessInput!]
|
||||
reports: [TrustCenterDocumentAccessInput!]
|
||||
trustCenterFiles: [TrustCenterDocumentAccessInput!]
|
||||
|
||||
@@ -1511,7 +1511,6 @@ type ComplexityRoot struct {
|
||||
}
|
||||
|
||||
TrustCenterAccess struct {
|
||||
Active func(childComplexity int) int
|
||||
ActiveCount func(childComplexity int) int
|
||||
AvailableDocumentAccesses func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.OrderBy[coredata.TrustCenterDocumentAccessOrderField]) int
|
||||
CreatedAt func(childComplexity int) int
|
||||
@@ -1522,6 +1521,7 @@ type ComplexityRoot struct {
|
||||
Name func(childComplexity int) int
|
||||
PendingRequestCount func(childComplexity int) int
|
||||
Permission func(childComplexity int, action string) int
|
||||
State func(childComplexity int) int
|
||||
UpdatedAt func(childComplexity int) int
|
||||
}
|
||||
|
||||
@@ -8662,12 +8662,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
||||
|
||||
return e.complexity.TrustCenter.UpdatedAt(childComplexity), true
|
||||
|
||||
case "TrustCenterAccess.active":
|
||||
if e.complexity.TrustCenterAccess.Active == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.TrustCenterAccess.Active(childComplexity), true
|
||||
case "TrustCenterAccess.activeCount":
|
||||
if e.complexity.TrustCenterAccess.ActiveCount == nil {
|
||||
break
|
||||
@@ -8738,6 +8732,12 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
||||
}
|
||||
|
||||
return e.complexity.TrustCenterAccess.Permission(childComplexity, args["action"].(string)), true
|
||||
case "TrustCenterAccess.state":
|
||||
if e.complexity.TrustCenterAccess.State == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.TrustCenterAccess.State(childComplexity), true
|
||||
case "TrustCenterAccess.updatedAt":
|
||||
if e.complexity.TrustCenterAccess.UpdatedAt == nil {
|
||||
break
|
||||
@@ -11528,6 +11528,20 @@ enum TrustCenterAccessOrderField
|
||||
)
|
||||
}
|
||||
|
||||
enum TrustCenterAccessState
|
||||
@goModel(
|
||||
model: "go.probo.inc/probo/pkg/coredata.TrustCenterAccessState"
|
||||
) {
|
||||
ACTIVE
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.TrustCenterAccessStateActive"
|
||||
)
|
||||
INACTIVE
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.TrustCenterAccessStateInactive"
|
||||
)
|
||||
}
|
||||
|
||||
enum TrustCenterDocumentAccessOrderField
|
||||
@goModel(
|
||||
model: "go.probo.inc/probo/pkg/coredata.TrustCenterDocumentAccessOrderField"
|
||||
@@ -12925,7 +12939,7 @@ type TrustCenterAccess implements Node {
|
||||
id: ID!
|
||||
email: EmailAddr!
|
||||
name: String!
|
||||
active: Boolean!
|
||||
state: TrustCenterAccessState!
|
||||
hasAcceptedNonDisclosureAgreement: Boolean!
|
||||
createdAt: Datetime!
|
||||
updatedAt: Datetime!
|
||||
@@ -13811,7 +13825,6 @@ input CreateTrustCenterAccessInput {
|
||||
trustCenterId: ID!
|
||||
email: EmailAddr!
|
||||
name: String!
|
||||
active: Boolean!
|
||||
}
|
||||
|
||||
input TrustCenterDocumentAccessInput {
|
||||
@@ -13822,7 +13835,7 @@ input TrustCenterDocumentAccessInput {
|
||||
input UpdateTrustCenterAccessInput {
|
||||
id: ID!
|
||||
name: String
|
||||
active: Boolean
|
||||
state: TrustCenterAccessState
|
||||
documents: [TrustCenterDocumentAccessInput!]
|
||||
reports: [TrustCenterDocumentAccessInput!]
|
||||
trustCenterFiles: [TrustCenterDocumentAccessInput!]
|
||||
@@ -51094,30 +51107,30 @@ func (ec *executionContext) fieldContext_TrustCenterAccess_name(_ context.Contex
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _TrustCenterAccess_active(ctx context.Context, field graphql.CollectedField, obj *types.TrustCenterAccess) (ret graphql.Marshaler) {
|
||||
func (ec *executionContext) _TrustCenterAccess_state(ctx context.Context, field graphql.CollectedField, obj *types.TrustCenterAccess) (ret graphql.Marshaler) {
|
||||
return graphql.ResolveField(
|
||||
ctx,
|
||||
ec.OperationContext,
|
||||
field,
|
||||
ec.fieldContext_TrustCenterAccess_active,
|
||||
ec.fieldContext_TrustCenterAccess_state,
|
||||
func(ctx context.Context) (any, error) {
|
||||
return obj.Active, nil
|
||||
return obj.State, nil
|
||||
},
|
||||
nil,
|
||||
ec.marshalNBoolean2bool,
|
||||
ec.marshalNTrustCenterAccessState2goᚗproboᚗincᚋproboᚋpkgᚋcoredataᚐTrustCenterAccessState,
|
||||
true,
|
||||
true,
|
||||
)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_TrustCenterAccess_active(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
func (ec *executionContext) fieldContext_TrustCenterAccess_state(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "TrustCenterAccess",
|
||||
Field: field,
|
||||
IsMethod: false,
|
||||
IsResolver: false,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
return nil, errors.New("field of type Boolean does not have child fields")
|
||||
return nil, errors.New("field of type TrustCenterAccessState does not have child fields")
|
||||
},
|
||||
}
|
||||
return fc, nil
|
||||
@@ -51520,8 +51533,8 @@ func (ec *executionContext) fieldContext_TrustCenterAccessEdge_node(_ context.Co
|
||||
return ec.fieldContext_TrustCenterAccess_email(ctx, field)
|
||||
case "name":
|
||||
return ec.fieldContext_TrustCenterAccess_name(ctx, field)
|
||||
case "active":
|
||||
return ec.fieldContext_TrustCenterAccess_active(ctx, field)
|
||||
case "state":
|
||||
return ec.fieldContext_TrustCenterAccess_state(ctx, field)
|
||||
case "hasAcceptedNonDisclosureAgreement":
|
||||
return ec.fieldContext_TrustCenterAccess_hasAcceptedNonDisclosureAgreement(ctx, field)
|
||||
case "createdAt":
|
||||
@@ -54373,8 +54386,8 @@ func (ec *executionContext) fieldContext_UpdateTrustCenterAccessPayload_trustCen
|
||||
return ec.fieldContext_TrustCenterAccess_email(ctx, field)
|
||||
case "name":
|
||||
return ec.fieldContext_TrustCenterAccess_name(ctx, field)
|
||||
case "active":
|
||||
return ec.fieldContext_TrustCenterAccess_active(ctx, field)
|
||||
case "state":
|
||||
return ec.fieldContext_TrustCenterAccess_state(ctx, field)
|
||||
case "hasAcceptedNonDisclosureAgreement":
|
||||
return ec.fieldContext_TrustCenterAccess_hasAcceptedNonDisclosureAgreement(ctx, field)
|
||||
case "createdAt":
|
||||
@@ -63154,7 +63167,7 @@ func (ec *executionContext) unmarshalInputCreateTrustCenterAccessInput(ctx conte
|
||||
asMap[k] = v
|
||||
}
|
||||
|
||||
fieldsInOrder := [...]string{"trustCenterId", "email", "name", "active"}
|
||||
fieldsInOrder := [...]string{"trustCenterId", "email", "name"}
|
||||
for _, k := range fieldsInOrder {
|
||||
v, ok := asMap[k]
|
||||
if !ok {
|
||||
@@ -63182,13 +63195,6 @@ func (ec *executionContext) unmarshalInputCreateTrustCenterAccessInput(ctx conte
|
||||
return it, err
|
||||
}
|
||||
it.Name = data
|
||||
case "active":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("active"))
|
||||
data, err := ec.unmarshalNBoolean2bool(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
it.Active = data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68055,7 +68061,7 @@ func (ec *executionContext) unmarshalInputUpdateTrustCenterAccessInput(ctx conte
|
||||
asMap[k] = v
|
||||
}
|
||||
|
||||
fieldsInOrder := [...]string{"id", "name", "active", "documents", "reports", "trustCenterFiles"}
|
||||
fieldsInOrder := [...]string{"id", "name", "state", "documents", "reports", "trustCenterFiles"}
|
||||
for _, k := range fieldsInOrder {
|
||||
v, ok := asMap[k]
|
||||
if !ok {
|
||||
@@ -68076,13 +68082,13 @@ func (ec *executionContext) unmarshalInputUpdateTrustCenterAccessInput(ctx conte
|
||||
return it, err
|
||||
}
|
||||
it.Name = data
|
||||
case "active":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("active"))
|
||||
data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v)
|
||||
case "state":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("state"))
|
||||
data, err := ec.unmarshalOTrustCenterAccessState2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋcoredataᚐTrustCenterAccessState(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
it.Active = data
|
||||
it.State = data
|
||||
case "documents":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("documents"))
|
||||
data, err := ec.unmarshalOTrustCenterDocumentAccessInput2ᚕᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐTrustCenterDocumentAccessInputᚄ(ctx, v)
|
||||
@@ -85235,8 +85241,8 @@ func (ec *executionContext) _TrustCenterAccess(ctx context.Context, sel ast.Sele
|
||||
if out.Values[i] == graphql.Null {
|
||||
atomic.AddUint32(&out.Invalids, 1)
|
||||
}
|
||||
case "active":
|
||||
out.Values[i] = ec._TrustCenterAccess_active(ctx, field, obj)
|
||||
case "state":
|
||||
out.Values[i] = ec._TrustCenterAccess_state(ctx, field, obj)
|
||||
if out.Values[i] == graphql.Null {
|
||||
atomic.AddUint32(&out.Invalids, 1)
|
||||
}
|
||||
@@ -96901,6 +96907,34 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func (ec *executionContext) unmarshalNTrustCenterAccessState2goᚗproboᚗincᚋproboᚋpkgᚋcoredataᚐTrustCenterAccessState(ctx context.Context, v any) (coredata.TrustCenterAccessState, error) {
|
||||
tmp, err := graphql.UnmarshalString(v)
|
||||
res := unmarshalNTrustCenterAccessState2goᚗproboᚗincᚋproboᚋpkgᚋcoredataᚐTrustCenterAccessState[tmp]
|
||||
return res, graphql.ErrorOnPath(ctx, err)
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalNTrustCenterAccessState2goᚗproboᚗincᚋproboᚋpkgᚋcoredataᚐTrustCenterAccessState(ctx context.Context, sel ast.SelectionSet, v coredata.TrustCenterAccessState) graphql.Marshaler {
|
||||
_ = sel
|
||||
res := graphql.MarshalString(marshalNTrustCenterAccessState2goᚗproboᚗincᚋproboᚋpkgᚋcoredataᚐTrustCenterAccessState[v])
|
||||
if res == graphql.Null {
|
||||
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
|
||||
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
var (
|
||||
unmarshalNTrustCenterAccessState2goᚗproboᚗincᚋproboᚋpkgᚋcoredataᚐTrustCenterAccessState = map[string]coredata.TrustCenterAccessState{
|
||||
"ACTIVE": coredata.TrustCenterAccessStateActive,
|
||||
"INACTIVE": coredata.TrustCenterAccessStateInactive,
|
||||
}
|
||||
marshalNTrustCenterAccessState2goᚗproboᚗincᚋproboᚋpkgᚋcoredataᚐTrustCenterAccessState = map[coredata.TrustCenterAccessState]string{
|
||||
coredata.TrustCenterAccessStateActive: "ACTIVE",
|
||||
coredata.TrustCenterAccessStateInactive: "INACTIVE",
|
||||
}
|
||||
)
|
||||
|
||||
func (ec *executionContext) marshalNTrustCenterDocumentAccess2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐTrustCenterDocumentAccess(ctx context.Context, sel ast.SelectionSet, v *types.TrustCenterDocumentAccess) graphql.Marshaler {
|
||||
if v == nil {
|
||||
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
|
||||
@@ -100605,6 +100639,36 @@ func (ec *executionContext) unmarshalOTrustCenterAccessOrder2ᚖgoᚗproboᚗinc
|
||||
return &res, graphql.ErrorOnPath(ctx, err)
|
||||
}
|
||||
|
||||
func (ec *executionContext) unmarshalOTrustCenterAccessState2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋcoredataᚐTrustCenterAccessState(ctx context.Context, v any) (*coredata.TrustCenterAccessState, error) {
|
||||
if v == nil {
|
||||
return nil, nil
|
||||
}
|
||||
tmp, err := graphql.UnmarshalString(v)
|
||||
res := unmarshalOTrustCenterAccessState2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋcoredataᚐTrustCenterAccessState[tmp]
|
||||
return &res, graphql.ErrorOnPath(ctx, err)
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalOTrustCenterAccessState2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋcoredataᚐTrustCenterAccessState(ctx context.Context, sel ast.SelectionSet, v *coredata.TrustCenterAccessState) graphql.Marshaler {
|
||||
if v == nil {
|
||||
return graphql.Null
|
||||
}
|
||||
_ = sel
|
||||
_ = ctx
|
||||
res := graphql.MarshalString(marshalOTrustCenterAccessState2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋcoredataᚐTrustCenterAccessState[*v])
|
||||
return res
|
||||
}
|
||||
|
||||
var (
|
||||
unmarshalOTrustCenterAccessState2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋcoredataᚐTrustCenterAccessState = map[string]coredata.TrustCenterAccessState{
|
||||
"ACTIVE": coredata.TrustCenterAccessStateActive,
|
||||
"INACTIVE": coredata.TrustCenterAccessStateInactive,
|
||||
}
|
||||
marshalOTrustCenterAccessState2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋcoredataᚐTrustCenterAccessState = map[coredata.TrustCenterAccessState]string{
|
||||
coredata.TrustCenterAccessStateActive: "ACTIVE",
|
||||
coredata.TrustCenterAccessStateInactive: "INACTIVE",
|
||||
}
|
||||
)
|
||||
|
||||
func (ec *executionContext) unmarshalOTrustCenterDocumentAccessInput2ᚕᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐTrustCenterDocumentAccessInputᚄ(ctx context.Context, v any) ([]*types.TrustCenterDocumentAccessInput, error) {
|
||||
if v == nil {
|
||||
return nil, nil
|
||||
|
||||
@@ -21,18 +21,6 @@ import (
|
||||
|
||||
type TrustCenterAccessOrderBy = OrderBy[coredata.TrustCenterAccessOrderField]
|
||||
|
||||
func NewTrustCenterAccess(tca *coredata.TrustCenterAccess) *TrustCenterAccess {
|
||||
return &TrustCenterAccess{
|
||||
ID: tca.ID,
|
||||
Email: tca.Email,
|
||||
Name: tca.Name,
|
||||
Active: tca.Active,
|
||||
HasAcceptedNonDisclosureAgreement: tca.HasAcceptedNonDisclosureAgreement,
|
||||
CreatedAt: tca.CreatedAt,
|
||||
UpdatedAt: tca.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func NewTrustCenterAccessConnection(
|
||||
page *page.Page[*coredata.TrustCenterAccess, coredata.TrustCenterAccessOrderField],
|
||||
) *TrustCenterAccessConnection {
|
||||
@@ -54,3 +42,15 @@ func NewTrustCenterAccessEdge(tca *coredata.TrustCenterAccess, orderBy coredata.
|
||||
Node: NewTrustCenterAccess(tca),
|
||||
}
|
||||
}
|
||||
|
||||
func NewTrustCenterAccess(tca *coredata.TrustCenterAccess) *TrustCenterAccess {
|
||||
return &TrustCenterAccess{
|
||||
ID: tca.ID,
|
||||
Email: tca.Email,
|
||||
Name: tca.Name,
|
||||
State: tca.State,
|
||||
HasAcceptedNonDisclosureAgreement: tca.HasAcceptedNonDisclosureAgreement,
|
||||
CreatedAt: tca.CreatedAt,
|
||||
UpdatedAt: tca.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -615,7 +615,6 @@ type CreateTrustCenterAccessInput struct {
|
||||
TrustCenterID gid.GID `json:"trustCenterId"`
|
||||
Email mail.Addr `json:"email"`
|
||||
Name string `json:"name"`
|
||||
Active bool `json:"active"`
|
||||
}
|
||||
|
||||
type CreateTrustCenterAccessPayload struct {
|
||||
@@ -1862,7 +1861,7 @@ type TrustCenterAccess struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Email mail.Addr `json:"email"`
|
||||
Name string `json:"name"`
|
||||
Active bool `json:"active"`
|
||||
State coredata.TrustCenterAccessState `json:"state"`
|
||||
HasAcceptedNonDisclosureAgreement bool `json:"hasAcceptedNonDisclosureAgreement"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
@@ -2256,7 +2255,7 @@ type UpdateTransferImpactAssessmentPayload struct {
|
||||
type UpdateTrustCenterAccessInput struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
Active *bool `json:"active,omitempty"`
|
||||
State *coredata.TrustCenterAccessState `json:"state,omitempty"`
|
||||
Documents []*TrustCenterDocumentAccessInput `json:"documents,omitempty"`
|
||||
Reports []*TrustCenterDocumentAccessInput `json:"reports,omitempty"`
|
||||
TrustCenterFiles []*TrustCenterDocumentAccessInput `json:"trustCenterFiles,omitempty"`
|
||||
|
||||
@@ -1921,7 +1921,7 @@ func (r *mutationResolver) UpdateTrustCenterAccess(ctx context.Context, input ty
|
||||
&probo.UpdateTrustCenterAccessRequest{
|
||||
ID: input.ID,
|
||||
Name: input.Name,
|
||||
Active: input.Active,
|
||||
State: input.State,
|
||||
DocumentAccesses: documentAccesses,
|
||||
ReportAccesses: reportAccesses,
|
||||
TrustCenterFileAccesses: fileAccesses,
|
||||
|
||||
@@ -148,7 +148,7 @@ func (s TrustCenterAccessService) Request(
|
||||
TrustCenterID: req.TrustCenterID,
|
||||
Email: req.Email,
|
||||
Name: req.FullName,
|
||||
Active: false,
|
||||
State: coredata.TrustCenterAccessStateInactive,
|
||||
HasAcceptedNonDisclosureAgreement: false,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
@@ -301,7 +301,7 @@ func (s TrustCenterAccessService) LoadDocumentAccess(
|
||||
return fmt.Errorf("cannot load trust center access: %w", err)
|
||||
}
|
||||
|
||||
if !access.Active {
|
||||
if access.State != coredata.TrustCenterAccessStateActive {
|
||||
return ErrMembershipInactive
|
||||
}
|
||||
|
||||
@@ -344,7 +344,7 @@ func (s TrustCenterAccessService) LoadReportAccess(
|
||||
return fmt.Errorf("cannot load trust center access: %w", err)
|
||||
}
|
||||
|
||||
if !access.Active {
|
||||
if access.State != coredata.TrustCenterAccessStateActive {
|
||||
return ErrMembershipInactive
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ func (s TrustCenterAccessService) LoadTrustCenterFileAccess(
|
||||
return fmt.Errorf("cannot load trust center access: %w", err)
|
||||
}
|
||||
|
||||
if !access.Active {
|
||||
if access.State != coredata.TrustCenterAccessStateActive {
|
||||
return ErrMembershipInactive
|
||||
}
|
||||
|
||||
@@ -430,7 +430,7 @@ func (s *TrustCenterAccessService) GrantByIDs(
|
||||
return fmt.Errorf("cannot load trust center access: %w", err)
|
||||
}
|
||||
|
||||
shouldSendEmail := !access.Active
|
||||
shouldSendEmail := access.State != coredata.TrustCenterAccessStateActive
|
||||
now := time.Now()
|
||||
|
||||
if len(documentIDs) > 0 {
|
||||
@@ -450,7 +450,7 @@ func (s *TrustCenterAccessService) GrantByIDs(
|
||||
}
|
||||
|
||||
if shouldSendEmail {
|
||||
access.Active = true
|
||||
access.State = coredata.TrustCenterAccessStateActive
|
||||
access.UpdatedAt = now
|
||||
if err := access.Update(ctx, tx, s.svc.scope); err != nil {
|
||||
return fmt.Errorf("cannot update trust center access: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user