Chore: Let kbn util infer types (#26907)

* Chore: Let kbn util infer types

Type fixes where needed

* Address review comments + test fix

* Modify kbn method and property names to pascalCase
This commit is contained in:
Zoltán Bedi
2020-08-13 09:35:32 +02:00
committed by GitHub
parent 6b1b52b704
commit 75e14aa120
23 changed files with 310 additions and 337 deletions

View File

@@ -13,7 +13,7 @@ export interface Props {
templateVariableOptions: Array<SelectableValue<string>>;
alignmentPeriod: string;
perSeriesAligner: string;
usedAlignmentPeriod: string;
usedAlignmentPeriod?: number;
}
export const AlignmentPeriods: FC<Props> = ({
@@ -25,7 +25,9 @@ export const AlignmentPeriods: FC<Props> = ({
usedAlignmentPeriod,
}) => {
const alignment = alignOptions.find(ap => ap.value === templateSrv.replace(perSeriesAligner));
const formatAlignmentText = `${kbn.secondsToHms(usedAlignmentPeriod)} interval (${alignment ? alignment.text : ''})`;
const formatAlignmentText = usedAlignmentPeriod
? `${kbn.secondsToHms(usedAlignmentPeriod)} interval (${alignment ? alignment.text : ''})`
: '';
const options = alignmentPeriods.map(ap => ({
...ap,
label: ap.text,

View File

@@ -7,7 +7,7 @@ import { SelectableValue } from '@grafana/data';
export interface Props {
refId: string;
usedAlignmentPeriod: string;
usedAlignmentPeriod?: number;
variableOptionGroup: SelectableValue<string>;
onChange: (query: MetricQuery) => void;
onRunQuery: () => void;

View File

@@ -67,7 +67,7 @@ export class QueryEditor extends PureComponent<Props, State> {
const sloQuery = { ...defaultSLOQuery, ...query.sloQuery, projectName: datasource.getDefaultProject() };
const queryType = query.queryType || QueryType.METRICS;
const meta = this.props.data?.series.length ? this.props.data?.series[0].meta : {};
const usedAlignmentPeriod = meta?.alignmentPeriod as string;
const usedAlignmentPeriod = meta?.alignmentPeriod;
const variableOptionGroup = {
label: 'Template Variables',
expanded: false,

View File

@@ -7,7 +7,7 @@ import { SLOQuery } from '../types';
import CloudMonitoringDatasource from '../datasource';
export interface Props {
usedAlignmentPeriod: string;
usedAlignmentPeriod?: number;
variableOptionGroup: SelectableValue<string>;
onChange: (query: SLOQuery) => void;
onRunQuery: () => void;