Fix create conrtrol importance is missing
Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
@@ -10,7 +10,17 @@ import { Textarea } from "@/components/ui/textarea";
|
|||||||
import { useToast } from "@/hooks/use-toast";
|
import { useToast } from "@/hooks/use-toast";
|
||||||
import { HelpCircle } from "lucide-react";
|
import { HelpCircle } from "lucide-react";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { CreateControlPageCreateControlMutation } from "./__generated__/CreateControlPageCreateControlMutation.graphql";
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from "@/components/ui/select";
|
||||||
|
import {
|
||||||
|
CreateControlPageCreateControlMutation,
|
||||||
|
ControlImportance,
|
||||||
|
} from "./__generated__/CreateControlPageCreateControlMutation.graphql";
|
||||||
|
|
||||||
const createControlMutation = graphql`
|
const createControlMutation = graphql`
|
||||||
mutation CreateControlPageCreateControlMutation(
|
mutation CreateControlPageCreateControlMutation(
|
||||||
@@ -71,7 +81,7 @@ function EditableField({
|
|||||||
}
|
}
|
||||||
className={cn(
|
className={cn(
|
||||||
"w-full resize-none",
|
"w-full resize-none",
|
||||||
required && !value && "border-red-500",
|
required && !value && "border-red-500"
|
||||||
)}
|
)}
|
||||||
placeholder={`Enter ${label.toLowerCase()}`}
|
placeholder={`Enter ${label.toLowerCase()}`}
|
||||||
rows={4}
|
rows={4}
|
||||||
@@ -100,6 +110,7 @@ function CreateControlPageContent() {
|
|||||||
name: "",
|
name: "",
|
||||||
description: "",
|
description: "",
|
||||||
category: "",
|
category: "",
|
||||||
|
importance: "MANDATORY" as ControlImportance,
|
||||||
});
|
});
|
||||||
|
|
||||||
const [commit, isInFlight] =
|
const [commit, isInFlight] =
|
||||||
@@ -126,7 +137,7 @@ function CreateControlPageContent() {
|
|||||||
|
|
||||||
const connectionId = ConnectionHandler.getConnectionID(
|
const connectionId = ConnectionHandler.getConnectionID(
|
||||||
frameworkId!,
|
frameworkId!,
|
||||||
"FrameworkOverviewPage_controls",
|
"FrameworkOverviewPage_controls"
|
||||||
);
|
);
|
||||||
|
|
||||||
commit({
|
commit({
|
||||||
@@ -136,6 +147,7 @@ function CreateControlPageContent() {
|
|||||||
name: formData.name,
|
name: formData.name,
|
||||||
description: formData.description,
|
description: formData.description,
|
||||||
category: formData.category,
|
category: formData.category,
|
||||||
|
importance: formData.importance,
|
||||||
},
|
},
|
||||||
connections: [connectionId],
|
connections: [connectionId],
|
||||||
},
|
},
|
||||||
@@ -155,7 +167,7 @@ function CreateControlPageContent() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
navigate(
|
navigate(
|
||||||
`/organizations/${organizationId}/frameworks/${frameworkId}/controls/${data.createControl.controlEdge.node.id}`,
|
`/organizations/${organizationId}/frameworks/${frameworkId}/controls/${data.createControl.controlEdge.node.id}`
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
onError(error) {
|
onError(error) {
|
||||||
@@ -207,6 +219,27 @@ function CreateControlPageContent() {
|
|||||||
helpText="Provide a detailed description of the control"
|
helpText="Provide a detailed description of the control"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label htmlFor="importance" className="text-sm font-medium">
|
||||||
|
Importance
|
||||||
|
</Label>
|
||||||
|
<Select
|
||||||
|
value={formData.importance}
|
||||||
|
onValueChange={(value) =>
|
||||||
|
handleFieldChange("importance", value as ControlImportance)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<SelectTrigger>
|
||||||
|
<SelectValue placeholder="Select importance" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="MANDATORY">Mandatory</SelectItem>
|
||||||
|
<SelectItem value="PREFERRED">Preferred</SelectItem>
|
||||||
|
<SelectItem value="ADVANCED">Advanced</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="flex justify-end gap-3">
|
<div className="flex justify-end gap-3">
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -215,7 +248,7 @@ function CreateControlPageContent() {
|
|||||||
navigate(
|
navigate(
|
||||||
`/organizations/${
|
`/organizations/${
|
||||||
frameworkId?.split(":")[1]
|
frameworkId?.split(":")[1]
|
||||||
}/frameworks/${frameworkId}`,
|
}/frameworks/${frameworkId}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -272,25 +272,6 @@ func (r *mutationResolver) CreateFramework(ctx context.Context, input types.Crea
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateControl is the resolver for the createControl field.
|
|
||||||
func (r *mutationResolver) CreateControl(ctx context.Context, input types.CreateControlInput) (*types.CreateControlPayload, error) {
|
|
||||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.FrameworkID.TenantID())
|
|
||||||
|
|
||||||
control, err := svc.Controls.Create(ctx, probo.CreateControlRequest{
|
|
||||||
FrameworkID: input.FrameworkID,
|
|
||||||
Name: input.Name,
|
|
||||||
Description: input.Description,
|
|
||||||
Category: input.Category,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("cannot create control: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &types.CreateControlPayload{
|
|
||||||
ControlEdge: types.NewControlEdge(control),
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateFramework is the resolver for the updateFramework field.
|
// UpdateFramework is the resolver for the updateFramework field.
|
||||||
func (r *mutationResolver) UpdateFramework(ctx context.Context, input types.UpdateFrameworkInput) (*types.UpdateFrameworkPayload, error) {
|
func (r *mutationResolver) UpdateFramework(ctx context.Context, input types.UpdateFrameworkInput) (*types.UpdateFrameworkPayload, error) {
|
||||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.ID.TenantID())
|
svc := r.GetTenantServiceIfAuthorized(ctx, input.ID.TenantID())
|
||||||
@@ -310,6 +291,26 @@ func (r *mutationResolver) UpdateFramework(ctx context.Context, input types.Upda
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CreateControl is the resolver for the createControl field.
|
||||||
|
func (r *mutationResolver) CreateControl(ctx context.Context, input types.CreateControlInput) (*types.CreateControlPayload, error) {
|
||||||
|
svc := r.GetTenantServiceIfAuthorized(ctx, input.FrameworkID.TenantID())
|
||||||
|
|
||||||
|
control, err := svc.Controls.Create(ctx, probo.CreateControlRequest{
|
||||||
|
FrameworkID: input.FrameworkID,
|
||||||
|
Name: input.Name,
|
||||||
|
Description: input.Description,
|
||||||
|
Category: input.Category,
|
||||||
|
Importance: input.Importance,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("cannot create control: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &types.CreateControlPayload{
|
||||||
|
ControlEdge: types.NewControlEdge(control),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
// UpdateControl is the resolver for the updateControl field.
|
// UpdateControl is the resolver for the updateControl field.
|
||||||
func (r *mutationResolver) UpdateControl(ctx context.Context, input types.UpdateControlInput) (*types.UpdateControlPayload, error) {
|
func (r *mutationResolver) UpdateControl(ctx context.Context, input types.UpdateControlInput) (*types.UpdateControlPayload, error) {
|
||||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.ID.TenantID())
|
svc := r.GetTenantServiceIfAuthorized(ctx, input.ID.TenantID())
|
||||||
|
|||||||
Reference in New Issue
Block a user