@perses-dev/dashboards 0.29.1 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/dist/cjs/components/DashboardStickyToolbar/DashboardStickyToolbar.js +79 -0
  2. package/dist/cjs/{stories/decorators/WithQueryClient.js → components/DashboardStickyToolbar/index.js} +11 -12
  3. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +8 -24
  4. package/dist/cjs/components/EditJsonButton/EditJsonButton.js +1 -0
  5. package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +5 -0
  6. package/dist/cjs/components/GridLayout/GridTitle.js +30 -9
  7. package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +88 -0
  8. package/dist/cjs/{stories/decorators/WithQueryParams.js → components/SaveChangesConfirmationDialog/index.js} +11 -12
  9. package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +78 -0
  10. package/dist/cjs/components/SaveDashboardButton/index.js +28 -0
  11. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +5 -5
  12. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +124 -198
  13. package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +178 -0
  14. package/dist/cjs/components/Variables/VariableEditorForm/index.js +1 -0
  15. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +7 -8
  16. package/dist/cjs/components/Variables/VariableList.js +16 -55
  17. package/dist/cjs/components/Variables/index.js +1 -0
  18. package/dist/cjs/components/index.js +2 -0
  19. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +5 -4
  20. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +13 -4
  21. package/dist/cjs/context/DashboardProvider/save-changes-dialog-slice.js +33 -0
  22. package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +56 -7
  23. package/dist/cjs/context/TemplateVariableProvider/hydrationUtils.js +2 -0
  24. package/dist/cjs/context/TemplateVariableProvider/utils.js +37 -0
  25. package/dist/cjs/context/useDashboard.js +4 -4
  26. package/dist/cjs/stories/decorators/index.js +0 -5
  27. package/dist/cjs/views/ViewDashboard/DashboardApp.js +2 -1
  28. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts +9 -0
  29. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts.map +1 -0
  30. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +68 -0
  31. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -0
  32. package/dist/components/DashboardStickyToolbar/index.d.ts +2 -0
  33. package/dist/components/DashboardStickyToolbar/index.d.ts.map +1 -0
  34. package/dist/{stories/decorators/WithQueryClient.js → components/DashboardStickyToolbar/index.js} +2 -10
  35. package/dist/components/DashboardStickyToolbar/index.js.map +1 -0
  36. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  37. package/dist/components/DashboardToolbar/DashboardToolbar.js +10 -26
  38. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  39. package/dist/components/EditJsonButton/EditJsonButton.js +1 -0
  40. package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -1
  41. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts.map +1 -1
  42. package/dist/components/EditJsonDialog/EditJsonDialog.js +5 -0
  43. package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
  44. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  45. package/dist/components/GridLayout/GridTitle.js +30 -9
  46. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  47. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts +3 -0
  48. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -0
  49. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +82 -0
  50. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -0
  51. package/dist/components/SaveChangesConfirmationDialog/index.d.ts +2 -0
  52. package/dist/components/SaveChangesConfirmationDialog/index.d.ts.map +1 -0
  53. package/dist/{stories/decorators/WithQueryParams.js → components/SaveChangesConfirmationDialog/index.js} +2 -10
  54. package/dist/components/SaveChangesConfirmationDialog/index.js.map +1 -0
  55. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts +10 -0
  56. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -0
  57. package/dist/components/SaveDashboardButton/SaveDashboardButton.js +72 -0
  58. package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -0
  59. package/dist/components/SaveDashboardButton/index.d.ts +2 -0
  60. package/dist/components/SaveDashboardButton/index.d.ts.map +1 -0
  61. package/dist/components/SaveDashboardButton/index.js +15 -0
  62. package/dist/components/SaveDashboardButton/index.js.map +1 -0
  63. package/dist/components/TimeRangeControls/TimeRangeControls.js +6 -6
  64. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  65. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +4 -2
  66. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  67. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +127 -196
  68. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  69. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +16 -0
  70. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -0
  71. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +122 -0
  72. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -0
  73. package/dist/components/Variables/VariableEditorForm/index.d.ts +1 -0
  74. package/dist/components/Variables/VariableEditorForm/index.d.ts.map +1 -1
  75. package/dist/components/Variables/VariableEditorForm/index.js +1 -0
  76. package/dist/components/Variables/VariableEditorForm/index.js.map +1 -1
  77. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
  78. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +7 -8
  79. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  80. package/dist/components/Variables/VariableList.d.ts +1 -7
  81. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  82. package/dist/components/Variables/VariableList.js +18 -52
  83. package/dist/components/Variables/VariableList.js.map +1 -1
  84. package/dist/components/Variables/index.d.ts +1 -0
  85. package/dist/components/Variables/index.d.ts.map +1 -1
  86. package/dist/components/Variables/index.js +1 -0
  87. package/dist/components/Variables/index.js.map +1 -1
  88. package/dist/components/index.d.ts +2 -0
  89. package/dist/components/index.d.ts.map +1 -1
  90. package/dist/components/index.js +2 -0
  91. package/dist/components/index.js.map +1 -1
  92. package/dist/context/DashboardProvider/DashboardProvider.d.ts +4 -3
  93. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  94. package/dist/context/DashboardProvider/DashboardProvider.js +5 -4
  95. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  96. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +6 -1
  97. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  98. package/dist/context/DashboardProvider/dashboard-provider-api.js +11 -3
  99. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  100. package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts +15 -0
  101. package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts.map +1 -0
  102. package/dist/context/DashboardProvider/save-changes-dialog-slice.js +27 -0
  103. package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -0
  104. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +4 -0
  105. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -1
  106. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +51 -7
  107. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
  108. package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts.map +1 -1
  109. package/dist/context/TemplateVariableProvider/hydrationUtils.js +2 -0
  110. package/dist/context/TemplateVariableProvider/hydrationUtils.js.map +1 -1
  111. package/dist/context/TemplateVariableProvider/utils.d.ts +4 -0
  112. package/dist/context/TemplateVariableProvider/utils.d.ts.map +1 -0
  113. package/dist/context/TemplateVariableProvider/utils.js +33 -0
  114. package/dist/context/TemplateVariableProvider/utils.js.map +1 -0
  115. package/dist/context/useDashboard.d.ts.map +1 -1
  116. package/dist/context/useDashboard.js +4 -4
  117. package/dist/context/useDashboard.js.map +1 -1
  118. package/dist/stories/decorators/WithDashboard.js.map +1 -1
  119. package/dist/stories/decorators/WithDatasourceStore.js.map +1 -1
  120. package/dist/stories/decorators/WithTemplateVariables.js.map +1 -1
  121. package/dist/stories/decorators/index.js +0 -5
  122. package/dist/stories/decorators/index.js.map +1 -1
  123. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  124. package/dist/views/ViewDashboard/DashboardApp.js +3 -2
  125. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  126. package/package.json +6 -6
  127. package/dist/cjs/stories/decorators/WithDataQueriesProvider.js +0 -39
  128. package/dist/cjs/stories/decorators/WithPluginRegistry.js +0 -94
  129. package/dist/cjs/stories/decorators/WithTimeRange.js +0 -38
  130. package/dist/stories/decorators/WithDataQueriesProvider.js +0 -33
  131. package/dist/stories/decorators/WithDataQueriesProvider.js.map +0 -1
  132. package/dist/stories/decorators/WithPluginRegistry.js +0 -49
  133. package/dist/stories/decorators/WithPluginRegistry.js.map +0 -1
  134. package/dist/stories/decorators/WithQueryClient.js.map +0 -1
  135. package/dist/stories/decorators/WithQueryParams.js.map +0 -1
  136. package/dist/stories/decorators/WithTimeRange.js +0 -32
  137. package/dist/stories/decorators/WithTimeRange.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/context/TemplateVariableProvider/utils.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAK7D,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,kBAAkB,EAAE,EAAE,QAAQ,EAAE,gBAAgB,WAgBpG"}
@@ -0,0 +1,33 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ /*
14
+ * Check whether saved variable definitions are out of date with current default list values in Zustand store
15
+ */ export function isSavedVariableModified(definitions, varState) {
16
+ for (const savedVariable of definitions){
17
+ if (savedVariable.kind === 'ListVariable') {
18
+ const currentVariable = varState[savedVariable.spec.name];
19
+ if (savedVariable.spec.default_value !== (currentVariable === null || currentVariable === void 0 ? void 0 : currentVariable.value)) {
20
+ return true;
21
+ }
22
+ } else if (savedVariable.kind === 'TextVariable') {
23
+ const currentVariable1 = varState[savedVariable.spec.name];
24
+ const currentVariableValue = typeof (currentVariable1 === null || currentVariable1 === void 0 ? void 0 : currentVariable1.value) === 'string' ? currentVariable1.value : '';
25
+ if (savedVariable.spec.value !== currentVariableValue) {
26
+ return true;
27
+ }
28
+ }
29
+ }
30
+ return false;
31
+ }
32
+
33
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/context/TemplateVariableProvider/utils.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 { VariableDefinition } from '@perses-dev/core';\nimport { VariableStateMap } from '@perses-dev/plugin-system';\n\n/*\n * Check whether saved variable definitions are out of date with current default list values in Zustand store\n */\nexport function isSavedVariableModified(definitions: VariableDefinition[], varState: VariableStateMap) {\n for (const savedVariable of definitions) {\n if (savedVariable.kind === 'ListVariable') {\n const currentVariable = varState[savedVariable.spec.name];\n if (savedVariable.spec.default_value !== currentVariable?.value) {\n return true;\n }\n } else if (savedVariable.kind === 'TextVariable') {\n const currentVariable = varState[savedVariable.spec.name];\n const currentVariableValue = typeof currentVariable?.value === 'string' ? currentVariable.value : '';\n if (savedVariable.spec.value !== currentVariableValue) {\n return true;\n }\n }\n }\n return false;\n}\n"],"names":["isSavedVariableModified","definitions","varState","savedVariable","kind","currentVariable","spec","name","default_value","value","currentVariableValue"],"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;AAKjC;;CAEC,GACD,OAAO,SAASA,uBAAuB,CAACC,WAAiC,EAAEC,QAA0B,EAAE;IACrG,KAAK,MAAMC,aAAa,IAAIF,WAAW,CAAE;QACvC,IAAIE,aAAa,CAACC,IAAI,KAAK,cAAc,EAAE;YACzC,MAAMC,eAAe,GAAGH,QAAQ,CAACC,aAAa,CAACG,IAAI,CAACC,IAAI,CAAC,AAAC;YAC1D,IAAIJ,aAAa,CAACG,IAAI,CAACE,aAAa,KAAKH,CAAAA,eAAe,aAAfA,eAAe,WAAO,GAAtBA,KAAAA,CAAsB,GAAtBA,eAAe,CAAEI,KAAK,CAAA,EAAE;gBAC/D,OAAO,IAAI,CAAC;YACd,CAAC;QACH,OAAO,IAAIN,aAAa,CAACC,IAAI,KAAK,cAAc,EAAE;YAChD,MAAMC,gBAAe,GAAGH,QAAQ,CAACC,aAAa,CAACG,IAAI,CAACC,IAAI,CAAC,AAAC;YAC1D,MAAMG,oBAAoB,GAAG,OAAOL,CAAAA,gBAAe,aAAfA,gBAAe,WAAO,GAAtBA,KAAAA,CAAsB,GAAtBA,gBAAe,CAAEI,KAAK,CAAA,KAAK,QAAQ,GAAGJ,gBAAe,CAACI,KAAK,GAAG,EAAE,AAAC;YACrG,IAAIN,aAAa,CAACG,IAAI,CAACG,KAAK,KAAKC,oBAAoB,EAAE;gBACrD,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDashboard.d.ts","sourceRoot":"","sources":["../../src/context/useDashboard.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAkB,iBAAiB,EAAkB,MAAM,kBAAkB,CAAC;AAIrF,wBAAgB,YAAY;;sCAoCe,iBAAiB;EAS3D"}
1
+ {"version":3,"file":"useDashboard.d.ts","sourceRoot":"","sources":["../../src/context/useDashboard.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAkB,iBAAiB,EAAkB,MAAM,kBAAkB,CAAC;AAIrF,wBAAgB,YAAY;;sCAkCe,iBAAiB;EAS3D"}
@@ -14,14 +14,14 @@ import { createPanelRef } from '@perses-dev/core';
14
14
  import { useDashboardStore } from './DashboardProvider';
15
15
  import { useTemplateVariableActions, useTemplateVariableDefinitions } from './TemplateVariableProvider';
16
16
  export function useDashboard() {
17
- const { panels , panelGroups , panelGroupOrder , defaultTimeRange , setDashboard: setDashboardResource , metadata , display , } = useDashboardStore(({ panels , panelGroups , panelGroupOrder , defaultTimeRange , setDashboard , metadata , display })=>({
17
+ const { panels , panelGroups , panelGroupOrder , setDashboard: setDashboardResource , metadata , display , duration , } = useDashboardStore(({ panels , panelGroups , panelGroupOrder , setDashboard , metadata , display , duration })=>({
18
18
  panels,
19
19
  panelGroups,
20
20
  panelGroupOrder,
21
- defaultTimeRange,
22
21
  setDashboard,
23
22
  metadata,
24
- display
23
+ display,
24
+ duration
25
25
  }));
26
26
  const { setVariableDefinitions } = useTemplateVariableActions();
27
27
  const variables = useTemplateVariableDefinitions();
@@ -34,7 +34,7 @@ export function useDashboard() {
34
34
  panels,
35
35
  layouts,
36
36
  variables,
37
- duration: defaultTimeRange.pastDuration
37
+ duration
38
38
  }
39
39
  };
40
40
  const setDashboard = (dashboardResource)=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/context/useDashboard.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 { createPanelRef, DashboardResource, GridDefinition } from '@perses-dev/core';\nimport { PanelGroupDefinition, PanelGroupId, useDashboardStore } from './DashboardProvider';\nimport { useTemplateVariableActions, useTemplateVariableDefinitions } from './TemplateVariableProvider';\n\nexport function useDashboard() {\n const {\n panels,\n panelGroups,\n panelGroupOrder,\n defaultTimeRange,\n setDashboard: setDashboardResource,\n metadata,\n display,\n } = useDashboardStore(\n ({ panels, panelGroups, panelGroupOrder, defaultTimeRange, setDashboard, metadata, display }) => ({\n panels,\n panelGroups,\n panelGroupOrder,\n defaultTimeRange,\n setDashboard,\n metadata,\n display,\n })\n );\n const { setVariableDefinitions } = useTemplateVariableActions();\n const variables = useTemplateVariableDefinitions();\n const layouts = convertPanelGroupsToLayouts(panelGroups, panelGroupOrder);\n\n const dashboard: DashboardResource = {\n kind: 'Dashboard',\n metadata,\n spec: {\n display,\n panels,\n layouts,\n variables,\n duration: defaultTimeRange.pastDuration,\n },\n };\n\n const setDashboard = (dashboardResource: DashboardResource) => {\n setVariableDefinitions(dashboardResource.spec.variables);\n setDashboardResource(dashboardResource);\n };\n\n return {\n dashboard,\n setDashboard,\n };\n}\n\nfunction convertPanelGroupsToLayouts(\n panelGroups: Record<number, PanelGroupDefinition>,\n panelGroupOrder: PanelGroupId[]\n): GridDefinition[] {\n const layouts: GridDefinition[] = [];\n panelGroupOrder.map((groupOrderId) => {\n const group = panelGroups[groupOrderId];\n if (group === undefined) {\n throw new Error('panel group not found');\n }\n const { title, isCollapsed, itemLayouts, itemPanelKeys } = group;\n let display = undefined;\n if (title) {\n display = {\n title,\n collapse: {\n open: !isCollapsed,\n },\n };\n }\n const layout: GridDefinition = {\n kind: 'Grid',\n spec: {\n display,\n items: itemLayouts.map((layout) => {\n const panelKey = itemPanelKeys[layout.i];\n if (panelKey === undefined) {\n throw new Error(`Missing panel key of layout ${layout.i}`);\n }\n return {\n x: layout.x,\n y: layout.y,\n width: layout.w,\n height: layout.h,\n content: createPanelRef(panelKey),\n };\n }),\n },\n };\n layouts.push(layout);\n });\n\n return layouts;\n}\n"],"names":["createPanelRef","useDashboardStore","useTemplateVariableActions","useTemplateVariableDefinitions","useDashboard","panels","panelGroups","panelGroupOrder","defaultTimeRange","setDashboard","setDashboardResource","metadata","display","setVariableDefinitions","variables","layouts","convertPanelGroupsToLayouts","dashboard","kind","spec","duration","pastDuration","dashboardResource","map","groupOrderId","group","undefined","Error","title","isCollapsed","itemLayouts","itemPanelKeys","collapse","open","layout","items","panelKey","i","x","y","width","w","height","h","content","push"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEA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C,CAAC;gBACJ,CAAC,CAAC;aACH;SACF,AAAC;QACFrB,OAAO,CAAC8B,IAAI,CAACX,MAAM,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,OAAOnB,OAAO,CAAC;AACjB,CAAC"}
1
+ {"version":3,"sources":["../../src/context/useDashboard.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 { createPanelRef, DashboardResource, GridDefinition } from '@perses-dev/core';\nimport { PanelGroupDefinition, PanelGroupId, useDashboardStore } from './DashboardProvider';\nimport { useTemplateVariableActions, useTemplateVariableDefinitions } from './TemplateVariableProvider';\n\nexport function useDashboard() {\n const {\n panels,\n panelGroups,\n panelGroupOrder,\n setDashboard: setDashboardResource,\n metadata,\n display,\n duration,\n } = useDashboardStore(({ panels, panelGroups, panelGroupOrder, setDashboard, metadata, display, duration }) => ({\n panels,\n panelGroups,\n panelGroupOrder,\n setDashboard,\n metadata,\n display,\n duration,\n }));\n const { setVariableDefinitions } = useTemplateVariableActions();\n const variables = useTemplateVariableDefinitions();\n const layouts = convertPanelGroupsToLayouts(panelGroups, panelGroupOrder);\n\n const dashboard: DashboardResource = {\n kind: 'Dashboard',\n metadata,\n spec: {\n display,\n panels,\n layouts,\n variables,\n duration,\n },\n };\n\n const setDashboard = (dashboardResource: DashboardResource) => {\n setVariableDefinitions(dashboardResource.spec.variables);\n setDashboardResource(dashboardResource);\n };\n\n return {\n dashboard,\n setDashboard,\n };\n}\n\nfunction convertPanelGroupsToLayouts(\n panelGroups: Record<number, PanelGroupDefinition>,\n panelGroupOrder: PanelGroupId[]\n): GridDefinition[] {\n const layouts: GridDefinition[] = [];\n panelGroupOrder.map((groupOrderId) => {\n const group = panelGroups[groupOrderId];\n if (group === undefined) {\n throw new Error('panel group not found');\n }\n const { title, isCollapsed, itemLayouts, itemPanelKeys } = group;\n let display = undefined;\n if (title) {\n display = {\n title,\n collapse: {\n open: !isCollapsed,\n },\n };\n }\n const layout: GridDefinition = {\n kind: 'Grid',\n spec: {\n display,\n items: itemLayouts.map((layout) => {\n const panelKey = itemPanelKeys[layout.i];\n if (panelKey === undefined) {\n throw new Error(`Missing panel key of layout ${layout.i}`);\n }\n return {\n x: layout.x,\n y: layout.y,\n width: layout.w,\n height: layout.h,\n content: createPanelRef(panelKey),\n };\n }),\n },\n };\n layouts.push(layout);\n });\n\n return layouts;\n}\n"],"names":["createPanelRef","useDashboardStore","useTemplateVariableActions","useTemplateVariableDefinitions","useDashboard","panels","panelGroups","panelGroupOrder","setDashboard","setDashboardResource","metadata","display","duration","setVariableDefinitions","variables","layouts","convertPanelGroupsToLayouts","dashboard","kind","spec","dashboardResource","map","groupOrderId","group","undefined","Error","title","isCollapsed","itemLayouts","itemPanelKeys","collapse","open","layout","items","panelKey","i","x","y","width","w","height","h","content","push"],"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,cAAc,QAA2C,kBAAkB,CAAC;AACrF,SAA6CC,iBAAiB,QAAQ,qBAAqB,CAAC;AAC5F,SAASC,0BAA0B,EAAEC,8BAA8B,QAAQ,4BAA4B,CAAC;AAExG,OAAO,SAASC,YAAY,GAAG;IAC7B,MAAM,EACJC,MAAM,CAAA,EACNC,WAAW,CAAA,EACXC,eAAe,CAAA,EACfC,YAAY,EAAEC,oBAAoB,CAAA,EAClCC,QAAQ,CAAA,EACRC,OAAO,CAA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C,KAAK,CAAA,EAAEC,WAAW,CAAA,EAAEC,WAAW,CAAA,EAAEC,aAAa,CAAA,EAAE,GAAGN,KAAK,AAAC;QACjE,IAAIZ,OAAO,GAAGa,SAAS,AAAC;QACxB,IAAIE,KAAK,EAAE;YACTf,OAAO,GAAG;gBACRe,KAAK;gBACLI,QAAQ,EAAE;oBACRC,IAAI,EAAE,CAACJ,WAAW;iBACnB;aACF,CAAC;QACJ,CAAC;QACD,MAAMK,MAAM,GAAmB;YAC7Bd,IAAI,EAAE,MAAM;YACZC,IAAI,EAAE;gBACJR,OAAO;gBACPsB,KAAK,EAAEL,WAAW,CAACP,GAAG,CAAC,CAACW,MAAM,GAAK;oBACjC,MAAME,QAAQ,GAAGL,aAAa,CAACG,MAAM,CAACG,CAAC,CAAC,AAAC;oBACzC,IAAID,QAAQ,KAAKV,SAAS,EAAE;wBAC1B,MAAM,IAAIC,KAAK,CAAC,CAAC,4BAA4B,EAAEO,MAAM,CAACG,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC7D,CAAC;oBACD,OAAO;wBACLC,CAAC,EAAEJ,MAAM,CAACI,CAAC;wBACXC,CAAC,EAAEL,MAAM,CAACK,CAAC;wBACXC,KAAK,EAAEN,MAAM,CAACO,CAAC;wBACfC,MAAM,EAAER,MAAM,CAACS,CAAC;wBAChBC,OAAO,EAAE1C,cAAc,CAACkC,QAAQ,CAAC;qBAClC,CAAC;gBACJ,CAAC,CAAC;aACH;SACF,AAAC;QACFnB,OAAO,CAAC4B,IAAI,CAACX,MAAM,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,OAAOjB,OAAO,CAAC;AACjB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/stories/decorators/WithDashboard.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 { StoryFn, StoryContext } from '@storybook/react';\nimport { DashboardProvider, DashboardProviderProps } from '@perses-dev/dashboards';\nimport { EMPTY_DASHBOARD_RESOURCE } from './constants';\n\nexport type WithDashboardParameter = {\n props: Partial<DashboardProviderProps>;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithDashboardParameter(parameter: unknown | WithDashboardParameter): parameter is WithDashboardParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithDashboard = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withDashboard;\n const parameter = isWithDashboardParameter(initParameter) ? initParameter : undefined;\n const props = parameter?.props;\n\n return (\n <DashboardProvider initialState={{ dashboardResource: EMPTY_DASHBOARD_RESOURCE }} {...props}>\n <Story />\n </DashboardProvider>\n );\n};\n"],"names":["DashboardProvider","EMPTY_DASHBOARD_RESOURCE","isWithDashboardParameter","parameter","WithDashboard","Story","context","initParameter","parameters","withDashboard","undefined","props","initialState","dashboardResource"],"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;AACA,SAASA,iBAAiB,QAAgC,wBAAwB,CAAC;AACnF,SAASC,wBAAwB,QAAQ,aAAa,CAAC;AAMvD,yDAAyD;AACzD,SAASC,wBAAwB,CAACC,SAA2C,EAAuC;IAClH,OAAO,CAAC,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,OAAO,IAAIA,SAAS,CAAC;AAC9E,CAAC;AAED,OAAO,MAAMC,aAAa,GAAG,CAACC,KAAc,EAAEC,OAA8B,GAAK;IAC/E,MAAMC,aAAa,GAAGD,OAAO,CAACE,UAAU,CAACC,aAAa,AAAC;IACvD,MAAMN,SAAS,GAAGD,wBAAwB,CAACK,aAAa,CAAC,GAAGA,aAAa,GAAGG,SAAS,AAAC;IACtF,MAAMC,KAAK,GAAGR,SAAS,aAATA,SAAS,WAAO,GAAhBA,KAAAA,CAAgB,GAAhBA,SAAS,CAAEQ,KAAK,AAAC;IAE/B,qBACE,KAACX,iBAAiB;QAACY,YAAY,EAAE;YAAEC,iBAAiB,EAAEZ,wBAAwB;SAAE;QAAG,GAAGU,KAAK;kBACzF,cAAA,KAACN,KAAK,KAAG;MACS,CACpB;AACJ,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/stories/decorators/WithDashboard.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 { StoryFn, StoryContext } from '@storybook/react';\nimport { DashboardProvider, DashboardProviderProps } from '@perses-dev/dashboards';\nimport { EMPTY_DASHBOARD_RESOURCE } from './constants';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withDashboard?: WithDashboardParameter;\n }\n}\n\nexport type WithDashboardParameter = {\n props: Partial<DashboardProviderProps>;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithDashboardParameter(parameter: unknown | WithDashboardParameter): parameter is WithDashboardParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithDashboard = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withDashboard;\n const parameter = isWithDashboardParameter(initParameter) ? initParameter : undefined;\n const props = parameter?.props;\n\n return (\n <DashboardProvider initialState={{ dashboardResource: EMPTY_DASHBOARD_RESOURCE }} {...props}>\n <Story />\n </DashboardProvider>\n );\n};\n"],"names":["DashboardProvider","EMPTY_DASHBOARD_RESOURCE","isWithDashboardParameter","parameter","WithDashboard","Story","context","initParameter","parameters","withDashboard","undefined","props","initialState","dashboardResource"],"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;AACA,SAASA,iBAAiB,QAAgC,wBAAwB,CAAC;AACnF,SAASC,wBAAwB,QAAQ,aAAa,CAAC;AAYvD,yDAAyD;AACzD,SAASC,wBAAwB,CAACC,SAA2C,EAAuC;IAClH,OAAO,CAAC,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,OAAO,IAAIA,SAAS,CAAC;AAC9E,CAAC;AAED,OAAO,MAAMC,aAAa,GAAG,CAACC,KAAc,EAAEC,OAA8B,GAAK;IAC/E,MAAMC,aAAa,GAAGD,OAAO,CAACE,UAAU,CAACC,aAAa,AAAC;IACvD,MAAMN,SAAS,GAAGD,wBAAwB,CAACK,aAAa,CAAC,GAAGA,aAAa,GAAGG,SAAS,AAAC;IACtF,MAAMC,KAAK,GAAGR,SAAS,aAATA,SAAS,WAAO,GAAhBA,KAAAA,CAAgB,GAAhBA,SAAS,CAAEQ,KAAK,AAAC;IAE/B,qBACE,KAACX,iBAAiB;QAACY,YAAY,EAAE;YAAEC,iBAAiB,EAAEZ,wBAAwB;SAAE;QAAG,GAAGU,KAAK;kBACzF,cAAA,KAACN,KAAK,KAAG;MACS,CACpB;AACJ,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/stories/decorators/WithDatasourceStore.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 { StoryFn, StoryContext } from '@storybook/react';\nimport { DatasourceStoreProvider, DatasourceStoreProviderProps } from '@perses-dev/dashboards';\nimport { defaultDatasourceProps } from '../../test';\n\nexport type WithDatasourceStoreParameter = {\n props: Partial<DatasourceStoreProviderProps>;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithDatasourceStoreParameter(\n parameter: unknown | WithDatasourceStoreParameter\n): parameter is WithDatasourceStoreParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithDatasourceStore = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withDatasourceStore;\n const parameter = isWithDatasourceStoreParameter(initParameter) ? initParameter : undefined;\n const props = parameter?.props;\n\n return (\n <DatasourceStoreProvider {...defaultDatasourceProps} {...props}>\n <Story />\n </DatasourceStoreProvider>\n );\n};\n"],"names":["DatasourceStoreProvider","defaultDatasourceProps","isWithDatasourceStoreParameter","parameter","WithDatasourceStore","Story","context","initParameter","parameters","withDatasourceStore","undefined","props"],"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;AACA,SAASA,uBAAuB,QAAsC,wBAAwB,CAAC;AAC/F,SAASC,sBAAsB,QAAQ,YAAY,CAAC;AAMpD,yDAAyD;AACzD,SAASC,8BAA8B,CACrCC,SAAiD,EACN;IAC3C,OAAO,CAAC,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,OAAO,IAAIA,SAAS,CAAC;AAC9E,CAAC;AAED,OAAO,MAAMC,mBAAmB,GAAG,CAACC,KAAc,EAAEC,OAA8B,GAAK;IACrF,MAAMC,aAAa,GAAGD,OAAO,CAACE,UAAU,CAACC,mBAAmB,AAAC;IAC7D,MAAMN,SAAS,GAAGD,8BAA8B,CAACK,aAAa,CAAC,GAAGA,aAAa,GAAGG,SAAS,AAAC;IAC5F,MAAMC,KAAK,GAAGR,SAAS,aAATA,SAAS,WAAO,GAAhBA,KAAAA,CAAgB,GAAhBA,SAAS,CAAEQ,KAAK,AAAC;IAE/B,qBACE,KAACX,uBAAuB;QAAE,GAAGC,sBAAsB;QAAG,GAAGU,KAAK;kBAC5D,cAAA,KAACN,KAAK,KAAG;MACe,CAC1B;AACJ,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/stories/decorators/WithDatasourceStore.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 { StoryFn, StoryContext } from '@storybook/react';\nimport { DatasourceStoreProvider, DatasourceStoreProviderProps } from '@perses-dev/dashboards';\nimport { defaultDatasourceProps } from '../../test';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withDatasourceStore?: WithDatasourceStoreParameter;\n }\n}\n\nexport type WithDatasourceStoreParameter = {\n props: Partial<DatasourceStoreProviderProps>;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithDatasourceStoreParameter(\n parameter: unknown | WithDatasourceStoreParameter\n): parameter is WithDatasourceStoreParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithDatasourceStore = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withDatasourceStore;\n const parameter = isWithDatasourceStoreParameter(initParameter) ? initParameter : undefined;\n const props = parameter?.props;\n\n return (\n <DatasourceStoreProvider {...defaultDatasourceProps} {...props}>\n <Story />\n </DatasourceStoreProvider>\n );\n};\n"],"names":["DatasourceStoreProvider","defaultDatasourceProps","isWithDatasourceStoreParameter","parameter","WithDatasourceStore","Story","context","initParameter","parameters","withDatasourceStore","undefined","props"],"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;AACA,SAASA,uBAAuB,QAAsC,wBAAwB,CAAC;AAC/F,SAASC,sBAAsB,QAAQ,YAAY,CAAC;AAYpD,yDAAyD;AACzD,SAASC,8BAA8B,CACrCC,SAAiD,EACN;IAC3C,OAAO,CAAC,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,OAAO,IAAIA,SAAS,CAAC;AAC9E,CAAC;AAED,OAAO,MAAMC,mBAAmB,GAAG,CAACC,KAAc,EAAEC,OAA8B,GAAK;IACrF,MAAMC,aAAa,GAAGD,OAAO,CAACE,UAAU,CAACC,mBAAmB,AAAC;IAC7D,MAAMN,SAAS,GAAGD,8BAA8B,CAACK,aAAa,CAAC,GAAGA,aAAa,GAAGG,SAAS,AAAC;IAC5F,MAAMC,KAAK,GAAGR,SAAS,aAATA,SAAS,WAAO,GAAhBA,KAAAA,CAAgB,GAAhBA,SAAS,CAAEQ,KAAK,AAAC;IAE/B,qBACE,KAACX,uBAAuB;QAAE,GAAGC,sBAAsB;QAAG,GAAGU,KAAK;kBAC5D,cAAA,KAACN,KAAK,KAAG;MACe,CAC1B;AACJ,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/stories/decorators/WithTemplateVariables.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 { StoryFn, StoryContext } from '@storybook/react';\nimport { TemplateVariableProvider, TemplateVariableProviderProps } from '@perses-dev/dashboards';\n\nexport type WithTemplateVariableParameter = {\n props: Partial<TemplateVariableProviderProps>;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithTemplateVariableParameter(\n parameter: unknown | WithTemplateVariableParameter\n): parameter is WithTemplateVariableParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithTemplateVariables = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withTemplateVariables;\n const parameter = isWithTemplateVariableParameter(initParameter) ? initParameter : undefined;\n const props = parameter?.props;\n\n return (\n <TemplateVariableProvider {...props}>\n <Story />\n </TemplateVariableProvider>\n );\n};\n"],"names":["TemplateVariableProvider","isWithTemplateVariableParameter","parameter","WithTemplateVariables","Story","context","initParameter","parameters","withTemplateVariables","undefined","props"],"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;AACA,SAASA,wBAAwB,QAAuC,wBAAwB,CAAC;AAMjG,yDAAyD;AACzD,SAASC,+BAA+B,CACtCC,SAAkD,EACN;IAC5C,OAAO,CAAC,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,OAAO,IAAIA,SAAS,CAAC;AAC9E,CAAC;AAED,OAAO,MAAMC,qBAAqB,GAAG,CAACC,KAAc,EAAEC,OAA8B,GAAK;IACvF,MAAMC,aAAa,GAAGD,OAAO,CAACE,UAAU,CAACC,qBAAqB,AAAC;IAC/D,MAAMN,SAAS,GAAGD,+BAA+B,CAACK,aAAa,CAAC,GAAGA,aAAa,GAAGG,SAAS,AAAC;IAC7F,MAAMC,KAAK,GAAGR,SAAS,aAATA,SAAS,WAAO,GAAhBA,KAAAA,CAAgB,GAAhBA,SAAS,CAAEQ,KAAK,AAAC;IAE/B,qBACE,KAACV,wBAAwB;QAAE,GAAGU,KAAK;kBACjC,cAAA,KAACN,KAAK,KAAG;MACgB,CAC3B;AACJ,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/stories/decorators/WithTemplateVariables.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 { StoryFn, StoryContext } from '@storybook/react';\nimport { TemplateVariableProvider, TemplateVariableProviderProps } from '@perses-dev/dashboards';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withTemplateVariables?: WithTemplateVariableParameter;\n }\n}\n\nexport type WithTemplateVariableParameter = {\n props: Partial<TemplateVariableProviderProps>;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithTemplateVariableParameter(\n parameter: unknown | WithTemplateVariableParameter\n): parameter is WithTemplateVariableParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithTemplateVariables = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withTemplateVariables;\n const parameter = isWithTemplateVariableParameter(initParameter) ? initParameter : undefined;\n const props = parameter?.props;\n\n return (\n <TemplateVariableProvider {...props}>\n <Story />\n </TemplateVariableProvider>\n );\n};\n"],"names":["TemplateVariableProvider","isWithTemplateVariableParameter","parameter","WithTemplateVariables","Story","context","initParameter","parameters","withTemplateVariables","undefined","props"],"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;AACA,SAASA,wBAAwB,QAAuC,wBAAwB,CAAC;AAYjG,yDAAyD;AACzD,SAASC,+BAA+B,CACtCC,SAAkD,EACN;IAC5C,OAAO,CAAC,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,OAAO,IAAIA,SAAS,CAAC;AAC9E,CAAC;AAED,OAAO,MAAMC,qBAAqB,GAAG,CAACC,KAAc,EAAEC,OAA8B,GAAK;IACvF,MAAMC,aAAa,GAAGD,OAAO,CAACE,UAAU,CAACC,qBAAqB,AAAC;IAC/D,MAAMN,SAAS,GAAGD,+BAA+B,CAACK,aAAa,CAAC,GAAGA,aAAa,GAAGG,SAAS,AAAC;IAC7F,MAAMC,KAAK,GAAGR,SAAS,aAATA,SAAS,WAAO,GAAhBA,KAAAA,CAAgB,GAAhBA,SAAS,CAAEQ,KAAK,AAAC;IAE/B,qBACE,KAACV,wBAAwB;QAAE,GAAGU,KAAK;kBACjC,cAAA,KAACN,KAAK,KAAG;MACgB,CAC3B;AACJ,CAAC,CAAC"}
@@ -12,12 +12,7 @@
12
12
  // limitations under the License.
13
13
  export * from './constants';
14
14
  export * from './WithDashboard';
15
- export * from './WithDataQueriesProvider';
16
15
  export * from './WithDatasourceStore';
17
- export * from './WithPluginRegistry';
18
- export * from './WithQueryClient';
19
- export * from './WithQueryParams';
20
16
  export * from './WithTemplateVariables';
21
- export * from './WithTimeRange';
22
17
 
23
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/stories/decorators/index.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 * from './constants';\nexport * from './WithDashboard';\nexport * from './WithDataQueriesProvider';\nexport * from './WithDatasourceStore';\nexport * from './WithPluginRegistry';\nexport * from './WithQueryClient';\nexport * from './WithQueryParams';\nexport * from './WithTemplateVariables';\nexport * from './WithTimeRange';\n"],"names":[],"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,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"sources":["../../../src/stories/decorators/index.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 * from './constants';\nexport * from './WithDashboard';\nexport * from './WithDatasourceStore';\nexport * from './WithTemplateVariables';\n"],"names":[],"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,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardApp.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAQL,mBAAmB,EAEpB,MAAM,kBAAkB,CAAC;AAG1B,MAAM,WAAW,iBAAiB;IAChC,mBAAmB,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACnD,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,uBAAuB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IAEtC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACnE,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAChD,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,YAAY,UAAW,iBAAiB,gBAuFpD,CAAC"}
1
+ {"version":3,"file":"DashboardApp.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAQL,mBAAmB,EAGpB,MAAM,kBAAkB,CAAC;AAG1B,MAAM,WAAW,iBAAiB;IAChC,mBAAmB,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACnD,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,uBAAuB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IAEtC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACnE,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAChD,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,YAAY,UAAW,iBAAiB,gBAwFpD,CAAC"}
@@ -14,7 +14,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { useState } from 'react';
15
15
  import { Box } from '@mui/material';
16
16
  import { ErrorAlert, ErrorBoundary } from '@perses-dev/components';
17
- import { PanelDrawer, Dashboard, PanelGroupDialog, DeletePanelGroupDialog, DiscardChangesConfirmationDialog, DashboardToolbar, DeletePanelDialog, EditJsonDialog } from '../../components';
17
+ import { PanelDrawer, Dashboard, PanelGroupDialog, DeletePanelGroupDialog, DiscardChangesConfirmationDialog, DashboardToolbar, DeletePanelDialog, EditJsonDialog, SaveChangesConfirmationDialog } from '../../components';
18
18
  import { useDashboard, useDiscardChangesConfirmationDialog, useEditMode } from '../../context';
19
19
  export const DashboardApp = (props)=>{
20
20
  const { dashboardResource , dashboardTitleComponent , emptyDashboardProps , onSave , onDiscard , initialVariableIsSticky , isReadonly , } = props;
@@ -90,7 +90,8 @@ export const DashboardApp = (props)=>{
90
90
  /*#__PURE__*/ _jsx(DeletePanelGroupDialog, {}),
91
91
  /*#__PURE__*/ _jsx(DeletePanelDialog, {}),
92
92
  /*#__PURE__*/ _jsx(DiscardChangesConfirmationDialog, {}),
93
- /*#__PURE__*/ _jsx(EditJsonDialog, {})
93
+ /*#__PURE__*/ _jsx(EditJsonDialog, {}),
94
+ /*#__PURE__*/ _jsx(SaveChangesConfirmationDialog, {})
94
95
  ]
95
96
  })
96
97
  ]
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/views/ViewDashboard/DashboardApp.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 { useState } from 'react';\nimport { Box } from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { DashboardResource } from '@perses-dev/core';\nimport {\n PanelDrawer,\n Dashboard,\n PanelGroupDialog,\n DeletePanelGroupDialog,\n DiscardChangesConfirmationDialog,\n DashboardToolbar,\n DeletePanelDialog,\n EmptyDashboardProps,\n EditJsonDialog,\n} from '../../components';\nimport { useDashboard, useDiscardChangesConfirmationDialog, useEditMode } from '../../context';\n\nexport interface DashboardAppProps {\n emptyDashboardProps?: Partial<EmptyDashboardProps>;\n dashboardResource: DashboardResource;\n dashboardTitleComponent?: JSX.Element;\n\n onSave?: (entity: DashboardResource) => Promise<DashboardResource>;\n onDiscard?: (entity: DashboardResource) => void;\n initialVariableIsSticky?: boolean;\n isReadonly: boolean;\n}\n\nexport const DashboardApp = (props: DashboardAppProps) => {\n const {\n dashboardResource,\n dashboardTitleComponent,\n emptyDashboardProps,\n onSave,\n onDiscard,\n initialVariableIsSticky,\n isReadonly,\n } = props;\n const { setEditMode } = useEditMode();\n const { dashboard, setDashboard } = useDashboard();\n const [originalDashboard, setOriginalDashboard] = useState<DashboardResource | undefined>(undefined);\n\n const { openDiscardChangesConfirmationDialog, closeDiscardChangesConfirmationDialog } =\n useDiscardChangesConfirmationDialog();\n\n const handleDiscardChanges = () => {\n // Reset to the original spec and exit edit mode\n if (originalDashboard) {\n setDashboard(originalDashboard);\n }\n setEditMode(false);\n closeDiscardChangesConfirmationDialog();\n if (onDiscard) {\n onDiscard(dashboard);\n }\n };\n\n const onEditButtonClick = () => {\n setEditMode(true);\n setOriginalDashboard(dashboard);\n };\n\n const onCancelButtonClick = () => {\n // check if dashboard has been modified\n if (JSON.stringify(dashboard) === JSON.stringify(originalDashboard)) {\n setEditMode(false);\n } else {\n openDiscardChangesConfirmationDialog({\n onDiscardChanges: () => {\n handleDiscardChanges();\n },\n onCancel: () => {\n closeDiscardChangesConfirmationDialog();\n },\n });\n }\n };\n\n return (\n <Box\n sx={{\n flexGrow: 1,\n overflowX: 'hidden',\n overflowY: 'auto',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n <DashboardToolbar\n dashboardName={dashboardResource.metadata.name}\n dashboardTitleComponent={dashboardTitleComponent}\n initialVariableIsSticky={initialVariableIsSticky}\n onSave={onSave}\n isReadonly={isReadonly}\n onEditButtonClick={onEditButtonClick}\n onCancelButtonClick={onCancelButtonClick}\n />\n <Box sx={{ padding: (theme) => theme.spacing(2), height: '100%' }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <Dashboard\n emptyDashboardProps={{\n onEditButtonClick,\n ...emptyDashboardProps,\n }}\n />\n </ErrorBoundary>\n <PanelDrawer />\n <PanelGroupDialog />\n <DeletePanelGroupDialog />\n <DeletePanelDialog />\n <DiscardChangesConfirmationDialog />\n <EditJsonDialog />\n </Box>\n </Box>\n );\n};\n"],"names":["useState","Box","ErrorAlert","ErrorBoundary","PanelDrawer","Dashboard","PanelGroupDialog","DeletePanelGroupDialog","DiscardChangesConfirmationDialog","DashboardToolbar","DeletePanelDialog","EditJsonDialog","useDashboard","useDiscardChangesConfirmationDialog","useEditMode","DashboardApp","props","dashboardResource","dashboardTitleComponent","emptyDashboardProps","onSave","onDiscard","initialVariableIsSticky","isReadonly","setEditMode","dashboard","setDashboard","originalDashboard","setOriginalDashboard","undefined","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","handleDiscardChanges","onEditButtonClick","onCancelButtonClick","JSON","stringify","onDiscardChanges","onCancel","sx","flexGrow","overflowX","overflowY","display","flexDirection","dashboardName","metadata","name","padding","theme","spacing","height","FallbackComponent"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,QAAQ,QAAQ,OAAO,CAAC;AACjC,SAASC,GAAG,QAAQ,eAAe,CAAC;AACpC,SAASC,UAAU,EAAEC,aAAa,QAAQ,wBAAwB,CAAC;AAEnE,SACEC,WAAW,EACXC,SAAS,EACTC,gBAAgB,EAChBC,sBAAsB,EACtBC,gCAAgC,EAChCC,gBAAgB,EAChBC,iBAAiB,EAEjBC,cAAc,QACT,kBAAkB,CAAC;AAC1B,SAASC,YAAY,EAAEC,mCAAmC,EAAEC,WAAW,QAAQ,eAAe,CAAC;AAa/F,OAAO,MAAMC,YAAY,GAAG,CAACC,KAAwB,GAAK;IACxD,MAAM,EACJC,iBAAiB,CAAA,EACjBC,uBAAuB,CAAA,EACvBC,mBAAmB,CAAA,EACnBC,MAAM,CAAA,EACNC,SAAS,CAAA,EACTC,uBAAuB,CAAA,EACvBC,UAAU,CAAA,IACX,GAAGP,KAAK,AAAC;IACV,MAAM,EAAEQ,WAAW,CAAA,EAAE,GAAGV,WAAW,EAAE,AAAC;IACtC,MAAM,EAAEW,SAAS,CAAA,EAAEC,Y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,gBAAgB;gBACfoC,aAAa,EAAE5B,iBAAiB,CAAC6B,QAAQ,CAACC,IAAI;gBAC9C7B,uBAAuB,EAAEA,uBAAuB;gBAChDI,uBAAuB,EAAEA,uBAAuB;gBAChDF,MAAM,EAAEA,MAAM;gBACdG,UAAU,EAAEA,UAAU;gBACtBU,iBAAiB,EAAEA,iBAAiB;gBACpCC,mBAAmB,EAAEA,mBAAmB;cACxC;0BACF,MAACjC,GAAG;gBAACsC,EAAE,EAAE;oBAAES,OAAO,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,OAAO,CAAC,CAAC,CAAC;oBAAEC,MAAM,EAAE,MAAM;iBAAE;;kCAC/D,KAAChD,aAAa;wBAACiD,iBAAiB,EAAElD,UAAU;kCAC1C,cAAA,KAACG,SAAS;4BACRc,mBAAmB,EAAE;gCACnBc,iBAAiB;gCACjB,GAAGd,mBAAmB;6BACvB;0BACD;sBACY;kCAChB,KAACf,WAAW,KAAG;kCACf,KAACE,gBAAgB,KAAG;kCACpB,KAACC,sBAAsB,KAAG;kCAC1B,KAACG,iBAAiB,KAAG;kCACrB,KAACF,gCAAgC,KAAG;kCACpC,KAACG,cAAc,KAAG;;cACd;;MACF,CACN;AACJ,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/views/ViewDashboard/DashboardApp.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 { useState } from 'react';\nimport { Box } from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { DashboardResource } from '@perses-dev/core';\nimport {\n PanelDrawer,\n Dashboard,\n PanelGroupDialog,\n DeletePanelGroupDialog,\n DiscardChangesConfirmationDialog,\n DashboardToolbar,\n DeletePanelDialog,\n EmptyDashboardProps,\n EditJsonDialog,\n SaveChangesConfirmationDialog,\n} from '../../components';\nimport { useDashboard, useDiscardChangesConfirmationDialog, useEditMode } from '../../context';\n\nexport interface DashboardAppProps {\n emptyDashboardProps?: Partial<EmptyDashboardProps>;\n dashboardResource: DashboardResource;\n dashboardTitleComponent?: JSX.Element;\n\n onSave?: (entity: DashboardResource) => Promise<DashboardResource>;\n onDiscard?: (entity: DashboardResource) => void;\n initialVariableIsSticky?: boolean;\n isReadonly: boolean;\n}\n\nexport const DashboardApp = (props: DashboardAppProps) => {\n const {\n dashboardResource,\n dashboardTitleComponent,\n emptyDashboardProps,\n onSave,\n onDiscard,\n initialVariableIsSticky,\n isReadonly,\n } = props;\n const { setEditMode } = useEditMode();\n const { dashboard, setDashboard } = useDashboard();\n const [originalDashboard, setOriginalDashboard] = useState<DashboardResource | undefined>(undefined);\n\n const { openDiscardChangesConfirmationDialog, closeDiscardChangesConfirmationDialog } =\n useDiscardChangesConfirmationDialog();\n\n const handleDiscardChanges = () => {\n // Reset to the original spec and exit edit mode\n if (originalDashboard) {\n setDashboard(originalDashboard);\n }\n setEditMode(false);\n closeDiscardChangesConfirmationDialog();\n if (onDiscard) {\n onDiscard(dashboard);\n }\n };\n\n const onEditButtonClick = () => {\n setEditMode(true);\n setOriginalDashboard(dashboard);\n };\n\n const onCancelButtonClick = () => {\n // check if dashboard has been modified\n if (JSON.stringify(dashboard) === JSON.stringify(originalDashboard)) {\n setEditMode(false);\n } else {\n openDiscardChangesConfirmationDialog({\n onDiscardChanges: () => {\n handleDiscardChanges();\n },\n onCancel: () => {\n closeDiscardChangesConfirmationDialog();\n },\n });\n }\n };\n\n return (\n <Box\n sx={{\n flexGrow: 1,\n overflowX: 'hidden',\n overflowY: 'auto',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n <DashboardToolbar\n dashboardName={dashboardResource.metadata.name}\n dashboardTitleComponent={dashboardTitleComponent}\n initialVariableIsSticky={initialVariableIsSticky}\n onSave={onSave}\n isReadonly={isReadonly}\n onEditButtonClick={onEditButtonClick}\n onCancelButtonClick={onCancelButtonClick}\n />\n <Box sx={{ padding: (theme) => theme.spacing(2), height: '100%' }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <Dashboard\n emptyDashboardProps={{\n onEditButtonClick,\n ...emptyDashboardProps,\n }}\n />\n </ErrorBoundary>\n <PanelDrawer />\n <PanelGroupDialog />\n <DeletePanelGroupDialog />\n <DeletePanelDialog />\n <DiscardChangesConfirmationDialog />\n <EditJsonDialog />\n <SaveChangesConfirmationDialog />\n </Box>\n </Box>\n );\n};\n"],"names":["useState","Box","ErrorAlert","ErrorBoundary","PanelDrawer","Dashboard","PanelGroupDialog","DeletePanelGroupDialog","DiscardChangesConfirmationDialog","DashboardToolbar","DeletePanelDialog","EditJsonDialog","SaveChangesConfirmationDialog","useDashboard","useDiscardChangesConfirmationDialog","useEditMode","DashboardApp","props","dashboardResource","dashboardTitleComponent","emptyDashboardProps","onSave","onDiscard","initialVariableIsSticky","isReadonly","setEditMode","dashboard","setDashboard","originalDashboard","setOriginalDashboard","undefined","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","handleDiscardChanges","onEditButtonClick","onCancelButtonClick","JSON","stringify","onDiscardChanges","onCancel","sx","flexGrow","overflowX","overflowY","display","flexDirection","dashboardName","metadata","name","padding","theme","spacing","height","FallbackComponent"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,QAAQ,QAAQ,OAAO,CAAC;AACjC,SAASC,GAAG,QAAQ,eAAe,CAAC;AACpC,SAASC,UAAU,EAAEC,aAAa,Q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1B,KAACG,iBAAiB,KAAG;kCACrB,KAACF,gCAAgC,KAAG;kCACpC,KAACG,cAAc,KAAG;kCAClB,KAACC,6BAA6B,KAAG;;cAC7B;;MACF,CACN;AACJ,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/dashboards",
3
- "version": "0.29.1",
3
+ "version": "0.31.0",
4
4
  "description": "The dashboards feature in Perses",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -29,9 +29,9 @@
29
29
  "lint:fix": "eslint --fix src --ext .ts,.tsx"
30
30
  },
31
31
  "dependencies": {
32
- "@perses-dev/components": "0.29.1",
33
- "@perses-dev/core": "0.29.1",
34
- "@perses-dev/plugin-system": "0.29.1",
32
+ "@perses-dev/components": "0.31.0",
33
+ "@perses-dev/core": "0.31.0",
34
+ "@perses-dev/plugin-system": "0.31.0",
35
35
  "@types/react-grid-layout": "^1.3.2",
36
36
  "date-fns": "^2.28.0",
37
37
  "immer": "^9.0.15",
@@ -44,8 +44,8 @@
44
44
  "zustand": "^4.3.3"
45
45
  },
46
46
  "devDependencies": {
47
- "@perses-dev/internal-utils": "0.29.1",
48
- "@perses-dev/storybook": "0.29.1",
47
+ "@perses-dev/internal-utils": "0.31.0",
48
+ "@perses-dev/storybook": "0.31.0",
49
49
  "intersection-observer": "^0.12.2"
50
50
  },
51
51
  "peerDependencies": {
@@ -1,39 +0,0 @@
1
- // Copyright 2023 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- Object.defineProperty(exports, "WithDataQueries", {
18
- enumerable: true,
19
- get: ()=>WithDataQueries
20
- });
21
- const _jsxRuntime = require("react/jsx-runtime");
22
- const _pluginSystem = require("@perses-dev/plugin-system");
23
- // Type guard because storybook types parameters as `any`
24
- function isWithDataQueriesParameter(parameter) {
25
- return !!parameter && typeof parameter === 'object' && 'props' in parameter;
26
- }
27
- const WithDataQueries = (Story, context)=>{
28
- const initParameter = context.parameters.WithDataQueries;
29
- const parameter = isWithDataQueriesParameter(initParameter) ? initParameter : {
30
- props: {
31
- definitions: []
32
- }
33
- };
34
- const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
35
- return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.DataQueriesProvider, {
36
- ...props,
37
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
38
- });
39
- };
@@ -1,94 +0,0 @@
1
- // Copyright 2023 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- Object.defineProperty(exports, "WithPluginRegistry", {
18
- enumerable: true,
19
- get: ()=>WithPluginRegistry
20
- });
21
- const _jsxRuntime = require("react/jsx-runtime");
22
- const _pluginSystem = require("@perses-dev/plugin-system");
23
- function _getRequireWildcardCache(nodeInterop) {
24
- if (typeof WeakMap !== "function") return null;
25
- var cacheBabelInterop = new WeakMap();
26
- var cacheNodeInterop = new WeakMap();
27
- return (_getRequireWildcardCache = function(nodeInterop) {
28
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
29
- })(nodeInterop);
30
- }
31
- function _interopRequireWildcard(obj, nodeInterop) {
32
- if (!nodeInterop && obj && obj.__esModule) {
33
- return obj;
34
- }
35
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
36
- return {
37
- default: obj
38
- };
39
- }
40
- var cache = _getRequireWildcardCache(nodeInterop);
41
- if (cache && cache.has(obj)) {
42
- return cache.get(obj);
43
- }
44
- var newObj = {};
45
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
46
- for(var key in obj){
47
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
48
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
49
- if (desc && (desc.get || desc.set)) {
50
- Object.defineProperty(newObj, key, desc);
51
- } else {
52
- newObj[key] = obj[key];
53
- }
54
- }
55
- }
56
- newObj.default = obj;
57
- if (cache) {
58
- cache.set(obj, newObj);
59
- }
60
- return newObj;
61
- }
62
- // NOTE: the aliases we use for components break these top level imports, so we
63
- // import relatively.
64
- // eslint-disable-next-line @typescript-eslint/no-var-requires
65
- const prometheusResource = require('../../../../prometheus-plugin/plugin.json');
66
- // eslint-disable-next-line @typescript-eslint/no-var-requires
67
- const panelsResource = require('../../../../panels-plugin/plugin.json');
68
- const bundledPluginLoader = (0, _pluginSystem.dynamicImportPluginLoader)([
69
- {
70
- resource: prometheusResource,
71
- // This throws an error in CI (but not locally for some reason), likely because
72
- // this package isn't a dependency for dashboards. We probably do not want to
73
- // make it one solely for type-checking in storybook.
74
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
75
- // @ts-ignore
76
- importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/ _interopRequireWildcard(require("@perses-dev/prometheus-plugin")))
77
- },
78
- {
79
- resource: panelsResource,
80
- // Same comment as above.
81
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
82
- // @ts-ignore
83
- importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/ _interopRequireWildcard(require("@perses-dev/panels-plugin")))
84
- }
85
- ]);
86
- const WithPluginRegistry = (Story)=>{
87
- return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.PluginRegistry, {
88
- pluginLoader: bundledPluginLoader,
89
- defaultPluginKinds: {
90
- TimeSeriesQuery: 'PrometheusTimeSeriesQuery'
91
- },
92
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
93
- });
94
- };
@@ -1,38 +0,0 @@
1
- // Copyright 2023 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- Object.defineProperty(exports, "WithTimeRange", {
18
- enumerable: true,
19
- get: ()=>WithTimeRange
20
- });
21
- const _jsxRuntime = require("react/jsx-runtime");
22
- const _pluginSystem = require("@perses-dev/plugin-system");
23
- // Type guard because storybook types parameters as `any`
24
- function isWithTimeRangeParameter(parameter) {
25
- return !!parameter && typeof parameter === 'object' && 'props' in parameter;
26
- }
27
- const WithTimeRange = (Story, context)=>{
28
- const initParameter = context.parameters.withTimeRange;
29
- const parameter = isWithTimeRangeParameter(initParameter) ? initParameter : undefined;
30
- const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
31
- return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.TimeRangeProvider, {
32
- initialTimeRange: {
33
- pastDuration: '1h'
34
- },
35
- ...props,
36
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
37
- });
38
- };
@@ -1,33 +0,0 @@
1
- // Copyright 2023 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- import { jsx as _jsx } from "react/jsx-runtime";
14
- import { DataQueriesProvider } from '@perses-dev/plugin-system';
15
- // Type guard because storybook types parameters as `any`
16
- function isWithDataQueriesParameter(parameter) {
17
- return !!parameter && typeof parameter === 'object' && 'props' in parameter;
18
- }
19
- export const WithDataQueries = (Story, context)=>{
20
- const initParameter = context.parameters.WithDataQueries;
21
- const parameter = isWithDataQueriesParameter(initParameter) ? initParameter : {
22
- props: {
23
- definitions: []
24
- }
25
- };
26
- const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
27
- return /*#__PURE__*/ _jsx(DataQueriesProvider, {
28
- ...props,
29
- children: /*#__PURE__*/ _jsx(Story, {})
30
- });
31
- };
32
-
33
- //# sourceMappingURL=WithDataQueriesProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/stories/decorators/WithDataQueriesProvider.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 { Definition, UnknownSpec } from '@perses-dev/core';\nimport { DataQueriesProvider, DataQueriesProviderProps } from '@perses-dev/plugin-system';\nimport { StoryFn, StoryContext } from '@storybook/react';\n\nexport type WithDataQueriesProvideParameter = {\n props: DataQueriesProviderProps;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithDataQueriesParameter(\n parameter: unknown | WithDataQueriesProvideParameter\n): parameter is WithDataQueriesProvideParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithDataQueries = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.WithDataQueries;\n const parameter = isWithDataQueriesParameter(initParameter)\n ? initParameter\n : { props: { definitions: [] as Array<Definition<UnknownSpec>> } };\n const props = parameter?.props;\n\n return (\n <DataQueriesProvider {...props}>\n <Story />\n </DataQueriesProvider>\n );\n};\n"],"names":["DataQueriesProvider","isWithDataQueriesParameter","parameter","WithDataQueries","Story","context","initParameter","parameters","props","definitions"],"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;AACA,SAASA,mBAAmB,QAAkC,2BAA2B,CAAC;AAO1F,yDAAyD;AACzD,SAASC,0BAA0B,CACjCC,SAAoD,EACN;IAC9C,OAAO,CAAC,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,OAAO,IAAIA,SAAS,CAAC;AAC9E,CAAC;AAED,OAAO,MAAMC,eAAe,GAAG,CAACC,KAAc,EAAEC,OAA8B,GAAK;IACjF,MAAMC,aAAa,GAAGD,OAAO,CAACE,UAAU,CAACJ,eAAe,AAAC;IACzD,MAAMD,SAAS,GAAGD,0BAA0B,CAACK,aAAa,CAAC,GACvDA,aAAa,GACb;QAAEE,KAAK,EAAE;YAAEC,WAAW,EAAE,EAAE;SAAoC;KAAE,AAAC;IACrE,MAAMD,KAAK,GAAGN,SAAS,aAATA,SAAS,WAAO,GAAhBA,KAAAA,CAAgB,GAAhBA,SAAS,CAAEM,KAAK,AAAC;IAE/B,qBACE,KAACR,mBAAmB;QAAE,GAAGQ,KAAK;kBAC5B,cAAA,KAACJ,KAAK,KAAG;MACW,CACtB;AACJ,CAAC,CAAC"}
@@ -1,49 +0,0 @@
1
- // Copyright 2023 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- import { jsx as _jsx } from "react/jsx-runtime";
14
- import { PluginRegistry, dynamicImportPluginLoader } from '@perses-dev/plugin-system';
15
- // NOTE: the aliases we use for components break these top level imports, so we
16
- // import relatively.
17
- // eslint-disable-next-line @typescript-eslint/no-var-requires
18
- const prometheusResource = require('../../../../prometheus-plugin/plugin.json');
19
- // eslint-disable-next-line @typescript-eslint/no-var-requires
20
- const panelsResource = require('../../../../panels-plugin/plugin.json');
21
- const bundledPluginLoader = dynamicImportPluginLoader([
22
- {
23
- resource: prometheusResource,
24
- // This throws an error in CI (but not locally for some reason), likely because
25
- // this package isn't a dependency for dashboards. We probably do not want to
26
- // make it one solely for type-checking in storybook.
27
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
28
- // @ts-ignore
29
- importPlugin: ()=>import('@perses-dev/prometheus-plugin')
30
- },
31
- {
32
- resource: panelsResource,
33
- // Same comment as above.
34
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
35
- // @ts-ignore
36
- importPlugin: ()=>import('@perses-dev/panels-plugin')
37
- }
38
- ]);
39
- export const WithPluginRegistry = (Story)=>{
40
- return /*#__PURE__*/ _jsx(PluginRegistry, {
41
- pluginLoader: bundledPluginLoader,
42
- defaultPluginKinds: {
43
- TimeSeriesQuery: 'PrometheusTimeSeriesQuery'
44
- },
45
- children: /*#__PURE__*/ _jsx(Story, {})
46
- });
47
- };
48
-
49
- //# sourceMappingURL=WithPluginRegistry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/stories/decorators/WithPluginRegistry.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 { StoryFn } from '@storybook/react';\nimport {\n PluginRegistry,\n PluginLoader,\n PluginModuleResource,\n dynamicImportPluginLoader,\n} from '@perses-dev/plugin-system';\n\n// NOTE: the aliases we use for components break these top level imports, so we\n// import relatively.\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst prometheusResource = require('../../../../prometheus-plugin/plugin.json');\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst panelsResource = require('../../../../panels-plugin/plugin.json');\n\nconst bundledPluginLoader: PluginLoader = dynamicImportPluginLoader([\n {\n resource: prometheusResource as PluginModuleResource,\n // This throws an error in CI (but not locally for some reason), likely because\n // this package isn't a dependency for dashboards. We probably do not want to\n // make it one solely for type-checking in storybook.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n importPlugin: () => import('@perses-dev/prometheus-plugin'),\n },\n {\n resource: panelsResource as PluginModuleResource,\n // Same comment as above.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n importPlugin: () => import('@perses-dev/panels-plugin'),\n },\n]);\n\nexport const WithPluginRegistry = (Story: StoryFn) => {\n return (\n <PluginRegistry\n pluginLoader={bundledPluginLoader}\n defaultPluginKinds={{ TimeSeriesQuery: 'PrometheusTimeSeriesQuery' }}\n >\n <Story />\n </PluginRegistry>\n );\n};\n"],"names":["PluginRegistry","dynamicImportPluginLoader","prometheusResource","require","panelsResource","bundledPluginLoader","resource","importPlugin","WithPluginRegistry","Story","pluginLoader","defaultPluginKinds","TimeSeriesQuery"],"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;AACA,SACEA,cAAc,EAGdC,yBAAyB,QACpB,2BAA2B,CAAC;AAEnC,+EAA+E;AAC/E,qBAAqB;AACrB,8DAA8D;AAC9D,MAAMC,kBAAkB,GAAGC,OAAO,CAAC,2CAA2C,CAAC,AAAC;AAChF,8DAA8D;AAC9D,MAAMC,cAAc,GAAGD,OAAO,CAAC,uCAAuC,CAAC,AAAC;AAExE,MAAME,mBAAmB,GAAiBJ,yBAAyB,CAAC;IAClE;QACEK,QAAQ,EAAEJ,kBAAkB;QAC5B,+EAA+E;QAC/E,6EAA6E;QAC7E,qDAAqD;QACrD,6DAA6D;QAC7D,aAAa;QACbK,YAAY,EAAE,IAAM,MAAM,CAAC,+BAA+B,CAAC;KAC5D;IACD;QACED,QAAQ,EAAEF,cAAc;QACxB,yBAAyB;QACzB,6DAA6D;QAC7D,aAAa;QACbG,YAAY,EAAE,IAAM,MAAM,CAAC,2BAA2B,CAAC;KACxD;CACF,CAAC,AAAC;AAEH,OAAO,MAAMC,kBAAkB,GAAG,CAACC,KAAc,GAAK;IACpD,qBACE,KAACT,cAAc;QACbU,YAAY,EAAEL,mBAAmB;QACjCM,kBAAkB,EAAE;YAAEC,eAAe,EAAE,2BAA2B;SAAE;kBAEpE,cAAA,KAACH,KAAK,KAAG;MACM,CACjB;AACJ,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/stories/decorators/WithQueryClient.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 { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { StoryFn } from '@storybook/react';\n\nexport const WithQueryClient = (Story: StoryFn) => {\n const queryClient = new QueryClient({});\n\n return (\n <QueryClientProvider client={queryClient}>\n <Story />\n </QueryClientProvider>\n );\n};\n"],"names":["QueryClient","QueryClientProvider","WithQueryClient","Story","queryClient","client"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,WAAW,EAAEC,mBAAmB,QAAQ,uBAAuB,CAAC;AAGzE,OAAO,MAAMC,eAAe,GAAG,CAACC,KAAc,GAAK;IACjD,MAAMC,WAAW,GAAG,IAAIJ,WAAW,CAAC,EAAE,CAAC,AAAC;IAExC,qBACE,KAACC,mBAAmB;QAACI,MAAM,EAAED,WAAW;kBACtC,cAAA,KAACD,KAAK,KAAG;MACW,CACtB;AACJ,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/stories/decorators/WithQueryParams.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 { WindowHistoryAdapter } from 'use-query-params/adapters/window';\nimport { QueryParamProvider } from 'use-query-params';\nimport { StoryFn } from '@storybook/react';\n\nexport const WithQueryParams = (Story: StoryFn) => {\n return (\n <QueryParamProvider adapter={WindowHistoryAdapter}>\n <Story />\n </QueryParamProvider>\n );\n};\n"],"names":["WindowHistoryAdapter","QueryParamProvider","WithQueryParams","Story","adapter"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,oBAAoB,QAAQ,kCAAkC,CAAC;AACxE,SAASC,kBAAkB,QAAQ,kBAAkB,CAAC;AAGtD,OAAO,MAAMC,eAAe,GAAG,CAACC,KAAc,GAAK;IACjD,qBACE,KAACF,kBAAkB;QAACG,OAAO,EAAEJ,oBAAoB;kBAC/C,cAAA,KAACG,KAAK,KAAG;MACU,CACrB;AACJ,CAAC,CAAC"}