Use compliance page logo instead of organization one

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-01-29 15:38:26 +04:00
parent d381c5fc88
commit 65deef5d29
9 changed files with 304 additions and 45 deletions

View File

@@ -211,6 +211,7 @@ export function OrganizationForm(props: {
<Label>{__("Organization logo")}</Label> <Label>{__("Organization logo")}</Label>
<div className="flex w-max items-center gap-4"> <div className="flex w-max items-center gap-4">
<Avatar <Avatar
className="bg-transparent"
src={logoPreview || organization.logoUrl} src={logoPreview || organization.logoUrl}
name={organization.name} name={organization.name}
size="xl" size="xl"

View File

@@ -77,11 +77,11 @@ export function OrganizationSidebar({
return ( return (
<Card className="p-6 relative overflow-hidden border-b border-border-low isolate"> <Card className="p-6 relative overflow-hidden border-b border-border-low isolate">
<div className="h-21 bg-[#044E4114] absolute top-0 left-0 right-0 -z-1"></div> <div className="h-21 bg-[#044E4114] absolute top-0 left-0 right-0 -z-1"></div>
{trustCenter.organization.logoUrl {trustCenter.logoFileUrl
? ( ? (
<img <img
alt="" alt=""
src={trustCenter.organization.logoUrl} src={trustCenter.logoFileUrl}
className="size-24 rounded-2xl border border-border-mid shadow-mid bg-level-1" className="size-24 rounded-2xl border border-border-mid shadow-mid bg-level-1"
/> />
) )

View File

@@ -12,13 +12,14 @@ export const currentTrustGraphQuery = graphql`
slug slug
isViewerMember isViewerMember
hasAcceptedNonDisclosureAgreement hasAcceptedNonDisclosureAgreement
logoFileUrl
darkLogoFileUrl
ndaFileName ndaFileName
ndaFileUrl ndaFileUrl
organization { organization {
name name
description description
websiteUrl websiteUrl
logoUrl
email email
headquarterAddress headquarterAddress
} }

View File

@@ -1,5 +1,5 @@
/** /**
* @generated SignedSource<<3dbd64be3b8852cb9bfca995f648dd65>> * @generated SignedSource<<6ca2f281af2d0dfbe388980e05bc8d0c>>
* @lightSyntaxTransform * @lightSyntaxTransform
* @nogrep * @nogrep
*/ */
@@ -21,16 +21,17 @@ export type TrustGraphCurrentQuery$data = {
}; };
}>; }>;
}; };
readonly darkLogoFileUrl: string | null | undefined;
readonly hasAcceptedNonDisclosureAgreement: boolean; readonly hasAcceptedNonDisclosureAgreement: boolean;
readonly id: string; readonly id: string;
readonly isViewerMember: boolean; readonly isViewerMember: boolean;
readonly logoFileUrl: string | null | undefined;
readonly ndaFileName: string | null | undefined; readonly ndaFileName: string | null | undefined;
readonly ndaFileUrl: string | null | undefined; readonly ndaFileUrl: string | null | undefined;
readonly organization: { readonly organization: {
readonly description: string | null | undefined; readonly description: string | null | undefined;
readonly email: string | null | undefined; readonly email: string | null | undefined;
readonly headquarterAddress: string | null | undefined; readonly headquarterAddress: string | null | undefined;
readonly logoUrl: string | null | undefined;
readonly name: string; readonly name: string;
readonly websiteUrl: string | null | undefined; readonly websiteUrl: string | null | undefined;
}; };
@@ -97,52 +98,59 @@ v6 = {
"alias": null, "alias": null,
"args": null, "args": null,
"kind": "ScalarField", "kind": "ScalarField",
"name": "ndaFileName", "name": "logoFileUrl",
"storageKey": null "storageKey": null
}, },
v7 = { v7 = {
"alias": null, "alias": null,
"args": null, "args": null,
"kind": "ScalarField", "kind": "ScalarField",
"name": "ndaFileUrl", "name": "darkLogoFileUrl",
"storageKey": null "storageKey": null
}, },
v8 = { v8 = {
"alias": null, "alias": null,
"args": null, "args": null,
"kind": "ScalarField", "kind": "ScalarField",
"name": "name", "name": "ndaFileName",
"storageKey": null "storageKey": null
}, },
v9 = { v9 = {
"alias": null, "alias": null,
"args": null, "args": null,
"kind": "ScalarField", "kind": "ScalarField",
"name": "description", "name": "ndaFileUrl",
"storageKey": null "storageKey": null
}, },
v10 = { v10 = {
"alias": null, "alias": null,
"args": null, "args": null,
"kind": "ScalarField", "kind": "ScalarField",
"name": "websiteUrl", "name": "name",
"storageKey": null "storageKey": null
}, },
v11 = { v11 = {
"alias": null, "alias": null,
"args": null, "args": null,
"kind": "ScalarField", "kind": "ScalarField",
"name": "logoUrl", "name": "description",
"storageKey": null "storageKey": null
}, },
v12 = { v12 = {
"alias": null, "alias": null,
"args": null, "args": null,
"kind": "ScalarField", "kind": "ScalarField",
"name": "headquarterAddress", "name": "websiteUrl",
"storageKey": null "storageKey": null
}, },
v13 = { v13 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "headquarterAddress",
"storageKey": null
},
v14 = {
"alias": "vendorInfo", "alias": "vendorInfo",
"args": [ "args": [
{ {
@@ -166,35 +174,35 @@ v13 = {
], ],
"storageKey": "vendors(first:0)" "storageKey": "vendors(first:0)"
}, },
v14 = [ v15 = [
{ {
"kind": "Literal", "kind": "Literal",
"name": "first", "name": "first",
"value": 50 "value": 50
} }
], ],
v15 = { v16 = {
"alias": null, "alias": null,
"args": null, "args": null,
"kind": "ScalarField", "kind": "ScalarField",
"name": "category", "name": "category",
"storageKey": null "storageKey": null
}, },
v16 = [ v17 = [
{ {
"kind": "Literal", "kind": "Literal",
"name": "first", "name": "first",
"value": 5 "value": 5
} }
], ],
v17 = { v18 = {
"alias": null, "alias": null,
"args": null, "args": null,
"kind": "ScalarField", "kind": "ScalarField",
"name": "isUserAuthorized", "name": "isUserAuthorized",
"storageKey": null "storageKey": null
}, },
v18 = { v19 = {
"alias": null, "alias": null,
"args": null, "args": null,
"kind": "ScalarField", "kind": "ScalarField",
@@ -235,6 +243,8 @@ return {
(v5/*: any*/), (v5/*: any*/),
(v6/*: any*/), (v6/*: any*/),
(v7/*: any*/), (v7/*: any*/),
(v8/*: any*/),
(v9/*: any*/),
{ {
"alias": null, "alias": null,
"args": null, "args": null,
@@ -243,12 +253,11 @@ return {
"name": "organization", "name": "organization",
"plural": false, "plural": false,
"selections": [ "selections": [
(v8/*: any*/),
(v9/*: any*/),
(v10/*: any*/), (v10/*: any*/),
(v11/*: any*/), (v11/*: any*/),
(v12/*: any*/),
(v0/*: any*/), (v0/*: any*/),
(v12/*: any*/) (v13/*: any*/)
], ],
"storageKey": null "storageKey": null
}, },
@@ -257,10 +266,10 @@ return {
"kind": "FragmentSpread", "kind": "FragmentSpread",
"name": "OverviewPageFragment" "name": "OverviewPageFragment"
}, },
(v13/*: any*/), (v14/*: any*/),
{ {
"alias": null, "alias": null,
"args": (v14/*: any*/), "args": (v15/*: any*/),
"concreteType": "AuditConnection", "concreteType": "AuditConnection",
"kind": "LinkedField", "kind": "LinkedField",
"name": "audits", "name": "audits",
@@ -338,6 +347,8 @@ return {
(v5/*: any*/), (v5/*: any*/),
(v6/*: any*/), (v6/*: any*/),
(v7/*: any*/), (v7/*: any*/),
(v8/*: any*/),
(v9/*: any*/),
{ {
"alias": null, "alias": null,
"args": null, "args": null,
@@ -346,12 +357,11 @@ return {
"name": "organization", "name": "organization",
"plural": false, "plural": false,
"selections": [ "selections": [
(v8/*: any*/),
(v9/*: any*/),
(v10/*: any*/), (v10/*: any*/),
(v11/*: any*/), (v11/*: any*/),
(v0/*: any*/),
(v12/*: any*/), (v12/*: any*/),
(v0/*: any*/),
(v13/*: any*/),
(v2/*: any*/) (v2/*: any*/)
], ],
"storageKey": null "storageKey": null
@@ -387,9 +397,15 @@ return {
"plural": false, "plural": false,
"selections": [ "selections": [
(v2/*: any*/), (v2/*: any*/),
(v8/*: any*/), (v10/*: any*/),
(v11/*: any*/), {
(v10/*: any*/) "alias": null,
"args": null,
"kind": "ScalarField",
"name": "logoUrl",
"storageKey": null
},
(v12/*: any*/)
], ],
"storageKey": null "storageKey": null
} }
@@ -437,9 +453,9 @@ return {
"name": "countries", "name": "countries",
"storageKey": null "storageKey": null
}, },
(v8/*: any*/),
(v15/*: any*/),
(v10/*: any*/), (v10/*: any*/),
(v16/*: any*/),
(v12/*: any*/),
{ {
"alias": null, "alias": null,
"args": null, "args": null,
@@ -458,7 +474,7 @@ return {
}, },
{ {
"alias": null, "alias": null,
"args": (v16/*: any*/), "args": (v17/*: any*/),
"concreteType": "DocumentConnection", "concreteType": "DocumentConnection",
"kind": "LinkedField", "kind": "LinkedField",
"name": "documents", "name": "documents",
@@ -488,8 +504,8 @@ return {
"name": "title", "name": "title",
"storageKey": null "storageKey": null
}, },
(v17/*: any*/),
(v18/*: any*/), (v18/*: any*/),
(v19/*: any*/),
{ {
"alias": null, "alias": null,
"args": null, "args": null,
@@ -508,7 +524,7 @@ return {
}, },
{ {
"alias": null, "alias": null,
"args": (v16/*: any*/), "args": (v17/*: any*/),
"concreteType": "TrustCenterFileConnection", "concreteType": "TrustCenterFileConnection",
"kind": "LinkedField", "kind": "LinkedField",
"name": "trustCenterFiles", "name": "trustCenterFiles",
@@ -531,10 +547,10 @@ return {
"plural": false, "plural": false,
"selections": [ "selections": [
(v2/*: any*/), (v2/*: any*/),
(v15/*: any*/), (v16/*: any*/),
(v8/*: any*/), (v10/*: any*/),
(v17/*: any*/), (v18/*: any*/),
(v18/*: any*/) (v19/*: any*/)
], ],
"storageKey": null "storageKey": null
} }
@@ -544,10 +560,10 @@ return {
], ],
"storageKey": "trustCenterFiles(first:5)" "storageKey": "trustCenterFiles(first:5)"
}, },
(v13/*: any*/), (v14/*: any*/),
{ {
"alias": null, "alias": null,
"args": (v14/*: any*/), "args": (v15/*: any*/),
"concreteType": "AuditConnection", "concreteType": "AuditConnection",
"kind": "LinkedField", "kind": "LinkedField",
"name": "audits", "name": "audits",
@@ -586,8 +602,8 @@ return {
"name": "filename", "name": "filename",
"storageKey": null "storageKey": null
}, },
(v17/*: any*/), (v18/*: any*/),
(v18/*: any*/) (v19/*: any*/)
], ],
"storageKey": null "storageKey": null
}, },
@@ -600,7 +616,7 @@ return {
"plural": false, "plural": false,
"selections": [ "selections": [
(v2/*: any*/), (v2/*: any*/),
(v8/*: any*/), (v10/*: any*/),
{ {
"alias": null, "alias": null,
"args": null, "args": null,
@@ -633,16 +649,16 @@ return {
] ]
}, },
"params": { "params": {
"cacheID": "211acd806d18a69efb76df5c7e6822bc", "cacheID": "f0861cffe9c1b2e60c6408a69ce5690f",
"id": null, "id": null,
"metadata": {}, "metadata": {},
"name": "TrustGraphCurrentQuery", "name": "TrustGraphCurrentQuery",
"operationKind": "query", "operationKind": "query",
"text": "query TrustGraphCurrentQuery {\n viewer {\n email\n fullName\n id\n }\n currentTrustCenter {\n id\n slug\n isViewerMember\n hasAcceptedNonDisclosureAgreement\n ndaFileName\n ndaFileUrl\n organization {\n name\n description\n websiteUrl\n logoUrl\n email\n headquarterAddress\n id\n }\n ...OverviewPageFragment\n vendorInfo: vendors(first: 0) {\n totalCount\n }\n audits(first: 50) {\n edges {\n node {\n id\n ...AuditRowFragment\n }\n }\n }\n }\n}\n\nfragment AuditRowFragment on Audit {\n report {\n id\n filename\n isUserAuthorized\n hasUserRequestedAccess\n }\n framework {\n id\n name\n lightLogoURL\n darkLogoURL\n }\n}\n\nfragment DocumentRowFragment on Document {\n id\n title\n isUserAuthorized\n hasUserRequestedAccess\n}\n\nfragment OverviewPageFragment on TrustCenter {\n references(first: 14) {\n edges {\n node {\n id\n name\n logoUrl\n websiteUrl\n }\n }\n }\n vendors(first: 3) {\n edges {\n node {\n id\n countries\n ...VendorRowFragment\n }\n }\n }\n documents(first: 5) {\n edges {\n node {\n id\n ...DocumentRowFragment\n documentType\n }\n }\n }\n trustCenterFiles(first: 5) {\n edges {\n node {\n id\n category\n ...TrustCenterFileRowFragment\n }\n }\n }\n}\n\nfragment TrustCenterFileRowFragment on TrustCenterFile {\n id\n name\n isUserAuthorized\n hasUserRequestedAccess\n}\n\nfragment VendorRowFragment on Vendor {\n id\n name\n category\n websiteUrl\n privacyPolicyUrl\n countries\n}\n" "text": "query TrustGraphCurrentQuery {\n viewer {\n email\n fullName\n id\n }\n currentTrustCenter {\n id\n slug\n isViewerMember\n hasAcceptedNonDisclosureAgreement\n logoFileUrl\n darkLogoFileUrl\n ndaFileName\n ndaFileUrl\n organization {\n name\n description\n websiteUrl\n email\n headquarterAddress\n id\n }\n ...OverviewPageFragment\n vendorInfo: vendors(first: 0) {\n totalCount\n }\n audits(first: 50) {\n edges {\n node {\n id\n ...AuditRowFragment\n }\n }\n }\n }\n}\n\nfragment AuditRowFragment on Audit {\n report {\n id\n filename\n isUserAuthorized\n hasUserRequestedAccess\n }\n framework {\n id\n name\n lightLogoURL\n darkLogoURL\n }\n}\n\nfragment DocumentRowFragment on Document {\n id\n title\n isUserAuthorized\n hasUserRequestedAccess\n}\n\nfragment OverviewPageFragment on TrustCenter {\n references(first: 14) {\n edges {\n node {\n id\n name\n logoUrl\n websiteUrl\n }\n }\n }\n vendors(first: 3) {\n edges {\n node {\n id\n countries\n ...VendorRowFragment\n }\n }\n }\n documents(first: 5) {\n edges {\n node {\n id\n ...DocumentRowFragment\n documentType\n }\n }\n }\n trustCenterFiles(first: 5) {\n edges {\n node {\n id\n category\n ...TrustCenterFileRowFragment\n }\n }\n }\n}\n\nfragment TrustCenterFileRowFragment on TrustCenterFile {\n id\n name\n isUserAuthorized\n hasUserRequestedAccess\n}\n\nfragment VendorRowFragment on Vendor {\n id\n name\n category\n websiteUrl\n privacyPolicyUrl\n countries\n}\n"
} }
}; };
})(); })();
(node as any).hash = "7623a958ac84c0615c8f4487ecda9224"; (node as any).hash = "566fdb9af999e51fdf50e2eccca60941";
export default node; export default node;

View File

@@ -491,6 +491,8 @@ type TrustCenter implements Node {
id: ID! id: ID!
active: Boolean! active: Boolean!
slug: String! slug: String!
logoFileUrl: String @goField(forceResolver: true)
darkLogoFileUrl: String @goField(forceResolver: true)
ndaFileName: String ndaFileName: String
ndaFileUrl: String @goField(forceResolver: true) ndaFileUrl: String @goField(forceResolver: true)
organization: Organization! @goField(forceResolver: true) organization: Organization! @goField(forceResolver: true)

View File

@@ -185,10 +185,12 @@ type ComplexityRoot struct {
TrustCenter struct { TrustCenter struct {
Active func(childComplexity int) int Active func(childComplexity int) int
Audits func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey) int Audits func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey) int
DarkLogoFileURL func(childComplexity int) int
Documents func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey) int Documents func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey) int
HasAcceptedNonDisclosureAgreement func(childComplexity int) int HasAcceptedNonDisclosureAgreement func(childComplexity int) int
ID func(childComplexity int) int ID func(childComplexity int) int
IsViewerMember func(childComplexity int) int IsViewerMember func(childComplexity int) int
LogoFileURL func(childComplexity int) int
NdaFileName func(childComplexity int) int NdaFileName func(childComplexity int) int
NdaFileURL func(childComplexity int) int NdaFileURL func(childComplexity int) int
Organization func(childComplexity int) int Organization func(childComplexity int) int
@@ -304,6 +306,9 @@ type ReportResolver interface {
HasUserRequestedAccess(ctx context.Context, obj *types.Report) (bool, error) HasUserRequestedAccess(ctx context.Context, obj *types.Report) (bool, error)
} }
type TrustCenterResolver interface { type TrustCenterResolver interface {
LogoFileURL(ctx context.Context, obj *types.TrustCenter) (*string, error)
DarkLogoFileURL(ctx context.Context, obj *types.TrustCenter) (*string, error)
NdaFileURL(ctx context.Context, obj *types.TrustCenter) (*string, error) NdaFileURL(ctx context.Context, obj *types.TrustCenter) (*string, error)
Organization(ctx context.Context, obj *types.TrustCenter) (*types.Organization, error) Organization(ctx context.Context, obj *types.TrustCenter) (*types.Organization, error)
IsViewerMember(ctx context.Context, obj *types.TrustCenter) (bool, error) IsViewerMember(ctx context.Context, obj *types.TrustCenter) (bool, error)
@@ -790,6 +795,12 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
} }
return e.complexity.TrustCenter.Audits(childComplexity, args["first"].(*int), args["after"].(*page.CursorKey), args["last"].(*int), args["before"].(*page.CursorKey)), true return e.complexity.TrustCenter.Audits(childComplexity, args["first"].(*int), args["after"].(*page.CursorKey), args["last"].(*int), args["before"].(*page.CursorKey)), true
case "TrustCenter.darkLogoFileUrl":
if e.complexity.TrustCenter.DarkLogoFileURL == nil {
break
}
return e.complexity.TrustCenter.DarkLogoFileURL(childComplexity), true
case "TrustCenter.documents": case "TrustCenter.documents":
if e.complexity.TrustCenter.Documents == nil { if e.complexity.TrustCenter.Documents == nil {
break break
@@ -819,6 +830,12 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
} }
return e.complexity.TrustCenter.IsViewerMember(childComplexity), true return e.complexity.TrustCenter.IsViewerMember(childComplexity), true
case "TrustCenter.logoFileUrl":
if e.complexity.TrustCenter.LogoFileURL == nil {
break
}
return e.complexity.TrustCenter.LogoFileURL(childComplexity), true
case "TrustCenter.ndaFileName": case "TrustCenter.ndaFileName":
if e.complexity.TrustCenter.NdaFileName == nil { if e.complexity.TrustCenter.NdaFileName == nil {
break break
@@ -1705,6 +1722,8 @@ type TrustCenter implements Node {
id: ID! id: ID!
active: Boolean! active: Boolean!
slug: String! slug: String!
logoFileUrl: String @goField(forceResolver: true)
darkLogoFileUrl: String @goField(forceResolver: true)
ndaFileName: String ndaFileName: String
ndaFileUrl: String @goField(forceResolver: true) ndaFileUrl: String @goField(forceResolver: true)
organization: Organization! @goField(forceResolver: true) organization: Organization! @goField(forceResolver: true)
@@ -4213,6 +4232,10 @@ func (ec *executionContext) fieldContext_Query_currentTrustCenter(_ context.Cont
return ec.fieldContext_TrustCenter_active(ctx, field) return ec.fieldContext_TrustCenter_active(ctx, field)
case "slug": case "slug":
return ec.fieldContext_TrustCenter_slug(ctx, field) return ec.fieldContext_TrustCenter_slug(ctx, field)
case "logoFileUrl":
return ec.fieldContext_TrustCenter_logoFileUrl(ctx, field)
case "darkLogoFileUrl":
return ec.fieldContext_TrustCenter_darkLogoFileUrl(ctx, field)
case "ndaFileName": case "ndaFileName":
return ec.fieldContext_TrustCenter_ndaFileName(ctx, field) return ec.fieldContext_TrustCenter_ndaFileName(ctx, field)
case "ndaFileUrl": case "ndaFileUrl":
@@ -4621,6 +4644,64 @@ func (ec *executionContext) fieldContext_TrustCenter_slug(_ context.Context, fie
return fc, nil return fc, nil
} }
func (ec *executionContext) _TrustCenter_logoFileUrl(ctx context.Context, field graphql.CollectedField, obj *types.TrustCenter) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_TrustCenter_logoFileUrl,
func(ctx context.Context) (any, error) {
return ec.resolvers.TrustCenter().LogoFileURL(ctx, obj)
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext_TrustCenter_logoFileUrl(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "TrustCenter",
Field: field,
IsMethod: true,
IsResolver: true,
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) _TrustCenter_darkLogoFileUrl(ctx context.Context, field graphql.CollectedField, obj *types.TrustCenter) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_TrustCenter_darkLogoFileUrl,
func(ctx context.Context) (any, error) {
return ec.resolvers.TrustCenter().DarkLogoFileURL(ctx, obj)
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext_TrustCenter_darkLogoFileUrl(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "TrustCenter",
Field: field,
IsMethod: true,
IsResolver: true,
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) _TrustCenter_ndaFileName(ctx context.Context, field graphql.CollectedField, obj *types.TrustCenter) (ret graphql.Marshaler) { func (ec *executionContext) _TrustCenter_ndaFileName(ctx context.Context, field graphql.CollectedField, obj *types.TrustCenter) (ret graphql.Marshaler) {
return graphql.ResolveField( return graphql.ResolveField(
ctx, ctx,
@@ -9204,6 +9285,72 @@ func (ec *executionContext) _TrustCenter(ctx context.Context, sel ast.SelectionS
if out.Values[i] == graphql.Null { if out.Values[i] == graphql.Null {
atomic.AddUint32(&out.Invalids, 1) atomic.AddUint32(&out.Invalids, 1)
} }
case "logoFileUrl":
field := field
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._TrustCenter_logoFileUrl(ctx, field, obj)
return res
}
if field.Deferrable != nil {
dfs, ok := deferred[field.Deferrable.Label]
di := 0
if ok {
dfs.AddField(field)
di = len(dfs.Values) - 1
} else {
dfs = graphql.NewFieldSet([]graphql.CollectedField{field})
deferred[field.Deferrable.Label] = dfs
}
dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler {
return innerFunc(ctx, dfs)
})
// don't run the out.Concurrently() call below
out.Values[i] = graphql.Null
continue
}
out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
case "darkLogoFileUrl":
field := field
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._TrustCenter_darkLogoFileUrl(ctx, field, obj)
return res
}
if field.Deferrable != nil {
dfs, ok := deferred[field.Deferrable.Label]
di := 0
if ok {
dfs.AddField(field)
di = len(dfs.Values) - 1
} else {
dfs = graphql.NewFieldSet([]graphql.CollectedField{field})
deferred[field.Deferrable.Label] = dfs
}
dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler {
return innerFunc(ctx, dfs)
})
// don't run the out.Concurrently() call below
out.Values[i] = graphql.Null
continue
}
out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
case "ndaFileName": case "ndaFileName":
out.Values[i] = ec._TrustCenter_ndaFileName(ctx, field, obj) out.Values[i] = ec._TrustCenter_ndaFileName(ctx, field, obj)
case "ndaFileUrl": case "ndaFileUrl":

View File

@@ -174,6 +174,8 @@ type TrustCenter struct {
ID gid.GID `json:"id"` ID gid.GID `json:"id"`
Active bool `json:"active"` Active bool `json:"active"`
Slug string `json:"slug"` Slug string `json:"slug"`
LogoFileURL *string `json:"logoFileUrl,omitempty"`
DarkLogoFileURL *string `json:"darkLogoFileUrl,omitempty"`
NdaFileName *string `json:"ndaFileName,omitempty"` NdaFileName *string `json:"ndaFileName,omitempty"`
NdaFileURL *string `json:"ndaFileUrl,omitempty"` NdaFileURL *string `json:"ndaFileUrl,omitempty"`
Organization *Organization `json:"organization"` Organization *Organization `json:"organization"`

View File

@@ -871,6 +871,20 @@ func (r *reportResolver) HasUserRequestedAccess(ctx context.Context, obj *types.
return true, nil return true, nil
} }
// LogoFileURL is the resolver for the logoFileUrl field.
func (r *trustCenterResolver) LogoFileURL(ctx context.Context, obj *types.TrustCenter) (*string, error) {
trustService := r.TrustService(ctx, obj.ID.TenantID())
return trustService.TrustCenters.GenerateLogoURL(ctx, obj.ID, 1*time.Hour)
}
// DarkLogoFileURL is the resolver for the darkLogoFileUrl field.
func (r *trustCenterResolver) DarkLogoFileURL(ctx context.Context, obj *types.TrustCenter) (*string, error) {
trustService := r.TrustService(ctx, obj.ID.TenantID())
return trustService.TrustCenters.GenerateLogoURL(ctx, obj.ID, 1*time.Hour)
}
// NdaFileURL is the resolver for the ndaFileUrl field. // NdaFileURL is the resolver for the ndaFileUrl field.
func (r *trustCenterResolver) NdaFileURL(ctx context.Context, obj *types.TrustCenter) (*string, error) { func (r *trustCenterResolver) NdaFileURL(ctx context.Context, obj *types.TrustCenter) (*string, error) {
trustService := r.TrustService(ctx, obj.ID.TenantID()) trustService := r.TrustService(ctx, obj.ID.TenantID())

View File

@@ -140,3 +140,79 @@ func (s TrustCenterService) GenerateNDAFileURL(
return presignedReq.URL, nil return presignedReq.URL, nil
} }
func (s TrustCenterService) GenerateLogoURL(
ctx context.Context,
compliancePageID gid.GID,
expiresIn time.Duration,
) (*string, error) {
compliancePage, _, err := s.Get(ctx, compliancePageID)
if err != nil {
return nil, fmt.Errorf("cannot get compliance page: %w", err)
}
if compliancePage.LogoFileID == nil {
return nil, nil
}
url, err := s.generateFileURL(ctx, *compliancePage.LogoFileID, expiresIn)
if err != nil {
return nil, fmt.Errorf("cannot generate file URL: %w", err)
}
return url, nil
}
func (s TrustCenterService) GenerateDarkLogoURL(
ctx context.Context,
compliancePageID gid.GID,
expiresIn time.Duration,
) (*string, error) {
compliancePage, _, err := s.Get(ctx, compliancePageID)
if err != nil {
return nil, fmt.Errorf("cannot get compliance page: %w", err)
}
if compliancePage.DarkLogoFileID == nil {
return nil, nil
}
url, err := s.generateFileURL(ctx, *compliancePage.DarkLogoFileID, expiresIn)
if err != nil {
return nil, fmt.Errorf("cannot generate file URL: %w", err)
}
return url, nil
}
func (s TrustCenterService) generateFileURL(ctx context.Context, fileID gid.GID, expiresIn time.Duration) (*string, error) {
file := &coredata.File{}
if err := s.svc.pg.WithConn(
ctx,
func(conn pg.Conn) error {
return file.LoadByID(ctx, conn, s.svc.scope, fileID)
},
); err != nil {
return nil, fmt.Errorf("cannot load file: %w", err)
}
presignClient := s3.NewPresignClient(s.svc.s3)
encodedFilename := url.QueryEscape(file.FileName)
contentDisposition := fmt.Sprintf("attachment; filename=\"%s\"; filename*=UTF-8''%s",
encodedFilename, encodedFilename)
presignedReq, err := presignClient.PresignGetObject(ctx, &s3.GetObjectInput{
Bucket: aws.String(s.svc.bucket),
Key: aws.String(file.FileKey),
ResponseCacheControl: aws.String("max-age=3600, public"),
ResponseContentDisposition: aws.String(contentDisposition),
}, func(opts *s3.PresignOptions) {
opts.Expires = expiresIn
})
if err != nil {
return nil, fmt.Errorf("cannot presign GetObject request: %w", err)
}
return &presignedReq.URL, nil
}