From 40501925cbe259111def8fceb30bdacdb9fd4a49 Mon Sep 17 00:00:00 2001 From: Alirie Gray Date: Tue, 19 Feb 2019 14:05:13 -0800 Subject: [PATCH] Add ability to update a variable --- CHANGELOG.md | 1 + ui/package-lock.json | 30 ++-- ui/package.json | 6 +- .../components/UpdateVariableOverlay.tsx | 146 ++++++++++++++++++ .../organizations/components/VariableList.tsx | 56 ++++++- .../organizations/components/VariableRow.tsx | 22 ++- ui/src/organizations/components/Variables.tsx | 21 +++ .../__snapshots__/Variables.test.tsx.snap | 9 ++ ui/src/shared/components/EditableName.tsx | 1 + ui/src/shared/copy/notifications.ts | 12 ++ 10 files changed, 282 insertions(+), 22 deletions(-) create mode 100644 ui/src/organizations/components/UpdateVariableOverlay.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index 55f23f31d4a..9579be3afd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Features 1. [11954](https://github.com/influxdata/influxdb/pull/11954): Add the ability to run a task manually from tasks page 1. [11990](https://github.com/influxdata/influxdb/pull/11990): Add the ability to select a custom time range in explorer and dashboard +1. [12011](https://github.com/influxdata/influxdb/pull/12011): Add the ability to update a Variable's name and query. ### Bug Fixes 1. [11997](https://github.com/influxdata/influxdb/pull/11997): Update the bucket retention policy to update the time in seconds diff --git a/ui/package-lock.json b/ui/package-lock.json index 8b354cb598f..4ed88b2680a 100644 --- a/ui/package-lock.json +++ b/ui/package-lock.json @@ -985,9 +985,9 @@ } }, "@influxdata/influx": { - "version": "0.2.10", - "resolved": "https://registry.npmjs.org/@influxdata/influx/-/influx-0.2.10.tgz", - "integrity": "sha512-apEhHRmxolj/fqB0J+hoWXP2NDWJFqDA9waMmYY5El/v8FTINTNWOdz8StSVWbqtmJ5uf0/D/JJig75aLaffaw==", + "version": "0.2.11", + "resolved": "https://registry.npmjs.org/@influxdata/influx/-/influx-0.2.11.tgz", + "integrity": "sha512-Y8rnNS5MXWGKVhODlW8KyCQFaVgmhLUTzA3koCd5Dp8GuRjclpP8vNMZWOI5DPOjPbKqd5aImgqvl5yVdgWeuA==", "requires": { "axios": "^0.18.0" } @@ -10649,7 +10649,7 @@ "dependencies": { "minimist": { "version": "0.0.10", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", "dev": true }, @@ -12481,14 +12481,14 @@ } }, "react": { - "version": "16.8.1", - "resolved": "https://registry.npmjs.org/react/-/react-16.8.1.tgz", - "integrity": "sha512-wLw5CFGPdo7p/AgteFz7GblI2JPOos0+biSoxf1FPsGxWQZdN/pj6oToJs1crn61DL3Ln7mN86uZ4j74p31ELQ==", + "version": "16.8.2", + "resolved": "https://registry.npmjs.org/react/-/react-16.8.2.tgz", + "integrity": "sha512-aB2ctx9uQ9vo09HVknqv3DGRpI7OIGJhCx3Bt0QqoRluEjHSaObJl+nG12GDdYH6sTgE7YiPJ6ZUyMx9kICdXw==", "requires": { "loose-envify": "^1.1.0", "object-assign": "^4.1.1", "prop-types": "^15.6.2", - "scheduler": "^0.13.1" + "scheduler": "^0.13.2" } }, "react-codemirror2": { @@ -12554,14 +12554,14 @@ } }, "react-dom": { - "version": "16.8.1", - "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.8.1.tgz", - "integrity": "sha512-N74IZUrPt6UiDjXaO7UbDDFXeUXnVhZzeRLy/6iqqN1ipfjrhR60Bp5NuBK+rv3GMdqdIuwIl22u1SYwf330bg==", + "version": "16.8.2", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.8.2.tgz", + "integrity": "sha512-cPGfgFfwi+VCZjk73buu14pYkYBR1b/SRMSYqkLDdhSEHnSwcuYTPu6/Bh6ZphJFIk80XLvbSe2azfcRzNF+Xg==", "requires": { "loose-envify": "^1.1.0", "object-assign": "^4.1.1", "prop-types": "^15.6.2", - "scheduler": "^0.13.1" + "scheduler": "^0.13.2" } }, "react-draggable": { @@ -13627,9 +13627,9 @@ } }, "scheduler": { - "version": "0.13.1", - "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.13.1.tgz", - "integrity": "sha512-VJKOkiKIN2/6NOoexuypwSrybx13MY7NSy9RNt8wPvZDMRT1CW6qlpF5jXRToXNHz3uWzbm2elNpZfXfGPqP9A==", + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.13.2.tgz", + "integrity": "sha512-qK5P8tHS7vdEMCW5IPyt8v9MJOHqTrOUgPXib7tqm9vh834ibBX5BNhwkplX/0iOzHW5sXyluehYfS9yrkz9+w==", "requires": { "loose-envify": "^1.1.0", "object-assign": "^4.1.1" diff --git a/ui/package.json b/ui/package.json index 839bd994aaa..60f8b9ad855 100644 --- a/ui/package.json +++ b/ui/package.json @@ -132,7 +132,7 @@ }, "dependencies": { "@influxdata/clockface": "0.0.4", - "@influxdata/influx": "^0.2.10", + "@influxdata/influx": "^0.2.11", "@influxdata/react-custom-scrollbars": "4.3.8", "axios": "^0.18.0", "babel-polyfill": "^6.26.0", @@ -158,14 +158,14 @@ "papaparse": "^4.4.0", "prop-types": "^15.6.1", "qs": "^6.5.2", - "react": "^16.8.0", + "react": "^16.8.2", "react-codemirror2": "^4.2.1", "react-copy-to-clipboard": "^5.0.1", "react-datepicker": "^2.1.0", "react-dimensions": "^1.2.0", "react-dnd": "^2.6.0", "react-dnd-html5-backend": "^2.6.0", - "react-dom": "^16.8.0", + "react-dom": "^16.8.2", "react-grid-layout": "^0.16.6", "react-markdown": "^4.0.3", "react-redux": "^5.0.7", diff --git a/ui/src/organizations/components/UpdateVariableOverlay.tsx b/ui/src/organizations/components/UpdateVariableOverlay.tsx new file mode 100644 index 00000000000..50d3ad2ac99 --- /dev/null +++ b/ui/src/organizations/components/UpdateVariableOverlay.tsx @@ -0,0 +1,146 @@ +// Libraries +import React, {PureComponent, ChangeEvent} from 'react' +import _ from 'lodash' + +// Components +import { + OverlayBody, + OverlayHeading, + OverlayFooter, + ComponentStatus, + OverlayContainer, + Form, + Input, +} from 'src/clockface' +import {Button, ButtonType, ComponentColor} from '@influxdata/clockface' +import FluxEditor from 'src/shared/components/FluxEditor' + +// Types +import {Variable} from '@influxdata/influx' + +interface Props { + variable: Variable + onCloseOverlay: () => void + onUpdateVariable: (variable: Variable) => Promise +} + +interface State { + variable: Variable + script: string + nameErrorMessage: string + nameInputStatus: ComponentStatus +} + +export default class UpdateVariableOverlay extends PureComponent { + constructor(props) { + super(props) + + const {variable} = this.props + const script = _.get(variable, 'arguments.values.query') + + this.state = { + variable, + script, + nameInputStatus: ComponentStatus.Default, + nameErrorMessage: '', + } + } + + public render() { + const {onCloseOverlay} = this.props + const {variable, nameInputStatus, nameErrorMessage, script} = this.state + + return ( + + + +
+ +
+ + + +
+ + +
+ +
+
+ + +