Skip to content

feat(ui): project variable support [FLOW-FE-138]#692

Merged
KaWaite merged 99 commits intomainfrom
ui/add-project-parameters
Jul 7, 2025
Merged

feat(ui): project variable support [FLOW-FE-138]#692
KaWaite merged 99 commits intomainfrom
ui/add-project-parameters

Conversation

@KaWaite
Copy link
Member

@KaWaite KaWaite commented Dec 12, 2024

Overview

What I've done

  • Project variables dialog UI + topbar button
  • Connected to GQL api for CRUD support

What I haven't done

  • Use inside of a node
  • Exporting support
  • Trigger support

How I tested

Screenshot

Which point I want you to review particularly

Memo

@netlify
Copy link

netlify bot commented Dec 12, 2024

Deploy Preview for reearth-flow ready!

Name Link
🔨 Latest commit 72be679
🔍 Latest deploy log https://app.netlify.com/sites/reearth-flow/deploys/675a8267d7d8e20008f1dd8d
😎 Deploy Preview https://deploy-preview-692--reearth-flow.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Dec 12, 2024

Deploy Preview for reearth-flow ready!

Name Link
🔨 Latest commit abdb274
🔍 Latest deploy log https://app.netlify.com/projects/reearth-flow/deploys/686b6a8524c41900087fbf1e
😎 Deploy Preview https://deploy-preview-692--reearth-flow.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@KaWaite KaWaite marked this pull request as ready for review December 17, 2024 23:38
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (8)
ui/src/features/Editor/components/LeftPanel/components/ProjectVariables/ProjectVarDialog.tsx (1)

159-161: Provide user feedback when removing whitespace from variable names

Currently, whitespace in variable names is automatically removed without user feedback, which might confuse users. Instead of silently modifying the input, consider preventing whitespace entry or displaying a validation message.

You could update the input to prevent whitespace characters:

 <Input
   value={variable.name}
   onClick={(e) => e.stopPropagation()}
   onChange={(e) => {
     setProjectVariables((pvs) => {
       const newPvs = [...pvs];
-      const newValue = e.target.value;
-      newPvs[idx].name = newValue.split(/\s+/).join("");
+      const newValue = e.target.value.replace(/\s/g, "");
+      newPvs[idx].name = newValue;
       return newPvs;
     });
   }}
 />

And optionally, inform the user that whitespace is not allowed in variable names.

ui/src/types/projectVar.ts (1)

12-13: Specify a stricter type for definition and address the TODO

Currently, definition is typed as any, which can lead to type safety issues. Consider defining definition based on VarType to enhance type safety. Additionally, there's a TODO to use ParameterType; implementing this would improve consistency.

Would you like assistance in defining ParameterType and updating the ProjectVar type accordingly?

ui/src/features/Editor/components/LeftPanel/components/ProjectVariables/ProjectVariable.tsx (1)

10-15: Add accessibility improvements

The component lacks proper accessibility attributes for better screen reader support.

-    <div className={`flex items-center rounded p-1 ${className}`}>
+    <div 
+      className={`flex items-center rounded p-1 ${className}`}
+      role="listitem"
+      aria-label={`Project variable ${variable.name}`}>
       <p className="flex-1 truncate text-sm">{variable.name}</p>
       <p className="flex-1 truncate text-sm dark:font-extralight">
         {JSON.stringify(variable.definition)}
       </p>
     </div>
ui/src/mock_data/projectVars.ts (1)

5-8: Improve mock data quality and readability

The mock data contains unnecessarily long values and random-looking IDs which reduce readability and maintainability.

-    id: "asdfasfsdasdffsdf",
-    name: "project_name",
-    definition: "My Projectjlasjdflakjsdflkjsadflkjasdflkjasdlkjafsdlk",
+    id: "project_name_001",
+    name: "project_name",
+    definition: "Sample Project",
ui/src/features/Editor/components/LeftPanel/components/ProjectVariables/index.tsx (2)

15-17: Plan GraphQL implementation

The TODO comment indicates missing GraphQL integration. This should be tracked and implemented to replace the mock data.

Would you like me to help create a GitHub issue to track the GraphQL implementation task? I can provide a template with the necessary requirements and implementation steps.


27-64: Add loading state handling

The component should handle loading states when fetching project variables (future GraphQL implementation).

 const ProjectVariables: React.FC = () => {
   const t = useT();
   const [isOpen, setIsOpen] = useState(false);
+  const [isLoading, setIsLoading] = useState(false);

   // TODO: get project variables from gql
   const [currentProjectVars, setCurrentProjectVars] =
     useState<ProjectVar[]>(MOCK_DATA);

   // ... existing code ...

   return (
     <>
       <div className="flex h-full flex-col gap-4 p-1">
         <div className="flex-1">
           <div className="flex items-center pb-2">
             <p className="flex-1 text-sm font-thin">{t("Key")}</p>
             <p className="flex-1 text-sm font-thin">{t("Value")}</p>
           </div>
           <ScrollArea>
+            {isLoading ? (
+              <div className="flex justify-center p-4">
+                <LoadingSpinner />
+              </div>
+            ) : (
             <div className="flex flex-col gap-1 overflow-y-auto">
               {currentProjectVars.map((variable, idx) => (
                 <ProjectVariable
                   key={variable.id}
                   className={`${idx % 2 !== 0 ? "bg-card" : "bg-primary"}`}
                   variable={variable}
                 />
               ))}
             </div>
+            )}
           </ScrollArea>
         </div>
ui/src/features/Editor/components/LeftPanel/index.tsx (1)

99-115: Consider the tab ordering logic.

While the implementation is correct, consider if the current tab order (project-vars → resources → actions-list) provides the most intuitive user experience. Common patterns typically group similar functionality together.

A potential alternative order could be:

  • navigator (current first)
  • actions-list (related to canvas actions)
  • resources (project resources)
  • project-vars (project configuration)
ui/src/lib/i18n/locales/es.json (1)

21-24: Consider using more technical terminology for "Key" in Spanish.

While the translations are generally good, consider using "Llave" instead of "Clave" for "Key" as it's more commonly used in programming contexts in Spanish.

Current translations:

  • "Key" → "Clave" (consider: "Llave")
  • "Value" → "Valor"
  • "Project Variables" → "Variables del proyecto"
  • "Edit Project Variables" → "Editar variables del proyecto"
  • "Resources" → "Recursos"

Also applies to: 27-28

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ed959cf and be8b7f3.

📒 Files selected for processing (13)
  • ui/src/features/Editor/components/LeftPanel/components/ProjectVariables/ProjectVarDialog.tsx (1 hunks)
  • ui/src/features/Editor/components/LeftPanel/components/ProjectVariables/ProjectVariable.tsx (1 hunks)
  • ui/src/features/Editor/components/LeftPanel/components/ProjectVariables/index.tsx (1 hunks)
  • ui/src/features/Editor/components/LeftPanel/components/index.ts (1 hunks)
  • ui/src/features/Editor/components/LeftPanel/index.tsx (4 hunks)
  • ui/src/lib/i18n/locales/en.json (1 hunks)
  • ui/src/lib/i18n/locales/es.json (1 hunks)
  • ui/src/lib/i18n/locales/fr.json (1 hunks)
  • ui/src/lib/i18n/locales/ja.json (1 hunks)
  • ui/src/lib/i18n/locales/zh.json (1 hunks)
  • ui/src/mock_data/projectVars.ts (1 hunks)
  • ui/src/types/index.ts (1 hunks)
  • ui/src/types/projectVar.ts (1 hunks)
🔇 Additional comments (9)
ui/src/features/Editor/components/LeftPanel/components/index.ts (1)

3-3: LGTM!

The export statement correctly includes the ProjectVariables component.

ui/src/types/index.ts (1)

10-10: LGTM!

The export statement correctly adds projectVar types to the exports.

ui/src/mock_data/projectVars.ts (1)

32-37: Consider implementing object type support

The commented-out object type configuration suggests incomplete feature implementation. If object type support is planned, it should be properly implemented or removed to avoid confusion.

Let's check if object type is supported in the codebase:

ui/src/features/Editor/components/LeftPanel/components/ProjectVariables/index.tsx (1)

22-25: 🛠️ Refactor suggestion

Add error handling for state updates

The handleSubmit function lacks error handling for the state update operation.

   const handleSubmit = (newProjectVars: ProjectVar[]) => {
+    try {
       setCurrentProjectVars(newProjectVars);
       handleDialogClose();
+    } catch (error) {
+      console.error('Failed to update project variables:', error);
+      // TODO: Add error notification
+    }
   };

Likely invalid or redundant comment.

ui/src/features/Editor/components/LeftPanel/index.tsx (2)

2-2: LGTM: Clean import additions and type definition.

The new imports and type extension for project variables support are well-organized and follow the existing pattern.

Also applies to: 19-19, 21-21


160-160: LGTM: Improved layout structure.

The flex layout modifications and overflow handling enhance the panel's responsiveness and scrolling behavior.

Also applies to: 167-167

ui/src/lib/i18n/locales/zh.json (1)

21-28: LGTM: Complete and accurate Chinese translations.

All new keys have appropriate Chinese translations that are semantically correct and maintain consistency with the existing translations.

ui/src/lib/i18n/locales/ja.json (1)

21-24: LGTM! Japanese translations are accurate and natural.

The translations for project variables feature are well-implemented with appropriate Japanese terminology:

  • "Key" → "キー"
  • "Value" → "値"
  • "Project Variables" → "プロジェクト変数"
  • "Edit Project Variables" → "プロジェクト変数を編集"
  • "Resources" → "リソース"

Also applies to: 27-28

ui/src/lib/i18n/locales/fr.json (1)

21-24: LGTM! French translations are accurate and consistent.

The translations for project variables feature are well-implemented with appropriate French terminology:

  • "Key" → "Clé"
  • "Value" → "Valeur"
  • "Project Variables" → "Variables du projet"
  • "Edit Project Variables" → "Modifier les variables du projet"
  • "Resources" → "Ressources"

Also applies to: 27-28

@KaWaite KaWaite requested a review from pyshx as a code owner March 30, 2025 20:26
@github-actions github-actions bot added the api label Mar 30, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Jun 24, 2025

🚀 Cloud Run Preview Deployed

🔗 Click here to open the preview in a new tab

@KaWaite KaWaite merged commit fdc84f9 into main Jul 7, 2025
25 checks passed
@KaWaite KaWaite deleted the ui/add-project-parameters branch July 7, 2025 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments