diff --git a/.changeset/nasty-webs-repeat.md b/.changeset/nasty-webs-repeat.md new file mode 100644 index 0000000..a1f328d --- /dev/null +++ b/.changeset/nasty-webs-repeat.md @@ -0,0 +1,5 @@ +--- +'grafana-zabbix': minor +--- + +Add support for disabled items in Item variable type diff --git a/src/datasource/components/VariableQueryEditor.tsx b/src/datasource/components/VariableQueryEditor.tsx index c6086f3..ce2ead2 100644 --- a/src/datasource/components/VariableQueryEditor.tsx +++ b/src/datasource/components/VariableQueryEditor.tsx @@ -1,12 +1,11 @@ import React, { PureComponent } from 'react'; import { parseLegacyVariableQuery } from '../utils'; -import { SelectableValue } from '@grafana/data'; import { VariableQuery, VariableQueryData, VariableQueryProps, VariableQueryTypes } from '../types'; import { ZabbixInput } from './ZabbixInput'; -import { InlineField, InlineFieldRow, InlineFormLabel, Input, Select } from '@grafana/ui'; +import { Combobox, ComboboxOption, InlineField, InlineFieldRow, InlineFormLabel, Input, Switch } from '@grafana/ui'; export class ZabbixVariableQueryEditor extends PureComponent { - queryTypes: Array> = [ + queryTypes: Array> = [ { value: VariableQueryTypes.Group, label: 'Group' }, { value: VariableQueryTypes.Host, label: 'Host' }, { value: VariableQueryTypes.Application, label: 'Application' }, @@ -23,6 +22,7 @@ export class ZabbixVariableQueryEditor extends PureComponent { - const { queryType, group, host, application, itemTag, item } = this.state; - const queryModel = { queryType, group, host, application, itemTag, item }; + const { queryType, group, host, application, itemTag, item, showDisabledItems } = this.state; + const queryModel = { queryType, group, host, application, itemTag, item, showDisabledItems }; this.props.onChange(queryModel, `Zabbix - ${queryType}`); }; - handleQueryTypeChange = (selectedItem: SelectableValue) => { + handleQueryTypeChange = (selectedItem: ComboboxOption) => { this.setState({ ...this.state, selectedQueryType: selectedItem, queryType: selectedItem.value, }); - const { group, host, application, itemTag, item } = this.state; + const { group, host, application, itemTag, item, showDisabledItems } = this.state; const queryType = selectedItem.value; - const queryModel = { queryType, group, host, application, itemTag, item }; + const queryModel = { queryType, group, host, application, itemTag, item, showDisabledItems }; + this.props.onChange(queryModel, `Zabbix - ${queryType}`); + }; + + handleShowDisabledItemsChange = (evt: React.FormEvent) => { + const showDisabledItems = (evt.target as any).checked; + this.setState((prevState: VariableQueryData) => { + return { + ...prevState, + showDisabledItems: showDisabledItems, + }; + }); + + const { queryType, group, host, application, itemTag, item } = this.state; + const queryModel = { queryType, group, host, application, itemTag, item, showDisabledItems }; this.props.onChange(queryModel, `Zabbix - ${queryType}`); }; render() { - const { selectedQueryType, legacyQuery, group, host, application, itemTag, item } = this.state; + const { selectedQueryType, legacyQuery, group, host, application, itemTag, item, showDisabledItems } = this.state; const { datasource } = this.props; const supportsItemTags = datasource?.zabbix?.isZabbix54OrHigherSync() || false; return ( <> - -