Skip to content

Commit

Permalink
Chore: Let kbn util infer types (grafana#26907)
Browse files Browse the repository at this point in the history
* Chore: Let kbn util infer types

Type fixes where needed

* Address review comments + test fix

* Modify kbn method and property names to pascalCase
  • Loading branch information
zoltanbedi committed Aug 13, 2020
1 parent 6b1b52b commit 75e14aa
Show file tree
Hide file tree
Showing 23 changed files with 305 additions and 332 deletions.
2 changes: 1 addition & 1 deletion packages/grafana-data/src/types/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export interface QueryResultMeta {
* Legacy data source specific, should be moved to custom
* */
gmdMeta?: any[]; // used by cloudwatch
alignmentPeriod?: string; // used by cloud monitoring
alignmentPeriod?: number; // used by cloud monitoring
searchWords?: string[]; // used by log models and loki
limit?: number; // used by log models and loki
json?: boolean; // used to keep track of old json doc values
Expand Down
2 changes: 1 addition & 1 deletion packages/grafana-data/src/valueFormats/valueFormats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface ValueFormatCategory {
formats: ValueFormat[];
}

interface ValueFormatterIndex {
export interface ValueFormatterIndex {
[id: string]: ValueFormatter;
}

Expand Down
2 changes: 1 addition & 1 deletion public/app/core/directives/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function tip($compile: any) {
'<i class="grafana-tip fa fa-' +
(attrs.icon || 'question-circle') +
'" bs-tooltip="\'' +
kbn.addslashes(elem.text()) +
kbn.addSlashes(elem.text()) +
'\'"></i>';
_t = _t.replace(/{/g, '\\{').replace(/}/g, '\\}');
elem.replaceWith($compile(angular.element(_t))(scope));
Expand Down
2 changes: 1 addition & 1 deletion public/app/core/services/context_srv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class ContextSrv {
if (!config.minRefreshInterval) {
return true;
}
return kbn.interval_to_ms(interval) >= kbn.interval_to_ms(config.minRefreshInterval);
return kbn.intervalToMs(interval) >= kbn.intervalToMs(config.minRefreshInterval);
}

getValidInterval(interval: string) {
Expand Down
8 changes: 4 additions & 4 deletions public/app/core/utils/kbn.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,23 @@ describe('Chcek KBN value formats', () => {

describe('describe_interval', () => {
it('falls back to seconds if input is a number', () => {
expect(kbn.describe_interval('123')).toEqual({
expect(kbn.describeInterval('123')).toEqual({
sec: 1,
type: 's',
count: 123,
});
});

it('parses a valid time unt string correctly', () => {
expect(kbn.describe_interval('123h')).toEqual({
expect(kbn.describeInterval('123h')).toEqual({
sec: 3600,
type: 'h',
count: 123,
});
});

it('fails if input is invalid', () => {
expect(() => kbn.describe_interval('123xyz')).toThrow();
expect(() => kbn.describe_interval('xyz')).toThrow();
expect(() => kbn.describeInterval('123xyz')).toThrow();
expect(() => kbn.describeInterval('xyz')).toThrow();
});
});
Loading

0 comments on commit 75e14aa

Please sign in to comment.