pierrejeambrun commented on code in PR #60995:
URL: https://github.com/apache/airflow/pull/60995#discussion_r2732007939
##########
airflow-core/src/airflow/ui/src/pages/Connections/Connections.tsx:
##########
@@ -58,78 +59,91 @@ export type ConnectionBody = {
const getColumns = ({
allRowsSelected,
+ multiTeam,
onRowSelect,
onSelectAll,
selectedRows,
translate,
-}: { translate: TFunction } & GetColumnsParams):
Array<ColumnDef<ConnectionResponse>> => [
- {
- accessorKey: "select",
- cell: ({ row }) => (
- <Checkbox
- borderWidth={1}
- checked={selectedRows.get(row.original.connection_id)}
- colorPalette="brand"
- onCheckedChange={(event) => onRowSelect(row.original.connection_id,
Boolean(event.checked))}
- />
- ),
- enableHiding: false,
- enableSorting: false,
- header: () => (
- <Checkbox
- borderWidth={1}
- checked={allRowsSelected}
- colorPalette="brand"
- onCheckedChange={(event) => onSelectAll(Boolean(event.checked))}
- />
- ),
- meta: {
- skeletonWidth: 10,
+}: { translate: TFunction } & GetColumnsParams):
Array<ColumnDef<ConnectionResponse>> => {
+ const columns: Array<ColumnDef<ConnectionResponse>> = [
+ {
+ accessorKey: "select",
+ cell: ({ row }) => (
+ <Checkbox
+ borderWidth={1}
+ checked={selectedRows.get(row.original.connection_id)}
+ colorPalette="brand"
+ onCheckedChange={(event) => onRowSelect(row.original.connection_id,
Boolean(event.checked))}
+ />
+ ),
+ enableHiding: false,
+ enableSorting: false,
+ header: () => (
+ <Checkbox
+ borderWidth={1}
+ checked={allRowsSelected}
+ colorPalette="brand"
+ onCheckedChange={(event) => onSelectAll(Boolean(event.checked))}
+ />
+ ),
+ meta: {
+ skeletonWidth: 10,
+ },
+ },
+ {
+ accessorKey: "connection_id",
+ header: translate("connections.columns.connectionId"),
+ },
+ {
+ accessorKey: "conn_type",
+ header: translate("connections.columns.connectionType"),
+ },
+ {
+ accessorKey: "description",
+ header: translate("columns.description"),
+ },
+ {
+ accessorKey: "host",
+ header: translate("connections.columns.host"),
},
- },
- {
- accessorKey: "connection_id",
- header: translate("connections.columns.connectionId"),
- },
- {
- accessorKey: "conn_type",
- header: translate("connections.columns.connectionType"),
- },
- {
- accessorKey: "description",
- header: translate("columns.description"),
- },
- {
- accessorKey: "host",
- header: translate("connections.columns.host"),
- },
- {
- accessorKey: "port",
- header: translate("connections.columns.port"),
- },
- {
- accessorKey: "actions",
- cell: ({ row: { original } }) => (
- <Flex justifyContent="end">
- <TestConnectionButton connection={original} />
- <EditConnectionButton connection={original}
disabled={selectedRows.size > 0} />
- <DeleteConnectionButton connectionId={original.connection_id}
disabled={selectedRows.size > 0} />
- </Flex>
- ),
- enableSorting: false,
- header: "",
- meta: {
- skeletonWidth: 10,
+ {
+ accessorKey: "port",
+ header: translate("connections.columns.port"),
},
- },
-];
+ {
+ accessorKey: "actions",
+ cell: ({ row: { original } }) => (
+ <Flex justifyContent="end">
+ <TestConnectionButton connection={original} />
+ <EditConnectionButton connection={original}
disabled={selectedRows.size > 0} />
+ <DeleteConnectionButton connectionId={original.connection_id}
disabled={selectedRows.size > 0} />
+ </Flex>
+ ),
+ enableSorting: false,
+ header: "",
+ meta: {
+ skeletonWidth: 10,
+ },
+ },
+ ];
+
+ if (multiTeam) {
+ columns.splice(6, 0, {
+ accessorKey: "team_name",
+ header: translate("columns.team"),
+ });
+ }
Review Comment:
Thanks for the PR.
We tend to never mutate objects because react diffing algorithm will compare
references and not render the update if the object was mutated in place.
This is why you see a lot of:
```
const newArray = [...oldArray, ,newItem]
```
Here we are outside of a react component so it should be fine. (a new
columns object is created on every render anyway)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]