-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3df6441
commit 01d92fd
Showing
5 changed files
with
96 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Due to the grafana/ui Icon component making fetch requests to | ||
// `/public/img/icon/<icon_name>.svg` we need to mock react-inlinesvg to prevent | ||
// the failed fetch requests from displaying errors in console. | ||
|
||
import React from 'react'; | ||
|
||
type Callback = (...args: any[]) => void; | ||
|
||
export interface StorageItem { | ||
content: string; | ||
queue: Callback[]; | ||
status: string; | ||
} | ||
|
||
export const cacheStore: { [key: string]: StorageItem } = Object.create(null); | ||
|
||
const SVG_FILE_NAME_REGEX = /(.+)\/(.+)\.svg$/; | ||
|
||
const InlineSVG = ({ src }: { src: string }) => { | ||
// testId will be the file name without extension (e.g. `public/img/icons/angle-double-down.svg` -> `angle-double-down`) | ||
const testId = src.replace(SVG_FILE_NAME_REGEX, '$2'); | ||
return <svg xmlns="http://www.w3.org/2000/svg" data-testid={testId} viewBox="0 0 24 24" />; | ||
}; | ||
|
||
export default InlineSVG; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️ | ||
* | ||
* In order to extend the configuration follow the steps in .config/README.md | ||
*/ | ||
|
||
/* | ||
* This utility function is useful in combination with jest `transformIgnorePatterns` config | ||
* to transform specific packages (e.g.ES modules) in a projects node_modules folder. | ||
*/ | ||
const nodeModulesToTransform = (moduleNames) => `node_modules\/(?!(${moduleNames.join('|')})\/)`; | ||
|
||
// Array of known nested grafana package dependencies that only bundle an ESM version | ||
const grafanaESModules = [ | ||
'd3', | ||
'd3-color', | ||
'd3-force', | ||
'd3-interpolate', | ||
'd3-scale-chromatic', | ||
'ol', | ||
'react-colorful', | ||
'uuid', | ||
]; | ||
|
||
module.exports = { | ||
nodeModulesToTransform, | ||
grafanaESModules | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters