From ab36f99b5c0ff2002bb5d4f70a757293af656509 Mon Sep 17 00:00:00 2001 From: Austin Turner Date: Sun, 26 Nov 2023 10:37:36 -0700 Subject: [PATCH] Upgrade React Data Grid Moved grouped tables to DataTree component Moved data table logic into a hook to be used by both components Deprecated column dragging using react-dnd in favor of native drag support --- .../app/components/core/ViewChildRecords.tsx | 4 +- .../debug-log-viewer/DebugLogViewerTable.tsx | 9 +- .../deploy/DeployMetadataDeploymentTable.tsx | 4 +- .../DeployMetadataHistoryTable.tsx | 7 +- .../ManagePermissionsEditorFieldTable.tsx | 4 +- .../PlatformEventMonitorEvents.tsx | 8 +- .../SalesforceApiExamplesModal.tsx | 13 +- libs/ui/src/index.ts | 1 + libs/ui/src/lib/data-table/DataTable.tsx | 397 ++---------------- .../src/lib/data-table/DataTableRenderers.tsx | 45 +- .../data-table/DataTableSubqueryRenderer.tsx | 1 - libs/ui/src/lib/data-table/DataTree.tsx | 112 +++++ .../data-table/SalesforceRecordDataTable.tsx | 1 - .../ui/src/lib/data-table/data-table-types.ts | 12 +- .../src/lib/data-table/data-table-utils.tsx | 1 + libs/ui/src/lib/data-table/useDataTable.tsx | 391 +++++++++++++++++ package.json | 2 +- tsconfig.base.json | 2 +- yarn.lock | 15 +- 19 files changed, 594 insertions(+), 435 deletions(-) create mode 100644 libs/ui/src/lib/data-table/DataTree.tsx create mode 100644 libs/ui/src/lib/data-table/useDataTable.tsx diff --git a/apps/jetstream/src/app/components/core/ViewChildRecords.tsx b/apps/jetstream/src/app/components/core/ViewChildRecords.tsx index 0bcbf960d..6b85c779f 100644 --- a/apps/jetstream/src/app/components/core/ViewChildRecords.tsx +++ b/apps/jetstream/src/app/components/core/ViewChildRecords.tsx @@ -9,7 +9,7 @@ import { Maybe, Record, SalesforceOrgUi } from '@jetstream/types'; import { AutoFullHeightContainer, ColumnWithFilter, - DataTable, + DataTree, Grid, Icon, PopoverErrorButton, @@ -346,7 +346,7 @@ export const ViewChildRecords: FunctionComponent = ({ - [] = [ width: 12, renderCell: LogViewedRenderer, resizable: false, - // TODO: filter for this }, { ...setColumnFromType('LogUser.Name', 'text'), name: 'User', key: 'LogUser.Name', width: 125, + draggable: true, }, { ...setColumnFromType('Application', 'text'), name: 'Application', key: 'Application', width: 125, + draggable: true, }, { ...setColumnFromType('Operation', 'text'), name: 'Operation', key: 'Operation', width: 125, + draggable: true, }, { ...setColumnFromType('Status', 'text'), name: 'Status', key: 'Status', width: 125, + draggable: true, }, { ...setColumnFromType('LogLength', 'text'), name: 'Size', key: 'LogLength', width: 125, + draggable: true, }, { ...setColumnFromType('LastModifiedDate', 'date'), name: 'Time', key: 'LastModifiedDate', width: 202, + draggable: true, }, ]; @@ -96,7 +101,7 @@ export const DebugLogViewerTable: FunctionComponent = return ( - + ); }; diff --git a/apps/jetstream/src/app/components/deploy/DeployMetadataDeploymentTable.tsx b/apps/jetstream/src/app/components/deploy/DeployMetadataDeploymentTable.tsx index 7179cba61..22a3c7df4 100644 --- a/apps/jetstream/src/app/components/deploy/DeployMetadataDeploymentTable.tsx +++ b/apps/jetstream/src/app/components/deploy/DeployMetadataDeploymentTable.tsx @@ -1,5 +1,5 @@ import { formatNumber } from '@jetstream/shared/ui-utils'; -import { AutoFullHeightContainer, ColumnWithFilter, DataTable, DataTableSelectedContext, Grid, Icon, SearchInput } from '@jetstream/ui'; +import { AutoFullHeightContainer, ColumnWithFilter, DataTableSelectedContext, DataTree, Grid, Icon, SearchInput } from '@jetstream/ui'; import groupBy from 'lodash/groupBy'; import { FunctionComponent, useEffect, useState } from 'react'; import { DeployMetadataTableRow } from './deploy-metadata.types'; @@ -60,7 +60,7 @@ export const DeployMetadataDeploymentTable: FunctionComponent )} - [] = [ name: 'Started', key: 'start', width: 200, + draggable: true, }, { ...setColumnFromType('type', 'text'), name: 'Type', key: 'type', width: 165, + draggable: true, renderCell: ({ column, row }) => TYPE_MAP[row[column.key]], }, { ...setColumnFromType('destinationOrg', 'text'), name: 'Deployed To Org', key: 'destinationOrg', + draggable: true, renderCell: OrgRenderer, getValue: ({ row }) => row.destinationOrg?.label, width: 350, @@ -38,6 +41,7 @@ const COLUMNS: ColumnWithFilter[] = [ ...setColumnFromType('status', 'text'), name: 'Status', key: 'status', + draggable: true, renderCell: StatusRenderer, width: 150, }, @@ -47,6 +51,7 @@ const COLUMNS: ColumnWithFilter[] = [ width: 220, sortable: false, resizable: false, + draggable: true, renderCell: ActionRenderer, }, ]; @@ -89,7 +94,7 @@ export const DeployMetadataHistoryTable: FunctionComponent getRowHeight(orgsById), [orgsById]); - return ; + return ; }; export default DeployMetadataHistoryTable; diff --git a/apps/jetstream/src/app/components/manage-permissions/ManagePermissionsEditorFieldTable.tsx b/apps/jetstream/src/app/components/manage-permissions/ManagePermissionsEditorFieldTable.tsx index 108c9bb90..76d408e67 100644 --- a/apps/jetstream/src/app/components/manage-permissions/ManagePermissionsEditorFieldTable.tsx +++ b/apps/jetstream/src/app/components/manage-permissions/ManagePermissionsEditorFieldTable.tsx @@ -1,6 +1,6 @@ import { useNonInitialEffect } from '@jetstream/shared/ui-utils'; import { MapOf } from '@jetstream/types'; -import { AutoFullHeightContainer, ColumnWithFilter, DataTable } from '@jetstream/ui'; +import { AutoFullHeightContainer, ColumnWithFilter, DataTree } from '@jetstream/ui'; import groupBy from 'lodash/groupBy'; import { forwardRef, useCallback, useImperativeHandle, useState } from 'react'; import { RowHeightArgs } from 'react-data-grid'; @@ -69,7 +69,7 @@ export const ManagePermissionsEditorFieldTable = forwardRef - [] = [ // autoHeight: true, renderCell: WrappedTextFormatter, cellClass: 'break-all', + draggable: true, }, { name: 'UUID', key: 'uuid', width: 160, // tooltipField: 'uuid', + draggable: true, }, { name: 'Replay Id', key: 'replayId', width: 120, // tooltipField: 'replayId', + draggable: true, }, ]; @@ -107,8 +110,7 @@ export const PlatformEventMonitorEvents: FunctionComponent - { return (