TableNativePlugin
Reviewed By: passy Differential Revision: D17258701 fbshipit-source-id: 0d622e63cc028969c9c6d51c5aa2cc8977aac151
This commit is contained in:
committed by
Facebook Github Bot
parent
c8c027150a
commit
b71ae59545
@@ -140,7 +140,8 @@ function buildRow(
|
|||||||
}
|
}
|
||||||
const oldColumns =
|
const oldColumns =
|
||||||
previousRowData && previousRowData.columns
|
previousRowData && previousRowData.columns
|
||||||
? Object.keys(previousRowData.columns).reduce((map, key) => {
|
? Object.keys(previousRowData.columns).reduce(
|
||||||
|
(map: {[key: string]: {value: any; isFilterable: boolean}}, key) => {
|
||||||
if (key !== 'id') {
|
if (key !== 'id') {
|
||||||
let value = null;
|
let value = null;
|
||||||
if (previousRowData && previousRowData.columns) {
|
if (previousRowData && previousRowData.columns) {
|
||||||
@@ -153,7 +154,9 @@ function buildRow(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}, {})
|
},
|
||||||
|
{},
|
||||||
|
)
|
||||||
: {};
|
: {};
|
||||||
const columns = Object.keys(rowData.columns).reduce((map, key) => {
|
const columns = Object.keys(rowData.columns).reduce((map, key) => {
|
||||||
if (rowData.columns && key !== 'id') {
|
if (rowData.columns && key !== 'id') {
|
||||||
@@ -186,10 +189,13 @@ function renderToolbar(section: ToolbarSection) {
|
|||||||
return [
|
return [
|
||||||
<Label>{item.label}</Label>,
|
<Label>{item.label}</Label>,
|
||||||
<Select
|
<Select
|
||||||
options={item.options.reduce((obj, item) => {
|
options={item.options.reduce(
|
||||||
|
(obj: {[key: string]: string}, item) => {
|
||||||
obj[item] = item;
|
obj[item] = item;
|
||||||
return obj;
|
return obj;
|
||||||
}, {})}
|
},
|
||||||
|
{},
|
||||||
|
)}
|
||||||
selected={item.value}
|
selected={item.value}
|
||||||
onChange={() => {}}
|
onChange={() => {}}
|
||||||
/>,
|
/>,
|
||||||
@@ -259,7 +265,7 @@ export default function createTableNativePlugin(id: string, title: string) {
|
|||||||
): Partial<PersistedState> => {
|
): Partial<PersistedState> => {
|
||||||
if (message.method === 'updateRows') {
|
if (message.method === 'updateRows') {
|
||||||
const newRows = [];
|
const newRows = [];
|
||||||
const newData = {};
|
const newData: {[key: string]: NumberedRowData} = {};
|
||||||
|
|
||||||
for (const rowData of message.data.reverse()) {
|
for (const rowData of message.data.reverse()) {
|
||||||
if (rowData.id == null) {
|
if (rowData.id == null) {
|
||||||
@@ -312,14 +318,14 @@ export default function createTableNativePlugin(id: string, title: string) {
|
|||||||
method === 'updateRows'
|
method === 'updateRows'
|
||||||
? {
|
? {
|
||||||
method,
|
method,
|
||||||
data,
|
data: data || [],
|
||||||
}
|
}
|
||||||
: {method};
|
: {method};
|
||||||
return this.typedPersistedStateReducer(persistedState, message);
|
return this.typedPersistedStateReducer(persistedState, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
selectedIds: [],
|
selectedIds: [] as Array<ID>,
|
||||||
error: null,
|
error: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -366,7 +372,7 @@ export default function createTableNativePlugin(id: string, title: string) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let paste = '';
|
let paste = '';
|
||||||
const mapFn = row =>
|
const mapFn = (row: TableBodyRow) =>
|
||||||
(
|
(
|
||||||
(this.props.persistedState.tableMetadata &&
|
(this.props.persistedState.tableMetadata &&
|
||||||
Object.keys(this.props.persistedState.tableMetadata.columns)) ||
|
Object.keys(this.props.persistedState.tableMetadata.columns)) ||
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export const ErrorBlockContainer = styled(CodeBlock)({
|
|||||||
*/
|
*/
|
||||||
export default class ErrorBlock extends React.Component<{
|
export default class ErrorBlock extends React.Component<{
|
||||||
/** Error message to display. Error object's `stack` or `message` property is used. */
|
/** Error message to display. Error object's `stack` or `message` property is used. */
|
||||||
error: Error | string | void;
|
error: Error | string | null;
|
||||||
/** Additional className added to the container. */
|
/** Additional className added to the container. */
|
||||||
className?: string;
|
className?: string;
|
||||||
}> {
|
}> {
|
||||||
|
|||||||
Reference in New Issue
Block a user