-
Notifications
You must be signed in to change notification settings - Fork 462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Backend] Merge 'master' changes into the backend #875
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
fe943ac
CI: fix shellcheck issues (#789)
mjtrangoni 9cf1323
annotations: fix options in grafana 6.x, fix #813
alexanderzobnin a652eaf
fix function editor in Grafana 6.4, closes #810
alexanderzobnin ca50d0d
add typings for grafana packages
alexanderzobnin 1827aa9
Add $__range_series variable for calculating function over the whole …
alexanderzobnin 1d13520
fix tests
alexanderzobnin 42d93b4
Don't set alert styles for react panels, fix #823
alexanderzobnin 51d423e
docs: add range variables
alexanderzobnin bc1453e
docs: percentile reference
alexanderzobnin bcbbc97
fix codespell
alexanderzobnin 5afeda6
Range-related variables #814
alexanderzobnin d09830f
update packages (build with node 12)
alexanderzobnin cf9780c
update circleci node image to 12
alexanderzobnin c1db914
fix test configuration (babel)
alexanderzobnin ff4ad19
Fix 817 (#851)
alexanderzobnin 68aa093
build(deps-dev): bump lodash from 4.17.10 to 4.17.13 (#852)
dependabot[bot] 4fcef29
fix packages security alerts
alexanderzobnin 1e6ca2d
problems: fix tags adding and removal
alexanderzobnin 90a9115
fix adding func from typeahead, closes #468
alexanderzobnin 51ef6f7
update change log
alexanderzobnin 90b8bfa
bump plugin version to 3.10.5
alexanderzobnin d54d6d2
problems: fix tag removal (list layout)
alexanderzobnin dd28b28
Fix percentile() function, closes #862 (#863)
mr-ns fe0c5cf
Update copyright, happy New Year!
alexanderzobnin 4f24b2b
fix not acknowledged problem color with a message (#858)
memfiz 82cfda6
Variable query editor (#856)
alexanderzobnin ef36b91
Merge remote-tracking branch 'upstream/master' into backend-rebase
ee30f7d
Fixes for backend
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module.exports = { | ||
"presets": [ | ||
[ "@babel/env", { targets: { node: 'current' } } ], | ||
[ "@babel/preset-env", { "targets": { "node": "current" } } ], | ||
"@babel/react" | ||
], | ||
"retainLines": true | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
{ | ||
"name": "grafana-zabbix", | ||
"private": false, | ||
"version": "3.10.4", | ||
"version": "3.10.5", | ||
"description": "Zabbix plugin for Grafana", | ||
"homepage": "http://grafana-zabbix.org", | ||
"scripts": { | ||
"build": "webpack --config webpack/webpack.prod.conf.js --progress --colors", | ||
"dev": "webpack --config webpack/webpack.dev.conf.js --watch --progress --colors", | ||
|
@@ -25,21 +26,23 @@ | |
"url": "https://github.com/alexanderzobnin/grafana-zabbix/issues" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.6.4", | ||
"@babel/preset-env": "^7.6.3", | ||
"@babel/preset-react": "^7.6.3", | ||
"@grafana/data": "^6.4.3", | ||
"@grafana/runtime": "^6.4.3", | ||
"@grafana/toolkit": "^6.4.3", | ||
"@grafana/ui": "^6.4.3", | ||
"@babel/core": "^7.8.3", | ||
"@babel/preset-env": "^7.8.3", | ||
"@babel/preset-react": "^7.8.3", | ||
"@emotion/core": "^10.0.27", | ||
"@grafana/data": "canary", | ||
"@grafana/runtime": "canary", | ||
"@grafana/toolkit": "canary", | ||
"@grafana/ui": "canary", | ||
"@types/classnames": "^2.2.9", | ||
"@types/grafana": "github:CorpGlory/types-grafana", | ||
"@types/jest": "^23.1.1", | ||
"@types/jquery": "^3.3.0", | ||
"@types/lodash": "^4.14.104", | ||
"@types/moment": "^2.13.0", | ||
"@types/react": "^16.4.6", | ||
"@types/react-dom": "^16.0.11", | ||
"@types/react": "^16.9.17", | ||
"@types/react-table": "^6.8.6", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Current builds of @grafana/ui started using react-table 7. Without defining our own version of the types here, it was using types 7.x and throwing errors due to type changes in the next version. |
||
"@types/react-dom": "^16.9.4", | ||
"@types/react-transition-group": "^2.0.15", | ||
"babel-jest": "^24.9.0", | ||
"babel-loader": "^8.0.6", | ||
|
@@ -49,24 +52,24 @@ | |
"classnames": "^2.2.6", | ||
"clean-webpack-plugin": "^0.1.19", | ||
"codecov": "^3.1.0", | ||
"copy-webpack-plugin": "^4.5.4", | ||
"css-loader": "^1.0.0", | ||
"copy-webpack-plugin": "^5.1.1", | ||
"css-loader": "2.1.1", | ||
"extract-text-webpack-plugin": "^4.0.0-beta.0", | ||
"grunt": "^1.0.3", | ||
"grunt-benchmark": "^1.0.0", | ||
"grunt-cli": "^1.3.1", | ||
"grunt-execute": "^0.2.2", | ||
"html-loader": "^0.5.5", | ||
"jest": "^23.6.0", | ||
"jest": "^24.9.0", | ||
"jscs": "^3.0.7", | ||
"jsdom": "~11.3.0", | ||
"jshint": "^2.9.6", | ||
"jshint-stylish": "^2.1.0", | ||
"load-grunt-tasks": "~3.2.0", | ||
"lodash": "~4.17.5", | ||
"lodash": "~4.17.13", | ||
"moment": "~2.21.0", | ||
"ng-annotate-webpack-plugin": "^0.3.0", | ||
"node-sass": "^4.9.4", | ||
"node-sass": "^4.13.0", | ||
"prop-types": "^15.6.2", | ||
"react": "^16.7.0", | ||
"react-dom": "^16.7.0", | ||
|
@@ -78,12 +81,19 @@ | |
"sass-loader": "^8.0.0", | ||
"style-loader": "^0.23.1", | ||
"tether-drop": "^1.4.2", | ||
"ts-jest": "^23.10.5", | ||
"ts-jest": "^24.2.0", | ||
"ts-loader": "^6.2.0", | ||
"tslint": "^5.11.0", | ||
"typescript": "^3.6.4", | ||
"webpack": "^4.22.0", | ||
"webpack-cli": "^3.1.2" | ||
"tslint": "5.20.1", | ||
"typescript": "3.7.2", | ||
"webpack": "4.29.6", | ||
"webpack-cli": "3.2.3" | ||
}, | ||
"homepage": "http://grafana-zabbix.org" | ||
"resolutions": { | ||
"js-yaml": "^3.13.1", | ||
"lodash": "~4.17.13", | ||
"set-value": "^2.0.1", | ||
"mixin-deep": "^1.3.2", | ||
"minimatch": "^3.0.2", | ||
"fstream": "^1.0.12" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
157 changes: 157 additions & 0 deletions
157
src/datasource-zabbix/components/VariableQueryEditor.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
import React, { PureComponent } from 'react'; | ||
import { parseLegacyVariableQuery } from '../utils'; | ||
import { Select, Input, AsyncSelect, FormLabel } from '@grafana/ui'; | ||
import { SelectableValue } from '@grafana/data'; | ||
import { VariableQuery, VariableQueryTypes, VariableQueryProps, VariableQueryData } from '../types'; | ||
import { ZabbixInput } from './ZabbixInput'; | ||
|
||
export class ZabbixVariableQueryEditor extends PureComponent<VariableQueryProps, VariableQueryData> { | ||
queryTypes: Array<SelectableValue<VariableQueryTypes>> = [ | ||
{ value: VariableQueryTypes.Group, label: 'Group'}, | ||
{ value: VariableQueryTypes.Host, label: 'Host' }, | ||
{ value: VariableQueryTypes.Application, label: 'Application' }, | ||
{ value: VariableQueryTypes.Item, label: 'Item' }, | ||
]; | ||
|
||
defaults: VariableQueryData = { | ||
selectedQueryType: { value: VariableQueryTypes.Group, label: 'Group' }, | ||
queryType: VariableQueryTypes.Group, | ||
group: '/.*/', | ||
host: '', | ||
application: '', | ||
item: '', | ||
}; | ||
|
||
constructor(props: VariableQueryProps) { | ||
super(props); | ||
|
||
if (this.props.query && typeof this.props.query === 'string') { | ||
// Backward compatibility | ||
const query = parseLegacyVariableQuery(this.props.query); | ||
const selectedQueryType = this.getSelectedQueryType(query.queryType); | ||
this.state = { | ||
selectedQueryType, | ||
legacyQuery: this.props.query, | ||
...query | ||
}; | ||
} else if (this.props.query) { | ||
const query = (this.props.query as VariableQuery); | ||
const selectedQueryType = this.getSelectedQueryType(query.queryType); | ||
this.state = { | ||
...this.defaults, | ||
...query, | ||
selectedQueryType, | ||
}; | ||
} else { | ||
this.state = this.defaults; | ||
} | ||
} | ||
|
||
getSelectedQueryType(queryType: VariableQueryTypes) { | ||
return this.queryTypes.find(q => q.value === queryType); | ||
} | ||
|
||
handleQueryUpdate = (evt: React.ChangeEvent<HTMLInputElement>, prop: string) => { | ||
const value = evt.currentTarget.value; | ||
this.setState((prevState: VariableQueryData) => { | ||
const newQuery = { | ||
...prevState, | ||
}; | ||
newQuery[prop] = value; | ||
|
||
return { | ||
...newQuery, | ||
}; | ||
}); | ||
} | ||
|
||
handleQueryChange = () => { | ||
const { queryType, group, host, application, item } = this.state; | ||
const queryModel = { queryType, group, host, application, item }; | ||
this.props.onChange(queryModel, `Zabbix - ${queryType}`); | ||
} | ||
|
||
handleQueryTypeChange = (selectedItem: SelectableValue<VariableQueryTypes>) => { | ||
this.setState({ | ||
...this.state, | ||
selectedQueryType: selectedItem, | ||
queryType: selectedItem.value, | ||
}); | ||
|
||
const { group, host, application, item } = this.state; | ||
const queryType = selectedItem.value; | ||
const queryModel = { queryType, group, host, application, item }; | ||
this.props.onChange(queryModel, `Zabbix - ${queryType}`); | ||
} | ||
|
||
render() { | ||
const { selectedQueryType, legacyQuery, group, host, application, item } = this.state; | ||
|
||
return ( | ||
<> | ||
<div className="gf-form max-width-21"> | ||
<FormLabel width={10}>Query Type</FormLabel> | ||
<Select | ||
width={11} | ||
value={selectedQueryType} | ||
options={this.queryTypes} | ||
onChange={this.handleQueryTypeChange} | ||
/> | ||
</div> | ||
<div className="gf-form-inline"> | ||
<div className="gf-form max-width-30"> | ||
<FormLabel width={10}>Group</FormLabel> | ||
<ZabbixInput | ||
value={group} | ||
onChange={evt => this.handleQueryUpdate(evt, 'group')} | ||
onBlur={this.handleQueryChange} | ||
/> | ||
</div> | ||
{selectedQueryType.value !== VariableQueryTypes.Group && | ||
<div className="gf-form max-width-30"> | ||
<FormLabel width={10}>Host</FormLabel> | ||
<ZabbixInput | ||
value={host} | ||
onChange={evt => this.handleQueryUpdate(evt, 'host')} | ||
onBlur={this.handleQueryChange} | ||
/> | ||
</div> | ||
} | ||
</div> | ||
{(selectedQueryType.value === VariableQueryTypes.Application || | ||
selectedQueryType.value === VariableQueryTypes.Item) && | ||
<div className="gf-form-inline"> | ||
<div className="gf-form max-width-30"> | ||
<FormLabel width={10}>Application</FormLabel> | ||
<ZabbixInput | ||
value={application} | ||
onChange={evt => this.handleQueryUpdate(evt, 'application')} | ||
onBlur={this.handleQueryChange} | ||
/> | ||
</div> | ||
{selectedQueryType.value === VariableQueryTypes.Item && | ||
<div className="gf-form max-width-30"> | ||
<FormLabel width={10}>Item</FormLabel> | ||
<ZabbixInput | ||
value={item} | ||
onChange={evt => this.handleQueryUpdate(evt, 'item')} | ||
onBlur={this.handleQueryChange} | ||
/> | ||
</div> | ||
} | ||
</div> | ||
} | ||
|
||
{legacyQuery && | ||
<div className="gf-form"> | ||
<FormLabel width={10} tooltip="Original query string, read-only">Legacy Query</FormLabel> | ||
<Input | ||
value={legacyQuery} | ||
readOnly={true} | ||
/> | ||
</div> | ||
} | ||
</> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React, { FC } from 'react'; | ||
import { css, cx } from 'emotion'; | ||
import { Themeable, withTheme, Input, EventsWithValidation, ValidationEvents } from '@grafana/ui'; | ||
import { GrafanaTheme } from '@grafana/data'; | ||
import { isRegex, variableRegex } from '../utils'; | ||
|
||
const variablePattern = RegExp(`^${variableRegex.source}`); | ||
|
||
const getStyles = (theme: GrafanaTheme) => ({ | ||
inputRegex: css` | ||
color: ${theme.colors.orange} | ||
`, | ||
inputVariable: css` | ||
color: ${theme.colors.variable} | ||
`, | ||
}); | ||
|
||
const zabbixInputValidationEvents: ValidationEvents = { | ||
[EventsWithValidation.onBlur]: [ | ||
{ | ||
rule: value => { | ||
if (!value) { | ||
return true; | ||
} | ||
if (value.length > 1 && value[0] === '/') { | ||
if (value[value.length - 1] !== '/') { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}, | ||
errorMessage: 'Not a valid regex', | ||
}, | ||
{ | ||
rule: value => { | ||
if (value === '*') { | ||
return false; | ||
} | ||
return true; | ||
}, | ||
errorMessage: 'Wildcards not supported. Use /.*/ instead', | ||
}, | ||
], | ||
}; | ||
|
||
interface Props extends React.ComponentProps<typeof Input>, Themeable { | ||
} | ||
|
||
const UnthemedZabbixInput: FC<Props> = ({ theme, value, ref, validationEvents, ...restProps }) => { | ||
const styles = getStyles(theme); | ||
|
||
let inputClass; | ||
if (variablePattern.test(value as string)) { | ||
inputClass = styles.inputVariable; | ||
} | ||
if (isRegex(value)) { | ||
inputClass = styles.inputRegex; | ||
} | ||
|
||
return ( | ||
<Input | ||
className={inputClass} | ||
value={value} | ||
validationEvents={zabbixInputValidationEvents} | ||
{...restProps} | ||
/> | ||
); | ||
}; | ||
|
||
export const ZabbixInput = withTheme(UnthemedZabbixInput); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's currently an issue that's failing unit tests if we don't mock @grafana/ui and @grafana/runtime: grafana/grafana#20921
However there's also apparently an issue in master that's causing a different error entirely. Neither one works, but we're going to need 6.6 (or whatever release has the fix).
tl;dr Jest tests are broken because of Grafana packages, we can't fix it and need to wait for a good version of @grafana/ui
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha, ok, that makes sense. I'll try to investigate. It seems, I remember some build error in grafana/ui related to Table interface.