Calculate Editable when Used
Summary: In D21788243, John suggested the field should be calculated when needed not precomputed. This diff does so by moving calculation logic to the component and removing the field This also fixes the crashing bug when switching to Structure tab, changing table, and switching back to Data tab. Reviewed By: mweststrate Differential Revision: D21906983 fbshipit-source-id: 5a9522a5ba3f504108282fb27deae25b5eadc693
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b81724b7b0
commit
a50c373631
@@ -98,7 +98,6 @@ type Page = {
|
|||||||
count: number;
|
count: number;
|
||||||
total: number;
|
total: number;
|
||||||
highlightedRows: Array<number>;
|
highlightedRows: Array<number>;
|
||||||
editable: boolean;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Structure = {
|
export type Structure = {
|
||||||
@@ -500,10 +499,6 @@ export default class DatabasesPlugin extends FlipperPlugin<
|
|||||||
indexesColumns: event.indexesColumns,
|
indexesColumns: event.indexesColumns,
|
||||||
indexesValues: event.indexesValues,
|
indexesValues: event.indexesValues,
|
||||||
},
|
},
|
||||||
currentPage: {
|
|
||||||
...state.currentPage!,
|
|
||||||
editable: isUpdatable(event.columns, event.rows),
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -821,7 +816,6 @@ export default class DatabasesPlugin extends FlipperPlugin<
|
|||||||
count: data.count,
|
count: data.count,
|
||||||
total: data.total,
|
total: data.total,
|
||||||
highlightedRows: [],
|
highlightedRows: [],
|
||||||
editable: false,
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
@@ -1137,7 +1131,15 @@ export default class DatabasesPlugin extends FlipperPlugin<
|
|||||||
<DatabaseDetailSidebar
|
<DatabaseDetailSidebar
|
||||||
columnLabels={page.columns}
|
columnLabels={page.columns}
|
||||||
columnValues={page.rows[page.highlightedRows[0]]}
|
columnValues={page.rows[page.highlightedRows[0]]}
|
||||||
onSave={page.editable ? this.onRowEdited.bind(this) : undefined}
|
onSave={
|
||||||
|
this.state.currentStructure &&
|
||||||
|
isUpdatable(
|
||||||
|
this.state.currentStructure.columns,
|
||||||
|
this.state.currentStructure.rows,
|
||||||
|
)
|
||||||
|
? this.onRowEdited.bind(this)
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</FlexRow>
|
</FlexRow>
|
||||||
|
|||||||
Reference in New Issue
Block a user