mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-02-17 01:36:57 +00:00
Add refresh button
This commit is contained in:
parent
55ee3854aa
commit
eef9a7c1a2
@ -1243,6 +1243,7 @@ const DocumentsTabComponent: React.FunctionComponent<{
|
|||||||
onSelectedItemsChange={onDocumentsSelectionChange}
|
onSelectedItemsChange={onDocumentsSelectionChange}
|
||||||
size={tableContainerSizePx}
|
size={tableContainerSizePx}
|
||||||
columnHeaders={columnHeaders}
|
columnHeaders={columnHeaders}
|
||||||
|
onRefreshClicked={refreshDocumentsGrid}
|
||||||
/>
|
/>
|
||||||
<a className="loadMore" role="button" onClick={() => loadNextPage(false)}>
|
<a className="loadMore" role="button" onClick={() => loadNextPage(false)}>
|
||||||
Load more
|
Load more
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
|
Button,
|
||||||
Menu,
|
Menu,
|
||||||
MenuItem,
|
MenuItem,
|
||||||
MenuList,
|
MenuList,
|
||||||
@ -24,6 +25,7 @@ import {
|
|||||||
useTableFeatures,
|
useTableFeatures,
|
||||||
useTableSelection,
|
useTableSelection,
|
||||||
} from "@fluentui/react-components";
|
} from "@fluentui/react-components";
|
||||||
|
import { ArrowClockwise16Filled } from "@fluentui/react-icons";
|
||||||
import React, { useEffect, useMemo } from "react";
|
import React, { useEffect, useMemo } from "react";
|
||||||
import { FixedSizeList as List, ListChildComponentProps } from "react-window";
|
import { FixedSizeList as List, ListChildComponentProps } from "react-window";
|
||||||
|
|
||||||
@ -41,6 +43,7 @@ export interface IDocumentsTableComponentProps {
|
|||||||
onSelectedItemsChange: (selectedItemsIndices: Set<number>) => void;
|
onSelectedItemsChange: (selectedItemsIndices: Set<number>) => void;
|
||||||
size: { height: number; width: number };
|
size: { height: number; width: number };
|
||||||
columnHeaders: ColumnHeaders;
|
columnHeaders: ColumnHeaders;
|
||||||
|
onRefreshClicked: () => void;
|
||||||
style?: React.CSSProperties;
|
style?: React.CSSProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,6 +64,7 @@ export const DocumentsTableComponent: React.FC<IDocumentsTableComponentProps> =
|
|||||||
style,
|
style,
|
||||||
size,
|
size,
|
||||||
columnHeaders,
|
columnHeaders,
|
||||||
|
onRefreshClicked,
|
||||||
}: IDocumentsTableComponentProps) => {
|
}: IDocumentsTableComponentProps) => {
|
||||||
const { targetDocument } = useFluent();
|
const { targetDocument } = useFluent();
|
||||||
const scrollbarWidth = useScrollbarWidth({ targetDocument });
|
const scrollbarWidth = useScrollbarWidth({ targetDocument });
|
||||||
@ -107,33 +111,39 @@ export const DocumentsTableComponent: React.FC<IDocumentsTableComponentProps> =
|
|||||||
[
|
[
|
||||||
createTableColumn<DocumentsTableComponentItem>({
|
createTableColumn<DocumentsTableComponentItem>({
|
||||||
columnId: "id",
|
columnId: "id",
|
||||||
compare: (a, b) => {
|
compare: (a, b) => a.id.localeCompare(b.id),
|
||||||
return a.id.localeCompare(b.id);
|
renderHeaderCell: () => "id",
|
||||||
},
|
renderCell: (item) => <TableCellLayout truncate>{item.id}</TableCellLayout>,
|
||||||
renderHeaderCell: () => {
|
|
||||||
return "id";
|
|
||||||
},
|
|
||||||
renderCell: (item) => {
|
|
||||||
return <TableCellLayout truncate>{item.id}</TableCellLayout>;
|
|
||||||
},
|
|
||||||
}),
|
}),
|
||||||
].concat(
|
].concat(
|
||||||
columnHeaders.partitionKeyHeaders.map((pkHeader) =>
|
columnHeaders.partitionKeyHeaders.map((pkHeader, index) =>
|
||||||
createTableColumn<DocumentsTableComponentItem>({
|
createTableColumn<DocumentsTableComponentItem>({
|
||||||
columnId: pkHeader,
|
columnId: pkHeader,
|
||||||
compare: (a, b) => {
|
compare: (a, b) => a[pkHeader].localeCompare(b[pkHeader]),
|
||||||
return a[pkHeader].localeCompare(b[pkHeader]);
|
// Show Refresh button on last column
|
||||||
},
|
renderHeaderCell: () =>
|
||||||
renderHeaderCell: () => {
|
index >= columnHeaders.partitionKeyHeaders.length - 1 ? (
|
||||||
return `/${pkHeader}`;
|
<>
|
||||||
},
|
<span>{`/${pkHeader}`}</span>
|
||||||
|
<Button
|
||||||
|
appearance="transparent"
|
||||||
|
aria-label="Refresh"
|
||||||
|
size="small"
|
||||||
|
icon={<ArrowClockwise16Filled />}
|
||||||
|
style={{ position: "absolute", right: 0 }}
|
||||||
|
onClick={onRefreshClicked}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
`/${pkHeader}`
|
||||||
|
),
|
||||||
renderCell: (item) => {
|
renderCell: (item) => {
|
||||||
return <TableCellLayout truncate>{item[pkHeader]}</TableCellLayout>;
|
return <TableCellLayout truncate>{item[pkHeader]}</TableCellLayout>;
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
[columnHeaders],
|
[columnHeaders.partitionKeyHeaders, onRefreshClicked],
|
||||||
);
|
);
|
||||||
|
|
||||||
const RenderRow = ({ index, style, data }: ReactWindowRenderFnProps) => {
|
const RenderRow = ({ index, style, data }: ReactWindowRenderFnProps) => {
|
||||||
@ -256,7 +266,7 @@ export const DocumentsTableComponent: React.FC<IDocumentsTableComponentProps> =
|
|||||||
</MenuPopover>
|
</MenuPopover>
|
||||||
</Menu>
|
</Menu>
|
||||||
))}
|
))}
|
||||||
{/** Scrollbar alignment for the header */}
|
{/** Scrollbar alignment for the header: TODO: Check if this really works? */}
|
||||||
<div role="presentation" style={{ width: scrollbarWidth }} />
|
<div role="presentation" style={{ width: scrollbarWidth }} />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHeader>
|
</TableHeader>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user