Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ui render issue when changing pipelines #104

Merged
merged 4 commits into from
Dec 4, 2024
Merged

Conversation

markphelps
Copy link
Contributor

Fixes issue that was preventing pipelines from rendering correctly when selecting a new one from the sidebar.

Also sorts the pipeline responses so react can better detect if the state actually changed


This pull request includes several changes to both the backend and frontend codebases to improve stability and simplify the state management. The most important changes include sorting entities for stability in the backend, refactoring the frontend to remove redundant state management, and updating components to use new props.

Backend Changes:

  • server.go: Added sorting for phases, edges, and pipelines by name to ensure stability. [1] [2] [3]

Frontend Changes:

  • pipeline.tsx: Removed the pipelinesSlice state management and refactored the component to fetch and use pipeline data directly from the API. [1] [2]
  • header.tsx: Updated the Header component to accept and display the pipelineId prop instead of using the selected pipeline from the state. [1] [2]
  • layout.tsx: Simplified the layout by removing unnecessary div elements around the Outlet component.
  • sidebar.tsx: Added a function to handle pipeline selection and navigation, improving code readability. [1] [2]

State Management Changes:

const [selectedNode, setSelectedNode] = useState<PhaseNode | null>(null);
const [isPanelExpanded, setIsPanelExpanded] = useState(true);

const { pipeline } = props;
const { nodes: initNodes, edges: initEdges } = getElements(pipeline);
const { data: pipeline, isLoading } = useGetPipelineQuery(pipelineId);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i will handle isLoading in another PR as I want to display some skeleton nodes or something while loading and this will prob be a bigger change

Copy link
Member

@GeorgeMac GeorgeMac left a comment

Choose a reason for hiding this comment

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

Noice

@erka
Copy link
Collaborator

erka commented Dec 4, 2024

slices.SortFunc could be better option for sorting slices.

Signed-off-by: Mark Phelps <[email protected]>
@kodiakhq kodiakhq bot merged commit 6395fbc into main Dec 4, 2024
3 checks passed
@kodiakhq kodiakhq bot deleted the fix-ui-render branch December 4, 2024 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants