You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "Adarshvk98 (via GitHub)" <gi...@apache.org> on 2025/05/13 12:05:15 UTC

[PR] kie-issues#11: GitLab support on KIE Sandbox [incubator-kie-tools]

Adarshvk98 opened a new pull request, #3132:
URL: https://github.com/apache/incubator-kie-tools/pull/3132

   Closes [issue #11](https://github.com/apache/incubator-kie-issues/issues/11)  
   
   ## Overview  
   This PR introduces support for GitLab's structure and features within our KIE Sandbox.
    - Aligning with GitLab’s concepts of Groups, Projects, and Snippets, this implementation maps similar functionality using Groups and Projects, although GitLab doesn’t use the term “organization” like GitHub or Bitbucket.
    - The REST API endpoints themselves are consistent across GitLab’s three offerings: **GitLab.com**, **GitLab Self-Managed**, and **GitLab Dedicated**. Therefore, there is an assumption that it will work across private instances.
   - There is no officially maintained GitLab client, so a simple fetch client was implemented as part of this [Reference material for the REST API](https://docs.gitlab.com/api/rest/)
   
   ---
   
   ## Key Features Implemented
   
   ### 1. Authentication  
   - Added support for authentication using **[Personal Access Tokens (PAT)](https://docs.gitlab.com/user/profile/personal_access_tokens/#create-a-personal-access-token)** to securely interact with GitLab APIs.
   - While creating a Personal Access Token, need to add the following scopes: `api`, `read_user`, `read_repository`, and `write_repository`.
   ### 2. Clone & Import Repository from URL  
   - **Clone Project Repository:**  
     Support cloning entire projects via URL.  
    eg: `https://<domain>/<group>/<project>.git`  
   
   - **Clone Specific Branch/Ref:**  
     Ability to clone a specific branch or reference from a project.  
     eg: `https://<domain>/<group>/<project>/-/tree/<branch>`  
   
   - **Import File from Branch:**  
     Import individual files directly from a specified branch in the repository.  
     eg: `https://<domain>/<group>/<project>/-/blob/<branch>/<file-path>`  
   
   - **User-Specific Project Support:**  
     Cloning and importing also supported for user-specific projects.
     eg: `https://<domain>/<user-id>/<project>.git`
   
   ### 3. Clone & Import Snippet from URL 
   - **Clone Standalone User-Specific Snippet:**   
     Clone snippets that belong to an individual user outside any project context.  
     eg: `https://<domain>/snippets/<snippet-id>.git`
   
   - **Import Standalone User-Specific Snippet File:**   
     Import snippet files directly by URL.  
     eg: `https://<domain>/snippets/<snippet-id>/raw/main/<file-name>`
   
   - **Clone Project Snippet:**   
     Clone snippets associated with a specific project group.  
     eg: `https://<domain>/<group>/<project>/-/snippets/<snippet-id>.git`
   
   - **Import Project Snippet File:**   
      Import snippet files belonging to a project snippet by direct URL access.    
      eg: `https://<domain>/<group>/<project>/-/snippets/<snippet-id>/raw/main/<file-name>`
   
   ### 4. Create Repository & Snippets
   - **Create Repository From Workspace:**   
      - Lists groups under the dropdown for selection.    
      - Supports creating repositories under user scope, group scope, or subgroup scope as selectable options.
   
   - **Create Snippet From Workspace:**    
      - Lists projects under the dropdown for selection.    
      - Supports creating snippets either under user scope or project scope.
   
   ### 5. Update GitLab Snippets
   - Enabled updating existing snippets only if the current authenticated user is the owner of the snippet (verified ownership before enabling update).
   
   ---
   
   ### Issue Observed
   To connect to gitlab.com, it is observed that need to disable TLS certificate verification to get a successful response from Git operations like ref-check, clone, push, and pull. However, it’s unclear how to resolve this issue since disabling TLS certificate verification would introduce security concerns. One possible solution is to send the `accept-encoding: “identity”` header from KIE Sandbox itself for GitLab authentication sessions. However it's not clear whether this is the right way to approach it. - **WIP**
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#11: GitLab support on KIE Sandbox [incubator-kie-tools]

Posted by "Adarshvk98 (via GitHub)" <gi...@apache.org>.
Adarshvk98 commented on code in PR #3132:
URL: https://github.com/apache/incubator-kie-tools/pull/3132#discussion_r2113099624


##########
packages/online-editor/src/editor/Toolbar/GitIntegration/LoadOrganizationsSelect.tsx:
##########
@@ -102,10 +121,30 @@ export const LoadOrganizationsSelect = (props: Props) => {
       return emptyResponse;
     }
     const values: any[] = json.values;
-    return { organizations: values.map((it) => ({ name: it.workspace.slug })) };
+    return { organizations: values.map((it) => ({ name: it.workspace.slug, value: it.workspace.slug })) };
   }, [bitbucketClient]);
 
-  const { onSelect } = props;
+  const getGitlabGroupsForUser = useCallback(async (): Promise<LoadOrganizationsReponse> => {
+    if (actionType && actionType === "snippet") {
+      const projectsResponse = await gitlabClient.listProjects();
+      const projectsResponseJson = await projectsResponse.json();
+      return {
+        organizations: (projectsResponseJson ?? []).map(({ name, id }: { name: string; id: string }) => ({
+          name,
+          value: id,
+        })),
+      };
+    }
+    const groupsResponse = await gitlabClient.listGroups();
+    const groupsResponseJson = await groupsResponse.json();
+    return {
+      organizations: (groupsResponseJson ?? []).map(({ name, id }: { name: string; id: string }) => ({

Review Comment:
   I would also suggest, as it displays a more readable format
   
   - To display Groups --> use `full_name`
   - To display Projects  --> use `name_with_namespace`
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#11: GitLab support on KIE Sandbox [incubator-kie-tools]

Posted by "Adarshvk98 (via GitHub)" <gi...@apache.org>.
Adarshvk98 commented on PR #3132:
URL: https://github.com/apache/incubator-kie-tools/pull/3132#issuecomment-2891073759

   Thank you, @jomarko, for reviewing. I’ve outlined my points below. Please take a look.
   
   >01 
   
   II’ve included “GitLab Snippet” in the above sentences.
   
   > 02
   
   Yes, those changes are related to the Patternfly 5 update. Perhaps I can take a look and try to fix it.
   
   > 03
   
   I have observed that once a repository is deleted, it will be in a pending deletion state for the next 7 days. After that date, it will be permanently deleted from GitLab.com. During this time, we can commit or make any changes to the deleted repository until it is permanently deleted
   
   > 04
   
   I tried to reproduce this issue, but I couldn't. Perhaps you could provide more information, such as a reproducible set of steps. When I tried, I was able to open the snippet URL displayed in the flash message. I noticed that your snippet URL ends with the .git extension, which might be the reason. If the snippet URL ends with the .git extension, it will display a 404 page. Could you please double-check the snippet URLs that end with the .git extension?
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#11: GitLab support on KIE Sandbox [incubator-kie-tools]

Posted by "Adarshvk98 (via GitHub)" <gi...@apache.org>.
Adarshvk98 commented on PR #3132:
URL: https://github.com/apache/incubator-kie-tools/pull/3132#issuecomment-2891319865

   Thanks for sharing those reproducible steps, it helps.
   
   I have fixed this [issue](https://github.com/apache/incubator-kie-tools/pull/3132/commits/49edf197ee1e8bd13859cee9cd901501ff52f39d)
   
   @jomarko Please take a look now ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#11: GitLab support on KIE Sandbox [incubator-kie-tools]

Posted by "Adarshvk98 (via GitHub)" <gi...@apache.org>.
Adarshvk98 commented on PR #3132:
URL: https://github.com/apache/incubator-kie-tools/pull/3132#issuecomment-2919097988

   Closes [issues - 1980](https://github.com/apache/incubator-kie-issues/issues/1980)
   
   Now, groups and nested groups are displayed with a separator of forward slash, which can avoid having different subgroups with the same name and same applies for projects as well
   ![image](https://github.com/user-attachments/assets/eee9be2f-ceee-45db-9ade-2cdd284afda9)
   ![image](https://github.com/user-attachments/assets/04e84eec-4c6a-4c55-8fbf-fb65d4bd304c)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#11: GitLab support on KIE Sandbox [incubator-kie-tools]

Posted by "Adarshvk98 (via GitHub)" <gi...@apache.org>.
Adarshvk98 commented on PR #3132:
URL: https://github.com/apache/incubator-kie-tools/pull/3132#issuecomment-2900581216

   Thank you, @jomarko , for taking the time to test this. I’ve some observations that I’d like to share below.
   >01 Pull Scenario
   
   I’ve tested the same scenario with other Git providers (Github) and noticed the issue you’ve observed here as well. Which means that it’s a common issue with pull ?. All the Git operations were performed using the npm package called [isomorphic-git](https://isomorphic-git.org/).
   
   >02 Snippet from two places
   
   From the home screen, you can clone the snippet because it supports both cloning the repository and importing a single file. However, from within the workspace, under the “New File” dropdown, you can only import a single file using the URL. I noticed that the URL you provided here is a snippet clone URL with a `.git` extension, which can contain multiple files. Therefore, it won’t support. Try entering a single raw snippet file URL in the input field. Below is a screenshot to help you get the raw URL of the snippet.
   
   <img width="1415" alt="image" src="https://github.com/user-attachments/assets/f3bcfdbf-ef2c-45bd-8a54-d5ff6ef78334" />
   
   <img width="1724" alt="image" src="https://github.com/user-attachments/assets/1dc6d93d-19de-4858-b338-795fabc73175" />
   
   > 03 Subgroups
   
   Currently, all groups and nested groups will be displayed in a dropdown list. I would like to hear your feedback on how this should be displayed.
   Note:
   - Repositories can be created under user space, group space, or nested group space.
   - Snippets can be created under user space or project space (where there’s no nested structure).
   
   cc: @tiagobento 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#11: GitLab support on KIE Sandbox [incubator-kie-tools]

Posted by "jomarko (via GitHub)" <gi...@apache.org>.
jomarko commented on PR #3132:
URL: https://github.com/apache/incubator-kie-tools/pull/3132#issuecomment-2919131865

   @Adarshvk98 thank you for updates. 
   
   ### Ordering
   I think we should apply some ordering to items. Please notice here, it may be difficult to find proper item without ordering.
   ![Screenshot 2025-05-29 132800](https://github.com/user-attachments/assets/d80a6454-dfc1-4d57-aede-86290a4fd9bb)
   
   ### Pull
   As my understanding is the pull scenario described in https://github.com/apache/incubator-kie-tools/pull/3132#pullrequestreview-2859954333 is a separate issue, could you please report ticket for it before we proceed with a merge?
   
   ### Snippet -> Repository
   Question, is it expected, by design, not sure what word to use, that if Sandbox user created firstly Gitlab snippet, that Sandbox still allows to create Repository from the snippet? I mean this button is allowed even if I work with snippet already.
   ![Screenshot 2025-05-29 133437](https://github.com/user-attachments/assets/afa37ec6-87ae-4d2a-ad77-83571745441c)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#11: GitLab support on KIE Sandbox [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on code in PR #3132:
URL: https://github.com/apache/incubator-kie-tools/pull/3132#discussion_r2113097097


##########
packages/online-editor/src/editor/Toolbar/GitIntegration/LoadOrganizationsSelect.tsx:
##########
@@ -102,10 +121,30 @@ export const LoadOrganizationsSelect = (props: Props) => {
       return emptyResponse;
     }
     const values: any[] = json.values;
-    return { organizations: values.map((it) => ({ name: it.workspace.slug })) };
+    return { organizations: values.map((it) => ({ name: it.workspace.slug, value: it.workspace.slug })) };
   }, [bitbucketClient]);
 
-  const { onSelect } = props;
+  const getGitlabGroupsForUser = useCallback(async (): Promise<LoadOrganizationsReponse> => {
+    if (actionType && actionType === "snippet") {
+      const projectsResponse = await gitlabClient.listProjects();
+      const projectsResponseJson = await projectsResponse.json();
+      return {
+        organizations: (projectsResponseJson ?? []).map(({ name, id }: { name: string; id: string }) => ({
+          name,
+          value: id,
+        })),
+      };
+    }
+    const groupsResponse = await gitlabClient.listGroups();
+    const groupsResponseJson = await groupsResponse.json();
+    return {
+      organizations: (groupsResponseJson ?? []).map(({ name, id }: { name: string; id: string }) => ({

Review Comment:
   I'd say we go with `full_name`, as it's display-friendly.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#11: GitLab support on KIE Sandbox [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on code in PR #3132:
URL: https://github.com/apache/incubator-kie-tools/pull/3132#discussion_r2112663189


##########
packages/online-editor/src/importFromUrl/ImportableUrlHooks.tsx:
##########
@@ -466,6 +549,12 @@ export function useImportableUrl(urlString?: string, allowedUrlTypes?: UrlType[]
       });
     }
 
+    // Gitlab
+    if (isGitRemoteDomainAllowed(url, "gitlab.com", AuthProviderType.gitlab)) {

Review Comment:
   No. Just like we do for `github.com`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#11: GitLab support on KIE Sandbox [incubator-kie-tools]

Posted by "Adarshvk98 (via GitHub)" <gi...@apache.org>.
Adarshvk98 commented on code in PR #3132:
URL: https://github.com/apache/incubator-kie-tools/pull/3132#discussion_r2113071670


##########
packages/online-editor/src/editor/Toolbar/GitIntegration/LoadOrganizationsSelect.tsx:
##########
@@ -102,10 +121,30 @@ export const LoadOrganizationsSelect = (props: Props) => {
       return emptyResponse;
     }
     const values: any[] = json.values;
-    return { organizations: values.map((it) => ({ name: it.workspace.slug })) };
+    return { organizations: values.map((it) => ({ name: it.workspace.slug, value: it.workspace.slug })) };
   }, [bitbucketClient]);
 
-  const { onSelect } = props;
+  const getGitlabGroupsForUser = useCallback(async (): Promise<LoadOrganizationsReponse> => {
+    if (actionType && actionType === "snippet") {
+      const projectsResponse = await gitlabClient.listProjects();
+      const projectsResponseJson = await projectsResponse.json();
+      return {
+        organizations: (projectsResponseJson ?? []).map(({ name, id }: { name: string; id: string }) => ({
+          name,
+          value: id,
+        })),
+      };
+    }
+    const groupsResponse = await gitlabClient.listGroups();
+    const groupsResponseJson = await groupsResponse.json();
+    return {
+      organizations: (groupsResponseJson ?? []).map(({ name, id }: { name: string; id: string }) => ({

Review Comment:
   @porcelli 
   **Creating a repository**
   I would like to know which one would be more suitable here, is either `full_path` or `full_name` ?
   - `full_path` : Group paths (used in URLs). It’s all lowercase, uses dashes/underscores instead of spaces, and shows the full nesting path.
   - `full_name` : Display-friendly name of the group, but in a human-readable format (with proper capitalization, spaces, slashes, etc.)
   
   Attaching a screenshot in case for a reference
   ![image](https://github.com/user-attachments/assets/aa298635-3758-476b-9ba2-1d9fc3daf1c2)
   
   **Creating a snippets**
   
   - The projects API response doesn’t have a `full_path`, but instead, it has `name` and `name_with_namespace`.
   
   ![image](https://github.com/user-attachments/assets/8bb965cc-a96e-48c3-bbd1-6b71873915d8)
   
   cc: @tiagobento 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#11: GitLab support on KIE Sandbox [incubator-kie-tools]

Posted by "jomarko (via GitHub)" <gi...@apache.org>.
jomarko commented on PR #3132:
URL: https://github.com/apache/incubator-kie-tools/pull/3132#issuecomment-2891335149

   @Adarshvk98 thank you, could you please attach screenshot or video, that `gist` works after your last commit?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#11: GitLab support on KIE Sandbox [incubator-kie-tools]

Posted by "Adarshvk98 (via GitHub)" <gi...@apache.org>.
Adarshvk98 commented on code in PR #3132:
URL: https://github.com/apache/incubator-kie-tools/pull/3132#discussion_r2113071670


##########
packages/online-editor/src/editor/Toolbar/GitIntegration/LoadOrganizationsSelect.tsx:
##########
@@ -102,10 +121,30 @@ export const LoadOrganizationsSelect = (props: Props) => {
       return emptyResponse;
     }
     const values: any[] = json.values;
-    return { organizations: values.map((it) => ({ name: it.workspace.slug })) };
+    return { organizations: values.map((it) => ({ name: it.workspace.slug, value: it.workspace.slug })) };
   }, [bitbucketClient]);
 
-  const { onSelect } = props;
+  const getGitlabGroupsForUser = useCallback(async (): Promise<LoadOrganizationsReponse> => {
+    if (actionType && actionType === "snippet") {
+      const projectsResponse = await gitlabClient.listProjects();
+      const projectsResponseJson = await projectsResponse.json();
+      return {
+        organizations: (projectsResponseJson ?? []).map(({ name, id }: { name: string; id: string }) => ({
+          name,
+          value: id,
+        })),
+      };
+    }
+    const groupsResponse = await gitlabClient.listGroups();
+    const groupsResponseJson = await groupsResponse.json();
+    return {
+      organizations: (groupsResponseJson ?? []).map(({ name, id }: { name: string; id: string }) => ({

Review Comment:
   @porcelli 
   I would like to know which one would be more suitable here, is either `full_path` or `full_name` ?
   - `full_path` : Group paths (used in URLs). It’s all lowercase, uses dashes/underscores instead of spaces, and shows the full nesting path.
   - `full_name` : Display-friendly name of the group, but in a human-readable format (with proper capitalization, spaces, slashes, etc.)
   
   Attaching a screenshot in case for a reference
   ![image](https://github.com/user-attachments/assets/aa298635-3758-476b-9ba2-1d9fc3daf1c2)
   cc: @tiagobento 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#11: GitLab support on KIE Sandbox [incubator-kie-tools]

Posted by "porcelli (via GitHub)" <gi...@apache.org>.
porcelli commented on code in PR #3132:
URL: https://github.com/apache/incubator-kie-tools/pull/3132#discussion_r2112302824


##########
packages/online-editor/src/importFromUrl/ImportableUrlHooks.tsx:
##########
@@ -466,6 +549,12 @@ export function useImportableUrl(urlString?: string, allowedUrlTypes?: UrlType[]
       });
     }
 
+    // Gitlab
+    if (isGitRemoteDomainAllowed(url, "gitlab.com", AuthProviderType.gitlab)) {

Review Comment:
   Shouldn't use the configurable domain here instead gitlab.com?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#11: GitLab support on KIE Sandbox [incubator-kie-tools]

Posted by "porcelli (via GitHub)" <gi...@apache.org>.
porcelli commented on code in PR #3132:
URL: https://github.com/apache/incubator-kie-tools/pull/3132#discussion_r2112909830


##########
packages/online-editor/src/editor/Toolbar/GitIntegration/LoadOrganizationsSelect.tsx:
##########
@@ -102,10 +121,30 @@ export const LoadOrganizationsSelect = (props: Props) => {
       return emptyResponse;
     }
     const values: any[] = json.values;
-    return { organizations: values.map((it) => ({ name: it.workspace.slug })) };
+    return { organizations: values.map((it) => ({ name: it.workspace.slug, value: it.workspace.slug })) };
   }, [bitbucketClient]);
 
-  const { onSelect } = props;
+  const getGitlabGroupsForUser = useCallback(async (): Promise<LoadOrganizationsReponse> => {
+    if (actionType && actionType === "snippet") {
+      const projectsResponse = await gitlabClient.listProjects();
+      const projectsResponseJson = await projectsResponse.json();
+      return {
+        organizations: (projectsResponseJson ?? []).map(({ name, id }: { name: string; id: string }) => ({
+          name,
+          value: id,
+        })),
+      };
+    }
+    const groupsResponse = await gitlabClient.listGroups();
+    const groupsResponseJson = await groupsResponse.json();
+    return {
+      organizations: (groupsResponseJson ?? []).map(({ name, id }: { name: string; id: string }) => ({

Review Comment:
   maybe use `full_path` instead of `name` so you show the full name and avoid ambiguities with different sub groups with same name.
   
   use full_path could also be applied to project list that I can list different projects (under different sub-groups) but with same name.
   
   ![Screenshot 2025-05-28 at 6 39 08 PM](https://github.com/user-attachments/assets/4716d307-7130-4574-8c25-13f5a1d99277)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#11: GitLab support on KIE Sandbox [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on code in PR #3132:
URL: https://github.com/apache/incubator-kie-tools/pull/3132#discussion_r2113097545


##########
packages/online-editor/src/editor/Toolbar/GitIntegration/LoadOrganizationsSelect.tsx:
##########
@@ -102,10 +121,30 @@ export const LoadOrganizationsSelect = (props: Props) => {
       return emptyResponse;
     }
     const values: any[] = json.values;
-    return { organizations: values.map((it) => ({ name: it.workspace.slug })) };
+    return { organizations: values.map((it) => ({ name: it.workspace.slug, value: it.workspace.slug })) };
   }, [bitbucketClient]);
 
-  const { onSelect } = props;
+  const getGitlabGroupsForUser = useCallback(async (): Promise<LoadOrganizationsReponse> => {
+    if (actionType && actionType === "snippet") {
+      const projectsResponse = await gitlabClient.listProjects();
+      const projectsResponseJson = await projectsResponse.json();
+      return {
+        organizations: (projectsResponseJson ?? []).map(({ name, id }: { name: string; id: string }) => ({
+          name,
+          value: id,
+        })),
+      };
+    }
+    const groupsResponse = await gitlabClient.listGroups();
+    const groupsResponseJson = await groupsResponse.json();
+    return {
+      organizations: (groupsResponseJson ?? []).map(({ name, id }: { name: string; id: string }) => ({

Review Comment:
   For snippets I think `name_with_namespace` follows the same logic.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#11: GitLab support on KIE Sandbox [incubator-kie-tools]

Posted by "Adarshvk98 (via GitHub)" <gi...@apache.org>.
Adarshvk98 commented on PR #3132:
URL: https://github.com/apache/incubator-kie-tools/pull/3132#issuecomment-2919191347

   Thanks, @jomarko , for suggesting this improvement. I’ve made those changes.
   >Pull
   
   For the pull scenario, I will create a Kie issue
   >Snippet -> Repository
   
   I think this is expected. We can convert a snippet into a repository, and this is implemented in the same way as GitHub today.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#11: GitLab support on KIE Sandbox [incubator-kie-tools]

Posted by "thiagoelg (via GitHub)" <gi...@apache.org>.
thiagoelg commented on code in PR #3132:
URL: https://github.com/apache/incubator-kie-tools/pull/3132#discussion_r2111989913


##########
packages/online-editor/src/gitlab/GitlabClient.ts:
##########
@@ -0,0 +1,222 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import lodash from "lodash";
+
+export interface Options {
+  appName: string;
+  token?: string;
+  domain?: string;
+  headers?: Record<string, string>;
+  proxyUrl?: string;
+}
+
+type GitlabVisibility = "private" | "internal" | "public";
+type GitlabBasePath = "/projects" | "/groups" | "/snippets";
+
+type GetSnippetArgsType = {
+  snippetId: string;
+  group?: string;
+  project?: string;
+};
+
+type GetSnippetFileArgsType = {
+  snippetId: string;
+  group?: string;
+  project?: string;
+  branch?: string;
+  filePath: string;
+};
+
+type GetRepositoryContentsArgsType = {
+  project: string;
+  ref: string;
+  path: string;
+  group?: string;
+};
+
+type CreateRepositoryArgsType = {
+  name: string;
+  groupId?: string;
+  visibility: GitlabVisibility;
+};
+
+type SnippetsFile = {
+  file_path: string;
+  content: string;
+};
+
+type CreateSnippetArgsType = {
+  title: string;
+  files: SnippetsFile[];
+  visibility: GitlabVisibility;
+  id?: string;
+};
+
+type ProjectPath = {
+  group?: string;
+  project?: string;
+};
+
+export interface GitlabClientApi {
+  appName: string;
+  token?: string;
+  domain?: string;
+  headers?: Record<string, string>;
+  getApiUrl(): string;
+  getAuthedUser(): Promise<Response>;
+  createRepository(args: CreateRepositoryArgsType): Promise<Response>;
+  getRepositoryContents(args: GetRepositoryContentsArgsType): Promise<Response>;
+  createSnippet(args: CreateSnippetArgsType): Promise<Response>;
+  getSnippet(args: GetSnippetArgsType): Promise<Response>;
+  getSnippetFile(args: GetSnippetFileArgsType): Promise<Response>;
+  getSnippetFileRaw(args: GetSnippetFileArgsType): Promise<Response>;
+  listGroups(): Promise<Response>;
+  listProjects(): Promise<Response>;
+}
+export class GitlabClient implements GitlabClientApi {
+  constructor(options: Options) {
+    this.appName = options.appName;
+    this.token = options?.token ?? "";
+    this.domain = options?.domain ?? "gitlab.com";
+    this.headers = {
+      "Content-Type": "application/json",
+      Accept: "application/json",
+      ...options?.headers,
+    };
+    this.proxyUrl = options.proxyUrl;
+  }
+  appName: string;
+  token: string;
+  domain: string;
+  headers: Record<string, string>;
+  proxyUrl?: string;
+
+  request = async (props: {
+    urlContext: string;
+    method?: string;
+    body?: any;
+    extraHeaders?: { [key: string]: string | undefined };
+  }) => {
+    const resolvedUrl = new URL(this.getApiUrl() + props.urlContext).toString();
+    const authHeader: Record<string, string> = { Authorization: "Bearer " + this.token };
+    const requestHeaders = {
+      ...this.headers,
+      ...props.extraHeaders,
+      ...authHeader,
+    };
+
+    return fetch(resolvedUrl, {
+      method: props.method,
+      headers: JSON.parse(JSON.stringify(requestHeaders)), // allows for erasing header in extraHeaders
+      body: props.body,
+    });
+  };
+
+  getApiUrl = () => {
+    if (this.proxyUrl) {
+      return `${this.proxyUrl}/${this.domain}/api/v4`;
+    }
+    return `https://${this.domain}/api/v4`;
+  };
+
+  getAuthedUser = () => this.request({ urlContext: "/user" });
+
+  createProjectPath = ({ group, project }: ProjectPath): string =>
+    encodeURIComponent([group, project].filter(Boolean).join("/"));
+
+  createProjectBasePathWithId = ({ group, project }: ProjectPath, basePath: GitlabBasePath = "/projects") => {
+    const id = this.createProjectPath({ group, project });
+    return id ? `${basePath}/${id}` : basePath;
+  };
+
+  checkSnippetLevel = ({ group, project }: ProjectPath): string => {
+    const isProjectSnippet = !lodash.isEmpty(group) || !lodash.isEmpty(project);

Review Comment:
   Aren't `group` and `project` strings? This could be `!group || !project`, right?
   If we really need lodash here, update the import to bring only the required function.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#11: GitLab support on KIE Sandbox [incubator-kie-tools]

Posted by "Adarshvk98 (via GitHub)" <gi...@apache.org>.
Adarshvk98 commented on code in PR #3132:
URL: https://github.com/apache/incubator-kie-tools/pull/3132#discussion_r2112114402


##########
packages/online-editor/src/gitlab/GitlabClient.ts:
##########
@@ -0,0 +1,222 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import lodash from "lodash";
+
+export interface Options {
+  appName: string;
+  token?: string;
+  domain?: string;
+  headers?: Record<string, string>;
+  proxyUrl?: string;
+}
+
+type GitlabVisibility = "private" | "internal" | "public";
+type GitlabBasePath = "/projects" | "/groups" | "/snippets";
+
+type GetSnippetArgsType = {
+  snippetId: string;
+  group?: string;
+  project?: string;
+};
+
+type GetSnippetFileArgsType = {
+  snippetId: string;
+  group?: string;
+  project?: string;
+  branch?: string;
+  filePath: string;
+};
+
+type GetRepositoryContentsArgsType = {
+  project: string;
+  ref: string;
+  path: string;
+  group?: string;
+};
+
+type CreateRepositoryArgsType = {
+  name: string;
+  groupId?: string;
+  visibility: GitlabVisibility;
+};
+
+type SnippetsFile = {
+  file_path: string;
+  content: string;
+};
+
+type CreateSnippetArgsType = {
+  title: string;
+  files: SnippetsFile[];
+  visibility: GitlabVisibility;
+  id?: string;
+};
+
+type ProjectPath = {
+  group?: string;
+  project?: string;
+};
+
+export interface GitlabClientApi {
+  appName: string;
+  token?: string;
+  domain?: string;
+  headers?: Record<string, string>;
+  getApiUrl(): string;
+  getAuthedUser(): Promise<Response>;
+  createRepository(args: CreateRepositoryArgsType): Promise<Response>;
+  getRepositoryContents(args: GetRepositoryContentsArgsType): Promise<Response>;
+  createSnippet(args: CreateSnippetArgsType): Promise<Response>;
+  getSnippet(args: GetSnippetArgsType): Promise<Response>;
+  getSnippetFile(args: GetSnippetFileArgsType): Promise<Response>;
+  getSnippetFileRaw(args: GetSnippetFileArgsType): Promise<Response>;
+  listGroups(): Promise<Response>;
+  listProjects(): Promise<Response>;
+}
+export class GitlabClient implements GitlabClientApi {
+  constructor(options: Options) {
+    this.appName = options.appName;
+    this.token = options?.token ?? "";
+    this.domain = options?.domain ?? "gitlab.com";
+    this.headers = {
+      "Content-Type": "application/json",
+      Accept: "application/json",
+      ...options?.headers,
+    };
+    this.proxyUrl = options.proxyUrl;
+  }
+  appName: string;
+  token: string;
+  domain: string;
+  headers: Record<string, string>;
+  proxyUrl?: string;
+
+  request = async (props: {
+    urlContext: string;
+    method?: string;
+    body?: any;
+    extraHeaders?: { [key: string]: string | undefined };
+  }) => {
+    const resolvedUrl = new URL(this.getApiUrl() + props.urlContext).toString();
+    const authHeader: Record<string, string> = { Authorization: "Bearer " + this.token };
+    const requestHeaders = {
+      ...this.headers,
+      ...props.extraHeaders,
+      ...authHeader,
+    };
+
+    return fetch(resolvedUrl, {
+      method: props.method,
+      headers: JSON.parse(JSON.stringify(requestHeaders)), // allows for erasing header in extraHeaders
+      body: props.body,
+    });
+  };
+
+  getApiUrl = () => {
+    if (this.proxyUrl) {
+      return `${this.proxyUrl}/${this.domain}/api/v4`;
+    }
+    return `https://${this.domain}/api/v4`;
+  };
+
+  getAuthedUser = () => this.request({ urlContext: "/user" });
+
+  createProjectPath = ({ group, project }: ProjectPath): string =>
+    encodeURIComponent([group, project].filter(Boolean).join("/"));
+
+  createProjectBasePathWithId = ({ group, project }: ProjectPath, basePath: GitlabBasePath = "/projects") => {
+    const id = this.createProjectPath({ group, project });
+    return id ? `${basePath}/${id}` : basePath;
+  };
+
+  checkSnippetLevel = ({ group, project }: ProjectPath): string => {
+    const isProjectSnippet = !lodash.isEmpty(group) || !lodash.isEmpty(project);

Review Comment:
   Updated the import of lodash



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#11: GitLab support on KIE Sandbox [incubator-kie-tools]

Posted by "jomarko (via GitHub)" <gi...@apache.org>.
jomarko commented on PR #3132:
URL: https://github.com/apache/incubator-kie-tools/pull/3132#issuecomment-2891145273

   ### 04 Steps to reproduce
   - Open Sandbox
   - Try Sample DMN
   - Share -> Create Gitlab SNippet, chose private visibility
   - Shown flash message is OK (no '.git' suffix) ✅ 
   - Move some decision node
   - Sync Snippet
   - The flash message contains '.git' suffix 🔴 
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#11: GitLab support on KIE Sandbox [incubator-kie-tools]

Posted by "jomarko (via GitHub)" <gi...@apache.org>.
jomarko commented on PR #3132:
URL: https://github.com/apache/incubator-kie-tools/pull/3132#issuecomment-2900093859

   ### Snippet from two places
   I can use this URL `https://gitlab.com/jomarko1-group/jomarko1-project/snippets/4844651.git` from home screen
   ![Screenshot 2025-05-22 083932](https://github.com/user-attachments/assets/e1619871-332b-4af9-ae60-7242bd2994ce)
   
   
   But I can not use the same URL from asset opened
   ![image](https://github.com/user-attachments/assets/0ea26755-3d63-4709-9fe5-67049c2ca480)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#11: GitLab support on KIE Sandbox [incubator-kie-tools]

Posted by "jomarko (via GitHub)" <gi...@apache.org>.
jomarko commented on PR #3132:
URL: https://github.com/apache/incubator-kie-tools/pull/3132#issuecomment-2900166419

   ### 03 Subgroups
   It is expected Sandbox list subgroup sibling of group?
   ![Screenshot 2025-05-22 091351](https://github.com/user-attachments/assets/e1260cc1-20f9-4536-8912-28ae81a8163a)
   
   
   while gitlab has subgroup like nested in group?
   ![image](https://github.com/user-attachments/assets/8cea2095-5575-49c1-8389-c865eefcdbb8)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#11: GitLab support on KIE Sandbox [incubator-kie-tools]

Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento merged PR #3132:
URL: https://github.com/apache/incubator-kie-tools/pull/3132


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org