From 776e6a7ebc96629a228dc20ab4ccaed8039dc136 Mon Sep 17 00:00:00 2001 From: Deniz Kusefoglu Date: Tue, 15 Jan 2019 22:17:00 -0800 Subject: [PATCH] Prevent in place editing of tables that broke table selection --- .../shared/components/tables/TableGraphs.tsx | 24 ++++++------------- .../components/tables/TableSidebarItem.tsx | 2 +- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/ui/src/shared/components/tables/TableGraphs.tsx b/ui/src/shared/components/tables/TableGraphs.tsx index 73c0202bf6..929c630bc0 100644 --- a/ui/src/shared/components/tables/TableGraphs.tsx +++ b/ui/src/shared/components/tables/TableGraphs.tsx @@ -14,10 +14,7 @@ import {setFieldOptions as setFieldOptionsAction} from 'src/shared/actions/v2/ti // Utils import {getDeep} from 'src/utils/wrappers' -import { - excludeNoisyColumns, - findTableNameHeaders, -} from 'src/dashboards/utils/tableGraph' +import {findTableNameHeaders} from 'src/dashboards/utils/tableGraph' // Types import {TableView, FieldOption} from 'src/types/v2/dashboards' @@ -41,7 +38,7 @@ interface State { @ErrorHandling class TableGraphs extends PureComponent { public state = { - selectedTableName: this.defaultTableName, + selectedTableName: getDeep(this, 'props.tables[0].name', null), } public componentDidMount() { @@ -71,13 +68,13 @@ class TableGraphs extends PureComponent { {this.showSidebar && ( )} {this.shouldShowTable && ( @@ -89,11 +86,11 @@ class TableGraphs extends PureComponent { ) } - private get selectedTableName(): string { + private get nameOfSelectedTable(): string { const {tables} = this.props const isNameInTables = tables.find( - t => (t.name = this.state.selectedTableName) + t => t.name === this.state.selectedTableName ) if (!isNameInTables) { @@ -127,14 +124,7 @@ class TableGraphs extends PureComponent { private get selectedTable(): FluxTable { const {tables} = this.props - const {selectedTableName} = this - const selectedTable = tables.find(t => t.name === selectedTableName) - const data = excludeNoisyColumns(selectedTable.data) - - return { - ...selectedTable, - data, - } + return tables.find(t => t.name === this.nameOfSelectedTable) } private updateFieldOptions() { diff --git a/ui/src/shared/components/tables/TableSidebarItem.tsx b/ui/src/shared/components/tables/TableSidebarItem.tsx index f770bdf819..2766e12faa 100644 --- a/ui/src/shared/components/tables/TableSidebarItem.tsx +++ b/ui/src/shared/components/tables/TableSidebarItem.tsx @@ -11,7 +11,7 @@ interface Props { id: string isSelected: boolean groupKey: GroupKey - onSelect: (id: string) => void + onSelect: (name: string) => void } @ErrorHandling