Skip to content

Poc gamma#15796

Draft
gcusnieux wants to merge 8 commits intopoc-gamma-reactfrom
poc-gamma-react-policy-studio
Draft

Poc gamma#15796
gcusnieux wants to merge 8 commits intopoc-gamma-reactfrom
poc-gamma-react-policy-studio

Conversation

@gcusnieux
Copy link
Copy Markdown
Member

Issue

https://gravitee.atlassian.net/browse/APIM-XXX

Description

A small description of what you did in that PR.

Additional context

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request initiates a Proof of Concept (POC) for a new React-based Policy Studio within the Gravitee Gamma application. The primary objective is to validate a modern architecture for complex user interfaces, focusing on drag-and-drop interactions, dynamic form generation from JSON schemas, and efficient state management. The implementation includes foundational UI components, a robust API client with development-friendly features like mock and chaos modes, and comprehensive documentation to guide future development and evaluation.

Highlights

  • New Policy Studio Implementation: Introduced a React-based Policy Studio Proof of Concept (POC) to re-implement the existing Angular Policy Studio v4, validating architectural patterns for complex UIs.
  • Comprehensive Documentation: Added detailed coding guidelines, architectural overview, and a dedicated POC plan document, outlining constraints, milestones, and verification steps for the new Policy Studio.
  • Drag-and-Drop Functionality: Implemented drag-and-drop for policies and steps using the dnd-kit library, including visual feedback and validation for phase compatibility.
  • State Management with useReducer: Centralized application state for flows, selected policies, and save operations using a useReducer hook, ensuring predictable state transitions.
  • API Integration with Mock & Chaos Modes: Developed a flexible API client that supports mock data for isolated development and a 'chaos mode' to simulate network latency and errors for resilience testing.
  • Dynamic Policy Configuration: Enabled configuration of policy steps via JSON Schema, utilizing a sheet component to display and allow editing of policy configurations.
  • Robust Error Handling: Integrated React Error Boundaries at various component levels and implemented defensive coding practices to gracefully handle corrupted API data.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the Policy Studio React POC, including comprehensive coding guidelines, architectural documentation, and implementation details for state management, data fetching, and UI components. The new CODING_GUIDELINES.md, POLICY_STUDIO_ARCHITECTURE.md, and POLICY_STUDIO_POC.md files are exceptionally well-written, providing clear and detailed information that will be invaluable for future development and understanding of the project. The implementation demonstrates a strong adherence to modern React and TypeScript best practices, including immutable state updates, robust error handling, and thoughtful consideration for accessibility and anti-happy-path scenarios. The use of safeFlows and safeStep functions to handle potentially corrupted API data is particularly commendable, directly addressing a key anti-happy-path constraint. Overall, the changes are of high quality and lay a solid foundation for the Policy Studio.

No flows yet. Click + to create one.
</div>
)}
{flows.map((flow, index) => (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using index as a key for list items is generally discouraged in React, especially when items can be added, removed, or reordered, as it can lead to subtle bugs and performance issues due to incorrect component reconciliation. While FlowListItems are not directly sortable, flows can be added or removed, which changes the indices of subsequent items.

Consider adding a unique id property to the Flow interface and using flow.id as the key. This ensures stable component identities across list changes.

readonly saveApi: (api: ApiV4) => Promise<void>;
}

export function useApi(apiId: string): UseApiResult {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The apiId parameter is typed as string, but useParams can return undefined. The calling component (PolicyStudioPage.tsx) uses apiId ?? '' to handle this, which is a valid workaround.

However, for clearer API contract and to allow the hook to explicitly handle the undefined case (e.g., by not fetching if apiId is undefined), consider typing apiId as string | undefined.

Suggested change
export function useApi(apiId: string): UseApiResult {
export function useApi(apiId: string | undefined): UseApiResult {

@@ -0,0 +1,79 @@
import type { Flow, Step, Phase, HttpMethod, PolicyPlugin } from './types';

let nextStepId = 1;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The nextStepId variable is a global mutable state used for generating unique step IDs. While this works for a POC, it could lead to issues in a larger application, especially with hot module replacement or if multiple instances of the application were to run in different contexts.

For a more robust solution, consider using a UUID generation library (e.g., uuid) to ensure globally unique IDs, or encapsulate the ID generation logic within a context or a more controlled scope if nextStepId needs to be sequential and resetable.

@gcusnieux gcusnieux changed the title Poc gamma react policy studio Poc gamma Mar 18, 2026
@gcusnieux gcusnieux force-pushed the poc-gamma-react-policy-studio branch from cb851b3 to c84b6cf Compare March 18, 2026 22:45
@gcusnieux gcusnieux force-pushed the poc-gamma-react-policy-studio branch from b5b8175 to 0c4f0de Compare March 20, 2026 08:26
@gcusnieux gcusnieux force-pushed the poc-gamma-react-policy-studio branch from 0c4f0de to 8d93be5 Compare March 20, 2026 09:45
"@rjsf/utils": "^6.4.1",
"@rjsf/validator-ajv8": "^6.4.1",
"@scalar/openapi-parser": "0.11.1",
"@toast-ui/editor": "3.2.2",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Aqua detected vulnerability in your code

Vulnerability ID: CVE-2025-26791
Check Name: dompurify: Mutation XSS in DOMPurify Due to Improper Template Literal Handling
Severity: MEDIUM
Fixed Version: 3.2.4
Reachable Path(s) Found: No
Description: DOMPurify before 3.2.4 has an incorrect template literal regular expression, sometimes leading to mutation cross-site scripting (mXSS).
(This package is used under: @toast-ui/editor@3.2.2->dompurify@2.5.9)
[This comment was created by Aqua Pipeline]

Read more at https://avd.aquasec.com/nvd/cve-2025-26791

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants