mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Typescript: A batch of implicit any fixes (#17590)
* Reduce noImplicitAny errors * Lower err count * Static version * Fix noImplicitAny * Table: moved type file
This commit is contained in:
committed by
Torkel Ödegaard
parent
2f00087a08
commit
8ffef57178
@@ -1,6 +1,9 @@
|
||||
import _ from 'lodash';
|
||||
import coreModule from 'app/core/core_module';
|
||||
import appEvents from 'app/core/app_events';
|
||||
import { BackendSrv } from 'app/core/services/backend_srv';
|
||||
import { ValidationSrv } from 'app/features/manage-dashboards';
|
||||
import { ContextSrv } from 'app/core/services/context_srv';
|
||||
|
||||
export class FolderPickerCtrl {
|
||||
initialTitle: string;
|
||||
@@ -24,7 +27,7 @@ export class FolderPickerCtrl {
|
||||
dashboardId?: number;
|
||||
|
||||
/** @ngInject */
|
||||
constructor(private backendSrv, private validationSrv, private contextSrv) {
|
||||
constructor(private backendSrv: BackendSrv, private validationSrv: ValidationSrv, private contextSrv: ContextSrv) {
|
||||
this.isEditor = this.contextSrv.isEditor;
|
||||
|
||||
if (!this.labelClass) {
|
||||
@@ -34,14 +37,14 @@ export class FolderPickerCtrl {
|
||||
this.loadInitialValue();
|
||||
}
|
||||
|
||||
getOptions(query) {
|
||||
getOptions(query: string) {
|
||||
const params = {
|
||||
query: query,
|
||||
query,
|
||||
type: 'dash-folder',
|
||||
permission: 'Edit',
|
||||
};
|
||||
|
||||
return this.backendSrv.get('api/search', params).then(result => {
|
||||
return this.backendSrv.get('api/search', params).then((result: any) => {
|
||||
if (
|
||||
this.isEditor &&
|
||||
(query === '' ||
|
||||
@@ -70,7 +73,7 @@ export class FolderPickerCtrl {
|
||||
});
|
||||
}
|
||||
|
||||
onFolderChange(option) {
|
||||
onFolderChange(option: { value: number; text: string }) {
|
||||
if (!option) {
|
||||
option = { value: 0, text: this.rootName };
|
||||
} else if (option.value === -1) {
|
||||
@@ -89,19 +92,19 @@ export class FolderPickerCtrl {
|
||||
.then(() => {
|
||||
this.hasValidationError = false;
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err: any) => {
|
||||
this.hasValidationError = true;
|
||||
this.validationError = err.message;
|
||||
});
|
||||
}
|
||||
|
||||
createFolder(evt) {
|
||||
createFolder(evt: any) {
|
||||
if (evt) {
|
||||
evt.stopPropagation();
|
||||
evt.preventDefault();
|
||||
}
|
||||
|
||||
return this.backendSrv.createFolder({ title: this.newFolderName }).then(result => {
|
||||
return this.backendSrv.createFolder({ title: this.newFolderName }).then((result: { title: string; id: number }) => {
|
||||
appEvents.emit('alert-success', ['Folder Created', 'OK']);
|
||||
|
||||
this.closeCreateFolder();
|
||||
@@ -110,7 +113,7 @@ export class FolderPickerCtrl {
|
||||
});
|
||||
}
|
||||
|
||||
cancelCreateFolder(evt) {
|
||||
cancelCreateFolder(evt: any) {
|
||||
if (evt) {
|
||||
evt.stopPropagation();
|
||||
evt.preventDefault();
|
||||
@@ -130,12 +133,13 @@ export class FolderPickerCtrl {
|
||||
}
|
||||
|
||||
private loadInitialValue() {
|
||||
const resetFolder = { text: this.initialTitle, value: null };
|
||||
const rootFolder = { text: this.rootName, value: 0 };
|
||||
const resetFolder: { text: string; value: any } = { text: this.initialTitle, value: null };
|
||||
const rootFolder: { text: string; value: any } = { text: this.rootName, value: 0 };
|
||||
|
||||
this.getOptions('').then(result => {
|
||||
let folder;
|
||||
this.getOptions('').then((result: any[]) => {
|
||||
let folder: { text: string; value: any };
|
||||
if (this.initialFolderId) {
|
||||
// @ts-ignore
|
||||
folder = _.find(result, { value: this.initialFolderId });
|
||||
} else if (this.enableReset && this.initialTitle && this.initialFolderId === null) {
|
||||
folder = resetFolder;
|
||||
|
||||
Reference in New Issue
Block a user