Skip to content

Commit 8f5b549

Browse files
authored
Merge pull request #568 from kinvolk/svg-fix
SVG fix, headlamp-plugin 0.4.9
2 parents 7cf3a26 + 4d9dc92 commit 8f5b549

File tree

10 files changed

+3103
-1444
lines changed

10 files changed

+3103
-1444
lines changed

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
"test": "cross-env TEST_TZ=true react-scripts test",
9191
"eject": "react-scripts eject",
9292
"lint": "eslint -c package.json --ext .js,.ts,.tsx src/ ../app/electron ../plugins/headlamp-plugin --ignore-pattern ../plugins/headlamp-plugin/template",
93-
"format": "prettier --config package.json --write src ../app/electron ../plugins/headlamp-plugin/bin ../plugins/headlamp-plugin/lib ../plugins/headlamp-plugin/config",
93+
"format": "prettier --config package.json --write src ../app/electron ../plugins/headlamp-plugin/bin ../plugins/headlamp-plugin/lib ../plugins/headlamp-plugin/config ../plugins/headlamp-plugin/template",
9494
"format-check": "prettier --config package.json --check src ../app/electron ../plugins/headlamp-plugin",
9595
"storybook": "start-storybook -p 6006 -s public",
9696
"build-typedoc": "npx typedoc",

frontend/src/plugin/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ window.pluginLib = {
1717
MuiCore: require('@material-ui/core'),
1818
MuiStyles: require('@material-ui/styles'),
1919
React: require('react'),
20+
ReactDOM: require('react-dom'),
2021
Recharts: require('recharts'),
2122
ReactRouter: require('react-router-dom'),
2223
ReactRedux: require('react-redux'),

frontend/src/plugin/lib.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@
6262
*
6363
* Third party Libraries in window.pluginLib that can be used by plugins.
6464
*
65-
* - ReactRedux, {@link https://www.npmjs.com/package/@material-ui/core @material-ui/core}
65+
* - MuiCore, {@link https://www.npmjs.com/package/@material-ui/core @material-ui/core}
6666
* - MuiStyles, {@link https://www.npmjs.com/package/@material-ui/styles @material-ui/styles}
6767
* - React, {@link https://www.npmjs.com/package/react react}
68+
* - ReactDOM, {@link https://www.npmjs.com/package/react-dom react-dom}
6869
* - ReactRedux, {@link https://www.npmjs.com/package/react-redux react-redux}
6970
* - Iconify, {@link https://www.npmjs.com/package/@iconify/react @iconify/react}
7071
* - Lodash, {@link https://www.npmjs.com/package/lodash lodash}
@@ -78,9 +79,6 @@
7879
import { ClusterRequest, setCluster } from '../lib/k8s/apiProxy';
7980
import Registry from './registry';
8081

81-
// @todo: types for CommonComponents, K8s, and Utils should be put into plugins-pkg.
82-
// Because available in window.pluginLib.
83-
8482
/**
8583
* Plugins should call Headlamp.registerPlugin(pluginId: string, pluginObj: Plugin) to register themselves.
8684
*

plugins/headlamp-plugin/config/webpack.config.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const externalModules = {
55
recharts: 'pluginLib.Recharts',
66
'react-router': 'pluginLib.ReactRouter',
77
'react-redux': 'pluginLib.ReactRedux',
8+
'react-dom': 'pluginLib.ReactDOM',
89
'@iconify/react': 'pluginLib.Iconify',
910
lodash: 'pluginLib.Lodash',
1011
notistack: 'pluginLib.Notistack',
@@ -67,7 +68,27 @@ module.exports = {
6768
},
6869
},
6970
{
70-
test: /\.(jpe?g|gif|png|svg)$/i,
71+
test: /\.svg$/,
72+
use: [
73+
{
74+
loader: require.resolve('@svgr/webpack'),
75+
options: {
76+
prettier: false,
77+
svgo: false,
78+
svgoConfig: {
79+
plugins: [{ removeViewBox: false }],
80+
},
81+
titleProp: true,
82+
ref: true,
83+
},
84+
},
85+
],
86+
issuer: {
87+
and: [/\.(ts|tsx|js|jsx|md|mdx)$/],
88+
},
89+
},
90+
{
91+
test: /\.(jpe?g|gif|png)$/i,
7192
use: [
7293
{
7394
loader: require.resolve('url-loader'),
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/// <reference types="node" />
2+
/// <reference types="react" />
3+
/// <reference types="react-dom" />
4+
5+
declare namespace NodeJS {
6+
interface ProcessEnv {
7+
readonly NODE_ENV: 'development' | 'production' | 'test';
8+
readonly PUBLIC_URL: string;
9+
}
10+
}
11+
12+
declare module '*.avif' {
13+
const src: string;
14+
export default src;
15+
}
16+
17+
declare module '*.bmp' {
18+
const src: string;
19+
export default src;
20+
}
21+
22+
declare module '*.gif' {
23+
const src: string;
24+
export default src;
25+
}
26+
27+
declare module '*.jpg' {
28+
const src: string;
29+
export default src;
30+
}
31+
32+
declare module '*.jpeg' {
33+
const src: string;
34+
export default src;
35+
}
36+
37+
declare module '*.png' {
38+
const src: string;
39+
export default src;
40+
}
41+
42+
declare module '*.webp' {
43+
const src: string;
44+
export default src;
45+
}
46+
47+
declare module '*.svg' {
48+
import * as React from 'react';
49+
50+
export const ReactComponent: React.FunctionComponent<
51+
React.SVGProps<SVGSVGElement> & { title?: string }
52+
>;
53+
54+
const src: string;
55+
export default src;
56+
}

0 commit comments

Comments
 (0)