Remove create trust center access mutation from console api

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-03-05 15:02:49 +04:00
parent 0d1bcd21aa
commit e1fb61979b
11 changed files with 6 additions and 868 deletions

View File

@@ -1,285 +0,0 @@
/**
* @generated SignedSource<<eab35c7d6cd3334dc38eae117619b5ec>>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import { ConcreteRequest } from 'relay-runtime';
import { FragmentRefs } from "relay-runtime";
export type CreateTrustCenterAccessInput = {
email: string;
name: string;
trustCenterId: string;
};
export type NewCompliancePageAccessDialogMutation$variables = {
connections: ReadonlyArray<string>;
input: CreateTrustCenterAccessInput;
};
export type NewCompliancePageAccessDialogMutation$data = {
readonly createTrustCenterAccess: {
readonly trustCenterAccessEdge: {
readonly cursor: string;
readonly node: {
readonly id: string;
readonly " $fragmentSpreads": FragmentRefs<"CompliancePageAccessListItemFragment">;
};
};
};
};
export type NewCompliancePageAccessDialogMutation = {
response: NewCompliancePageAccessDialogMutation$data;
variables: NewCompliancePageAccessDialogMutation$variables;
};
const node: ConcreteRequest = (function(){
var v0 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "connections"
},
v1 = {
"defaultValue": null,
"kind": "LocalArgument",
"name": "input"
},
v2 = [
{
"kind": "Variable",
"name": "input",
"variableName": "input"
}
],
v3 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "cursor",
"storageKey": null
},
v4 = {
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "id",
"storageKey": null
};
return {
"fragment": {
"argumentDefinitions": [
(v0/*: any*/),
(v1/*: any*/)
],
"kind": "Fragment",
"metadata": null,
"name": "NewCompliancePageAccessDialogMutation",
"selections": [
{
"alias": null,
"args": (v2/*: any*/),
"concreteType": "CreateTrustCenterAccessPayload",
"kind": "LinkedField",
"name": "createTrustCenterAccess",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "TrustCenterAccessEdge",
"kind": "LinkedField",
"name": "trustCenterAccessEdge",
"plural": false,
"selections": [
(v3/*: any*/),
{
"alias": null,
"args": null,
"concreteType": "TrustCenterAccess",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v4/*: any*/),
{
"args": null,
"kind": "FragmentSpread",
"name": "CompliancePageAccessListItemFragment"
}
],
"storageKey": null
}
],
"storageKey": null
}
],
"storageKey": null
}
],
"type": "Mutation",
"abstractKey": null
},
"kind": "Request",
"operation": {
"argumentDefinitions": [
(v1/*: any*/),
(v0/*: any*/)
],
"kind": "Operation",
"name": "NewCompliancePageAccessDialogMutation",
"selections": [
{
"alias": null,
"args": (v2/*: any*/),
"concreteType": "CreateTrustCenterAccessPayload",
"kind": "LinkedField",
"name": "createTrustCenterAccess",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"concreteType": "TrustCenterAccessEdge",
"kind": "LinkedField",
"name": "trustCenterAccessEdge",
"plural": false,
"selections": [
(v3/*: any*/),
{
"alias": null,
"args": null,
"concreteType": "TrustCenterAccess",
"kind": "LinkedField",
"name": "node",
"plural": false,
"selections": [
(v4/*: any*/),
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "createdAt",
"storageKey": null
},
{
"alias": null,
"args": null,
"concreteType": "Profile",
"kind": "LinkedField",
"name": "profile",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "fullName",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "emailAddress",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "state",
"storageKey": null
},
(v4/*: any*/)
],
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "activeCount",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "pendingRequestCount",
"storageKey": null
},
{
"alias": null,
"args": null,
"concreteType": "ElectronicSignature",
"kind": "LinkedField",
"name": "ndaSignature",
"plural": false,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "status",
"storageKey": null
},
(v4/*: any*/)
],
"storageKey": null
},
{
"alias": "canUpdate",
"args": [
{
"kind": "Literal",
"name": "action",
"value": "core:trust-center-access:update"
}
],
"kind": "ScalarField",
"name": "permission",
"storageKey": "permission(action:\"core:trust-center-access:update\")"
}
],
"storageKey": null
}
],
"storageKey": null
},
{
"alias": null,
"args": null,
"filters": null,
"handle": "prependEdge",
"key": "",
"kind": "LinkedHandle",
"name": "trustCenterAccessEdge",
"handleArgs": [
{
"kind": "Variable",
"name": "connections",
"variableName": "connections"
}
]
}
],
"storageKey": null
}
]
},
"params": {
"cacheID": "da08cb11a0a3e5668078201ca7c634ef",
"id": null,
"metadata": {},
"name": "NewCompliancePageAccessDialogMutation",
"operationKind": "mutation",
"text": "mutation NewCompliancePageAccessDialogMutation(\n $input: CreateTrustCenterAccessInput!\n) {\n createTrustCenterAccess(input: $input) {\n trustCenterAccessEdge {\n cursor\n node {\n id\n ...CompliancePageAccessListItemFragment\n }\n }\n }\n}\n\nfragment CompliancePageAccessListItemFragment on TrustCenterAccess {\n id\n createdAt\n profile {\n fullName\n emailAddress\n state\n id\n }\n activeCount\n pendingRequestCount\n ndaSignature {\n status\n id\n }\n canUpdate: permission(action: \"core:trust-center-access:update\")\n}\n"
}
};
})();
(node as any).hash = "43aac1b4e3b2006dc097ef818860f541";
export default node;

View File

@@ -1,13 +1,11 @@
import { useTranslate } from "@probo/i18n";
import { Button, IconPlusLarge, Spinner, Table, Tbody, Td, Tr, useDialogRef } from "@probo/ui";
import { useState } from "react";
import { Spinner, Table, Tbody, Td, Tr } from "@probo/ui";
import { type PreloadedQuery, usePreloadedQuery } from "react-relay";
import { ConnectionHandler, graphql } from "relay-runtime";
import { graphql } from "relay-runtime";
import type { CompliancePageAccessPageQuery } from "#/__generated__/core/CompliancePageAccessPageQuery.graphql";
import { CompliancePageAccessList } from "./_components/CompliancePageAccessList";
import { NewCompliancePageAccessDialog } from "./_components/NewCompliancePageAccessDialog";
export const compliancePageAccessPageQuery = graphql`
query CompliancePageAccessPageQuery($organizationId: ID!) {
@@ -16,7 +14,6 @@ export const compliancePageAccessPageQuery = graphql`
... on Organization {
compliancePage: trustCenter @required(action: THROW) {
id
canCreateAccess: permission(action: "core:trust-center-access:create")
...CompliancePageAccessListFragment
}
}
@@ -28,20 +25,12 @@ export function CompliancePageAccessPage(props: { queryRef: PreloadedQuery<Compl
const { queryRef } = props;
const { __ } = useTranslate();
const dialogRef = useDialogRef();
const [editingAccessId, setEditingAccessId] = useState<string | null>(null);
const { organization } = usePreloadedQuery<CompliancePageAccessPageQuery>(compliancePageAccessPageQuery, queryRef);
if (organization.__typename !== "Organization") {
throw new Error("invalid type for node");
}
const connectionId = ConnectionHandler.getConnectionID(
organization.compliancePage.id,
"CompliancePageAccessList_accesses",
{ orderBy: { field: "CREATED_AT", direction: "DESC" } },
);
return (
<div className="space-y-4">
<div className="flex items-center justify-between">
@@ -53,23 +42,11 @@ export function CompliancePageAccessPage(props: { queryRef: PreloadedQuery<Compl
)}
</p>
</div>
{organization.compliancePage?.id
&& organization.compliancePage.canCreateAccess && (
<Button
icon={IconPlusLarge}
onClick={() => {
dialogRef.current?.open();
}}
>
{__("Add Access")}
</Button>
)}
</div>
{organization.compliancePage
? (
<CompliancePageAccessList
editingAccessId={editingAccessId}
fragmentRef={organization.compliancePage}
/>
)
@@ -84,13 +61,6 @@ export function CompliancePageAccessPage(props: { queryRef: PreloadedQuery<Compl
</Tbody>
</Table>
)}
<NewCompliancePageAccessDialog
connectionId={connectionId}
compliancePageId={organization.compliancePage.id}
onCreate={setEditingAccessId}
ref={dialogRef}
/>
</div>
);
}

View File

@@ -41,9 +41,8 @@ const fragment = graphql`
export function CompliancePageAccessList(props: {
fragmentRef: CompliancePageAccessListFragment$key;
editingAccessId: string | null;
}) {
const { editingAccessId, fragmentRef } = props;
const { fragmentRef } = props;
const { __ } = useTranslate();
@@ -86,9 +85,8 @@ export function CompliancePageAccessList(props: {
<Tbody>
{accesses.edges.map(({ node: access }) => (
<CompliancePageAccessListItem
key={`${access.id}-${editingAccessId === access.id}`}
key={access.id}
fragmentRef={access}
dialogOpen={editingAccessId === access.id}
/>
))}
</Tbody>

View File

@@ -53,12 +53,11 @@ const toggleAccessStateMutation = graphql`
export function CompliancePageAccessListItem(props: {
fragmentRef: CompliancePageAccessListItemFragment$key;
dialogOpen: boolean;
}) {
const { fragmentRef, dialogOpen: initialDialogOpen } = props;
const { fragmentRef } = props;
const { __ } = useTranslate();
const [dialogOpen, setDialogOpen] = useState<boolean>(initialDialogOpen);
const [dialogOpen, setDialogOpen] = useState<boolean>(false);
const access = useFragment<CompliancePageAccessListItemFragment$key>(fragment, fragmentRef);

View File

@@ -1,127 +0,0 @@
import { useTranslate } from "@probo/i18n";
import { Button, Dialog, DialogContent, DialogFooter, type DialogRef, Field, Spinner } from "@probo/ui";
import { type DataID, graphql } from "relay-runtime";
import { z } from "zod";
import type { NewCompliancePageAccessDialogMutation } from "#/__generated__/core/NewCompliancePageAccessDialogMutation.graphql";
import { useFormWithSchema } from "#/hooks/useFormWithSchema";
import { useMutationWithToasts } from "#/hooks/useMutationWithToasts";
const createCompliancePageAccessMutation = graphql`
mutation NewCompliancePageAccessDialogMutation(
$input: CreateTrustCenterAccessInput!
$connections: [ID!]!
) {
createTrustCenterAccess(input: $input) {
trustCenterAccessEdge @prependEdge(connections: $connections) {
cursor
node {
id
...CompliancePageAccessListItemFragment
}
}
}
}
`;
export function NewCompliancePageAccessDialog(props: {
connectionId: DataID;
compliancePageId: string;
ref: DialogRef;
onCreate: (accessId: string) => void;
}) {
const { connectionId, compliancePageId, ref, onCreate } = props;
const { __ } = useTranslate();
const inviteSchema = z.object({
name: z
.string()
.min(1, __("Name is required"))
.min(2, __("Name must be at least 2 characters long")),
email: z
.string()
.min(1, __("Email is required"))
.email(__("Please enter a valid email address")),
});
const inviteForm = useFormWithSchema(inviteSchema, {
defaultValues: { name: "", email: "" },
});
const [createInvitation, isCreating] = useMutationWithToasts<NewCompliancePageAccessDialogMutation>(
createCompliancePageAccessMutation,
{
successMessage: __("Access created successfully"),
errorMessage: __("Failed to create access"),
},
);
const handleInvite = async (data: z.infer<typeof inviteSchema>) => {
const email = data.email.trim();
await createInvitation({
variables: {
input: {
trustCenterId: compliancePageId,
email: email,
name: data.name.trim(),
},
connections: connectionId ? [connectionId] : [],
},
onCompleted: (response, errors) => {
if (errors?.length) {
return;
}
const newAccess = response.createTrustCenterAccess.trustCenterAccessEdge.node;
onCreate(newAccess.id);
setTimeout(() => {
inviteForm.reset();
ref.current?.close();
}, 50);
setTimeout(() => {
inviteForm.reset();
}, 300);
},
});
};
return (
<Dialog ref={ref} title={__("Invite External Access")}>
<form onSubmit={e => void inviteForm.handleSubmit(handleInvite)(e)}>
<DialogContent padded className="space-y-6">
<div>
<p className="text-txt-secondary text-sm mb-4">
{__("Give a person access to your compliance page")}
</p>
<Field
label={__("Full Name")}
required
error={inviteForm.formState.errors.name?.message}
{...inviteForm.register("name")}
placeholder={__("John Doe")}
/>
<div className="mt-4">
<Field
label={__("Email Address")}
required
error={inviteForm.formState.errors.email?.message}
type="email"
{...inviteForm.register("email")}
placeholder={__("john@example.com")}
/>
</div>
</div>
</DialogContent>
<DialogFooter>
<Button type="submit" disabled={isCreating}>
{isCreating && <Spinner />}
{__("Create Access")}
</Button>
</DialogFooter>
</form>
</Dialog>
);
}

View File

@@ -366,51 +366,6 @@ func (s AuthService) SendPasswordResetInstructionByEmail(
)
}
func (s AuthService) LoadOrCreateIdentity(
ctx context.Context,
req *LoadOrCreateIdentityRequest,
) (*coredata.Identity, error) {
if err := req.Validate(); err != nil {
return nil, fmt.Errorf("invalid request: %w", err)
}
var (
identity *coredata.Identity
now = time.Now()
)
if err := s.pg.WithTx(ctx, func(tx pg.Conn) error {
identity = &coredata.Identity{}
if err := identity.LoadByEmail(ctx, tx, req.Email); err != nil {
if !errors.Is(err, coredata.ErrResourceNotFound) {
return fmt.Errorf("cannot load identity: %w", err)
}
identity = &coredata.Identity{
ID: gid.New(gid.NilTenant, coredata.IdentityEntityType),
EmailAddress: req.Email,
FullName: req.FullName,
HashedPassword: nil,
EmailAddressVerified: false,
CreatedAt: now,
UpdatedAt: now,
}
err = identity.Insert(ctx, tx)
if err != nil {
return fmt.Errorf("cannot insert identity: %w", err)
}
}
return nil
}); err != nil {
return nil, err
}
return identity, nil
}
func (s AuthService) CreateIdentityWithPassword(
ctx context.Context,
req *CreateIdentityWithPasswordRequest,

View File

@@ -23,7 +23,6 @@ import (
"go.gearno.de/kit/pg"
"go.probo.inc/probo/packages/emails"
"go.probo.inc/probo/pkg/coredata"
"go.probo.inc/probo/pkg/esign"
"go.probo.inc/probo/pkg/gid"
"go.probo.inc/probo/pkg/mail"
"go.probo.inc/probo/pkg/page"
@@ -212,78 +211,6 @@ func (s TrustCenterAccessService) CountActiveDocumentAccesses(
return count, nil
}
func (s TrustCenterAccessService) Create(
ctx context.Context,
req *CreateTrustCenterAccessRequest,
) (*coredata.TrustCenterAccess, error) {
if err := req.Validate(); err != nil {
return nil, err
}
now := time.Now()
var access *coredata.TrustCenterAccess
err := s.svc.pg.WithTx(
ctx,
func(tx pg.Conn) error {
trustCenter := &coredata.TrustCenter{}
if err := trustCenter.LoadByID(ctx, tx, s.svc.scope, req.TrustCenterID); err != nil {
return fmt.Errorf("cannot load trust center: %w", err)
}
// FIXME: need to change UX
profile := &coredata.MembershipProfile{}
if err := profile.LoadByIdentityIDAndOrganizationID(ctx, tx, s.svc.scope, trustCenter.OrganizationID, req.IdentityID); err != nil {
if !errors.Is(err, coredata.ErrResourceNotFound) {
return fmt.Errorf("cannot load profile: %w", err)
}
if err := profile.Insert(ctx, tx); err != nil {
return fmt.Errorf("cannot insert profile: %w", err)
}
}
access = &coredata.TrustCenterAccess{
ID: gid.New(s.svc.scope.GetTenantID(), coredata.TrustCenterAccessEntityType),
OrganizationID: trustCenter.OrganizationID,
TenantID: s.svc.scope.GetTenantID(),
IdentityID: profile.IdentityID,
TrustCenterID: req.TrustCenterID,
CreatedAt: now,
UpdatedAt: now,
}
if trustCenter.NonDisclosureAgreementFileID != nil && s.svc.esign != nil {
sig, err := s.svc.esign.CreateSignature(
ctx,
tx,
&esign.CreateSignatureRequest{
OrganizationID: access.OrganizationID,
DocumentType: coredata.ElectronicSignatureDocumentTypeNDA,
FileID: *trustCenter.NonDisclosureAgreementFileID,
SignerEmail: profile.EmailAddress,
},
)
if err != nil {
return fmt.Errorf("cannot create pending signature: %w", err)
}
access.ElectronicSignatureID = &sig.ID
}
if err := access.Insert(ctx, tx, s.svc.scope); err != nil {
return fmt.Errorf("cannot insert trust center access: %w", err)
}
return nil
},
)
if err != nil {
return nil, err
}
return access, nil
}
func (s TrustCenterAccessService) Update(
ctx context.Context,
req *UpdateTrustCenterAccessRequest,

View File

@@ -3304,9 +3304,6 @@ type Mutation {
input: UpdateTrustCenterBrandInput!
): UpdateTrustCenterBrandPayload!
# Trust Center Access CRUD mutations
createTrustCenterAccess(
input: CreateTrustCenterAccessInput!
): CreateTrustCenterAccessPayload!
updateTrustCenterAccess(
input: UpdateTrustCenterAccessInput!
): UpdateTrustCenterAccessPayload!
@@ -3688,12 +3685,6 @@ input UpdateTrustCenterBrandInput {
darkLogoFile: Upload @goField(omittable: true)
}
input CreateTrustCenterAccessInput {
trustCenterId: ID!
email: EmailAddr!
name: String!
}
input TrustCenterDocumentAccessInput {
id: ID!
status: TrustCenterDocumentAccessStatus!
@@ -4538,10 +4529,6 @@ type UpdateTrustCenterBrandPayload {
trustCenter: TrustCenter!
}
type CreateTrustCenterAccessPayload {
trustCenterAccessEdge: TrustCenterAccessEdge!
}
type UpdateTrustCenterAccessPayload {
trustCenterAccess: TrustCenterAccess!
}

View File

@@ -432,10 +432,6 @@ type ComplexityRoot struct {
TransferImpactAssessment func(childComplexity int) int
}
CreateTrustCenterAccessPayload struct {
TrustCenterAccessEdge func(childComplexity int) int
}
CreateTrustCenterFilePayload struct {
TrustCenterFileEdge func(childComplexity int) int
}
@@ -1012,7 +1008,6 @@ type ComplexityRoot struct {
CreateStateOfApplicability func(childComplexity int, input types.CreateStateOfApplicabilityInput) int
CreateTask func(childComplexity int, input types.CreateTaskInput) int
CreateTransferImpactAssessment func(childComplexity int, input types.CreateTransferImpactAssessmentInput) int
CreateTrustCenterAccess func(childComplexity int, input types.CreateTrustCenterAccessInput) int
CreateTrustCenterFile func(childComplexity int, input types.CreateTrustCenterFileInput) int
CreateTrustCenterReference func(childComplexity int, input types.CreateTrustCenterReferenceInput) int
CreateVendor func(childComplexity int, input types.CreateVendorInput) int
@@ -2191,7 +2186,6 @@ type MutationResolver interface {
UploadTrustCenterNda(ctx context.Context, input types.UploadTrustCenterNDAInput) (*types.UploadTrustCenterNDAPayload, error)
DeleteTrustCenterNda(ctx context.Context, input types.DeleteTrustCenterNDAInput) (*types.DeleteTrustCenterNDAPayload, error)
UpdateTrustCenterBrand(ctx context.Context, input types.UpdateTrustCenterBrandInput) (*types.UpdateTrustCenterBrandPayload, error)
CreateTrustCenterAccess(ctx context.Context, input types.CreateTrustCenterAccessInput) (*types.CreateTrustCenterAccessPayload, error)
UpdateTrustCenterAccess(ctx context.Context, input types.UpdateTrustCenterAccessInput) (*types.UpdateTrustCenterAccessPayload, error)
DeleteTrustCenterAccess(ctx context.Context, input types.DeleteTrustCenterAccessInput) (*types.DeleteTrustCenterAccessPayload, error)
CreateTrustCenterReference(ctx context.Context, input types.CreateTrustCenterReferenceInput) (*types.CreateTrustCenterReferencePayload, error)
@@ -3615,13 +3609,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
return e.ComplexityRoot.CreateTransferImpactAssessmentPayload.TransferImpactAssessment(childComplexity), true
case "CreateTrustCenterAccessPayload.trustCenterAccessEdge":
if e.ComplexityRoot.CreateTrustCenterAccessPayload.TrustCenterAccessEdge == nil {
break
}
return e.ComplexityRoot.CreateTrustCenterAccessPayload.TrustCenterAccessEdge(childComplexity), true
case "CreateTrustCenterFilePayload.trustCenterFileEdge":
if e.ComplexityRoot.CreateTrustCenterFilePayload.TrustCenterFileEdge == nil {
break
@@ -5764,17 +5751,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
}
return e.ComplexityRoot.Mutation.CreateTransferImpactAssessment(childComplexity, args["input"].(types.CreateTransferImpactAssessmentInput)), true
case "Mutation.createTrustCenterAccess":
if e.ComplexityRoot.Mutation.CreateTrustCenterAccess == nil {
break
}
args, err := ec.field_Mutation_createTrustCenterAccess_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Mutation.CreateTrustCenterAccess(childComplexity, args["input"].(types.CreateTrustCenterAccessInput)), true
case "Mutation.createTrustCenterFile":
if e.ComplexityRoot.Mutation.CreateTrustCenterFile == nil {
break
@@ -10610,7 +10586,6 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
ec.unmarshalInputCreateStateOfApplicabilityInput,
ec.unmarshalInputCreateTaskInput,
ec.unmarshalInputCreateTransferImpactAssessmentInput,
ec.unmarshalInputCreateTrustCenterAccessInput,
ec.unmarshalInputCreateTrustCenterFileInput,
ec.unmarshalInputCreateTrustCenterReferenceInput,
ec.unmarshalInputCreateVendorContactInput,
@@ -14142,9 +14117,6 @@ type Mutation {
input: UpdateTrustCenterBrandInput!
): UpdateTrustCenterBrandPayload!
# Trust Center Access CRUD mutations
createTrustCenterAccess(
input: CreateTrustCenterAccessInput!
): CreateTrustCenterAccessPayload!
updateTrustCenterAccess(
input: UpdateTrustCenterAccessInput!
): UpdateTrustCenterAccessPayload!
@@ -14526,12 +14498,6 @@ input UpdateTrustCenterBrandInput {
darkLogoFile: Upload @goField(omittable: true)
}
input CreateTrustCenterAccessInput {
trustCenterId: ID!
email: EmailAddr!
name: String!
}
input TrustCenterDocumentAccessInput {
id: ID!
status: TrustCenterDocumentAccessStatus!
@@ -15376,10 +15342,6 @@ type UpdateTrustCenterBrandPayload {
trustCenter: TrustCenter!
}
type CreateTrustCenterAccessPayload {
trustCenterAccessEdge: TrustCenterAccessEdge!
}
type UpdateTrustCenterAccessPayload {
trustCenterAccess: TrustCenterAccess!
}
@@ -17684,17 +17646,6 @@ func (ec *executionContext) field_Mutation_createTransferImpactAssessment_args(c
return args, nil
}
func (ec *executionContext) field_Mutation_createTrustCenterAccess_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalNCreateTrustCenterAccessInput2goᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐCreateTrustCenterAccessInput)
if err != nil {
return nil, err
}
args["input"] = arg0
return args, nil
}
func (ec *executionContext) field_Mutation_createTrustCenterFile_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
@@ -26267,41 +26218,6 @@ func (ec *executionContext) fieldContext_CreateTransferImpactAssessmentPayload_t
return fc, nil
}
func (ec *executionContext) _CreateTrustCenterAccessPayload_trustCenterAccessEdge(ctx context.Context, field graphql.CollectedField, obj *types.CreateTrustCenterAccessPayload) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_CreateTrustCenterAccessPayload_trustCenterAccessEdge,
func(ctx context.Context) (any, error) {
return obj.TrustCenterAccessEdge, nil
},
nil,
ec.marshalNTrustCenterAccessEdge2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐTrustCenterAccessEdge,
true,
true,
)
}
func (ec *executionContext) fieldContext_CreateTrustCenterAccessPayload_trustCenterAccessEdge(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "CreateTrustCenterAccessPayload",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
switch field.Name {
case "cursor":
return ec.fieldContext_TrustCenterAccessEdge_cursor(ctx, field)
case "node":
return ec.fieldContext_TrustCenterAccessEdge_node(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type TrustCenterAccessEdge", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) _CreateTrustCenterFilePayload_trustCenterFileEdge(ctx context.Context, field graphql.CollectedField, obj *types.CreateTrustCenterFilePayload) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
@@ -35557,51 +35473,6 @@ func (ec *executionContext) fieldContext_Mutation_updateTrustCenterBrand(ctx con
return fc, nil
}
func (ec *executionContext) _Mutation_createTrustCenterAccess(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Mutation_createTrustCenterAccess,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Mutation().CreateTrustCenterAccess(ctx, fc.Args["input"].(types.CreateTrustCenterAccessInput))
},
nil,
ec.marshalNCreateTrustCenterAccessPayload2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐCreateTrustCenterAccessPayload,
true,
true,
)
}
func (ec *executionContext) fieldContext_Mutation_createTrustCenterAccess(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Mutation",
Field: field,
IsMethod: true,
IsResolver: true,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
switch field.Name {
case "trustCenterAccessEdge":
return ec.fieldContext_CreateTrustCenterAccessPayload_trustCenterAccessEdge(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type CreateTrustCenterAccessPayload", field.Name)
},
}
defer func() {
if r := recover(); r != nil {
err = ec.Recover(ctx, r)
ec.Error(ctx, err)
}
}()
ctx = graphql.WithFieldContext(ctx, fc)
if fc.Args, err = ec.field_Mutation_createTrustCenterAccess_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) _Mutation_updateTrustCenterAccess(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
@@ -66210,46 +66081,6 @@ func (ec *executionContext) unmarshalInputCreateTransferImpactAssessmentInput(ct
return it, nil
}
func (ec *executionContext) unmarshalInputCreateTrustCenterAccessInput(ctx context.Context, obj any) (types.CreateTrustCenterAccessInput, error) {
var it types.CreateTrustCenterAccessInput
asMap := map[string]any{}
for k, v := range obj.(map[string]any) {
asMap[k] = v
}
fieldsInOrder := [...]string{"trustCenterId", "email", "name"}
for _, k := range fieldsInOrder {
v, ok := asMap[k]
if !ok {
continue
}
switch k {
case "trustCenterId":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("trustCenterId"))
data, err := ec.unmarshalNID2goᚗproboᚗincᚋproboᚋpkgᚋgidᚐGID(ctx, v)
if err != nil {
return it, err
}
it.TrustCenterID = data
case "email":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email"))
data, err := ec.unmarshalNEmailAddr2goᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx, v)
if err != nil {
return it, err
}
it.Email = data
case "name":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name"))
data, err := ec.unmarshalNString2string(ctx, v)
if err != nil {
return it, err
}
it.Name = data
}
}
return it, nil
}
func (ec *executionContext) unmarshalInputCreateTrustCenterFileInput(ctx context.Context, obj any) (types.CreateTrustCenterFileInput, error) {
var it types.CreateTrustCenterFileInput
asMap := map[string]any{}
@@ -76033,45 +75864,6 @@ func (ec *executionContext) _CreateTransferImpactAssessmentPayload(ctx context.C
return out
}
var createTrustCenterAccessPayloadImplementors = []string{"CreateTrustCenterAccessPayload"}
func (ec *executionContext) _CreateTrustCenterAccessPayload(ctx context.Context, sel ast.SelectionSet, obj *types.CreateTrustCenterAccessPayload) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, createTrustCenterAccessPayloadImplementors)
out := graphql.NewFieldSet(fields)
deferred := make(map[string]*graphql.FieldSet)
for i, field := range fields {
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("CreateTrustCenterAccessPayload")
case "trustCenterAccessEdge":
out.Values[i] = ec._CreateTrustCenterAccessPayload_trustCenterAccessEdge(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
default:
panic("unknown field " + strconv.Quote(field.Name))
}
}
out.Dispatch(ctx)
if out.Invalids > 0 {
return graphql.Null
}
atomic.AddInt32(&ec.Deferred, int32(len(deferred)))
for label, dfs := range deferred {
ec.ProcessDeferredGroup(graphql.DeferredGroup{
Label: label,
Path: graphql.GetPath(ctx),
FieldSet: dfs,
Context: ctx,
})
}
return out
}
var createTrustCenterFilePayloadImplementors = []string{"CreateTrustCenterFilePayload"}
func (ec *executionContext) _CreateTrustCenterFilePayload(ctx context.Context, sel ast.SelectionSet, obj *types.CreateTrustCenterFilePayload) graphql.Marshaler {
@@ -82083,13 +81875,6 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "createTrustCenterAccess":
out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
return ec._Mutation_createTrustCenterAccess(ctx, field)
})
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "updateTrustCenterAccess":
out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
return ec._Mutation_updateTrustCenterAccess(ctx, field)
@@ -96272,25 +96057,6 @@ func (ec *executionContext) marshalNCreateTransferImpactAssessmentPayload2ᚖgo
return ec._CreateTransferImpactAssessmentPayload(ctx, sel, v)
}
func (ec *executionContext) unmarshalNCreateTrustCenterAccessInput2goᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐCreateTrustCenterAccessInput(ctx context.Context, v any) (types.CreateTrustCenterAccessInput, error) {
res, err := ec.unmarshalInputCreateTrustCenterAccessInput(ctx, v)
return res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalNCreateTrustCenterAccessPayload2goᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐCreateTrustCenterAccessPayload(ctx context.Context, sel ast.SelectionSet, v types.CreateTrustCenterAccessPayload) graphql.Marshaler {
return ec._CreateTrustCenterAccessPayload(ctx, sel, &v)
}
func (ec *executionContext) marshalNCreateTrustCenterAccessPayload2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐCreateTrustCenterAccessPayload(ctx context.Context, sel ast.SelectionSet, v *types.CreateTrustCenterAccessPayload) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return ec._CreateTrustCenterAccessPayload(ctx, sel, v)
}
func (ec *executionContext) unmarshalNCreateTrustCenterFileInput2goᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐCreateTrustCenterFileInput(ctx context.Context, v any) (types.CreateTrustCenterFileInput, error) {
res, err := ec.unmarshalInputCreateTrustCenterFileInput(ctx, v)
return res, graphql.ErrorOnPath(ctx, err)

View File

@@ -606,16 +606,6 @@ type CreateTransferImpactAssessmentPayload struct {
TransferImpactAssessment *TransferImpactAssessment `json:"transferImpactAssessment"`
}
type CreateTrustCenterAccessInput struct {
TrustCenterID gid.GID `json:"trustCenterId"`
Email mail.Addr `json:"email"`
Name string `json:"name"`
}
type CreateTrustCenterAccessPayload struct {
TrustCenterAccessEdge *TrustCenterAccessEdge `json:"trustCenterAccessEdge"`
}
type CreateTrustCenterFileInput struct {
OrganizationID gid.GID `json:"organizationId"`
Name string `json:"name"`

View File

@@ -1915,48 +1915,6 @@ func (r *mutationResolver) UpdateTrustCenterBrand(ctx context.Context, input typ
}, nil
}
// CreateTrustCenterAccess is the resolver for the createTrustCenterAccess field.
func (r *mutationResolver) CreateTrustCenterAccess(ctx context.Context, input types.CreateTrustCenterAccessInput) (*types.CreateTrustCenterAccessPayload, error) {
if err := r.authorize(ctx, input.TrustCenterID, probo.ActionTrustCenterAccessCreate); err != nil {
return nil, err
}
prb := r.ProboService(ctx, input.TrustCenterID.TenantID())
// TODO: should not create an access nor identity, but send a compliance page invitation
identity, err := r.iam.AuthService.LoadOrCreateIdentity(
ctx,
&iam.LoadOrCreateIdentityRequest{
Email: input.Email,
FullName: input.Name,
},
)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot load or create identity", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
access, err := prb.TrustCenterAccesses.Create(
ctx,
&probo.CreateTrustCenterAccessRequest{
TrustCenterID: input.TrustCenterID,
IdentityID: identity.ID,
},
)
if err != nil {
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
return nil, gqlutils.Conflict(ctx, err)
}
r.logger.ErrorCtx(ctx, "cannot create trust center access", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
return &types.CreateTrustCenterAccessPayload{
TrustCenterAccessEdge: types.NewTrustCenterAccessEdge(access, coredata.TrustCenterAccessOrderFieldCreatedAt),
}, nil
}
// UpdateTrustCenterAccess is the resolver for the updateTrustCenterAccess field.
func (r *mutationResolver) UpdateTrustCenterAccess(ctx context.Context, input types.UpdateTrustCenterAccessInput) (*types.UpdateTrustCenterAccessPayload, error) {
if err := r.authorize(ctx, input.ID, probo.ActionTrustCenterAccessUpdate); err != nil {