Skip to content

Commit ca8d83a

Browse files
committed
tc
1 parent dc8365e commit ca8d83a

File tree

1 file changed

+15
-53
lines changed

1 file changed

+15
-53
lines changed

torchci/components/HudGroupingSettings/MainPageSettings.tsx

Lines changed: 15 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import {
1313
verticalListSortingStrategy,
1414
} from "@dnd-kit/sortable";
1515
import { CSS } from "@dnd-kit/utilities";
16-
import { KeyboardArrowDown } from "@mui/icons-material";
17-
import KeyboardArrowUpIcon from "@mui/icons-material/KeyboardArrowUp";
1816
import {
1917
Button,
2018
Dialog,
@@ -37,7 +35,6 @@ import {
3735
isDupName,
3836
saveTreeData,
3937
} from "./mainPageSettingsUtils";
40-
import { set } from "lodash";
4138

4239
function validRegex(value: string) {
4340
try {
@@ -172,31 +169,6 @@ export default function SettingsModal({
172169
setTreeData(treeData.filter((node) => node.name !== name));
173170
}
174171

175-
function moveItem(name: string, direction: "up" | "down") {
176-
const group = treeData.find((node) => node.name === name)!;
177-
const index =
178-
orderBy === "display" ? group.displayPriority : group.filterPriority;
179-
const swapWithIndex = index + (direction === "down" ? 1 : -1);
180-
181-
if (swapWithIndex < 0 || swapWithIndex >= treeData.length) {
182-
return;
183-
}
184-
const swapWith = treeData.find(
185-
(node) =>
186-
(orderBy === "display" ? node.displayPriority : node.filterPriority) ===
187-
swapWithIndex
188-
);
189-
190-
if (orderBy == "display") {
191-
group.displayPriority = swapWithIndex;
192-
swapWith!.displayPriority = index;
193-
} else {
194-
group.filterPriority = swapWithIndex;
195-
swapWith!.filterPriority = index;
196-
}
197-
setTreeData([...treeData]);
198-
}
199-
200172
function setItem(name: string, newName: string, regex: string) {
201173
setTreeData(
202174
treeData.map((node) => {
@@ -222,7 +194,13 @@ export default function SettingsModal({
222194
};
223195

224196
return (
225-
<ListItem ref={setNodeRef} style={style} {...attributes} {...listeners} id={data.name}>
197+
<ListItem
198+
ref={setNodeRef}
199+
style={style}
200+
{...attributes}
201+
{...listeners}
202+
id={data.name}
203+
>
226204
<ListItemButton>
227205
<Stack
228206
direction="row"
@@ -237,12 +215,6 @@ export default function SettingsModal({
237215
<Typography>{data.regex.source}</Typography>
238216
</Stack>
239217
<Stack direction="row" alignItems={"center"}>
240-
<Button onClick={() => moveItem(data.name, "up")}>
241-
<KeyboardArrowUpIcon />
242-
</Button>
243-
<Button onClick={() => moveItem(data.name, "down")}>
244-
<KeyboardArrowDown />
245-
</Button>
246218
<EditSectionDialog
247219
treeData={treeData}
248220
name={data.name}
@@ -257,15 +229,12 @@ export default function SettingsModal({
257229
});
258230
function handleDragEnd(event: any) {
259231
const { active, over } = event;
260-
const priority = orderBy === "display" ? "displayPriority" : "filterPriority";
261-
console.log(active.id, over.id);
262-
treeDataOrdered.forEach((node) => {
263-
console.log(node.name, node[priority]);
264-
})
265-
266-
const oldIndex = treeData.find((node) => node.name === active.id)![priority];
232+
const priority =
233+
orderBy === "display" ? "displayPriority" : "filterPriority";
234+
const oldIndex = treeData.find((node) => node.name === active.id)![
235+
priority
236+
];
267237
const newIndex = treeData.find((node) => node.name === over.id)![priority];
268-
console.log(newIndex, oldIndex);
269238
if (oldIndex < newIndex) {
270239
setTreeData(
271240
treeData.map((node) => {
@@ -277,7 +246,7 @@ export default function SettingsModal({
277246
} else if (oldIndex <= node[priority] && node[priority] <= newIndex) {
278247
return {
279248
...node,
280-
[orderBy]: node[priority] - 1,
249+
[priority]: node[priority] - 1,
281250
};
282251
}
283252
return node;
@@ -302,13 +271,6 @@ export default function SettingsModal({
302271
})
303272
);
304273
}
305-
// if (active.id !== over.id) {
306-
// setItems((items) => {
307-
// const oldIndex = items.indexOf(active.id);
308-
// const newIndex = items.indexOf(over.id);
309-
310-
// });
311-
// }
312274
}
313275
return (
314276
<Dialog
@@ -317,7 +279,7 @@ export default function SettingsModal({
317279
maxWidth="xl"
318280
onClose={handleClose}
319281
onClick={(e) => e.stopPropagation()}
320-
style={{zIndex: 3000}}
282+
style={{ zIndex: 400000 }}
321283
>
322284
<Stack
323285
spacing={2}
@@ -367,7 +329,7 @@ export default function SettingsModal({
367329
strategy={verticalListSortingStrategy}
368330
>
369331
{treeDataOrdered.map((id) => (
370-
<Node key={id.name} data={id}/>
332+
<Node key={id.name} data={id} />
371333
))}
372334
</SortableContext>
373335
</DndContext>

0 commit comments

Comments
 (0)