@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
|
||||
### Added
|
||||
|
||||
- Add delete measure in the UI and GraphQL API
|
||||
|
||||
### Removed
|
||||
|
||||
- Remove `importance` field from measure as it's not used anymore
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
useMutation,
|
||||
fetchQuery,
|
||||
useRelayEnvironment,
|
||||
ConnectionHandler,
|
||||
} from "react-relay";
|
||||
import {
|
||||
AlertTriangle,
|
||||
@@ -106,6 +107,7 @@ import { MesureViewCreateControlMappingMutation } from "./__generated__/MesureVi
|
||||
import { MesureViewDeleteControlMappingMutation } from "./__generated__/MesureViewDeleteControlMappingMutation.graphql";
|
||||
import { MesureViewRisksQuery$data } from "./__generated__/MesureViewRisksQuery.graphql";
|
||||
import { MesureViewRisksQuery } from "./__generated__/MesureViewRisksQuery.graphql";
|
||||
import { MesureViewDeleteMesureMutation } from "./__generated__/MesureViewDeleteMesureMutation.graphql";
|
||||
|
||||
// Function to format ISO8601 duration to human-readable format
|
||||
const formatDuration = (isoDuration: string): string => {
|
||||
@@ -326,6 +328,17 @@ const updateMesureStateMutation = graphql`
|
||||
}
|
||||
`;
|
||||
|
||||
const deleteMesureMutation = graphql`
|
||||
mutation MesureViewDeleteMesureMutation(
|
||||
$input: DeleteMesureInput!
|
||||
$connections: [ID!]!
|
||||
) {
|
||||
deleteMesure(input: $input) {
|
||||
deletedMesureId @deleteEdge(connections: $connections)
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const organizationQuery = graphql`
|
||||
query MesureViewOrganizationQuery($organizationId: ID!) {
|
||||
organization: node(id: $organizationId) {
|
||||
@@ -477,11 +490,17 @@ function MesureViewContent({
|
||||
mesureViewQuery,
|
||||
queryRef
|
||||
);
|
||||
const { toast } = useToast();
|
||||
const { organizationId, mesureId } = useParams();
|
||||
const navigate = useNavigate();
|
||||
const { toast } = useToast();
|
||||
const { organizationId, mesureId } = useParams<{
|
||||
organizationId: string;
|
||||
mesureId: string;
|
||||
}>();
|
||||
const environment = useRelayEnvironment();
|
||||
|
||||
const [commitDeleteMesure, isDeletingMesure] = useMutation<MesureViewDeleteMesureMutation>(deleteMesureMutation);
|
||||
const [isDeleteMesureOpen, setIsDeleteMesureOpen] = useState(false);
|
||||
|
||||
// Add state for main content tabs
|
||||
const [mainContentTab, setMainContentTab] = useState<string>("tasks");
|
||||
|
||||
@@ -1815,32 +1834,70 @@ function MesureViewContent({
|
||||
return "Very High";
|
||||
};
|
||||
|
||||
const handleDeleteMesure = () => {
|
||||
setIsDeleteMesureOpen(true);
|
||||
};
|
||||
|
||||
const confirmDeleteMesure = () => {
|
||||
const connectionId = ConnectionHandler.getConnectionID(
|
||||
organizationId!,
|
||||
"MesureListView_mesures"
|
||||
);
|
||||
|
||||
commitDeleteMesure({
|
||||
variables: {
|
||||
connections: [connectionId],
|
||||
input: {
|
||||
mesureId: mesureId!,
|
||||
},
|
||||
},
|
||||
onCompleted: () => {
|
||||
toast({
|
||||
title: "Mesure deleted",
|
||||
description: "Mesure has been deleted successfully.",
|
||||
});
|
||||
navigate(`/organizations/${organizationId}/mesures`);
|
||||
},
|
||||
onError: (error) => {
|
||||
toast({
|
||||
title: "Error deleting mesure",
|
||||
description: error.message,
|
||||
variant: "destructive",
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<PageTemplate
|
||||
title={data.mesure.name ?? ""}
|
||||
title={data.mesure?.name || "Mesure"}
|
||||
description={data.mesure?.description}
|
||||
actions={
|
||||
<div className="flex items-center gap-2">
|
||||
<Button onClick={handleEditMesure}>Edit Mesure</Button>
|
||||
<Select
|
||||
defaultValue={data.mesure.state}
|
||||
onValueChange={handleMesureStateChange}
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={handleEditMesure}
|
||||
>
|
||||
<SelectTrigger className="w-[160px] h-10 text-sm">
|
||||
<div
|
||||
className={`${getStateColor(
|
||||
data.mesure.state
|
||||
)} px-2 py-0.5 rounded-sm text-sm w-full text-center`}
|
||||
>
|
||||
{formatState(data.mesure.state)}
|
||||
</div>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="NOT_STARTED">Not Started</SelectItem>
|
||||
<SelectItem value="IN_PROGRESS">In Progress</SelectItem>
|
||||
<SelectItem value="IMPLEMENTED">Implemented</SelectItem>
|
||||
<SelectItem value="NOT_APPLICABLE">Not Applicable</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
Edit
|
||||
</Button>
|
||||
<select
|
||||
value={data.mesure?.state || ""}
|
||||
onChange={(e) => handleMesureStateChange(e.target.value)}
|
||||
className="rounded-full cursor-pointer inline-flex items-center justify-center gap-2 whitespace-nowrap text-sm font-medium transition-colors focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-active-b disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 border border-low-b hover:bg-h-tertiary-bg active:bg-p-tertiary-bg focus:bg-tertiary-bg shadow-xs px-2"
|
||||
>
|
||||
<option value="">Select state</option>
|
||||
<option value="NOT_STARTED">Not Started</option>
|
||||
<option value="IN_PROGRESS">In Progress</option>
|
||||
<option value="NOT_APPLICABLE">Not Applicable</option>
|
||||
<option value="IMPLEMENTED">Implemented</option>
|
||||
</select>
|
||||
<Button
|
||||
variant="destructive"
|
||||
onClick={() => handleDeleteMesure()}
|
||||
disabled={isDeletingMesure}
|
||||
>
|
||||
{isDeletingMesure ? "Deleting..." : "Delete"}
|
||||
</Button>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
@@ -3598,6 +3655,33 @@ function MesureViewContent({
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
{/* Delete Mesure Confirmation Dialog */}
|
||||
<Dialog open={isDeleteMesureOpen} onOpenChange={setIsDeleteMesureOpen}>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Delete Mesure</DialogTitle>
|
||||
<DialogDescription>
|
||||
Are you sure you want to delete this mesure? This action cannot be undone.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogFooter>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => setIsDeleteMesureOpen(false)}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
variant="destructive"
|
||||
onClick={confirmDeleteMesure}
|
||||
disabled={isDeletingMesure}
|
||||
>
|
||||
{isDeletingMesure ? "Deleting..." : "Delete"}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</PageTemplate>
|
||||
);
|
||||
}
|
||||
|
||||
132
apps/console/src/pages/organizations/mesures/__generated__/MesureViewDeleteMesureMutation.graphql.ts
generated
Normal file
132
apps/console/src/pages/organizations/mesures/__generated__/MesureViewDeleteMesureMutation.graphql.ts
generated
Normal file
@@ -0,0 +1,132 @@
|
||||
/**
|
||||
* @generated SignedSource<<d2f54e72111c91de1b3fe8ece42a4f07>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
export type DeleteMesureInput = {
|
||||
mesureId: string;
|
||||
};
|
||||
export type MesureViewDeleteMesureMutation$variables = {
|
||||
connections: ReadonlyArray<string>;
|
||||
input: DeleteMesureInput;
|
||||
};
|
||||
export type MesureViewDeleteMesureMutation$data = {
|
||||
readonly deleteMesure: {
|
||||
readonly deletedMesureId: string;
|
||||
};
|
||||
};
|
||||
export type MesureViewDeleteMesureMutation = {
|
||||
response: MesureViewDeleteMesureMutation$data;
|
||||
variables: MesureViewDeleteMesureMutation$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": "deletedMesureId",
|
||||
"storageKey": null
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": [
|
||||
(v0/*: any*/),
|
||||
(v1/*: any*/)
|
||||
],
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "MesureViewDeleteMesureMutation",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v2/*: any*/),
|
||||
"concreteType": "DeleteMesurePayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "deleteMesure",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"type": "Mutation",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": [
|
||||
(v1/*: any*/),
|
||||
(v0/*: any*/)
|
||||
],
|
||||
"kind": "Operation",
|
||||
"name": "MesureViewDeleteMesureMutation",
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v2/*: any*/),
|
||||
"concreteType": "DeleteMesurePayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "deleteMesure",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"filters": null,
|
||||
"handle": "deleteEdge",
|
||||
"key": "",
|
||||
"kind": "ScalarHandle",
|
||||
"name": "deletedMesureId",
|
||||
"handleArgs": [
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "connections",
|
||||
"variableName": "connections"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "075b3e2d23906985e70fa5ccd3b623c7",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "MesureViewDeleteMesureMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation MesureViewDeleteMesureMutation(\n $input: DeleteMesureInput!\n) {\n deleteMesure(input: $input) {\n deletedMesureId\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "abf5ae3a6720522aee6b8d672ac389ef";
|
||||
|
||||
export default node;
|
||||
@@ -433,3 +433,22 @@ WHERE %s
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *Mesure) Delete(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
) error {
|
||||
q := `
|
||||
DELETE FROM mesures
|
||||
WHERE %s
|
||||
AND id = @mesure_id
|
||||
`
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"mesure_id": m.ID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
return err
|
||||
}
|
||||
|
||||
7
pkg/coredata/migrations/20250417T085900Z.sql
Normal file
7
pkg/coredata/migrations/20250417T085900Z.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
ALTER TABLE evidences DROP CONSTRAINT evidences_task_id_fkey;
|
||||
|
||||
ALTER TABLE evidences
|
||||
ADD CONSTRAINT evidences_task_id_fkey
|
||||
FOREIGN KEY (task_id)
|
||||
REFERENCES tasks(id)
|
||||
ON DELETE CASCADE;
|
||||
@@ -371,3 +371,18 @@ func (s MesureService) Create(
|
||||
|
||||
return mesure, nil
|
||||
}
|
||||
|
||||
func (s MesureService) Delete(
|
||||
ctx context.Context,
|
||||
mesureID gid.GID,
|
||||
) error {
|
||||
return s.svc.pg.WithTx(ctx, func(conn pg.Conn) error {
|
||||
mesure := &coredata.Mesure{ID: mesureID}
|
||||
|
||||
if err := mesure.Delete(ctx, conn, s.svc.scope); err != nil {
|
||||
return fmt.Errorf("cannot delete mesure: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -895,6 +895,7 @@ type Mutation {
|
||||
createMesure(input: CreateMesureInput!): CreateMesurePayload!
|
||||
updateMesure(input: UpdateMesureInput!): UpdateMesurePayload!
|
||||
importMesure(input: ImportMesureInput!): ImportMesurePayload!
|
||||
deleteMesure(input: DeleteMesureInput!): DeleteMesurePayload!
|
||||
|
||||
# Control mutations
|
||||
createControlMesureMapping(
|
||||
@@ -1481,3 +1482,11 @@ input CreateVendorRiskAssessmentInput {
|
||||
type CreateVendorRiskAssessmentPayload {
|
||||
vendorRiskAssessmentEdge: VendorRiskAssessmentEdge!
|
||||
}
|
||||
|
||||
input DeleteMesureInput {
|
||||
mesureId: ID!
|
||||
}
|
||||
|
||||
type DeleteMesurePayload {
|
||||
deletedMesureId: ID!
|
||||
}
|
||||
@@ -182,6 +182,10 @@ type ComplexityRoot struct {
|
||||
DeletedFrameworkID func(childComplexity int) int
|
||||
}
|
||||
|
||||
DeleteMesurePayload struct {
|
||||
DeletedMesureID func(childComplexity int) int
|
||||
}
|
||||
|
||||
DeleteOrganizationPayload struct {
|
||||
DeletedOrganizationID func(childComplexity int) int
|
||||
}
|
||||
@@ -321,6 +325,7 @@ type ComplexityRoot struct {
|
||||
DeleteControlPolicyMapping func(childComplexity int, input types.DeleteControlPolicyMappingInput) int
|
||||
DeleteEvidence func(childComplexity int, input types.DeleteEvidenceInput) int
|
||||
DeleteFramework func(childComplexity int, input types.DeleteFrameworkInput) int
|
||||
DeleteMesure func(childComplexity int, input types.DeleteMesureInput) int
|
||||
DeleteOrganization func(childComplexity int, input types.DeleteOrganizationInput) int
|
||||
DeletePeople func(childComplexity int, input types.DeletePeopleInput) int
|
||||
DeletePolicy func(childComplexity int, input types.DeletePolicyInput) int
|
||||
@@ -675,6 +680,7 @@ type MutationResolver interface {
|
||||
CreateMesure(ctx context.Context, input types.CreateMesureInput) (*types.CreateMesurePayload, error)
|
||||
UpdateMesure(ctx context.Context, input types.UpdateMesureInput) (*types.UpdateMesurePayload, error)
|
||||
ImportMesure(ctx context.Context, input types.ImportMesureInput) (*types.ImportMesurePayload, error)
|
||||
DeleteMesure(ctx context.Context, input types.DeleteMesureInput) (*types.DeleteMesurePayload, error)
|
||||
CreateControlMesureMapping(ctx context.Context, input types.CreateControlMesureMappingInput) (*types.CreateControlMesureMappingPayload, error)
|
||||
CreateControlPolicyMapping(ctx context.Context, input types.CreateControlPolicyMappingInput) (*types.CreateControlPolicyMappingPayload, error)
|
||||
DeleteControlMesureMapping(ctx context.Context, input types.DeleteControlMesureMappingInput) (*types.DeleteControlMesureMappingPayload, error)
|
||||
@@ -1070,6 +1076,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
||||
|
||||
return e.complexity.DeleteFrameworkPayload.DeletedFrameworkID(childComplexity), true
|
||||
|
||||
case "DeleteMesurePayload.deletedMesureId":
|
||||
if e.complexity.DeleteMesurePayload.DeletedMesureID == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.DeleteMesurePayload.DeletedMesureID(childComplexity), true
|
||||
|
||||
case "DeleteOrganizationPayload.deletedOrganizationId":
|
||||
if e.complexity.DeleteOrganizationPayload.DeletedOrganizationID == nil {
|
||||
break
|
||||
@@ -1694,6 +1707,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
||||
|
||||
return e.complexity.Mutation.DeleteFramework(childComplexity, args["input"].(types.DeleteFrameworkInput)), true
|
||||
|
||||
case "Mutation.deleteMesure":
|
||||
if e.complexity.Mutation.DeleteMesure == nil {
|
||||
break
|
||||
}
|
||||
|
||||
args, err := ec.field_Mutation_deleteMesure_args(context.TODO(), rawArgs)
|
||||
if err != nil {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
return e.complexity.Mutation.DeleteMesure(childComplexity, args["input"].(types.DeleteMesureInput)), true
|
||||
|
||||
case "Mutation.deleteOrganization":
|
||||
if e.complexity.Mutation.DeleteOrganization == nil {
|
||||
break
|
||||
@@ -3248,6 +3273,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
|
||||
ec.unmarshalInputDeleteControlPolicyMappingInput,
|
||||
ec.unmarshalInputDeleteEvidenceInput,
|
||||
ec.unmarshalInputDeleteFrameworkInput,
|
||||
ec.unmarshalInputDeleteMesureInput,
|
||||
ec.unmarshalInputDeleteOrganizationInput,
|
||||
ec.unmarshalInputDeletePeopleInput,
|
||||
ec.unmarshalInputDeletePolicyInput,
|
||||
@@ -4279,6 +4305,7 @@ type Mutation {
|
||||
createMesure(input: CreateMesureInput!): CreateMesurePayload!
|
||||
updateMesure(input: UpdateMesureInput!): UpdateMesurePayload!
|
||||
importMesure(input: ImportMesureInput!): ImportMesurePayload!
|
||||
deleteMesure(input: DeleteMesureInput!): DeleteMesurePayload!
|
||||
|
||||
# Control mutations
|
||||
createControlMesureMapping(
|
||||
@@ -4865,7 +4892,14 @@ input CreateVendorRiskAssessmentInput {
|
||||
type CreateVendorRiskAssessmentPayload {
|
||||
vendorRiskAssessmentEdge: VendorRiskAssessmentEdge!
|
||||
}
|
||||
`, BuiltIn: false},
|
||||
|
||||
input DeleteMesureInput {
|
||||
mesureId: ID!
|
||||
}
|
||||
|
||||
type DeleteMesurePayload {
|
||||
deletedMesureId: ID!
|
||||
}`, BuiltIn: false},
|
||||
}
|
||||
var parsedSchema = gqlparser.MustLoadSchema(sources...)
|
||||
|
||||
@@ -5903,6 +5937,29 @@ func (ec *executionContext) field_Mutation_deleteFramework_argsInput(
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Mutation_deleteMesure_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
arg0, err := ec.field_Mutation_deleteMesure_argsInput(ctx, rawArgs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
args["input"] = arg0
|
||||
return args, nil
|
||||
}
|
||||
func (ec *executionContext) field_Mutation_deleteMesure_argsInput(
|
||||
ctx context.Context,
|
||||
rawArgs map[string]any,
|
||||
) (types.DeleteMesureInput, error) {
|
||||
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
|
||||
if tmp, ok := rawArgs["input"]; ok {
|
||||
return ec.unmarshalNDeleteMesureInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDeleteMesureInput(ctx, tmp)
|
||||
}
|
||||
|
||||
var zeroVal types.DeleteMesureInput
|
||||
return zeroVal, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Mutation_deleteOrganization_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
args := map[string]any{}
|
||||
@@ -10147,6 +10204,50 @@ func (ec *executionContext) fieldContext_DeleteFrameworkPayload_deletedFramework
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _DeleteMesurePayload_deletedMesureId(ctx context.Context, field graphql.CollectedField, obj *types.DeleteMesurePayload) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_DeleteMesurePayload_deletedMesureId(ctx, field)
|
||||
if err != nil {
|
||||
return graphql.Null
|
||||
}
|
||||
ctx = graphql.WithFieldContext(ctx, fc)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
ret = graphql.Null
|
||||
}
|
||||
}()
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return obj.DeletedMesureID, nil
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return graphql.Null
|
||||
}
|
||||
if resTmp == nil {
|
||||
if !graphql.HasFieldError(ctx, fc) {
|
||||
ec.Errorf(ctx, "must not be null")
|
||||
}
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(gid.GID)
|
||||
fc.Result = res
|
||||
return ec.marshalNID2githubᚗcomᚋgetproboᚋproboᚋpkgᚋgidᚐGID(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_DeleteMesurePayload_deletedMesureId(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "DeleteMesurePayload",
|
||||
Field: field,
|
||||
IsMethod: false,
|
||||
IsResolver: false,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
return nil, errors.New("field of type ID does not have child fields")
|
||||
},
|
||||
}
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _DeleteOrganizationPayload_deletedOrganizationId(ctx context.Context, field graphql.CollectedField, obj *types.DeleteOrganizationPayload) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_DeleteOrganizationPayload_deletedOrganizationId(ctx, field)
|
||||
if err != nil {
|
||||
@@ -13744,6 +13845,65 @@ func (ec *executionContext) fieldContext_Mutation_importMesure(ctx context.Conte
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Mutation_deleteMesure(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Mutation_deleteMesure(ctx, field)
|
||||
if err != nil {
|
||||
return graphql.Null
|
||||
}
|
||||
ctx = graphql.WithFieldContext(ctx, fc)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
ret = graphql.Null
|
||||
}
|
||||
}()
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return ec.resolvers.Mutation().DeleteMesure(rctx, fc.Args["input"].(types.DeleteMesureInput))
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return graphql.Null
|
||||
}
|
||||
if resTmp == nil {
|
||||
if !graphql.HasFieldError(ctx, fc) {
|
||||
ec.Errorf(ctx, "must not be null")
|
||||
}
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(*types.DeleteMesurePayload)
|
||||
fc.Result = res
|
||||
return ec.marshalNDeleteMesurePayload2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDeleteMesurePayload(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_Mutation_deleteMesure(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 "deletedMesureId":
|
||||
return ec.fieldContext_DeleteMesurePayload_deletedMesureId(ctx, field)
|
||||
}
|
||||
return nil, fmt.Errorf("no field named %q was found under type DeleteMesurePayload", 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_deleteMesure_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return fc, err
|
||||
}
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Mutation_createControlMesureMapping(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Mutation_createControlMesureMapping(ctx, field)
|
||||
if err != nil {
|
||||
@@ -26589,6 +26749,33 @@ func (ec *executionContext) unmarshalInputDeleteFrameworkInput(ctx context.Conte
|
||||
return it, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) unmarshalInputDeleteMesureInput(ctx context.Context, obj any) (types.DeleteMesureInput, error) {
|
||||
var it types.DeleteMesureInput
|
||||
asMap := map[string]any{}
|
||||
for k, v := range obj.(map[string]any) {
|
||||
asMap[k] = v
|
||||
}
|
||||
|
||||
fieldsInOrder := [...]string{"mesureId"}
|
||||
for _, k := range fieldsInOrder {
|
||||
v, ok := asMap[k]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
switch k {
|
||||
case "mesureId":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mesureId"))
|
||||
data, err := ec.unmarshalNID2githubᚗcomᚋgetproboᚋproboᚋpkgᚋgidᚐGID(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
it.MesureID = data
|
||||
}
|
||||
}
|
||||
|
||||
return it, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) unmarshalInputDeleteOrganizationInput(ctx context.Context, obj any) (types.DeleteOrganizationInput, error) {
|
||||
var it types.DeleteOrganizationInput
|
||||
asMap := map[string]any{}
|
||||
@@ -29400,6 +29587,45 @@ func (ec *executionContext) _DeleteFrameworkPayload(ctx context.Context, sel ast
|
||||
return out
|
||||
}
|
||||
|
||||
var deleteMesurePayloadImplementors = []string{"DeleteMesurePayload"}
|
||||
|
||||
func (ec *executionContext) _DeleteMesurePayload(ctx context.Context, sel ast.SelectionSet, obj *types.DeleteMesurePayload) graphql.Marshaler {
|
||||
fields := graphql.CollectFields(ec.OperationContext, sel, deleteMesurePayloadImplementors)
|
||||
|
||||
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("DeleteMesurePayload")
|
||||
case "deletedMesureId":
|
||||
out.Values[i] = ec._DeleteMesurePayload_deletedMesureId(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 deleteOrganizationPayloadImplementors = []string{"DeleteOrganizationPayload"}
|
||||
|
||||
func (ec *executionContext) _DeleteOrganizationPayload(ctx context.Context, sel ast.SelectionSet, obj *types.DeleteOrganizationPayload) graphql.Marshaler {
|
||||
@@ -30709,6 +30935,13 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet)
|
||||
if out.Values[i] == graphql.Null {
|
||||
out.Invalids++
|
||||
}
|
||||
case "deleteMesure":
|
||||
out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
|
||||
return ec._Mutation_deleteMesure(ctx, field)
|
||||
})
|
||||
if out.Values[i] == graphql.Null {
|
||||
out.Invalids++
|
||||
}
|
||||
case "createControlMesureMapping":
|
||||
out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
|
||||
return ec._Mutation_createControlMesureMapping(ctx, field)
|
||||
@@ -35033,6 +35266,25 @@ func (ec *executionContext) marshalNDeleteFrameworkPayload2ᚖgithubᚗcomᚋget
|
||||
return ec._DeleteFrameworkPayload(ctx, sel, v)
|
||||
}
|
||||
|
||||
func (ec *executionContext) unmarshalNDeleteMesureInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDeleteMesureInput(ctx context.Context, v any) (types.DeleteMesureInput, error) {
|
||||
res, err := ec.unmarshalInputDeleteMesureInput(ctx, v)
|
||||
return res, graphql.ErrorOnPath(ctx, err)
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalNDeleteMesurePayload2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDeleteMesurePayload(ctx context.Context, sel ast.SelectionSet, v types.DeleteMesurePayload) graphql.Marshaler {
|
||||
return ec._DeleteMesurePayload(ctx, sel, &v)
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalNDeleteMesurePayload2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDeleteMesurePayload(ctx context.Context, sel ast.SelectionSet, v *types.DeleteMesurePayload) graphql.Marshaler {
|
||||
if v == nil {
|
||||
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
|
||||
ec.Errorf(ctx, "the requested element is null which the schema does not allow")
|
||||
}
|
||||
return graphql.Null
|
||||
}
|
||||
return ec._DeleteMesurePayload(ctx, sel, v)
|
||||
}
|
||||
|
||||
func (ec *executionContext) unmarshalNDeleteOrganizationInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐDeleteOrganizationInput(ctx context.Context, v any) (types.DeleteOrganizationInput, error) {
|
||||
res, err := ec.unmarshalInputDeleteOrganizationInput(ctx, v)
|
||||
return res, graphql.ErrorOnPath(ctx, err)
|
||||
|
||||
@@ -292,6 +292,14 @@ type DeleteFrameworkPayload struct {
|
||||
DeletedFrameworkID gid.GID `json:"deletedFrameworkId"`
|
||||
}
|
||||
|
||||
type DeleteMesureInput struct {
|
||||
MesureID gid.GID `json:"mesureId"`
|
||||
}
|
||||
|
||||
type DeleteMesurePayload struct {
|
||||
DeletedMesureID gid.GID `json:"deletedMesureId"`
|
||||
}
|
||||
|
||||
type DeleteOrganizationInput struct {
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
}
|
||||
|
||||
@@ -593,6 +593,20 @@ func (r *mutationResolver) ImportMesure(ctx context.Context, input types.ImportM
|
||||
}, nil
|
||||
}
|
||||
|
||||
// DeleteMesure is the resolver for the deleteMesure field.
|
||||
func (r *mutationResolver) DeleteMesure(ctx context.Context, input types.DeleteMesureInput) (*types.DeleteMesurePayload, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.MesureID.TenantID())
|
||||
|
||||
err := svc.Mesures.Delete(ctx, input.MesureID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot delete mesure: %w", err))
|
||||
}
|
||||
|
||||
return &types.DeleteMesurePayload{
|
||||
DeletedMesureID: input.MesureID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// CreateControlMesureMapping is the resolver for the createControlMesureMapping field.
|
||||
func (r *mutationResolver) CreateControlMesureMapping(ctx context.Context, input types.CreateControlMesureMappingInput) (*types.CreateControlMesureMappingPayload, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.MesureID.TenantID())
|
||||
|
||||
Reference in New Issue
Block a user