@perses-dev/dashboards 0.23.1 → 0.24.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.
Files changed (46) hide show
  1. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +7 -3
  2. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +2 -1
  3. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  4. package/dist/components/TimeRangeControls/TimeRangeControls.js +8 -4
  5. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  6. package/package.json +6 -5
  7. package/dist/cjs/components/Panel/Panel.test.js +0 -137
  8. package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +0 -131
  9. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +0 -87
  10. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +0 -95
  11. package/dist/cjs/components/Variables/variable-model.test.js +0 -106
  12. package/dist/cjs/context/TemplateVariableProvider/query-params.test.js +0 -82
  13. package/dist/cjs/utils/panelUtils.test.js +0 -195
  14. package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +0 -110
  15. package/dist/components/Panel/Panel.test.d.ts +0 -2
  16. package/dist/components/Panel/Panel.test.d.ts.map +0 -1
  17. package/dist/components/Panel/Panel.test.js +0 -130
  18. package/dist/components/Panel/Panel.test.js.map +0 -1
  19. package/dist/components/PanelDrawer/PanelDrawer.test.d.ts +0 -2
  20. package/dist/components/PanelDrawer/PanelDrawer.test.d.ts.map +0 -1
  21. package/dist/components/PanelDrawer/PanelDrawer.test.js +0 -124
  22. package/dist/components/PanelDrawer/PanelDrawer.test.js.map +0 -1
  23. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.d.ts +0 -2
  24. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.d.ts.map +0 -1
  25. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +0 -80
  26. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +0 -1
  27. package/dist/components/TimeRangeControls/TimeRangeControls.test.d.ts +0 -2
  28. package/dist/components/TimeRangeControls/TimeRangeControls.test.d.ts.map +0 -1
  29. package/dist/components/TimeRangeControls/TimeRangeControls.test.js +0 -88
  30. package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +0 -1
  31. package/dist/components/Variables/variable-model.test.d.ts +0 -2
  32. package/dist/components/Variables/variable-model.test.d.ts.map +0 -1
  33. package/dist/components/Variables/variable-model.test.js +0 -104
  34. package/dist/components/Variables/variable-model.test.js.map +0 -1
  35. package/dist/context/TemplateVariableProvider/query-params.test.d.ts +0 -2
  36. package/dist/context/TemplateVariableProvider/query-params.test.d.ts.map +0 -1
  37. package/dist/context/TemplateVariableProvider/query-params.test.js +0 -80
  38. package/dist/context/TemplateVariableProvider/query-params.test.js.map +0 -1
  39. package/dist/utils/panelUtils.test.d.ts +0 -2
  40. package/dist/utils/panelUtils.test.d.ts.map +0 -1
  41. package/dist/utils/panelUtils.test.js +0 -193
  42. package/dist/utils/panelUtils.test.js.map +0 -1
  43. package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts +0 -2
  44. package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts.map +0 -1
  45. package/dist/views/ViewDashboard/tests/panelGroups.test.js +0 -103
  46. package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +0 -1
@@ -26,6 +26,7 @@ _export(exports, {
26
26
  });
27
27
  const _jsxRuntime = require("react/jsx-runtime");
28
28
  const _refresh = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Refresh"));
29
+ const _material = require("@mui/material");
29
30
  const _components = require("@perses-dev/components");
30
31
  const _pluginSystem = require("@perses-dev/plugin-system");
31
32
  const _core = require("@perses-dev/core");
@@ -94,8 +95,9 @@ const TIME_OPTIONS = [
94
95
  }
95
96
  ];
96
97
  const DEFAULT_HEIGHT = '34px';
97
- function TimeRangeControls({ heightPx }) {
98
+ function TimeRangeControls({ heightPx , showRefresh =true }) {
98
99
  const { timeRange , setTimeRange , refresh } = (0, _pluginSystem.useTimeRange)();
100
+ // TODO: Remove this since it couples to the dashboard context
99
101
  const defaultTimeRange = (0, _context.useDefaultTimeRange)();
100
102
  // Convert height to a string, then use the string for styling
101
103
  const height = heightPx === undefined ? DEFAULT_HEIGHT : `${heightPx}px`;
@@ -110,7 +112,9 @@ function TimeRangeControls({ heightPx }) {
110
112
  });
111
113
  }
112
114
  }
113
- return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
115
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
116
+ direction: "row",
117
+ spacing: 1,
114
118
  children: [
115
119
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.DateTimeRangePicker, {
116
120
  timeOptions: TIME_OPTIONS,
@@ -118,7 +122,7 @@ function TimeRangeControls({ heightPx }) {
118
122
  onChange: setTimeRange,
119
123
  height: height
120
124
  }),
121
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.InfoTooltip, {
125
+ showRefresh && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.InfoTooltip, {
122
126
  description: _constants.TOOLTIP_TEXT.refreshDashboard,
123
127
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_toolbarIconButton.ToolbarIconButton, {
124
128
  "aria-label": _constants.TOOLTIP_TEXT.refreshDashboard,
@@ -3,7 +3,8 @@ import { TimeOption } from '@perses-dev/components';
3
3
  export declare const TIME_OPTIONS: TimeOption[];
4
4
  interface TimeRangeControlsProps {
5
5
  heightPx?: number;
6
+ showRefresh?: boolean;
6
7
  }
7
- export declare function TimeRangeControls({ heightPx }: TimeRangeControlsProps): JSX.Element;
8
+ export declare function TimeRangeControls({ heightPx, showRefresh }: TimeRangeControlsProps): JSX.Element;
8
9
  export {};
9
10
  //# sourceMappingURL=TimeRangeControls.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TimeRangeControls.d.ts","sourceRoot":"","sources":["../../../src/components/TimeRangeControls/TimeRangeControls.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAoC,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAOtF,eAAO,MAAM,YAAY,EAAE,UAAU,EAUpC,CAAC;AAIF,UAAU,sBAAsB;IAE9B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,EAAE,sBAAsB,eA2BrE"}
1
+ {"version":3,"file":"TimeRangeControls.d.ts","sourceRoot":"","sources":["../../../src/components/TimeRangeControls/TimeRangeControls.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAoC,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAOtF,eAAO,MAAM,YAAY,EAAE,UAAU,EAUpC,CAAC;AAIF,UAAU,sBAAsB;IAE9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,WAAkB,EAAE,EAAE,sBAAsB,eA8BzF"}
@@ -10,8 +10,9 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import RefreshIcon from 'mdi-material-ui/Refresh';
15
+ import { Stack } from '@mui/material';
15
16
  import { DateTimeRangePicker, InfoTooltip } from '@perses-dev/components';
16
17
  import { useTimeRange } from '@perses-dev/plugin-system';
17
18
  import { isDurationString } from '@perses-dev/core';
@@ -75,8 +76,9 @@ export const TIME_OPTIONS = [
75
76
  }
76
77
  ];
77
78
  const DEFAULT_HEIGHT = '34px';
78
- export function TimeRangeControls({ heightPx }) {
79
+ export function TimeRangeControls({ heightPx , showRefresh =true }) {
79
80
  const { timeRange , setTimeRange , refresh } = useTimeRange();
81
+ // TODO: Remove this since it couples to the dashboard context
80
82
  const defaultTimeRange = useDefaultTimeRange();
81
83
  // Convert height to a string, then use the string for styling
82
84
  const height = heightPx === undefined ? DEFAULT_HEIGHT : `${heightPx}px`;
@@ -91,7 +93,9 @@ export function TimeRangeControls({ heightPx }) {
91
93
  });
92
94
  }
93
95
  }
94
- return /*#__PURE__*/ _jsxs(_Fragment, {
96
+ return /*#__PURE__*/ _jsxs(Stack, {
97
+ direction: "row",
98
+ spacing: 1,
95
99
  children: [
96
100
  /*#__PURE__*/ _jsx(DateTimeRangePicker, {
97
101
  timeOptions: TIME_OPTIONS,
@@ -99,7 +103,7 @@ export function TimeRangeControls({ heightPx }) {
99
103
  onChange: setTimeRange,
100
104
  height: height
101
105
  }),
102
- /*#__PURE__*/ _jsx(InfoTooltip, {
106
+ showRefresh && /*#__PURE__*/ _jsx(InfoTooltip, {
103
107
  description: TOOLTIP_TEXT.refreshDashboard,
104
108
  children: /*#__PURE__*/ _jsx(ToolbarIconButton, {
105
109
  "aria-label": TOOLTIP_TEXT.refreshDashboard,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/TimeRangeControls/TimeRangeControls.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 RefreshIcon from 'mdi-material-ui/Refresh';\nimport { DateTimeRangePicker, InfoTooltip, TimeOption } from '@perses-dev/components';\nimport { useTimeRange } from '@perses-dev/plugin-system';\nimport { isDurationString } from '@perses-dev/core';\nimport { TOOLTIP_TEXT } from '../../constants';\nimport { useDefaultTimeRange } from '../../context';\nimport { ToolbarIconButton } from '../ToolbarIconButton';\n\nexport const TIME_OPTIONS: TimeOption[] = [\n { value: { pastDuration: '5m' }, display: 'Last 5 minutes' },\n { value: { pastDuration: '15m' }, display: 'Last 15 minutes' },\n { value: { pastDuration: '30m' }, display: 'Last 30 minutes' },\n { value: { pastDuration: '1h' }, display: 'Last 1 hour' },\n { value: { pastDuration: '6h' }, display: 'Last 6 hours' },\n { value: { pastDuration: '12h' }, display: 'Last 12 hours' },\n { value: { pastDuration: '24h' }, display: 'Last 1 day' },\n { value: { pastDuration: '7d' }, display: 'Last 7 days' },\n { value: { pastDuration: '14d' }, display: 'Last 14 days' },\n];\n\nconst DEFAULT_HEIGHT = '34px';\n\ninterface TimeRangeControlsProps {\n // The controls look best at heights >= 28 pixels\n heightPx?: number;\n}\n\nexport function TimeRangeControls({ heightPx }: TimeRangeControlsProps) {\n const { timeRange, setTimeRange, refresh } = useTimeRange();\n const defaultTimeRange = useDefaultTimeRange();\n\n // Convert height to a string, then use the string for styling\n const height = heightPx === undefined ? DEFAULT_HEIGHT : `${heightPx}px`;\n\n // add time shortcut if one does not match duration from dashboard JSON\n if (!TIME_OPTIONS.some((option) => option.value.pastDuration === defaultTimeRange.pastDuration)) {\n if (isDurationString(defaultTimeRange.pastDuration)) {\n TIME_OPTIONS.push({\n value: { pastDuration: defaultTimeRange.pastDuration },\n display: `Last ${defaultTimeRange.pastDuration}`,\n });\n }\n }\n\n return (\n <>\n <DateTimeRangePicker timeOptions={TIME_OPTIONS} value={timeRange} onChange={setTimeRange} height={height} />\n <InfoTooltip description={TOOLTIP_TEXT.refreshDashboard}>\n <ToolbarIconButton aria-label={TOOLTIP_TEXT.refreshDashboard} onClick={refresh} sx={{ height }}>\n <RefreshIcon />\n </ToolbarIconButton>\n </InfoTooltip>\n </>\n );\n}\n"],"names":["RefreshIcon","DateTimeRangePicker","InfoTooltip","useTimeRange","isDurationString","TOOLTIP_TEXT","useDefaultTimeRange","ToolbarIconButton","TIME_OPTIONS","value","pastDuration","display","DEFAULT_HEIGHT","TimeRangeControls","heightPx","timeRange","setTimeRange","refresh","defaultTimeRange","height","undefined","some","option","push","timeOptions","onChange","description","refreshDashboard","aria-label","onClick","sx"],"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;AAAA,OAAOA,WAAW,MAAM,yBAAyB,CAAC;AAClD,SAASC,mBAAmB,EAAEC,WAAW,QAAoB,wBAAwB,CAAC;AACtF,SAASC,YAAY,QAAQ,2BAA2B,CAAC;AACzD,SAASC,gBAAgB,QAAQ,kBAAkB,CAAC;AACpD,SAASC,YAAY,QAAQ,iBAAiB,CAAC;AAC/C,SAASC,mBAAmB,QAAQ,eAAe,CAAC;AACpD,SAASC,iBAAiB,QAAQ,sBAAsB,CAAC;AAEzD,OAAO,MAAMC,YAAY,GAAiB;IACxC;QAAEC,KAAK,EAAE;YAAEC,YAAY,EAAE,IAAI;SAAE;QAAEC,OAAO,EAAE,gBAAgB;KAAE;IAC5D;QAAEF,KAAK,EAAE;YAAEC,YAAY,EAAE,KAAK;SAAE;QAAEC,OAAO,EAAE,iBAAiB;KAAE;IAC9D;QAAEF,KAAK,EAAE;YAAEC,YAAY,EAAE,KAAK;SAAE;QAAEC,OAAO,EAAE,iBAAiB;KAAE;IAC9D;QAAEF,KAAK,EAAE;YAAEC,YAAY,EAAE,IAAI;SAAE;QAAEC,OAAO,EAAE,aAAa;KAAE;IACzD;QAAEF,KAAK,EAAE;YAAEC,YAAY,EAAE,IAAI;SAAE;QAAEC,OAAO,EAAE,cAAc;KAAE;IAC1D;QAAEF,KAAK,EAAE;YAAEC,YAAY,EAAE,KAAK;SAAE;QAAEC,OAAO,EAAE,eAAe;KAAE;IAC5D;QAAEF,KAAK,EAAE;YAAEC,YAA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AW,EAAErB,YAAY,CAACsB,gBAAgB;0BACrD,cAAA,KAACpB,iBAAiB;oBAACqB,YAAU,EAAEvB,YAAY,CAACsB,gBAAgB;oBAAEE,OAAO,EAAEZ,OAAO;oBAAEa,EAAE,EAAE;wBAAEX,MAAM;qBAAE;8BAC5F,cAAA,KAACnB,WAAW,KAAG;kBACG;cACR;;MACb,CACH;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/TimeRangeControls/TimeRangeControls.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 RefreshIcon from 'mdi-material-ui/Refresh';\nimport { Stack } from '@mui/material';\nimport { DateTimeRangePicker, InfoTooltip, TimeOption } from '@perses-dev/components';\nimport { useTimeRange } from '@perses-dev/plugin-system';\nimport { isDurationString } from '@perses-dev/core';\nimport { TOOLTIP_TEXT } from '../../constants';\nimport { useDefaultTimeRange } from '../../context';\nimport { ToolbarIconButton } from '../ToolbarIconButton';\n\nexport const TIME_OPTIONS: TimeOption[] = [\n { value: { pastDuration: '5m' }, display: 'Last 5 minutes' },\n { value: { pastDuration: '15m' }, display: 'Last 15 minutes' },\n { value: { pastDuration: '30m' }, display: 'Last 30 minutes' },\n { value: { pastDuration: '1h' }, display: 'Last 1 hour' },\n { value: { pastDuration: '6h' }, display: 'Last 6 hours' },\n { value: { pastDuration: '12h' }, display: 'Last 12 hours' },\n { value: { pastDuration: '24h' }, display: 'Last 1 day' },\n { value: { pastDuration: '7d' }, display: 'Last 7 days' },\n { value: { pastDuration: '14d' }, display: 'Last 14 days' },\n];\n\nconst DEFAULT_HEIGHT = '34px';\n\ninterface TimeRangeControlsProps {\n // The controls look best at heights >= 28 pixels\n heightPx?: number;\n\n // Whether to show the refresh button or not\n showRefresh?: boolean;\n}\n\nexport function TimeRangeControls({ heightPx, showRefresh = true }: TimeRangeControlsProps) {\n const { timeRange, setTimeRange, refresh } = useTimeRange();\n // TODO: Remove this since it couples to the dashboard context\n const defaultTimeRange = useDefaultTimeRange();\n\n // Convert height to a string, then use the string for styling\n const height = heightPx === undefined ? DEFAULT_HEIGHT : `${heightPx}px`;\n\n // add time shortcut if one does not match duration from dashboard JSON\n if (!TIME_OPTIONS.some((option) => option.value.pastDuration === defaultTimeRange.pastDuration)) {\n if (isDurationString(defaultTimeRange.pastDuration)) {\n TIME_OPTIONS.push({\n value: { pastDuration: defaultTimeRange.pastDuration },\n display: `Last ${defaultTimeRange.pastDuration}`,\n });\n }\n }\n\n return (\n <Stack direction=\"row\" spacing={1}>\n <DateTimeRangePicker timeOptions={TIME_OPTIONS} value={timeRange} onChange={setTimeRange} height={height} />\n {showRefresh && (\n <InfoTooltip description={TOOLTIP_TEXT.refreshDashboard}>\n <ToolbarIconButton aria-label={TOOLTIP_TEXT.refreshDashboard} onClick={refresh} sx={{ height }}>\n <RefreshIcon />\n </ToolbarIconButton>\n </InfoTooltip>\n )}\n </Stack>\n );\n}\n"],"names":["RefreshIcon","Stack","DateTimeRangePicker","InfoTooltip","useTimeRange","isDurationString","TOOLTIP_TEXT","useDefaultTimeRange","ToolbarIconButton","TIME_OPTIONS","value","pastDuration","display","DEFAULT_HEIGHT","TimeRangeControls","heightPx","showRefresh","timeRange","setTimeRange","refresh","defaultTimeRange","height","undefined","some","option","push","direction","spacing","timeOptions","onChange","description","refreshDashboard","aria-label","onClick","sx"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;A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Ee,EAAE,EAAE;wBAAEb,MAAM;qBAAE;8BAC5F,cAAA,KAACrB,WAAW,KAAG;kBACG;cACR,AACf;;MACK,CACR;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/dashboards",
3
- "version": "0.23.1",
3
+ "version": "0.24.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",
@@ -20,7 +20,8 @@
20
20
  "build": "concurrently \"npm:build:*\"",
21
21
  "build:cjs": "swc ./src -d dist/cjs --config-file ../.cjs.swcrc",
22
22
  "build:esm": "swc ./src -d dist --config-file ../.swcrc",
23
- "build:types": "tsc --emitDeclarationOnly --declaration --preserveWatchOutput",
23
+ "build:types": "tsc --project tsconfig.build.json",
24
+ "type-check": "tsc --noEmit",
24
25
  "start": "concurrently -P \"npm:build:* -- {*}\" -- --watch",
25
26
  "test": "TZ=UTC jest",
26
27
  "test:watch": "npm run test -- --watch",
@@ -28,9 +29,9 @@
28
29
  "lint:fix": "eslint --fix src --ext .ts,.tsx"
29
30
  },
30
31
  "dependencies": {
31
- "@perses-dev/components": "0.23.1",
32
- "@perses-dev/core": "0.23.1",
33
- "@perses-dev/plugin-system": "0.23.1",
32
+ "@perses-dev/components": "0.24.0",
33
+ "@perses-dev/core": "0.24.0",
34
+ "@perses-dev/plugin-system": "0.24.0",
34
35
  "@types/react-grid-layout": "^1.3.2",
35
36
  "date-fns": "^2.28.0",
36
37
  "immer": "^9.0.15",
@@ -1,137 +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
- const _jsxRuntime = require("react/jsx-runtime");
18
- const _react = require("@testing-library/react");
19
- const _userEvent = /*#__PURE__*/ _interopRequireDefault(require("@testing-library/user-event"));
20
- const _test = require("../../test");
21
- const _panel = require("./Panel");
22
- function _interopRequireDefault(obj) {
23
- return obj && obj.__esModule ? obj : {
24
- default: obj
25
- };
26
- }
27
- describe('Panel', ()=>{
28
- const createTestPanel = ()=>({
29
- kind: 'Panel',
30
- spec: {
31
- display: {
32
- name: 'Fake Panel Title',
33
- description: 'This is a fake panel'
34
- },
35
- plugin: {
36
- kind: 'TimeSeriesChart',
37
- spec: {}
38
- }
39
- }
40
- });
41
- // Helper to render the panel with some context set
42
- const renderPanel = (definition, editHandlers)=>{
43
- definition !== null && definition !== void 0 ? definition : definition = createTestPanel();
44
- (0, _test.renderWithContext)(/*#__PURE__*/ (0, _jsxRuntime.jsx)(_panel.Panel, {
45
- definition: definition,
46
- editHandlers: editHandlers
47
- }));
48
- };
49
- // Helper to get the panel once rendered
50
- const getPanel = ()=>_react.screen.getByRole('region', {
51
- name: 'Fake Panel Title'
52
- });
53
- it('should render panel', async ()=>{
54
- renderPanel();
55
- const panel = getPanel();
56
- expect(panel).toBeInTheDocument();
57
- // Should diplay header with panel's title
58
- const header = _react.screen.getByRole('banner');
59
- expect(header).toHaveTextContent('Fake Panel Title');
60
- // Should display chart's content from the fake panel plugin
61
- const content = _react.screen.getByRole('figure');
62
- await (0, _react.waitFor)(()=>{
63
- expect(content).toHaveTextContent('TimeSeriesChart panel');
64
- });
65
- expect(content);
66
- });
67
- it('shows panel description', async ()=>{
68
- renderPanel();
69
- const panel = getPanel();
70
- // Description button should not be visible until hover on panel
71
- const missingButton = _react.screen.queryByRole('button', {
72
- name: /description/i
73
- });
74
- expect(missingButton).not.toBeInTheDocument();
75
- _userEvent.default.hover(panel);
76
- const descriptionButton = _react.screen.getByRole('button', {
77
- name: /description/i
78
- });
79
- expect(descriptionButton).toBeInTheDocument();
80
- // Can hover to see panel description in tooltip
81
- _userEvent.default.hover(descriptionButton);
82
- const tooltip = await _react.screen.findByRole('tooltip');
83
- expect(tooltip).toHaveTextContent('This is a fake panel');
84
- });
85
- it('does not show description when panel does not have one', ()=>{
86
- // Render a panel without a description set
87
- const withoutDescription = createTestPanel();
88
- withoutDescription.spec.display.description = undefined;
89
- renderPanel(withoutDescription);
90
- const panel = getPanel();
91
- _userEvent.default.hover(panel);
92
- const descriptionButton = _react.screen.queryByRole('button', {
93
- name: /description/i
94
- });
95
- expect(descriptionButton).not.toBeInTheDocument();
96
- });
97
- it('does not show description in edit mode', ()=>{
98
- renderPanel(undefined, {
99
- onEditPanelClick: jest.fn(),
100
- onDeletePanelClick: jest.fn(),
101
- onDuplicatePanelClick: jest.fn()
102
- });
103
- const panel = getPanel();
104
- _userEvent.default.hover(panel);
105
- const descriptionButton = _react.screen.queryByRole('button', {
106
- name: /description/i
107
- });
108
- expect(descriptionButton).not.toBeInTheDocument();
109
- });
110
- it('can trigger panel actions in edit mode', ()=>{
111
- const onEditPanelClick = jest.fn();
112
- const onDeletePanelClick = jest.fn();
113
- const onDuplicatePanelClick = jest.fn();
114
- renderPanel(undefined, {
115
- onEditPanelClick,
116
- onDeletePanelClick,
117
- onDuplicatePanelClick
118
- });
119
- const panel = getPanel();
120
- _userEvent.default.hover(panel);
121
- const editButton = _react.screen.getByRole('button', {
122
- name: /edit/i
123
- });
124
- _userEvent.default.click(editButton);
125
- const deleteButton = _react.screen.getByRole('button', {
126
- name: /delete/i
127
- });
128
- _userEvent.default.click(deleteButton);
129
- const duplicateButton = _react.screen.getByRole('button', {
130
- name: /duplicate/i
131
- });
132
- _userEvent.default.click(duplicateButton);
133
- expect(onEditPanelClick).toHaveBeenCalledTimes(1);
134
- expect(onDeletePanelClick).toHaveBeenCalledTimes(1);
135
- expect(onDuplicatePanelClick).toHaveBeenCalledTimes(1);
136
- });
137
- });
@@ -1,131 +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
- const _jsxRuntime = require("react/jsx-runtime");
18
- const _react = require("@testing-library/react");
19
- const _userEvent = /*#__PURE__*/ _interopRequireDefault(require("@testing-library/user-event"));
20
- const _testUtils = require("react-dom/test-utils");
21
- const _test = require("../../test");
22
- const _dashboardProvider = require("../../context/DashboardProvider");
23
- const _panelDrawer = require("./PanelDrawer");
24
- function _interopRequireDefault(obj) {
25
- return obj && obj.__esModule ? obj : {
26
- default: obj
27
- };
28
- }
29
- describe('Panel Drawer', ()=>{
30
- const renderPanelDrawer = ()=>{
31
- const { store , DashboardProviderSpy } = (0, _test.createDashboardProviderSpy)();
32
- (0, _test.renderWithContext)(/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_dashboardProvider.DashboardProvider, {
33
- initialState: {
34
- dashboardResource: (0, _test.getTestDashboard)(),
35
- isEditMode: true
36
- },
37
- children: [
38
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(DashboardProviderSpy, {}),
39
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panelDrawer.PanelDrawer, {})
40
- ]
41
- }));
42
- const { value: storeApi } = store;
43
- if (storeApi === undefined) {
44
- throw new Error('Expected dashboard store to be set after initial render');
45
- }
46
- return storeApi;
47
- };
48
- it('should add new panel', async ()=>{
49
- const storeApi = renderPanelDrawer();
50
- // Open the drawer for a new panel
51
- (0, _testUtils.act)(()=>storeApi.getState().openAddPanel());
52
- const nameInput = await _react.screen.findByLabelText(/Name/);
53
- _userEvent.default.type(nameInput, 'New Panel');
54
- _userEvent.default.click(_react.screen.getByText('Add'));
55
- // TODO: Assert drawer is closed?
56
- const panels = storeApi.getState().panels;
57
- expect(panels).toMatchObject({
58
- // Should have the new panel in the store
59
- NewPanel: {
60
- kind: 'Panel',
61
- spec: {
62
- display: {
63
- name: 'New Panel'
64
- },
65
- plugin: {
66
- kind: '',
67
- spec: {}
68
- }
69
- }
70
- }
71
- });
72
- });
73
- it('should add panel with duplicate panel name', async ()=>{
74
- const storeApi = renderPanelDrawer();
75
- (0, _testUtils.act)(()=>storeApi.getState().openAddPanel());
76
- const nameInput = await _react.screen.findByLabelText(/Name/);
77
- _userEvent.default.type(nameInput, 'cpu');
78
- _userEvent.default.click(_react.screen.getByText('Add'));
79
- const panels = storeApi.getState().panels;
80
- expect(panels).toMatchObject({
81
- // make sure we don't have duplicate panel key by appending "-1"
82
- 'cpu-1': {
83
- kind: 'Panel',
84
- spec: {
85
- display: {
86
- name: 'cpu'
87
- },
88
- plugin: {
89
- kind: '',
90
- spec: {}
91
- }
92
- }
93
- }
94
- });
95
- });
96
- it('should edit an existing panel', async ()=>{
97
- const storeApi = renderPanelDrawer();
98
- // Open the drawer for an existing panel
99
- const group = Object.values(storeApi.getState().panelGroups).find((group)=>group.title === 'CPU Stats');
100
- if (group === undefined) {
101
- throw new Error('Test group not found');
102
- }
103
- const layout = Object.entries(group.itemPanelKeys).find(([, panelKey])=>panelKey === 'cpu');
104
- if (layout === undefined) {
105
- throw new Error('Test panel not found');
106
- }
107
- (0, _testUtils.act)(()=>storeApi.getState().openEditPanel({
108
- panelGroupId: group.id,
109
- panelGroupItemLayoutId: layout[0]
110
- }));
111
- const nameInput = await _react.screen.findByLabelText(/Name/);
112
- _userEvent.default.clear(nameInput);
113
- _userEvent.default.type(nameInput, 'cpu usage');
114
- _userEvent.default.click(_react.screen.getByText('Apply'));
115
- const panels = storeApi.getState().panels;
116
- expect(panels).toMatchObject({
117
- cpu: {
118
- kind: 'Panel',
119
- spec: {
120
- display: {
121
- name: 'cpu usage'
122
- },
123
- plugin: {
124
- kind: 'TimeSeriesChart',
125
- spec: {}
126
- }
127
- }
128
- }
129
- });
130
- });
131
- });
@@ -1,87 +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
- const _jsxRuntime = require("react/jsx-runtime");
18
- const _react = require("@testing-library/react");
19
- const _userEvent = /*#__PURE__*/ _interopRequireDefault(require("@testing-library/user-event"));
20
- const _testUtils = require("react-dom/test-utils");
21
- const _context = require("../../context");
22
- const _test = require("../../test");
23
- const _panelGroupDialog = require("./PanelGroupDialog");
24
- function _interopRequireDefault(obj) {
25
- return obj && obj.__esModule ? obj : {
26
- default: obj
27
- };
28
- }
29
- describe('Add Panel Group', ()=>{
30
- const renderDialog = ()=>{
31
- const { store , DashboardProviderSpy } = (0, _test.createDashboardProviderSpy)();
32
- (0, _test.renderWithContext)(/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_context.DashboardProvider, {
33
- initialState: {
34
- dashboardResource: (0, _test.getTestDashboard)(),
35
- isEditMode: true
36
- },
37
- children: [
38
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(DashboardProviderSpy, {}),
39
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panelGroupDialog.PanelGroupDialog, {})
40
- ]
41
- }));
42
- const { value: storeApi } = store;
43
- if (storeApi === undefined) {
44
- throw new Error('Expected dashboard store to be set after initial render');
45
- }
46
- return storeApi;
47
- };
48
- it('should add new panel group', async ()=>{
49
- const storeApi = renderDialog();
50
- // Open the dialog for a new panel group
51
- (0, _testUtils.act)(()=>storeApi.getState().openAddPanelGroup());
52
- const nameInput = await _react.screen.findByLabelText(/Name/);
53
- _userEvent.default.type(nameInput, 'New Panel Group');
54
- _userEvent.default.click(_react.screen.getByText('Add'));
55
- // TODO: Figure out how to test this without coupling to the store state
56
- const panelGroups = Object.values(storeApi.getState().panelGroups);
57
- expect(panelGroups).toContainEqual({
58
- id: expect.any(Number),
59
- title: 'New Panel Group',
60
- isCollapsed: false,
61
- itemLayouts: expect.any(Array),
62
- itemPanelKeys: expect.any(Object)
63
- });
64
- });
65
- it('should edit existing panel group', async ()=>{
66
- const storeApi = renderDialog();
67
- // Open the dialog for an existing panel group
68
- const group = Object.values(storeApi.getState().panelGroups).find((group)=>group.title === 'CPU Stats');
69
- if (group === undefined) {
70
- throw new Error('Missing test group');
71
- }
72
- (0, _testUtils.act)(()=>storeApi.getState().openEditPanelGroup(group.id));
73
- const nameInput = await _react.screen.findByLabelText(/Name/);
74
- _userEvent.default.clear(nameInput);
75
- _userEvent.default.type(nameInput, 'New Name');
76
- _userEvent.default.click(_react.screen.getByText('Apply'));
77
- // TODO: Figure out how to test this without coupling to the store state
78
- const panelGroups = storeApi.getState().panelGroups;
79
- expect(panelGroups).toMatchObject({
80
- [group.id]: {
81
- id: group.id,
82
- title: 'New Name',
83
- isCollapsed: false
84
- }
85
- });
86
- });
87
- });
@@ -1,95 +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
- const _jsxRuntime = require("react/jsx-runtime");
18
- const _reactRouter = require("react-router");
19
- const _history = require("history");
20
- const _userEvent = /*#__PURE__*/ _interopRequireDefault(require("@testing-library/user-event"));
21
- const _react = require("@testing-library/react");
22
- const _pluginSystem = require("@perses-dev/plugin-system");
23
- const _test = require("../../test");
24
- const _testDashboard = /*#__PURE__*/ _interopRequireDefault(require("../../test/testDashboard"));
25
- const _context = require("../../context");
26
- const _timeRangeControls = require("./TimeRangeControls");
27
- function _interopRequireDefault(obj) {
28
- return obj && obj.__esModule ? obj : {
29
- default: obj
30
- };
31
- }
32
- const history = (0, _history.createMemoryHistory)({
33
- initialEntries: [
34
- (0, _reactRouter.generatePath)('/home'),
35
- (0, _reactRouter.generatePath)('/dashboards/:id', {
36
- id: 'test'
37
- })
38
- ]
39
- });
40
- describe('TimeRangeControls', ()=>{
41
- let initialState;
42
- const testDefaultTimeRange = {
43
- pastDuration: _testDashboard.default.spec.duration
44
- };
45
- beforeEach(()=>{
46
- initialState = {
47
- dashboardResource: _testDashboard.default
48
- };
49
- });
50
- const renderTimeRangeControls = (testURLParams)=>{
51
- (0, _test.renderWithContext)(/*#__PURE__*/ (0, _jsxRuntime.jsx)(_context.DashboardProvider, {
52
- initialState: initialState,
53
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.TimeRangeProvider, {
54
- initialTimeRange: testDefaultTimeRange,
55
- enabledURLParams: testURLParams,
56
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_timeRangeControls.TimeRangeControls, {})
57
- })
58
- }), undefined, history);
59
- };
60
- it('should default to dashboard duration and update selected time option when clicked', async ()=>{
61
- renderTimeRangeControls(false);
62
- expect(_react.screen.getByText('Last 30 minutes')).toBeInTheDocument();
63
- const dateButton = _react.screen.getByRole('button', {
64
- name: /time range/i
65
- });
66
- _userEvent.default.click(dateButton);
67
- const firstSelected = _react.screen.getByRole('option', {
68
- name: 'Last 5 minutes'
69
- });
70
- _userEvent.default.click(firstSelected);
71
- expect(dateButton).toHaveTextContent(/5 minutes/i);
72
- });
73
- it('should update URL params with correct time range values', ()=>{
74
- renderTimeRangeControls(true);
75
- const dateButton = _react.screen.getByRole('button', {
76
- name: /time range/i
77
- });
78
- _userEvent.default.click(dateButton);
79
- const firstSelected = _react.screen.getByRole('option', {
80
- name: 'Last 5 minutes'
81
- });
82
- _userEvent.default.click(firstSelected);
83
- expect(history.location.search).toEqual('?start=5m');
84
- // pick another option from TimeRangeSelector dropdown
85
- const secondSelected = _react.screen.getByText('Last 12 hours');
86
- _userEvent.default.click(secondSelected);
87
- expect(history.location.search).toEqual('?start=12h');
88
- // back button should return to previous page selected
89
- (0, _react.act)(()=>{
90
- history.back();
91
- });
92
- expect(history.location.pathname).toEqual('/home');
93
- });
94
- // TODO: add additional tests for absolute time selection, other inputs, form validation, etc.
95
- });