mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
DataSources: minor typescript cleanups and comments (#16860)
* datasource interface cleanup * more types * use PluginInclude
This commit is contained in:
committed by
Torkel Ödegaard
parent
3e6104f45a
commit
ece4d2201c
@@ -105,7 +105,11 @@ export function deleteDataSource(): ThunkResult<void> {
|
||||
};
|
||||
}
|
||||
|
||||
export function nameExits(dataSources, name) {
|
||||
interface ItemWithName {
|
||||
name: string;
|
||||
}
|
||||
|
||||
export function nameExits(dataSources: ItemWithName[], name: string) {
|
||||
return (
|
||||
dataSources.filter(dataSource => {
|
||||
return dataSource.name.toLowerCase() === name.toLowerCase();
|
||||
@@ -113,7 +117,7 @@ export function nameExits(dataSources, name) {
|
||||
);
|
||||
}
|
||||
|
||||
export function findNewName(dataSources, name) {
|
||||
export function findNewName(dataSources: ItemWithName[], name: string) {
|
||||
// Need to loop through current data sources to make sure
|
||||
// the name doesn't exist
|
||||
while (nameExits(dataSources, name)) {
|
||||
@@ -143,18 +147,18 @@ function updateFrontendSettings() {
|
||||
});
|
||||
}
|
||||
|
||||
function nameHasSuffix(name) {
|
||||
function nameHasSuffix(name: string) {
|
||||
return name.endsWith('-', name.length - 1);
|
||||
}
|
||||
|
||||
function getLastDigit(name) {
|
||||
function getLastDigit(name: string) {
|
||||
return parseInt(name.slice(-1), 10);
|
||||
}
|
||||
|
||||
function incrementLastDigit(digit) {
|
||||
function incrementLastDigit(digit: number) {
|
||||
return isNaN(digit) ? 1 : digit + 1;
|
||||
}
|
||||
|
||||
function getNewName(name) {
|
||||
function getNewName(name: string) {
|
||||
return name.slice(0, name.length - 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user