Chore: More typescript improvements 💪 (#68699)

* fix some anys

* some canvas/geomap improvements

* some more panel type fixes

* just omit the type in TagOption
This commit is contained in:
Ashley Harrison
2023-05-22 11:53:58 +01:00
committed by GitHub
parent 623c014cda
commit e8ca3c0409
48 changed files with 187 additions and 298 deletions
+66 -200
View File
@@ -1458,9 +1458,6 @@ exports[`better eslint`] = {
"public/app/core/components/ForgottenPassword/ChangePassword.tsx:5381": [ "public/app/core/components/ForgottenPassword/ChangePassword.tsx:5381": [
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"] [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"]
], ],
"public/app/core/components/Login/LoginCtrl.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/core/components/Login/LoginForm.tsx:5381": [ "public/app/core/components/Login/LoginForm.tsx:5381": [
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"], [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"],
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"] [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"]
@@ -1474,89 +1471,82 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "5"], [0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Do not use any type assertions.", "6"], [0, 0, 0, "Do not use any type assertions.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"], [0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"], [0, 0, 0, "Do not use any type assertions.", "8"],
[0, 0, 0, "Do not use any type assertions.", "9"], [0, 0, 0, "Unexpected any. Specify a different type.", "9"],
[0, 0, 0, "Unexpected any. Specify a different type.", "10"], [0, 0, 0, "Do not use any type assertions.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"], [0, 0, 0, "Unexpected any. Specify a different type.", "11"],
[0, 0, 0, "Do not use any type assertions.", "12"], [0, 0, 0, "Do not use any type assertions.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"], [0, 0, 0, "Unexpected any. Specify a different type.", "13"],
[0, 0, 0, "Unexpected any. Specify a different type.", "14"], [0, 0, 0, "Do not use any type assertions.", "14"],
[0, 0, 0, "Do not use any type assertions.", "15"], [0, 0, 0, "Unexpected any. Specify a different type.", "15"],
[0, 0, 0, "Unexpected any. Specify a different type.", "16"], [0, 0, 0, "Do not use any type assertions.", "16"],
[0, 0, 0, "Do not use any type assertions.", "17"], [0, 0, 0, "Unexpected any. Specify a different type.", "17"],
[0, 0, 0, "Unexpected any. Specify a different type.", "18"], [0, 0, 0, "Do not use any type assertions.", "18"],
[0, 0, 0, "Do not use any type assertions.", "19"], [0, 0, 0, "Unexpected any. Specify a different type.", "19"],
[0, 0, 0, "Unexpected any. Specify a different type.", "20"], [0, 0, 0, "Do not use any type assertions.", "20"],
[0, 0, 0, "Do not use any type assertions.", "21"], [0, 0, 0, "Unexpected any. Specify a different type.", "21"],
[0, 0, 0, "Unexpected any. Specify a different type.", "22"], [0, 0, 0, "Do not use any type assertions.", "22"],
[0, 0, 0, "Do not use any type assertions.", "23"], [0, 0, 0, "Unexpected any. Specify a different type.", "23"],
[0, 0, 0, "Unexpected any. Specify a different type.", "24"], [0, 0, 0, "Do not use any type assertions.", "24"],
[0, 0, 0, "Do not use any type assertions.", "25"], [0, 0, 0, "Unexpected any. Specify a different type.", "25"],
[0, 0, 0, "Unexpected any. Specify a different type.", "26"], [0, 0, 0, "Do not use any type assertions.", "26"],
[0, 0, 0, "Do not use any type assertions.", "27"], [0, 0, 0, "Unexpected any. Specify a different type.", "27"],
[0, 0, 0, "Unexpected any. Specify a different type.", "28"], [0, 0, 0, "Do not use any type assertions.", "28"],
[0, 0, 0, "Do not use any type assertions.", "29"], [0, 0, 0, "Unexpected any. Specify a different type.", "29"],
[0, 0, 0, "Unexpected any. Specify a different type.", "30"], [0, 0, 0, "Unexpected any. Specify a different type.", "30"],
[0, 0, 0, "Do not use any type assertions.", "31"], [0, 0, 0, "Do not use any type assertions.", "31"],
[0, 0, 0, "Unexpected any. Specify a different type.", "32"], [0, 0, 0, "Unexpected any. Specify a different type.", "32"],
[0, 0, 0, "Unexpected any. Specify a different type.", "33"], [0, 0, 0, "Do not use any type assertions.", "33"],
[0, 0, 0, "Do not use any type assertions.", "34"], [0, 0, 0, "Unexpected any. Specify a different type.", "34"],
[0, 0, 0, "Unexpected any. Specify a different type.", "35"], [0, 0, 0, "Unexpected any. Specify a different type.", "35"],
[0, 0, 0, "Do not use any type assertions.", "36"], [0, 0, 0, "Do not use any type assertions.", "36"],
[0, 0, 0, "Unexpected any. Specify a different type.", "37"], [0, 0, 0, "Unexpected any. Specify a different type.", "37"],
[0, 0, 0, "Unexpected any. Specify a different type.", "38"], [0, 0, 0, "Do not use any type assertions.", "38"],
[0, 0, 0, "Do not use any type assertions.", "39"], [0, 0, 0, "Unexpected any. Specify a different type.", "39"],
[0, 0, 0, "Unexpected any. Specify a different type.", "40"], [0, 0, 0, "Unexpected any. Specify a different type.", "40"],
[0, 0, 0, "Do not use any type assertions.", "41"], [0, 0, 0, "Do not use any type assertions.", "41"],
[0, 0, 0, "Unexpected any. Specify a different type.", "42"], [0, 0, 0, "Unexpected any. Specify a different type.", "42"],
[0, 0, 0, "Unexpected any. Specify a different type.", "43"], [0, 0, 0, "Do not use any type assertions.", "43"],
[0, 0, 0, "Do not use any type assertions.", "44"], [0, 0, 0, "Unexpected any. Specify a different type.", "44"],
[0, 0, 0, "Unexpected any. Specify a different type.", "45"], [0, 0, 0, "Unexpected any. Specify a different type.", "45"],
[0, 0, 0, "Do not use any type assertions.", "46"], [0, 0, 0, "Do not use any type assertions.", "46"],
[0, 0, 0, "Unexpected any. Specify a different type.", "47"], [0, 0, 0, "Unexpected any. Specify a different type.", "47"],
[0, 0, 0, "Unexpected any. Specify a different type.", "48"], [0, 0, 0, "Do not use any type assertions.", "48"],
[0, 0, 0, "Do not use any type assertions.", "49"], [0, 0, 0, "Unexpected any. Specify a different type.", "49"],
[0, 0, 0, "Unexpected any. Specify a different type.", "50"], [0, 0, 0, "Unexpected any. Specify a different type.", "50"],
[0, 0, 0, "Do not use any type assertions.", "51"], [0, 0, 0, "Do not use any type assertions.", "51"],
[0, 0, 0, "Unexpected any. Specify a different type.", "52"], [0, 0, 0, "Unexpected any. Specify a different type.", "52"],
[0, 0, 0, "Unexpected any. Specify a different type.", "53"], [0, 0, 0, "Do not use any type assertions.", "53"],
[0, 0, 0, "Do not use any type assertions.", "54"], [0, 0, 0, "Unexpected any. Specify a different type.", "54"],
[0, 0, 0, "Unexpected any. Specify a different type.", "55"], [0, 0, 0, "Unexpected any. Specify a different type.", "55"],
[0, 0, 0, "Do not use any type assertions.", "56"], [0, 0, 0, "Do not use any type assertions.", "56"],
[0, 0, 0, "Unexpected any. Specify a different type.", "57"], [0, 0, 0, "Unexpected any. Specify a different type.", "57"],
[0, 0, 0, "Unexpected any. Specify a different type.", "58"], [0, 0, 0, "Do not use any type assertions.", "58"],
[0, 0, 0, "Do not use any type assertions.", "59"], [0, 0, 0, "Unexpected any. Specify a different type.", "59"],
[0, 0, 0, "Unexpected any. Specify a different type.", "60"], [0, 0, 0, "Unexpected any. Specify a different type.", "60"],
[0, 0, 0, "Do not use any type assertions.", "61"], [0, 0, 0, "Do not use any type assertions.", "61"],
[0, 0, 0, "Unexpected any. Specify a different type.", "62"], [0, 0, 0, "Unexpected any. Specify a different type.", "62"],
[0, 0, 0, "Unexpected any. Specify a different type.", "63"], [0, 0, 0, "Do not use any type assertions.", "63"],
[0, 0, 0, "Do not use any type assertions.", "64"], [0, 0, 0, "Unexpected any. Specify a different type.", "64"],
[0, 0, 0, "Unexpected any. Specify a different type.", "65"], [0, 0, 0, "Unexpected any. Specify a different type.", "65"],
[0, 0, 0, "Do not use any type assertions.", "66"], [0, 0, 0, "Do not use any type assertions.", "66"],
[0, 0, 0, "Unexpected any. Specify a different type.", "67"], [0, 0, 0, "Unexpected any. Specify a different type.", "67"],
[0, 0, 0, "Unexpected any. Specify a different type.", "68"], [0, 0, 0, "Do not use any type assertions.", "68"],
[0, 0, 0, "Do not use any type assertions.", "69"], [0, 0, 0, "Unexpected any. Specify a different type.", "69"],
[0, 0, 0, "Unexpected any. Specify a different type.", "70"], [0, 0, 0, "Unexpected any. Specify a different type.", "70"],
[0, 0, 0, "Do not use any type assertions.", "71"], [0, 0, 0, "Do not use any type assertions.", "71"],
[0, 0, 0, "Unexpected any. Specify a different type.", "72"], [0, 0, 0, "Unexpected any. Specify a different type.", "72"],
[0, 0, 0, "Unexpected any. Specify a different type.", "73"], [0, 0, 0, "Do not use any type assertions.", "73"],
[0, 0, 0, "Do not use any type assertions.", "74"], [0, 0, 0, "Unexpected any. Specify a different type.", "74"],
[0, 0, 0, "Unexpected any. Specify a different type.", "75"], [0, 0, 0, "Unexpected any. Specify a different type.", "75"],
[0, 0, 0, "Do not use any type assertions.", "76"], [0, 0, 0, "Do not use any type assertions.", "76"],
[0, 0, 0, "Unexpected any. Specify a different type.", "77"], [0, 0, 0, "Unexpected any. Specify a different type.", "77"],
[0, 0, 0, "Unexpected any. Specify a different type.", "78"], [0, 0, 0, "Do not use any type assertions.", "78"],
[0, 0, 0, "Do not use any type assertions.", "79"], [0, 0, 0, "Unexpected any. Specify a different type.", "79"],
[0, 0, 0, "Unexpected any. Specify a different type.", "80"], [0, 0, 0, "Do not use any type assertions.", "80"],
[0, 0, 0, "Do not use any type assertions.", "81"], [0, 0, 0, "Unexpected any. Specify a different type.", "81"],
[0, 0, 0, "Unexpected any. Specify a different type.", "82"], [0, 0, 0, "Do not use any type assertions.", "82"],
[0, 0, 0, "Do not use any type assertions.", "83"], [0, 0, 0, "Unexpected any. Specify a different type.", "83"]
[0, 0, 0, "Unexpected any. Specify a different type.", "84"],
[0, 0, 0, "Do not use any type assertions.", "85"],
[0, 0, 0, "Unexpected any. Specify a different type.", "86"]
],
"public/app/core/components/PanelTypeFilter/PanelTypeFilter.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
], ],
"public/app/core/components/PasswordField/PasswordField.tsx:5381": [ "public/app/core/components/PasswordField/PasswordField.tsx:5381": [
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"] [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"]
@@ -1577,40 +1567,25 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "6"] [0, 0, 0, "Unexpected any. Specify a different type.", "6"]
], ],
"public/app/core/components/TagFilter/TagOption.tsx:5381": [ "public/app/core/components/TagFilter/TagOption.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/core/components/TimelineChart/TimelineChart.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
], ],
"public/app/core/components/connectWithCleanUp.tsx:5381": [ "public/app/core/components/connectWithCleanUp.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"] [0, 0, 0, "Do not use any type assertions.", "1"]
], ],
"public/app/core/components/modals/AngularModalProxy.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/core/navigation/GrafanaRoute.test.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/core/navigation/__mocks__/routeProps.ts:5381": [ "public/app/core/navigation/__mocks__/routeProps.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"]
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
], ],
"public/app/core/navigation/types.ts:5381": [ "public/app/core/navigation/types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
], ],
"public/app/core/reducers/root.ts:5381": [ "public/app/core/reducers/root.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [0, 0, 0, "Unexpected any. Specify a different type.", "1"]
], ],
"public/app/core/services/ResponseQueue.ts:5381": [ "public/app/core/services/ResponseQueue.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
], ],
"public/app/core/services/backend_srv.ts:5381": [ "public/app/core/services/backend_srv.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@@ -1633,10 +1608,8 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "17"] [0, 0, 0, "Unexpected any. Specify a different type.", "17"]
], ],
"public/app/core/services/context_srv.ts:5381": [ "public/app/core/services/context_srv.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"]
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
], ],
"public/app/core/services/echo/backends/analytics/ApplicationInsightsBackend.ts:5381": [ "public/app/core/services/echo/backends/analytics/ApplicationInsightsBackend.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
@@ -1681,9 +1654,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [0, 0, 0, "Unexpected any. Specify a different type.", "1"]
], ],
"public/app/core/utils/acl.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/core/utils/connectWithReduxStore.tsx:5381": [ "public/app/core/utils/connectWithReduxStore.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"],
@@ -1706,13 +1676,8 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "3"], [0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"], [0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"], [0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Do not use any type assertions.", "6"], [0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"], [0, 0, 0, "Unexpected any. Specify a different type.", "7"]
[0, 0, 0, "Do not use any type assertions.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
[0, 0, 0, "Unexpected any. Specify a different type.", "12"]
], ],
"public/app/core/utils/fetch.ts:5381": [ "public/app/core/utils/fetch.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
@@ -1728,16 +1693,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "10"] [0, 0, 0, "Unexpected any. Specify a different type.", "10"]
], ],
"public/app/core/utils/flatten.ts:5381": [ "public/app/core/utils/flatten.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"]
],
"public/app/core/utils/kbn.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
], ],
"public/app/core/utils/object.ts:5381": [ "public/app/core/utils/object.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
@@ -2078,25 +2034,9 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "3"], [0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"] [0, 0, 0, "Unexpected any. Specify a different type.", "4"]
], ],
"public/app/features/canvas/elements/droneFront.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/features/canvas/elements/droneSide.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/features/canvas/elements/droneTop.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/features/canvas/elements/notFound.tsx:5381": [ "public/app/features/canvas/elements/notFound.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
"public/app/features/canvas/elements/windTurbine.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/features/canvas/runtime/element.tsx:5381": [ "public/app/features/canvas/runtime/element.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [0, 0, 0, "Do not use any type assertions.", "1"],
@@ -2192,9 +2132,6 @@ exports[`better eslint`] = {
"public/app/features/dashboard/components/DashboardRow/DashboardRow.test.tsx:5381": [ "public/app/features/dashboard/components/DashboardRow/DashboardRow.test.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
"public/app/features/dashboard/components/HelpWizard/randomizer.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/features/dashboard/components/Inspector/PanelInspector.tsx:5381": [ "public/app/features/dashboard/components/Inspector/PanelInspector.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [0, 0, 0, "Do not use any type assertions.", "0"]
], ],
@@ -2246,9 +2183,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"], [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"],
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"] [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"]
], ],
"public/app/features/dashboard/components/SaveDashboard/SaveDashboardErrorProxy.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.test.tsx:5381": [ "public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.test.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
@@ -2259,12 +2193,10 @@ exports[`better eslint`] = {
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "3"] [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "3"]
], ],
"public/app/features/dashboard/components/SaveDashboard/types.ts:5381": [ "public/app/features/dashboard/components/SaveDashboard/types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
], ],
"public/app/features/dashboard/components/SaveDashboard/useDashboardSave.tsx:5381": [ "public/app/features/dashboard/components/SaveDashboard/useDashboardSave.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
], ],
"public/app/features/dashboard/components/ShareModal/ShareExport.tsx:5381": [ "public/app/features/dashboard/components/ShareModal/ShareExport.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@@ -2284,12 +2216,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "3"], [0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "4"] [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "4"]
], ],
"public/app/features/dashboard/components/VersionHistory/__mocks__/dashboardHistoryMocks.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
],
"public/app/features/dashboard/components/VersionHistory/useDashboardRestore.tsx:5381": [ "public/app/features/dashboard/components/VersionHistory/useDashboardRestore.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [0, 0, 0, "Unexpected any. Specify a different type.", "1"]
@@ -2314,9 +2240,6 @@ exports[`better eslint`] = {
"public/app/features/dashboard/dashgrid/DashboardPanel.tsx:5381": [ "public/app/features/dashboard/dashgrid/DashboardPanel.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
"public/app/features/dashboard/dashgrid/LazyLoader.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/features/dashboard/dashgrid/PanelChromeAngular.tsx:5381": [ "public/app/features/dashboard/dashgrid/PanelChromeAngular.tsx:5381": [
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"] [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"]
], ],
@@ -2337,24 +2260,14 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"], [0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"], [0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"], [0, 0, 0, "Unexpected any. Specify a different type.", "4"]
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"]
],
"public/app/features/dashboard/services/DashboardSrv.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
"public/app/features/dashboard/services/PublicDashboardDataSource.ts:5381": [ "public/app/features/dashboard/services/PublicDashboardDataSource.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [0, 0, 0, "Do not use any type assertions.", "0"]
], ],
"public/app/features/dashboard/services/TimeSrv.ts:5381": [ "public/app/features/dashboard/services/TimeSrv.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"]
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
], ],
"public/app/features/dashboard/state/DashboardMigrator.test.ts:5381": [ "public/app/features/dashboard/state/DashboardMigrator.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@@ -5072,28 +4985,15 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "10"], [0, 0, 0, "Do not use any type assertions.", "10"],
[0, 0, 0, "Do not use any type assertions.", "11"] [0, 0, 0, "Do not use any type assertions.", "11"]
], ],
"public/app/plugins/panel/canvas/CanvasPanel.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
],
"public/app/plugins/panel/canvas/InlineEdit.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/panel/canvas/InlineEditBody.tsx:5381": [ "public/app/plugins/panel/canvas/InlineEditBody.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"], [0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"], [0, 0, 0, "Do not use any type assertions.", "3"],
[0, 0, 0, "Do not use any type assertions.", "4"], [0, 0, 0, "Unexpected any. Specify a different type.", "4"]
[0, 0, 0, "Unexpected any. Specify a different type.", "5"]
], ],
"public/app/plugins/panel/canvas/editor/APIEditor.tsx:5381": [ "public/app/plugins/panel/canvas/editor/APIEditor.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
], ],
"public/app/plugins/panel/canvas/editor/PlacementEditor.tsx:5381": [ "public/app/plugins/panel/canvas/editor/PlacementEditor.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@@ -5117,9 +5017,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "4"], [0, 0, 0, "Do not use any type assertions.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"] [0, 0, 0, "Unexpected any. Specify a different type.", "5"]
], ],
"public/app/plugins/panel/canvas/utils.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/plugins/panel/dashlist/module.tsx:5381": [ "public/app/plugins/panel/dashlist/module.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
@@ -5141,9 +5038,7 @@ exports[`better eslint`] = {
"public/app/plugins/panel/geomap/components/MarkersLegend.tsx:5381": [ "public/app/plugins/panel/geomap/components/MarkersLegend.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"], [0, 0, 0, "Unexpected any. Specify a different type.", "2"]
[0, 0, 0, "Do not use any type assertions.", "3"],
[0, 0, 0, "Do not use any type assertions.", "4"]
], ],
"public/app/plugins/panel/geomap/components/MeasureVectorLayer.ts:5381": [ "public/app/plugins/panel/geomap/components/MeasureVectorLayer.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
@@ -5172,9 +5067,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"] [0, 0, 0, "Do not use any type assertions.", "1"]
], ],
"public/app/plugins/panel/geomap/layers/basemaps/carto.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/plugins/panel/geomap/layers/basemaps/esri.ts:5381": [ "public/app/plugins/panel/geomap/layers/basemaps/esri.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [0, 0, 0, "Do not use any type assertions.", "0"]
], ],
@@ -5187,10 +5079,7 @@ exports[`better eslint`] = {
], ],
"public/app/plugins/panel/geomap/migrations.ts:5381": [ "public/app/plugins/panel/geomap/migrations.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"]
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
], ],
"public/app/plugins/panel/geomap/utils/layers.ts:5381": [ "public/app/plugins/panel/geomap/utils/layers.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@@ -5200,8 +5089,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
"public/app/plugins/panel/geomap/utils/tootltip.ts:5381": [ "public/app/plugins/panel/geomap/utils/tootltip.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"]
[0, 0, 0, "Do not use any type assertions.", "1"]
], ],
"public/app/plugins/panel/graph/GraphContextMenuCtrl.ts:5381": [ "public/app/plugins/panel/graph/GraphContextMenuCtrl.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@@ -5546,11 +5434,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "2"], [0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"] [0, 0, 0, "Unexpected any. Specify a different type.", "3"]
], ],
"public/app/plugins/panel/heatmap/HeatmapHoverView.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
],
"public/app/plugins/panel/heatmap/HeatmapPanel.tsx:5381": [ "public/app/plugins/panel/heatmap/HeatmapPanel.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [0, 0, 0, "Do not use any type assertions.", "1"],
@@ -5595,8 +5478,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "15"], [0, 0, 0, "Do not use any type assertions.", "15"],
[0, 0, 0, "Do not use any type assertions.", "16"], [0, 0, 0, "Do not use any type assertions.", "16"],
[0, 0, 0, "Do not use any type assertions.", "17"], [0, 0, 0, "Do not use any type assertions.", "17"],
[0, 0, 0, "Do not use any type assertions.", "18"], [0, 0, 0, "Do not use any type assertions.", "18"]
[0, 0, 0, "Do not use any type assertions.", "19"]
], ],
"public/app/plugins/panel/histogram/Histogram.tsx:5381": [ "public/app/plugins/panel/histogram/Histogram.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@@ -5621,9 +5503,7 @@ exports[`better eslint`] = {
"public/app/plugins/panel/live/LivePanel.tsx:5381": [ "public/app/plugins/panel/live/LivePanel.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"], [0, 0, 0, "Do not use any type assertions.", "2"]
[0, 0, 0, "Do not use any type assertions.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
], ],
"public/app/plugins/panel/live/types.ts:5381": [ "public/app/plugins/panel/live/types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@@ -5653,12 +5533,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"] [0, 0, 0, "Do not use any type assertions.", "1"]
], ],
"public/app/plugins/panel/nodeGraph/usePanning.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"]
],
"public/app/plugins/panel/nodeGraph/utils.ts:5381": [ "public/app/plugins/panel/nodeGraph/utils.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"],
@@ -5839,12 +5713,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "2"], [0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"] [0, 0, 0, "Do not use any type assertions.", "3"]
], ],
"public/app/plugins/panel/timeseries/SpanNullsEditor.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
],
"public/app/plugins/panel/timeseries/migrations.ts:5381": [ "public/app/plugins/panel/timeseries/migrations.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [0, 0, 0, "Do not use any type assertions.", "1"],
@@ -5874,12 +5742,10 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "0"] [0, 0, 0, "Do not use any type assertions.", "0"]
], ],
"public/app/plugins/panel/timeseries/suggestions.ts:5381": [ "public/app/plugins/panel/timeseries/suggestions.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
], ],
"public/app/plugins/panel/trend/suggestions.ts:5381": [ "public/app/plugins/panel/trend/suggestions.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
], ],
"public/app/plugins/panel/xychart/AutoEditor.tsx:5381": [ "public/app/plugins/panel/xychart/AutoEditor.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@@ -240,6 +240,7 @@ export class AsyncSelect<T> extends PureComponent<AsyncProps<T>> {
value={value} value={value}
//@ts-expect-error //@ts-expect-error
getOptionLabel={getOptionLabel} getOptionLabel={getOptionLabel}
//@ts-expect-error
getOptionValue={getOptionValue} getOptionValue={getOptionValue}
menuShouldScrollIntoView={false} menuShouldScrollIntoView={false}
onChange={onChange} onChange={onChange}
@@ -37,7 +37,7 @@ export interface SelectCommonProps<T> {
/** Function for formatting the text that is displayed when creating a new value*/ /** Function for formatting the text that is displayed when creating a new value*/
formatCreateLabel?: (input: string) => string; formatCreateLabel?: (input: string) => string;
getOptionLabel?: (item: SelectableValue<T>) => React.ReactNode; getOptionLabel?: (item: SelectableValue<T>) => React.ReactNode;
getOptionValue?: (item: SelectableValue<T>) => string; getOptionValue?: (item: SelectableValue<T>) => T | undefined;
hideSelectedOptions?: boolean; hideSelectedOptions?: boolean;
inputValue?: string; inputValue?: string;
invalid?: boolean; invalid?: boolean;
@@ -5,6 +5,8 @@ import { getBackendSrv } from '@grafana/runtime';
import appEvents from 'app/core/app_events'; import appEvents from 'app/core/app_events';
import config from 'app/core/config'; import config from 'app/core/config';
import { LoginDTO } from './types';
const isOauthEnabled = () => { const isOauthEnabled = () => {
return !!config.oauth && Object.keys(config.oauth).length > 0; return !!config.oauth && Object.keys(config.oauth).length > 0;
}; };
@@ -38,7 +40,7 @@ interface State {
} }
export class LoginCtrl extends PureComponent<Props, State> { export class LoginCtrl extends PureComponent<Props, State> {
result: any = {}; result: LoginDTO | undefined;
constructor(props: Props) { constructor(props: Props) {
super(props); super(props);
@@ -87,7 +89,7 @@ export class LoginCtrl extends PureComponent<Props, State> {
}); });
getBackendSrv() getBackendSrv()
.post('/login', formModel) .post<LoginDTO>('/login', formModel)
.then((result) => { .then((result) => {
this.result = result; this.result = result;
if (formModel.password !== 'admin' || config.ldapEnabled || config.authProxyEnabled) { if (formModel.password !== 'admin' || config.ldapEnabled || config.authProxyEnabled) {
@@ -112,7 +114,7 @@ export class LoginCtrl extends PureComponent<Props, State> {
toGrafana = () => { toGrafana = () => {
// Use window.location.href to force page reload // Use window.location.href to force page reload
if (this.result.redirectUrl) { if (this.result?.redirectUrl) {
if (config.appSubUrl !== '' && !this.result.redirectUrl.startsWith(config.appSubUrl)) { if (config.appSubUrl !== '' && !this.result.redirectUrl.startsWith(config.appSubUrl)) {
window.location.assign(config.appSubUrl + this.result.redirectUrl); window.location.assign(config.appSubUrl + this.result.redirectUrl);
} else { } else {
@@ -0,0 +1,4 @@
export interface LoginDTO {
message: string;
redirectUrl: string;
}
@@ -87,21 +87,21 @@ export const getAllOptionEditors = () => {
}, },
}; };
const select: StandardEditorsRegistryItem<any> = { const select: StandardEditorsRegistryItem = {
id: 'select', id: 'select',
name: 'Select', name: 'Select',
description: 'Allows option selection', description: 'Allows option selection',
editor: SelectValueEditor as any, editor: SelectValueEditor as any,
}; };
const multiSelect: StandardEditorsRegistryItem<any> = { const multiSelect: StandardEditorsRegistryItem = {
id: 'multi-select', id: 'multi-select',
name: 'Multi select', name: 'Multi select',
description: 'Allows for multiple option selection', description: 'Allows for multiple option selection',
editor: MultiSelectValueEditor as any, editor: MultiSelectValueEditor as any,
}; };
const radio: StandardEditorsRegistryItem<any> = { const radio: StandardEditorsRegistryItem = {
id: 'radio', id: 'radio',
name: 'Radio', name: 'Radio',
description: 'Allows option selection', description: 'Allows option selection',
@@ -32,8 +32,8 @@ export const PanelTypeFilter = ({ onChange: propsOnChange, maxMenuHeight }: Prop
const selectOptions = { const selectOptions = {
defaultOptions: true, defaultOptions: true,
getOptionLabel: (i: any) => i.label, getOptionLabel: (i: SelectableValue<PanelPluginMeta>) => i.label,
getOptionValue: (i: any) => i.value, getOptionValue: (i: SelectableValue<PanelPluginMeta>) => i.value,
noOptionsMessage: 'No Panel types found', noOptionsMessage: 'No Panel types found',
placeholder: 'Filter by type', placeholder: 'Filter by type',
maxMenuHeight, maxMenuHeight,
@@ -56,7 +56,7 @@ export const PanelTypeFilter = ({ onChange: propsOnChange, maxMenuHeight }: Prop
Clear types Clear types
</Button> </Button>
)} )}
<MultiSelect {...selectOptions} prefix={<Icon name="filter" />} aria-label="Panel Type filter" /> <MultiSelect<PanelPluginMeta> {...selectOptions} prefix={<Icon name="filter" />} aria-label="Panel Type filter" />
</div> </div>
); );
}; };
@@ -7,7 +7,7 @@ import { useStyles2 } from '@grafana/ui';
import { TagBadge } from './TagBadge'; import { TagBadge } from './TagBadge';
export const TagOption = ({ data, className, label, isFocused, innerProps }: OptionProps<any, any>) => { export const TagOption = ({ data, className, label, isFocused, innerProps }: OptionProps<any>) => {
const styles = useStyles2(getStyles); const styles = useStyles2(getStyles);
return ( return (
@@ -32,7 +32,7 @@ const propsToDiff = ['rowHeight', 'colWidth', 'showValue', 'mergeValues', 'align
export class TimelineChart extends React.Component<TimelineProps> { export class TimelineChart extends React.Component<TimelineProps> {
declare context: React.ContextType<typeof PanelContextRoot>; declare context: React.ContextType<typeof PanelContextRoot>;
static contextType = PanelContextRoot; static contextType = PanelContextRoot;
panelContext: PanelContext = {} as PanelContext; panelContext: PanelContext | undefined;
getValueColor = (frameIdx: number, fieldIdx: number, value: unknown) => { getValueColor = (frameIdx: number, fieldIdx: number, value: unknown) => {
const field = this.props.frames[frameIdx].fields[fieldIdx]; const field = this.props.frames[frameIdx].fields[fieldIdx];
@@ -7,7 +7,7 @@ import { connectWithProvider } from '../../utils/connectWithReduxStore';
/** /**
* Component that enables rendering React modals from Angular * Component that enables rendering React modals from Angular
*/ */
export const AngularModalProxy = connectWithProvider((props: any) => { export const AngularModalProxy = connectWithProvider((props: Record<string, unknown>) => {
return ( return (
<> <>
<ModalsProvider {...props}> <ModalsProvider {...props}>
@@ -9,6 +9,7 @@ import { setEchoSrv } from '@grafana/runtime';
import { Echo } from '../services/echo/Echo'; import { Echo } from '../services/echo/Echo';
import { GrafanaRoute, Props } from './GrafanaRoute'; import { GrafanaRoute, Props } from './GrafanaRoute';
import { GrafanaRouteComponentProps } from './types';
function setup(overrides: Partial<Props>) { function setup(overrides: Partial<Props>) {
const props: Props = { const props: Props = {
@@ -35,14 +36,14 @@ describe('GrafanaRoute', () => {
}); });
it('Parses search', () => { it('Parses search', () => {
let capturedProps: any; let capturedProps: GrafanaRouteComponentProps;
const PageComponent = (props: any) => { const PageComponent = (props: GrafanaRouteComponentProps) => {
capturedProps = props; capturedProps = props;
return <div />; return <div />;
}; };
setup({ route: { component: PageComponent, path: '' } }); setup({ route: { component: PageComponent, path: '' } });
expect(capturedProps.queryParams.query).toBe('hello'); expect(capturedProps!.queryParams.query).toBe('hello');
}); });
it('Shows loading on lazy load', async () => { it('Shows loading on lazy load', async () => {
@@ -9,10 +9,16 @@ export function getRouteComponentProps<T extends {} = {}, Q extends Record<strin
const defaults: GrafanaRouteComponentProps<T, Q> = { const defaults: GrafanaRouteComponentProps<T, Q> = {
history: createMemoryHistory(), history: createMemoryHistory(),
location: { location: {
hash: '',
pathname: '',
state: {},
search: '', search: '',
} as any, },
match: { params: {} } as any, match: { params: {} } as any,
route: {} as any, route: {
path: '',
component: () => null,
},
queryParams: {} as any, queryParams: {} as any,
}; };
+1 -1
View File
@@ -12,7 +12,7 @@ export type GrafanaRouteComponent<T extends {} = any> = React.ComponentType<Graf
export interface RouteDescriptor { export interface RouteDescriptor {
path: string; path: string;
component: GrafanaRouteComponent<any>; component: GrafanaRouteComponent;
roles?: () => string[]; roles?: () => string[];
pageClass?: string; pageClass?: string;
/** Can be used like an id for the route if the same component is used by many routes */ /** Can be used like an id for the route if the same component is used by many routes */
+2 -2
View File
@@ -16,8 +16,8 @@ interface FetchResponsesEntry<T> {
} }
export class ResponseQueue { export class ResponseQueue {
private queue: Subject<FetchWorkEntry> = new Subject<FetchWorkEntry>(); // internal stream for requests that are to be executed private queue = new Subject<FetchWorkEntry>(); // internal stream for requests that are to be executed
private responses: Subject<FetchResponsesEntry<any>> = new Subject<FetchResponsesEntry<any>>(); // external stream with responses from fetch private responses = new Subject<FetchResponsesEntry<any>>(); // external stream with responses from fetch
constructor(fetchQueue: FetchQueue, fetch: <T>(options: BackendSrvRequest) => Observable<FetchResponse<T>>) { constructor(fetchQueue: FetchQueue, fetch: <T>(options: BackendSrvRequest) => Observable<FetchResponse<T>>) {
// This will create an implicit live subscription for as long as this class lives. // This will create an implicit live subscription for as long as this class lives.
-2
View File
@@ -63,8 +63,6 @@ export class User implements Omit<CurrentUserInternal, 'lightTheme'> {
} }
export class ContextSrv { export class ContextSrv {
pinned: any;
version: any;
user: User; user: User;
isSignedIn: boolean; isSignedIn: boolean;
isGrafanaAdmin: boolean; isGrafanaAdmin: boolean;
+1 -1
View File
@@ -5,7 +5,7 @@ export function processAclItems(items: DashboardAclDTO[]): DashboardAcl[] {
} }
function processAclItem(dto: DashboardAclDTO): DashboardAcl { function processAclItem(dto: DashboardAclDTO): DashboardAcl {
const item = dto as DashboardAcl; const item: DashboardAcl = dto;
item.sortRank = 0; item.sortRank = 0;
+3 -3
View File
@@ -195,7 +195,7 @@ export const safeParseJson = (text?: string): any | undefined => {
} }
}; };
export const safeStringifyValue = (value: any, space?: number) => { export const safeStringifyValue = (value: unknown, space?: number) => {
if (value === undefined || value === null) { if (value === undefined || value === null) {
return ''; return '';
} }
@@ -469,8 +469,8 @@ export const getTimeRangeFromUrl = (
}; };
return { return {
from: dateMath.parse(raw.from, false, timeZone as any)!, from: dateMath.parse(raw.from, false, timeZone)!,
to: dateMath.parse(raw.to, true, timeZone as any)!, to: dateMath.parse(raw.to, true, timeZone)!,
raw, raw,
}; };
}; };
+5 -2
View File
@@ -1,13 +1,16 @@
// Copyright (c) 2014, Hugh Kennedy // Copyright (c) 2014, Hugh Kennedy
// Based on code from https://github.com/hughsk/flat/blob/master/index.js // Based on code from https://github.com/hughsk/flat/blob/master/index.js
// //
export default function flatten(target: object, opts?: { delimiter?: any; maxDepth?: any; safe?: any }): any { export default function flatten(
target: object,
opts?: { delimiter?: string; maxDepth?: number; safe?: boolean }
): Record<string, unknown> {
opts = opts || {}; opts = opts || {};
const delimiter = opts.delimiter || '.'; const delimiter = opts.delimiter || '.';
let maxDepth = opts.maxDepth || 3; let maxDepth = opts.maxDepth || 3;
let currentDepth = 1; let currentDepth = 1;
const output: any = {}; const output: Record<string, unknown> = {};
function step(object: any, prev: string | null) { function step(object: any, prev: string | null) {
Object.keys(object).forEach((key) => { Object.keys(object).forEach((key) => {
+3 -2
View File
@@ -12,8 +12,9 @@ import {
escapeRegex, escapeRegex,
} from '@grafana/data'; } from '@grafana/data';
const valueFormats: ValueFormatterIndex = {};
const kbn = { const kbn = {
valueFormats: {} as ValueFormatterIndex, valueFormats,
intervalRegex: /(\d+(?:\.\d+)?)(ms|[Mwdhmsy])/, intervalRegex: /(\d+(?:\.\d+)?)(ms|[Mwdhmsy])/,
intervalsInSeconds: { intervalsInSeconds: {
y: 31536000, y: 31536000,
@@ -24,7 +25,7 @@ const kbn = {
m: 60, m: 60,
s: 1, s: 1,
ms: 0.001, ms: 0.001,
} as { [index: string]: number }, } as const,
/** @deprecated since 9.4, use grafana/data */ /** @deprecated since 9.4, use grafana/data */
regexEscape: (value: string): string => { regexEscape: (value: string): string => {
deprecationWarning('kbn.ts', 'kbn.regexEscape()', 'escapeRegex from @grafana/data'); deprecationWarning('kbn.ts', 'kbn.regexEscape()', 'escapeRegex from @grafana/data');
@@ -69,7 +69,7 @@ const DroneFrontDisplay = ({ data }: CanvasElementProps<DroneFrontConfig, DroneF
); );
}; };
export const droneFrontItem: CanvasElementItem<any, any> = { export const droneFrontItem: CanvasElementItem = {
id: 'droneFront', id: 'droneFront',
name: 'Drone Front', name: 'Drone Front',
description: 'Drone front', description: 'Drone front',
@@ -68,7 +68,7 @@ const DroneSideDisplay = ({ data }: CanvasElementProps<DroneSideConfig, DroneSid
); );
}; };
export const droneSideItem: CanvasElementItem<any, any> = { export const droneSideItem: CanvasElementItem = {
id: 'droneSide', id: 'droneSide',
name: 'Drone Side', name: 'Drone Side',
description: 'Drone Side', description: 'Drone Side',
@@ -80,7 +80,7 @@ const DroneTopDisplay = ({ data }: CanvasElementProps<DroneTopConfig, DroneTopDa
); );
}; };
export const droneTopItem: CanvasElementItem<any, any> = { export const droneTopItem: CanvasElementItem = {
id: 'droneTop', id: 'droneTop',
name: 'Drone Top', name: 'Drone Top',
description: 'Drone top', description: 'Drone top',
@@ -64,7 +64,7 @@ const WindTurbineDisplay = ({ data }: CanvasElementProps<WindTurbineConfig, Wind
); );
}; };
export const windTurbineItem: CanvasElementItem<any, any> = { export const windTurbineItem: CanvasElementItem = {
id: 'windTurbine', id: 'windTurbine',
name: 'Wind Turbine', name: 'Wind Turbine',
description: 'Spinny spinny', description: 'Spinny spinny',
@@ -66,8 +66,7 @@ export function randomizeData(data: DataFrameJSON[], opts: Randomize): DataFrame
if (opts.values) { if (opts.values) {
schema.fields.forEach((f, idx) => { schema.fields.forEach((f, idx) => {
if (f.type === FieldType.string && data) { if (f.type === FieldType.string && data) {
// eslint-ignore-next-line const v = data.values[idx].map((v) => rand(String(v)));
const v = data.values[idx].map((v) => rand(v as string));
data.values[idx] = v; data.values[idx] = v;
} }
}); });
@@ -14,7 +14,7 @@ interface SaveDashboardErrorProxyProps {
/** original dashboard */ /** original dashboard */
dashboard: DashboardModel; dashboard: DashboardModel;
/** dashboard save model with applied modifications, i.e. title */ /** dashboard save model with applied modifications, i.e. title */
dashboardSaveModel: any; dashboardSaveModel: DashboardModel;
error: FetchError; error: FetchError;
onDismiss: () => void; onDismiss: () => void;
} }
@@ -28,7 +28,7 @@ export interface SaveDashboardFormProps {
dashboard: DashboardModel; dashboard: DashboardModel;
onCancel: () => void; onCancel: () => void;
onSuccess: () => void; onSuccess: () => void;
onSubmit?: (clone: any, options: SaveDashboardOptions, dashboard: DashboardModel) => Promise<any>; onSubmit?: (clone: DashboardModel, options: SaveDashboardOptions, dashboard: DashboardModel) => Promise<any>;
} }
export interface SaveDashboardModalProps { export interface SaveDashboardModalProps {
@@ -29,7 +29,7 @@ export const useDashboardSave = (dashboard: DashboardModel, isCopy = false) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const notifyApp = useAppNotification(); const notifyApp = useAppNotification();
const [state, onDashboardSave] = useAsyncFn( const [state, onDashboardSave] = useAsyncFn(
async (clone: any, options: SaveDashboardOptions, dashboard: DashboardModel) => { async (clone: DashboardModel, options: SaveDashboardOptions, dashboard: DashboardModel) => {
try { try {
const result = await saveDashboard(clone, options, dashboard); const result = await saveDashboard(clone, options, dashboard);
dashboard.version = result.version; dashboard.version = result.version;
@@ -48,11 +48,7 @@ export function versions() {
]; ];
} }
export function compare(type: any) { export function restore(version: number, restoredFrom?: number) {
return type === 'basic' ? '<div></div>' : '<pre><code></code></pre>';
}
export function restore(version: any, restoredFrom?: any): any {
return { return {
dashboard: { dashboard: {
meta: { meta: {
@@ -50,7 +50,8 @@ export function LazyLoader({ children, width, height, onLoad, onChange }: Props)
); );
} }
LazyLoader.callbacks = {} as Record<string, (e: IntersectionObserverEntry) => void>; const callbacks: Record<string, (e: IntersectionObserverEntry) => void> = {};
LazyLoader.callbacks = callbacks;
LazyLoader.addCallback = (id: string, c: (e: IntersectionObserverEntry) => void) => (LazyLoader.callbacks[id] = c); LazyLoader.addCallback = (id: string, c: (e: IntersectionObserverEntry) => void) => (LazyLoader.callbacks[id] = c);
LazyLoader.observer = new IntersectionObserver( LazyLoader.observer = new IntersectionObserver(
(entries) => { (entries) => {
@@ -48,7 +48,7 @@ export class DashboardLoaderSrv {
} else if (type === 'public') { } else if (type === 'public') {
promise = backendSrv promise = backendSrv
.getPublicDashboardByUid(uid) .getPublicDashboardByUid(uid)
.then((result: any) => { .then((result) => {
return result; return result;
}) })
.catch((e) => { .catch((e) => {
@@ -73,7 +73,7 @@ export class DashboardLoaderSrv {
} else { } else {
promise = backendSrv promise = backendSrv
.getDashboardByUid(uid) .getDashboardByUid(uid)
.then((result: any) => { .then((result) => {
if (result.meta.isFolder) { if (result.meta.isFolder) {
appEvents.emit(AppEvents.alertError, ['Dashboard not found']); appEvents.emit(AppEvents.alertError, ['Dashboard not found']);
throw new Error('Dashboard not found'); throw new Error('Dashboard not found');
@@ -114,7 +114,7 @@ export class DashboardLoaderSrv {
dashboard: result.data, dashboard: result.data,
}; };
}, },
(err: any) => { (err) => {
console.error('Script dashboard error ' + err); console.error('Script dashboard error ' + err);
appEvents.emit(AppEvents.alertError, [ appEvents.emit(AppEvents.alertError, [
'Script Error', 'Script Error',
@@ -142,7 +142,7 @@ export class DashboardLoaderSrv {
return Promise.reject('expecting path parameter'); return Promise.reject('expecting path parameter');
} }
const queryParams: { [key: string]: any } = {}; const queryParams: { [key: string]: string } = {};
params.forEach((value, key) => { params.forEach((value, key) => {
queryParams[key] = value; queryParams[key] = value;
@@ -2,6 +2,7 @@ import { lastValueFrom } from 'rxjs';
import { AppEvents } from '@grafana/data'; import { AppEvents } from '@grafana/data';
import { BackendSrvRequest } from '@grafana/runtime'; import { BackendSrvRequest } from '@grafana/runtime';
import { Dashboard } from '@grafana/schema';
import { appEvents } from 'app/core/app_events'; import { appEvents } from 'app/core/app_events';
import { t } from 'app/core/internationalization'; import { t } from 'app/core/internationalization';
import { getBackendSrv } from 'app/core/services/backend_srv'; import { getBackendSrv } from 'app/core/services/backend_srv';
@@ -45,7 +46,7 @@ export class DashboardSrv {
appEvents.subscribe(RemovePanelEvent, (e) => this.onRemovePanel(e.payload)); appEvents.subscribe(RemovePanelEvent, (e) => this.onRemovePanel(e.payload));
} }
create(dashboard: any, meta: DashboardMeta) { create(dashboard: Dashboard, meta: DashboardMeta) {
return new DashboardModel(dashboard, meta); return new DashboardModel(dashboard, meta);
} }
@@ -22,17 +22,18 @@ import { TimeModel } from '../state/TimeModel';
import { getRefreshFromUrl } from '../utils/getRefreshFromUrl'; import { getRefreshFromUrl } from '../utils/getRefreshFromUrl';
export class TimeSrv { export class TimeSrv {
time: any; time: RawTimeRange;
refreshTimer: number | undefined; refreshTimer: number | undefined;
refresh: any; refresh: any;
oldRefresh: string | null | undefined; oldRefresh: string | null | undefined;
timeModel?: TimeModel; timeModel?: TimeModel;
timeAtLoad: any; timeAtLoad: RawTimeRange;
private autoRefreshBlocked?: boolean; private autoRefreshBlocked?: boolean;
constructor(private contextSrv: ContextSrv) { constructor(private contextSrv: ContextSrv) {
// default time // default time
this.time = getDefaultTimeRange().raw; this.time = getDefaultTimeRange().raw;
this.timeAtLoad = getDefaultTimeRange().raw;
this.refreshTimeModel = this.refreshTimeModel.bind(this); this.refreshTimeModel = this.refreshTimeModel.bind(this);
appEvents.subscribe(ZoomOutEvent, (e) => { appEvents.subscribe(ZoomOutEvent, (e) => {
@@ -105,7 +106,7 @@ export class TimeSrv {
} }
} }
private parseUrlParam(value: any) { private parseUrlParam(value: string) {
if (value.indexOf('now') !== -1) { if (value.indexOf('now') !== -1) {
return value; return value;
} }
@@ -121,7 +122,7 @@ export class TimeSrv {
} }
} }
if (!isNaN(value)) { if (!isNaN(Number(value))) {
const epoch = parseInt(value, 10); const epoch = parseInt(value, 10);
return toUtc(epoch); return toUtc(epoch);
} }
@@ -44,7 +44,7 @@ export const activePanelSubject = new ReplaySubject<SelectionAction>(1);
export class CanvasPanel extends Component<Props, State> { export class CanvasPanel extends Component<Props, State> {
declare context: React.ContextType<typeof PanelContextRoot>; declare context: React.ContextType<typeof PanelContextRoot>;
static contextType = PanelContextRoot; static contextType = PanelContextRoot;
panelContext: PanelContext = {} as PanelContext; panelContext: PanelContext | undefined;
readonly scene: Scene; readonly scene: Scene;
private subs = new Subscription(); private subs = new Subscription();
@@ -104,7 +104,7 @@ export class CanvasPanel extends Component<Props, State> {
activeCanvasPanel = this; activeCanvasPanel = this;
activePanelSubject.next({ panel: this }); activePanelSubject.next({ panel: this });
this.panelContext = this.context as PanelContext; this.panelContext = this.context;
if (this.panelContext.onInstanceStateChange) { if (this.panelContext.onInstanceStateChange) {
this.panelContext.onInstanceStateChange({ this.panelContext.onInstanceStateChange({
scene: this.scene, scene: this.scene,
@@ -126,7 +126,7 @@ export class CanvasPanel extends Component<Props, State> {
} }
}); });
this.panelContext.onInstanceStateChange!({ this.panelContext?.onInstanceStateChange!({
scene: this.scene, scene: this.scene,
selected: v, selected: v,
layer: this.scene.root, layer: this.scene.root,
@@ -142,7 +142,7 @@ export class CanvasPanel extends Component<Props, State> {
return; return;
} }
this.panelContext.onInstanceStateChange!({ this.panelContext?.onInstanceStateChange!({
scene: this.scene, scene: this.scene,
selected: this.context.instanceState.selected, selected: this.context.instanceState.selected,
selectedConnection: v, selectedConnection: v,
@@ -1,6 +1,6 @@
import { css } from '@emotion/css'; import { css } from '@emotion/css';
import React, { SyntheticEvent, useEffect, useRef, useState } from 'react'; import React, { SyntheticEvent, useEffect, useRef, useState } from 'react';
import Draggable from 'react-draggable'; import Draggable, { DraggableEventHandler } from 'react-draggable';
import { Resizable, ResizeCallbackData } from 'react-resizable'; import { Resizable, ResizeCallbackData } from 'react-resizable';
import { Dimensions2D, GrafanaTheme2 } from '@grafana/data'; import { Dimensions2D, GrafanaTheme2 } from '@grafana/data';
@@ -53,7 +53,7 @@ export function InlineEdit({ onClose, id, scene }: Props) {
} }
}, [windowHeight, windowWidth, placement, measurements]); }, [windowHeight, windowWidth, placement, measurements]);
const onDragStop = (event: any, dragElement: any) => { const onDragStop: DraggableEventHandler = (event, dragElement) => {
let x = dragElement.x < 0 ? 0 : dragElement.x; let x = dragElement.x < 0 ? 0 : dragElement.x;
let y = dragElement.y < 0 ? 0 : dragElement.y; let y = dragElement.y < 0 ? 0 : dragElement.y;
@@ -138,8 +138,8 @@ function getOptionsPaneCategoryDescriptor<T = any>(
}; };
const access: NestedValueAccess = { const access: NestedValueAccess = {
getValue: (path: string) => lodashGet(props.options, path), getValue: (path) => lodashGet(props.options, path),
onChange: (path: string, value: any) => { onChange: (path, value) => {
props.onChange(setOptionImmutably(props.options as any, path, value)); props.onChange(setOptionImmutably(props.options as any, path, value));
}, },
}; };
@@ -11,9 +11,9 @@ export interface APIEditorConfig {
data?: string; data?: string;
} }
const dummyStringSettings: StandardEditorsRegistryItem<string, StringFieldConfigSettings> = { const dummyStringSettings = {
settings: {}, settings: {},
} as any; } as StandardEditorsRegistryItem<string, StringFieldConfigSettings>;
export const callApi = (api: APIEditorConfig, isTest = false) => { export const callApi = (api: APIEditorConfig, isTest = false) => {
if (api) { if (api) {
@@ -24,7 +24,7 @@ export const callApi = (api: APIEditorConfig, isTest = false) => {
data: api.data ?? {}, data: api.data ?? {},
}) })
.subscribe({ .subscribe({
error: (error: any) => { error: (error) => {
if (isTest) { if (isTest) {
appEvents.emit(AppEvents.alertError, ['Error has occurred: ', JSON.stringify(error)]); appEvents.emit(AppEvents.alertError, ['Error has occurred: ', JSON.stringify(error)]);
console.error(error); console.error(error);
@@ -39,7 +39,7 @@ export const callApi = (api: APIEditorConfig, isTest = false) => {
} }
}; };
type Props = StandardEditorProps<APIEditorConfig, any, any>; type Props = StandardEditorProps<APIEditorConfig>;
export function APIEditor({ value, context, onChange }: Props) { export function APIEditor({ value, context, onChange }: Props) {
const labelWidth = 9; const labelWidth = 9;
+5 -2
View File
@@ -82,8 +82,11 @@ export function getElementTypesOptions(items: CanvasElementItem[], current: stri
export function onAddItem(sel: SelectableValue<string>, rootLayer: FrameState | undefined, anchorPoint?: AnchorPoint) { export function onAddItem(sel: SelectableValue<string>, rootLayer: FrameState | undefined, anchorPoint?: AnchorPoint) {
const newItem = canvasElementRegistry.getIfExists(sel.value) ?? notFoundItem; const newItem = canvasElementRegistry.getIfExists(sel.value) ?? notFoundItem;
const newElementOptions = newItem.getNewOptions() as CanvasElementOptions; const newElementOptions: CanvasElementOptions = {
newElementOptions.type = newItem.id; ...newItem.getNewOptions(),
type: newItem.id,
name: '',
};
if (anchorPoint) { if (anchorPoint) {
newElementOptions.placement = { ...newElementOptions.placement, top: anchorPoint.y, left: anchorPoint.x }; newElementOptions.placement = { ...newElementOptions.placement, top: anchorPoint.y, left: anchorPoint.x };
@@ -36,13 +36,13 @@ export function MarkersLegend(props: MarkersLegendProps) {
} }
const props = hoverEvent.getProperties(); const props = hoverEvent.getProperties();
const frame = props.frame as DataFrame; // eslint-disable-line const frame: DataFrame = props.frame;
if (!frame) { if (!frame) {
return undefined; return undefined;
} }
const rowIndex = props.rowIndex as number; // eslint-disable-line const rowIndex: number = props.rowIndex;
return colorField.values[rowIndex]; return colorField.values[rowIndex];
}, [hoverEvent, colorField]); }, [hoverEvent, colorField]);
@@ -99,8 +99,8 @@ export function MarkersLegend(props: MarkersLegendProps) {
<ColorScale <ColorScale
hoverValue={hoverValue} hoverValue={hoverValue}
colorPalette={colors} colorPalette={colors}
min={colorRange.min as number} min={colorRange.min ?? 0}
max={colorRange.max as number} max={colorRange.max ?? 100}
display={display} display={display}
useStopsPercentage={false} useStopsPercentage={false}
/> />
@@ -36,7 +36,7 @@ export const carto: MapLayerRegistryItem<CartoConfig> = {
create: async (map: Map, options: MapLayerOptions<CartoConfig>, eventBus: EventBus, theme: GrafanaTheme2) => ({ create: async (map: Map, options: MapLayerOptions<CartoConfig>, eventBus: EventBus, theme: GrafanaTheme2) => ({
init: () => { init: () => {
const cfg = { ...defaultCartoConfig, ...options.config }; const cfg = { ...defaultCartoConfig, ...options.config };
let style = cfg.theme as string; let style: string | undefined = cfg.theme;
if (!style || style === LayerTheme.Auto) { if (!style || style === LayerTheme.Auto) {
style = theme.isDark ? 'dark' : 'light'; style = theme.isDark ? 'dark' : 'light';
} }
@@ -153,14 +153,14 @@ export function worldmapToGeomapOptions(angular: any): {
'SE Asia': 'se-asia', 'SE Asia': 'se-asia',
'Last GeoHash': MapCenterID.Coordinates, // MapCenterID.LastPoint, 'Last GeoHash': MapCenterID.Coordinates, // MapCenterID.LastPoint,
}; };
options.view.id = mapCenters[angular.mapCenter as any]; options.view.id = mapCenters[angular.mapCenter];
options.view.lat = asNumber(angular.mapCenterLatitude); options.view.lat = asNumber(angular.mapCenterLatitude);
options.view.lon = asNumber(angular.mapCenterLongitude); options.view.lon = asNumber(angular.mapCenterLongitude);
return { fieldConfig, options, xform }; return { fieldConfig, options, xform };
} }
function asNumber(v: any): number | undefined { function asNumber(v: unknown): number | undefined {
const num = +v; const num = Number(v);
return isNaN(num) ? undefined : num; return isNaN(num) ? undefined : num;
} }
@@ -65,9 +65,9 @@ export const pointerMoveListener = (evt: MapBrowserEvent<MouseEvent>, panel: Geo
//this is used as the generic hover event //this is used as the generic hover event
if (!hoverPayload.data) { if (!hoverPayload.data) {
const props = feature.getProperties(); const props = feature.getProperties();
const frame = props['frame']; const frame: DataFrame = props['frame'];
if (frame) { if (frame) {
hoverPayload.data = ttip.data = frame as DataFrame; hoverPayload.data = ttip.data = frame;
hoverPayload.rowIndex = ttip.rowIndex = props['rowIndex']; hoverPayload.rowIndex = ttip.rowIndex = props['rowIndex'];
} }
@@ -39,7 +39,7 @@ const HeatmapHoverCell = ({ data, hover, showHistogram }: Props) => {
const yField = data.heatmap?.fields[1]; const yField = data.heatmap?.fields[1];
const countField = data.heatmap?.fields[2]; const countField = data.heatmap?.fields[2];
const xDisp = (v: any) => { const xDisp = (v: number) => {
if (xField?.display) { if (xField?.display) {
return formattedValueToString(xField.display(v)); return formattedValueToString(xField.display(v));
} }
@@ -57,7 +57,7 @@ const HeatmapHoverCell = ({ data, hover, showHistogram }: Props) => {
// labeled buckets // labeled buckets
const meta = readHeatmapRowsCustomMeta(data.heatmap); const meta = readHeatmapRowsCustomMeta(data.heatmap);
const yDisp = yField?.display ? (v: any) => formattedValueToString(yField.display!(v)) : (v: any) => `${v}`; const yDisp = yField?.display ? (v: string) => formattedValueToString(yField.display!(v)) : (v: string) => `${v}`;
const yValueIdx = index % data.yBucketCount! ?? 0; const yValueIdx = index % data.yBucketCount! ?? 0;
+1 -2
View File
@@ -289,8 +289,7 @@ export function prepConfig(opts: PrepConfigOpts) {
return builder; // early abort (avoids error) return builder; // early abort (avoids error)
} }
// eslint-ignore @typescript-eslint/no-explicit-any const yFieldConfig: FieldConfig | undefined = yField.config?.custom;
const yFieldConfig = yField.config?.custom as FieldConfig | undefined;
const yScale = yFieldConfig?.scaleDistribution ?? { type: ScaleDistribution.Linear }; const yScale = yFieldConfig?.scaleDistribution ?? { type: ScaleDistribution.Linear };
const yAxisReverse = Boolean(yAxisConfig.reverse); const yAxisReverse = Boolean(yAxisConfig.reverse);
const isSparseHeatmap = heatmapType === DataFrameType.HeatmapCells && !isHeatmapCellsDense(dataRef.current?.heatmap!); const isSparseHeatmap = heatmapType === DataFrameType.HeatmapCells && !isHeatmapCellsDense(dataRef.current?.heatmap!);
+2 -2
View File
@@ -192,10 +192,10 @@ export class LivePanel extends PureComponent<Props, State> {
}), }),
state: LoadingState.Streaming, state: LoadingState.Streaming,
} as PanelData; } as PanelData;
const props = { const props: PanelProps = {
...this.props, ...this.props,
options: { frameIndex: 0, showHeader: true }, options: { frameIndex: 0, showHeader: true },
} as PanelProps<any>; };
return <TablePanel {...props} data={data} height={height} />; return <TablePanel {...props} data={data} height={height} />;
} }
} }
@@ -184,11 +184,11 @@ function inBounds(value: number, min: number | undefined, max: number | undefine
} }
function getEventXY(event: Event): { x: number; y: number } { function getEventXY(event: Event): { x: number; y: number } {
if ((event as any).changedTouches) { if (event instanceof TouchEvent) {
const e = event as TouchEvent; return { x: event.changedTouches[0].clientX, y: event.changedTouches[0].clientY };
return { x: e.changedTouches[0].clientX, y: e.changedTouches[0].clientY }; } else if (event instanceof MouseEvent) {
return { x: event.clientX, y: event.clientY };
} else { } else {
const e = event as MouseEvent; return { x: 0, y: 0 };
return { x: e.clientX, y: e.clientY };
} }
} }
@@ -22,8 +22,8 @@ type Props = FieldOverrideEditorProps<boolean | number, unknown>;
export const SpanNullsEditor = ({ value, onChange }: Props) => { export const SpanNullsEditor = ({ value, onChange }: Props) => {
const isThreshold = typeof value === 'number'; const isThreshold = typeof value === 'number';
const formattedTime = isThreshold ? rangeUtil.secondsToHms((value as number) / 1000) : undefined; const formattedTime = isThreshold ? rangeUtil.secondsToHms(value / 1000) : undefined;
GAPS_OPTIONS[2].value = isThreshold ? (value as number) : 3600000; // 1h GAPS_OPTIONS[2].value = isThreshold ? value : 3600000; // 1h
const checkAndUpdate = (txt: string) => { const checkAndUpdate = (txt: string) => {
let val: boolean | number = false; let val: boolean | number = false;
@@ -41,11 +41,11 @@ export const SpanNullsEditor = ({ value, onChange }: Props) => {
if (e.key !== 'Enter') { if (e.key !== 'Enter') {
return; return;
} }
checkAndUpdate((e.target as any).value); checkAndUpdate(e.currentTarget.value);
}; };
const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => { const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {
checkAndUpdate(e.target.value); checkAndUpdate(e.currentTarget.value);
}; };
return ( return (
@@ -4,7 +4,14 @@ import {
VisualizationSuggestion, VisualizationSuggestion,
DataTransformerID, DataTransformerID,
} from '@grafana/data'; } from '@grafana/data';
import { GraphDrawStyle, GraphFieldConfig, GraphGradientMode, LineInterpolation, StackingMode } from '@grafana/schema'; import {
GraphDrawStyle,
GraphFieldConfig,
GraphGradientMode,
LineInterpolation,
StackingMode,
VizLegendOptions,
} from '@grafana/schema';
import { getDashboardSrv } from 'app/features/dashboard/services/DashboardSrv'; import { getDashboardSrv } from 'app/features/dashboard/services/DashboardSrv';
import { SuggestionName } from 'app/types/suggestions'; import { SuggestionName } from 'app/types/suggestions';
@@ -22,7 +29,7 @@ export class TimeSeriesSuggestionsSupplier {
name: SuggestionName.LineChart, name: SuggestionName.LineChart,
pluginId: 'timeseries', pluginId: 'timeseries',
options: { options: {
legend: {} as any, legend: {} as VizLegendOptions,
}, },
fieldConfig: { fieldConfig: {
defaults: { defaults: {
@@ -1,5 +1,5 @@
import { VisualizationSuggestionsBuilder } from '@grafana/data'; import { VisualizationSuggestionsBuilder } from '@grafana/data';
import { GraphDrawStyle, GraphFieldConfig } from '@grafana/schema'; import { GraphDrawStyle, GraphFieldConfig, VizLegendOptions } from '@grafana/schema';
import { SuggestionName } from 'app/types/suggestions'; import { SuggestionName } from 'app/types/suggestions';
import { Options } from './panelcfg.gen'; import { Options } from './panelcfg.gen';
@@ -17,7 +17,7 @@ export class TrendSuggestionsSupplier {
name: SuggestionName.LineChart, name: SuggestionName.LineChart,
pluginId: 'trend', pluginId: 'trend',
options: { options: {
legend: {} as any, legend: {} as VizLegendOptions,
}, },
fieldConfig: { fieldConfig: {
defaults: { defaults: {