rickychen-infinirc opened a new pull request, #58757:
URL: https://github.com/apache/airflow/pull/58757

   **Description**
   
   This PR fixes the variable editor to preserve JSON formatting when editing 
variables in the Airflow UI.
   
   **Problem:**
   In Airflow 3.x, variable values are displayed as minified single-line 
strings in the edit dialog, making it difficult to read and edit structured 
data like JSON and YAML.
   
   **Solution:**
   Added a `formatValue` function in `EditVariableButton.tsx` that formats JSON 
values with proper indentation (2 spaces) when the edit dialog is opened. 
Non-JSON values are preserved as-is.
   
   **Changes:**
   - Modified `EditVariableButton.tsx` to add `formatValue` function
   - JSON values are formatted using `JSON.stringify(parsed, null, 2)`
   - Non-JSON values are displayed unchanged
   
   **Testing:**
   1. Created test variable with formatted JSON
   2. Verified formatting is preserved in edit dialog
   3. Tested with YAML values - preserved as-is
   
   **Screenshots:**
   
   **Before:**
   Value field shows: `{"key": "val", "key2": "val2"}`
   <img width="788" height="376" alt="截圖 2025-11-27 下午2 28 11" 
src="https://github.com/user-attachments/assets/bce8baf9-8763-4686-a7bb-1f00d0eec85d";
 />
   
   
   **After:**
   Value field shows:
   ```
   {
     "key": "val",
     "key2": "val2"
   }
   ```
   <img width="886" height="461" alt="截圖 2025-11-27 下午2 29 14" 
src="https://github.com/user-attachments/assets/3b982871-77b4-4e8a-b442-b7b50153b700";
 />
   
   
   
   
   **Related Issue(s):**
   Closes #58648
   
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to