@perses-dev/explore 0.44.0 → 0.45.0-rc0

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.
Files changed (51) hide show
  1. package/dist/cjs/components/ExploreToolbar/ExploreToolbar.js +8 -2
  2. package/dist/cjs/components/TimeSeriesExplorer/TimeSeriesExplorer.js +169 -0
  3. package/dist/cjs/views/ViewExplore/ViewExplore.js +25 -26
  4. package/dist/cjs/views/ViewExplore/ViewExploreApp.js +8 -20
  5. package/dist/components/ExploreToolbar/ExploreToolbar.d.ts +2 -2
  6. package/dist/components/ExploreToolbar/ExploreToolbar.d.ts.map +1 -1
  7. package/dist/components/ExploreToolbar/ExploreToolbar.js +2 -1
  8. package/dist/components/ExploreToolbar/ExploreToolbar.js.map +1 -1
  9. package/dist/components/TimeSeriesExplorer/TimeSeriesExplorer.d.ts +11 -0
  10. package/dist/components/TimeSeriesExplorer/TimeSeriesExplorer.d.ts.map +1 -0
  11. package/dist/components/TimeSeriesExplorer/TimeSeriesExplorer.js +112 -0
  12. package/dist/components/TimeSeriesExplorer/TimeSeriesExplorer.js.map +1 -0
  13. package/dist/views/ViewExplore/ViewExplore.d.ts +2 -4
  14. package/dist/views/ViewExplore/ViewExplore.d.ts.map +1 -1
  15. package/dist/views/ViewExplore/ViewExplore.js +21 -27
  16. package/dist/views/ViewExplore/ViewExplore.js.map +1 -1
  17. package/dist/views/ViewExplore/ViewExploreApp.d.ts +2 -2
  18. package/dist/views/ViewExplore/ViewExploreApp.d.ts.map +1 -1
  19. package/dist/views/ViewExplore/ViewExploreApp.js +3 -20
  20. package/dist/views/ViewExplore/ViewExploreApp.js.map +1 -1
  21. package/package.json +8 -9
  22. package/dist/cjs/components/PanelEditor/PanelEditorForm.js +0 -138
  23. package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +0 -51
  24. package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +0 -96
  25. package/dist/cjs/components/TimeSeriesQueryEditor/index.js +0 -30
  26. package/dist/cjs/context/usePanelEditor.js +0 -89
  27. package/dist/cjs/context/useTimeSeriesQueryEditorActions.js +0 -132
  28. package/dist/components/PanelEditor/PanelEditorForm.d.ts +0 -15
  29. package/dist/components/PanelEditor/PanelEditorForm.d.ts.map +0 -1
  30. package/dist/components/PanelEditor/PanelEditorForm.js +0 -125
  31. package/dist/components/PanelEditor/PanelEditorForm.js.map +0 -1
  32. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts +0 -11
  33. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts.map +0 -1
  34. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +0 -43
  35. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js.map +0 -1
  36. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts +0 -11
  37. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts.map +0 -1
  38. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +0 -83
  39. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js.map +0 -1
  40. package/dist/components/TimeSeriesQueryEditor/index.d.ts +0 -2
  41. package/dist/components/TimeSeriesQueryEditor/index.d.ts.map +0 -1
  42. package/dist/components/TimeSeriesQueryEditor/index.js +0 -15
  43. package/dist/components/TimeSeriesQueryEditor/index.js.map +0 -1
  44. package/dist/context/usePanelEditor.d.ts +0 -15
  45. package/dist/context/usePanelEditor.d.ts.map +0 -1
  46. package/dist/context/usePanelEditor.js +0 -84
  47. package/dist/context/usePanelEditor.js.map +0 -1
  48. package/dist/context/useTimeSeriesQueryEditorActions.d.ts +0 -14
  49. package/dist/context/useTimeSeriesQueryEditorActions.d.ts.map +0 -1
  50. package/dist/context/useTimeSeriesQueryEditorActions.js +0 -119
  51. package/dist/context/useTimeSeriesQueryEditorActions.js.map +0 -1
@@ -13,26 +13,11 @@
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { Box } from '@mui/material';
15
15
  import { ChartsProvider, useChartsTheme } from '@perses-dev/components';
16
- import { PanelEditorForm } from '../../components/PanelEditor/PanelEditorForm';
16
+ import React from 'react';
17
+ import { TimeSeriesExplorer } from '../../components/TimeSeriesExplorer/TimeSeriesExplorer';
17
18
  export function ViewExploreApp(props) {
18
19
  const { exploreTitleComponent } = props;
19
20
  const chartsTheme = useChartsTheme();
20
- const data = {
21
- groupId: 0,
22
- panelDefinition: {
23
- kind: 'Panel',
24
- spec: {
25
- display: {
26
- name: ''
27
- },
28
- plugin: {
29
- kind: 'TimeSeriesChart',
30
- spec: {}
31
- },
32
- queries: []
33
- }
34
- }
35
- };
36
21
  return /*#__PURE__*/ _jsx(Box, {
37
22
  sx: {
38
23
  flexGrow: 1,
@@ -44,9 +29,7 @@ export function ViewExploreApp(props) {
44
29
  children: /*#__PURE__*/ _jsx(ChartsProvider, {
45
30
  chartsTheme: chartsTheme,
46
31
  enablePinning: false,
47
- children: /*#__PURE__*/ _jsx(PanelEditorForm, {
48
- initialAction: "update",
49
- initialValues: data,
32
+ children: /*#__PURE__*/ _jsx(TimeSeriesExplorer, {
50
33
  exploreTitleComponent: exploreTitleComponent
51
34
  })
52
35
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/views/ViewExplore/ViewExploreApp.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 { Box } from '@mui/material';\nimport { ChartsProvider, useChartsTheme } from '@perses-dev/components';\nimport { PanelEditorValues } from '@perses-dev/dashboards';\nimport { PanelEditorForm } from '../../components/PanelEditor/PanelEditorForm';\n\nexport interface ViewAppProps {\n exploreTitleComponent?: JSX.Element;\n}\n\nexport function ViewExploreApp(props: ViewAppProps) {\n const { exploreTitleComponent } = props;\n\n const chartsTheme = useChartsTheme();\n const data: PanelEditorValues = {\n groupId: 0,\n panelDefinition: {\n kind: 'Panel',\n spec: {\n display: {\n name: '',\n },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {},\n },\n queries: [],\n },\n },\n };\n\n return (\n <Box\n sx={{\n flexGrow: 1,\n overflowX: 'hidden',\n overflowY: 'auto',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n <ChartsProvider chartsTheme={chartsTheme} enablePinning={false}>\n <PanelEditorForm initialAction=\"update\" initialValues={data} exploreTitleComponent={exploreTitleComponent} />\n </ChartsProvider>\n </Box>\n );\n}\n"],"names":["Box","ChartsProvider","useChartsTheme","PanelEditorForm","ViewExploreApp","props","exploreTitleComponent","chartsTheme","data","groupId","panelDefinition","kind","spec","display","name","plugin","queries","sx","flexGrow","overflowX","overflowY","flexDirection","enablePinning","initialAction","initialValues"],"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,GAAG,QAAQ,gBAAgB;AACpC,SAASC,cAAc,EAAEC,cAAc,QAAQ,yBAAyB;AAExE,SAASC,eAAe,QAAQ,+CAA+C;AAM/E,OAAO,SAASC,eAAeC,KAAmB;IAChD,MAAM,EAAEC,qBAAqB,EAAE,GAAGD;IAElC,MAAME,cAAcL;IACpB,MAAMM,OAA0B;QAC9BC,SAAS;QACTC,iBAAiB;YACfC,MAAM;YACNC,MAAM;gBACJC,SAAS;oBACPC,MAAM;gBACR;gBACAC,QAAQ;oBACNJ,MAAM;oBACNC,MAAM,CAAC;gBACT;gBACAI,SAAS,EAAE;YACb;QACF;IACF;IAEA,qBACE,KAAChB;QACCiB,IAAI;YACFC,UAAU;YACVC,WAAW;YACXC,WAAW;YACXP,SAAS;YACTQ,eAAe;QACjB;kBAEA,cAAA,KAACpB;YAAeM,aAAaA;YAAae,eAAe;sBACvD,cAAA,KAACnB;gBAAgBoB,eAAc;gBAASC,eAAehB;gBAAMF,uBAAuBA;;;;AAI5F"}
1
+ {"version":3,"sources":["../../../src/views/ViewExplore/ViewExploreApp.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 { Box } from '@mui/material';\nimport { ChartsProvider, useChartsTheme } from '@perses-dev/components';\nimport React from 'react';\nimport { TimeSeriesExplorer } from '../../components/TimeSeriesExplorer/TimeSeriesExplorer';\n\nexport interface ViewAppProps {\n exploreTitleComponent?: React.ReactNode;\n}\n\nexport function ViewExploreApp(props: ViewAppProps) {\n const { exploreTitleComponent } = props;\n\n const chartsTheme = useChartsTheme();\n\n return (\n <Box\n sx={{\n flexGrow: 1,\n overflowX: 'hidden',\n overflowY: 'auto',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n <ChartsProvider chartsTheme={chartsTheme} enablePinning={false}>\n <TimeSeriesExplorer exploreTitleComponent={exploreTitleComponent} />\n </ChartsProvider>\n </Box>\n );\n}\n"],"names":["Box","ChartsProvider","useChartsTheme","React","TimeSeriesExplorer","ViewExploreApp","props","exploreTitleComponent","chartsTheme","sx","flexGrow","overflowX","overflowY","display","flexDirection","enablePinning"],"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,GAAG,QAAQ,gBAAgB;AACpC,SAASC,cAAc,EAAEC,cAAc,QAAQ,yBAAyB;AACxE,OAAOC,WAAW,QAAQ;AAC1B,SAASC,kBAAkB,QAAQ,yDAAyD;AAM5F,OAAO,SAASC,eAAeC,KAAmB;IAChD,MAAM,EAAEC,qBAAqB,EAAE,GAAGD;IAElC,MAAME,cAAcN;IAEpB,qBACE,KAACF;QACCS,IAAI;YACFC,UAAU;YACVC,WAAW;YACXC,WAAW;YACXC,SAAS;YACTC,eAAe;QACjB;kBAEA,cAAA,KAACb;YAAeO,aAAaA;YAAaO,eAAe;sBACvD,cAAA,KAACX;gBAAmBG,uBAAuBA;;;;AAInD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/explore",
3
- "version": "0.44.0",
3
+ "version": "0.45.0-rc0",
4
4
  "description": "The explore feature in Perses",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -23,16 +23,15 @@
23
23
  "build:types": "tsc --project tsconfig.build.json",
24
24
  "type-check": "tsc --noEmit",
25
25
  "start": "concurrently -P \"npm:build:* -- {*}\" -- --watch",
26
- "test": "cross-env TZ=UTC jest",
27
- "test:watch": "npm run test -- --watch",
28
26
  "lint": "eslint src --ext .ts,.tsx",
29
27
  "lint:fix": "eslint --fix src --ext .ts,.tsx"
30
28
  },
31
29
  "dependencies": {
32
- "@perses-dev/components": "0.44.0",
33
- "@perses-dev/core": "0.44.0",
34
- "@perses-dev/plugin-system": "0.44.0",
35
- "@perses-dev/dashboards": "0.44.0",
30
+ "@perses-dev/components": "0.45.0-rc0",
31
+ "@perses-dev/core": "0.45.0-rc0",
32
+ "@perses-dev/panels-plugin": "0.45.0-rc0",
33
+ "@perses-dev/plugin-system": "0.45.0-rc0",
34
+ "@perses-dev/dashboards": "0.45.0-rc0",
36
35
  "@types/react-grid-layout": "^1.3.2",
37
36
  "date-fns": "^2.28.0",
38
37
  "immer": "^9.0.15",
@@ -46,8 +45,8 @@
46
45
  "zustand": "^4.3.3"
47
46
  },
48
47
  "devDependencies": {
49
- "@perses-dev/internal-utils": "0.44.0",
50
- "@perses-dev/storybook": "0.44.0",
48
+ "@perses-dev/internal-utils": "0.45.0-rc0",
49
+ "@perses-dev/storybook": "0.45.0-rc0",
51
50
  "history": "^5.3.0",
52
51
  "intersection-observer": "^0.12.2"
53
52
  },
@@ -1,138 +0,0 @@
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, "PanelEditorForm", {
18
- enumerable: true,
19
- get: function() {
20
- return PanelEditorForm;
21
- }
22
- });
23
- const _jsxruntime = require("react/jsx-runtime");
24
- const _dashboards = require("@perses-dev/dashboards");
25
- const _pluginsystem = require("@perses-dev/plugin-system");
26
- const _reacthookform = require("react-hook-form");
27
- const _material = require("@mui/material");
28
- const _Plus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Plus"));
29
- const _components = require("@perses-dev/components");
30
- const _TimeSeriesQueryEditor = require("../TimeSeriesQueryEditor");
31
- const _ExploreToolbar = require("../ExploreToolbar");
32
- const _useTimeSeriesQueryEditorActions = require("../../context/useTimeSeriesQueryEditorActions");
33
- const _usePanelEditor = require("../../context/usePanelEditor");
34
- function _interop_require_default(obj) {
35
- return obj && obj.__esModule ? obj : {
36
- default: obj
37
- };
38
- }
39
- function PanelEditorForm(props) {
40
- const { exploreTitleComponent, initialValues: { panelDefinition: initialPanelDef } } = props;
41
- const { setQueries, setPlugin, panelDefinition } = (0, _usePanelEditor.usePanelEditor)(initialPanelDef);
42
- const { plugin } = panelDefinition.spec;
43
- var _panelDefinition_spec_queries;
44
- const queries = (_panelDefinition_spec_queries = panelDefinition.spec.queries) !== null && _panelDefinition_spec_queries !== void 0 ? _panelDefinition_spec_queries : [];
45
- // Use common plugin editor logic even though we've split the inputs up in this form
46
- const pluginEditor = (0, _pluginsystem.usePluginEditor)({
47
- pluginType: 'Panel',
48
- value: {
49
- kind: plugin.kind,
50
- spec: plugin.spec
51
- },
52
- onChange: (plugin)=>{
53
- setPlugin(plugin);
54
- },
55
- onHideQueryEditorChange: (isHidden)=>{
56
- setQueries(undefined, isHidden);
57
- }
58
- });
59
- const onChange = (queries)=>setQueries(queries);
60
- const { handleQueryChange, handleQueryAdd, handleQueryCollapseExpand, handleQueryDelete, queriesCollapsed, defaultTimeSeriesQueryKind } = (0, _useTimeSeriesQueryEditorActions.useTimeSeriesQueryEditorActions)({
61
- onChange,
62
- queries
63
- });
64
- const form = (0, _reacthookform.useForm)({
65
- mode: 'onBlur',
66
- defaultValues: {
67
- type: pluginEditor.pendingKind ? pluginEditor.pendingKind : plugin.kind
68
- }
69
- });
70
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
71
- sx: {
72
- width: '100%'
73
- },
74
- px: 2,
75
- pb: 2,
76
- pt: 1.5,
77
- gap: 2,
78
- children: [
79
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_ExploreToolbar.ExploreToolbar, {
80
- exploreTitleComponent: exploreTitleComponent
81
- }),
82
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.FormProvider, {
83
- ...form,
84
- children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Grid, {
85
- container: true,
86
- spacing: 2,
87
- children: [
88
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
89
- item: true,
90
- xs: 12,
91
- children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
92
- gap: 1,
93
- children: [
94
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_TimeSeriesQueryEditor.TimeSeriesQueryEditor, {
95
- handleQueryChange: handleQueryChange,
96
- handleQueryCollapseExpand: handleQueryCollapseExpand,
97
- handleQueryDelete: handleQueryDelete,
98
- queriesCollapsed: queriesCollapsed,
99
- queries: queries,
100
- defaultTimeSeriesQueryKind: defaultTimeSeriesQueryKind
101
- }),
102
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
103
- variant: "contained",
104
- startIcon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {}),
105
- sx: {
106
- marginRight: 'auto'
107
- },
108
- onClick: handleQueryAdd,
109
- children: "Add Query"
110
- })
111
- ]
112
- })
113
- }),
114
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
115
- item: true,
116
- xs: 12,
117
- children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
118
- gap: 1,
119
- children: [
120
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
121
- variant: "h4",
122
- children: "Preview"
123
- }),
124
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
125
- FallbackComponent: _components.ErrorAlert,
126
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_dashboards.PanelPreview, {
127
- panelDefinition: panelDefinition
128
- })
129
- })
130
- ]
131
- })
132
- })
133
- ]
134
- })
135
- })
136
- ]
137
- });
138
- }
@@ -1,51 +0,0 @@
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, "TimeSeriesQueryEditor", {
18
- enumerable: true,
19
- get: function() {
20
- return TimeSeriesQueryEditor;
21
- }
22
- });
23
- const _jsxruntime = require("react/jsx-runtime");
24
- const _TimeSeriesQueryInput = require("./TimeSeriesQueryInput");
25
- function TimeSeriesQueryEditor(props) {
26
- const { queries, handleQueryChange, handleQueryCollapseExpand, handleQueryDelete, queriesCollapsed, defaultTimeSeriesQueryKind } = props;
27
- const hasMoreThanOneQuery = queries.length > 1;
28
- const queryDefinitions = queries.length ? queries : [
29
- {
30
- kind: 'TimeSeriesQuery',
31
- spec: {
32
- plugin: {
33
- kind: defaultTimeSeriesQueryKind,
34
- spec: {
35
- query: ''
36
- }
37
- }
38
- }
39
- }
40
- ];
41
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
42
- children: queryDefinitions.map((query, i)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_TimeSeriesQueryInput.TimeSeriesQueryInput, {
43
- index: i,
44
- query: query,
45
- onChange: handleQueryChange,
46
- isCollapsed: !!queriesCollapsed[i],
47
- onDelete: hasMoreThanOneQuery ? handleQueryDelete : undefined,
48
- onCollapseExpand: handleQueryCollapseExpand
49
- }, i))
50
- });
51
- }
@@ -1,96 +0,0 @@
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, "TimeSeriesQueryInput", {
18
- enumerable: true,
19
- get: function() {
20
- return TimeSeriesQueryInput;
21
- }
22
- });
23
- const _jsxruntime = require("react/jsx-runtime");
24
- const _material = require("@mui/material");
25
- const _ChevronDown = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/ChevronDown"));
26
- const _ChevronRight = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/ChevronRight"));
27
- const _DeleteOutline = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/DeleteOutline"));
28
- const _pluginsystem = require("@perses-dev/plugin-system");
29
- const _immer = /*#__PURE__*/ _interop_require_default(require("immer"));
30
- function _interop_require_default(obj) {
31
- return obj && obj.__esModule ? obj : {
32
- default: obj
33
- };
34
- }
35
- function TimeSeriesQueryInput(props) {
36
- const { index, query, isCollapsed, onDelete, onChange, onCollapseExpand } = props;
37
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
38
- spacing: 1,
39
- children: [
40
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
41
- direction: "row",
42
- alignItems: "center",
43
- borderBottom: 1,
44
- borderColor: (theme)=>theme.palette.divider,
45
- children: [
46
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
47
- size: "small",
48
- onClick: ()=>onCollapseExpand(index),
49
- children: isCollapsed ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_ChevronRight.default, {}) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_ChevronDown.default, {})
50
- }),
51
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Typography, {
52
- variant: "overline",
53
- component: "h4",
54
- children: [
55
- "Query ",
56
- index + 1
57
- ]
58
- }),
59
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
60
- size: "small",
61
- // Use `visibility` to ensure that the row has the same height when delete button is visible or not visible
62
- sx: {
63
- marginLeft: 'auto',
64
- visibility: `${onDelete ? 'visible' : 'hidden'}`
65
- },
66
- onClick: ()=>onDelete && onDelete(index),
67
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_DeleteOutline.default, {})
68
- })
69
- ]
70
- }),
71
- !isCollapsed && /*#__PURE__*/ (0, _jsxruntime.jsx)(QueryEditor, {
72
- value: query,
73
- onChange: (next)=>onChange(index, next)
74
- })
75
- ]
76
- }, index);
77
- }
78
- function QueryEditor(props) {
79
- const { value, onChange, ...others } = props;
80
- const { spec: { plugin } } = value;
81
- const handlePluginChange = (next)=>{
82
- onChange((0, _immer.default)(value, (draft)=>{
83
- draft.spec.plugin = next;
84
- }));
85
- };
86
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
87
- ...others,
88
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.PluginEditor, {
89
- isExplore: true,
90
- pluginType: "TimeSeriesQuery",
91
- pluginKindLabel: "Query Type",
92
- value: plugin,
93
- onChange: handlePluginChange
94
- })
95
- });
96
- }
@@ -1,30 +0,0 @@
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
- _export_star(require("./TimeSeriesQueryEditor"), exports);
18
- function _export_star(from, to) {
19
- Object.keys(from).forEach(function(k) {
20
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
21
- Object.defineProperty(to, k, {
22
- enumerable: true,
23
- get: function() {
24
- return from[k];
25
- }
26
- });
27
- }
28
- });
29
- return from;
30
- }
@@ -1,89 +0,0 @@
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, "usePanelEditor", {
18
- enumerable: true,
19
- get: function() {
20
- return usePanelEditor;
21
- }
22
- });
23
- const _react = require("react");
24
- const usePanelEditor = (panelDefinition)=>{
25
- const { display, plugin: pluginDefinition, queries: initialQueries } = panelDefinition.spec;
26
- const [name, setName] = (0, _react.useState)(display.name);
27
- const [description, setDescription] = (0, _react.useState)(display.description);
28
- const [plugin, setPlugin] = (0, _react.useState)(pluginDefinition);
29
- // need to keep track of prevQueries if switching from a panel with no queries (ex: markdown) to one with queries
30
- const [prevQueries, setPrevQueries] = (0, _react.useState)(initialQueries);
31
- const [currentQueries, setCurrentQueries] = (0, _react.useState)(initialQueries);
32
- /**
33
- * If hideQueryEditor is true, set panelDefinition.spec.queries to undefined.
34
- * If hideQueryEditor is false and query is undefined, set panelDefinition.spec.queries to previous queries.
35
- */ const setQueries = (0, _react.useCallback)((queries, hideQueryEditor)=>{
36
- if (hideQueryEditor) {
37
- setPrevQueries(currentQueries);
38
- setCurrentQueries(undefined);
39
- } else {
40
- setCurrentQueries(queries === undefined ? prevQueries : queries);
41
- }
42
- }, [
43
- setCurrentQueries,
44
- currentQueries,
45
- setPrevQueries,
46
- prevQueries
47
- ]);
48
- // reset panel definition
49
- const setPanelDefinition = (0, _react.useCallback)((panelDefinition)=>{
50
- const { display, plugin, queries } = panelDefinition.spec;
51
- setName(display.name);
52
- setDescription(display.description);
53
- setPlugin(plugin);
54
- setQueries(queries);
55
- }, [
56
- setName,
57
- setDescription,
58
- setPlugin,
59
- setQueries
60
- ]);
61
- return (0, _react.useMemo)(()=>({
62
- panelDefinition: {
63
- kind: 'Panel',
64
- spec: {
65
- display: {
66
- name,
67
- description
68
- },
69
- plugin,
70
- queries: currentQueries
71
- }
72
- },
73
- setName,
74
- setDescription,
75
- setQueries,
76
- setPlugin,
77
- setPanelDefinition
78
- }), [
79
- name,
80
- description,
81
- plugin,
82
- currentQueries,
83
- setName,
84
- setDescription,
85
- setQueries,
86
- setPlugin,
87
- setPanelDefinition
88
- ]);
89
- };
@@ -1,132 +0,0 @@
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, "useTimeSeriesQueryEditorActions", {
18
- enumerable: true,
19
- get: function() {
20
- return useTimeSeriesQueryEditorActions;
21
- }
22
- });
23
- const _pluginsystem = require("@perses-dev/plugin-system");
24
- const _immer = /*#__PURE__*/ _interop_require_default(require("immer"));
25
- const _react = require("react");
26
- function _interop_require_default(obj) {
27
- return obj && obj.__esModule ? obj : {
28
- default: obj
29
- };
30
- }
31
- const DEFAULT_QUERY_PLUGIN_TYPE = 'TimeSeriesQuery';
32
- const useTimeSeriesQueryEditorActions = (props)=>{
33
- const { queries, onChange } = props;
34
- const { defaultPluginKinds } = (0, _pluginsystem.usePluginRegistry)();
35
- var _defaultPluginKinds_DEFAULT_QUERY_PLUGIN_TYPE;
36
- const defaultTimeSeriesQueryKind = (_defaultPluginKinds_DEFAULT_QUERY_PLUGIN_TYPE = defaultPluginKinds === null || defaultPluginKinds === void 0 ? void 0 : defaultPluginKinds[DEFAULT_QUERY_PLUGIN_TYPE]) !== null && _defaultPluginKinds_DEFAULT_QUERY_PLUGIN_TYPE !== void 0 ? _defaultPluginKinds_DEFAULT_QUERY_PLUGIN_TYPE : '';
37
- const { data: defaultQueryPlugin } = (0, _pluginsystem.usePlugin)(DEFAULT_QUERY_PLUGIN_TYPE, defaultTimeSeriesQueryKind, {
38
- useErrorBoundary: true,
39
- enabled: true
40
- });
41
- const [queriesCollapsed, setQueriesCollapsed] = (0, _react.useState)(queries.map(()=>false));
42
- const handleQueryChange = (0, _react.useCallback)((index, queryDef)=>{
43
- onChange((0, _immer.default)(queries, (draft)=>{
44
- if (draft) {
45
- draft[index] = queryDef;
46
- return;
47
- }
48
- draft = [
49
- queryDef
50
- ];
51
- }));
52
- }, [
53
- onChange,
54
- queries
55
- ]);
56
- const handleQueryAdd = (0, _react.useCallback)(()=>{
57
- if (!defaultQueryPlugin) return;
58
- onChange((0, _immer.default)(queries, (draft)=>{
59
- const queryDef = {
60
- kind: DEFAULT_QUERY_PLUGIN_TYPE,
61
- spec: {
62
- plugin: {
63
- kind: defaultTimeSeriesQueryKind,
64
- spec: defaultQueryPlugin.createInitialOptions()
65
- }
66
- }
67
- };
68
- if (draft) {
69
- draft.push(queryDef);
70
- } else {
71
- draft = [
72
- ...queries,
73
- queryDef
74
- ];
75
- }
76
- }));
77
- setQueriesCollapsed((queriesCollapsed)=>{
78
- queriesCollapsed.push(false);
79
- return [
80
- ...queriesCollapsed
81
- ];
82
- });
83
- }, [
84
- defaultQueryPlugin,
85
- defaultTimeSeriesQueryKind,
86
- onChange,
87
- queries,
88
- setQueriesCollapsed
89
- ]);
90
- const handleQueryDelete = (0, _react.useCallback)((index)=>{
91
- onChange((0, _immer.default)(queries, (draft)=>{
92
- draft.splice(index, 1);
93
- }));
94
- setQueriesCollapsed((queriesCollapsed)=>{
95
- queriesCollapsed.splice(index, 1);
96
- return [
97
- ...queriesCollapsed
98
- ];
99
- });
100
- }, [
101
- onChange,
102
- setQueriesCollapsed,
103
- queries
104
- ]);
105
- const handleQueryCollapseExpand = (0, _react.useCallback)((index)=>{
106
- setQueriesCollapsed((queriesCollapsed)=>{
107
- queriesCollapsed[index] = !queriesCollapsed[index];
108
- return [
109
- ...queriesCollapsed
110
- ];
111
- });
112
- }, [
113
- setQueriesCollapsed
114
- ]);
115
- return (0, _react.useMemo)(()=>{
116
- return {
117
- handleQueryChange,
118
- handleQueryAdd,
119
- handleQueryDelete,
120
- handleQueryCollapseExpand,
121
- queriesCollapsed,
122
- defaultTimeSeriesQueryKind
123
- };
124
- }, [
125
- handleQueryChange,
126
- handleQueryAdd,
127
- handleQueryDelete,
128
- handleQueryCollapseExpand,
129
- queriesCollapsed,
130
- defaultTimeSeriesQueryKind
131
- ]);
132
- };
@@ -1,15 +0,0 @@
1
- /// <reference types="react" />
2
- import { PanelEditorValues } from '@perses-dev/dashboards';
3
- import { Action, PanelDefinition, QueryDefinition, UnknownSpec } from '@perses-dev/core';
4
- export interface PanelEditorProps {
5
- initialValues: PanelEditorValues;
6
- initialAction: Action;
7
- exploreTitleComponent?: JSX.Element;
8
- }
9
- export interface PanelSpecEditorProps {
10
- panelDefinition: PanelDefinition;
11
- onQueriesChange: (queries: QueryDefinition[]) => void;
12
- onPluginSpecChange: (spec: UnknownSpec) => void;
13
- }
14
- export declare function PanelEditorForm(props: PanelEditorProps): import("react/jsx-runtime").JSX.Element;
15
- //# sourceMappingURL=PanelEditorForm.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PanelEditorForm.d.ts","sourceRoot":"","sources":["../../../src/components/PanelEditor/PanelEditorForm.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,iBAAiB,EAAgB,MAAM,wBAAwB,CAAC;AAMzE,OAAO,EAAE,MAAM,EAAc,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAOrG,MAAM,WAAW,gBAAgB;IAC/B,aAAa,EAAE,iBAAiB,CAAC;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,qBAAqB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;CACrC;AAED,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,eAAe,CAAC;IACjC,eAAe,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;IACtD,kBAAkB,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;CACjD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,gBAAgB,2CAyEtD"}