From 1fd1bb5dffc32c0a733cc3e987b42eb850b04cbd Mon Sep 17 00:00:00 2001 From: Jack Westbrook Date: Wed, 27 Mar 2024 18:35:08 +0100 Subject: [PATCH] refactor(frontend): update imports of tether-drop to point to vendor directory --- public/app/angular/components/info_popover.ts | 6 ++++-- public/app/angular/services/popover_srv.ts | 6 ++++-- public/app/core/navigation/GrafanaRoute.tsx | 11 ++++++----- public/app/plugins/panel/graph/jquery.flot.events.ts | 5 +++-- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/public/app/angular/components/info_popover.ts b/public/app/angular/components/info_popover.ts index 41417f5a680..e78bb0ba72c 100644 --- a/public/app/angular/components/info_popover.ts +++ b/public/app/angular/components/info_popover.ts @@ -1,9 +1,10 @@ import { each } from 'lodash'; -// @ts-ignore -import Drop from 'tether-drop'; import coreModule from 'app/angular/core_module'; +// @ts-ignore +import Drop from '../../../vendor/tether-drop'; + export function infoPopover() { return { restrict: 'E', @@ -54,6 +55,7 @@ export function infoPopover() { // Create drop in next digest after directive content is rendered. scope.$applyAsync(() => { + // @ts-ignore const drop = new Drop(dropOptions); const unbind = scope.$on('$destroy', () => { diff --git a/public/app/angular/services/popover_srv.ts b/public/app/angular/services/popover_srv.ts index 3afd2810202..56ec5375d14 100644 --- a/public/app/angular/services/popover_srv.ts +++ b/public/app/angular/services/popover_srv.ts @@ -1,10 +1,11 @@ import { extend } from 'lodash'; -// @ts-ignore -import Drop from 'tether-drop'; import { GrafanaRootScope } from 'app/angular/GrafanaCtrl'; import coreModule from 'app/angular/core_module'; +// @ts-ignore +import Drop from '../../../vendor/tether-drop'; + coreModule.service('popoverSrv', ['$compile', '$rootScope', '$timeout', popoverSrv]); function popoverSrv(this: any, $compile: any, $rootScope: GrafanaRootScope, $timeout: any) { @@ -51,6 +52,7 @@ function popoverSrv(this: any, $compile: any, $rootScope: GrafanaRootScope, $tim $compile(contentElement)(scope); $timeout(() => { + // @ts-ignore drop = new Drop({ target: options.element, content: contentElement, diff --git a/public/app/core/navigation/GrafanaRoute.tsx b/public/app/core/navigation/GrafanaRoute.tsx index 1a49e9fb762..4c7756b6478 100644 --- a/public/app/core/navigation/GrafanaRoute.tsx +++ b/public/app/core/navigation/GrafanaRoute.tsx @@ -1,11 +1,11 @@ import { Suspense, useEffect, useLayoutEffect } from 'react'; import { Navigate, useLocation } from 'react-router-dom-v5-compat'; -// @ts-ignore -import Drop from 'tether-drop'; import { locationSearchToObject, navigationLogger, reportPageview } from '@grafana/runtime'; import { ErrorBoundary } from '@grafana/ui'; +// @ts-ignore +import Drop from '../../../vendor/tether-drop'; import { useGrafana } from '../context/GrafanaContext'; import { contextSrv } from '../services/context_srv'; @@ -102,7 +102,8 @@ function cleanupDOM() { // cleanup tether-drop // TODO: Vite doesn't like this. Pretty sure the lib is incompatible with Vite. - // for (const drop of Drop.drops) { - // drop.destroy(); - // } + // @ts-ignore + for (const drop of Drop.drops) { + drop.destroy(); + } } diff --git a/public/app/plugins/panel/graph/jquery.flot.events.ts b/public/app/plugins/panel/graph/jquery.flot.events.ts index d6083432c5c..b0e296ef109 100644 --- a/public/app/plugins/panel/graph/jquery.flot.events.ts +++ b/public/app/plugins/panel/graph/jquery.flot.events.ts @@ -1,11 +1,12 @@ import 'jquery'; import { partition, each } from 'lodash'; -//@ts-ignore -import Drop from 'tether-drop'; import { CreatePlotOverlay } from '@grafana/data'; import { getLegacyAngularInjector } from '@grafana/runtime'; +//@ts-ignore +import Drop from '../../../vendor/tether-drop'; + const createAnnotationToolip: CreatePlotOverlay = (element, event, plot) => { const injector = getLegacyAngularInjector(); const content = document.createElement('div');