Skip to content

Commit 6a952ef

Browse files
authored
fix(app-aco): minor ACO table fixes (#3811)
1 parent d044358 commit 6a952ef

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

packages/app-aco/src/components/Table/components/Table/Columns/ColumnsRepository.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@ export class ColumnsRepository implements IColumnsRepository {
1111
}
1212

1313
getColumns(): ColumnDTO[] {
14-
return this.columns;
14+
return this.sortColumns(this.columns);
1515
}
1616

1717
init(): Promise<void> {
1818
return Promise.resolve();
1919
}
20+
21+
private sortColumns(columns: ColumnDTO[]) {
22+
return columns
23+
.slice()
24+
.sort((a, b) => (a.name === "actions" ? 1 : b.name === "actions" ? -1 : 0));
25+
}
2026
}

packages/app-aco/src/components/Table/components/Table/TableInner.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useCallback, useMemo } from "react";
22
import { observer } from "mobx-react-lite";
33
import { Columns, DataTable, DefaultData, OnSortingChange, Sorting } from "@webiny/ui/DataTable";
4-
import { ColumnsPresenter, ColumnMapper } from "./Columns";
4+
import { ColumnMapper, ColumnsPresenter } from "./Columns";
55
import { ColumnsVisibilityPresenter, ColumnsVisibilityUpdater } from "./ColumnVisibility";
66
import { TablePresenter } from "./TablePresenter";
77
import { TableRowProvider } from "~/components";
@@ -36,9 +36,11 @@ export const TableInner = observer(
3636

3737
const columns = useMemo(() => {
3838
return props.columnsPresenter.vm.columns.reduce((result, column) => {
39+
const { nameColumnId = "name" } = props;
3940
const { name: defaultName } = column;
4041

41-
const name = defaultName === "name" ? props.nameColumnId : defaultName;
42+
// Determine the column name, using the provided `nameColumnId` if the default is 'name'
43+
const name = defaultName === "name" ? nameColumnId : defaultName;
4244

4345
result[name as keyof Columns<T>] = ColumnMapper.toDataTable(column, cellRenderer);
4446

0 commit comments

Comments
 (0)