@perses-dev/dashboards 0.51.1 → 0.52.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/DownloadButton/DownloadButton.js +3 -33
- package/dist/cjs/components/DownloadButton/serializeDashboard.js +64 -0
- package/dist/components/DownloadButton/DownloadButton.d.ts.map +1 -1
- package/dist/components/DownloadButton/DownloadButton.js +3 -33
- package/dist/components/DownloadButton/DownloadButton.js.map +1 -1
- package/dist/components/DownloadButton/serializeDashboard.d.ts +8 -0
- package/dist/components/DownloadButton/serializeDashboard.d.ts.map +1 -0
- package/dist/components/DownloadButton/serializeDashboard.js +56 -0
- package/dist/components/DownloadButton/serializeDashboard.js.map +1 -0
- package/package.json +5 -5
|
@@ -25,8 +25,8 @@ const _material = require("@mui/material");
|
|
|
25
25
|
const _components = require("@perses-dev/components");
|
|
26
26
|
const _DownloadOutline = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/DownloadOutline"));
|
|
27
27
|
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
28
|
-
const _yaml = require("yaml");
|
|
29
28
|
const _context = require("../../context");
|
|
29
|
+
const _serializeDashboard = require("./serializeDashboard");
|
|
30
30
|
function _interop_require_default(obj) {
|
|
31
31
|
return obj && obj.__esModule ? obj : {
|
|
32
32
|
default: obj
|
|
@@ -83,43 +83,13 @@ function DownloadButton() {
|
|
|
83
83
|
};
|
|
84
84
|
const handleItemClick = (format, shape)=>()=>{
|
|
85
85
|
setAnchorEl(null);
|
|
86
|
-
|
|
87
|
-
switch(format){
|
|
88
|
-
case 'json':
|
|
89
|
-
type = 'application/json';
|
|
90
|
-
content = JSON.stringify(dashboard, null, 2);
|
|
91
|
-
break;
|
|
92
|
-
case 'yaml':
|
|
93
|
-
{
|
|
94
|
-
type = 'application/yaml';
|
|
95
|
-
if (shape === 'cr') {
|
|
96
|
-
const name = dashboard.metadata.name.toLowerCase().replace(/[^a-z0-9-]/g, '-');
|
|
97
|
-
content = (0, _yaml.stringify)({
|
|
98
|
-
apiVersion: 'perses.dev/v1alpha1',
|
|
99
|
-
kind: 'PersesDashboard',
|
|
100
|
-
metadata: {
|
|
101
|
-
labels: {
|
|
102
|
-
'app.kubernetes.io/name': 'perses-dashboard',
|
|
103
|
-
'app.kubernetes.io/instance': name,
|
|
104
|
-
'app.kubernetes.io/part-of': 'perses-operator'
|
|
105
|
-
},
|
|
106
|
-
name,
|
|
107
|
-
namespace: dashboard.metadata.project
|
|
108
|
-
},
|
|
109
|
-
spec: dashboard.spec
|
|
110
|
-
});
|
|
111
|
-
} else {
|
|
112
|
-
content = (0, _yaml.stringify)(dashboard);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
86
|
+
const { contentType, content } = (0, _serializeDashboard.serializeDashboard)(dashboard, format, shape);
|
|
117
87
|
if (!hiddenLinkRef || !hiddenLinkRef.current) return;
|
|
118
88
|
// Create blob URL
|
|
119
89
|
const hiddenLinkUrl = URL.createObjectURL(new Blob([
|
|
120
90
|
content
|
|
121
91
|
], {
|
|
122
|
-
type
|
|
92
|
+
type: contentType
|
|
123
93
|
}));
|
|
124
94
|
// Simulate click
|
|
125
95
|
hiddenLinkRef.current.download = `${dashboard.metadata.name}${shape === 'cr' ? '-cr' : ''}.${format}`;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "serializeDashboard", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return serializeDashboard;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _yaml = require("yaml");
|
|
24
|
+
function serializeYaml(dashboard, shape) {
|
|
25
|
+
let content;
|
|
26
|
+
if (shape === 'cr') {
|
|
27
|
+
const name = dashboard.metadata.name.toLowerCase().replace(/[^a-z0-9-]/g, '-');
|
|
28
|
+
content = (0, _yaml.stringify)({
|
|
29
|
+
apiVersion: 'perses.dev/v1alpha1',
|
|
30
|
+
kind: 'PersesDashboard',
|
|
31
|
+
metadata: {
|
|
32
|
+
labels: {
|
|
33
|
+
'app.kubernetes.io/name': 'perses-dashboard',
|
|
34
|
+
'app.kubernetes.io/instance': name,
|
|
35
|
+
'app.kubernetes.io/part-of': 'perses-operator'
|
|
36
|
+
},
|
|
37
|
+
name,
|
|
38
|
+
namespace: dashboard.metadata.project
|
|
39
|
+
},
|
|
40
|
+
spec: dashboard.spec
|
|
41
|
+
}, {
|
|
42
|
+
schema: 'yaml-1.1'
|
|
43
|
+
});
|
|
44
|
+
} else {
|
|
45
|
+
content = (0, _yaml.stringify)(dashboard, {
|
|
46
|
+
schema: 'yaml-1.1'
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
contentType: 'application/yaml',
|
|
51
|
+
content
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function serializeDashboard(dashboard, format, shape) {
|
|
55
|
+
switch(format){
|
|
56
|
+
case 'json':
|
|
57
|
+
return {
|
|
58
|
+
contentType: 'application/json',
|
|
59
|
+
content: JSON.stringify(dashboard, null, 2)
|
|
60
|
+
};
|
|
61
|
+
case 'yaml':
|
|
62
|
+
return serializeYaml(dashboard, shape);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DownloadButton.d.ts","sourceRoot":"","sources":["../../../src/components/DownloadButton/DownloadButton.tsx"],"names":[],"mappings":"AAgBA,OAAc,EAAE,YAAY,EAAU,MAAM,OAAO,CAAC;AAKpD,wBAAgB,cAAc,IAAI,YAAY,
|
|
1
|
+
{"version":3,"file":"DownloadButton.d.ts","sourceRoot":"","sources":["../../../src/components/DownloadButton/DownloadButton.tsx"],"names":[],"mappings":"AAgBA,OAAc,EAAE,YAAY,EAAU,MAAM,OAAO,CAAC;AAKpD,wBAAgB,cAAc,IAAI,YAAY,CA+D7C"}
|
|
@@ -15,8 +15,8 @@ import { ClickAwayListener, Menu, MenuItem, MenuList } from '@mui/material';
|
|
|
15
15
|
import { ToolbarIconButton } from '@perses-dev/components';
|
|
16
16
|
import DownloadIcon from 'mdi-material-ui/DownloadOutline';
|
|
17
17
|
import React, { useRef } from 'react';
|
|
18
|
-
import { stringify } from 'yaml';
|
|
19
18
|
import { useDashboard } from '../../context';
|
|
19
|
+
import { serializeDashboard } from './serializeDashboard';
|
|
20
20
|
// Button that enables downloading the dashboard as a JSON file
|
|
21
21
|
export function DownloadButton() {
|
|
22
22
|
const { dashboard } = useDashboard();
|
|
@@ -28,43 +28,13 @@ export function DownloadButton() {
|
|
|
28
28
|
};
|
|
29
29
|
const handleItemClick = (format, shape)=>()=>{
|
|
30
30
|
setAnchorEl(null);
|
|
31
|
-
|
|
32
|
-
switch(format){
|
|
33
|
-
case 'json':
|
|
34
|
-
type = 'application/json';
|
|
35
|
-
content = JSON.stringify(dashboard, null, 2);
|
|
36
|
-
break;
|
|
37
|
-
case 'yaml':
|
|
38
|
-
{
|
|
39
|
-
type = 'application/yaml';
|
|
40
|
-
if (shape === 'cr') {
|
|
41
|
-
const name = dashboard.metadata.name.toLowerCase().replace(/[^a-z0-9-]/g, '-');
|
|
42
|
-
content = stringify({
|
|
43
|
-
apiVersion: 'perses.dev/v1alpha1',
|
|
44
|
-
kind: 'PersesDashboard',
|
|
45
|
-
metadata: {
|
|
46
|
-
labels: {
|
|
47
|
-
'app.kubernetes.io/name': 'perses-dashboard',
|
|
48
|
-
'app.kubernetes.io/instance': name,
|
|
49
|
-
'app.kubernetes.io/part-of': 'perses-operator'
|
|
50
|
-
},
|
|
51
|
-
name,
|
|
52
|
-
namespace: dashboard.metadata.project
|
|
53
|
-
},
|
|
54
|
-
spec: dashboard.spec
|
|
55
|
-
});
|
|
56
|
-
} else {
|
|
57
|
-
content = stringify(dashboard);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
31
|
+
const { contentType, content } = serializeDashboard(dashboard, format, shape);
|
|
62
32
|
if (!hiddenLinkRef || !hiddenLinkRef.current) return;
|
|
63
33
|
// Create blob URL
|
|
64
34
|
const hiddenLinkUrl = URL.createObjectURL(new Blob([
|
|
65
35
|
content
|
|
66
36
|
], {
|
|
67
|
-
type
|
|
37
|
+
type: contentType
|
|
68
38
|
}));
|
|
69
39
|
// Simulate click
|
|
70
40
|
hiddenLinkRef.current.download = `${dashboard.metadata.name}${shape === 'cr' ? '-cr' : ''}.${format}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/DownloadButton/DownloadButton.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ClickAwayListener, Menu, MenuItem, MenuList } from '@mui/material';\nimport { ToolbarIconButton } from '@perses-dev/components';\nimport DownloadIcon from 'mdi-material-ui/DownloadOutline';\nimport React, { ReactElement, useRef } from 'react';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/components/DownloadButton/DownloadButton.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ClickAwayListener, Menu, MenuItem, MenuList } from '@mui/material';\nimport { ToolbarIconButton } from '@perses-dev/components';\nimport DownloadIcon from 'mdi-material-ui/DownloadOutline';\nimport React, { ReactElement, useRef } from 'react';\nimport { useDashboard } from '../../context';\nimport { serializeDashboard } from './serializeDashboard';\n\n// Button that enables downloading the dashboard as a JSON file\nexport function DownloadButton(): ReactElement {\n const { dashboard } = useDashboard();\n const hiddenLinkRef = useRef<HTMLAnchorElement>(null);\n const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);\n const open = Boolean(anchorEl);\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>): void => {\n setAnchorEl(event.currentTarget);\n };\n const handleItemClick = (format: 'json' | 'yaml', shape?: 'cr') => (): void => {\n setAnchorEl(null);\n\n const { contentType, content } = serializeDashboard(dashboard, format, shape);\n\n if (!hiddenLinkRef || !hiddenLinkRef.current) return;\n // Create blob URL\n const hiddenLinkUrl = URL.createObjectURL(new Blob([content], { type: contentType }));\n // Simulate click\n hiddenLinkRef.current.download = `${dashboard.metadata.name}${shape === 'cr' ? '-cr' : ''}.${format}`;\n hiddenLinkRef.current.href = hiddenLinkUrl;\n hiddenLinkRef.current.click();\n // Remove blob URL (for memory management)\n URL.revokeObjectURL(hiddenLinkUrl);\n };\n\n return (\n <>\n <ToolbarIconButton\n id=\"download-dashboard-button\"\n aria-controls={open ? 'basic-menu' : undefined}\n aria-haspopup=\"true\"\n aria-expanded={open ? 'true' : undefined}\n onClick={handleClick}\n >\n <DownloadIcon />\n </ToolbarIconButton>\n\n <Menu\n id=\"download-dashboard-formats\"\n anchorEl={anchorEl}\n open={open}\n hideBackdrop={true}\n onClose={() => setAnchorEl(null)}\n MenuListProps={{\n 'aria-labelledby': 'download-dashboard-button',\n }}\n >\n <div>\n <ClickAwayListener onClickAway={() => setAnchorEl(null)}>\n <MenuList>\n <MenuItem onClick={handleItemClick('json')}>JSON</MenuItem>\n <MenuItem onClick={handleItemClick('yaml')}>YAML</MenuItem>\n <MenuItem onClick={handleItemClick('yaml', 'cr')}>YAML (CR)</MenuItem>\n </MenuList>\n </ClickAwayListener>\n </div>\n </Menu>\n\n {/* Hidden link to download the dashboard as a JSON or YAML file */}\n {/* eslint-disable jsx-a11y/anchor-has-content */}\n {/* eslint-disable jsx-a11y/anchor-is-valid */}\n <a ref={hiddenLinkRef} style={{ display: 'none' }} />\n </>\n );\n}\n"],"names":["ClickAwayListener","Menu","MenuItem","MenuList","ToolbarIconButton","DownloadIcon","React","useRef","useDashboard","serializeDashboard","DownloadButton","dashboard","hiddenLinkRef","anchorEl","setAnchorEl","useState","open","Boolean","handleClick","event","currentTarget","handleItemClick","format","shape","contentType","content","current","hiddenLinkUrl","URL","createObjectURL","Blob","type","download","metadata","name","href","click","revokeObjectURL","id","aria-controls","undefined","aria-haspopup","aria-expanded","onClick","hideBackdrop","onClose","MenuListProps","div","onClickAway","a","ref","style","display"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,iBAAiB,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,gBAAgB;AAC5E,SAASC,iBAAiB,QAAQ,yBAAyB;AAC3D,OAAOC,kBAAkB,kCAAkC;AAC3D,OAAOC,SAAuBC,MAAM,QAAQ,QAAQ;AACpD,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,kBAAkB,QAAQ,uBAAuB;AAE1D,+DAA+D;AAC/D,OAAO,SAASC;IACd,MAAM,EAAEC,SAAS,EAAE,GAAGH;IACtB,MAAMI,gBAAgBL,OAA0B;IAChD,MAAM,CAACM,UAAUC,YAAY,GAAGR,MAAMS,QAAQ,CAAqB;IACnE,MAAMC,OAAOC,QAAQJ;IACrB,MAAMK,cAAc,CAACC;QACnBL,YAAYK,MAAMC,aAAa;IACjC;IACA,MAAMC,kBAAkB,CAACC,QAAyBC,QAAiB;YACjET,YAAY;YAEZ,MAAM,EAAEU,WAAW,EAAEC,OAAO,EAAE,GAAGhB,mBAAmBE,WAAWW,QAAQC;YAEvE,IAAI,CAACX,iBAAiB,CAACA,cAAcc,OAAO,EAAE;YAC9C,kBAAkB;YAClB,MAAMC,gBAAgBC,IAAIC,eAAe,CAAC,IAAIC,KAAK;gBAACL;aAAQ,EAAE;gBAAEM,MAAMP;YAAY;YAClF,iBAAiB;YACjBZ,cAAcc,OAAO,CAACM,QAAQ,GAAG,GAAGrB,UAAUsB,QAAQ,CAACC,IAAI,GAAGX,UAAU,OAAO,QAAQ,GAAG,CAAC,EAAED,QAAQ;YACrGV,cAAcc,OAAO,CAACS,IAAI,GAAGR;YAC7Bf,cAAcc,OAAO,CAACU,KAAK;YAC3B,0CAA0C;YAC1CR,IAAIS,eAAe,CAACV;QACtB;IAEA,qBACE;;0BACE,KAACvB;gBACCkC,IAAG;gBACHC,iBAAevB,OAAO,eAAewB;gBACrCC,iBAAc;gBACdC,iBAAe1B,OAAO,SAASwB;gBAC/BG,SAASzB;0BAET,cAAA,KAACb;;0BAGH,KAACJ;gBACCqC,IAAG;gBACHzB,UAAUA;gBACVG,MAAMA;gBACN4B,cAAc;gBACdC,SAAS,IAAM/B,YAAY;gBAC3BgC,eAAe;oBACb,mBAAmB;gBACrB;0BAEA,cAAA,KAACC;8BACC,cAAA,KAAC/C;wBAAkBgD,aAAa,IAAMlC,YAAY;kCAChD,cAAA,MAACX;;8CACC,KAACD;oCAASyC,SAAStB,gBAAgB;8CAAS;;8CAC5C,KAACnB;oCAASyC,SAAStB,gBAAgB;8CAAS;;8CAC5C,KAACnB;oCAASyC,SAAStB,gBAAgB,QAAQ;8CAAO;;;;;;;0BAS1D,KAAC4B;gBAAEC,KAAKtC;gBAAeuC,OAAO;oBAAEC,SAAS;gBAAO;;;;AAGtD"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DashboardResource, EphemeralDashboardResource } from '@perses-dev/core';
|
|
2
|
+
type SerializedDashboard = {
|
|
3
|
+
contentType: string;
|
|
4
|
+
content: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function serializeDashboard(dashboard: DashboardResource | EphemeralDashboardResource, format: 'json' | 'yaml', shape?: 'cr'): SerializedDashboard;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=serializeDashboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializeDashboard.d.ts","sourceRoot":"","sources":["../../../src/components/DownloadButton/serializeDashboard.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAGjF,KAAK,mBAAmB,GAAG;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AA+BF,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,iBAAiB,GAAG,0BAA0B,EACzD,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,KAAK,CAAC,EAAE,IAAI,GACX,mBAAmB,CAOrB"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { stringify } from 'yaml';
|
|
14
|
+
function serializeYaml(dashboard, shape) {
|
|
15
|
+
let content;
|
|
16
|
+
if (shape === 'cr') {
|
|
17
|
+
const name = dashboard.metadata.name.toLowerCase().replace(/[^a-z0-9-]/g, '-');
|
|
18
|
+
content = stringify({
|
|
19
|
+
apiVersion: 'perses.dev/v1alpha1',
|
|
20
|
+
kind: 'PersesDashboard',
|
|
21
|
+
metadata: {
|
|
22
|
+
labels: {
|
|
23
|
+
'app.kubernetes.io/name': 'perses-dashboard',
|
|
24
|
+
'app.kubernetes.io/instance': name,
|
|
25
|
+
'app.kubernetes.io/part-of': 'perses-operator'
|
|
26
|
+
},
|
|
27
|
+
name,
|
|
28
|
+
namespace: dashboard.metadata.project
|
|
29
|
+
},
|
|
30
|
+
spec: dashboard.spec
|
|
31
|
+
}, {
|
|
32
|
+
schema: 'yaml-1.1'
|
|
33
|
+
});
|
|
34
|
+
} else {
|
|
35
|
+
content = stringify(dashboard, {
|
|
36
|
+
schema: 'yaml-1.1'
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
contentType: 'application/yaml',
|
|
41
|
+
content
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export function serializeDashboard(dashboard, format, shape) {
|
|
45
|
+
switch(format){
|
|
46
|
+
case 'json':
|
|
47
|
+
return {
|
|
48
|
+
contentType: 'application/json',
|
|
49
|
+
content: JSON.stringify(dashboard, null, 2)
|
|
50
|
+
};
|
|
51
|
+
case 'yaml':
|
|
52
|
+
return serializeYaml(dashboard, shape);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=serializeDashboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/DownloadButton/serializeDashboard.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DashboardResource, EphemeralDashboardResource } from '@perses-dev/core';\nimport { stringify } from 'yaml';\n\ntype SerializedDashboard = {\n contentType: string;\n content: string;\n};\n\nfunction serializeYaml(dashboard: DashboardResource | EphemeralDashboardResource, shape?: 'cr'): SerializedDashboard {\n let content: string;\n\n if (shape === 'cr') {\n const name = dashboard.metadata.name.toLowerCase().replace(/[^a-z0-9-]/g, '-');\n content = stringify(\n {\n apiVersion: 'perses.dev/v1alpha1',\n kind: 'PersesDashboard',\n metadata: {\n labels: {\n 'app.kubernetes.io/name': 'perses-dashboard',\n 'app.kubernetes.io/instance': name,\n 'app.kubernetes.io/part-of': 'perses-operator',\n },\n name,\n namespace: dashboard.metadata.project,\n },\n spec: dashboard.spec,\n },\n { schema: 'yaml-1.1' }\n );\n } else {\n content = stringify(dashboard, { schema: 'yaml-1.1' });\n }\n\n return { contentType: 'application/yaml', content };\n}\n\nexport function serializeDashboard(\n dashboard: DashboardResource | EphemeralDashboardResource,\n format: 'json' | 'yaml',\n shape?: 'cr'\n): SerializedDashboard {\n switch (format) {\n case 'json':\n return { contentType: 'application/json', content: JSON.stringify(dashboard, null, 2) };\n case 'yaml':\n return serializeYaml(dashboard, shape);\n }\n}\n"],"names":["stringify","serializeYaml","dashboard","shape","content","name","metadata","toLowerCase","replace","apiVersion","kind","labels","namespace","project","spec","schema","contentType","serializeDashboard","format","JSON"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,SAAS,QAAQ,OAAO;AAOjC,SAASC,cAAcC,SAAyD,EAAEC,KAAY;IAC5F,IAAIC;IAEJ,IAAID,UAAU,MAAM;QAClB,MAAME,OAAOH,UAAUI,QAAQ,CAACD,IAAI,CAACE,WAAW,GAAGC,OAAO,CAAC,eAAe;QAC1EJ,UAAUJ,UACR;YACES,YAAY;YACZC,MAAM;YACNJ,UAAU;gBACRK,QAAQ;oBACN,0BAA0B;oBAC1B,8BAA8BN;oBAC9B,6BAA6B;gBAC/B;gBACAA;gBACAO,WAAWV,UAAUI,QAAQ,CAACO,OAAO;YACvC;YACAC,MAAMZ,UAAUY,IAAI;QACtB,GACA;YAAEC,QAAQ;QAAW;IAEzB,OAAO;QACLX,UAAUJ,UAAUE,WAAW;YAAEa,QAAQ;QAAW;IACtD;IAEA,OAAO;QAAEC,aAAa;QAAoBZ;IAAQ;AACpD;AAEA,OAAO,SAASa,mBACdf,SAAyD,EACzDgB,MAAuB,EACvBf,KAAY;IAEZ,OAAQe;QACN,KAAK;YACH,OAAO;gBAAEF,aAAa;gBAAoBZ,SAASe,KAAKnB,SAAS,CAACE,WAAW,MAAM;YAAG;QACxF,KAAK;YACH,OAAOD,cAAcC,WAAWC;IACpC;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perses-dev/dashboards",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.52.0-beta.0",
|
|
4
4
|
"description": "The dashboards feature in Perses",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/perses/perses/blob/main/README.md",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"lint:fix": "eslint --fix src --ext .ts,.tsx"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@perses-dev/components": "0.
|
|
33
|
-
"@perses-dev/core": "0.
|
|
34
|
-
"@perses-dev/plugin-system": "0.
|
|
32
|
+
"@perses-dev/components": "0.52.0-beta.0",
|
|
33
|
+
"@perses-dev/core": "0.52.0-beta.0",
|
|
34
|
+
"@perses-dev/plugin-system": "0.52.0-beta.0",
|
|
35
35
|
"@types/react-grid-layout": "^1.3.2",
|
|
36
36
|
"date-fns": "^4.1.0",
|
|
37
37
|
"immer": "^10.1.1",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"zustand": "^4.3.3"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@perses-dev/internal-utils": "0.
|
|
49
|
+
"@perses-dev/internal-utils": "0.52.0-beta.0",
|
|
50
50
|
"history": "^5.3.0",
|
|
51
51
|
"intersection-observer": "^0.12.2"
|
|
52
52
|
},
|