Chore: Type improvements (#93267)

* some type fixes + ignore graveyard folder

* few more fixes

* remove comment

* ignore global styles

* few more type fixes
pull/92884/head^2
Ashley Harrison 10 months ago committed by GitHub
parent 3514504240
commit 161d452841
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 211
      .betterer.results
  2. 14
      .betterer.ts
  3. 16
      packages/grafana-data/src/dataframe/dimensions.ts
  4. 29
      packages/grafana-data/src/datetime/datemath.ts
  5. 5
      packages/grafana-data/src/events/EventBus.ts
  6. 5
      packages/grafana-data/src/events/types.ts
  7. 2
      packages/grafana-data/src/field/fieldState.ts
  8. 4
      packages/grafana-data/src/field/overrides/processors.ts
  9. 2
      packages/grafana-data/src/geo/layer.ts
  10. 2
      packages/grafana-data/src/transformations/fieldReducer.ts
  11. 4
      packages/grafana-data/src/transformations/transformers/joinDataFrames.ts
  12. 10
      public/app/core/components/TagFilter/TagFilter.tsx
  13. 4
      public/app/features/dashboard-scene/saving/DashboardSceneChangeTracker.test.ts
  14. 2
      public/app/features/dashboard-scene/scene/NavToolbarActions.test.tsx
  15. 11
      public/app/features/dashboard-scene/serialization/transformSaveModelToScene.test.ts
  16. 40
      public/app/features/dashboard-scene/serialization/transformSceneToSaveModel.test.ts
  17. 2
      public/app/features/dashboard/components/PanelEditor/getVisualizationOptions.tsx
  18. 2
      public/app/features/dashboard/components/PanelEditor/utils.ts
  19. 5
      public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.test.tsx
  20. 7
      public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardForm.test.tsx
  21. 7
      public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardForm.tsx
  22. 7
      public/app/features/dashboard/components/SaveDashboard/types.ts
  23. 2
      public/app/features/dashboard/dashgrid/PanelStateWrapper.tsx
  24. 2
      public/app/features/dimensions/scale.ts
  25. 4
      public/app/features/explore/utils/links.test.ts
  26. 6
      public/app/features/panel/panellinks/link_srv.ts
  27. 2
      public/app/features/panel/panellinks/specs/link_srv.test.ts
  28. 6
      public/app/features/plugins/datasource_srv.ts

@ -44,9 +44,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "3"], [0, 0, 0, "Do not use any type assertions.", "3"],
[0, 0, 0, "Do not use any type assertions.", "4"] [0, 0, 0, "Do not use any type assertions.", "4"]
], ],
"packages/grafana-data/src/dataframe/dimensions.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"packages/grafana-data/src/dataframe/processDataFrame.test.ts:5381": [ "packages/grafana-data/src/dataframe/processDataFrame.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
@ -73,9 +70,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "19"] [0, 0, 0, "Do not use any type assertions.", "19"]
], ],
"packages/grafana-data/src/datetime/datemath.ts:5381": [ "packages/grafana-data/src/datetime/datemath.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, "Do not use any type assertions.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
], ],
"packages/grafana-data/src/datetime/durationutil.ts:5381": [ "packages/grafana-data/src/datetime/durationutil.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [0, 0, 0, "Do not use any type assertions.", "0"]
@ -91,32 +86,22 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "7"], [0, 0, 0, "Do not use any type assertions.", "7"],
[0, 0, 0, "Do not use any type assertions.", "8"] [0, 0, 0, "Do not use any type assertions.", "8"]
], ],
"packages/grafana-data/src/events/EventBus.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"packages/grafana-data/src/events/types.ts:5381": [ "packages/grafana-data/src/events/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"], [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.", "4"]
], ],
"packages/grafana-data/src/field/displayProcessor.ts:5381": [ "packages/grafana-data/src/field/displayProcessor.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"], [0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"] [0, 0, 0, "Do not use any type assertions.", "2"]
], ],
"packages/grafana-data/src/field/fieldState.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"packages/grafana-data/src/field/overrides/processors.ts:5381": [ "packages/grafana-data/src/field/overrides/processors.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.", "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"]
], ],
"packages/grafana-data/src/field/standardFieldConfigEditorRegistry.ts:5381": [ "packages/grafana-data/src/field/standardFieldConfigEditorRegistry.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@ -128,8 +113,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "6"] [0, 0, 0, "Unexpected any. Specify a different type.", "6"]
], ],
"packages/grafana-data/src/geo/layer.ts:5381": [ "packages/grafana-data/src/geo/layer.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"]
], ],
"packages/grafana-data/src/panel/PanelPlugin.ts:5381": [ "packages/grafana-data/src/panel/PanelPlugin.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@ -159,9 +143,6 @@ exports[`better eslint`] = {
"packages/grafana-data/src/themes/createColors.ts:5381": [ "packages/grafana-data/src/themes/createColors.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [0, 0, 0, "Do not use any type assertions.", "0"]
], ],
"packages/grafana-data/src/transformations/fieldReducer.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"packages/grafana-data/src/transformations/matchers/valueMatchers/types.ts:5381": [ "packages/grafana-data/src/transformations/matchers/valueMatchers/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"] [0, 0, 0, "Unexpected any. Specify a different type.", "1"]
@ -172,9 +153,6 @@ exports[`better eslint`] = {
"packages/grafana-data/src/transformations/transformDataFrame.ts:5381": [ "packages/grafana-data/src/transformations/transformDataFrame.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
"packages/grafana-data/src/transformations/transformers/joinDataFrames.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"packages/grafana-data/src/transformations/transformers/nulls/nullInsertThreshold.ts:5381": [ "packages/grafana-data/src/transformations/transformers/nulls/nullInsertThreshold.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"]
@ -959,48 +937,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, "Unexpected any. Specify a different type.", "1"] [0, 0, 0, "Unexpected any. Specify a different type.", "1"]
], ],
"packages/grafana-ui/src/graveyard/Graph/Graph.tsx:5381": [
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"]
],
"packages/grafana-ui/src/graveyard/Graph/GraphContextMenu.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"packages/grafana-ui/src/graveyard/Graph/utils.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"packages/grafana-ui/src/graveyard/GraphNG/GraphNG.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"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Do not use any type assertions.", "5"],
[0, 0, 0, "Do not use any type assertions.", "6"],
[0, 0, 0, "Do not use any type assertions.", "7"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
[0, 0, 0, "Do not use any type assertions.", "9"],
[0, 0, 0, "Do not use any type assertions.", "10"],
[0, 0, 0, "Do not use any type assertions.", "11"]
],
"packages/grafana-ui/src/graveyard/GraphNG/hooks.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"packages/grafana-ui/src/graveyard/GraphNG/nullInsertThreshold.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, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
],
"packages/grafana-ui/src/graveyard/GraphNG/nullToUndefThreshold.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, "Do not use any type assertions.", "2"]
],
"packages/grafana-ui/src/graveyard/TimeSeries/utils.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
],
"packages/grafana-ui/src/options/builder/hideSeries.tsx:5381": [ "packages/grafana-ui/src/options/builder/hideSeries.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [0, 0, 0, "Do not use any type assertions.", "0"]
], ],
@ -1225,10 +1161,7 @@ exports[`better eslint`] = {
], ],
"public/app/core/components/TagFilter/TagFilter.tsx:5381": [ "public/app/core/components/TagFilter/TagFilter.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, "No untranslated strings. Wrap text with <Trans />", "1"]
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "4"]
], ],
"public/app/core/components/TimeSeries/utils.ts:5381": [ "public/app/core/components/TimeSeries/utils.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@ -2784,10 +2717,6 @@ exports[`better eslint`] = {
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "2"], [0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "2"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "3"] [0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "3"]
], ],
"public/app/features/dashboard-scene/saving/DashboardSceneChangeTracker.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/features/dashboard-scene/saving/SaveDashboardAsForm.tsx:5381": [ "public/app/features/dashboard-scene/saving/SaveDashboardAsForm.tsx:5381": [
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"], [0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"], [0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"],
@ -2824,9 +2753,6 @@ exports[`better eslint`] = {
"public/app/features/dashboard-scene/scene/DashboardControls.tsx:5381": [ "public/app/features/dashboard-scene/scene/DashboardControls.tsx: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-scene/scene/NavToolbarActions.test.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/features/dashboard-scene/scene/NavToolbarActions.tsx:5381": [ "public/app/features/dashboard-scene/scene/NavToolbarActions.tsx:5381": [
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"], [0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"], [0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"],
@ -2863,28 +2789,10 @@ exports[`better eslint`] = {
"public/app/features/dashboard-scene/serialization/buildNewDashboardSaveModel.ts:5381": [ "public/app/features/dashboard-scene/serialization/buildNewDashboardSaveModel.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-scene/serialization/transformSaveModelToScene.test.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-scene/serialization/transformSceneToSaveModel.test.ts:5381": [ "public/app/features/dashboard-scene/serialization/transformSceneToSaveModel.test.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.", "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"],
[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"],
[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"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
[0, 0, 0, "Unexpected any. Specify a different type.", "14"]
], ],
"public/app/features/dashboard-scene/serialization/transformSceneToSaveModel.ts:5381": [ "public/app/features/dashboard-scene/serialization/transformSceneToSaveModel.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
@ -3196,16 +3104,14 @@ exports[`better eslint`] = {
], ],
"public/app/features/dashboard/components/PanelEditor/getVisualizationOptions.tsx:5381": [ "public/app/features/dashboard/components/PanelEditor/getVisualizationOptions.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"]
], ],
"public/app/features/dashboard/components/PanelEditor/utils.ts:5381": [ "public/app/features/dashboard/components/PanelEditor/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, "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.", "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/features/dashboard/components/PublicDashboardNotAvailable/PublicDashboardNotAvailable.tsx:5381": [ "public/app/features/dashboard/components/PublicDashboardNotAvailable/PublicDashboardNotAvailable.tsx:5381": [
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"] [0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"]
@ -3244,21 +3150,17 @@ exports[`better eslint`] = {
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"], [0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "2"] [0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "2"]
], ],
"public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.test.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.tsx:5381": [ "public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.tsx:5381": [
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"], [0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"], [0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "2"] [0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "2"]
], ],
"public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardForm.tsx:5381": [ "public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardForm.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "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"],
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "2"], [0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "2"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "3"], [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", "4"], [0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "4"]
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "5"]
], ],
"public/app/features/dashboard/components/SaveDashboard/forms/SaveProvisionedDashboardForm.tsx:5381": [ "public/app/features/dashboard/components/SaveDashboard/forms/SaveProvisionedDashboardForm.tsx:5381": [
[0, 0, 0, "\'HorizontalGroup\' import from \'@grafana/ui\' is restricted from being used by a pattern. Use Stack component instead.", "0"], [0, 0, 0, "\'HorizontalGroup\' import from \'@grafana/ui\' is restricted from being used by a pattern. Use Stack component instead.", "0"],
@ -3271,9 +3173,6 @@ exports[`better eslint`] = {
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "7"], [0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "7"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "8"] [0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "8"]
], ],
"public/app/features/dashboard/components/SaveDashboard/types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"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"]
], ],
@ -3365,9 +3264,6 @@ exports[`better eslint`] = {
"public/app/features/dashboard/containers/SoloPanelPage.tsx:5381": [ "public/app/features/dashboard/containers/SoloPanelPage.tsx:5381": [
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"] [0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"]
], ],
"public/app/features/dashboard/dashgrid/PanelStateWrapper.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/features/dashboard/dashgrid/SeriesVisibilityConfigFactory.ts:5381": [ "public/app/features/dashboard/dashgrid/SeriesVisibilityConfigFactory.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [0, 0, 0, "Do not use any type assertions.", "0"]
], ],
@ -3754,8 +3650,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "7"] [0, 0, 0, "Do not use export all (\`export * from ...\`)", "7"]
], ],
"public/app/features/dimensions/scale.ts:5381": [ "public/app/features/dimensions/scale.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/features/dimensions/types.ts:5381": [ "public/app/features/dimensions/types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@ -4775,10 +4670,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/features/panel/panellinks/link_srv.ts:5381": [ "public/app/features/panel/panellinks/link_srv.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"]
], ],
"public/app/features/playlist/PlaylistForm.tsx:5381": [ "public/app/features/playlist/PlaylistForm.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"],
@ -4971,15 +4863,9 @@ 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, "Do not use any type assertions.", "2"], [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.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "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"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"], [0, 0, 0, "Do not use any type assertions.", "6"]
[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, "Do not use any type assertions.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
[0, 0, 0, "Do not use any type assertions.", "12"]
], ],
"public/app/features/plugins/extensions/usePluginComponents.tsx:5381": [ "public/app/features/plugins/extensions/usePluginComponents.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [0, 0, 0, "Do not use any type assertions.", "0"]
@ -7497,65 +7383,6 @@ exports[`no gf-form usage`] = {
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"] [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"]
], ],
"packages/grafana-ui/src/themes/GlobalStyles/forms.ts:5381": [
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"]
],
"packages/grafana-ui/src/themes/GlobalStyles/legacySelect.ts:5381": [
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"]
],
"public/app/angular/components/PageHeader/PageHeader.tsx:5381": [ "public/app/angular/components/PageHeader/PageHeader.tsx:5381": [
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"], [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"],
[0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"] [0, 0, 0, "gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.", "5381"]

@ -7,9 +7,10 @@ import { glob } from 'glob';
// Why are we ignoring these? // Why are we ignoring these?
// They're all deprecated/being removed so doesn't make sense to fix types // They're all deprecated/being removed so doesn't make sense to fix types
const eslintPathsToIgnore = [ const eslintPathsToIgnore = [
'public/app/angular', // will be removed in Grafana 11 'packages/grafana-ui/src/graveyard', // will be removed alongside angular in Grafana 12
'public/app/plugins/panel/graph', // will be removed alongside angular 'public/app/angular', // will be removed in Grafana 12
'public/app/plugins/panel/table-old', // will be removed alongside angular 'public/app/plugins/panel/graph', // will be removed alongside angular in Grafana 12
'public/app/plugins/panel/table-old', // will be removed alongside angular in Grafana 12
'e2e/test-plugins', 'e2e/test-plugins',
]; ];
@ -21,10 +22,9 @@ export default {
.exclude(new RegExp(eslintPathsToIgnore.join('|'))), .exclude(new RegExp(eslintPathsToIgnore.join('|'))),
'no undocumented stories': () => countUndocumentedStories().include('**/!(*.internal).story.tsx'), 'no undocumented stories': () => countUndocumentedStories().include('**/!(*.internal).story.tsx'),
'no gf-form usage': () => 'no gf-form usage': () =>
regexp( regexp(/gf-form/gm, 'gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.')
/gf-form/gm, .include('**/*.{ts,tsx,html}')
'gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.' .exclude(new RegExp('packages/grafana-ui/src/themes/GlobalStyles')),
).include('**/*.{ts,tsx,html}'),
}; };
function countUndocumentedStories() { function countUndocumentedStories() {

@ -1,7 +1,7 @@
import { KeyValue } from '../types/data'; import { KeyValue } from '../types/data';
import { Field } from '../types/dataFrame'; import { Field } from '../types/dataFrame';
export interface Dimension<T = any> { export interface Dimension<T = unknown> {
// Name of the dimension // Name of the dimension
name: string; name: string;
// Collection of fields representing dimension // Collection of fields representing dimension
@ -12,28 +12,28 @@ export interface Dimension<T = any> {
columns: Array<Field<T>>; columns: Array<Field<T>>;
} }
export type Dimensions = KeyValue<Dimension>; export type Dimensions<T = unknown> = KeyValue<Dimension<T>>;
export const createDimension = (name: string, columns: Field[]): Dimension => { export const createDimension = <T>(name: string, columns: Array<Field<T>>): Dimension<T> => {
return { return {
name, name,
columns, columns,
}; };
}; };
export const getColumnsFromDimension = (dimension: Dimension) => { export const getColumnsFromDimension = <T>(dimension: Dimension<T>) => {
return dimension.columns; return dimension.columns;
}; };
export const getColumnFromDimension = (dimension: Dimension, column: number) => { export const getColumnFromDimension = <T>(dimension: Dimension<T>, column: number) => {
return dimension.columns[column]; return dimension.columns[column];
}; };
export const getValueFromDimension = (dimension: Dimension, column: number, row: number) => { export const getValueFromDimension = <T>(dimension: Dimension<T>, column: number, row: number) => {
return dimension.columns[column].values[row]; return dimension.columns[column].values[row];
}; };
export const getAllValuesFromDimension = (dimension: Dimension, column: number, row: number) => { export const getAllValuesFromDimension = <T>(dimension: Dimension<T>, column: number, row: number) => {
return dimension.columns.map((c) => c.values[row]); return dimension.columns.map((c) => c.values[row]);
}; };
export const getDimensionByName = (dimensions: Dimensions, name: string) => dimensions[name]; export const getDimensionByName = <T>(dimensions: Dimensions<T>, name: string) => dimensions[name];

@ -2,7 +2,15 @@ import { includes, isDate } from 'lodash';
import { TimeZone } from '../types/time'; import { TimeZone } from '../types/time';
import { DateTime, dateTime, dateTimeForTimeZone, DurationUnit, isDateTime, ISO_8601 } from './moment_wrapper'; import {
DateTime,
dateTime,
dateTimeAsMoment,
dateTimeForTimeZone,
DurationUnit,
isDateTime,
ISO_8601,
} from './moment_wrapper';
const units: DurationUnit[] = ['y', 'M', 'w', 'd', 'h', 'm', 's', 'Q']; const units: DurationUnit[] = ['y', 'M', 'w', 'd', 'h', 'm', 's', 'Q'];
@ -51,10 +59,10 @@ export function parse(
// We got some non string which is not a moment nor Date. TS should be able to check for that but not always. // We got some non string which is not a moment nor Date. TS should be able to check for that but not always.
return undefined; return undefined;
} else { } else {
let time; let time: DateTime;
let mathString = ''; let mathString = '';
let index; let index = -1;
let parseString; let parseString = '';
if (text.substring(0, 3) === 'now') { if (text.substring(0, 3) === 'now') {
time = dateTimeForTimeZone(timezone); time = dateTimeForTimeZone(timezone);
@ -104,10 +112,9 @@ export function isValid(text: string | DateTime): boolean {
* @param time * @param time
* @param roundUp If true it will round the time to endOf time unit, otherwise to startOf time unit. * @param roundUp If true it will round the time to endOf time unit, otherwise to startOf time unit.
*/ */
// TODO: Had to revert Andrejs `time: moment.Moment` to `time: any`
export function parseDateMath( export function parseDateMath(
mathString: string, mathString: string,
time: any, time: DateTime,
roundUp?: boolean, roundUp?: boolean,
fiscalYearStartMonth = 0 fiscalYearStartMonth = 0
): DateTime | undefined { ): DateTime | undefined {
@ -187,21 +194,21 @@ export function parseDateMath(
return result; return result;
} }
export function roundToFiscal(fyStartMonth: number, dateTime: any, unit: string, roundUp: boolean | undefined) { export function roundToFiscal(fyStartMonth: number, dateTime: DateTime, unit: string, roundUp: boolean | undefined) {
switch (unit) { switch (unit) {
case 'y': case 'y':
if (roundUp) { if (roundUp) {
roundToFiscal(fyStartMonth, dateTime, unit, false).add(11, 'M').endOf('M'); roundToFiscal(fyStartMonth, dateTime, unit, false)?.add(11, 'M').endOf('M');
} else { } else {
dateTime.subtract((dateTime.month() - fyStartMonth + 12) % 12, 'M').startOf('M'); dateTime.subtract((dateTimeAsMoment(dateTime).month() - fyStartMonth + 12) % 12, 'M').startOf('M');
} }
return dateTime; return dateTime;
case 'Q': case 'Q':
if (roundUp) { if (roundUp) {
roundToFiscal(fyStartMonth, dateTime, unit, false).add(2, 'M').endOf('M'); roundToFiscal(fyStartMonth, dateTime, unit, false)?.add(2, 'M').endOf('M');
} else { } else {
// why + 12? to ensure this number is always a positive offset from fyStartMonth // why + 12? to ensure this number is always a positive offset from fyStartMonth
dateTime.subtract((dateTime.month() - fyStartMonth + 12) % 3, 'M').startOf('M'); dateTime.subtract((dateTimeAsMoment(dateTime).month() - fyStartMonth + 12) % 3, 'M').startOf('M');
} }
return dateTime; return dateTime;
default: default:

@ -1,3 +1,4 @@
import { IScope } from 'angular';
import EventEmitter from 'eventemitter3'; import EventEmitter from 'eventemitter3';
import { Unsubscribable, Observable, Subscriber } from 'rxjs'; import { Unsubscribable, Observable, Subscriber } from 'rxjs';
import { filter } from 'rxjs/operators'; import { filter } from 'rxjs/operators';
@ -55,7 +56,7 @@ export class EventBusSrv implements EventBus, LegacyEmitter {
/** /**
* Legacy functions * Legacy functions
*/ */
emit<T>(event: AppEvent<T> | string, payload?: T | any): void { emit<T>(event: AppEvent<T> | string, payload?: T): void {
// console.log(`Deprecated emitter function used (emit), use $emit`); // console.log(`Deprecated emitter function used (emit), use $emit`);
if (typeof event === 'string') { if (typeof event === 'string') {
@ -65,7 +66,7 @@ export class EventBusSrv implements EventBus, LegacyEmitter {
} }
} }
on<T>(event: AppEvent<T> | string, handler: LegacyEventHandler<T>, scope?: any) { on<T>(event: AppEvent<T> | string, handler: LegacyEventHandler<T>, scope?: IScope) {
// console.log(`Deprecated emitter function used (on), use $on`); // console.log(`Deprecated emitter function used (on), use $on`);
// need this wrapper to make old events compatible with old handlers // need this wrapper to make old events compatible with old handlers

@ -1,3 +1,4 @@
import { IScope } from 'angular';
import { Unsubscribable, Observable } from 'rxjs'; import { Unsubscribable, Observable } from 'rxjs';
/** /**
@ -128,12 +129,12 @@ export interface LegacyEmitter {
/** /**
* @deprecated use $on * @deprecated use $on
*/ */
on<T>(event: AppEvent<T> | string, handler: LegacyEventHandler<T>, scope?: any): void; on<T>(event: AppEvent<T> | string, handler: LegacyEventHandler<T>, scope?: IScope): void;
/** /**
* @deprecated use $on * @deprecated use $on
*/ */
off<T>(event: AppEvent<T> | string, handler: (payload?: T | any) => void): void; off<T>(event: AppEvent<T> | string, handler: (payload?: T) => void): void;
} }
/** @public */ /** @public */

@ -64,7 +64,7 @@ export function cacheFieldDisplayNames(frames: DataFrame[]) {
* moves each field's config.custom.hideFrom to field.state.hideFrom * moves each field's config.custom.hideFrom to field.state.hideFrom
* and mutates orgiginal field.config.custom.hideFrom to one with explicit overrides only, (without the ad-hoc stateful __system override from legend toggle) * and mutates orgiginal field.config.custom.hideFrom to one with explicit overrides only, (without the ad-hoc stateful __system override from legend toggle)
*/ */
export function decoupleHideFromState(frames: DataFrame[], fieldConfig: FieldConfigSource<any>) { export function decoupleHideFromState(frames: DataFrame[], fieldConfig: FieldConfigSource) {
frames.forEach((frame) => { frames.forEach((frame) => {
frame.fields.forEach((field) => { frame.fields.forEach((field) => {
const hideFrom = { const hideFrom = {

@ -19,7 +19,7 @@ export interface NumberFieldConfigSettings {
} }
export const numberOverrideProcessor = ( export const numberOverrideProcessor = (
value: any, value: unknown,
context: FieldOverrideContext, context: FieldOverrideContext,
settings?: NumberFieldConfigSettings settings?: NumberFieldConfigSettings
) => { ) => {
@ -27,7 +27,7 @@ export const numberOverrideProcessor = (
return undefined; return undefined;
} }
return parseFloat(value); return parseFloat(String(value));
}; };
export const displayNameOverrideProcessor = ( export const displayNameOverrideProcessor = (

@ -42,7 +42,7 @@ export interface MapLayerHandler<TConfig = any> {
*/ */
registerOptionsUI?: ( registerOptionsUI?: (
builder: PanelOptionsEditorBuilder<MapLayerOptions<TConfig>>, builder: PanelOptionsEditorBuilder<MapLayerOptions<TConfig>>,
context: StandardEditorContext<any> context: StandardEditorContext<MapLayerOptions<TConfig>>
) => void; ) => void;
} }

@ -423,7 +423,7 @@ const buildPercentileReducers = (percentiles = [...Array.from({ length: 99 }, (_
percentiles.forEach((p) => { percentiles.forEach((p) => {
const percentile = p / 100; const percentile = p / 100;
const id = `p${p}` as ReducerID; const id = `p${p}`;
const name = `${p}${nth(p)} %`; const name = `${p}${nth(p)} %`;
const description = `${p}${nth(p)} percentile value`; const description = `${p}${nth(p)} percentile value`;

@ -546,7 +546,7 @@ export function join(tables: AlignedData[], nullModes?: number[][], mode: JoinMo
// Test a few samples to see if the values are ascending // Test a few samples to see if the values are ascending
// Only exported for tests // Only exported for tests
export function isLikelyAscendingVector(data: any[], samples = 50) { export function isLikelyAscendingVector(data: unknown[], samples = 50) {
const len = data.length; const len = data.length;
// empty or single value // empty or single value
@ -576,7 +576,7 @@ export function isLikelyAscendingVector(data: any[], samples = 50) {
for (let prevVal = data[firstIdx], i = firstIdx + stride; i <= lastIdx; i += stride) { for (let prevVal = data[firstIdx], i = firstIdx + stride; i <= lastIdx; i += stride) {
const v = data[i]; const v = data[i];
if (v != null) { if (v != null && prevVal != null) {
if (v <= prevVal) { if (v <= prevVal) {
return false; return false;
} }

@ -2,7 +2,7 @@ import { css } from '@emotion/css';
import { useCallback, useEffect, useMemo, useState } from 'react'; import { useCallback, useEffect, useMemo, useState } from 'react';
import { components, MultiValueRemoveProps } from 'react-select'; import { components, MultiValueRemoveProps } from 'react-select';
import { escapeStringForRegex, GrafanaTheme2 } from '@grafana/data'; import { escapeStringForRegex, GrafanaTheme2, SelectableValue } from '@grafana/data';
import { Icon, MultiSelect, useStyles2 } from '@grafana/ui'; import { Icon, MultiSelect, useStyles2 } from '@grafana/ui';
import { t } from 'app/core/internationalization'; import { t } from 'app/core/internationalization';
@ -28,9 +28,9 @@ export interface Props {
width?: number; width?: number;
} }
const filterOption = (option: any, searchQuery: string) => { const filterOption = (option: SelectableValue<string>, searchQuery: string) => {
const regex = RegExp(escapeStringForRegex(searchQuery), 'i'); const regex = RegExp(escapeStringForRegex(searchQuery), 'i');
return regex.test(option.value); return Boolean(option.value && regex.test(option.value));
}; };
export const TagFilter = ({ export const TagFilter = ({
@ -124,8 +124,8 @@ export const TagFilter = ({
formatCreateLabel, formatCreateLabel,
defaultOptions: true, defaultOptions: true,
filterOption, filterOption,
getOptionLabel: (i: any) => i.label, getOptionLabel: (i: SelectableValue<string>) => i.label,
getOptionValue: (i: any) => i.value, getOptionValue: (i: SelectableValue<string>) => i.value,
inputId, inputId,
isMulti: true, isMulti: true,
onChange: onTagChange, onChange: onTagChange,

@ -25,11 +25,11 @@ describe('DashboardSceneChangeTracker', () => {
() => () =>
({ ({
terminate, terminate,
}) as any }) as unknown as CorsWorker
); );
const changeTracker = new DashboardSceneChangeTracker({ const changeTracker = new DashboardSceneChangeTracker({
subscribeToEvent: jest.fn().mockReturnValue({ unsubscribe: jest.fn() }), subscribeToEvent: jest.fn().mockReturnValue({ unsubscribe: jest.fn() }),
} as any); } as unknown as DashboardScene);
changeTracker.startTrackingChanges(); changeTracker.startTrackingChanges();
expect(changeTracker['_changesWorker']).not.toBeUndefined(); expect(changeTracker['_changesWorker']).not.toBeUndefined();

@ -28,7 +28,7 @@ jest.mock('app/features/playlist/PlaylistSrv', () => ({
})); }));
jest.mock('@grafana/runtime', () => ({ jest.mock('@grafana/runtime', () => ({
...jest.requireActual<Record<string, any>>('@grafana/runtime'), ...jest.requireActual('@grafana/runtime'),
getDataSourceSrv: () => ({ getDataSourceSrv: () => ({
get: jest.fn(), get: jest.fn(),
getInstanceSettings: jest.fn().mockReturnValue({ getInstanceSettings: jest.fn().mockReturnValue({

@ -746,7 +746,10 @@ describe('transformSaveModelToScene', () => {
describe('Repeating rows', () => { describe('Repeating rows', () => {
it('Should build correct scene model', () => { it('Should build correct scene model', () => {
const scene = transformSaveModelToScene({ dashboard: repeatingRowsAndPanelsDashboardJson as any, meta: {} }); const scene = transformSaveModelToScene({
dashboard: repeatingRowsAndPanelsDashboardJson as DashboardDataDTO,
meta: {},
});
const body = scene.state.body as SceneGridLayout; const body = scene.state.body as SceneGridLayout;
const row2 = body.state.children[1] as SceneGridRow; const row2 = body.state.children[1] as SceneGridRow;
@ -762,7 +765,7 @@ describe('transformSaveModelToScene', () => {
describe('Annotation queries', () => { describe('Annotation queries', () => {
it('Should build correct scene model', () => { it('Should build correct scene model', () => {
const scene = transformSaveModelToScene({ dashboard: dashboard_to_load1 as any, meta: {} }); const scene = transformSaveModelToScene({ dashboard: dashboard_to_load1 as DashboardDataDTO, meta: {} });
expect(scene.state.$data).toBeInstanceOf(DashboardDataLayerSet); expect(scene.state.$data).toBeInstanceOf(DashboardDataLayerSet);
expect(scene.state.controls!.state.variableControls[1]).toBeInstanceOf(SceneDataLayerControls); expect(scene.state.controls!.state.variableControls[1]).toBeInstanceOf(SceneDataLayerControls);
@ -790,7 +793,7 @@ describe('transformSaveModelToScene', () => {
describe('Alerting data layer', () => { describe('Alerting data layer', () => {
it('Should add alert states data layer if unified alerting enabled', () => { it('Should add alert states data layer if unified alerting enabled', () => {
config.unifiedAlertingEnabled = true; config.unifiedAlertingEnabled = true;
const scene = transformSaveModelToScene({ dashboard: dashboard_to_load1 as any, meta: {} }); const scene = transformSaveModelToScene({ dashboard: dashboard_to_load1 as DashboardDataDTO, meta: {} });
expect(scene.state.$data).toBeInstanceOf(DashboardDataLayerSet); expect(scene.state.$data).toBeInstanceOf(DashboardDataLayerSet);
expect(scene.state.controls!.state.variableControls[1]).toBeInstanceOf(SceneDataLayerControls); expect(scene.state.controls!.state.variableControls[1]).toBeInstanceOf(SceneDataLayerControls);
@ -803,7 +806,7 @@ describe('transformSaveModelToScene', () => {
config.unifiedAlertingEnabled = false; config.unifiedAlertingEnabled = false;
const dashboard = { ...dashboard_to_load1 } as unknown as DashboardDataDTO; const dashboard = { ...dashboard_to_load1 } as unknown as DashboardDataDTO;
dashboard.panels![0].alert = {}; dashboard.panels![0].alert = {};
const scene = transformSaveModelToScene({ dashboard: dashboard_to_load1 as any, meta: {} }); const scene = transformSaveModelToScene({ dashboard: dashboard_to_load1 as DashboardDataDTO, meta: {} });
expect(scene.state.$data).toBeInstanceOf(DashboardDataLayerSet); expect(scene.state.$data).toBeInstanceOf(DashboardDataLayerSet);
expect(scene.state.controls!.state.variableControls[1]).toBeInstanceOf(SceneDataLayerControls); expect(scene.state.controls!.state.variableControls[1]).toBeInstanceOf(SceneDataLayerControls);

@ -28,6 +28,7 @@ import { PanelModel } from 'app/features/dashboard/state';
import { getTimeRange } from 'app/features/dashboard/utils/timeRange'; import { getTimeRange } from 'app/features/dashboard/utils/timeRange';
import { reduceTransformRegistryItem } from 'app/features/transformers/editors/ReduceTransformerEditor'; import { reduceTransformRegistryItem } from 'app/features/transformers/editors/ReduceTransformerEditor';
import { SHARED_DASHBOARD_QUERY } from 'app/plugins/datasource/dashboard'; import { SHARED_DASHBOARD_QUERY } from 'app/plugins/datasource/dashboard';
import { DashboardDataDTO } from 'app/types';
import { buildPanelEditScene } from '../panel-edit/PanelEditor'; import { buildPanelEditScene } from '../panel-edit/PanelEditor';
import { DashboardDataLayerSet } from '../scene/DashboardDataLayerSet'; import { DashboardDataLayerSet } from '../scene/DashboardDataLayerSet';
@ -192,7 +193,7 @@ describe('transformSceneToSaveModel', () => {
}, },
links: [{ ...NEW_LINK, title: 'Link 1' }], links: [{ ...NEW_LINK, title: 'Link 1' }],
}; };
const scene = transformSaveModelToScene({ dashboard: dashboardWithCustomSettings as any, meta: {} }); const scene = transformSaveModelToScene({ dashboard: dashboardWithCustomSettings as DashboardDataDTO, meta: {} });
const saveModel = transformSceneToSaveModel(scene); const saveModel = transformSceneToSaveModel(scene);
expect(saveModel).toMatchSnapshot(); expect(saveModel).toMatchSnapshot();
@ -201,7 +202,7 @@ describe('transformSceneToSaveModel', () => {
describe('Given a simple scene with variables', () => { describe('Given a simple scene with variables', () => {
it('Should transform back to persisted model', () => { it('Should transform back to persisted model', () => {
const scene = transformSaveModelToScene({ dashboard: dashboard_to_load1 as any, meta: {} }); const scene = transformSaveModelToScene({ dashboard: dashboard_to_load1 as DashboardDataDTO, meta: {} });
const saveModel = transformSceneToSaveModel(scene); const saveModel = transformSceneToSaveModel(scene);
expect(saveModel).toMatchSnapshot(); expect(saveModel).toMatchSnapshot();
@ -210,7 +211,10 @@ describe('transformSceneToSaveModel', () => {
describe('Given a scene with rows', () => { describe('Given a scene with rows', () => {
it('Should transform back to persisted model', () => { it('Should transform back to persisted model', () => {
const scene = transformSaveModelToScene({ dashboard: repeatingRowsAndPanelsDashboardJson as any, meta: {} }); const scene = transformSaveModelToScene({
dashboard: repeatingRowsAndPanelsDashboardJson as DashboardDataDTO,
meta: {},
});
const saveModel = transformSceneToSaveModel(scene); const saveModel = transformSceneToSaveModel(scene);
@ -222,7 +226,10 @@ describe('transformSceneToSaveModel', () => {
}); });
it('Should remove repeated rows in save model', () => { it('Should remove repeated rows in save model', () => {
const scene = transformSaveModelToScene({ dashboard: repeatingRowsAndPanelsDashboardJson as any, meta: {} }); const scene = transformSaveModelToScene({
dashboard: repeatingRowsAndPanelsDashboardJson as DashboardDataDTO,
meta: {},
});
const variable = scene.state.$variables?.state.variables[0] as MultiValueVariable; const variable = scene.state.$variables?.state.variables[0] as MultiValueVariable;
variable.changeValueTo(['a', 'b', 'c']); variable.changeValueTo(['a', 'b', 'c']);
@ -427,7 +434,7 @@ describe('transformSceneToSaveModel', () => {
describe('Annotations', () => { describe('Annotations', () => {
it('should transform annotations to save model', () => { it('should transform annotations to save model', () => {
const scene = transformSaveModelToScene({ dashboard: dashboard_to_load1 as any, meta: {} }); const scene = transformSaveModelToScene({ dashboard: dashboard_to_load1 as DashboardDataDTO, meta: {} });
const saveModel = transformSceneToSaveModel(scene); const saveModel = transformSceneToSaveModel(scene);
expect(saveModel.annotations?.list?.length).toBe(4); expect(saveModel.annotations?.list?.length).toBe(4);
@ -435,7 +442,7 @@ describe('transformSceneToSaveModel', () => {
}); });
it('should transform annotations to save model after state changes', () => { it('should transform annotations to save model after state changes', () => {
const scene = transformSaveModelToScene({ dashboard: dashboard_to_load1 as any, meta: {} }); const scene = transformSaveModelToScene({ dashboard: dashboard_to_load1 as DashboardDataDTO, meta: {} });
const layers = (scene.state.$data as DashboardDataLayerSet)?.state.annotationLayers; const layers = (scene.state.$data as DashboardDataLayerSet)?.state.annotationLayers;
const enabledLayer = layers[1]; const enabledLayer = layers[1];
@ -678,7 +685,7 @@ describe('transformSceneToSaveModel', () => {
}); });
it('attaches snapshot data to panels using Grafana snapshot query', async () => { it('attaches snapshot data to panels using Grafana snapshot query', async () => {
const scene = transformSaveModelToScene({ dashboard: snapshotableDashboardJson as any, meta: {} }); const scene = transformSaveModelToScene({ dashboard: snapshotableDashboardJson as DashboardDataDTO, meta: {} });
activateFullSceneTree(scene); activateFullSceneTree(scene);
@ -733,7 +740,10 @@ describe('transformSceneToSaveModel', () => {
}); });
it('handles basic rows', async () => { it('handles basic rows', async () => {
const scene = transformSaveModelToScene({ dashboard: snapshotableWithRowsDashboardJson as any, meta: {} }); const scene = transformSaveModelToScene({
dashboard: snapshotableWithRowsDashboardJson as DashboardDataDTO,
meta: {},
});
activateFullSceneTree(scene); activateFullSceneTree(scene);
@ -940,7 +950,7 @@ describe('transformSceneToSaveModel', () => {
let snapshot: Dashboard = {} as Dashboard; let snapshot: Dashboard = {} as Dashboard;
beforeEach(() => { beforeEach(() => {
const scene = transformSaveModelToScene({ dashboard: snapshotableDashboardJson as any, meta: {} }); const scene = transformSaveModelToScene({ dashboard: snapshotableDashboardJson as DashboardDataDTO, meta: {} });
activateFullSceneTree(scene); activateFullSceneTree(scene);
snapshot = transformSceneToSaveModel(scene, true); snapshot = transformSceneToSaveModel(scene, true);
}); });
@ -1004,7 +1014,7 @@ describe('transformSceneToSaveModel', () => {
}); });
it('should remove links', async () => { it('should remove links', async () => {
const scene = transformSaveModelToScene({ dashboard: snapshotableDashboardJson as any, meta: {} }); const scene = transformSaveModelToScene({ dashboard: snapshotableDashboardJson as DashboardDataDTO, meta: {} });
activateFullSceneTree(scene); activateFullSceneTree(scene);
const snapshot = transformSceneToSaveModel(scene, true); const snapshot = transformSceneToSaveModel(scene, true);
expect(snapshot.links?.length).toBe(1); expect(snapshot.links?.length).toBe(1);
@ -1104,7 +1114,10 @@ describe('transformSceneToSaveModel', () => {
describe('Given a scene with repeated panels and non-repeated panels', () => { describe('Given a scene with repeated panels and non-repeated panels', () => {
it('should save repeated panels itemHeight as height', () => { it('should save repeated panels itemHeight as height', () => {
const scene = transformSaveModelToScene({ dashboard: repeatingRowsAndPanelsDashboardJson as any, meta: {} }); const scene = transformSaveModelToScene({
dashboard: repeatingRowsAndPanelsDashboardJson as DashboardDataDTO,
meta: {},
});
const gridItem = sceneGraph.findByKey(scene, 'grid-item-2') as DashboardGridItem; const gridItem = sceneGraph.findByKey(scene, 'grid-item-2') as DashboardGridItem;
expect(gridItem).toBeInstanceOf(DashboardGridItem); expect(gridItem).toBeInstanceOf(DashboardGridItem);
expect(gridItem.state.height).toBe(10); expect(gridItem.state.height).toBe(10);
@ -1117,7 +1130,10 @@ describe('transformSceneToSaveModel', () => {
}); });
it('should not save non-repeated panels itemHeight as height', () => { it('should not save non-repeated panels itemHeight as height', () => {
const scene = transformSaveModelToScene({ dashboard: repeatingRowsAndPanelsDashboardJson as any, meta: {} }); const scene = transformSaveModelToScene({
dashboard: repeatingRowsAndPanelsDashboardJson as DashboardDataDTO,
meta: {},
});
const gridItem = sceneGraph.findByKey(scene, 'grid-item-15') as DashboardGridItem; const gridItem = sceneGraph.findByKey(scene, 'grid-item-15') as DashboardGridItem;
expect(gridItem).toBeInstanceOf(DashboardGridItem); expect(gridItem).toBeInstanceOf(DashboardGridItem);
expect(gridItem.state.height).toBe(2); expect(gridItem.state.height).toBe(2);

@ -135,7 +135,7 @@ export function getVisualizationOptions(props: OptionPaneRenderProps): OptionsPa
description: fieldOption.description, description: fieldOption.description,
overrides: getOptionOverrides(fieldOption, currentFieldConfig, data?.series), overrides: getOptionOverrides(fieldOption, currentFieldConfig, data?.series),
render: function renderEditor() { render: function renderEditor() {
const onChange = (v: any) => { const onChange = (v: unknown) => {
onFieldConfigsChange( onFieldConfigsChange(
updateDefaultFieldConfigValue(currentFieldConfig, fieldOption.path, v, fieldOption.isCustom) updateDefaultFieldConfigValue(currentFieldConfig, fieldOption.path, v, fieldOption.isCustom)
); );

@ -39,7 +39,7 @@ export function supportsDataQuery(plugin: PanelPlugin | undefined | null): boole
export const updateDefaultFieldConfigValue = ( export const updateDefaultFieldConfigValue = (
config: FieldConfigSource, config: FieldConfigSource,
name: string, name: string,
value: any, value: unknown,
isCustom?: boolean isCustom?: boolean
) => { ) => {
let defaults = { ...config.defaults }; let defaults = { ...config.defaults };

@ -3,6 +3,7 @@ import userEvent from '@testing-library/user-event';
import { DashboardModel } from 'app/features/dashboard/state'; import { DashboardModel } from 'app/features/dashboard/state';
import * as api from 'app/features/manage-dashboards/state/actions'; import * as api from 'app/features/manage-dashboards/state/actions';
import { SaveDashboardResponseDTO } from 'app/types';
import { SaveDashboardAsForm, SaveDashboardAsFormProps } from './SaveDashboardAsForm'; import { SaveDashboardAsForm, SaveDashboardAsFormProps } from './SaveDashboardAsForm';
@ -16,7 +17,7 @@ jest.mock('app/features/manage-dashboards/services/ValidationSrv', () => ({
jest.spyOn(api, 'searchFolders').mockResolvedValue([]); jest.spyOn(api, 'searchFolders').mockResolvedValue([]);
const prepareDashboardMock = (panel: any) => { const prepareDashboardMock = (panel: object) => {
const json = { const json = {
title: 'name', title: 'name',
panels: [panel], panels: [panel],
@ -43,7 +44,7 @@ const renderAndSubmitForm = async (
onSuccess={() => {}} onSuccess={() => {}}
onSubmit={async (jsonModel) => { onSubmit={async (jsonModel) => {
submitSpy(jsonModel); submitSpy(jsonModel);
return {}; return {} as SaveDashboardResponseDTO;
}} }}
{...otherProps} {...otherProps}
/> />

@ -4,6 +4,7 @@ import userEvent from '@testing-library/user-event';
import { Dashboard } from '@grafana/schema'; import { Dashboard } from '@grafana/schema';
import { DashboardModel } from 'app/features/dashboard/state'; import { DashboardModel } from 'app/features/dashboard/state';
import { createDashboardModelFixture } from 'app/features/dashboard/state/__fixtures__/dashboardFixtures'; import { createDashboardModelFixture } from 'app/features/dashboard/state/__fixtures__/dashboardFixtures';
import { SaveDashboardResponseDTO } from 'app/types';
import { SaveDashboardOptions } from '../types'; import { SaveDashboardOptions } from '../types';
@ -41,7 +42,7 @@ const renderAndSubmitForm = async (dashboard: DashboardModel, submitSpy: jest.Mo
onSuccess={() => {}} onSuccess={() => {}}
onSubmit={async (jsonModel) => { onSubmit={async (jsonModel) => {
submitSpy(jsonModel); submitSpy(jsonModel);
return { status: 'success' }; return { status: 'success' } as SaveDashboardResponseDTO;
}} }}
saveModel={{ saveModel={{
clone: dashboard.getSaveModelClone(), clone: dashboard.getSaveModelClone(),
@ -69,7 +70,7 @@ describe('SaveDashboardAsForm', () => {
onCancel={() => {}} onCancel={() => {}}
onSuccess={() => {}} onSuccess={() => {}}
onSubmit={async () => { onSubmit={async () => {
return {}; return {} as SaveDashboardResponseDTO;
}} }}
saveModel={{ saveModel={{
clone: { id: 1, schemaVersion: 3 }, clone: { id: 1, schemaVersion: 3 },
@ -132,7 +133,7 @@ describe('SaveDashboardAsForm', () => {
onCancel={() => {}} onCancel={() => {}}
onSuccess={() => {}} onSuccess={() => {}}
onSubmit={async () => { onSubmit={async () => {
return {}; return {} as SaveDashboardResponseDTO;
}} }}
saveModel={{ saveModel={{
clone: createDashboardModelFixture().getSaveModelClone(), clone: createDashboardModelFixture().getSaveModelClone(),

@ -7,6 +7,7 @@ import { config } from '@grafana/runtime';
import { Dashboard } from '@grafana/schema'; import { Dashboard } from '@grafana/schema';
import { Button, Checkbox, TextArea, useStyles2, Stack } from '@grafana/ui'; import { Button, Checkbox, TextArea, useStyles2, Stack } from '@grafana/ui';
import { DashboardModel } from 'app/features/dashboard/state'; import { DashboardModel } from 'app/features/dashboard/state';
import { SaveDashboardResponseDTO } from 'app/types';
import { GenAIDashboardChangesButton } from '../../GenAI/GenAIDashboardChangesButton'; import { GenAIDashboardChangesButton } from '../../GenAI/GenAIDashboardChangesButton';
import { SaveDashboardData, SaveDashboardOptions } from '../types'; import { SaveDashboardData, SaveDashboardOptions } from '../types';
@ -17,7 +18,11 @@ export type SaveProps = {
saveModel: SaveDashboardData; // already cloned saveModel: SaveDashboardData; // already cloned
onCancel: () => void; onCancel: () => void;
onSuccess: () => void; onSuccess: () => void;
onSubmit?: (saveModel: Dashboard, options: SaveDashboardOptions, dashboard: DashboardModel) => Promise<any>; onSubmit?: (
saveModel: Dashboard,
options: SaveDashboardOptions,
dashboard: DashboardModel
) => Promise<SaveDashboardResponseDTO>;
options: SaveDashboardOptions; options: SaveDashboardOptions;
onOptionsChange: (opts: SaveDashboardOptions) => void; onOptionsChange: (opts: SaveDashboardOptions) => void;
}; };

@ -2,6 +2,7 @@ import { Dashboard } from '@grafana/schema';
import { ObjectMeta } from 'app/features/apiserver/types'; import { ObjectMeta } from 'app/features/apiserver/types';
import { CloneOptions, DashboardModel } from 'app/features/dashboard/state/DashboardModel'; import { CloneOptions, DashboardModel } from 'app/features/dashboard/state/DashboardModel';
import { Diffs } from 'app/features/dashboard-scene/settings/version-history/utils'; import { Diffs } from 'app/features/dashboard-scene/settings/version-history/utils';
import { SaveDashboardResponseDTO } from 'app/types';
export interface SaveDashboardData { export interface SaveDashboardData {
clone: Dashboard; // cloned copy clone: Dashboard; // cloned copy
@ -33,7 +34,11 @@ export interface SaveDashboardFormProps {
isLoading: boolean; isLoading: boolean;
onCancel: () => void; onCancel: () => void;
onSuccess: () => void; onSuccess: () => void;
onSubmit?: (saveModel: Dashboard, options: SaveDashboardOptions, dashboard: DashboardModel) => Promise<any>; onSubmit?: (
saveModel: Dashboard,
options: SaveDashboardOptions,
dashboard: DashboardModel
) => Promise<SaveDashboardResponseDTO>;
} }
export interface SaveDashboardModalProps { export interface SaveDashboardModalProps {

@ -379,7 +379,7 @@ export class PanelStateWrapper extends PureComponent<Props, State> {
this.setState(stateUpdate); this.setState(stateUpdate);
}; };
onOptionsChange = (options: any) => { onOptionsChange = (options: object) => {
this.props.panel.updateOptions(options); this.props.panel.updateOptions(options);
}; };

@ -94,7 +94,7 @@ export function validateScaleOptions(options?: ScaleDimensionOptions): ScaleDime
export function validateScaleConfig(copy: ScaleDimensionConfig, options: ScaleDimensionOptions): ScaleDimensionConfig { export function validateScaleConfig(copy: ScaleDimensionConfig, options: ScaleDimensionOptions): ScaleDimensionConfig {
let { min, max } = validateScaleOptions(options); let { min, max } = validateScaleOptions(options);
if (!copy) { if (!copy) {
copy = {} as any; copy = {} as ScaleDimensionConfig;
} }
if (copy.max == null) { if (copy.max == null) {

@ -719,10 +719,10 @@ function setup(
}; };
}, },
getAnchorInfo(link) { getAnchorInfo(link) {
return { ...link }; return { ...link, href: link.url ?? '' };
}, },
getLinkUrl(link) { getLinkUrl(link) {
return link.url; return link.url ?? '';
}, },
}); });

@ -242,12 +242,12 @@ export const getCalculationValueDataLinksVariableSuggestions = (dataFrames: Data
export interface LinkService { export interface LinkService {
getDataLinkUIModel: <T>(link: DataLink, replaceVariables: InterpolateFunction | undefined, origin: T) => LinkModel<T>; getDataLinkUIModel: <T>(link: DataLink, replaceVariables: InterpolateFunction | undefined, origin: T) => LinkModel<T>;
getAnchorInfo: (link: any) => { getAnchorInfo: (link: DashboardLink) => {
href: string; href: string;
title: string; title: string;
tooltip: string; tooltip: string;
}; };
getLinkUrl: (link: any) => string; getLinkUrl: (link: DashboardLink) => string;
} }
export class LinkSrv implements LinkService { export class LinkSrv implements LinkService {
@ -268,7 +268,7 @@ export class LinkSrv implements LinkService {
return getConfig().disableSanitizeHtml ? url : textUtil.sanitizeUrl(url); return getConfig().disableSanitizeHtml ? url : textUtil.sanitizeUrl(url);
} }
getAnchorInfo(link: any) { getAnchorInfo(link: DashboardLink) {
const templateSrv = getTemplateSrv(); const templateSrv = getTemplateSrv();
return { return {
href: this.getLinkUrl(link), href: this.getLinkUrl(link),

@ -165,7 +165,7 @@ describe('linkSrv', () => {
url: '/graph?home=$home', url: '/graph?home=$home',
title: 'Visit home', title: 'Visit home',
tooltip: 'Visit ${home:raw}', tooltip: 'Visit ${home:raw}',
}); } as unknown as DashboardLink);
expect(linkSrv.getLinkUrl).toBeCalledTimes(1); expect(linkSrv.getLinkUrl).toBeCalledTimes(1);
expect(templateSrv.replace).toBeCalledTimes(3); expect(templateSrv.replace).toBeCalledTimes(3);

@ -144,7 +144,7 @@ export class DatasourceSrv implements DataSourceService {
return this.loadDatasource(nameOrUid); return this.loadDatasource(nameOrUid);
} }
async loadDatasource(key: string): Promise<DataSourceApi<any, any>> { async loadDatasource(key: string): Promise<DataSourceApi> {
if (this.datasources[key]) { if (this.datasources[key]) {
return Promise.resolve(this.datasources[key]); return Promise.resolve(this.datasources[key]);
} }
@ -164,7 +164,7 @@ export class DatasourceSrv implements DataSourceService {
// If there is only one constructor argument it is instanceSettings // If there is only one constructor argument it is instanceSettings
const useAngular = dsPlugin.DataSourceClass.length !== 1; const useAngular = dsPlugin.DataSourceClass.length !== 1;
let instance: DataSourceApi<any, any>; let instance: DataSourceApi;
if (useAngular) { if (useAngular) {
instance = getLegacyAngularInjector().instantiate(dsPlugin.DataSourceClass, { instance = getLegacyAngularInjector().instantiate(dsPlugin.DataSourceClass, {
@ -184,7 +184,7 @@ export class DatasourceSrv implements DataSourceService {
anyInstance.type = instanceSettings.type; anyInstance.type = instanceSettings.type;
anyInstance.meta = instanceSettings.meta; anyInstance.meta = instanceSettings.meta;
anyInstance.uid = instanceSettings.uid; anyInstance.uid = instanceSettings.uid;
(instance as any).getRef = DataSourceApi.prototype.getRef; anyInstance.getRef = DataSourceApi.prototype.getRef;
} }
// store in instance cache // store in instance cache

Loading…
Cancel
Save