mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
rename template variables prop
This commit is contained in:
parent
ff762c213f
commit
96d65b55b6
@ -10,7 +10,7 @@ export interface Props {
|
||||
placeholder?: string;
|
||||
className?: string;
|
||||
groupName?: string;
|
||||
templateVariables?: any[];
|
||||
variables?: any[];
|
||||
}
|
||||
|
||||
interface State {
|
||||
@ -19,7 +19,7 @@ interface State {
|
||||
|
||||
export class StackdriverPicker extends React.Component<Props, State> {
|
||||
static defaultProps = {
|
||||
templateVariables: [],
|
||||
variables: [],
|
||||
options: [],
|
||||
groupName: 'Options',
|
||||
};
|
||||
@ -34,7 +34,7 @@ export class StackdriverPicker extends React.Component<Props, State> {
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps: Props) {
|
||||
if (nextProps.options.length > 0 || nextProps.templateVariables.length) {
|
||||
if (nextProps.options.length > 0 || nextProps.variables.length) {
|
||||
this.setState({ options: this.buildOptions(nextProps) });
|
||||
}
|
||||
}
|
||||
@ -44,10 +44,10 @@ export class StackdriverPicker extends React.Component<Props, State> {
|
||||
return nextProps.value !== this.props.value || !_.isEqual(nextOptions, this.state.options);
|
||||
}
|
||||
|
||||
buildOptions({ templateVariables = [], groupName = '', options }) {
|
||||
return templateVariables.length > 0
|
||||
buildOptions({ variables = [], groupName = '', options }) {
|
||||
return variables.length > 0
|
||||
? [
|
||||
this.getTemplateVariablesGroup(),
|
||||
this.getVariablesGroup(),
|
||||
{
|
||||
label: groupName,
|
||||
expanded: true,
|
||||
@ -57,10 +57,10 @@ export class StackdriverPicker extends React.Component<Props, State> {
|
||||
: options;
|
||||
}
|
||||
|
||||
getTemplateVariablesGroup() {
|
||||
getVariablesGroup() {
|
||||
return {
|
||||
label: 'Template Variables',
|
||||
options: this.props.templateVariables.map(v => ({
|
||||
options: this.props.variables.map(v => ({
|
||||
label: `$${v.name}`,
|
||||
value: `$${v.name}`,
|
||||
})),
|
||||
|
@ -8,7 +8,7 @@
|
||||
is-searchable="true"
|
||||
placeholder="'Select Aggregation'"
|
||||
className="'width-15'"
|
||||
template-variables="ctrl.templateSrv.variables"
|
||||
variables="ctrl.templateSrv.variables"
|
||||
group-name="'Aggregations'"
|
||||
></stackdriver-picker>
|
||||
</div>
|
||||
@ -31,7 +31,7 @@
|
||||
is-searchable="true"
|
||||
placeholder="'Select Alignment'"
|
||||
className="'width-15'"
|
||||
template-variables="ctrl.templateSrv.variables"
|
||||
variables="ctrl.templateSrv.variables"
|
||||
group-name="'Alignment Options'"
|
||||
></stackdriver-picker>
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
is-searchable="true"
|
||||
placeholder="'Select Alignment'"
|
||||
className="'width-15'"
|
||||
template-variables="ctrl.templateSrv.variables"
|
||||
variables="ctrl.templateSrv.variables"
|
||||
group-name="'Alignment Periods'"
|
||||
></stackdriver-picker>
|
||||
</div>
|
||||
|
@ -19,7 +19,7 @@
|
||||
onChange="ctrl.handleMetricTypeChange"
|
||||
value="ctrl.target.metricType"
|
||||
options="ctrl.getMetricsList()"
|
||||
template-variables="ctrl.templateSrv.variables"
|
||||
variables="ctrl.templateSrv.variables"
|
||||
group-name="'Metric Types'"
|
||||
is-searchable="true"
|
||||
placeholder="'Select Metric'"
|
||||
|
@ -71,7 +71,7 @@ export class StackdriverQueryCtrl extends QueryCtrl {
|
||||
'className',
|
||||
'placeholder',
|
||||
'groupName',
|
||||
['templateVariables', { watchDepth: 'reference' }],
|
||||
['variables', { watchDepth: 'reference' }],
|
||||
]);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user