@perses-dev/plugin-system 0.0.0-snapshot-time-zone-selector-946f408 → 0.0.0-snapshot-panel-actions-520389b

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 (32) hide show
  1. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +1 -3
  2. package/dist/cjs/constants/user-interface-text.js +0 -1
  3. package/dist/cjs/remote/PluginRuntime.js +16 -8
  4. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +3 -30
  5. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js +1 -5
  6. package/dist/cjs/runtime/TimeRangeProvider/query-params.js +0 -31
  7. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  8. package/dist/components/TimeRangeControls/TimeRangeControls.js +2 -4
  9. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  10. package/dist/constants/user-interface-text.d.ts +0 -1
  11. package/dist/constants/user-interface-text.d.ts.map +1 -1
  12. package/dist/constants/user-interface-text.js +0 -1
  13. package/dist/constants/user-interface-text.js.map +1 -1
  14. package/dist/model/panels.d.ts +8 -0
  15. package/dist/model/panels.d.ts.map +1 -1
  16. package/dist/model/panels.js.map +1 -1
  17. package/dist/remote/PluginRuntime.d.ts.map +1 -1
  18. package/dist/remote/PluginRuntime.js +16 -8
  19. package/dist/remote/PluginRuntime.js.map +1 -1
  20. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +0 -12
  21. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
  22. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +4 -28
  23. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  24. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts +0 -1
  25. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts.map +1 -1
  26. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js +2 -6
  27. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js.map +1 -1
  28. package/dist/runtime/TimeRangeProvider/query-params.d.ts +0 -4
  29. package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -1
  30. package/dist/runtime/TimeRangeProvider/query-params.js +1 -29
  31. package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
  32. package/package.json +3 -3
@@ -84,7 +84,6 @@ const DEFAULT_REFRESH_INTERVAL_OPTIONS = [
84
84
  const DEFAULT_HEIGHT = '34px';
85
85
  function TimeRangeControls({ heightPx, showTimeRangeSelector = true, showRefreshButton = true, showRefreshInterval = true, showCustomTimeRange, showZoomButtons = true, timePresets }) {
86
86
  const { timeRange, setTimeRange, refresh, refreshInterval, setRefreshInterval } = (0, _runtime.useTimeRange)();
87
- const { timeZone } = (0, _runtime.useTimeZone)();
88
87
  const showCustomTimeRangeValue = (0, _runtime.useShowCustomTimeRangeSetting)(showCustomTimeRange);
89
88
  const showZoomInOutButtons = (0, _runtime.useShowZoomRangeSetting)(showZoomButtons);
90
89
  const timePresetsValue = (0, _runtime.useTimeRangeOptionsSetting)(timePresets);
@@ -173,8 +172,7 @@ function TimeRangeControls({ heightPx, showTimeRangeSelector = true, showRefresh
173
172
  value: timeRange,
174
173
  onChange: setTimeRange,
175
174
  height: height,
176
- showCustomTimeRange: showCustomTimeRangeValue,
177
- timeZone: timeZone
175
+ showCustomTimeRange: showCustomTimeRangeValue
178
176
  }),
179
177
  showZoomInOutButtons && /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
180
178
  description: _constants.TOOLTIP_TEXT.zoomOut,
@@ -27,7 +27,6 @@ const TOOLTIP_TEXT = {
27
27
  // Time range controls buttons
28
28
  refresh: 'Refresh',
29
29
  refreshInterval: 'Auto refresh interval',
30
- timezone: 'Timezone',
31
30
  zoomIn: 'Zoom in',
32
31
  zoomOut: 'Zoom out'
33
32
  };
@@ -135,36 +135,44 @@ const getPluginRuntime = ()=>{
135
135
  requiredVersion: '^5.5.0'
136
136
  }
137
137
  },
138
+ '@perses-dev/core': {
139
+ version: '0.51.0-rc.1',
140
+ lib: ()=>require('@perses-dev/core'),
141
+ shareConfig: {
142
+ singleton: true,
143
+ requiredVersion: '^0.51.0-rc.1'
144
+ }
145
+ },
138
146
  '@perses-dev/components': {
139
- version: '0.51.0-beta.0',
147
+ version: '0.51.0-rc.1',
140
148
  lib: ()=>require('@perses-dev/components'),
141
149
  shareConfig: {
142
150
  singleton: true,
143
- requiredVersion: '^0.51.0-rc.0'
151
+ requiredVersion: '^0.51.0-rc.1'
144
152
  }
145
153
  },
146
154
  '@perses-dev/plugin-system': {
147
- version: '0.51.0-beta.0',
155
+ version: '0.51.0-rc.1',
148
156
  lib: ()=>require('@perses-dev/plugin-system'),
149
157
  shareConfig: {
150
158
  singleton: true,
151
- requiredVersion: '^0.51.0-rc.0'
159
+ requiredVersion: '^0.51.0-rc.1'
152
160
  }
153
161
  },
154
162
  '@perses-dev/explore': {
155
- version: '0.51.0-beta.0',
163
+ version: '0.51.0-rc.1',
156
164
  lib: ()=>require('@perses-dev/explore'),
157
165
  shareConfig: {
158
166
  singleton: true,
159
- requiredVersion: '^0.51.0-rc.0'
167
+ requiredVersion: '^0.51.0-rc.1'
160
168
  }
161
169
  },
162
170
  '@perses-dev/dashboards': {
163
- version: '0.51.0-beta.0',
171
+ version: '0.51.0-rc.1',
164
172
  lib: ()=>require('@perses-dev/dashboards'),
165
173
  shareConfig: {
166
174
  singleton: true,
167
- requiredVersion: '^0.51.0-rc.0'
175
+ requiredVersion: '^0.51.0-rc.1'
168
176
  }
169
177
  },
170
178
  // Below are the shared modules that are used by the plugins, this can be part of the SDK
@@ -35,15 +35,11 @@ _export(exports, {
35
35
  },
36
36
  useTimeRangeContext: function() {
37
37
  return useTimeRangeContext;
38
- },
39
- useTimeZone: function() {
40
- return useTimeZone;
41
38
  }
42
39
  });
43
40
  const _jsxruntime = require("react/jsx-runtime");
44
41
  const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
45
42
  const _core = require("@perses-dev/core");
46
- const _components = require("@perses-dev/components");
47
43
  const _refreshinterval = require("./refresh-interval");
48
44
  function _getRequireWildcardCache(nodeInterop) {
49
45
  if (typeof WeakMap !== "function") return null;
@@ -97,29 +93,15 @@ function useTimeRangeContext() {
97
93
  function useTimeRange() {
98
94
  return useTimeRangeContext();
99
95
  }
100
- function useTimeZone() {
101
- const { timeZone, setTimeZone } = useTimeRangeContext();
102
- return {
103
- timeZone,
104
- setTimeZone,
105
- formatWithUserTimeZone: (date, formatString)=>{
106
- return (0, _components.formatWithTimeZone)(date, formatString, timeZone);
107
- },
108
- dateFormatOptionsWithUserTimeZone: (dateFormatOptions)=>{
109
- return (0, _components.dateFormatOptionsWithTimeZone)(dateFormatOptions, timeZone);
110
- }
111
- };
112
- }
113
96
  function useSuggestedStepMs(width) {
114
97
  const { absoluteTimeRange } = useTimeRange();
115
98
  if (width === undefined) return 0;
116
99
  return (0, _core.getSuggestedStepMs)(absoluteTimeRange, width);
117
100
  }
118
101
  function TimeRangeProvider(props) {
119
- const { timeRange, refreshInterval, children, setTimeRange, setRefreshInterval, timeZone = _core.DEFAULT_DASHBOARD_TIMEZONE, setTimeZone } = props;
102
+ const { timeRange, refreshInterval, children, setTimeRange, setRefreshInterval } = props;
120
103
  const [localTimeRange, setLocalTimeRange] = (0, _react.useState)(timeRange);
121
104
  const [localRefreshInterval, setLocalRefreshInterval] = (0, _react.useState)(refreshInterval);
122
- const [localTimeZone, setLocalTimeZone] = (0, _react.useState)(timeZone);
123
105
  const [refreshCounter, setRefreshCounter] = (0, _react.useState)(0);
124
106
  (0, _react.useEffect)(()=>{
125
107
  setLocalTimeRange(timeRange);
@@ -132,11 +114,6 @@ function TimeRangeProvider(props) {
132
114
  }, [
133
115
  refreshInterval
134
116
  ]);
135
- (0, _react.useEffect)(()=>{
136
- setLocalTimeZone(timeZone);
137
- }, [
138
- timeZone
139
- ]);
140
117
  const refresh = (0, _react.useCallback)(()=>{
141
118
  setRefreshCounter((counter)=>counter + 1);
142
119
  }, [
@@ -158,26 +135,22 @@ function TimeRangeProvider(props) {
158
135
  const absoluteTimeRange = (0, _core.isRelativeTimeRange)(localTimeRange) ? (0, _core.toAbsoluteTimeRange)(localTimeRange) : localTimeRange;
159
136
  return {
160
137
  timeRange: localTimeRange,
161
- timeZone: localTimeZone,
162
138
  setTimeRange: setTimeRange ?? setLocalTimeRange,
163
139
  absoluteTimeRange,
164
140
  refresh,
165
141
  refreshKey: `${absoluteTimeRange.start}:${absoluteTimeRange.end}:${localRefreshInterval}:${refreshCounter}`,
166
142
  refreshInterval: localRefreshInterval,
167
143
  refreshIntervalInMs: refreshIntervalInMs,
168
- setRefreshInterval: setRefreshInterval ?? setLocalRefreshInterval,
169
- setTimeZone: setTimeZone ?? setLocalTimeZone
144
+ setRefreshInterval: setRefreshInterval ?? setLocalRefreshInterval
170
145
  };
171
146
  }, [
172
147
  localTimeRange,
173
- localTimeZone,
174
148
  setTimeRange,
175
149
  refresh,
176
150
  localRefreshInterval,
177
151
  refreshCounter,
178
152
  refreshIntervalInMs,
179
- setRefreshInterval,
180
- setTimeZone
153
+ setRefreshInterval
181
154
  ]);
182
155
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(TimeRangeContext.Provider, {
183
156
  value: ctx,
@@ -21,7 +21,6 @@ Object.defineProperty(exports, "TimeRangeProviderWithQueryParams", {
21
21
  }
22
22
  });
23
23
  const _jsxruntime = require("react/jsx-runtime");
24
- const _core = require("@perses-dev/core");
25
24
  const _react = /*#__PURE__*/ _interop_require_default(require("react"));
26
25
  const _TimeRangeProvider = require("./TimeRangeProvider");
27
26
  const _queryparams = require("./query-params");
@@ -31,17 +30,14 @@ function _interop_require_default(obj) {
31
30
  };
32
31
  }
33
32
  function TimeRangeProviderWithQueryParams(props) {
34
- const { initialTimeRange, initialRefreshInterval, children, initialTimeZone = _core.DEFAULT_DASHBOARD_TIMEZONE } = props;
33
+ const { initialTimeRange, initialRefreshInterval, children } = props;
35
34
  const { timeRange, setTimeRange } = (0, _queryparams.useTimeRangeParams)(initialTimeRange);
36
35
  const { refreshInterval, setRefreshInterval } = (0, _queryparams.useSetRefreshIntervalParams)(initialRefreshInterval);
37
- const { timeZone, setTimeZone } = (0, _queryparams.useSetTimeZoneParams)(initialTimeZone);
38
36
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_TimeRangeProvider.TimeRangeProvider, {
39
37
  timeRange: timeRange,
40
38
  refreshInterval: refreshInterval,
41
39
  setTimeRange: setTimeRange,
42
40
  setRefreshInterval: setRefreshInterval,
43
- timeZone: timeZone,
44
- setTimeZone: setTimeZone,
45
41
  children: children
46
42
  });
47
43
  }
@@ -45,9 +45,6 @@ _export(exports, {
45
45
  useSetRefreshIntervalParams: function() {
46
46
  return useSetRefreshIntervalParams;
47
47
  },
48
- useSetTimeZoneParams: function() {
49
- return useSetTimeZoneParams;
50
- },
51
48
  useTimeRangeParams: function() {
52
49
  return useTimeRangeParams;
53
50
  }
@@ -224,31 +221,3 @@ function useSetRefreshIntervalParams(initialRefreshInterval) {
224
221
  setRefreshInterval: setRefreshInterval
225
222
  };
226
223
  }
227
- function useSetTimeZoneParams(initialTimeZone) {
228
- const [query, setQuery] = (0, _usequeryparams.useQueryParams)({
229
- timeZone: _usequeryparams.StringParam
230
- }, {
231
- updateType: 'replaceIn'
232
- });
233
- const { timeZone } = query;
234
- (0, _react.useEffect)(()=>{
235
- if (!timeZone) {
236
- setQuery({
237
- timeZone: initialTimeZone
238
- });
239
- }
240
- }, [
241
- setQuery,
242
- timeZone,
243
- initialTimeZone
244
- ]);
245
- const setTimeZone = (0, _react.useCallback)((timeZone)=>setQuery({
246
- timeZone
247
- }), [
248
- setQuery
249
- ]);
250
- return {
251
- timeZone: timeZone ? timeZone : initialTimeZone,
252
- setTimeZone: setTimeZone
253
- };
254
- }
@@ -1 +1 @@
1
- {"version":3,"file":"TimeRangeControls.d.ts","sourceRoot":"","sources":["../../../src/components/TimeRangeControls/TimeRangeControls.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAGL,UAAU,EAIX,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,YAAY,EAAe,MAAM,OAAO,CAAC;AAUlD,eAAO,MAAM,gCAAgC,EAAE,UAAU,EAOxD,CAAC;AAIF,UAAU,sBAAsB;IAE9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;CAC5B;AAED,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,qBAA4B,EAC5B,iBAAwB,EACxB,mBAA0B,EAC1B,mBAAmB,EACnB,eAAsB,EACtB,WAAW,GACZ,EAAE,sBAAsB,GAAG,YAAY,CA4IvC"}
1
+ {"version":3,"file":"TimeRangeControls.d.ts","sourceRoot":"","sources":["../../../src/components/TimeRangeControls/TimeRangeControls.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAGL,UAAU,EAIX,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,YAAY,EAAe,MAAM,OAAO,CAAC;AASlD,eAAO,MAAM,gCAAgC,EAAE,UAAU,EAOxD,CAAC;AAIF,UAAU,sBAAsB;IAE9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;CAC5B;AAED,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,qBAA4B,EAC5B,iBAAwB,EACxB,mBAA0B,EAC1B,mBAAmB,EACnB,eAAsB,EACtB,WAAW,GACZ,EAAE,sBAAsB,GAAG,YAAY,CA0IvC"}
@@ -21,7 +21,7 @@ import { RefreshIntervalPicker, InfoTooltip, ToolbarIconButton, TimeRangeSelecto
21
21
  import { parseDurationString } from '@perses-dev/core';
22
22
  import { useCallback } from 'react';
23
23
  import { TOOLTIP_TEXT } from '../../constants';
24
- import { useTimeRange, useTimeZone, useShowCustomTimeRangeSetting, useTimeRangeOptionsSetting, useShowZoomRangeSetting } from '../../runtime';
24
+ import { useTimeRange, useShowCustomTimeRangeSetting, useTimeRangeOptionsSetting, useShowZoomRangeSetting } from '../../runtime';
25
25
  export const DEFAULT_REFRESH_INTERVAL_OPTIONS = [
26
26
  {
27
27
  value: {
@@ -63,7 +63,6 @@ export const DEFAULT_REFRESH_INTERVAL_OPTIONS = [
63
63
  const DEFAULT_HEIGHT = '34px';
64
64
  export function TimeRangeControls({ heightPx, showTimeRangeSelector = true, showRefreshButton = true, showRefreshInterval = true, showCustomTimeRange, showZoomButtons = true, timePresets }) {
65
65
  const { timeRange, setTimeRange, refresh, refreshInterval, setRefreshInterval } = useTimeRange();
66
- const { timeZone } = useTimeZone();
67
66
  const showCustomTimeRangeValue = useShowCustomTimeRangeSetting(showCustomTimeRange);
68
67
  const showZoomInOutButtons = useShowZoomRangeSetting(showZoomButtons);
69
68
  const timePresetsValue = useTimeRangeOptionsSetting(timePresets);
@@ -152,8 +151,7 @@ export function TimeRangeControls({ heightPx, showTimeRangeSelector = true, show
152
151
  value: timeRange,
153
152
  onChange: setTimeRange,
154
153
  height: height,
155
- showCustomTimeRange: showCustomTimeRangeValue,
156
- timeZone: timeZone
154
+ showCustomTimeRange: showCustomTimeRangeValue
157
155
  }),
158
156
  showZoomInOutButtons && /*#__PURE__*/ _jsx(InfoTooltip, {
159
157
  description: TOOLTIP_TEXT.zoomOut,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/TimeRangeControls/TimeRangeControls.tsx"],"sourcesContent":["// Copyright 2024 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';\n// eslint-disable-next-line import/no-duplicates\nimport ZoomIn from 'mdi-material-ui/PlusCircleOutline';\n// eslint-disable-next-line import/no-duplicates\nimport ZoomOut from 'mdi-material-ui/MinusCircleOutline';\nimport { Stack } from '@mui/material';\nimport {\n RefreshIntervalPicker,\n InfoTooltip,\n TimeOption,\n ToolbarIconButton,\n TimeRangeSelector,\n buildRelativeTimeOption,\n} from '@perses-dev/components';\nimport { AbsoluteTimeRange, DurationString, parseDurationString, RelativeTimeRange } from '@perses-dev/core';\nimport { ReactElement, useCallback } from 'react';\nimport { TOOLTIP_TEXT } from '../../constants';\nimport {\n useTimeRange,\n useTimeZone,\n useShowCustomTimeRangeSetting,\n useTimeRangeOptionsSetting,\n useShowZoomRangeSetting,\n} from '../../runtime';\n\nexport const DEFAULT_REFRESH_INTERVAL_OPTIONS: TimeOption[] = [\n { value: { pastDuration: '0s' }, display: 'Off' },\n { value: { pastDuration: '5s' }, display: '5s' },\n { value: { pastDuration: '10s' }, display: '10s' },\n { value: { pastDuration: '15s' }, display: '15s' },\n { value: { pastDuration: '30s' }, display: '30s' },\n { value: { pastDuration: '60s' }, display: '1m' },\n];\n\nconst DEFAULT_HEIGHT = '34px';\n\ninterface TimeRangeControlsProps {\n // The controls look best at heights >= 28 pixels\n heightPx?: number;\n showTimeRangeSelector?: boolean;\n showRefreshButton?: boolean;\n showRefreshInterval?: boolean;\n showCustomTimeRange?: boolean;\n showZoomButtons?: boolean;\n timePresets?: TimeOption[];\n}\n\nexport function TimeRangeControls({\n heightPx,\n showTimeRangeSelector = true,\n showRefreshButton = true,\n showRefreshInterval = true,\n showCustomTimeRange,\n showZoomButtons = true,\n timePresets,\n}: TimeRangeControlsProps): ReactElement {\n const { timeRange, setTimeRange, refresh, refreshInterval, setRefreshInterval } = useTimeRange();\n const { timeZone } = useTimeZone();\n\n const showCustomTimeRangeValue = useShowCustomTimeRangeSetting(showCustomTimeRange);\n const showZoomInOutButtons = useShowZoomRangeSetting(showZoomButtons);\n const timePresetsValue = useTimeRangeOptionsSetting(timePresets);\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 preset if one does not match duration given in time range\n if (\n 'pastDuration' in timeRange &&\n !timePresetsValue.some((option) => option.value.pastDuration === timeRange['pastDuration'])\n ) {\n timePresetsValue.push(buildRelativeTimeOption(timeRange['pastDuration']));\n }\n\n // set the new refresh interval both in the dashboard context & as query param\n const handleRefreshIntervalChange = useCallback(\n (duration: DurationString) => {\n setRefreshInterval(duration);\n },\n [setRefreshInterval]\n );\n\n const fromDurationToMillis = (strDuration: string): number => {\n const duration = parseDurationString(strDuration);\n const millis =\n // eslint-disable-next-line prettier/prettier\n ((duration.seconds ?? 0) +\n (duration.minutes ?? 0) * 60 +\n (duration.hours ?? 0) * 3600 +\n (duration.days ?? 0) * 86400 +\n (duration.weeks ?? 0) * 7 * 86400 +\n (duration.months ?? 0) * 30.436875 * 86400 + // avg month duration is ok for zoom purposes\n (duration.years ?? 0) * 365.2425 * 86400) * // avg year duration is ok for zoom purposes\n // eslint-disable-next-line prettier/prettier\n 1000; // to milliseconds\n return millis;\n };\n\n // Function to double current time range, adding 50% before current start and 50% after current end\n const doubleTimeRange = (): AbsoluteTimeRange => {\n let newStart, newEnd, extendEndsBy;\n const now = new Date();\n if (Object.hasOwn(timeRange, 'start')) {\n // current range is absolute\n const absVal = timeRange as AbsoluteTimeRange;\n extendEndsBy = (absVal.end.getTime() - absVal.start.getTime()) / 2; // half it to add 50% before current start and after current end\n newStart = new Date(absVal.start.getTime() - extendEndsBy);\n newEnd = new Date(absVal.end.getTime() + extendEndsBy);\n } else {\n // current range is relative\n const relVal = timeRange as RelativeTimeRange;\n extendEndsBy = fromDurationToMillis(relVal.pastDuration) / 2;\n newEnd = typeof relVal.end === 'undefined' ? now : new Date(relVal.end.getTime() + extendEndsBy);\n newStart = new Date(newEnd.getTime() - extendEndsBy * 4);\n }\n if (newEnd.getTime() > now.getTime()) {\n // if the new computed end is in the future\n newEnd = now;\n newStart.setTime(now.getTime() - extendEndsBy * 4);\n }\n if (newStart.getTime() < 1) {\n newStart.setTime(1);\n }\n return { start: newStart, end: newEnd };\n };\n\n // Function to half current time range, cutting 25% before current start and 25% after current end\n const halfTimeRange = (): AbsoluteTimeRange => {\n let newStart, newEnd;\n if (Object.hasOwn(timeRange, 'start')) {\n const absVal = timeRange as AbsoluteTimeRange;\n const shrinkEndsBy = (absVal.end.getTime() - absVal.start.getTime()) / 4;\n newStart = new Date(absVal.start.getTime() + shrinkEndsBy);\n newEnd = new Date(absVal.end.getTime() - shrinkEndsBy);\n } else {\n const relVal = timeRange as RelativeTimeRange;\n const shrinkEndsBy = fromDurationToMillis(relVal.pastDuration) / 4; // 25% of it to cut after current start and before current end\n const endIsAbsolute = typeof relVal.end !== 'undefined';\n newEnd = endIsAbsolute ? new Date(relVal.end!.getTime() - shrinkEndsBy) : new Date();\n newStart = new Date(newEnd.getTime() - shrinkEndsBy * 2);\n }\n if (newStart.getTime() >= newEnd.getTime() - 1000) {\n newStart.setTime(newEnd.getTime() - 1000);\n }\n return { start: newStart, end: newEnd };\n };\n\n const setHalfTimeRange = (): void => setTimeRange(halfTimeRange());\n const setDoubleTimeRange = (): void => setTimeRange(doubleTimeRange());\n\n return (\n <Stack direction=\"row\" spacing={1}>\n {showTimeRangeSelector && (\n <TimeRangeSelector\n timeOptions={timePresetsValue}\n value={timeRange}\n onChange={setTimeRange}\n height={height}\n showCustomTimeRange={showCustomTimeRangeValue}\n timeZone={timeZone}\n />\n )}\n {showZoomInOutButtons && (\n <InfoTooltip description={TOOLTIP_TEXT.zoomOut}>\n <ToolbarIconButton aria-label={TOOLTIP_TEXT.zoomOut} onClick={setDoubleTimeRange} sx={{ height }}>\n <ZoomOut />\n </ToolbarIconButton>\n </InfoTooltip>\n )}\n {showZoomInOutButtons && (\n <InfoTooltip description={TOOLTIP_TEXT.zoomIn}>\n <ToolbarIconButton aria-label={TOOLTIP_TEXT.zoomIn} onClick={setHalfTimeRange} sx={{ height }}>\n <ZoomIn />\n </ToolbarIconButton>\n </InfoTooltip>\n )}\n {showRefreshButton && (\n <InfoTooltip description={TOOLTIP_TEXT.refresh}>\n <ToolbarIconButton aria-label={TOOLTIP_TEXT.refresh} onClick={refresh} sx={{ height }}>\n <RefreshIcon />\n </ToolbarIconButton>\n </InfoTooltip>\n )}\n {showRefreshInterval && (\n <InfoTooltip description={TOOLTIP_TEXT.refreshInterval}>\n <RefreshIntervalPicker\n timeOptions={DEFAULT_REFRESH_INTERVAL_OPTIONS}\n value={refreshInterval}\n onChange={handleRefreshIntervalChange}\n height={height}\n />\n </InfoTooltip>\n )}\n </Stack>\n );\n}\n"],"names":["RefreshIcon","ZoomIn","ZoomOut","Stack","RefreshIntervalPicker","InfoTooltip","ToolbarIconButton","TimeRangeSelector","buildRelativeTimeOption","parseDurationString","useCallback","TOOLTIP_TEXT","useTimeRange","useTimeZone","useShowCustomTimeRangeSetting","useTimeRangeOptionsSetting","useShowZoomRangeSetting","DEFAULT_REFRESH_INTERVAL_OPTIONS","value","pastDuration","display","DEFAULT_HEIGHT","TimeRangeControls","heightPx","showTimeRangeSelector","showRefreshButton","showRefreshInterval","showCustomTimeRange","showZoomButtons","timePresets","timeRange","setTimeRange","refresh","refreshInterval","setRefreshInterval","timeZone","showCustomTimeRangeValue","showZoomInOutButtons","timePresetsValue","height","undefined","some","option","push","handleRefreshIntervalChange","duration","fromDurationToMillis","strDuration","millis","seconds","minutes","hours","days","weeks","months","years","doubleTimeRange","newStart","newEnd","extendEndsBy","now","Date","Object","hasOwn","absVal","end","getTime","start","relVal","setTime","halfTimeRange","shrinkEndsBy","endIsAbsolute","setHalfTimeRange","setDoubleTimeRange","direction","spacing","timeOptions","onChange","description","zoomOut","aria-label","onClick","sx","zoomIn"],"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,OAAOA,iBAAiB,0BAA0B;AAClD,gDAAgD;AAChD,OAAOC,YAAY,oCAAoC;AACvD,gDAAgD;AAChD,OAAOC,aAAa,qCAAqC;AACzD,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SACEC,qBAAqB,EACrBC,WAAW,EAEXC,iBAAiB,EACjBC,iBAAiB,EACjBC,uBAAuB,QAClB,yBAAyB;AAChC,SAA4CC,mBAAmB,QAA2B,mBAAmB;AAC7G,SAAuBC,WAAW,QAAQ,QAAQ;AAClD,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SACEC,YAAY,EACZC,WAAW,EACXC,6BAA6B,EAC7BC,0BAA0B,EAC1BC,uBAAuB,QAClB,gBAAgB;AAEvB,OAAO,MAAMC,mCAAiD;IAC5D;QAAEC,OAAO;YAAEC,cAAc;QAAK;QAAGC,SAAS;IAAM;IAChD;QAAEF,OAAO;YAAEC,cAAc;QAAK;QAAGC,SAAS;IAAK;IAC/C;QAAEF,OAAO;YAAEC,cAAc;QAAM;QAAGC,SAAS;IAAM;IACjD;QAAEF,OAAO;YAAEC,cAAc;QAAM;QAAGC,SAAS;IAAM;IACjD;QAAEF,OAAO;YAAEC,cAAc;QAA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E,cAAYtE,aAAayE,MAAM;oBAAEF,SAAST;oBAAkBU,IAAI;wBAAE5C;oBAAO;8BAC1F,cAAA,KAACtC;;;YAINwB,mCACC,KAACpB;gBAAY0E,aAAapE,aAAaqB,OAAO;0BAC5C,cAAA,KAAC1B;oBAAkB2E,cAAYtE,aAAaqB,OAAO;oBAAEkD,SAASlD;oBAASmD,IAAI;wBAAE5C;oBAAO;8BAClF,cAAA,KAACvC;;;YAIN0B,qCACC,KAACrB;gBAAY0E,aAAapE,aAAasB,eAAe;0BACpD,cAAA,KAAC7B;oBACCyE,aAAa5D;oBACbC,OAAOe;oBACP6C,UAAUlC;oBACVL,QAAQA;;;;;AAMpB"}
1
+ {"version":3,"sources":["../../../src/components/TimeRangeControls/TimeRangeControls.tsx"],"sourcesContent":["// Copyright 2024 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';\n// eslint-disable-next-line import/no-duplicates\nimport ZoomIn from 'mdi-material-ui/PlusCircleOutline';\n// eslint-disable-next-line import/no-duplicates\nimport ZoomOut from 'mdi-material-ui/MinusCircleOutline';\nimport { Stack } from '@mui/material';\nimport {\n RefreshIntervalPicker,\n InfoTooltip,\n TimeOption,\n ToolbarIconButton,\n TimeRangeSelector,\n buildRelativeTimeOption,\n} from '@perses-dev/components';\nimport { AbsoluteTimeRange, DurationString, parseDurationString, RelativeTimeRange } from '@perses-dev/core';\nimport { ReactElement, useCallback } from 'react';\nimport { TOOLTIP_TEXT } from '../../constants';\nimport {\n useTimeRange,\n useShowCustomTimeRangeSetting,\n useTimeRangeOptionsSetting,\n useShowZoomRangeSetting,\n} from '../../runtime';\n\nexport const DEFAULT_REFRESH_INTERVAL_OPTIONS: TimeOption[] = [\n { value: { pastDuration: '0s' }, display: 'Off' },\n { value: { pastDuration: '5s' }, display: '5s' },\n { value: { pastDuration: '10s' }, display: '10s' },\n { value: { pastDuration: '15s' }, display: '15s' },\n { value: { pastDuration: '30s' }, display: '30s' },\n { value: { pastDuration: '60s' }, display: '1m' },\n];\n\nconst DEFAULT_HEIGHT = '34px';\n\ninterface TimeRangeControlsProps {\n // The controls look best at heights >= 28 pixels\n heightPx?: number;\n showTimeRangeSelector?: boolean;\n showRefreshButton?: boolean;\n showRefreshInterval?: boolean;\n showCustomTimeRange?: boolean;\n showZoomButtons?: boolean;\n timePresets?: TimeOption[];\n}\n\nexport function TimeRangeControls({\n heightPx,\n showTimeRangeSelector = true,\n showRefreshButton = true,\n showRefreshInterval = true,\n showCustomTimeRange,\n showZoomButtons = true,\n timePresets,\n}: TimeRangeControlsProps): ReactElement {\n const { timeRange, setTimeRange, refresh, refreshInterval, setRefreshInterval } = useTimeRange();\n\n const showCustomTimeRangeValue = useShowCustomTimeRangeSetting(showCustomTimeRange);\n const showZoomInOutButtons = useShowZoomRangeSetting(showZoomButtons);\n const timePresetsValue = useTimeRangeOptionsSetting(timePresets);\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 preset if one does not match duration given in time range\n if (\n 'pastDuration' in timeRange &&\n !timePresetsValue.some((option) => option.value.pastDuration === timeRange['pastDuration'])\n ) {\n timePresetsValue.push(buildRelativeTimeOption(timeRange['pastDuration']));\n }\n\n // set the new refresh interval both in the dashboard context & as query param\n const handleRefreshIntervalChange = useCallback(\n (duration: DurationString) => {\n setRefreshInterval(duration);\n },\n [setRefreshInterval]\n );\n\n const fromDurationToMillis = (strDuration: string): number => {\n const duration = parseDurationString(strDuration);\n const millis =\n // eslint-disable-next-line prettier/prettier\n ((duration.seconds ?? 0) +\n (duration.minutes ?? 0) * 60 +\n (duration.hours ?? 0) * 3600 +\n (duration.days ?? 0) * 86400 +\n (duration.weeks ?? 0) * 7 * 86400 +\n (duration.months ?? 0) * 30.436875 * 86400 + // avg month duration is ok for zoom purposes\n (duration.years ?? 0) * 365.2425 * 86400) * // avg year duration is ok for zoom purposes\n // eslint-disable-next-line prettier/prettier\n 1000; // to milliseconds\n return millis;\n };\n\n // Function to double current time range, adding 50% before current start and 50% after current end\n const doubleTimeRange = (): AbsoluteTimeRange => {\n let newStart, newEnd, extendEndsBy;\n const now = new Date();\n if (Object.hasOwn(timeRange, 'start')) {\n // current range is absolute\n const absVal = timeRange as AbsoluteTimeRange;\n extendEndsBy = (absVal.end.getTime() - absVal.start.getTime()) / 2; // half it to add 50% before current start and after current end\n newStart = new Date(absVal.start.getTime() - extendEndsBy);\n newEnd = new Date(absVal.end.getTime() + extendEndsBy);\n } else {\n // current range is relative\n const relVal = timeRange as RelativeTimeRange;\n extendEndsBy = fromDurationToMillis(relVal.pastDuration) / 2;\n newEnd = typeof relVal.end === 'undefined' ? now : new Date(relVal.end.getTime() + extendEndsBy);\n newStart = new Date(newEnd.getTime() - extendEndsBy * 4);\n }\n if (newEnd.getTime() > now.getTime()) {\n // if the new computed end is in the future\n newEnd = now;\n newStart.setTime(now.getTime() - extendEndsBy * 4);\n }\n if (newStart.getTime() < 1) {\n newStart.setTime(1);\n }\n return { start: newStart, end: newEnd };\n };\n\n // Function to half current time range, cutting 25% before current start and 25% after current end\n const halfTimeRange = (): AbsoluteTimeRange => {\n let newStart, newEnd;\n if (Object.hasOwn(timeRange, 'start')) {\n const absVal = timeRange as AbsoluteTimeRange;\n const shrinkEndsBy = (absVal.end.getTime() - absVal.start.getTime()) / 4;\n newStart = new Date(absVal.start.getTime() + shrinkEndsBy);\n newEnd = new Date(absVal.end.getTime() - shrinkEndsBy);\n } else {\n const relVal = timeRange as RelativeTimeRange;\n const shrinkEndsBy = fromDurationToMillis(relVal.pastDuration) / 4; // 25% of it to cut after current start and before current end\n const endIsAbsolute = typeof relVal.end !== 'undefined';\n newEnd = endIsAbsolute ? new Date(relVal.end!.getTime() - shrinkEndsBy) : new Date();\n newStart = new Date(newEnd.getTime() - shrinkEndsBy * 2);\n }\n if (newStart.getTime() >= newEnd.getTime() - 1000) {\n newStart.setTime(newEnd.getTime() - 1000);\n }\n return { start: newStart, end: newEnd };\n };\n\n const setHalfTimeRange = (): void => setTimeRange(halfTimeRange());\n const setDoubleTimeRange = (): void => setTimeRange(doubleTimeRange());\n\n return (\n <Stack direction=\"row\" spacing={1}>\n {showTimeRangeSelector && (\n <TimeRangeSelector\n timeOptions={timePresetsValue}\n value={timeRange}\n onChange={setTimeRange}\n height={height}\n showCustomTimeRange={showCustomTimeRangeValue}\n />\n )}\n {showZoomInOutButtons && (\n <InfoTooltip description={TOOLTIP_TEXT.zoomOut}>\n <ToolbarIconButton aria-label={TOOLTIP_TEXT.zoomOut} onClick={setDoubleTimeRange} sx={{ height }}>\n <ZoomOut />\n </ToolbarIconButton>\n </InfoTooltip>\n )}\n {showZoomInOutButtons && (\n <InfoTooltip description={TOOLTIP_TEXT.zoomIn}>\n <ToolbarIconButton aria-label={TOOLTIP_TEXT.zoomIn} onClick={setHalfTimeRange} sx={{ height }}>\n <ZoomIn />\n </ToolbarIconButton>\n </InfoTooltip>\n )}\n {showRefreshButton && (\n <InfoTooltip description={TOOLTIP_TEXT.refresh}>\n <ToolbarIconButton aria-label={TOOLTIP_TEXT.refresh} onClick={refresh} sx={{ height }}>\n <RefreshIcon />\n </ToolbarIconButton>\n </InfoTooltip>\n )}\n {showRefreshInterval && (\n <InfoTooltip description={TOOLTIP_TEXT.refreshInterval}>\n <RefreshIntervalPicker\n timeOptions={DEFAULT_REFRESH_INTERVAL_OPTIONS}\n value={refreshInterval}\n onChange={handleRefreshIntervalChange}\n height={height}\n />\n </InfoTooltip>\n )}\n </Stack>\n );\n}\n"],"names":["RefreshIcon","ZoomIn","ZoomOut","Stack","RefreshIntervalPicker","InfoTooltip","ToolbarIconButton","TimeRangeSelector","buildRelativeTimeOption","parseDurationString","useCallback","TOOLTIP_TEXT","useTimeRange","useShowCustomTimeRangeSetting","useTimeRangeOptionsSetting","useShowZoomRangeSetting","DEFAULT_REFRESH_INTERVAL_OPTIONS","value","pastDuration","display","DEFAULT_HEIGHT","TimeRangeControls","heightPx","showTimeRangeSelector","showRefreshButton","showRefreshInterval","showCustomTimeRange","showZoomButtons","timePresets","timeRange","setTimeRange","refresh","refreshInterval","setRefreshInterval","showCustomTimeRangeValue","showZoomInOutButtons","timePresetsValue","height","undefined","some","option","push","handleRefreshIntervalChange","duration","fromDurationToMillis","strDuration","millis","seconds","minutes","hours","days","weeks","months","years","doubleTimeRange","newStart","newEnd","extendEndsBy","now","Date","Object","hasOwn","absVal","end","getTime","start","relVal","setTime","halfTimeRange","shrinkEndsBy","endIsAbsolute","setHalfTimeRange","setDoubleTimeRange","direction","spacing","timeOptions","onChange","description","zoomOut","aria-label","onClick","sx","zoomIn"],"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,OAAOA,iBAAiB,0BAA0B;AAClD,gDAAgD;AAChD,OAAOC,YAAY,oCAAoC;AACvD,gDAAgD;AAChD,OAAOC,aAAa,qCAAqC;AACzD,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SACEC,qBAAqB,EACrBC,WAAW,EAEXC,iBAAiB,EACjBC,iBAAiB,EACjBC,uBAAuB,QAClB,yBAAyB;AAChC,SAA4CC,mBAAmB,QAA2B,mBAAmB;AAC7G,SAAuBC,WAAW,QAAQ,QAAQ;AAClD,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SACEC,YAAY,EACZC,6BAA6B,EAC7BC,0BAA0B,EAC1BC,uBAAuB,QAClB,gBAAgB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AYwE,aAAalE,aAAamE,OAAO;0BAC5C,cAAA,KAACxE;oBAAkByE,cAAYpE,aAAamE,OAAO;oBAAEE,SAASR;oBAAoBS,IAAI;wBAAE5C;oBAAO;8BAC7F,cAAA,KAACnC;;;YAINiC,sCACC,KAAC9B;gBAAYwE,aAAalE,aAAauE,MAAM;0BAC3C,cAAA,KAAC5E;oBAAkByE,cAAYpE,aAAauE,MAAM;oBAAEF,SAAST;oBAAkBU,IAAI;wBAAE5C;oBAAO;8BAC1F,cAAA,KAACpC;;;YAINuB,mCACC,KAACnB;gBAAYwE,aAAalE,aAAaoB,OAAO;0BAC5C,cAAA,KAACzB;oBAAkByE,cAAYpE,aAAaoB,OAAO;oBAAEiD,SAASjD;oBAASkD,IAAI;wBAAE5C;oBAAO;8BAClF,cAAA,KAACrC;;;YAINyB,qCACC,KAACpB;gBAAYwE,aAAalE,aAAaqB,eAAe;0BACpD,cAAA,KAAC5B;oBACCuE,aAAa3D;oBACbC,OAAOe;oBACP4C,UAAUlC;oBACVL,QAAQA;;;;;AAMpB"}
@@ -3,7 +3,6 @@ export declare const TOOLTIP_TEXT: {
3
3
  copyVariableValues: string;
4
4
  refresh: string;
5
5
  refreshInterval: string;
6
- timezone: string;
7
6
  zoomIn: string;
8
7
  zoomOut: string;
9
8
  };
@@ -1 +1 @@
1
- {"version":3,"file":"user-interface-text.d.ts","sourceRoot":"","sources":["../../src/constants/user-interface-text.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,YAAY;;;;;;;;CAUxB,CAAC"}
1
+ {"version":3,"file":"user-interface-text.d.ts","sourceRoot":"","sources":["../../src/constants/user-interface-text.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,YAAY;;;;;;;CASxB,CAAC"}
@@ -17,7 +17,6 @@ export const TOOLTIP_TEXT = {
17
17
  // Time range controls buttons
18
18
  refresh: 'Refresh',
19
19
  refreshInterval: 'Auto refresh interval',
20
- timezone: 'Timezone',
21
20
  zoomIn: 'Zoom in',
22
21
  zoomOut: 'Zoom out'
23
22
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/constants/user-interface-text.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\nexport const TOOLTIP_TEXT = {\n // Variable editor buttons\n refreshVariableValues: 'Refresh values',\n copyVariableValues: 'Copy values to clipboard',\n // Time range controls buttons\n refresh: 'Refresh',\n refreshInterval: 'Auto refresh interval',\n timezone: 'Timezone',\n zoomIn: 'Zoom in',\n zoomOut: 'Zoom out',\n};\n"],"names":["TOOLTIP_TEXT","refreshVariableValues","copyVariableValues","refresh","refreshInterval","timezone","zoomIn","zoomOut"],"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,OAAO,MAAMA,eAAe;IAC1B,0BAA0B;IAC1BC,uBAAuB;IACvBC,oBAAoB;IACpB,8BAA8B;IAC9BC,SAAS;IACTC,iBAAiB;IACjBC,UAAU;IACVC,QAAQ;IACRC,SAAS;AACX,EAAE"}
1
+ {"version":3,"sources":["../../src/constants/user-interface-text.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\nexport const TOOLTIP_TEXT = {\n // Variable editor buttons\n refreshVariableValues: 'Refresh values',\n copyVariableValues: 'Copy values to clipboard',\n // Time range controls buttons\n refresh: 'Refresh',\n refreshInterval: 'Auto refresh interval',\n zoomIn: 'Zoom in',\n zoomOut: 'Zoom out',\n};\n"],"names":["TOOLTIP_TEXT","refreshVariableValues","copyVariableValues","refresh","refreshInterval","zoomIn","zoomOut"],"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,OAAO,MAAMA,eAAe;IAC1B,0BAA0B;IAC1BC,uBAAuB;IACvBC,oBAAoB;IACpB,8BAA8B;IAC9BC,SAAS;IACTC,iBAAiB;IACjBC,QAAQ;IACRC,SAAS;AACX,EAAE"}
@@ -6,6 +6,10 @@ import { OptionsEditorProps, Plugin } from './plugin-base';
6
6
  export type PanelOptionsEditorComponent<T> = Pick<OptionsEditorTab, 'label'> & {
7
7
  content: React.ComponentType<OptionsEditorProps<T>>;
8
8
  };
9
+ export type PanelAction<TPanelProps> = {
10
+ component: React.ComponentType<TPanelProps>;
11
+ location?: string;
12
+ };
9
13
  /**
10
14
  * Plugin the provides custom visualizations inside a Panel.
11
15
  */
@@ -36,6 +40,10 @@ export interface PanelPlugin<Spec = UnknownSpec, TPanelProps = PanelProps<Spec>>
36
40
  * @default false
37
41
  */
38
42
  hideQueryEditor?: boolean;
43
+ /**
44
+ * List of panel actions that will be rendered in the panel header
45
+ */
46
+ actions?: Array<PanelAction<TPanelProps>>;
39
47
  }
40
48
  /**
41
49
  * The props provided by Perses to a panel plugin's PanelComponent.
@@ -1 +1 @@
1
- {"version":3,"file":"panels.d.ts","sourceRoot":"","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,4BAA4B,CAAC,EAAE,KAAK,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC,CAAC;IACxE;;;OAGG;IACH,gBAAgB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;IACpD;;;OAGG;IACH,mBAAmB,CAAC,EAAE,eAAe,EAAE,CAAC;IACxC;;;;OAIG;IACH,YAAY,CAAC,EAAE,YAAY,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,KAAK,YAAY,CAAC,CAAC;IAC7D;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAG1B;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC;CAE3C;AAED;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,IAAI,EAAE,mBAAmB,GAAG,aAAa;IACnE,IAAI,EAAE,IAAI,CAAC;IACX,iBAAiB,CAAC,EAAE;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC,CAAC;CACrD;AAED,MAAM,WAAW,SAAS,CAAC,mBAAmB,GAAG,aAAa;IAC5D,UAAU,EAAE,eAAe,CAAC;IAC5B,IAAI,EAAE,mBAAmB,CAAC;CAC3B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/panels.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 React from 'react';\nimport { UnknownSpec, PanelDefinition, QueryPluginType, QueryDataType, QueryDefinition } from '@perses-dev/core';\nimport { OptionsEditorTab } from '../components';\nimport { QueryOptions } from '../runtime';\nimport { OptionsEditorProps, Plugin } from './plugin-base';\n\nexport type PanelOptionsEditorComponent<T> = Pick<OptionsEditorTab, 'label'> & {\n content: React.ComponentType<OptionsEditorProps<T>>;\n};\n\n/**\n * Plugin the provides custom visualizations inside a Panel.\n */\nexport interface PanelPlugin<Spec = UnknownSpec, TPanelProps = PanelProps<Spec>> extends Plugin<Spec> {\n PanelComponent: React.ComponentType<TPanelProps>;\n /**\n * React components for custom tabs\n */\n panelOptionsEditorComponents?: Array<PanelOptionsEditorComponent<Spec>>;\n /**\n * Show a custom React component when the query is loading.\n * Default: <LoadingOverlay />\n */\n LoadingComponent?: React.ComponentType<TPanelProps>;\n /**\n * List of query types supported by this panel.\n * @default [] (no query types supported) only relevant if hideQueryEditor is true\n */\n supportedQueryTypes?: QueryPluginType[];\n /**\n * Static options for the queries that will be executed.\n * Each {@link QueryPluginType} implementation can have its own options.\n * For example see {@link UseTimeSeriesQueryOptions} for time series queries.\n */\n queryOptions?: QueryOptions | ((spec: Spec) => QueryOptions);\n /**\n * If true, query editor will be hidden for panel plugin\n * @default false\n */\n hideQueryEditor?: boolean;\n}\n\n/**\n * The props provided by Perses to a panel plugin's PanelComponent.\n */\nexport interface PanelProps<Spec, SupportedQueryTypes = QueryDataType> {\n spec: Spec;\n contentDimensions?: {\n width: number;\n height: number;\n };\n definition?: PanelDefinition;\n queryResults: Array<PanelData<SupportedQueryTypes>>;\n}\n\nexport interface PanelData<SupportedQueryTypes = QueryDataType> {\n definition: QueryDefinition;\n data: SupportedQueryTypes;\n}\n"],"names":["React"],"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,OAAOA,WAAW,QAAQ"}
1
+ {"version":3,"sources":["../../src/model/panels.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 React from 'react';\nimport { UnknownSpec, PanelDefinition, QueryPluginType, QueryDataType, QueryDefinition } from '@perses-dev/core';\nimport { OptionsEditorTab } from '../components';\nimport { QueryOptions } from '../runtime';\nimport { OptionsEditorProps, Plugin } from './plugin-base';\n\nexport type PanelOptionsEditorComponent<T> = Pick<OptionsEditorTab, 'label'> & {\n content: React.ComponentType<OptionsEditorProps<T>>;\n};\n\nexport type PanelAction<TPanelProps> = {\n component: React.ComponentType<TPanelProps>; // Self-contained component with onClick handler\n location?: string; // 'header' or other available locations\n};\n\n/**\n * Plugin the provides custom visualizations inside a Panel.\n */\nexport interface PanelPlugin<Spec = UnknownSpec, TPanelProps = PanelProps<Spec>> extends Plugin<Spec> {\n PanelComponent: React.ComponentType<TPanelProps>;\n /**\n * React components for custom tabs\n */\n panelOptionsEditorComponents?: Array<PanelOptionsEditorComponent<Spec>>;\n /**\n * Show a custom React component when the query is loading.\n * Default: <LoadingOverlay />\n */\n LoadingComponent?: React.ComponentType<TPanelProps>;\n /**\n * List of query types supported by this panel.\n * @default [] (no query types supported) only relevant if hideQueryEditor is true\n */\n supportedQueryTypes?: QueryPluginType[];\n /**\n * Static options for the queries that will be executed.\n * Each {@link QueryPluginType} implementation can have its own options.\n * For example see {@link UseTimeSeriesQueryOptions} for time series queries.\n */\n queryOptions?: QueryOptions | ((spec: Spec) => QueryOptions);\n /**\n * If true, query editor will be hidden for panel plugin\n * @default false\n */\n hideQueryEditor?: boolean;\n\n // ========== ADDED: Actions array ==========\n /**\n * List of panel actions that will be rendered in the panel header\n */\n actions?: Array<PanelAction<TPanelProps>>;\n // ========================================\n}\n\n/**\n * The props provided by Perses to a panel plugin's PanelComponent.\n */\nexport interface PanelProps<Spec, SupportedQueryTypes = QueryDataType> {\n spec: Spec;\n contentDimensions?: {\n width: number;\n height: number;\n };\n definition?: PanelDefinition;\n queryResults: Array<PanelData<SupportedQueryTypes>>;\n}\n\nexport interface PanelData<SupportedQueryTypes = QueryDataType> {\n definition: QueryDefinition;\n data: SupportedQueryTypes;\n}\n"],"names":["React"],"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,OAAOA,WAAW,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"PluginRuntime.d.ts","sourceRoot":"","sources":["../../src/remote/PluginRuntime.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,cAAc,EAAoB,MAAM,qCAAqC,CAAC;AAMvF,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AA4LxE,eAAO,MAAM,UAAU,eACT,MAAM,cACN,MAAM,YACR,MAAM,KACf,QAAQ,kBAAkB,GAAG,IAAI,CAInC,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,GAAG;IACtE,aAAa,EAAE,cAAc,CAAC;IAC9B,UAAU,EAAE,MAAM,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAC;CACtD,CAKA"}
1
+ {"version":3,"file":"PluginRuntime.d.ts","sourceRoot":"","sources":["../../src/remote/PluginRuntime.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,cAAc,EAAoB,MAAM,qCAAqC,CAAC;AAMvF,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAoMxE,eAAO,MAAM,UAAU,eACT,MAAM,cACN,MAAM,YACR,MAAM,KACf,QAAQ,kBAAkB,GAAG,IAAI,CAInC,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,GAAG;IACtE,aAAa,EAAE,cAAc,CAAC;IAC9B,UAAU,EAAE,MAAM,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAC;CACtD,CAKA"}
@@ -71,36 +71,44 @@ const getPluginRuntime = ()=>{
71
71
  requiredVersion: '^5.5.0'
72
72
  }
73
73
  },
74
+ '@perses-dev/core': {
75
+ version: '0.51.0-rc.1',
76
+ lib: ()=>require('@perses-dev/core'),
77
+ shareConfig: {
78
+ singleton: true,
79
+ requiredVersion: '^0.51.0-rc.1'
80
+ }
81
+ },
74
82
  '@perses-dev/components': {
75
- version: '0.51.0-beta.0',
83
+ version: '0.51.0-rc.1',
76
84
  lib: ()=>require('@perses-dev/components'),
77
85
  shareConfig: {
78
86
  singleton: true,
79
- requiredVersion: '^0.51.0-rc.0'
87
+ requiredVersion: '^0.51.0-rc.1'
80
88
  }
81
89
  },
82
90
  '@perses-dev/plugin-system': {
83
- version: '0.51.0-beta.0',
91
+ version: '0.51.0-rc.1',
84
92
  lib: ()=>require('@perses-dev/plugin-system'),
85
93
  shareConfig: {
86
94
  singleton: true,
87
- requiredVersion: '^0.51.0-rc.0'
95
+ requiredVersion: '^0.51.0-rc.1'
88
96
  }
89
97
  },
90
98
  '@perses-dev/explore': {
91
- version: '0.51.0-beta.0',
99
+ version: '0.51.0-rc.1',
92
100
  lib: ()=>require('@perses-dev/explore'),
93
101
  shareConfig: {
94
102
  singleton: true,
95
- requiredVersion: '^0.51.0-rc.0'
103
+ requiredVersion: '^0.51.0-rc.1'
96
104
  }
97
105
  },
98
106
  '@perses-dev/dashboards': {
99
- version: '0.51.0-beta.0',
107
+ version: '0.51.0-rc.1',
100
108
  lib: ()=>require('@perses-dev/dashboards'),
101
109
  shareConfig: {
102
110
  singleton: true,
103
- requiredVersion: '^0.51.0-rc.0'
111
+ requiredVersion: '^0.51.0-rc.1'
104
112
  }
105
113
  },
106
114
  // Below are the shared modules that are used by the plugins, this can be part of the SDK
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/remote/PluginRuntime.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-require-imports */\n// Copyright 2024 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 { FederationHost, init, loadRemote } from '@module-federation/enhanced/runtime';\nimport * as ReactQuery from '@tanstack/react-query';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport * as ReactHookForm from 'react-hook-form';\nimport * as ReactRouterDOM from 'react-router-dom';\nimport { PersesPlugin, RemotePluginModule } from './PersesPlugin.types';\n\nlet instance: FederationHost | null = null;\n\nconst getPluginRuntime = (): FederationHost => {\n if (instance === null) {\n const pluginRuntime = init({\n name: '@perses/perses-ui-host',\n remotes: [], // all remotes are loaded dynamically\n shared: {\n react: {\n version: React.version,\n lib: () => React,\n shareConfig: {\n singleton: true,\n requiredVersion: `^${React.version}`,\n },\n },\n 'react-dom': {\n version: '18.3.1',\n lib: () => ReactDOM,\n shareConfig: {\n singleton: true,\n requiredVersion: `^18.3.1`,\n },\n },\n 'react-router-dom': {\n version: '6.26.0',\n lib: () => ReactRouterDOM,\n shareConfig: {\n singleton: true,\n requiredVersion: '^6.26.0',\n },\n },\n '@tanstack/react-query': {\n version: '4.39.1',\n lib: () => ReactQuery,\n shareConfig: {\n singleton: true,\n requiredVersion: '^4.39.1',\n },\n },\n 'react-hook-form': {\n version: '7.52.2',\n lib: () => ReactHookForm,\n shareConfig: {\n singleton: true,\n requiredVersion: '^7.52.2',\n },\n },\n echarts: {\n version: '5.5.0',\n lib: () => require('echarts'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^5.5.0',\n },\n },\n '@perses-dev/components': {\n version: '0.51.0-beta.0',\n lib: () => require('@perses-dev/components'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^0.51.0-rc.0',\n },\n },\n '@perses-dev/plugin-system': {\n version: '0.51.0-beta.0',\n lib: () => require('@perses-dev/plugin-system'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^0.51.0-rc.0',\n },\n },\n '@perses-dev/explore': {\n version: '0.51.0-beta.0',\n lib: () => require('@perses-dev/explore'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^0.51.0-rc.0',\n },\n },\n '@perses-dev/dashboards': {\n version: '0.51.0-beta.0',\n lib: () => require('@perses-dev/dashboards'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^0.51.0-rc.0',\n },\n },\n // Below are the shared modules that are used by the plugins, this can be part of the SDK\n 'date-fns': {\n version: '4.1.0',\n lib: () => require('date-fns'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^4.1.0',\n },\n },\n 'date-fns-tz': {\n version: '3.2.0',\n lib: () => require('date-fns-tz'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^3.2.0',\n },\n },\n lodash: {\n version: '4.17.21',\n lib: () => require('lodash'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^4.17.21',\n },\n },\n '@emotion/react': {\n version: '11.11.3',\n lib: () => require('@emotion/react'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^11.11.3',\n },\n },\n '@emotion/styled': {\n version: '11.11.0',\n lib: () => require('@emotion/styled'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^11.11.0',\n },\n },\n '@hookform/resolvers/zod': {\n version: '3.3.4',\n lib: () => require('@hookform/resolvers/zod'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^3.3.4',\n },\n },\n 'use-resize-observer': {\n version: '9.1.0',\n lib: () => require('use-resize-observer'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^9.1.0',\n },\n },\n 'mdi-material-ui': {\n version: '7.4.0',\n lib: () => require('mdi-material-ui'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^7.4.0',\n },\n },\n immer: {\n version: '10.1.1',\n lib: () => require('immer'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^10.1.1',\n },\n },\n },\n });\n\n instance = pluginRuntime;\n\n return instance;\n }\n return instance;\n};\n\nconst registerRemote = (name: string, baseURL?: string): void => {\n const pluginRuntime = getPluginRuntime();\n const existingRemote = pluginRuntime.options.remotes.find((remote) => remote.name === name);\n if (!existingRemote) {\n const remoteEntryURL = baseURL ? `${baseURL}/${name}/mf-manifest.json` : `/plugins/${name}/mf-manifest.json`;\n pluginRuntime.registerRemotes([\n {\n name,\n entry: remoteEntryURL,\n alias: name,\n },\n ]);\n }\n};\n\nexport const loadPlugin = async (\n moduleName: string,\n pluginName: string,\n baseURL?: string\n): Promise<RemotePluginModule | null> => {\n registerRemote(moduleName, baseURL);\n\n return loadRemote<RemotePluginModule>(`${moduleName}/${pluginName}`);\n};\n\nexport function usePluginRuntime({ plugin }: { plugin: PersesPlugin }): {\n pluginRuntime: FederationHost;\n loadPlugin: () => Promise<RemotePluginModule | null>;\n} {\n return {\n pluginRuntime: getPluginRuntime(),\n loadPlugin: () => loadPlugin(plugin.moduleName, plugin.name, plugin.baseURL),\n };\n}\n"],"names":["init","loadRemote","ReactQuery","React","ReactDOM","ReactHookForm","ReactRouterDOM","instance","getPluginRuntime","pluginRuntime","name","remotes","shared","react","version","lib","shareConfig","singleton","requiredVersion","echarts","require","lodash","immer","registerRemote","baseURL","existingRemote","options","find","remote","remoteEntryURL","registerRemotes","entry","alias","loadPlugin","moduleName","pluginName","usePluginRuntime","plugin"],"mappings":"AAAA,wDAAwD,GACxD,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAAyBA,IAAI,EAAEC,UAAU,QAAQ,sCAAsC;AACvF,YAAYC,gBAAgB,wBAAwB;AACpD,OAAOC,WAAW,QAAQ;AAC1B,OAAOC,cAAc,YAAY;AACjC,YAAYC,mBAAmB,kBAAkB;AACjD,YAAYC,oBAAoB,mBAAmB;AAGnD,IAAIC,WAAkC;AAEtC,MAAMC,mBAAmB;IACvB,IAAID,aAAa,MAAM;QACrB,MAAME,gBAAgBT,KAAK;YACzBU,MAAM;YACNC,SAAS,EAAE;YACXC,QAAQ;gBACNC,OAAO;oBACLC,SAASX,MAAMW,OAAO;oBACtBC,KAAK,IAAMZ;oBACXa,aAAa;wBACXC,WAAW;wBACXC,iBAAiB,CAAC,CAAC,EAAEf,MAAMW,OAAO,EAAE;oBACtC;gBACF;gBACA,aAAa;oBACXA,SAAS;oBACTC,KAAK,IAAMX;oBACXY,aAAa;wBACXC,WAAW;wBACXC,iBAAiB,CAAC,OAAO,CAAC;oBAC5B;gBACF;gBACA,oBAAoB;oBAClBJ,SAAS;oBACTC,KAAK,IAAMT;oBACXU,aAAa;wBACXC,WAAW;wBACXC,iBAAiB;oBACnB;gBACF;gBACA,yBAAyB;oBACvBJ,SAAS;oBACTC,KAAK,IAAMb;oBACXc,aAAa;wBACXC,WAAW;wBACXC,iBAAiB;oBACnB;gBACF;gBACA,mBAAmB;oBACjBJ,SAAS;oBACTC,KAAK,IAAMV;oBACXW,aAAa;wBACXC,WAAW;wBACXC,iBAAiB;oBACnB;gBACF;gBACAC,SAAS;oBACPL,SAAS;oBACTC,KAAK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ACF;gBACA,uBAAuB;oBACrBJ,SAAS;oBACTC,KAAK,IAAMK,QAAQ;oBACnBJ,aAAa;wBACXC,WAAW;wBACXC,iBAAiB;oBACnB;gBACF;gBACA,mBAAmB;oBACjBJ,SAAS;oBACTC,KAAK,IAAMK,QAAQ;oBACnBJ,aAAa;wBACXC,WAAW;wBACXC,iBAAiB;oBACnB;gBACF;gBACAI,OAAO;oBACLR,SAAS;oBACTC,KAAK,IAAMK,QAAQ;oBACnBJ,aAAa;wBACXC,WAAW;wBACXC,iBAAiB;oBACnB;gBACF;YACF;QACF;QAEAX,WAAWE;QAEX,OAAOF;IACT;IACA,OAAOA;AACT;AAEA,MAAMgB,iBAAiB,CAACb,MAAcc;IACpC,MAAMf,gBAAgBD;IACtB,MAAMiB,iBAAiBhB,cAAciB,OAAO,CAACf,OAAO,CAACgB,IAAI,CAAC,CAACC,SAAWA,OAAOlB,IAAI,KAAKA;IACtF,IAAI,CAACe,gBAAgB;QACnB,MAAMI,iBAAiBL,UAAU,GAAGA,QAAQ,CAAC,EAAEd,KAAK,iBAAiB,CAAC,GAAG,CAAC,SAAS,EAAEA,KAAK,iBAAiB,CAAC;QAC5GD,cAAcqB,eAAe,CAAC;YAC5B;gBACEpB;gBACAqB,OAAOF;gBACPG,OAAOtB;YACT;SACD;IACH;AACF;AAEA,OAAO,MAAMuB,aAAa,OACxBC,YACAC,YACAX;IAEAD,eAAeW,YAAYV;IAE3B,OAAOvB,WAA+B,GAAGiC,WAAW,CAAC,EAAEC,YAAY;AACrE,EAAE;AAEF,OAAO,SAASC,iBAAiB,EAAEC,MAAM,EAA4B;IAInE,OAAO;QACL5B,eAAeD;QACfyB,YAAY,IAAMA,WAAWI,OAAOH,UAAU,EAAEG,OAAO3B,IAAI,EAAE2B,OAAOb,OAAO;IAC7E;AACF"}
1
+ {"version":3,"sources":["../../src/remote/PluginRuntime.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-require-imports */\n// Copyright 2024 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 { FederationHost, init, loadRemote } from '@module-federation/enhanced/runtime';\nimport * as ReactQuery from '@tanstack/react-query';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport * as ReactHookForm from 'react-hook-form';\nimport * as ReactRouterDOM from 'react-router-dom';\nimport { PersesPlugin, RemotePluginModule } from './PersesPlugin.types';\n\nlet instance: FederationHost | null = null;\n\nconst getPluginRuntime = (): FederationHost => {\n if (instance === null) {\n const pluginRuntime = init({\n name: '@perses/perses-ui-host',\n remotes: [], // all remotes are loaded dynamically\n shared: {\n react: {\n version: React.version,\n lib: () => React,\n shareConfig: {\n singleton: true,\n requiredVersion: `^${React.version}`,\n },\n },\n 'react-dom': {\n version: '18.3.1',\n lib: () => ReactDOM,\n shareConfig: {\n singleton: true,\n requiredVersion: `^18.3.1`,\n },\n },\n 'react-router-dom': {\n version: '6.26.0',\n lib: () => ReactRouterDOM,\n shareConfig: {\n singleton: true,\n requiredVersion: '^6.26.0',\n },\n },\n '@tanstack/react-query': {\n version: '4.39.1',\n lib: () => ReactQuery,\n shareConfig: {\n singleton: true,\n requiredVersion: '^4.39.1',\n },\n },\n 'react-hook-form': {\n version: '7.52.2',\n lib: () => ReactHookForm,\n shareConfig: {\n singleton: true,\n requiredVersion: '^7.52.2',\n },\n },\n echarts: {\n version: '5.5.0',\n lib: () => require('echarts'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^5.5.0',\n },\n },\n '@perses-dev/core': {\n version: '0.51.0-rc.1',\n lib: () => require('@perses-dev/core'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^0.51.0-rc.1',\n },\n },\n '@perses-dev/components': {\n version: '0.51.0-rc.1',\n lib: () => require('@perses-dev/components'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^0.51.0-rc.1',\n },\n },\n '@perses-dev/plugin-system': {\n version: '0.51.0-rc.1',\n lib: () => require('@perses-dev/plugin-system'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^0.51.0-rc.1',\n },\n },\n '@perses-dev/explore': {\n version: '0.51.0-rc.1',\n lib: () => require('@perses-dev/explore'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^0.51.0-rc.1',\n },\n },\n '@perses-dev/dashboards': {\n version: '0.51.0-rc.1',\n lib: () => require('@perses-dev/dashboards'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^0.51.0-rc.1',\n },\n },\n // Below are the shared modules that are used by the plugins, this can be part of the SDK\n 'date-fns': {\n version: '4.1.0',\n lib: () => require('date-fns'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^4.1.0',\n },\n },\n 'date-fns-tz': {\n version: '3.2.0',\n lib: () => require('date-fns-tz'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^3.2.0',\n },\n },\n lodash: {\n version: '4.17.21',\n lib: () => require('lodash'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^4.17.21',\n },\n },\n '@emotion/react': {\n version: '11.11.3',\n lib: () => require('@emotion/react'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^11.11.3',\n },\n },\n '@emotion/styled': {\n version: '11.11.0',\n lib: () => require('@emotion/styled'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^11.11.0',\n },\n },\n '@hookform/resolvers/zod': {\n version: '3.3.4',\n lib: () => require('@hookform/resolvers/zod'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^3.3.4',\n },\n },\n 'use-resize-observer': {\n version: '9.1.0',\n lib: () => require('use-resize-observer'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^9.1.0',\n },\n },\n 'mdi-material-ui': {\n version: '7.4.0',\n lib: () => require('mdi-material-ui'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^7.4.0',\n },\n },\n immer: {\n version: '10.1.1',\n lib: () => require('immer'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^10.1.1',\n },\n },\n },\n });\n\n instance = pluginRuntime;\n\n return instance;\n }\n return instance;\n};\n\nconst registerRemote = (name: string, baseURL?: string): void => {\n const pluginRuntime = getPluginRuntime();\n const existingRemote = pluginRuntime.options.remotes.find((remote) => remote.name === name);\n if (!existingRemote) {\n const remoteEntryURL = baseURL ? `${baseURL}/${name}/mf-manifest.json` : `/plugins/${name}/mf-manifest.json`;\n pluginRuntime.registerRemotes([\n {\n name,\n entry: remoteEntryURL,\n alias: name,\n },\n ]);\n }\n};\n\nexport const loadPlugin = async (\n moduleName: string,\n pluginName: string,\n baseURL?: string\n): Promise<RemotePluginModule | null> => {\n registerRemote(moduleName, baseURL);\n\n return loadRemote<RemotePluginModule>(`${moduleName}/${pluginName}`);\n};\n\nexport function usePluginRuntime({ plugin }: { plugin: PersesPlugin }): {\n pluginRuntime: FederationHost;\n loadPlugin: () => Promise<RemotePluginModule | null>;\n} {\n return {\n pluginRuntime: getPluginRuntime(),\n loadPlugin: () => loadPlugin(plugin.moduleName, plugin.name, plugin.baseURL),\n };\n}\n"],"names":["init","loadRemote","ReactQuery","React","ReactDOM","ReactHookForm","ReactRouterDOM","instance","getPluginRuntime","pluginRuntime","name","remotes","shared","react","version","lib","shareConfig","singleton","requiredVersion","echarts","require","lodash","immer","registerRemote","baseURL","existingRemote","options","find","remote","remoteEntryURL","registerRemotes","entry","alias","loadPlugin","moduleName","pluginName","usePluginRuntime","plugin"],"mappings":"AAAA,wDAAwD,GACxD,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAAyBA,IAAI,EAAEC,UAA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BJ,aAAa;wBACXC,WAAW;wBACXC,iBAAiB;oBACnB;gBACF;gBACAI,OAAO;oBACLR,SAAS;oBACTC,KAAK,IAAMK,QAAQ;oBACnBJ,aAAa;wBACXC,WAAW;wBACXC,iBAAiB;oBACnB;gBACF;YACF;QACF;QAEAX,WAAWE;QAEX,OAAOF;IACT;IACA,OAAOA;AACT;AAEA,MAAMgB,iBAAiB,CAACb,MAAcc;IACpC,MAAMf,gBAAgBD;IACtB,MAAMiB,iBAAiBhB,cAAciB,OAAO,CAACf,OAAO,CAACgB,IAAI,CAAC,CAACC,SAAWA,OAAOlB,IAAI,KAAKA;IACtF,IAAI,CAACe,gBAAgB;QACnB,MAAMI,iBAAiBL,UAAU,GAAGA,QAAQ,CAAC,EAAEd,KAAK,iBAAiB,CAAC,GAAG,CAAC,SAAS,EAAEA,KAAK,iBAAiB,CAAC;QAC5GD,cAAcqB,eAAe,CAAC;YAC5B;gBACEpB;gBACAqB,OAAOF;gBACPG,OAAOtB;YACT;SACD;IACH;AACF;AAEA,OAAO,MAAMuB,aAAa,OACxBC,YACAC,YACAX;IAEAD,eAAeW,YAAYV;IAE3B,OAAOvB,WAA+B,GAAGiC,WAAW,CAAC,EAAEC,YAAY;AACrE,EAAE;AAEF,OAAO,SAASC,iBAAiB,EAAEC,MAAM,EAA4B;IAInE,OAAO;QACL5B,eAAeD;QACfyB,YAAY,IAAMA,WAAWI,OAAOH,UAAU,EAAEG,OAAO3B,IAAI,EAAE2B,OAAOb,OAAO;IAC7E;AACF"}
@@ -5,8 +5,6 @@ export interface TimeRangeProviderProps {
5
5
  refreshInterval?: DurationString;
6
6
  setTimeRange?: (value: TimeRangeValue) => void;
7
7
  setRefreshInterval?: (value: DurationString) => void;
8
- timeZone?: string;
9
- setTimeZone?: (timeZone: string) => void;
10
8
  children?: React.ReactNode;
11
9
  }
12
10
  export interface TimeRange {
@@ -18,8 +16,6 @@ export interface TimeRange {
18
16
  refreshInterval?: DurationString;
19
17
  refreshIntervalInMs: number;
20
18
  setRefreshInterval: (value: DurationString) => void;
21
- timeZone: string;
22
- setTimeZone: (timeZone: string) => void;
23
19
  }
24
20
  export declare const TimeRangeContext: React.Context<TimeRange | undefined>;
25
21
  export declare function useTimeRangeContext(): TimeRange;
@@ -27,13 +23,6 @@ export declare function useTimeRangeContext(): TimeRange;
27
23
  * Get and set the current resolved time range at runtime.
28
24
  */
29
25
  export declare function useTimeRange(): TimeRange;
30
- interface TimeZone {
31
- timeZone: string;
32
- setTimeZone: (timeZone: string) => void;
33
- formatWithUserTimeZone: (date: Date, formatString: string) => string;
34
- dateFormatOptionsWithUserTimeZone: (dateFormatOptions: Intl.DateTimeFormatOptions) => Intl.DateTimeFormatOptions;
35
- }
36
- export declare function useTimeZone(): TimeZone;
37
26
  /**
38
27
  * Gets the suggested step for a graph query in ms for the currently selected time range.
39
28
  */
@@ -42,5 +31,4 @@ export declare function useSuggestedStepMs(width?: number): number;
42
31
  * Provider implementation that supplies the time range state at runtime.
43
32
  */
44
33
  export declare function TimeRangeProvider(props: TimeRangeProviderProps): ReactElement;
45
- export {};
46
34
  //# sourceMappingURL=TimeRangeProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TimeRangeProvider.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,EAAiB,YAAY,EAAyD,MAAM,OAAO,CAAC;AAClH,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,cAAc,EAKf,MAAM,kBAAkB,CAAC;AAI1B,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,cAAc,CAAC;IAC1B,eAAe,CAAC,EAAE,cAAc,CAAC;IACjC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC/C,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC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Provider.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,EAAiB,YAAY,EAAyD,MAAM,OAAO,CAAC;AAClH,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,cAAc,EAIf,MAAM,kBAAkB,CAAC;AAG1B,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,cAAc,CAAC;IAC1B,eAAe,CAAC,EAAE,cAAc,CAAC;IACjC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC/C,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IACrD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,cAAc,CAAC;IAC1B,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,YAAY,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC9C,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,cAAc,CAAC;IACjC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kBAAkB,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;CACrD;AAED,eAAO,MAAM,gBAAgB,sCAAkD,CAAC;AAEhF,wBAAgB,mBAAmB,IAAI,SAAS,CAM/C;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,SAAS,CAExC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAIzD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,GAAG,YAAY,CAwD7E"}
@@ -12,8 +12,7 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
15
- import { isRelativeTimeRange, toAbsoluteTimeRange, getSuggestedStepMs, DEFAULT_DASHBOARD_TIMEZONE } from '@perses-dev/core';
16
- import { dateFormatOptionsWithTimeZone, formatWithTimeZone } from '@perses-dev/components';
15
+ import { isRelativeTimeRange, toAbsoluteTimeRange, getSuggestedStepMs } from '@perses-dev/core';
17
16
  import { getRefreshIntervalInMs } from './refresh-interval';
18
17
  export const TimeRangeContext = /*#__PURE__*/ createContext(undefined);
19
18
  export function useTimeRangeContext() {
@@ -28,19 +27,6 @@ export function useTimeRangeContext() {
28
27
  */ export function useTimeRange() {
29
28
  return useTimeRangeContext();
30
29
  }
31
- export function useTimeZone() {
32
- const { timeZone, setTimeZone } = useTimeRangeContext();
33
- return {
34
- timeZone,
35
- setTimeZone,
36
- formatWithUserTimeZone: (date, formatString)=>{
37
- return formatWithTimeZone(date, formatString, timeZone);
38
- },
39
- dateFormatOptionsWithUserTimeZone: (dateFormatOptions)=>{
40
- return dateFormatOptionsWithTimeZone(dateFormatOptions, timeZone);
41
- }
42
- };
43
- }
44
30
  /**
45
31
  * Gets the suggested step for a graph query in ms for the currently selected time range.
46
32
  */ export function useSuggestedStepMs(width) {
@@ -51,10 +37,9 @@ export function useTimeZone() {
51
37
  /**
52
38
  * Provider implementation that supplies the time range state at runtime.
53
39
  */ export function TimeRangeProvider(props) {
54
- const { timeRange, refreshInterval, children, setTimeRange, setRefreshInterval, timeZone = DEFAULT_DASHBOARD_TIMEZONE, setTimeZone } = props;
40
+ const { timeRange, refreshInterval, children, setTimeRange, setRefreshInterval } = props;
55
41
  const [localTimeRange, setLocalTimeRange] = useState(timeRange);
56
42
  const [localRefreshInterval, setLocalRefreshInterval] = useState(refreshInterval);
57
- const [localTimeZone, setLocalTimeZone] = useState(timeZone);
58
43
  const [refreshCounter, setRefreshCounter] = useState(0);
59
44
  useEffect(()=>{
60
45
  setLocalTimeRange(timeRange);
@@ -67,11 +52,6 @@ export function useTimeZone() {
67
52
  }, [
68
53
  refreshInterval
69
54
  ]);
70
- useEffect(()=>{
71
- setLocalTimeZone(timeZone);
72
- }, [
73
- timeZone
74
- ]);
75
55
  const refresh = useCallback(()=>{
76
56
  setRefreshCounter((counter)=>counter + 1);
77
57
  }, [
@@ -93,26 +73,22 @@ export function useTimeZone() {
93
73
  const absoluteTimeRange = isRelativeTimeRange(localTimeRange) ? toAbsoluteTimeRange(localTimeRange) : localTimeRange;
94
74
  return {
95
75
  timeRange: localTimeRange,
96
- timeZone: localTimeZone,
97
76
  setTimeRange: setTimeRange ?? setLocalTimeRange,
98
77
  absoluteTimeRange,
99
78
  refresh,
100
79
  refreshKey: `${absoluteTimeRange.start}:${absoluteTimeRange.end}:${localRefreshInterval}:${refreshCounter}`,
101
80
  refreshInterval: localRefreshInterval,
102
81
  refreshIntervalInMs: refreshIntervalInMs,
103
- setRefreshInterval: setRefreshInterval ?? setLocalRefreshInterval,
104
- setTimeZone: setTimeZone ?? setLocalTimeZone
82
+ setRefreshInterval: setRefreshInterval ?? setLocalRefreshInterval
105
83
  };
106
84
  }, [
107
85
  localTimeRange,
108
- localTimeZone,
109
86
  setTimeRange,
110
87
  refresh,
111
88
  localRefreshInterval,
112
89
  refreshCounter,
113
90
  refreshIntervalInMs,
114
- setRefreshInterval,
115
- setTimeZone
91
+ setRefreshInterval
116
92
  ]);
117
93
  return /*#__PURE__*/ _jsx(TimeRangeContext.Provider, {
118
94
  value: ctx,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.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 React, { createContext, ReactElement, useCallback, useContext, useEffect, useMemo, useState } from 'react';\nimport {\n AbsoluteTimeRange,\n DurationString,\n TimeRangeValue,\n isRelativeTimeRange,\n toAbsoluteTimeRange,\n getSuggestedStepMs,\n DEFAULT_DASHBOARD_TIMEZONE,\n} from '@perses-dev/core';\nimport { dateFormatOptionsWithTimeZone, formatWithTimeZone } from '@perses-dev/components';\nimport { getRefreshIntervalInMs } from './refresh-interval';\n\nexport interface TimeRangeProviderProps {\n timeRange: TimeRangeValue;\n refreshInterval?: DurationString;\n setTimeRange?: (value: TimeRangeValue) => void;\n setRefreshInterval?: (value: DurationString) => void;\n timeZone?: string;\n setTimeZone?: (timeZone: string) => void;\n children?: React.ReactNode;\n}\n\nexport interface TimeRange {\n timeRange: TimeRangeValue;\n absoluteTimeRange: AbsoluteTimeRange; // resolved absolute time for plugins to use\n setTimeRange: (value: TimeRangeValue) => void;\n refresh: () => void;\n refreshKey: string;\n refreshInterval?: DurationString;\n refreshIntervalInMs: number;\n setRefreshInterval: (value: DurationString) => void;\n timeZone: string;\n setTimeZone: (timeZone: string) => void;\n}\n\nexport const TimeRangeContext = createContext<TimeRange | undefined>(undefined);\n\nexport function useTimeRangeContext(): TimeRange {\n const ctx = useContext(TimeRangeContext);\n if (ctx === undefined) {\n throw new Error('No TimeRangeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\n/**\n * Get and set the current resolved time range at runtime.\n */\nexport function useTimeRange(): TimeRange {\n return useTimeRangeContext();\n}\n\ninterface TimeZone {\n timeZone: string;\n setTimeZone: (timeZone: string) => void;\n formatWithUserTimeZone: (date: Date, formatString: string) => string;\n dateFormatOptionsWithUserTimeZone: (dateFormatOptions: Intl.DateTimeFormatOptions) => Intl.DateTimeFormatOptions;\n}\n\nexport function useTimeZone(): TimeZone {\n const { timeZone, setTimeZone } = useTimeRangeContext();\n return {\n timeZone,\n setTimeZone,\n formatWithUserTimeZone: (date: Date, formatString: string): string => {\n return formatWithTimeZone(date, formatString, timeZone);\n },\n dateFormatOptionsWithUserTimeZone: (dateFormatOptions: Intl.DateTimeFormatOptions): Intl.DateTimeFormatOptions => {\n return dateFormatOptionsWithTimeZone(dateFormatOptions, timeZone);\n },\n };\n}\n\n/**\n * Gets the suggested step for a graph query in ms for the currently selected time range.\n */\nexport function useSuggestedStepMs(width?: number): number {\n const { absoluteTimeRange } = useTimeRange();\n if (width === undefined) return 0;\n return getSuggestedStepMs(absoluteTimeRange, width);\n}\n\n/**\n * Provider implementation that supplies the time range state at runtime.\n */\nexport function TimeRangeProvider(props: TimeRangeProviderProps): ReactElement {\n const {\n timeRange,\n refreshInterval,\n children,\n setTimeRange,\n setRefreshInterval,\n timeZone = DEFAULT_DASHBOARD_TIMEZONE,\n setTimeZone,\n } = props;\n\n const [localTimeRange, setLocalTimeRange] = useState<TimeRangeValue>(timeRange);\n const [localRefreshInterval, setLocalRefreshInterval] = useState<DurationString | undefined>(refreshInterval);\n const [localTimeZone, setLocalTimeZone] = useState<string>(timeZone);\n\n const [refreshCounter, setRefreshCounter] = useState(0);\n\n useEffect(() => {\n setLocalTimeRange(timeRange);\n }, [timeRange, refreshCounter]);\n\n useEffect(() => {\n setLocalRefreshInterval(refreshInterval);\n }, [refreshInterval]);\n\n useEffect(() => {\n setLocalTimeZone(timeZone);\n }, [timeZone]);\n\n const refresh = useCallback(() => {\n setRefreshCounter((counter) => counter + 1);\n }, [setRefreshCounter]);\n\n const refreshIntervalInMs = getRefreshIntervalInMs(localRefreshInterval);\n useEffect(() => {\n if (refreshIntervalInMs > 0) {\n const interval = setInterval(() => {\n refresh();\n }, refreshIntervalInMs);\n\n return (): void => clearInterval(interval);\n }\n }, [refresh, refreshIntervalInMs]);\n\n const ctx = useMemo(() => {\n const absoluteTimeRange = isRelativeTimeRange(localTimeRange)\n ? toAbsoluteTimeRange(localTimeRange)\n : localTimeRange;\n return {\n timeRange: localTimeRange,\n timeZone: localTimeZone,\n setTimeRange: setTimeRange ?? setLocalTimeRange,\n absoluteTimeRange,\n refresh,\n refreshKey: `${absoluteTimeRange.start}:${absoluteTimeRange.end}:${localRefreshInterval}:${refreshCounter}`,\n refreshInterval: localRefreshInterval,\n refreshIntervalInMs: refreshIntervalInMs,\n setRefreshInterval: setRefreshInterval ?? setLocalRefreshInterval,\n setTimeZone: setTimeZone ?? setLocalTimeZone,\n };\n }, [\n localTimeRange,\n localTimeZone,\n setTimeRange,\n refresh,\n localRefreshInterval,\n refreshCounter,\n refreshIntervalInMs,\n setRefreshInterval,\n setTimeZone,\n ]);\n\n return <TimeRangeContext.Provider value={ctx}>{children}</TimeRangeContext.Provider>;\n}\n"],"names":["React","createContext","useCallback","useContext","useEffect","useMemo","useState","isRelativeTimeRange","toAbsoluteTimeRange","getSuggestedStepMs","DEFAULT_DASHBOARD_TIMEZONE","dateFormatOptionsWithTimeZone","formatWithTimeZone","getRefreshIntervalInMs","TimeRangeContext","undefined","useTimeRangeContext","ctx","Error","useTimeRange","useTimeZone","timeZone","setTimeZone","formatWithUserTimeZone","date","formatString","dateFormatOptionsWithUserTimeZone","dateFormatOptions","useSuggestedStepMs","width","absoluteTimeRange","TimeRangeProvider","props","timeRange","refreshInterval","children","setTimeRange","setRefreshInterval","localTimeRange","setLocalTimeRange","localRefreshInterval","setLocalRefreshInterval","localTimeZone","setLocalTimeZone","refreshCounter","setRefreshCounter","refresh","counter","refreshIntervalInMs","interval","setInterval","clearInterval","refreshKey","start","end","Provider","value"],"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,OAAOA,SAASC,aAAa,EAAgBC,WAAW,EAAEC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAClH,SAIEC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,UAAU;QACRqC,wBAAwBP;IAC1B,GAAG;QAACA;KAAgB;IAEpB9B,UAAU;QACRuC,iBAAiBtB;IACnB,GAAG;QAACA;KAAS;IAEb,MAAMyB,UAAU5C,YAAY;QAC1B2C,kBAAkB,CAACE,UAAYA,UAAU;IAC3C,GAAG;QAACF;KAAkB;IAEtB,MAAMG,sBAAsBnC,uBAAuB2B;IACnDpC,UAAU;QACR,IAAI4C,sBAAsB,GAAG;YAC3B,MAAMC,WAAWC,YAAY;gBAC3BJ;YACF,GAAGE;YAEH,OAAO,IAAYG,cAAcF;QACnC;IACF,GAAG;QAACH;QAASE;KAAoB;IAEjC,MAAM/B,MAAMZ,QAAQ;QAClB,MAAMyB,oBAAoBvB,oBAAoB+B,kBAC1C9B,oBAAoB8B,kBACpBA;QACJ,OAAO;YACLL,WAAWK;YACXjB,UAAUqB;YACVN,cAAcA,gBAAgBG;YAC9BT;YACAgB;YACAM,YAAY,GAAGtB,kBAAkBuB,KAAK,CAAC,CAAC,EAAEvB,kBAAkBwB,GAAG,CAAC,CAAC,EAAEd,qBAAqB,CAAC,EAAEI,gBAAgB;YAC3GV,iBAAiBM;YACjBQ,qBAAqBA;YACrBX,oBAAoBA,sBAAsBI;YAC1CnB,aAAaA,eAAeqB;QAC9B;IACF,GAAG;QACDL;QACAI;QACAN;QACAU;QACAN;QACAI;QACAI;QACAX;QACAf;KACD;IAED,qBAAO,KAACR,iBAAiByC,QAAQ;QAACC,OAAOvC;kBAAMkB;;AACjD"}
1
+ {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.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 React, { createContext, ReactElement, useCallback, useContext, useEffect, useMemo, useState } from 'react';\nimport {\n AbsoluteTimeRange,\n DurationString,\n TimeRangeValue,\n isRelativeTimeRange,\n toAbsoluteTimeRange,\n getSuggestedStepMs,\n} from '@perses-dev/core';\nimport { getRefreshIntervalInMs } from './refresh-interval';\n\nexport interface TimeRangeProviderProps {\n timeRange: TimeRangeValue;\n refreshInterval?: DurationString;\n setTimeRange?: (value: TimeRangeValue) => void;\n setRefreshInterval?: (value: DurationString) => void;\n children?: React.ReactNode;\n}\n\nexport interface TimeRange {\n timeRange: TimeRangeValue;\n absoluteTimeRange: AbsoluteTimeRange; // resolved absolute time for plugins to use\n setTimeRange: (value: TimeRangeValue) => void;\n refresh: () => void;\n refreshKey: string;\n refreshInterval?: DurationString;\n refreshIntervalInMs: number;\n setRefreshInterval: (value: DurationString) => void;\n}\n\nexport const TimeRangeContext = createContext<TimeRange | undefined>(undefined);\n\nexport function useTimeRangeContext(): TimeRange {\n const ctx = useContext(TimeRangeContext);\n if (ctx === undefined) {\n throw new Error('No TimeRangeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\n/**\n * Get and set the current resolved time range at runtime.\n */\nexport function useTimeRange(): TimeRange {\n return useTimeRangeContext();\n}\n\n/**\n * Gets the suggested step for a graph query in ms for the currently selected time range.\n */\nexport function useSuggestedStepMs(width?: number): number {\n const { absoluteTimeRange } = useTimeRange();\n if (width === undefined) return 0;\n return getSuggestedStepMs(absoluteTimeRange, width);\n}\n\n/**\n * Provider implementation that supplies the time range state at runtime.\n */\nexport function TimeRangeProvider(props: TimeRangeProviderProps): ReactElement {\n const { timeRange, refreshInterval, children, setTimeRange, setRefreshInterval } = props;\n\n const [localTimeRange, setLocalTimeRange] = useState<TimeRangeValue>(timeRange);\n const [localRefreshInterval, setLocalRefreshInterval] = useState<DurationString | undefined>(refreshInterval);\n\n const [refreshCounter, setRefreshCounter] = useState(0);\n\n useEffect(() => {\n setLocalTimeRange(timeRange);\n }, [timeRange, refreshCounter]);\n\n useEffect(() => {\n setLocalRefreshInterval(refreshInterval);\n }, [refreshInterval]);\n\n const refresh = useCallback(() => {\n setRefreshCounter((counter) => counter + 1);\n }, [setRefreshCounter]);\n\n const refreshIntervalInMs = getRefreshIntervalInMs(localRefreshInterval);\n useEffect(() => {\n if (refreshIntervalInMs > 0) {\n const interval = setInterval(() => {\n refresh();\n }, refreshIntervalInMs);\n\n return (): void => clearInterval(interval);\n }\n }, [refresh, refreshIntervalInMs]);\n\n const ctx = useMemo(() => {\n const absoluteTimeRange = isRelativeTimeRange(localTimeRange)\n ? toAbsoluteTimeRange(localTimeRange)\n : localTimeRange;\n return {\n timeRange: localTimeRange,\n setTimeRange: setTimeRange ?? setLocalTimeRange,\n absoluteTimeRange,\n refresh,\n refreshKey: `${absoluteTimeRange.start}:${absoluteTimeRange.end}:${localRefreshInterval}:${refreshCounter}`,\n refreshInterval: localRefreshInterval,\n refreshIntervalInMs: refreshIntervalInMs,\n setRefreshInterval: setRefreshInterval ?? setLocalRefreshInterval,\n };\n }, [\n localTimeRange,\n setTimeRange,\n refresh,\n localRefreshInterval,\n refreshCounter,\n refreshIntervalInMs,\n setRefreshInterval,\n ]);\n\n return <TimeRangeContext.Provider value={ctx}>{children}</TimeRangeContext.Provider>;\n}\n"],"names":["React","createContext","useCallback","useContext","useEffect","useMemo","useState","isRelativeTimeRange","toAbsoluteTimeRange","getSuggestedStepMs","getRefreshIntervalInMs","TimeRangeContext","undefined","useTimeRangeContext","ctx","Error","useTimeRange","useSuggestedStepMs","width","absoluteTimeRange","TimeRangeProvider","props","timeRange","refreshInterval","children","setTimeRange","setRefreshInterval","localTimeRange","setLocalTimeRange","localRefreshInterval","setLocalRefreshInterval","refreshCounter","setRefreshCounter","refresh","counter","refreshIntervalInMs","interval","setInterval","clearInterval","refreshKey","start","end","Provider","value"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AAC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IAEtB,MAAMG,sBAAsBzB,uBAAuBmB;IACnDzB,UAAU;QACR,IAAI+B,sBAAsB,GAAG;YAC3B,MAAMC,WAAWC,YAAY;gBAC3BJ;YACF,GAAGE;YAEH,OAAO,IAAYG,cAAcF;QACnC;IACF,GAAG;QAACH;QAASE;KAAoB;IAEjC,MAAMrB,MAAMT,QAAQ;QAClB,MAAMc,oBAAoBZ,oBAAoBoB,kBAC1CnB,oBAAoBmB,kBACpBA;QACJ,OAAO;YACLL,WAAWK;YACXF,cAAcA,gBAAgBG;YAC9BT;YACAc;YACAM,YAAY,GAAGpB,kBAAkBqB,KAAK,CAAC,CAAC,EAAErB,kBAAkBsB,GAAG,CAAC,CAAC,EAAEZ,qBAAqB,CAAC,EAAEE,gBAAgB;YAC3GR,iBAAiBM;YACjBM,qBAAqBA;YACrBT,oBAAoBA,sBAAsBI;QAC5C;IACF,GAAG;QACDH;QACAF;QACAQ;QACAJ;QACAE;QACAI;QACAT;KACD;IAED,qBAAO,KAACf,iBAAiB+B,QAAQ;QAACC,OAAO7B;kBAAMU;;AACjD"}
@@ -4,7 +4,6 @@ export interface TimeRangeFromQueryProps {
4
4
  initialTimeRange: TimeRangeValue;
5
5
  initialRefreshInterval?: DurationString;
6
6
  children?: React.ReactNode;
7
- initialTimeZone?: string;
8
7
  }
9
8
  export declare function TimeRangeProviderWithQueryParams(props: TimeRangeFromQueryProps): ReactElement;
10
9
  //# sourceMappingURL=TimeRangeProviderWithQueryParams.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TimeRangeProviderWithQueryParams.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.tsx"],"names":[],"mappings":"AAaA,OAAO,EAA8B,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC9F,OAAO,KAAK,EAAE,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAI5C,MAAM,WAAW,uBAAuB;IACtC,gBAAgB,EAAE,cAAc,CAAC;IACjC,sBAAsB,CAAC,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,uBAAuB,GAAG,YAAY,CAmB7F"}
1
+ {"version":3,"file":"TimeRangeProviderWithQueryParams.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAI5C,MAAM,WAAW,uBAAuB;IACtC,gBAAgB,EAAE,cAAc,CAAC;IACjC,sBAAsB,CAAC,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,uBAAuB,GAAG,YAAY,CAgB7F"}
@@ -11,22 +11,18 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
- import { DEFAULT_DASHBOARD_TIMEZONE } from '@perses-dev/core';
15
14
  import React from 'react';
16
15
  import { TimeRangeProvider } from './TimeRangeProvider';
17
- import { useSetRefreshIntervalParams, useSetTimeZoneParams, useTimeRangeParams } from './query-params';
16
+ import { useSetRefreshIntervalParams, useTimeRangeParams } from './query-params';
18
17
  export function TimeRangeProviderWithQueryParams(props) {
19
- const { initialTimeRange, initialRefreshInterval, children, initialTimeZone = DEFAULT_DASHBOARD_TIMEZONE } = props;
18
+ const { initialTimeRange, initialRefreshInterval, children } = props;
20
19
  const { timeRange, setTimeRange } = useTimeRangeParams(initialTimeRange);
21
20
  const { refreshInterval, setRefreshInterval } = useSetRefreshIntervalParams(initialRefreshInterval);
22
- const { timeZone, setTimeZone } = useSetTimeZoneParams(initialTimeZone);
23
21
  return /*#__PURE__*/ _jsx(TimeRangeProvider, {
24
22
  timeRange: timeRange,
25
23
  refreshInterval: refreshInterval,
26
24
  setTimeRange: setTimeRange,
27
25
  setRefreshInterval: setRefreshInterval,
28
- timeZone: timeZone,
29
- setTimeZone: setTimeZone,
30
26
  children: children
31
27
  });
32
28
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.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 { DEFAULT_DASHBOARD_TIMEZONE, DurationString, TimeRangeValue } from '@perses-dev/core';\nimport React, { ReactElement } from 'react';\nimport { TimeRangeProvider } from './TimeRangeProvider';\nimport { useSetRefreshIntervalParams, useSetTimeZoneParams, useTimeRangeParams } from './query-params';\n\nexport interface TimeRangeFromQueryProps {\n initialTimeRange: TimeRangeValue;\n initialRefreshInterval?: DurationString;\n children?: React.ReactNode;\n initialTimeZone?: string;\n}\n\nexport function TimeRangeProviderWithQueryParams(props: TimeRangeFromQueryProps): ReactElement {\n const { initialTimeRange, initialRefreshInterval, children, initialTimeZone = DEFAULT_DASHBOARD_TIMEZONE } = props;\n\n const { timeRange, setTimeRange } = useTimeRangeParams(initialTimeRange);\n const { refreshInterval, setRefreshInterval } = useSetRefreshIntervalParams(initialRefreshInterval);\n\n const { timeZone, setTimeZone } = useSetTimeZoneParams(initialTimeZone);\n return (\n <TimeRangeProvider\n timeRange={timeRange}\n refreshInterval={refreshInterval}\n setTimeRange={setTimeRange}\n setRefreshInterval={setRefreshInterval}\n timeZone={timeZone}\n setTimeZone={setTimeZone}\n >\n {children}\n </TimeRangeProvider>\n );\n}\n"],"names":["DEFAULT_DASHBOARD_TIMEZONE","React","TimeRangeProvider","useSetRefreshIntervalParams","useSetTimeZoneParams","useTimeRangeParams","TimeRangeProviderWithQueryParams","props","initialTimeRange","initialRefreshInterval","children","initialTimeZone","timeRange","setTimeRange","refreshInterval","setRefreshInterval","timeZone","setTimeZone"],"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,0BAA0B,QAAwC,mBAAmB;AAC9F,OAAOC,WAA6B,QAAQ;AAC5C,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,2BAA2B,EAAEC,oBAAoB,EAAEC,kBAAkB,QAAQ,iBAAiB;AASvG,OAAO,SAASC,iCAAiCC,KAA8B;IAC7E,MAAM,EAAEC,gBAAgB,EAAEC,sBAAsB,EAAEC,QAAQ,EAAEC,kBAAkBX,0BAA0B,EAAE,GAAGO;IAE7G,MAAM,EAAEK,SAAS,EAAEC,YAAY,EAAE,GAAGR,mBAAmBG;IACvD,MAAM,EAAEM,eAAe,EAAEC,kBAAkB,EAAE,GAAGZ,4BAA4BM;IAE5E,MAAM,EAAEO,QAAQ,EAAEC,WAAW,EAAE,GAAGb,qBAAqBO;IACvD,qBACE,KAACT;QACCU,WAAWA;QACXE,iBAAiBA;QACjBD,cAAcA;QACdE,oBAAoBA;QACpBC,UAAUA;QACVC,aAAaA;kBAEZP;;AAGP"}
1
+ {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.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 { DurationString, TimeRangeValue } from '@perses-dev/core';\nimport React, { ReactElement } from 'react';\nimport { TimeRangeProvider } from './TimeRangeProvider';\nimport { useSetRefreshIntervalParams, useTimeRangeParams } from './query-params';\n\nexport interface TimeRangeFromQueryProps {\n initialTimeRange: TimeRangeValue;\n initialRefreshInterval?: DurationString;\n children?: React.ReactNode;\n}\n\nexport function TimeRangeProviderWithQueryParams(props: TimeRangeFromQueryProps): ReactElement {\n const { initialTimeRange, initialRefreshInterval, children } = props;\n\n const { timeRange, setTimeRange } = useTimeRangeParams(initialTimeRange);\n const { refreshInterval, setRefreshInterval } = useSetRefreshIntervalParams(initialRefreshInterval);\n\n return (\n <TimeRangeProvider\n timeRange={timeRange}\n refreshInterval={refreshInterval}\n setTimeRange={setTimeRange}\n setRefreshInterval={setRefreshInterval}\n >\n {children}\n </TimeRangeProvider>\n );\n}\n"],"names":["React","TimeRangeProvider","useSetRefreshIntervalParams","useTimeRangeParams","TimeRangeProviderWithQueryParams","props","initialTimeRange","initialRefreshInterval","children","timeRange","setTimeRange","refreshInterval","setRefreshInterval"],"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,OAAOA,WAA6B,QAAQ;AAC5C,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,2BAA2B,EAAEC,kBAAkB,QAAQ,iBAAiB;AAQjF,OAAO,SAASC,iCAAiCC,KAA8B;IAC7E,MAAM,EAAEC,gBAAgB,EAAEC,sBAAsB,EAAEC,QAAQ,EAAE,GAAGH;IAE/D,MAAM,EAAEI,SAAS,EAAEC,YAAY,EAAE,GAAGP,mBAAmBG;IACvD,MAAM,EAAEK,eAAe,EAAEC,kBAAkB,EAAE,GAAGV,4BAA4BK;IAE5E,qBACE,KAACN;QACCQ,WAAWA;QACXE,iBAAiBA;QACjBD,cAAcA;QACdE,oBAAoBA;kBAEnBJ;;AAGP"}
@@ -34,8 +34,4 @@ export declare function useInitialRefreshInterval(dashboardDuration: DurationStr
34
34
  * Returns refresh interval getter and setter, taking the URL query params.
35
35
  */
36
36
  export declare function useSetRefreshIntervalParams(initialRefreshInterval?: DurationString): Pick<TimeRange, 'refreshInterval' | 'setRefreshInterval'>;
37
- export declare function useSetTimeZoneParams(initialTimeZone: string): {
38
- timeZone: string;
39
- setTimeZone: (timeZone: string) => void;
40
- };
41
37
  //# sourceMappingURL=query-params.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"query-params.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/query-params.ts"],"names":[],"mappings":"AAcA,OAAO,EAAkB,gBAAgB,EAAe,MAAM,kBAAkB,CAAC;AAEjF,OAAO,EACL,cAAc,EAGd,cAAc,EAEf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,cAAc,GAAG,IAAI,GAAG,SAAS,CAAC;AAwBvE,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAWhG;AAGD,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,GACtD,IAAI,GAAG,cAAc,GAAG,IAAI,GAAG,SAAS,CAI1C;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EA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,GAAG,IAAI,GAAG,SAAS,GACtD,IAAI,GAAG,cAAc,GAAG,IAAI,GAAG,SAAS,CAI1C;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,gBAAgB,CAAC,eAAe,EAAE,eAAe,CAQ7E,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;CAGhC,CAAC;AAEF,eAAO,MAAM,0BAA0B;;CAEtC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,iBAAiB,EAAE,cAAc,GAAG,cAAc,CAgBrF;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,gBAAgB,EAAE,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,WAAW,GAAG,cAAc,CAAC,CA8BlH;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,iBAAiB,EAAE,cAAc,GAAG,cAAc,CAc3F;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,sBAAsB,CAAC,EAAE,cAAc,GACtC,IAAI,CAAC,SAAS,EAAE,iBAAiB,GAAG,oBAAoB,CAAC,CAyB3D"}
@@ -11,7 +11,7 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { useMemo, useCallback, useEffect, useState } from 'react';
14
- import { useQueryParams, StringParam } from 'use-query-params';
14
+ import { useQueryParams } from 'use-query-params';
15
15
  import { getUnixTime, isDate } from 'date-fns';
16
16
  import { isRelativeTimeRange, isDurationString } from '@perses-dev/core';
17
17
  /* Interprets an encoded string and returns either the string or null/undefined if not available */ function getEncodedValue(input, allowEmptyString) {
@@ -195,33 +195,5 @@ export const refreshIntervalQueryConfig = {
195
195
  setRefreshInterval: setRefreshInterval
196
196
  };
197
197
  }
198
- export function useSetTimeZoneParams(initialTimeZone) {
199
- const [query, setQuery] = useQueryParams({
200
- timeZone: StringParam
201
- }, {
202
- updateType: 'replaceIn'
203
- });
204
- const { timeZone } = query;
205
- useEffect(()=>{
206
- if (!timeZone) {
207
- setQuery({
208
- timeZone: initialTimeZone
209
- });
210
- }
211
- }, [
212
- setQuery,
213
- timeZone,
214
- initialTimeZone
215
- ]);
216
- const setTimeZone = useCallback((timeZone)=>setQuery({
217
- timeZone
218
- }), [
219
- setQuery
220
- ]);
221
- return {
222
- timeZone: timeZone ? timeZone : initialTimeZone,
223
- setTimeZone: setTimeZone
224
- };
225
- }
226
198
 
227
199
  //# sourceMappingURL=query-params.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/query-params.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 { useMemo, useCallback, useEffect, useState } from 'react';\nimport { useQueryParams, QueryParamConfig, StringParam } from 'use-query-params';\nimport { getUnixTime, isDate } from 'date-fns';\nimport {\n TimeRangeValue,\n isRelativeTimeRange,\n isDurationString,\n DurationString,\n AbsoluteTimeRange,\n} from '@perses-dev/core';\nimport { TimeRange } from './TimeRangeProvider';\n\nexport type TimeOptionValue = Date | DurationString | null | undefined;\n\n/* Interprets an encoded string and returns either the string or null/undefined if not available */\nfunction getEncodedValue(\n input: string | Array<string | null> | null | undefined,\n allowEmptyString?: boolean\n): string | null | undefined {\n // '' or []\n if (!input || (input.length === 0 && (!allowEmptyString || (allowEmptyString && input !== '')))) {\n return null;\n }\n\n const str = input instanceof Array ? input[0] : input;\n if (str === null || str === undefined) {\n return str;\n }\n if (!allowEmptyString && str === '') {\n return null;\n }\n\n return str;\n}\n\n/* Encodes individual TimeRangeValue as a string, depends on whether start is relative or absolute */\nexport function encodeTimeRangeValue(timeOptionValue: TimeOptionValue): string | null | undefined {\n if (!timeOptionValue) {\n return timeOptionValue;\n }\n\n if (typeof timeOptionValue === 'string') {\n if (isDurationString(timeOptionValue)) {\n return timeOptionValue;\n }\n }\n return (getUnixTime(timeOptionValue) * 1000).toString();\n}\n\n/* Converts param input to supported relative or absolute time range format */\nexport function decodeTimeRangeValue(\n input: string | Array<string | null> | null | undefined\n): Date | DurationString | null | undefined {\n const paramString = getEncodedValue(input);\n if (!paramString) return null;\n return isDurationString(paramString) ? paramString : new Date(Number(paramString));\n}\n\n/**\n * Custom TimeRangeValue param type\n * See: https://github.com/pbeshai/use-query-params/tree/master/packages/serialize-query-params#param-types\n */\nexport const TimeRangeParam: QueryParamConfig<TimeOptionValue, TimeOptionValue> = {\n encode: encodeTimeRangeValue,\n decode: decodeTimeRangeValue,\n equals: (valueA: TimeOptionValue, valueB: TimeOptionValue) => {\n if (valueA === valueB) return true;\n if (!valueA || !valueB) return valueA === valueB;\n return valueA.valueOf() === valueB.valueOf();\n },\n};\n\nexport const timeRangeQueryConfig = {\n start: TimeRangeParam,\n end: TimeRangeParam,\n};\n\nexport const refreshIntervalQueryConfig = {\n refresh: TimeRangeParam,\n};\n\n/**\n * Gets the initial time range taking into account URL params and dashboard JSON duration\n * Sets start query param if it is empty on page load\n */\nexport function useInitialTimeRange(dashboardDuration: DurationString): TimeRangeValue {\n const [query] = useQueryParams(timeRangeQueryConfig, { updateType: 'replaceIn' });\n const { start, end } = query;\n return useMemo(() => {\n let initialTimeRange: TimeRangeValue = { pastDuration: dashboardDuration };\n if (!start) {\n return initialTimeRange;\n }\n const startStr = start.toString();\n if (isDurationString(startStr)) {\n initialTimeRange = { pastDuration: startStr };\n } else if (isDate(start) && isDate(end)) {\n initialTimeRange = { start: start, end: end } as AbsoluteTimeRange;\n }\n return initialTimeRange;\n }, [start, end, dashboardDuration]);\n}\n\n/**\n * Returns time range getter and setter, taking the URL query params.\n */\nexport function useTimeRangeParams(initialTimeRange: TimeRangeValue): Pick<TimeRange, 'timeRange' | 'setTimeRange'> {\n const [query, setQuery] = useQueryParams(timeRangeQueryConfig, { updateType: 'replaceIn' });\n\n // determine whether initial param had previously been populated to fix back btn\n const [paramsLoaded, setParamsLoaded] = useState<boolean>(false);\n\n const { start } = query;\n\n useEffect(() => {\n // when dashboard loaded with no params, default to dashboard duration\n if (!paramsLoaded && !start) {\n if (isRelativeTimeRange(initialTimeRange)) {\n setQuery({ start: initialTimeRange.pastDuration, end: undefined });\n setParamsLoaded(true);\n }\n }\n }, [initialTimeRange, paramsLoaded, start, setQuery]);\n\n const setTimeRange: TimeRange['setTimeRange'] = useCallback(\n (value: TimeRangeValue) => {\n if (isRelativeTimeRange(value)) {\n setQuery({ start: value.pastDuration, end: undefined });\n } else {\n setQuery(value);\n }\n },\n [setQuery]\n );\n\n return { timeRange: initialTimeRange, setTimeRange: setTimeRange };\n}\n\n/**\n * Gets the initial refresh interval taking into account URL params and dashboard JSON duration\n * Sets refresh query param if it is empty on page load\n */\nexport function useInitialRefreshInterval(dashboardDuration: DurationString): DurationString {\n const [query] = useQueryParams(refreshIntervalQueryConfig, { updateType: 'replaceIn' });\n const { refresh } = query;\n return useMemo(() => {\n let initialTimeRange: DurationString = dashboardDuration;\n if (!refresh) {\n return initialTimeRange;\n }\n const startStr = refresh.toString();\n if (isDurationString(startStr)) {\n initialTimeRange = startStr;\n }\n return initialTimeRange;\n }, [dashboardDuration, refresh]);\n}\n\n/**\n * Returns refresh interval getter and setter, taking the URL query params.\n */\nexport function useSetRefreshIntervalParams(\n initialRefreshInterval?: DurationString\n): Pick<TimeRange, 'refreshInterval' | 'setRefreshInterval'> {\n const [query, setQuery] = useQueryParams(refreshIntervalQueryConfig, { updateType: 'replaceIn' });\n\n // determine whether initial param had previously been populated to fix back btn\n const [paramsLoaded, setParamsLoaded] = useState<boolean>(false);\n\n const { refresh } = query;\n\n useEffect(() => {\n // when dashboard loaded with no params, default to dashboard refresh interval\n if (!paramsLoaded && !refresh) {\n setQuery({ refresh: initialRefreshInterval });\n setParamsLoaded(true);\n }\n }, [initialRefreshInterval, paramsLoaded, refresh, setQuery]);\n\n const setRefreshInterval: TimeRange['setRefreshInterval'] = useCallback(\n (refresh: DurationString) => setQuery({ refresh }),\n [setQuery]\n );\n\n return {\n refreshInterval: initialRefreshInterval,\n setRefreshInterval: setRefreshInterval,\n };\n}\n\nexport function useSetTimeZoneParams(initialTimeZone: string): {\n timeZone: string;\n setTimeZone: (timeZone: string) => void;\n} {\n const [query, setQuery] = useQueryParams({ timeZone: StringParam }, { updateType: 'replaceIn' });\n const { timeZone } = query;\n\n useEffect(() => {\n if (!timeZone) {\n setQuery({ timeZone: initialTimeZone });\n }\n }, [setQuery, timeZone, initialTimeZone]);\n\n const setTimeZone = useCallback((timeZone: string) => setQuery({ timeZone }), [setQuery]);\n\n return {\n timeZone: timeZone ? timeZone : initialTimeZone,\n setTimeZone: setTimeZone,\n };\n}\n"],"names":["useMemo","useCallback","useEffect","useState","useQueryParams","StringParam","getUnixTime","isDate","isRelativeTimeRange","isDurationString","getEncodedValue","input","allowEmptyString","length","str","Array","undefined","encodeTimeRangeValue","timeOptionValue","toString","decodeTimeRangeValue","paramString","Date","Number","TimeRangeParam","encode","decode","equals","valueA","valueB","valueOf","timeRangeQueryConfig","start","end","refreshIntervalQueryConfig","refresh","useInitialTimeRange","dashboardDuration","query","updateType","initialTimeRange","pastDuration","startStr","useTimeRangeParams","setQuery","paramsLoaded","setParamsLoaded","setTimeRange","value","timeRange","useInitialRefreshInterval","useSetRefreshIntervalParams","initialRefreshInterval","setRefreshInterval","refreshInterval","useSetTimeZoneParams","initialTimeZone","timeZone","setTimeZone"],"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,OAAO,EAAEC,WAAW,EAAEC,SAAS,EAAEC,QAAQ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,QAAQ,EAAE,GAAGnB;IAErBpC,UAAU;QACR,IAAI,CAACuD,UAAU;YACbb,SAAS;gBAAEa,UAAUD;YAAgB;QACvC;IACF,GAAG;QAACZ;QAAUa;QAAUD;KAAgB;IAExC,MAAME,cAAczD,YAAY,CAACwD,WAAqBb,SAAS;YAAEa;QAAS,IAAI;QAACb;KAAS;IAExF,OAAO;QACLa,UAAUA,WAAWA,WAAWD;QAChCE,aAAaA;IACf;AACF"}
1
+ {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/query-params.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 { useMemo, useCallback, useEffect, useState } from 'react';\nimport { useQueryParams, QueryParamConfig } from 'use-query-params';\nimport { getUnixTime, isDate } from 'date-fns';\nimport {\n TimeRangeValue,\n isRelativeTimeRange,\n isDurationString,\n DurationString,\n AbsoluteTimeRange,\n} from '@perses-dev/core';\nimport { TimeRange } from './TimeRangeProvider';\n\nexport type TimeOptionValue = Date | DurationString | null | undefined;\n\n/* Interprets an encoded string and returns either the string or null/undefined if not available */\nfunction getEncodedValue(\n input: string | Array<string | null> | null | undefined,\n allowEmptyString?: boolean\n): string | null | undefined {\n // '' or []\n if (!input || (input.length === 0 && (!allowEmptyString || (allowEmptyString && input !== '')))) {\n return null;\n }\n\n const str = input instanceof Array ? input[0] : input;\n if (str === null || str === undefined) {\n return str;\n }\n if (!allowEmptyString && str === '') {\n return null;\n }\n\n return str;\n}\n\n/* Encodes individual TimeRangeValue as a string, depends on whether start is relative or absolute */\nexport function encodeTimeRangeValue(timeOptionValue: TimeOptionValue): string | null | undefined {\n if (!timeOptionValue) {\n return timeOptionValue;\n }\n\n if (typeof timeOptionValue === 'string') {\n if (isDurationString(timeOptionValue)) {\n return timeOptionValue;\n }\n }\n return (getUnixTime(timeOptionValue) * 1000).toString();\n}\n\n/* Converts param input to supported relative or absolute time range format */\nexport function decodeTimeRangeValue(\n input: string | Array<string | null> | null | undefined\n): Date | DurationString | null | undefined {\n const paramString = getEncodedValue(input);\n if (!paramString) return null;\n return isDurationString(paramString) ? paramString : new Date(Number(paramString));\n}\n\n/**\n * Custom TimeRangeValue param type\n * See: https://github.com/pbeshai/use-query-params/tree/master/packages/serialize-query-params#param-types\n */\nexport const TimeRangeParam: QueryParamConfig<TimeOptionValue, TimeOptionValue> = {\n encode: encodeTimeRangeValue,\n decode: decodeTimeRangeValue,\n equals: (valueA: TimeOptionValue, valueB: TimeOptionValue) => {\n if (valueA === valueB) return true;\n if (!valueA || !valueB) return valueA === valueB;\n return valueA.valueOf() === valueB.valueOf();\n },\n};\n\nexport const timeRangeQueryConfig = {\n start: TimeRangeParam,\n end: TimeRangeParam,\n};\n\nexport const refreshIntervalQueryConfig = {\n refresh: TimeRangeParam,\n};\n\n/**\n * Gets the initial time range taking into account URL params and dashboard JSON duration\n * Sets start query param if it is empty on page load\n */\nexport function useInitialTimeRange(dashboardDuration: DurationString): TimeRangeValue {\n const [query] = useQueryParams(timeRangeQueryConfig, { updateType: 'replaceIn' });\n const { start, end } = query;\n return useMemo(() => {\n let initialTimeRange: TimeRangeValue = { pastDuration: dashboardDuration };\n if (!start) {\n return initialTimeRange;\n }\n const startStr = start.toString();\n if (isDurationString(startStr)) {\n initialTimeRange = { pastDuration: startStr };\n } else if (isDate(start) && isDate(end)) {\n initialTimeRange = { start: start, end: end } as AbsoluteTimeRange;\n }\n return initialTimeRange;\n }, [start, end, dashboardDuration]);\n}\n\n/**\n * Returns time range getter and setter, taking the URL query params.\n */\nexport function useTimeRangeParams(initialTimeRange: TimeRangeValue): Pick<TimeRange, 'timeRange' | 'setTimeRange'> {\n const [query, setQuery] = useQueryParams(timeRangeQueryConfig, { updateType: 'replaceIn' });\n\n // determine whether initial param had previously been populated to fix back btn\n const [paramsLoaded, setParamsLoaded] = useState<boolean>(false);\n\n const { start } = query;\n\n useEffect(() => {\n // when dashboard loaded with no params, default to dashboard duration\n if (!paramsLoaded && !start) {\n if (isRelativeTimeRange(initialTimeRange)) {\n setQuery({ start: initialTimeRange.pastDuration, end: undefined });\n setParamsLoaded(true);\n }\n }\n }, [initialTimeRange, paramsLoaded, start, setQuery]);\n\n const setTimeRange: TimeRange['setTimeRange'] = useCallback(\n (value: TimeRangeValue) => {\n if (isRelativeTimeRange(value)) {\n setQuery({ start: value.pastDuration, end: undefined });\n } else {\n setQuery(value);\n }\n },\n [setQuery]\n );\n\n return { timeRange: initialTimeRange, setTimeRange: setTimeRange };\n}\n\n/**\n * Gets the initial refresh interval taking into account URL params and dashboard JSON duration\n * Sets refresh query param if it is empty on page load\n */\nexport function useInitialRefreshInterval(dashboardDuration: DurationString): DurationString {\n const [query] = useQueryParams(refreshIntervalQueryConfig, { updateType: 'replaceIn' });\n const { refresh } = query;\n return useMemo(() => {\n let initialTimeRange: DurationString = dashboardDuration;\n if (!refresh) {\n return initialTimeRange;\n }\n const startStr = refresh.toString();\n if (isDurationString(startStr)) {\n initialTimeRange = startStr;\n }\n return initialTimeRange;\n }, [dashboardDuration, refresh]);\n}\n\n/**\n * Returns refresh interval getter and setter, taking the URL query params.\n */\nexport function useSetRefreshIntervalParams(\n initialRefreshInterval?: DurationString\n): Pick<TimeRange, 'refreshInterval' | 'setRefreshInterval'> {\n const [query, setQuery] = useQueryParams(refreshIntervalQueryConfig, { updateType: 'replaceIn' });\n\n // determine whether initial param had previously been populated to fix back btn\n const [paramsLoaded, setParamsLoaded] = useState<boolean>(false);\n\n const { refresh } = query;\n\n useEffect(() => {\n // when dashboard loaded with no params, default to dashboard refresh interval\n if (!paramsLoaded && !refresh) {\n setQuery({ refresh: initialRefreshInterval });\n setParamsLoaded(true);\n }\n }, [initialRefreshInterval, paramsLoaded, refresh, setQuery]);\n\n const setRefreshInterval: TimeRange['setRefreshInterval'] = useCallback(\n (refresh: DurationString) => setQuery({ refresh }),\n [setQuery]\n );\n\n return {\n refreshInterval: initialRefreshInterval,\n setRefreshInterval: setRefreshInterval,\n };\n}\n"],"names":["useMemo","useCallback","useEffect","useState","useQueryParams","getUnixTime","isDate","isRelativeTimeRange","isDurationString","getEncodedValue","input","allowEmptyString","length","str","Array","undefined","encodeTimeRangeValue","timeOptionValue","toString","decodeTimeRangeValue","paramString","Date","Number","TimeRangeParam","encode","decode","equals","valueA","valueB","valueOf","timeRangeQueryConfig","start","end","refreshIntervalQueryConfig","refresh","useInitialTimeRange","dashboardDuration","query","updateType","initialTimeRange","pastDuration","startStr","useTimeRangeParams","setQuery","paramsLoaded","setParamsLoaded","setTimeRange","value","timeRange","useInitialRefreshInterval","useSetRefreshIntervalParams","initialRefreshInterval","setRefreshInterval","refreshInterval"],"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,OAAO,EAAEC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAClE,SAASC,cAAc,QAA0B,mBAAmB;AACpE,SAASC,WAAW,EAAEC,MAAM,QAAQ,WAAW;AAC/C,SAEEC,mBAAmB,EACnBC,gBAAgB,QAGX,mBAAmB;AAK1B,iGAAiG,GACjG,SAASC,gBACPC,KAAuD,EACvDC,gBAA0B;IAE1B,WAAW;IACX,IAAI,CAACD,SAAUA,MAAME,MAAM,KAAK,KAAM,CAAA,CAACD,oBAAqBA,oBAAoBD,UAAU,EAAE,GAAK;QAC/F,OAAO;IACT;IAEA,MAAMG,MAAMH,iBAAiBI,QAAQJ,KAAK,CAA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A,MAAME,WAAWP,QAAQhB,QAAQ;QACjC,IAAIV,iBAAiBiC,WAAW;YAC9BF,mBAAmBE;QACrB;QACA,OAAOF;IACT,GAAG;QAACH;QAAmBF;KAAQ;AACjC;AAEA;;CAEC,GACD,OAAO,SAASgB,4BACdC,sBAAuC;IAEvC,MAAM,CAACd,OAAOM,SAAS,GAAGvC,eAAe6B,4BAA4B;QAAEK,YAAY;IAAY;IAE/F,gFAAgF;IAChF,MAAM,CAACM,cAAcC,gBAAgB,GAAG1C,SAAkB;IAE1D,MAAM,EAAE+B,OAAO,EAAE,GAAGG;IAEpBnC,UAAU;QACR,8EAA8E;QAC9E,IAAI,CAAC0C,gBAAgB,CAACV,SAAS;YAC7BS,SAAS;gBAAET,SAASiB;YAAuB;YAC3CN,gBAAgB;QAClB;IACF,GAAG;QAACM;QAAwBP;QAAcV;QAASS;KAAS;IAE5D,MAAMS,qBAAsDnD,YAC1D,CAACiC,UAA4BS,SAAS;YAAET;QAAQ,IAChD;QAACS;KAAS;IAGZ,OAAO;QACLU,iBAAiBF;QACjBC,oBAAoBA;IACtB;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/plugin-system",
3
- "version": "0.0.0-snapshot-time-zone-selector-946f408",
3
+ "version": "0.0.0-snapshot-panel-actions-520389b",
4
4
  "description": "The plugin feature in Pereses",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -29,8 +29,8 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@module-federation/enhanced": "^0.14.3",
32
- "@perses-dev/components": "0.0.0-snapshot-time-zone-selector-946f408",
33
- "@perses-dev/core": "0.0.0-snapshot-time-zone-selector-946f408",
32
+ "@perses-dev/components": "0.0.0-snapshot-panel-actions-520389b",
33
+ "@perses-dev/core": "0.0.0-snapshot-panel-actions-520389b",
34
34
  "date-fns": "^4.1.0",
35
35
  "date-fns-tz": "^3.2.0",
36
36
  "immer": "^10.1.1",