Move default actions and extra actions next to the search
Summary: Having default and extra actions at the bottom is not actionable. Users are used to haveing table controls on the top. Reviewed By: LukeDefeo, aigoncharov Differential Revision: D49538205 fbshipit-source-id: 724a31dc44de79cb0e09efae48dd2135450b34ae
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b8950a2298
commit
a37b04737c
@@ -84,7 +84,7 @@ export function MasterDetailWithPowerSearch<T extends object>({
|
|||||||
sidebarPosition,
|
sidebarPosition,
|
||||||
sidebarSize,
|
sidebarSize,
|
||||||
onSelect,
|
onSelect,
|
||||||
extraActions,
|
actionsTop,
|
||||||
enableMenuEntries,
|
enableMenuEntries,
|
||||||
enableClear,
|
enableClear,
|
||||||
isPaused,
|
isPaused,
|
||||||
@@ -206,11 +206,13 @@ export function MasterDetailWithPowerSearch<T extends object>({
|
|||||||
records={records!}
|
records={records!}
|
||||||
tableManagerRef={tableManagerRef}
|
tableManagerRef={tableManagerRef}
|
||||||
onSelect={handleSelect}
|
onSelect={handleSelect}
|
||||||
extraActions={
|
actionsRight={
|
||||||
<>
|
<>
|
||||||
{connected && isPaused && (
|
{connected && isPaused && (
|
||||||
<Button
|
<Button
|
||||||
size="small"
|
size="small"
|
||||||
|
type="text"
|
||||||
|
style={{height: '100%'}}
|
||||||
title={`Click to ${pausedState ? 'resume' : 'pause'} the stream`}
|
title={`Click to ${pausedState ? 'resume' : 'pause'} the stream`}
|
||||||
danger={pausedState}
|
danger={pausedState}
|
||||||
onClick={handleTogglePause}>
|
onClick={handleTogglePause}>
|
||||||
@@ -218,13 +220,18 @@ export function MasterDetailWithPowerSearch<T extends object>({
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{connected && enableClear && (
|
{connected && enableClear && (
|
||||||
<Button size="small" title="Clear records" onClick={handleClear}>
|
<Button
|
||||||
|
size="small"
|
||||||
|
type="text"
|
||||||
|
title="Clear records"
|
||||||
|
onClick={handleClear}
|
||||||
|
style={{height: '100%'}}>
|
||||||
<DeleteOutlined />
|
<DeleteOutlined />
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{extraActions}
|
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
actionsTop={actionsTop}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -85,7 +85,8 @@ type DataTableBaseProps<T = any> = {
|
|||||||
enableMultiPanels?: boolean;
|
enableMultiPanels?: boolean;
|
||||||
// if set (the default) will grow and become scrollable. Otherwise will use natural size
|
// if set (the default) will grow and become scrollable. Otherwise will use natural size
|
||||||
scrollable?: boolean;
|
scrollable?: boolean;
|
||||||
extraActions?: React.ReactElement;
|
actionsRight?: React.ReactElement;
|
||||||
|
actionsTop?: React.ReactElement;
|
||||||
onSelect?(record: T | undefined, records: T[]): void;
|
onSelect?(record: T | undefined, records: T[]): void;
|
||||||
onRowStyle?(record: T): CSSProperties | undefined;
|
onRowStyle?(record: T): CSSProperties | undefined;
|
||||||
tableManagerRef?: RefObject<DataTableManager<T> | undefined>; // Actually we want a MutableRefObject, but that is not what React.createRef() returns, and we don't want to put the burden on the plugin dev to cast it...
|
tableManagerRef?: RefObject<DataTableManager<T> | undefined>; // Actually we want a MutableRefObject, but that is not what React.createRef() returns, and we don't want to put the burden on the plugin dev to cast it...
|
||||||
@@ -631,6 +632,7 @@ export function DataTable<T extends object>(
|
|||||||
|
|
||||||
const header = (
|
const header = (
|
||||||
<Layout.Container>
|
<Layout.Container>
|
||||||
|
{props.actionsTop ? <Searchbar gap>{props.actionsTop}</Searchbar> : null}
|
||||||
{props.enableSearchbar && (
|
{props.enableSearchbar && (
|
||||||
<Searchbar gap>
|
<Searchbar gap>
|
||||||
<PowerSearch
|
<PowerSearch
|
||||||
@@ -647,15 +649,11 @@ export function DataTable<T extends object>(
|
|||||||
</Button>
|
</Button>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
)}
|
)}
|
||||||
|
{props.actionsRight}
|
||||||
</Searchbar>
|
</Searchbar>
|
||||||
)}
|
)}
|
||||||
</Layout.Container>
|
</Layout.Container>
|
||||||
);
|
);
|
||||||
const footer = props.extraActions ? (
|
|
||||||
<Layout.Container>
|
|
||||||
<Searchbar gap>{props.extraActions}</Searchbar>
|
|
||||||
</Layout.Container>
|
|
||||||
) : null;
|
|
||||||
const columnHeaders = (
|
const columnHeaders = (
|
||||||
<Layout.Container>
|
<Layout.Container>
|
||||||
{props.enableColumnHeaders && (
|
{props.enableColumnHeaders && (
|
||||||
@@ -734,7 +732,7 @@ export function DataTable<T extends object>(
|
|||||||
</Layout.Container>
|
</Layout.Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let mainPanel = (
|
const mainPanel = (
|
||||||
<Layout.Container grow={props.scrollable} style={{position: 'relative'}}>
|
<Layout.Container grow={props.scrollable} style={{position: 'relative'}}>
|
||||||
{mainSection}
|
{mainSection}
|
||||||
{props.enableAutoScroll && (
|
{props.enableAutoScroll && (
|
||||||
@@ -752,14 +750,6 @@ export function DataTable<T extends object>(
|
|||||||
{range && !isUnitTest && <RangeFinder>{range}</RangeFinder>}
|
{range && !isUnitTest && <RangeFinder>{range}</RangeFinder>}
|
||||||
</Layout.Container>
|
</Layout.Container>
|
||||||
);
|
);
|
||||||
if (footer) {
|
|
||||||
mainPanel = (
|
|
||||||
<Layout.Bottom>
|
|
||||||
{mainPanel}
|
|
||||||
{footer}
|
|
||||||
</Layout.Bottom>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return props.enableMultiPanels && tableState.sideBySide ? (
|
return props.enableMultiPanels && tableState.sideBySide ? (
|
||||||
//TODO: Make the panels resizable by having a dynamic maxWidth for Layout.Right/Left possibly?
|
//TODO: Make the panels resizable by having a dynamic maxWidth for Layout.Right/Left possibly?
|
||||||
<Layout.Horizontal style={{height: '100%'}}>
|
<Layout.Horizontal style={{height: '100%'}}>
|
||||||
|
|||||||
Reference in New Issue
Block a user