Skip to content

Commit

Permalink
feat(ui-studies): sort study tree folders (#2300)
Browse files Browse the repository at this point in the history
Co-authored-by: Anis SMAIL <anis.smail_externe@rte-france.com>
Co-authored-by: Samir Kamal <1954121+skamril@users.noreply.github.com>
3 people authored Jan 23, 2025
1 parent a7dd4ab commit 0e87c2f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions webapp/src/components/App/Studies/StudyTree/StudyTreeNode.tsx
Original file line number Diff line number Diff line change
@@ -12,7 +12,8 @@
* This file is part of the Antares project.
*/

import { memo } from "react";
import { memo, useMemo } from "react";
import * as R from "ramda";
import type { StudyTreeNodeProps } from "./types";
import TreeItemEnhanced from "@/components/common/TreeItemEnhanced";
import { t } from "i18next";
@@ -25,6 +26,11 @@ export default memo(function StudyTreeNode({
const isLoadingFolder = studyTreeNode.hasChildren && studyTreeNode.children.length === 0;
const id = parentId ? `${parentId}/${studyTreeNode.name}` : studyTreeNode.name;

const sortedChildren = useMemo(
() => R.sortBy(R.prop("name"), studyTreeNode.children),
[studyTreeNode.children],
);

if (isLoadingFolder) {
return (
<TreeItemEnhanced
@@ -43,7 +49,7 @@ export default memo(function StudyTreeNode({
label={studyTreeNode.name}
onClick={() => onNodeClick(id, studyTreeNode)}
>
{studyTreeNode.children.map((child) => (
{sortedChildren.map((child) => (
<StudyTreeNode
key={`${id}/${child.name}`}
studyTreeNode={child}

0 comments on commit 0e87c2f

Please sign in to comment.