feat(ui/explorer): add imports to flux scripts (#13711)
* fix(ui) Update flux function docs and examples * add package property to FluxToolbarFunction * added package property to built-in flux functions * added package propert to the toFloat function * prettified fluxFunction.ts * updated columns parameter on derivative function * added newline after derivative desc for prettier fluxFunction.ts * chore(e2e): updsate cypress to 2.0 * feat(query-builder): add import statements * wip * feat(ui/builder): simplify import addition logic * test: remove only * chore: linting * test: string organizationpull/13713/head
parent
e181edd077
commit
f2fd7d6728
|
@ -7,7 +7,7 @@
|
|||
1. [13423](https://github.com/influxdata/influxdb/pull/13423): Set autorefresh of dashboard to pause if absolute time range is selected
|
||||
1. [13473](https://github.com/influxdata/influxdb/pull/13473): Switch task back end to a more modular and flexible system
|
||||
1. [13493](https://github.com/influxdata/influxdb/pull/13493): Add org profile tab with ability to edit organization name
|
||||
1. [13510](https://github.com/influxdata/influxdb/pull/13510): Add org name to dahboard page title
|
||||
1. [13510](https://github.com/influxdata/influxdb/pull/13510): Add org name to dahboard page title
|
||||
1. [13520](https://github.com/influxdata/influxdb/pull/13520): Add cautioning to bucket renaming
|
||||
1. [13560](https://github.com/influxdata/influxdb/pull/13560): Add option to generate all access token in tokens tab
|
||||
1. [13601](https://github.com/influxdata/influxdb/pull/13601): Add option to generate read/write token in tokens tab
|
||||
|
@ -17,6 +17,7 @@
|
|||
1. [13585](https://github.com/influxdata/influxdb/pull/13585): Prevent overlapping text and dot in time range dropdown
|
||||
1. [13602](https://github.com/influxdata/influxdb/pull/13602): Updated link in notes cell to a more useful site
|
||||
1. [13618](https://github.com/influxdata/influxdb/pull/13618): Show error message when adding line protocol
|
||||
1. [13657](https://github.com/influxdata/influxdb/pull/13657): Update UI Flux function documentation
|
||||
|
||||
### UI Improvements
|
||||
1. [13424](https://github.com/influxdata/influxdb/pull/13424): Add general polish and empty states to Create Dashboard from Template overlay
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
import {Doc} from 'codemirror'
|
||||
import {Organization} from '@influxdata/influx'
|
||||
import {FROM, RANGE, MEAN} from '../../src/shared/constants/fluxFunctions'
|
||||
import {
|
||||
FROM,
|
||||
RANGE,
|
||||
MEAN,
|
||||
MATH_ABS,
|
||||
MATH_FLOOR,
|
||||
STRINGS_TITLE,
|
||||
STRINGS_TRIM,
|
||||
} from '../../src/shared/constants/fluxFunctions'
|
||||
|
||||
interface HTMLElementCM extends HTMLElement {
|
||||
CodeMirror: {
|
||||
|
@ -49,6 +57,38 @@ describe('DataExplorer', () => {
|
|||
cy.getByTestID('time-machine-submit-button').should('be.disabled')
|
||||
})
|
||||
|
||||
it('imports the appropriate packages to build a query', () => {
|
||||
cy.getByTestID('functions-toolbar-tab').click()
|
||||
|
||||
cy.get<$CM>('.CodeMirror').then($cm => {
|
||||
const cm = $cm[0].CodeMirror
|
||||
cy.wrap(cm.doc).as('flux')
|
||||
expect(cm.doc.getValue()).to.eq('')
|
||||
})
|
||||
|
||||
cy.getByTestID('flux-function from').click()
|
||||
cy.getByTestID('flux-function range').click()
|
||||
cy.getByTestID('flux-function math.abs').click()
|
||||
cy.getByTestID('flux-function math.floor').click()
|
||||
cy.getByTestID('flux-function strings.title').click()
|
||||
cy.getByTestID('flux-function strings.trim').click()
|
||||
|
||||
cy.get<Doc>('@flux').then(doc => {
|
||||
const actual = doc.getValue()
|
||||
const expected = `
|
||||
import"${STRINGS_TITLE.package}"
|
||||
import"${MATH_ABS.package}"
|
||||
${FROM.example}|>
|
||||
${RANGE.example}|>
|
||||
${MATH_ABS.example}|>
|
||||
${MATH_FLOOR.example}|>
|
||||
${STRINGS_TITLE.example}|>
|
||||
${STRINGS_TRIM.example}`
|
||||
|
||||
cy.fluxEqual(actual, expected).should('be.true')
|
||||
})
|
||||
})
|
||||
|
||||
it('can use the function selector to build a query', () => {
|
||||
cy.getByTestID('functions-toolbar-tab').click()
|
||||
|
||||
|
|
|
@ -943,9 +943,9 @@
|
|||
}
|
||||
},
|
||||
"@cypress/xvfb": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/@cypress/xvfb/-/xvfb-1.2.3.tgz",
|
||||
"integrity": "sha512-yYrK+/bgL3hwoRHMZG4r5fyLniCy1pXex5fimtewAY6vE/jsVs8Q37UsEO03tFlcmiLnQ3rBNMaZBYTi/+C1cw==",
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://registry.npmjs.org/@cypress/xvfb/-/xvfb-1.2.4.tgz",
|
||||
"integrity": "sha512-skbBzPggOVYCbnGgV+0dmBdW/s77ZkAOXIC1knS8NagwDjBrNC1LuXtQJeiN6l+m7lzmHtaoUw/ctJKdqkG57Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"debug": "^3.1.0",
|
||||
|
@ -1159,34 +1159,6 @@
|
|||
"integrity": "sha512-wYxU3kp5zItbxKmeRYCEplS2MW7DzyBnxPGj+GJVHZEUZiK/nn5Ei1sUFgURDh+X051+zsGe28iud3oHjrYWQQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/blob-util": {
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/blob-util/-/blob-util-1.3.3.tgz",
|
||||
"integrity": "sha512-4ahcL/QDnpjWA2Qs16ZMQif7HjGP2cw3AGjHabybjw7Vm1EKu+cfQN1D78BaZbS1WJNa1opSMF5HNMztx7lR0w==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/bluebird": {
|
||||
"version": "3.5.18",
|
||||
"resolved": "https://registry.npmjs.org/@types/bluebird/-/bluebird-3.5.18.tgz",
|
||||
"integrity": "sha512-OTPWHmsyW18BhrnG5x8F7PzeZ2nFxmHGb42bZn79P9hl+GI5cMzyPgQTwNjbem0lJhoru/8vtjAFCUOu3+gE2w==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/chai": {
|
||||
"version": "4.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.0.8.tgz",
|
||||
"integrity": "sha512-m812CONwdZn/dMzkIJEY0yAs4apyTkTORgfB2UsMOxgkUbC205AHnm4T8I0I5gPg9MHrFc1dJ35iS75c0CJkjg==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/chai-jquery": {
|
||||
"version": "1.1.35",
|
||||
"resolved": "https://registry.npmjs.org/@types/chai-jquery/-/chai-jquery-1.1.35.tgz",
|
||||
"integrity": "sha512-7aIt9QMRdxuagLLI48dPz96YJdhu64p6FCa6n4qkGN5DQLHnrIjZpD9bXCvV2G0NwgZ1FAmfP214dxc5zNCfgQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/chai": "*",
|
||||
"@types/jquery": "*"
|
||||
}
|
||||
},
|
||||
"@types/cheerio": {
|
||||
"version": "0.22.9",
|
||||
"resolved": "https://registry.npmjs.org/@types/cheerio/-/cheerio-0.22.9.tgz",
|
||||
|
@ -1279,12 +1251,6 @@
|
|||
"integrity": "sha512-G6EBrbjWDfmIpYu8UcRBOhwtDiYaLj5N5jUR5rx0YvbKxRBhXPZVLUmtfShewSUNKiQwpHavpML69a2WMbIlEQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/jquery": {
|
||||
"version": "3.3.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.3.6.tgz",
|
||||
"integrity": "sha512-403D4wN95Mtzt2EoQHARf5oe/jEPhzBOBNrunk+ydQGW8WmkQ/E8rViRAEB1qEt/vssfGfNVD6ujP4FVeegrLg==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/level-codec": {
|
||||
"version": "9.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/level-codec/-/level-codec-9.0.0.tgz",
|
||||
|
@ -1314,18 +1280,6 @@
|
|||
"integrity": "sha512-cmSgi6JMX/yBwgpVm4GooNWIH+vEeJoa8FAa6ExOhpJbC0Juq32/uYKiKb3VPSqrEA0aOnjvwZanla3O1WZMbw==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/minimatch": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz",
|
||||
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/mocha": {
|
||||
"version": "2.2.44",
|
||||
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-2.2.44.tgz",
|
||||
"integrity": "sha512-k2tWTQU8G4+iSMvqKi0Q9IIsWAp/n8xzdZS4Q4YVIltApoMA00wFBFdlJnmoaK1/z7B0Cy0yPe6GgXteSmdUNw==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "9.6.34",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-9.6.34.tgz",
|
||||
|
@ -1465,22 +1419,6 @@
|
|||
"integrity": "sha512-41qEJgBH/TWgo5NFSvBCJ1qkoi3Q6ONSF2avrHq1LVEZfYpdHmj0y9SuTK+u9ZhG1sYQKBL1AWXKyLWP4RaUoQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/sinon": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-7.0.0.tgz",
|
||||
"integrity": "sha512-kcYoPw0uKioFVC/oOqafk2yizSceIQXCYnkYts9vJIwQklFRsMubTObTDrjQamUyBRd47332s85074cd/hCwxg==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/sinon-chai": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/sinon-chai/-/sinon-chai-3.2.2.tgz",
|
||||
"integrity": "sha512-5zSs2AslzyPZdOsbm2NRtuSNAI2aTWzNKOHa/GRecKo7a5efYD7qGcPxMZXQDayVXT2Vnd5waXxBvV31eCZqiA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/chai": "*",
|
||||
"@types/sinon": "*"
|
||||
}
|
||||
},
|
||||
"@types/text-encoding": {
|
||||
"version": "0.0.32",
|
||||
"resolved": "https://registry.npmjs.org/@types/text-encoding/-/text-encoding-0.0.32.tgz",
|
||||
|
@ -3628,13 +3566,10 @@
|
|||
"dev": true
|
||||
},
|
||||
"common-tags": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.4.0.tgz",
|
||||
"integrity": "sha1-EYe+Tz1M8MBCfUP3Tu8fc1AWFMA=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"babel-runtime": "^6.18.0"
|
||||
}
|
||||
"version": "1.8.0",
|
||||
"resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.0.tgz",
|
||||
"integrity": "sha512-6P6g0uetGpW/sdyUy/iQQCbFF0kWVMSIVSyYz7Zgjcgh8mgw8PQzDNZeyZ5DQ2gM7LBoZPHmnjz8rUthkBG5tw==",
|
||||
"dev": true
|
||||
},
|
||||
"commondir": {
|
||||
"version": "1.0.1",
|
||||
|
@ -4120,63 +4055,58 @@
|
|||
"dev": true
|
||||
},
|
||||
"cypress": {
|
||||
"version": "3.1.5",
|
||||
"resolved": "https://registry.npmjs.org/cypress/-/cypress-3.1.5.tgz",
|
||||
"integrity": "sha512-jzYGKJqU1CHoNocPndinf/vbG28SeU+hg+4qhousT/HDBMJxYgjecXOmSgBX/ga9/TakhqSrIrSP2r6gW/OLtg==",
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/cypress/-/cypress-3.2.0.tgz",
|
||||
"integrity": "sha512-PN0wz6x634QyNL56/voTzJoeScDfwtecvSfFTHfv5MkHuECVSR4VQcEZTvYtKWln3CMBMUkWbBKPIwwu2+a/kw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@cypress/listr-verbose-renderer": "0.4.1",
|
||||
"@cypress/xvfb": "1.2.3",
|
||||
"@types/blob-util": "1.3.3",
|
||||
"@types/bluebird": "3.5.18",
|
||||
"@types/chai": "4.0.8",
|
||||
"@types/chai-jquery": "1.1.35",
|
||||
"@types/jquery": "3.3.6",
|
||||
"@types/lodash": "4.14.87",
|
||||
"@types/minimatch": "3.0.3",
|
||||
"@types/mocha": "2.2.44",
|
||||
"@types/sinon": "7.0.0",
|
||||
"@types/sinon-chai": "3.2.2",
|
||||
"@cypress/xvfb": "1.2.4",
|
||||
"bluebird": "3.5.0",
|
||||
"cachedir": "1.3.0",
|
||||
"chalk": "2.4.1",
|
||||
"chalk": "2.4.2",
|
||||
"check-more-types": "2.24.0",
|
||||
"commander": "2.11.0",
|
||||
"common-tags": "1.4.0",
|
||||
"commander": "2.15.1",
|
||||
"common-tags": "1.8.0",
|
||||
"debug": "3.1.0",
|
||||
"execa": "0.10.0",
|
||||
"executable": "4.1.1",
|
||||
"extract-zip": "1.6.6",
|
||||
"extract-zip": "1.6.7",
|
||||
"fs-extra": "4.0.1",
|
||||
"getos": "3.1.0",
|
||||
"glob": "7.1.2",
|
||||
"is-ci": "1.0.10",
|
||||
"glob": "7.1.3",
|
||||
"is-ci": "1.2.1",
|
||||
"is-installed-globally": "0.1.0",
|
||||
"lazy-ass": "1.6.0",
|
||||
"listr": "0.12.0",
|
||||
"lodash": "4.17.11",
|
||||
"log-symbols": "2.2.0",
|
||||
"minimist": "1.2.0",
|
||||
"moment": "2.22.2",
|
||||
"moment": "2.24.0",
|
||||
"ramda": "0.24.1",
|
||||
"request": "2.87.0",
|
||||
"request-progress": "0.3.1",
|
||||
"supports-color": "5.1.0",
|
||||
"tmp": "0.0.31",
|
||||
"request": "2.88.0",
|
||||
"request-progress": "0.4.0",
|
||||
"supports-color": "5.5.0",
|
||||
"tmp": "0.0.33",
|
||||
"url": "0.11.0",
|
||||
"yauzl": "2.8.0"
|
||||
"yauzl": "2.10.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/lodash": {
|
||||
"version": "4.14.87",
|
||||
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.87.tgz",
|
||||
"integrity": "sha512-AqRC+aEF4N0LuNHtcjKtvF9OTfqZI0iaBoe3dA6m/W+/YZJBZjBmW/QIZ8fBeXC6cnytSY9tBoFBqZ9uSCeVsw==",
|
||||
"dev": true
|
||||
"chalk": {
|
||||
"version": "2.4.2",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
|
||||
"integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-styles": "^3.2.1",
|
||||
"escape-string-regexp": "^1.0.5",
|
||||
"supports-color": "^5.3.0"
|
||||
}
|
||||
},
|
||||
"commander": {
|
||||
"version": "2.11.0",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz",
|
||||
"integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==",
|
||||
"version": "2.15.1",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz",
|
||||
"integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==",
|
||||
"dev": true
|
||||
},
|
||||
"debug": {
|
||||
|
@ -4203,75 +4133,19 @@
|
|||
"strip-eof": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"fast-deep-equal": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz",
|
||||
"integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=",
|
||||
"dev": true
|
||||
},
|
||||
"glob": {
|
||||
"version": "7.1.2",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
|
||||
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
"inherits": "2",
|
||||
"minimatch": "^3.0.4",
|
||||
"once": "^1.3.0",
|
||||
"path-is-absolute": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"har-validator": {
|
||||
"version": "5.0.3",
|
||||
"resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz",
|
||||
"integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ajv": "^5.1.0",
|
||||
"har-schema": "^2.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ajv": {
|
||||
"version": "5.5.2",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz",
|
||||
"integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"co": "^4.6.0",
|
||||
"fast-deep-equal": "^1.0.0",
|
||||
"fast-json-stable-stringify": "^2.0.0",
|
||||
"json-schema-traverse": "^0.3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"has-flag": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz",
|
||||
"integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=",
|
||||
"dev": true
|
||||
},
|
||||
"is-ci": {
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmjs.org/is-ci/-/is-ci-1.0.10.tgz",
|
||||
"integrity": "sha1-9zkzayYyNlBhqdSCcM1WrjNpMY4=",
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/is-ci/-/is-ci-1.2.1.tgz",
|
||||
"integrity": "sha512-s6tfsaQaQi3JNciBH6shVqEDvhGut0SUXr31ag8Pd8BBbVVlcGfWhpPmEOoM6RJ5TFhbypvf5yyRw/VXW1IiWg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ci-info": "^1.0.0"
|
||||
"ci-info": "^1.5.0"
|
||||
}
|
||||
},
|
||||
"json-schema-traverse": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz",
|
||||
"integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=",
|
||||
"dev": true
|
||||
},
|
||||
"oauth-sign": {
|
||||
"version": "0.8.2",
|
||||
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz",
|
||||
"integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=",
|
||||
"moment": {
|
||||
"version": "2.24.0",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz",
|
||||
"integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==",
|
||||
"dev": true
|
||||
},
|
||||
"ramda": {
|
||||
|
@ -4279,52 +4153,6 @@
|
|||
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.24.1.tgz",
|
||||
"integrity": "sha1-w7d1UZfzW43DUCIoJixMkd22uFc=",
|
||||
"dev": true
|
||||
},
|
||||
"request": {
|
||||
"version": "2.87.0",
|
||||
"resolved": "https://registry.npmjs.org/request/-/request-2.87.0.tgz",
|
||||
"integrity": "sha512-fcogkm7Az5bsS6Sl0sibkbhcKsnyon/jV1kF3ajGmF0c8HrttdKTPRT9hieOaQHA5HEq6r8OyWOo/o781C1tNw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"aws-sign2": "~0.7.0",
|
||||
"aws4": "^1.6.0",
|
||||
"caseless": "~0.12.0",
|
||||
"combined-stream": "~1.0.5",
|
||||
"extend": "~3.0.1",
|
||||
"forever-agent": "~0.6.1",
|
||||
"form-data": "~2.3.1",
|
||||
"har-validator": "~5.0.3",
|
||||
"http-signature": "~1.2.0",
|
||||
"is-typedarray": "~1.0.0",
|
||||
"isstream": "~0.1.2",
|
||||
"json-stringify-safe": "~5.0.1",
|
||||
"mime-types": "~2.1.17",
|
||||
"oauth-sign": "~0.8.2",
|
||||
"performance-now": "^2.1.0",
|
||||
"qs": "~6.5.1",
|
||||
"safe-buffer": "^5.1.1",
|
||||
"tough-cookie": "~2.3.3",
|
||||
"tunnel-agent": "^0.6.0",
|
||||
"uuid": "^3.1.0"
|
||||
}
|
||||
},
|
||||
"supports-color": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.1.0.tgz",
|
||||
"integrity": "sha512-Ry0AwkoKjDpVKK4sV4h6o3UJmNRbjYm2uXhwfj3J56lMVdvnUNqzQVRztOOMGQ++w1K/TjNDFvpJk0F/LoeBCQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"has-flag": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"tough-cookie": {
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz",
|
||||
"integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"punycode": "^1.4.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -5541,43 +5369,17 @@
|
|||
}
|
||||
},
|
||||
"extract-zip": {
|
||||
"version": "1.6.6",
|
||||
"resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.6.tgz",
|
||||
"integrity": "sha1-EpDt6NINCHK0Kf0/NRyhKOxe+Fw=",
|
||||
"version": "1.6.7",
|
||||
"resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.7.tgz",
|
||||
"integrity": "sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"concat-stream": "1.6.0",
|
||||
"concat-stream": "1.6.2",
|
||||
"debug": "2.6.9",
|
||||
"mkdirp": "0.5.0",
|
||||
"mkdirp": "0.5.1",
|
||||
"yauzl": "2.4.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"concat-stream": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz",
|
||||
"integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"inherits": "^2.0.3",
|
||||
"readable-stream": "^2.2.2",
|
||||
"typedarray": "^0.0.6"
|
||||
}
|
||||
},
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
|
||||
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
|
||||
"dev": true
|
||||
},
|
||||
"mkdirp": {
|
||||
"version": "0.5.0",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.0.tgz",
|
||||
"integrity": "sha1-HXMHam35hs2TROFecfzAWkyavxI=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
},
|
||||
"yauzl": {
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz",
|
||||
|
@ -10940,6 +10742,12 @@
|
|||
"integrity": "sha512-479Bjw9nTE5DdBSZZWprFryHGjUaQC31y1wHo19We/k0BZlrmhqQitWoUL0cD8+scljCbIUL+E58oRDEakdGGA==",
|
||||
"dev": true
|
||||
},
|
||||
"node-eta": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/node-eta/-/node-eta-0.1.1.tgz",
|
||||
"integrity": "sha1-QGYQmzk3HHYccrfr2pqeoKXeEh8=",
|
||||
"dev": true
|
||||
},
|
||||
"node-fetch": {
|
||||
"version": "1.7.3",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz",
|
||||
|
@ -11941,7 +11749,7 @@
|
|||
},
|
||||
"pify": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
|
||||
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
|
||||
"dev": true
|
||||
},
|
||||
|
@ -14045,12 +13853,13 @@
|
|||
}
|
||||
},
|
||||
"request-progress": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://registry.npmjs.org/request-progress/-/request-progress-0.3.1.tgz",
|
||||
"integrity": "sha1-ByHBBdipasayzossia4tXs/Pazo=",
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/request-progress/-/request-progress-0.4.0.tgz",
|
||||
"integrity": "sha1-wZVOOQhqqFJpxWYLzuAUKmpw1+c=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"throttleit": "~0.0.2"
|
||||
"node-eta": "^0.1.1",
|
||||
"throttleit": "^0.0.2"
|
||||
}
|
||||
},
|
||||
"request-promise-core": {
|
||||
|
@ -15320,12 +15129,12 @@
|
|||
"dev": true
|
||||
},
|
||||
"tmp": {
|
||||
"version": "0.0.31",
|
||||
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz",
|
||||
"integrity": "sha1-jzirlDjhcxXl29izZX6L+yd65Kc=",
|
||||
"version": "0.0.33",
|
||||
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
|
||||
"integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"os-tmpdir": "~1.0.1"
|
||||
"os-tmpdir": "~1.0.2"
|
||||
}
|
||||
},
|
||||
"tmpl": {
|
||||
|
@ -16727,13 +16536,24 @@
|
|||
}
|
||||
},
|
||||
"yauzl": {
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.8.0.tgz",
|
||||
"integrity": "sha1-eUUK/yKyqcWkHvVOAtuQfM+/nuI=",
|
||||
"version": "2.10.0",
|
||||
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz",
|
||||
"integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"buffer-crc32": "~0.2.3",
|
||||
"fd-slicer": "~1.0.1"
|
||||
"fd-slicer": "~1.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"fd-slicer": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz",
|
||||
"integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"pend": "~1.2.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@
|
|||
"ajv": "^6.7.0",
|
||||
"autoprefixer": "^6.3.1",
|
||||
"babel-loader": "^8.0.5",
|
||||
"cypress": "^3.1.5",
|
||||
"cypress": "^3.2.0",
|
||||
"enzyme": "^3.6.0",
|
||||
"enzyme-adapter-react-16": "^1.6.0",
|
||||
"enzyme-to-json": "^3.3.4",
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -23,7 +23,7 @@ import {insertVariable} from 'src/timeMachine/utils/insertVariable'
|
|||
import {HANDLE_VERTICAL, HANDLE_NONE} from 'src/shared/constants'
|
||||
|
||||
// Types
|
||||
import {AppState} from 'src/types'
|
||||
import {AppState, FluxToolbarFunction} from 'src/types'
|
||||
|
||||
interface StateProps {
|
||||
activeQueryText: string
|
||||
|
@ -135,8 +135,7 @@ class TimeMachineFluxEditor extends PureComponent<Props, State> {
|
|||
}
|
||||
|
||||
private handleInsertFluxFunction = async (
|
||||
functionName: string,
|
||||
fluxFunction: string
|
||||
func: FluxToolbarFunction
|
||||
): Promise<void> => {
|
||||
const {activeQueryText} = this.props
|
||||
const {line} = this.cursorPosition
|
||||
|
@ -144,8 +143,7 @@ class TimeMachineFluxEditor extends PureComponent<Props, State> {
|
|||
const {updatedScript, cursorPosition} = insertFluxFunction(
|
||||
line,
|
||||
activeQueryText,
|
||||
functionName,
|
||||
fluxFunction
|
||||
func
|
||||
)
|
||||
await this.props.onSetActiveQueryText(updatedScript)
|
||||
|
||||
|
|
|
@ -19,10 +19,10 @@ import {getActiveQuery} from 'src/timeMachine/selectors'
|
|||
import {FLUX_FUNCTIONS} from 'src/shared/constants/fluxFunctions'
|
||||
|
||||
// Types
|
||||
import {AppState} from 'src/types'
|
||||
import {AppState, FluxToolbarFunction} from 'src/types'
|
||||
|
||||
interface OwnProps {
|
||||
onInsertFluxFunction: (functionName: string, text: string) => void
|
||||
onInsertFluxFunction: (func: FluxToolbarFunction) => void
|
||||
}
|
||||
|
||||
interface StateProps {
|
||||
|
@ -75,8 +75,8 @@ class FluxFunctionsToolbar extends PureComponent<Props, State> {
|
|||
this.setState({searchTerm})
|
||||
}
|
||||
|
||||
private handleClickFunction = (funcName: string, funcExample: string) => {
|
||||
this.props.onInsertFluxFunction(funcName, funcExample)
|
||||
private handleClickFunction = (func: FluxToolbarFunction) => {
|
||||
this.props.onInsertFluxFunction(func)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import {FluxToolbarFunction} from 'src/types/shared'
|
|||
interface Props {
|
||||
category: string
|
||||
funcs: FluxToolbarFunction[]
|
||||
onClickFunction: (name: string, example: string) => void
|
||||
onClickFunction: (func: FluxToolbarFunction) => void
|
||||
}
|
||||
|
||||
const FunctionCategory: SFC<Props> = props => {
|
||||
|
|
|
@ -10,7 +10,7 @@ import {FluxToolbarFunction} from 'src/types/shared'
|
|||
|
||||
interface Props {
|
||||
func: FluxToolbarFunction
|
||||
onClickFunction: (name: string, example: string) => void
|
||||
onClickFunction: (func: FluxToolbarFunction) => void
|
||||
testID: string
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ class ToolbarFunction extends PureComponent<Props, State> {
|
|||
private handleClickFunction = () => {
|
||||
const {func, onClickFunction} = this.props
|
||||
|
||||
onClickFunction(func.name, func.example)
|
||||
onClickFunction(func)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@ import {Position} from 'codemirror'
|
|||
// Constants
|
||||
import {FROM, UNION} from 'src/shared/constants/fluxFunctions'
|
||||
|
||||
// Types
|
||||
import {FluxToolbarFunction} from 'src/types'
|
||||
|
||||
const rejoinScript = (scriptLines: string[]): string => {
|
||||
return scriptLines.join('\n')
|
||||
}
|
||||
|
@ -14,7 +17,6 @@ const insertAtLine = (
|
|||
insertOnSameLine?: boolean
|
||||
): string => {
|
||||
const front = scriptLines.slice(0, lineNumber)
|
||||
|
||||
const backStartIndex = insertOnSameLine ? lineNumber + 1 : lineNumber
|
||||
const back = scriptLines.slice(backStartIndex)
|
||||
|
||||
|
@ -69,30 +71,50 @@ const getCursorPosition = (
|
|||
return {line, ch}
|
||||
}
|
||||
|
||||
const genImport = (script: string, funcPackage: string) => {
|
||||
const importStatement = `import "${funcPackage}"`
|
||||
|
||||
if (!funcPackage || script.includes(importStatement)) {
|
||||
return ''
|
||||
}
|
||||
|
||||
return importStatement
|
||||
}
|
||||
|
||||
export const insertFluxFunction = (
|
||||
currentLineNumber: number,
|
||||
currentScript: string,
|
||||
functionName: string,
|
||||
fluxFunction: string
|
||||
func: FluxToolbarFunction
|
||||
): {updatedScript: string; cursorPosition: Position} => {
|
||||
const {name, example} = func
|
||||
|
||||
const scriptLines = currentScript.split('\n')
|
||||
const insertLineNumber = getInsertLineNumber(currentLineNumber, scriptLines)
|
||||
|
||||
let insertLineNumber = getInsertLineNumber(currentLineNumber, scriptLines)
|
||||
|
||||
const insertOnSameLine = currentLineNumber === insertLineNumber
|
||||
|
||||
const formattedFunction = formatFunctionForInsert(functionName, fluxFunction)
|
||||
const formattedFunction = formatFunctionForInsert(name, example)
|
||||
|
||||
const updatedScript = insertAtLine(
|
||||
let nextScript = insertAtLine(
|
||||
insertLineNumber,
|
||||
scriptLines,
|
||||
formattedFunction,
|
||||
insertOnSameLine
|
||||
)
|
||||
|
||||
const updatedCursorPosition = getCursorPosition(
|
||||
const importStatement = genImport(nextScript, func.package)
|
||||
|
||||
if (importStatement) {
|
||||
nextScript = `${importStatement}\n${nextScript}`
|
||||
insertLineNumber += 1
|
||||
}
|
||||
|
||||
const nextCursorPos = getCursorPosition(
|
||||
insertLineNumber,
|
||||
formattedFunction,
|
||||
functionName
|
||||
name
|
||||
)
|
||||
|
||||
return {updatedScript, cursorPosition: updatedCursorPosition}
|
||||
return {updatedScript: nextScript, cursorPosition: nextCursorPos}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ export interface FluxToolbarFunction {
|
|||
name: string
|
||||
args: FluxToolbarArg[]
|
||||
desc: string
|
||||
package: string
|
||||
example: string
|
||||
category: string
|
||||
link: string
|
||||
|
|
Loading…
Reference in New Issue