Skip to content

Commit

Permalink
chore(weave): sort datasets while editing
Browse files Browse the repository at this point in the history
  • Loading branch information
bcsherma committed Feb 4, 2025
1 parent 3ee5fbd commit 546735e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,6 @@ export const EditableDatasetView: FC<EditableDataTableViewProps> = ({
pageSize: 50,
});

// Reset sort model and pagination if we enter edit mode with sorting applied.
useEffect(() => {
if (isEditing && sortModel.length > 0) {
setPaginationModel({page: 0, pageSize: 50});
setSortModel([]);
setSortBy([]);
}
}, [isEditing, sortModel]);

const sharedRef = useContext(WeaveCHTableSourceRefContext);

const history = useHistory();
Expand Down Expand Up @@ -269,16 +260,16 @@ export const EditableDatasetView: FC<EditableDataTableViewProps> = ({

const rows = useMemo(() => {
if (fetchQueryLoaded) {
return loadedRows.map((row, i) => {
return loadedRows.map(row => {
const digest = row.digest;
const absoluteIndex =
i + paginationModel.pageSize * paginationModel.page;
const value = flattenObjectPreservingWeaveTypes(row.val);
const editedRow = editedRows.get(absoluteIndex);
return {
___weave: {
id: `${digest}_${absoluteIndex}`,
index: absoluteIndex,
id: `${digest}_${row.original_index}`,
index: row.original_index,
isNew: false,
serverValue: value,
},
Expand Down Expand Up @@ -404,7 +395,7 @@ export const EditableDatasetView: FC<EditableDataTableViewProps> = ({
flex: columnWidths[field as string] ? undefined : 1,
minWidth: 100,
editable: isEditing,
sortable: !isEditing,
sortable: true,
filterable: false,
renderCell: (params: GridRenderCellParams) => {
if (!isEditing) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ export type TraceTableQueryRes = {
rows: Array<{
digest: string;
val: any;
original_index?: number;
}>;
};

Expand Down

0 comments on commit 546735e

Please sign in to comment.