From 53b8d249a4aeb14acb84e19931ced425c2e699b3 Mon Sep 17 00:00:00 2001 From: Amit Amrutiya Date: Mon, 16 Dec 2024 13:48:37 +0530 Subject: [PATCH] fix: wrong sort direction Signed-off-by: Amit Amrutiya --- .../CatalogDesignTable/CatalogDesignTable.tsx | 4 +++- .../DesignTableColumnConfig.tsx | 2 +- .../TeamTable/TeamTableConfiguration.tsx | 18 +++++++++++++----- src/custom/UsersTable/UsersTable.tsx | 6 +++--- src/custom/Workspaces/DesignTable.tsx | 2 +- src/custom/Workspaces/EnvironmentTable.tsx | 6 +++--- src/custom/Workspaces/WorkspaceTeamsTable.tsx | 2 +- 7 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/custom/CatalogDesignTable/CatalogDesignTable.tsx b/src/custom/CatalogDesignTable/CatalogDesignTable.tsx index 89e1e223..552420b8 100644 --- a/src/custom/CatalogDesignTable/CatalogDesignTable.tsx +++ b/src/custom/CatalogDesignTable/CatalogDesignTable.tsx @@ -25,6 +25,7 @@ interface CatalogDesignsTableProps { setPage: (page: number) => void; columnVisibility: Record; colViews: ColView[]; + rowsPerPageOptions?: number[]; handleBulkDeleteModal: (patterns: Pattern[], modalRef: React.RefObject) => void; setSearch?: (search: string) => void; handleBulkpatternsDataUnpublishModal: ( @@ -49,6 +50,7 @@ export const CatalogDesignsTable: React.FC = ({ colViews = [], handleBulkDeleteModal, setSearch, + rowsPerPageOptions = [10, 25, 50, 100], handleBulkpatternsDataUnpublishModal }) => { const theme = useTheme(); @@ -195,7 +197,7 @@ export const CatalogDesignsTable: React.FC = ({ // eslint-disable-next-line @typescript-eslint/ban-ts-comment //@ts-ignore data={patterns || []} - rowsPerPageOptions={[15, 30, 45, 60, 75]} + rowsPerPageOptions={rowsPerPageOptions} options={options} colViews={colViews} tableCols={processedColumns} diff --git a/src/custom/CatalogDesignTable/DesignTableColumnConfig.tsx b/src/custom/CatalogDesignTable/DesignTableColumnConfig.tsx index 06c092e9..ad884cee 100644 --- a/src/custom/CatalogDesignTable/DesignTableColumnConfig.tsx +++ b/src/custom/CatalogDesignTable/DesignTableColumnConfig.tsx @@ -72,7 +72,7 @@ export const createDesignsColumnsConfig = ({ }, { name: 'name', - label: 'Pattern Name', + label: 'Name', options: { filter: false, sort: true, diff --git a/src/custom/TeamTable/TeamTableConfiguration.tsx b/src/custom/TeamTable/TeamTableConfiguration.tsx index 8ebd6321..80d584a9 100644 --- a/src/custom/TeamTable/TeamTableConfiguration.tsx +++ b/src/custom/TeamTable/TeamTableConfiguration.tsx @@ -111,7 +111,8 @@ export default function TeamTableConfiguration({ ['name', 'xs'], ['description', 'm'], ['owner', 'l'], - ['created_at', 'xl'], + ['created_at', 'na'], + ['updated_at', 'xl'], ['deleted_at', 'na'], ['actions', 'xs'] ]; @@ -165,6 +166,16 @@ export default function TeamTableConfiguration({ sortDescFirst: true } }, + { + name: 'updated_at', + label: 'Updated At', + options: { + filter: false, + sort: true, + searchable: false, + sortDescFirst: true + } + }, { name: 'deleted_at', label: 'Deleted At', @@ -290,10 +301,7 @@ export default function TeamTableConfiguration({ backgroundColor: '#f3f1f1' } }, - sortOrder: { - name: 'created_at', - direction: 'desc' - }, + viewColumns: false, search: false, rowsExpanded: [ExpandedRowIdx], diff --git a/src/custom/UsersTable/UsersTable.tsx b/src/custom/UsersTable/UsersTable.tsx index 16d991b8..ba389b1c 100644 --- a/src/custom/UsersTable/UsersTable.tsx +++ b/src/custom/UsersTable/UsersTable.tsx @@ -70,7 +70,7 @@ const UsersTable: React.FC = ({ }) => { const [page, setPage] = useState(0); const [pageSize, setPageSize] = useState(10); - const [sortOrder, setSortOrder] = useState(''); + const [sortOrder, setSortOrder] = useState('last_login_time desc'); const [search, setSearch] = useState(''); const availableRoles: string[] = []; const { handleError, handleSuccess, handleInfo } = useNotificationHandlers(); @@ -176,8 +176,8 @@ const UsersTable: React.FC = ({ elevation: 0, serverSide: true, sortOrder: { - name: 'last_login_time', - direction: 'desc' + name: sortOrder.split(' ')[0], + direction: sortOrder.split(' ')[1] }, onTableChange: (action: string, tableState: any) => { const sortInfo = tableState.announceText ? tableState.announceText.split(' : ') : []; diff --git a/src/custom/Workspaces/DesignTable.tsx b/src/custom/Workspaces/DesignTable.tsx index d0d1f3e2..594f3e0d 100644 --- a/src/custom/Workspaces/DesignTable.tsx +++ b/src/custom/Workspaces/DesignTable.tsx @@ -104,7 +104,7 @@ const DesignTable: React.FC = ({ const modalRef = useRef(null); const [page, setPage] = useState(0); const [pageSize, setPageSize] = useState(10); - const [sortOrder, setSortOrder] = useState(''); + const [sortOrder, setSortOrder] = useState('updated_at desc'); const [isSearchExpanded, setIsSearchExpanded] = useState(false); const handlePublishModal = (pattern: Pattern): void => { diff --git a/src/custom/Workspaces/EnvironmentTable.tsx b/src/custom/Workspaces/EnvironmentTable.tsx index 127a1339..79aa6739 100644 --- a/src/custom/Workspaces/EnvironmentTable.tsx +++ b/src/custom/Workspaces/EnvironmentTable.tsx @@ -70,7 +70,7 @@ const EnvironmentTable: React.FC = ({ const [isSearchExpanded, setIsSearchExpanded] = useState(false); const [page, setPage] = useState(0); const [pageSize, setPageSize] = useState(10); - const [sortOrder, setSortOrder] = useState(''); + const [sortOrder, setSortOrder] = useState('updated_at desc'); const { data: environmentsOfWorkspace } = useGetEnvironmentsOfWorkspaceQuery({ workspaceId, page: page, @@ -197,8 +197,8 @@ const EnvironmentTable: React.FC = ({ page, elevation: 0, sortOrder: { - name: 'updated_at', - direction: 'desc' + name: sortOrder.split(' ')[0], + direction: sortOrder.split(' ')[1] }, serverSide: true, onTableChange: (action: string, tableState: any) => { diff --git a/src/custom/Workspaces/WorkspaceTeamsTable.tsx b/src/custom/Workspaces/WorkspaceTeamsTable.tsx index 74173c8c..5dca1304 100644 --- a/src/custom/Workspaces/WorkspaceTeamsTable.tsx +++ b/src/custom/Workspaces/WorkspaceTeamsTable.tsx @@ -49,7 +49,7 @@ const TeamsTable: React.FC = ({ }) => { const [page, setPage] = useState(0); const [pageSize, setPageSize] = useState(10); - const [sortOrder, setSortOrder] = useState(''); + const [sortOrder, setSortOrder] = useState('updated_at desc'); const [bulkSelect, setBulkSelect] = useState(false); const [expanded, setExpanded] = useState(true); const handleAccordionChange = () => {