Просмотр исходного кода

feat(stories): Sort folders first (#68993)

<img alt="clipboard.png" width="301"
src="https://i.imgur.com/MLdTnTG.png" />
Evan Purkhiser 11 месяцев назад
Родитель
Сommit
8b4ed4c7c9
1 измененных файлов с 6 добавлено и 1 удалено
  1. 6 1
      static/app/views/stories/storyTree.tsx

+ 6 - 1
static/app/views/stories/storyTree.tsx

@@ -25,9 +25,14 @@ function FolderContent({path, content}: {content: TreeMapping; path: string}) {
   const location = useLocation<StoriesQuery>();
   const currentFile = location.query.name;
 
+  // sort folders to the top
+  const entries = Object.entries(content).sort(
+    (a, b) => Number(!!Object.keys(b[1]).length) - Number(!!Object.keys(a[1]).length)
+  );
+
   return (
     <UnorderedList>
-      {Object.entries(content).map(([name, children]) => {
+      {entries.map(([name, children]) => {
         const childPath = toPath(path, name);
 
         if (Object.keys(children).length === 0) {