From 403e97c460e8811151185b6706704fa8a8d32582 Mon Sep 17 00:00:00 2001 From: Deniz Kusefoglu Date: Thu, 18 Jul 2019 10:19:08 -0700 Subject: [PATCH] Consume types from client 1.5 (#14372) * Bump js client version * Fix types after client version --- ui/package.json | 2 +- ui/src/shared/utils/filterUnusedVars.ts | 22 +++++++++++----------- ui/src/types/dashboards.ts | 9 ++++++--- ui/yarn.lock | 8 ++++---- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/ui/package.json b/ui/package.json index 684a6c964e..39217a8825 100644 --- a/ui/package.json +++ b/ui/package.json @@ -141,7 +141,7 @@ "dependencies": { "@influxdata/clockface": "0.0.13", "@influxdata/giraffe": "0.16.0", - "@influxdata/influx": "0.4.0", + "@influxdata/influx": "0.5.0", "@influxdata/influxdb-templates": "0.2.0", "@influxdata/react-custom-scrollbars": "4.3.8", "axios": "^0.19.0", diff --git a/ui/src/shared/utils/filterUnusedVars.ts b/ui/src/shared/utils/filterUnusedVars.ts index 2a0bdc9501..8d76f61538 100644 --- a/ui/src/shared/utils/filterUnusedVars.ts +++ b/ui/src/shared/utils/filterUnusedVars.ts @@ -2,24 +2,24 @@ import {isInQuery} from 'src/variables/utils/hydrateVars' // Types -import {QueryView} from 'src/types/dashboards' -import {IVariable as Variable, View} from '@influxdata/influx' +import {QueryViewProperties, View, ViewProperties} from 'src/types' +import {IVariable as Variable} from '@influxdata/influx' + +function isQueryViewProperties(vp: ViewProperties): vp is QueryViewProperties { + return (vp as QueryViewProperties).queries !== undefined +} /* Given a collection variables and a collection of views, return only the variables that are used in at least one of the view queries. */ export const filterUnusedVars = (variables: Variable[], views: View[]) => { - const queryViews: QueryView[] = views.filter( - view => !!view.properties.queries - ) + const viewProperties = views.map(v => v.properties) + const queryViewProperties = viewProperties.filter(isQueryViewProperties) - const queryTexts = queryViews.reduce( - (acc, view) => [ - ...acc, - ...view.properties.queries.map(query => query.text), - ], - [] + const queryTexts = queryViewProperties.reduce( + (acc, vp) => [...acc, ...vp.queries.map(query => query.text)], + [] as Array ) const varsInUse = variables.filter(variable => diff --git a/ui/src/types/dashboards.ts b/ui/src/types/dashboards.ts index 24f18f3d64..0f76aa5f54 100644 --- a/ui/src/types/dashboards.ts +++ b/ui/src/types/dashboards.ts @@ -3,8 +3,8 @@ import {Color} from 'src/types/colors' import { IDashboard as DashboardAPI, - View as ViewAPI, Cell as CellAPI, + ViewLinks, } from '@influxdata/influx' export enum Scale { @@ -94,8 +94,10 @@ export interface MarkDownProperties { text: string } -export interface View - extends ViewAPI { +export interface View { + links?: ViewLinks + id?: string + name?: string properties?: T dashboardID?: string cellID?: string @@ -135,6 +137,7 @@ export type QueryViewProperties = Extract< > export type WorkingView = View | NewView + export type QueryView = WorkingView /** diff --git a/ui/yarn.lock b/ui/yarn.lock index 1af41d25e0..2e3e4749b0 100644 --- a/ui/yarn.lock +++ b/ui/yarn.lock @@ -753,10 +753,10 @@ resolved "https://registry.yarnpkg.com/@influxdata/giraffe/-/giraffe-0.16.0.tgz#b04a304460a7c9449fe1a9fa2a3f5db97949e916" integrity sha512-nDVQgx5Lq3fjsMXTzYwzf0HXKjSxzsBJibitObwtE0wefpzU4LW0IEUrcCBNIQyXj1OxyBNL9a67gZ4DyV7M2w== -"@influxdata/influx@0.4.0": - version "0.4.0" - resolved "https://registry.yarnpkg.com/@influxdata/influx/-/influx-0.4.0.tgz#8ca2a8696134d2a9c326b600dcebfacc95c63473" - integrity sha512-zNtqrjP/FmtrzxUPC3erRtIxJjuQPLhEc1w/dVKsgL4nkS+NsfEnZ1M2dMDWp0qrirS1JZir0ejFod1MuwenbA== +"@influxdata/influx@0.5.0": + version "0.5.0" + resolved "https://registry.yarnpkg.com/@influxdata/influx/-/influx-0.5.0.tgz#dedf688d84a50b526a15362633bd5ee7f1e7a95b" + integrity sha512-P24C5j20RRMX2JT43vTdoSozjZp01rcXxOAoIMR+sDMSMG4XuuckIEEOsdTnP1w+N2ivhjC74MjzmswxKeO0fw== dependencies: axios "^0.19.0"