Use audit name in compliance page

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2026-02-27 17:21:32 +01:00
parent 6a83b53b47
commit 067c3c1680
9 changed files with 126 additions and 49 deletions

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 trust_v1
import (
"context"
"go.probo.inc/probo/pkg/coredata"
"go.probo.inc/probo/pkg/server/gqlutils"
)
func (r *mutationResolver) checkNDASignature(
ctx context.Context,
trustCenter *coredata.TrustCenter,
identity *coredata.Identity,
) error {
if trustCenter.NonDisclosureAgreementFileID == nil {
return nil
}
trustService := r.TrustService(ctx, trustCenter.ID.TenantID())
access, err := trustService.TrustCenterAccesses.GetAccess(ctx, trustCenter.ID, identity.EmailAddress)
if err != nil {
return gqlutils.Forbiddenf(ctx, "user has not signed the NDA")
}
if access.ElectronicSignatureID == nil {
return nil
}
sig, err := r.esign.GetSignatureByID(ctx, *access.ElectronicSignatureID)
if err != nil {
return gqlutils.Forbiddenf(ctx, "user has not signed the NDA")
}
switch sig.Status {
case coredata.ElectronicSignatureStatusAccepted,
coredata.ElectronicSignatureStatusProcessing,
coredata.ElectronicSignatureStatusCompleted:
return nil
default:
return gqlutils.Forbiddenf(ctx, "user has not signed the NDA")
}
}

View File

@@ -90,6 +90,7 @@ type Report implements Node {
type Audit implements Node {
id: ID!
name: String
framework: Framework! @goField(forceResolver: true)
report: Report @goField(forceResolver: true)
}

View File

@@ -73,6 +73,7 @@ type ComplexityRoot struct {
Audit struct {
Framework func(childComplexity int) int
ID func(childComplexity int) int
Name func(childComplexity int) int
Report func(childComplexity int) int
}
@@ -393,6 +394,12 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
}
return e.complexity.Audit.ID(childComplexity), true
case "Audit.name":
if e.complexity.Audit.Name == nil {
break
}
return e.complexity.Audit.Name(childComplexity), true
case "Audit.report":
if e.complexity.Audit.Report == nil {
break
@@ -1427,6 +1434,7 @@ type Report implements Node {
type Audit implements Node {
id: ID!
name: String
framework: Framework! @goField(forceResolver: true)
report: Report @goField(forceResolver: true)
}
@@ -2572,6 +2580,35 @@ func (ec *executionContext) fieldContext_Audit_id(_ context.Context, field graph
return fc, nil
}
func (ec *executionContext) _Audit_name(ctx context.Context, field graphql.CollectedField, obj *types.Audit) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Audit_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext_Audit_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Audit",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type String does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _Audit_framework(ctx context.Context, field graphql.CollectedField, obj *types.Audit) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
@@ -2779,6 +2816,8 @@ func (ec *executionContext) fieldContext_AuditEdge_node(_ context.Context, field
switch field.Name {
case "id":
return ec.fieldContext_Audit_id(ctx, field)
case "name":
return ec.fieldContext_Audit_name(ctx, field)
case "framework":
return ec.fieldContext_Audit_framework(ctx, field)
case "report":
@@ -8772,6 +8811,8 @@ func (ec *executionContext) _Audit(ctx context.Context, sel ast.SelectionSet, ob
if out.Values[i] == graphql.Null {
atomic.AddUint32(&out.Invalids, 1)
}
case "name":
out.Values[i] = ec._Audit_name(ctx, field, obj)
case "framework":
field := field

View File

@@ -35,7 +35,8 @@ func NewAuditConnection(
func NewAudit(a *coredata.Audit) *Audit {
return &Audit{
ID: a.ID,
ID: a.ID,
Name: a.Name,
}
}

View File

@@ -27,6 +27,7 @@ type AcceptElectronicSignaturePayload struct {
type Audit struct {
ID gid.GID `json:"id"`
Name *string `json:"name,omitempty"`
Framework *Framework `json:"framework"`
Report *Report `json:"report,omitempty"`
}

View File

@@ -236,41 +236,6 @@ func (r *mutationResolver) RequestAllAccesses(ctx context.Context) (*types.Reque
}, nil
}
func (r *mutationResolver) checkNDASignature(
ctx context.Context,
trustCenter *coredata.TrustCenter,
identity *coredata.Identity,
) error {
if trustCenter.NonDisclosureAgreementFileID == nil {
return nil
}
trustService := r.TrustService(ctx, trustCenter.ID.TenantID())
access, err := trustService.TrustCenterAccesses.GetAccess(ctx, trustCenter.ID, identity.EmailAddress)
if err != nil {
return gqlutils.Forbiddenf(ctx, "user has not signed the NDA")
}
if access.ElectronicSignatureID == nil {
return nil
}
sig, err := r.esign.GetSignatureByID(ctx, *access.ElectronicSignatureID)
if err != nil {
return gqlutils.Forbiddenf(ctx, "user has not signed the NDA")
}
switch sig.Status {
case coredata.ElectronicSignatureStatusAccepted,
coredata.ElectronicSignatureStatusProcessing,
coredata.ElectronicSignatureStatusCompleted:
return nil
default:
return gqlutils.Forbiddenf(ctx, "user has not signed the NDA")
}
}
// ExportDocumentPDF is the resolver for the exportDocumentPDF field.
func (r *mutationResolver) ExportDocumentPDF(ctx context.Context, input types.ExportDocumentPDFInput) (*types.ExportDocumentPDFPayload, error) {
trustService := r.TrustService(ctx, input.DocumentID.TenantID())