From eef9a7c1a21c8193ecff6668d2628181b5a4f67e Mon Sep 17 00:00:00 2001 From: Laurent Nguyen Date: Wed, 27 Mar 2024 11:56:16 +0100 Subject: [PATCH] Add refresh button --- .../Tabs/DocumentsTabV2/DocumentsTabV2.tsx | 15 +++--- .../DocumentsTableComponent.tsx | 46 +++++++++++-------- 2 files changed, 36 insertions(+), 25 deletions(-) diff --git a/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabV2.tsx b/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabV2.tsx index 4a50a3083..5e8004417 100644 --- a/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabV2.tsx +++ b/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabV2.tsx @@ -1167,13 +1167,13 @@ const DocumentsTabComponent: React.FunctionComponent<{ value={filterContent} onChange={(e) => setFilterContent(e.target.value)} /* - data-bind=" - W attr:{ - placeholder:isPreferredApiMongoDB?'Type a query predicate (e.g., {´a´:´foo´}), or choose one from the drop down list, or leave empty to query all documents.':'Type a query predicate (e.g., WHERE c.id=´1´), or choose one from the drop down list, or leave empty to query all documents.' - }, - css: { placeholderVisible: filterContent().length === 0 }, - textInput: filterContent" - */ + data-bind=" + W attr:{ + placeholder:isPreferredApiMongoDB?'Type a query predicate (e.g., {´a´:´foo´}), or choose one from the drop down list, or leave empty to query all documents.':'Type a query predicate (e.g., WHERE c.id=´1´), or choose one from the drop down list, or leave empty to query all documents.' + }, + css: { placeholderVisible: filterContent().length === 0 }, + textInput: filterContent" + */ /> @@ -1243,6 +1243,7 @@ const DocumentsTabComponent: React.FunctionComponent<{ onSelectedItemsChange={onDocumentsSelectionChange} size={tableContainerSizePx} columnHeaders={columnHeaders} + onRefreshClicked={refreshDocumentsGrid} /> loadNextPage(false)}> Load more diff --git a/src/Explorer/Tabs/DocumentsTabV2/DocumentsTableComponent.tsx b/src/Explorer/Tabs/DocumentsTabV2/DocumentsTableComponent.tsx index 169da42ef..19db00d65 100644 --- a/src/Explorer/Tabs/DocumentsTabV2/DocumentsTableComponent.tsx +++ b/src/Explorer/Tabs/DocumentsTabV2/DocumentsTableComponent.tsx @@ -1,4 +1,5 @@ import { + Button, Menu, MenuItem, MenuList, @@ -24,6 +25,7 @@ import { useTableFeatures, useTableSelection, } from "@fluentui/react-components"; +import { ArrowClockwise16Filled } from "@fluentui/react-icons"; import React, { useEffect, useMemo } from "react"; import { FixedSizeList as List, ListChildComponentProps } from "react-window"; @@ -41,6 +43,7 @@ export interface IDocumentsTableComponentProps { onSelectedItemsChange: (selectedItemsIndices: Set) => void; size: { height: number; width: number }; columnHeaders: ColumnHeaders; + onRefreshClicked: () => void; style?: React.CSSProperties; } @@ -61,6 +64,7 @@ export const DocumentsTableComponent: React.FC = style, size, columnHeaders, + onRefreshClicked, }: IDocumentsTableComponentProps) => { const { targetDocument } = useFluent(); const scrollbarWidth = useScrollbarWidth({ targetDocument }); @@ -107,33 +111,39 @@ export const DocumentsTableComponent: React.FC = [ createTableColumn({ columnId: "id", - compare: (a, b) => { - return a.id.localeCompare(b.id); - }, - renderHeaderCell: () => { - return "id"; - }, - renderCell: (item) => { - return {item.id}; - }, + compare: (a, b) => a.id.localeCompare(b.id), + renderHeaderCell: () => "id", + renderCell: (item) => {item.id}, }), ].concat( - columnHeaders.partitionKeyHeaders.map((pkHeader) => + columnHeaders.partitionKeyHeaders.map((pkHeader, index) => createTableColumn({ columnId: pkHeader, - compare: (a, b) => { - return a[pkHeader].localeCompare(b[pkHeader]); - }, - renderHeaderCell: () => { - return `/${pkHeader}`; - }, + compare: (a, b) => a[pkHeader].localeCompare(b[pkHeader]), + // Show Refresh button on last column + renderHeaderCell: () => + index >= columnHeaders.partitionKeyHeaders.length - 1 ? ( + <> + {`/${pkHeader}`} +