Commit 786df792 by Erik Sundell

remove group name from select component. let the parent set group name instead

parent 03856b4e
......@@ -27,7 +27,6 @@ export function registerAngularDirectives() {
'isSearchable',
'className',
'placeholder',
'groupName',
['variables', { watchDepth: 'reference' }],
]);
}
......@@ -11,7 +11,6 @@ export interface Props {
value: string;
placeholder?: string;
className?: string;
groupName?: string;
variables?: Variable[];
}
......@@ -23,7 +22,6 @@ export class MetricSelect extends React.Component<Props, State> {
static defaultProps = {
variables: [],
options: [],
groupName: 'Options',
};
constructor(props) {
......@@ -46,15 +44,16 @@ export class MetricSelect extends React.Component<Props, State> {
return nextProps.value !== this.props.value || !_.isEqual(nextOptions, this.state.options);
}
buildOptions({ variables = [], groupName = '', options }) {
buildOptions({ variables = [], options }) {
return variables.length > 0
? [
this.getVariablesGroup(),
{
label: groupName,
expanded: true,
options,
},
// {
// label: groupName,
// expanded: true,
// options,
// },
...options,
]
: options;
}
......
......@@ -29,10 +29,16 @@ export class StackdriverAggregationCtrl {
constructor(private $scope, private templateSrv) {
this.$scope.ctrl = this;
this.target = $scope.target;
this.alignmentPeriods = alignmentPeriods.map(ap => ({
this.alignmentPeriods = [
{
label: 'Alignment Periods',
expanded: true,
options: alignmentPeriods.map(ap => ({
...ap,
label: ap.text,
}));
})),
},
];
this.setAggOptions();
this.setAlignOptions();
const self = this;
......@@ -46,28 +52,43 @@ export class StackdriverAggregationCtrl {
}
setAlignOptions() {
this.alignOptions = getAlignmentOptionsByMetric(this.target.valueType, this.target.metricKind).map(a => ({
const alignOptions = getAlignmentOptionsByMetric(this.target.valueType, this.target.metricKind).map(a => ({
...a,
label: a.text,
}));
if (!this.alignOptions.find(o => o.value === this.templateSrv.replace(this.target.aggregation.perSeriesAligner))) {
this.target.aggregation.perSeriesAligner = this.alignOptions.length > 0 ? this.alignOptions[0].value : '';
if (!alignOptions.find(o => o.value === this.templateSrv.replace(this.target.aggregation.perSeriesAligner))) {
this.target.aggregation.perSeriesAligner = alignOptions.length > 0 ? alignOptions[0].value : '';
}
this.alignOptions = [
{
label: 'Alignment Options',
expanded: true,
options: alignOptions,
},
];
}
setAggOptions() {
this.aggOptions = getAggregationOptionsByMetric(this.target.valueType, this.target.metricKind).map(a => ({
let aggOptions = getAggregationOptionsByMetric(this.target.valueType, this.target.metricKind).map(a => ({
...a,
label: a.text,
}));
if (!this.aggOptions.find(o => o.value === this.templateSrv.replace(this.target.aggregation.crossSeriesReducer))) {
if (!aggOptions.find(o => o.value === this.templateSrv.replace(this.target.aggregation.crossSeriesReducer))) {
this.deselectAggregationOption('REDUCE_NONE');
}
if (this.target.aggregation.groupBys.length > 0) {
this.aggOptions = this.aggOptions.filter(o => o.value !== 'REDUCE_NONE');
aggOptions = aggOptions.filter(o => o.value !== 'REDUCE_NONE');
this.deselectAggregationOption('REDUCE_NONE');
}
this.aggOptions = [
{
label: 'Aggregation Options',
expanded: true,
options: aggOptions,
},
];
}
handleAlignmentChange(value) {
......
......@@ -130,7 +130,14 @@ export class StackdriverFilterCtrl {
) {
this.target.metricType = metricsByService[0].value;
}
return metricsByService;
return [
{
label: 'Metrics',
expanded: true,
options: metricsByService,
},
];
}
async getLabels() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment