Skip to content

Commit 5031365

Browse files
committed
chore: fix merge conflicts merging in master
2 parents d4d6dbc + 490b0c1 commit 5031365

File tree

2 files changed

+48
-4
lines changed

2 files changed

+48
-4
lines changed

.github/workflows/deploy-to-staging.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ jobs:
7070
7171
# Wait for PostgreSQL to be ready
7272
until docker compose exec store-pgsql pg_isready; do sleep 5; done
73-
74-
docker compose exec neurostore flask db migrate
7573
docker compose exec neurostore flask db upgrade
7674
'
7775
@@ -86,8 +84,6 @@ jobs:
8684
8785
# Wait for PostgreSQL to be ready
8886
until docker compose exec compose_pgsql pg_isready; do sleep 5; done
89-
90-
docker compose exec compose flask db migrate
9187
docker compose exec compose flask db upgrade
9288
'
9389

compose/neurosynth-frontend/src/pages/Annotations/components/EditAnnotationsHotTable.tsx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,52 @@ const AnnotationsHotTable: React.FC<{ annotationId?: string }> = React.memo((pro
139139
}
140140
};
141141

142+
const reorderArray = <T,>(arr: T[], from: number, to: number) => {
143+
if (from === to) return [...arr];
144+
const updated = [...arr];
145+
const [removed] = updated.splice(from, 1);
146+
updated.splice(to, 0, removed);
147+
return updated;
148+
};
149+
150+
const handleColumnMove = (movedColumns: number[], finalIndex: number) => {
151+
if (!canEdit) return;
152+
if (!movedColumns.length) return;
153+
const fromVisualIndex = movedColumns[0];
154+
const toVisualIndex = finalIndex;
155+
156+
if (fromVisualIndex < 2 || toVisualIndex < 2) return; // lock study/analysis columns
157+
158+
const from = fromVisualIndex - 2;
159+
let to = toVisualIndex - 2;
160+
161+
setAnnotationsHotState((prev) => {
162+
if (from >= prev.noteKeys.length) return prev;
163+
if (to >= prev.noteKeys.length) to = prev.noteKeys.length - 1;
164+
165+
const updatedNoteKeys = reorderArray(prev.noteKeys, from, to).map((noteKey, index) => ({
166+
...noteKey,
167+
order: index,
168+
}));
169+
170+
const updatedHotData = prev.hotData.map((row) => {
171+
const metadataCols = row.slice(0, 2);
172+
const noteCols = reorderArray(row.slice(2), from, to);
173+
return [...metadataCols, ...noteCols];
174+
});
175+
176+
return {
177+
...prev,
178+
isEdited: true,
179+
noteKeys: updatedNoteKeys,
180+
hotColumns: createColumns(updatedNoteKeys, !canEdit),
181+
hotData: updatedHotData,
182+
};
183+
});
184+
185+
hotTableRef.current?.hotInstance?.getPlugin('manualColumnMove').clearMoves();
186+
};
187+
142188
/**
143189
* NOTE: there is a bug where fixed, mergedCells (such as the cells showing our studies) get messed up when you scroll to the right. I think that this is
144190
* due to virtualization - as we scroll to the right, the original heights of the cells are no longer in the DOM and so the calculated row heights are lost and
@@ -247,12 +293,14 @@ const AnnotationsHotTable: React.FC<{ annotationId?: string }> = React.memo((pro
247293
mergeCells={mergeCells}
248294
disableVisualSelection={!canEdit}
249295
colHeaders={hotColumnHeaders}
296+
manualColumnMove={canEdit}
250297
colWidths={colWidths}
251298
rowHeights={rowHeights}
252299
columns={hotColumns}
253300
data={JSON.parse(JSON.stringify(hotData))}
254301
afterOnCellMouseUp={handleCellMouseUp}
255302
beforeOnCellMouseDown={handleCellMouseDown}
303+
afterColumnMove={handleColumnMove}
256304
/>
257305
) : (
258306
<Typography sx={{ color: 'warning.dark' }}>

0 commit comments

Comments
 (0)