From 21d3d0cde8d1f4db2b314b66cfd81568b9d9f5e3 Mon Sep 17 00:00:00 2001 From: mcbrewster <37322608+mcbrewster@users.noreply.github.com> Date: Sat, 1 Jun 2019 02:08:34 -0700 Subject: [PATCH] Web-console: prevent unnecessary loading of disabled data sources (#7804) * prevent loading disabled datasources * prevent double loading * remove complexity * rename function * remove space --- .../views/datasource-view/datasource-view.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/web-console/src/views/datasource-view/datasource-view.tsx b/web-console/src/views/datasource-view/datasource-view.tsx index 35d46f95a3f..964b4e1d922 100644 --- a/web-console/src/views/datasource-view/datasource-view.tsx +++ b/web-console/src/views/datasource-view/datasource-view.tsx @@ -151,8 +151,11 @@ export class DatasourcesView extends React.Component x.datasource); - const disabledResp = await axios.get('/druid/coordinator/v1/metadata/datasources?includeDisabled'); - const disabled: string[] = disabledResp.data.filter((d: string) => !seen[d]); + let disabled: string [] = []; + if (this.state.showDisabled) { + const disabledResp = await axios.get('/druid/coordinator/v1/metadata/datasources?includeDisabled' ); + disabled = disabledResp.data.filter((d: string) => !seen[d]); + } const rulesResp = await axios.get('/druid/coordinator/v1/rules'); const rules = rulesResp.data; @@ -395,6 +398,13 @@ GROUP BY 1`); }); } + private toggleDisabled(showDisabled: boolean) { + if (!showDisabled) { + this.datasourceQueryManager.rerunLastQuery(); + } + this.setState({showDisabled: !showDisabled}); + } + getDatasourceActions(datasource: string, disabled: boolean): BasicAction[] { const { goToSql } = this.props; @@ -657,7 +667,7 @@ GROUP BY 1`); this.setState({ showDisabled: !showDisabled })} + onChange={() => this.toggleDisabled(showDisabled)} />