# HG changeset patch
# User ogiorgis <olivier.giorgis@logilab.fr>
# Date 1710429538 -3600
#      Thu Mar 14 16:18:58 2024 +0100
# Node ID 0f3e807f14b3e84b10e9184e7dd150823d94f52e
# Parent  f62131463bdaa61d4e31ec6573d15d21ccccd584
feat: add graph_uri field

diff --git a/frontend/src/api/cubicweb.ts b/frontend/src/api/cubicweb.ts
--- a/frontend/src/api/cubicweb.ts
+++ b/frontend/src/api/cubicweb.ts
@@ -179,7 +179,7 @@
 export function useApiCreateRecipe() {
   const client = useClient();
   const insertRql =
-    "INSERT ImportRecipe X: X name %(name)s, X process_type %(process_type)s";
+    "INSERT ImportRecipe X: X name %(name)s, X graph_uri %(graph_uri)s, X process_type %(process_type)s";
   const setDataServiceRql =
     "SET X dataservice %(dataservice)s WHERE X eid %(eid)s";
   const setProjectRql =
@@ -188,6 +188,7 @@
     const transaction = new Transaction();
     const insertQuery = transaction.push(insertRql, {
       name: data.name,
+      graph_uri: data.graph_uri,
       process_type: data.process_type,
     });
     const eidRef = insertQuery.ref().row(0).column(0);
@@ -211,8 +212,8 @@
     "X virtuoso_password ATTR_VIRTUOSO_PASSWORD, X activated ATTR_ACTIVATED, X ontology_file REL_ONTOLOGY?, X shacl_files REL_SHACL?";
 
   const recipeListRql =
-    "Any X, ATTR_NAME, ATTR_PROCESS_TYPE , REL_DATASERVICE " +
-    "WHERE X is ImportRecipe, X name ATTR_NAME, X process_type ATTR_PROCESS_TYPE, X dataservice REL_DATASERVICE, O import_recipes X, O eid %(eid)s";
+    "Any X, ATTR_NAME, ATTR_GRAPH_URI, ATTR_PROCESS_TYPE ,REL_DATASERVICE " +
+    "WHERE X is ImportRecipe, X name ATTR_NAME, X graph_uri ATTR_GRAPH_URI, X process_type ATTR_PROCESS_TYPE, X dataservice REL_DATASERVICE, O import_recipes X, O eid %(eid)s";
 
   return async (eid: number) => {
     try {
@@ -233,7 +234,8 @@
             eid: r[0],
             name: r[1],
             process_type: r[2],
-            dataservice: r[3],
+            graph_uri: r[3],
+            dataservice: r[4],
           }) as Recipe,
       );
 
diff --git a/frontend/src/components/RecipeModal.tsx b/frontend/src/components/RecipeModal.tsx
--- a/frontend/src/components/RecipeModal.tsx
+++ b/frontend/src/components/RecipeModal.tsx
@@ -130,6 +130,22 @@
             )}
           />
           <Controller
+            name="graph_uri"
+            control={control}
+            rules={{ required: true }}
+            render={({ field, fieldState: { error } }) => (
+              <TextField
+                label="Graph Uri"
+                disabled={saving}
+                {...field}
+                error={error !== undefined}
+                helperText={
+                  error?.type === "required" ? "Champ requis" : error?.message
+                }
+              />
+            )}
+          />
+          <Controller
             name="process_type"
             control={control}
             rules={{ required: true }}
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -29,6 +29,7 @@
   eid: number;
   name: string;
   dataservice: number;
+  graph_uri: string;
   process_type: "default" | "default-dryrun";
 };