krikera opened a new pull request, #51534:
URL: https://github.com/apache/airflow/pull/51534

   <!--
    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.
    -->
   
   ## Fix DagVersionSelect filtering to show only versions compatible with 
selected DagRun
   
   This PR fixes the DagVersionSelect component in the Graph view to filter 
available versions based on the currently selected DagRun, preventing users 
from selecting incompatible version/DagRun combinations that cause confusion.
   
   ### Problem
   When viewing a DAG's Graph view, users could select any DAG version 
regardless of which DagRun was selected. This led to confusing scenarios where 
the selected version wasn't actually part of the displayed DagRun's 
`dag_versions` array, causing inconsistent data presentation.
   
   ### Solution
   - **Filter versions by DagRun**: When a specific DagRun is selected, only 
show versions that exist in that DagRun's `dag_versions` array
   - **Auto-clear incompatible selections**: Automatically clear version 
selection when switching to a DagRun that doesn't contain the currently 
selected version
   - **Maintain backward compatibility**: When no DagRun is selected, continue 
showing all available DAG versions
   - **Improve UX**: Prevent confusing version/DagRun combinations and provide 
clearer user guidance
   
   ### Changes Made
   1. **Enhanced DagVersionSelect component**:
      - Added `useDagRunServiceGetDagRun` hook to fetch current DagRun data
      - Implemented `availableVersions` filtering logic using `useMemo`
      - Added `useEffect` to auto-clear incompatible version selections
      - Updated component disabled state to handle filtered results
   
   2. **Key Logic**:
      ```typescript
      // Filter versions based on selected DagRun
      const availableVersions = useMemo(() => {
        if (!data?.dag_versions) return [];
        
        // If a DagRun is selected, only show versions that are part of that 
DagRun
        if (dagRunData?.dag_versions) {
          const dagRunVersionNumbers = new Set(
            dagRunData.dag_versions.map(v => v.version_number)
          );
          return data.dag_versions.filter(v => 
            dagRunVersionNumbers.has(v.version_number)
          );
        }
        
        // If no DagRun is selected, show all versions
        return data.dag_versions;
      }, [data?.dag_versions, dagRunData?.dag_versions]);
      ```
   
   ---
   
   closes: #51487
   
   


-- 
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