@perses-dev/dashboards 0.17.0 → 0.19.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 (87) hide show
  1. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +49 -32
  2. package/dist/cjs/components/GridLayout/GridContainer.js +2 -2
  3. package/dist/cjs/components/GridLayout/GridTitle.js +1 -1
  4. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +2 -1
  5. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +28 -5
  6. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +11 -5
  7. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +17 -2
  8. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +5 -4
  9. package/dist/cjs/components/Variables/VariableList.js +3 -0
  10. package/dist/cjs/components/Variables/variable-model.js +38 -6
  11. package/dist/cjs/components/Variables/variable-model.test.js +106 -0
  12. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +0 -2
  13. package/dist/cjs/context/TemplateVariableProvider/query-params.js +3 -1
  14. package/dist/cjs/context/index.js +0 -1
  15. package/dist/cjs/views/ViewDashboard/DashboardApp.js +2 -1
  16. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +6 -4
  17. package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +4 -2
  18. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +1 -0
  19. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  20. package/dist/components/DashboardToolbar/DashboardToolbar.js +50 -33
  21. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  22. package/dist/components/GridLayout/GridContainer.js +2 -2
  23. package/dist/components/GridLayout/GridContainer.js.map +1 -1
  24. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  25. package/dist/components/GridLayout/GridTitle.js +1 -1
  26. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  27. package/dist/components/PanelDrawer/PanelDrawer.js +2 -1
  28. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  29. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  30. package/dist/components/TimeRangeControls/TimeRangeControls.js +24 -7
  31. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  32. package/dist/components/TimeRangeControls/TimeRangeControls.test.js +11 -5
  33. package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -1
  34. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  35. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +17 -2
  36. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  37. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +1 -0
  38. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
  39. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +5 -4
  40. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  41. package/dist/components/Variables/VariableList.d.ts +2 -0
  42. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  43. package/dist/components/Variables/VariableList.js +3 -0
  44. package/dist/components/Variables/VariableList.js.map +1 -1
  45. package/dist/components/Variables/variable-model.d.ts +3 -2
  46. package/dist/components/Variables/variable-model.d.ts.map +1 -1
  47. package/dist/components/Variables/variable-model.js +38 -7
  48. package/dist/components/Variables/variable-model.js.map +1 -1
  49. package/dist/components/Variables/variable-model.test.d.ts +2 -0
  50. package/dist/components/Variables/variable-model.test.d.ts.map +1 -0
  51. package/dist/components/Variables/variable-model.test.js +104 -0
  52. package/dist/components/Variables/variable-model.test.js.map +1 -0
  53. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
  54. package/dist/context/DashboardProvider/panel-editor-slice.js +0 -2
  55. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  56. package/dist/context/TemplateVariableProvider/query-params.js +3 -1
  57. package/dist/context/TemplateVariableProvider/query-params.js.map +1 -1
  58. package/dist/context/index.d.ts +0 -1
  59. package/dist/context/index.d.ts.map +1 -1
  60. package/dist/context/index.js +0 -1
  61. package/dist/context/index.js.map +1 -1
  62. package/dist/views/ViewDashboard/DashboardApp.d.ts +1 -0
  63. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  64. package/dist/views/ViewDashboard/DashboardApp.js +2 -1
  65. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  66. package/dist/views/ViewDashboard/ViewDashboard.d.ts +1 -0
  67. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  68. package/dist/views/ViewDashboard/ViewDashboard.js +5 -3
  69. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  70. package/dist/views/ViewDashboard/tests/panelGroups.test.js +4 -2
  71. package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -1
  72. package/package.json +5 -5
  73. package/dist/cjs/context/TimeRangeProvider/TimeRangeProvider.js +0 -91
  74. package/dist/cjs/context/TimeRangeProvider/index.js +0 -29
  75. package/dist/cjs/context/TimeRangeProvider/query-params.js +0 -157
  76. package/dist/context/TimeRangeProvider/TimeRangeProvider.d.ts +0 -19
  77. package/dist/context/TimeRangeProvider/TimeRangeProvider.d.ts.map +0 -1
  78. package/dist/context/TimeRangeProvider/TimeRangeProvider.js +0 -44
  79. package/dist/context/TimeRangeProvider/TimeRangeProvider.js.map +0 -1
  80. package/dist/context/TimeRangeProvider/index.d.ts +0 -3
  81. package/dist/context/TimeRangeProvider/index.d.ts.map +0 -1
  82. package/dist/context/TimeRangeProvider/index.js +0 -16
  83. package/dist/context/TimeRangeProvider/index.js.map +0 -1
  84. package/dist/context/TimeRangeProvider/query-params.d.ts +0 -25
  85. package/dist/context/TimeRangeProvider/query-params.d.ts.map +0 -1
  86. package/dist/context/TimeRangeProvider/query-params.js +0 -149
  87. package/dist/context/TimeRangeProvider/query-params.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/Variables/variable-model.test.ts"],"sourcesContent":["// Copyright 2022 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 { VariableOption } from '@perses-dev/plugin-system';\nimport { filterVariableList } from './variable-model';\n\ndescribe('filterVariableList', () => {\n const testSuite = [\n {\n title: 'basic case',\n capturing_regexp: /([^-]*)-host-([^-]*)/g,\n originalValues: [\n { label: 'l1', value: 'us1-host-ahdix' },\n { label: 'l2', value: 'us1-host-diua' },\n { label: 'l3', value: 'eu1-host-adf' },\n { label: 'l4', value: 'bar' },\n ] as VariableOption[],\n result: [\n { label: 'l1', value: 'us1ahdix' },\n { label: 'l2', value: 'us1diua' },\n { label: 'l3', value: 'eu1adf' },\n ],\n },\n {\n title: 'duplicate captured value',\n capturing_regexp: /prometheus-(.+):\\d+/g,\n originalValues: [\n { label: 'l1', value: 'prometheus-app:9090' },\n { label: 'l2', value: 'prometheus-app:9091' },\n { label: 'l3', value: 'prometheus-platform:9091' },\n { label: 'l4', value: 'prometheus-database:9091' },\n { label: 'l5', value: 'prometheus-perses:9091' },\n ] as VariableOption[],\n result: [\n { label: 'l1', value: 'app' },\n { label: 'l3', value: 'platform' },\n { label: 'l4', value: 'database' },\n { label: 'l5', value: 'perses' },\n ],\n },\n ];\n testSuite.forEach(({ title, capturing_regexp, originalValues, result }) => {\n it(title, () => {\n expect(filterVariableList(originalValues, capturing_regexp)).toEqual(result);\n });\n });\n});\n"],"names":["filterVariableList","describe","testSuite","title","capturing_regexp","originalValues","label","value","result","forEach","it","expect","toEqual"],"mappings":"AAAA,o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I;oBAAEC,KAAK,EAAE,wBAAwB;iBAAE;aACjD;YACDC,MAAM,EAAE;gBACN;oBAAEF,KAAK,EAAE,IAAI;oBAAEC,KAAK,EAAE,KAAK;iBAAE;gBAC7B;oBAAED,KAAK,EAAE,IAAI;oBAAEC,KAAK,EAAE,UAAU;iBAAE;gBAClC;oBAAED,KAAK,EAAE,IAAI;oBAAEC,KAAK,EAAE,UAAU;iBAAE;gBAClC;oBAAED,KAAK,EAAE,IAAI;oBAAEC,KAAK,EAAE,QAAQ;iBAAE;aACjC;SACF;KACF,AAAC;IACFL,SAAS,CAACO,OAAO,CAAC,CAAC,EAAEN,KAAK,CAAA,EAAEC,gBAAgB,CAAA,EAAEC,cAAc,CAAA,EAAEG,MAAM,CAAA,EAAE,GAAK;QACzEE,EAAE,CAACP,KAAK,EAAE,IAAM;YACdQ,MAAM,CAACX,kBAAkB,CAACK,cAAc,EAAED,gBAAgB,CAAC,CAAC,CAACQ,OAAO,CAACJ,MAAM,CAAC,CAAC;QAC/E,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"panel-editor-slice.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/panel-editor-slice.ts"],"names":[],"mappings":"AAaA,OAAO,EAAmB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAc,UAAU,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,YAAY,EAKb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAE/B;;OAEG;IACH,aAAa,EAAE,CAAC,gBAAgB,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAE5D;;OAEG;IACH,YAAY,EAAE,CAAC,YAAY,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;CACrD;AAED,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;IAErB;;OAEG;IACH,aAAa,EAAE,iBAAiB,CAAC;IAEjC;;OAEG;IACH,YAAY,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAEhD;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,YAAY,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,WAAW,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,YAAY,CAEpD,gBAAgB,GAAG,UAAU,GAAG,eAAe,EAC/C,UAAU,EACV;CAAE,EACF,gBAAgB,CACjB,CAyJA"}
1
+ {"version":3,"file":"panel-editor-slice.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/panel-editor-slice.ts"],"names":[],"mappings":"AAaA,OAAO,EAAmB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAc,UAAU,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,YAAY,EAKb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAE/B;;OAEG;IACH,aAAa,EAAE,CAAC,gBAAgB,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAE5D;;OAEG;IACH,YAAY,EAAE,CAAC,YAAY,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;CACrD;AAED,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;IAErB;;OAEG;IACH,aAAa,EAAE,iBAAiB,CAAC;IAEjC;;OAEG;IACH,YAAY,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAEhD;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,YAAY,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,WAAW,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,YAAY,CAEpD,gBAAgB,GAAG,UAAU,GAAG,eAAe,EAC/C,UAAU,EACV;CAAE,EACF,gBAAgB,CACjB,CAuJA"}
@@ -107,8 +107,6 @@ import { addPanelGroup, createEmptyPanelGroup } from './panel-group-slice';
107
107
  name: '',
108
108
  description: '',
109
109
  groupId: panelGroupId,
110
- // TODO: If we knew what plugins were available (and how to create the initial spec), we might be able to
111
- // set a smarter default here?
112
110
  kind: '',
113
111
  spec: {}
114
112
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/panel-editor-slice.ts"],"sourcesContent":["// Copyright 2022 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 { PanelDefinition, UnknownSpec } from '@perses-dev/core';\nimport { StateCreator } from 'zustand';\nimport { removeWhiteSpacesAndSpecialCharacters } from '../../utils/functions';\nimport { generateId, Middleware } from './common';\nimport {\n PanelGroupSlice,\n PanelGroupItemId,\n PanelGroupId,\n PanelGroupDefinition,\n PanelGroupItemLayout,\n addPanelGroup,\n createEmptyPanelGroup,\n} from './panel-group-slice';\nimport { PanelSlice } from './panel-slice';\n\n/**\n * Slice that handles the visual editor state and actions for adding or editing Panels.\n */\nexport interface PanelEditorSlice {\n /**\n * State for the panel editor when its open, otherwise undefined when it's closed.\n */\n panelEditor?: PanelEditorState;\n\n /**\n * Opens the editor for editing an existing panel by providing its layout coordinates.\n */\n openEditPanel: (panelGroupItemId: PanelGroupItemId) => void;\n\n /**\n * Opens the editor for adding a new Panel to a panel group.\n */\n openAddPanel: (panelGroupId?: PanelGroupId) => void;\n}\n\nexport interface PanelEditorState {\n /**\n * Whether we're adding a new panel, or editing an existing panel.\n */\n mode: 'Add' | 'Edit';\n\n /**\n * Initial values for the things that can be edited about a panel.\n */\n initialValues: PanelEditorValues;\n\n /**\n * Applies changes, but doesn't close the editor.\n */\n applyChanges: (next: PanelEditorValues) => void;\n\n /**\n * Close the editor.\n */\n close: () => void;\n}\n\n/**\n * Panel values that can be edited in the panel editor.\n */\nexport interface PanelEditorValues {\n name: string;\n description: string;\n groupId: PanelGroupId;\n kind: string;\n spec: UnknownSpec;\n}\n\n/**\n * Curried function for creating the PanelEditorSlice.\n */\nexport function createPanelEditorSlice(): StateCreator<\n // Actions in here need to modify both Panels and Panel Groups state\n PanelEditorSlice & PanelSlice & PanelGroupSlice,\n Middleware,\n [],\n PanelEditorSlice\n> {\n // Return the state creator function for Zustand that uses the panels provided as intitial state\n return (set, get) => ({\n panelEditor: undefined,\n\n openEditPanel(panelGroupItemId) {\n const { panels, panelGroups } = get();\n\n // Figure out the panel key at that location\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const panelKey = panelGroups[panelGroupId]?.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) {\n throw new Error(`Could not find Panel Group item ${panelGroupItemId}`);\n }\n\n // Find the panel to edit\n const panelToEdit = panels[panelKey];\n if (panelToEdit === undefined) {\n throw new Error(`Cannot find Panel with key '${panelKey}'`);\n }\n\n const editorState: PanelEditorState = {\n mode: 'Edit',\n initialValues: {\n name: panelToEdit.spec.display.name,\n description: panelToEdit.spec.display.description ?? '',\n groupId: panelGroupItemId.panelGroupId,\n kind: panelToEdit.spec.plugin.kind,\n spec: panelToEdit.spec.plugin.spec,\n },\n applyChanges: (next) => {\n const panelDefinititon = createPanelDefinitionFromEditorValues(next);\n set((state) => {\n state.panels[panelKey] = panelDefinititon;\n\n // If the panel didn't change groups, nothing else to do\n if (next.groupId === panelGroupId) {\n return;\n }\n\n // Move panel to the new group\n const existingGroup = state.panelGroups[panelGroupId];\n if (existingGroup === undefined) {\n throw new Error(`Missing panel group ${panelGroupId}`);\n }\n\n const existingLayoutIdx = existingGroup.itemLayouts.findIndex((layout) => layout.i === panelGroupLayoutId);\n const existingLayout = existingGroup.itemLayouts[existingLayoutIdx];\n const existingPanelKey = existingGroup.itemPanelKeys[panelGroupLayoutId];\n if (existingLayoutIdx === -1 || existingLayout === undefined || existingPanelKey === undefined) {\n throw new Error(`Missing panel group item ${panelGroupLayoutId}`);\n }\n\n // Remove item from the old group\n existingGroup.itemLayouts.splice(existingLayoutIdx, 1);\n delete existingGroup.itemPanelKeys[panelGroupLayoutId];\n\n // Add item to the end of the new group\n const newGroup = state.panelGroups[next.groupId];\n if (newGroup === undefined) {\n throw new Error(`Could not find new group ${next.groupId}`);\n }\n\n newGroup.itemLayouts.push({\n i: existingLayout.i,\n x: 0,\n y: getYForNewRow(newGroup),\n w: existingLayout.w,\n h: existingLayout.h,\n });\n newGroup.itemPanelKeys[existingLayout.i] = existingPanelKey;\n });\n },\n close: () => {\n set((state) => {\n state.panelEditor = undefined;\n });\n },\n };\n\n // Open the editor with the new state\n set((state) => {\n state.panelEditor = editorState;\n });\n },\n\n openAddPanel(panelGroupId) {\n // If a panel group isn't supplied, add to the first group or create a group if there aren't any\n let newGroup: PanelGroupDefinition | undefined = undefined;\n panelGroupId ??= get().panelGroupOrder[0];\n if (panelGroupId === undefined) {\n newGroup = createEmptyPanelGroup();\n newGroup.title = 'Panel Group';\n panelGroupId = newGroup.id;\n }\n\n const editorState: PanelEditorState = {\n mode: 'Add',\n initialValues: {\n name: '',\n description: '',\n groupId: panelGroupId,\n // TODO: If we knew what plugins were available (and how to create the initial spec), we might be able to\n // set a smarter default here?\n kind: '',\n spec: {},\n },\n applyChanges: (next) => {\n const panelDef = createPanelDefinitionFromEditorValues(next);\n const uniquePanelKeys = getUniquePanelKeys(get().panels);\n let panelKey = removeWhiteSpacesAndSpecialCharacters(next.name);\n // append count if panel key already exists\n if (uniquePanelKeys[panelKey]) {\n panelKey += `-${uniquePanelKeys[panelKey]}`;\n }\n set((state) => {\n // Add a panel\n state.panels[panelKey] = panelDef;\n\n // Also add a panel group item referencing the panel\n const group = state.panelGroups[next.groupId];\n if (group === undefined) {\n throw new Error(`Missing panel group ${next.groupId}`);\n }\n const layout: PanelGroupItemLayout = {\n i: generateId().toString(),\n x: 0,\n y: getYForNewRow(group),\n w: 12,\n h: 6,\n };\n group.itemLayouts.push(layout);\n group.itemPanelKeys[layout.i] = panelKey;\n });\n },\n close: () => {\n set((state) => {\n state.panelEditor = undefined;\n });\n },\n };\n\n set((state) => {\n // Add the new panel group if one was created for the panel\n if (newGroup !== undefined) {\n addPanelGroup(state, newGroup);\n }\n\n // Open the editor with the new state\n state.panelEditor = editorState;\n });\n },\n });\n}\n\n// Helper to create PanelDefinitions when saving\nfunction createPanelDefinitionFromEditorValues(editorValues: PanelEditorValues): PanelDefinition {\n return {\n kind: 'Panel',\n spec: {\n display: {\n name: editorValues.name,\n description: editorValues.description !== '' ? editorValues.description : undefined,\n },\n plugin: {\n kind: editorValues.kind,\n spec: editorValues.spec,\n },\n },\n };\n}\n\n// Given a PanelGroup, will find the Y coordinate for adding a new row to the grid, taking into account the items present\nfunction getYForNewRow(group: PanelGroupDefinition) {\n let newRowY = 0;\n for (const layout of group.itemLayouts) {\n const itemMaxY = layout.y + layout.h;\n if (itemMaxY > newRowY) {\n newRowY = itemMaxY;\n }\n }\n return newRowY;\n}\n\n// Find all the unique panel keys\n// ex: cpu, cpu-1, cpu-2 count as the same panel key since these panels have the same name\nfunction getUniquePanelKeys(panels: Record<string, PanelDefinition>): Record<string, number> {\n const uniquePanelKeys: Record<string, number> = {};\n Object.keys(panels).forEach((panelKey) => {\n const key = panelKey.replace(/-([0-9]+)/, '');\n const count = uniquePanelKeys[key];\n if (count) {\n uniquePanelKeys[key] = count + 1;\n } else {\n uniquePanelKeys[key] = 1;\n }\n });\n return uniquePanelKeys;\n}\n"],"names":["removeWhiteSpacesAndSpecialCharacters","generateId","addPanelGroup","createEmptyPanelGroup","createPanelEditorSlice","set","get","panelEditor","undefined","openEditPanel","panelGroupItemId","panelGroups","panels","panelGroupId","panelGroupItemLayoutId","panelGroupLayoutId","panelKey","itemPanelKeys","Error","panelToEdit","editorState","mode","initialValues","name","spec","display","description","groupId","kind","plugin","applyChanges","next","panelDefinititon","createPanelDefinitionFromEditorValues","state","existingGroup","existingLayoutIdx","itemLayouts","findIndex","layout","i","existingLayout","existingPanelKey","splice","newGroup","push","x","y","getYForNewRow","w","h","close","openAddPanel","panelGroupOrder","title","id","panelDef","uniquePanelKeys","getUniquePanelKeys","group","toString","editorValues","newRowY","itemMaxY","Object","keys","forEach","key","replace","count"],"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;AAIjC,SAASA,qCAAqC,QAAQ,uBAAuB,CAAC;AAC9E,SAASC,UAAU,QAAoB,UAAU,CAAC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DqB,MAAM,EAAE;gBACND,IAAI,EAAEiC,YAAY,CAACjC,IAAI;gBACvBJ,IAAI,EAAEqC,YAAY,CAACrC,IAAI;aACxB;SACF;KACF,CAAC;AACJ,CAAC;AAED,yHAAyH;AACzH,SAASwB,aAAa,CAACW,KAA2B,EAAE;IAClD,IAAIG,OAAO,GAAG,CAAC,AAAC;IAChB,KAAK,MAAMvB,MAAM,IAAIoB,KAAK,CAACtB,WAAW,CAAE;QACtC,MAAM0B,QAAQ,GAAGxB,MAAM,CAACQ,CAAC,GAAGR,MAAM,CAACW,CAAC,AAAC;QACrC,IAAIa,QAAQ,GAAGD,OAAO,EAAE;YACtBA,OAAO,GAAGC,QAAQ,CAAC;QACrB,CAAC;IACH,CAAC;IACD,OAAOD,OAAO,CAAC;AACjB,CAAC;AAED,iCAAiC;AACjC,0FAA0F;AAC1F,SAASJ,kBAAkB,CAAC9C,MAAuC,EAA0B;IAC3F,MAAM6C,eAAe,GAA2B,EAAE,AAAC;IACnDO,MAAM,CAACC,IAAI,CAACrD,MAAM,CAAC,CAACsD,OAAO,CAAC,CAAClD,QAAQ,GAAK;QACxC,MAAMmD,GAAG,GAAGnD,QAAQ,CAACoD,OAAO,cAAc,EAAE,CAAC,AAAC;QAC9C,MAAMC,KAAK,GAAGZ,eAAe,CAACU,GAAG,CAAC,AAAC;QACnC,IAAIE,KAAK,EAAE;YACTZ,eAAe,CAACU,GAAG,CAAC,GAAGE,KAAK,GAAG,CAAC,CAAC;QACnC,OAAO;YACLZ,eAAe,CAACU,GAAG,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAOV,eAAe,CAAC;AACzB,CAAC"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/panel-editor-slice.ts"],"sourcesContent":["// Copyright 2022 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 { PanelDefinition, UnknownSpec } from '@perses-dev/core';\nimport { StateCreator } from 'zustand';\nimport { removeWhiteSpacesAndSpecialCharacters } from '../../utils/functions';\nimport { generateId, Middleware } from './common';\nimport {\n PanelGroupSlice,\n PanelGroupItemId,\n PanelGroupId,\n PanelGroupDefinition,\n PanelGroupItemLayout,\n addPanelGroup,\n createEmptyPanelGroup,\n} from './panel-group-slice';\nimport { PanelSlice } from './panel-slice';\n\n/**\n * Slice that handles the visual editor state and actions for adding or editing Panels.\n */\nexport interface PanelEditorSlice {\n /**\n * State for the panel editor when its open, otherwise undefined when it's closed.\n */\n panelEditor?: PanelEditorState;\n\n /**\n * Opens the editor for editing an existing panel by providing its layout coordinates.\n */\n openEditPanel: (panelGroupItemId: PanelGroupItemId) => void;\n\n /**\n * Opens the editor for adding a new Panel to a panel group.\n */\n openAddPanel: (panelGroupId?: PanelGroupId) => void;\n}\n\nexport interface PanelEditorState {\n /**\n * Whether we're adding a new panel, or editing an existing panel.\n */\n mode: 'Add' | 'Edit';\n\n /**\n * Initial values for the things that can be edited about a panel.\n */\n initialValues: PanelEditorValues;\n\n /**\n * Applies changes, but doesn't close the editor.\n */\n applyChanges: (next: PanelEditorValues) => void;\n\n /**\n * Close the editor.\n */\n close: () => void;\n}\n\n/**\n * Panel values that can be edited in the panel editor.\n */\nexport interface PanelEditorValues {\n name: string;\n description: string;\n groupId: PanelGroupId;\n kind: string;\n spec: UnknownSpec;\n}\n\n/**\n * Curried function for creating the PanelEditorSlice.\n */\nexport function createPanelEditorSlice(): StateCreator<\n // Actions in here need to modify both Panels and Panel Groups state\n PanelEditorSlice & PanelSlice & PanelGroupSlice,\n Middleware,\n [],\n PanelEditorSlice\n> {\n // Return the state creator function for Zustand that uses the panels provided as intitial state\n return (set, get) => ({\n panelEditor: undefined,\n\n openEditPanel(panelGroupItemId) {\n const { panels, panelGroups } = get();\n\n // Figure out the panel key at that location\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const panelKey = panelGroups[panelGroupId]?.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) {\n throw new Error(`Could not find Panel Group item ${panelGroupItemId}`);\n }\n\n // Find the panel to edit\n const panelToEdit = panels[panelKey];\n if (panelToEdit === undefined) {\n throw new Error(`Cannot find Panel with key '${panelKey}'`);\n }\n\n const editorState: PanelEditorState = {\n mode: 'Edit',\n initialValues: {\n name: panelToEdit.spec.display.name,\n description: panelToEdit.spec.display.description ?? '',\n groupId: panelGroupItemId.panelGroupId,\n kind: panelToEdit.spec.plugin.kind,\n spec: panelToEdit.spec.plugin.spec,\n },\n applyChanges: (next) => {\n const panelDefinititon = createPanelDefinitionFromEditorValues(next);\n set((state) => {\n state.panels[panelKey] = panelDefinititon;\n\n // If the panel didn't change groups, nothing else to do\n if (next.groupId === panelGroupId) {\n return;\n }\n\n // Move panel to the new group\n const existingGroup = state.panelGroups[panelGroupId];\n if (existingGroup === undefined) {\n throw new Error(`Missing panel group ${panelGroupId}`);\n }\n\n const existingLayoutIdx = existingGroup.itemLayouts.findIndex((layout) => layout.i === panelGroupLayoutId);\n const existingLayout = existingGroup.itemLayouts[existingLayoutIdx];\n const existingPanelKey = existingGroup.itemPanelKeys[panelGroupLayoutId];\n if (existingLayoutIdx === -1 || existingLayout === undefined || existingPanelKey === undefined) {\n throw new Error(`Missing panel group item ${panelGroupLayoutId}`);\n }\n\n // Remove item from the old group\n existingGroup.itemLayouts.splice(existingLayoutIdx, 1);\n delete existingGroup.itemPanelKeys[panelGroupLayoutId];\n\n // Add item to the end of the new group\n const newGroup = state.panelGroups[next.groupId];\n if (newGroup === undefined) {\n throw new Error(`Could not find new group ${next.groupId}`);\n }\n\n newGroup.itemLayouts.push({\n i: existingLayout.i,\n x: 0,\n y: getYForNewRow(newGroup),\n w: existingLayout.w,\n h: existingLayout.h,\n });\n newGroup.itemPanelKeys[existingLayout.i] = existingPanelKey;\n });\n },\n close: () => {\n set((state) => {\n state.panelEditor = undefined;\n });\n },\n };\n\n // Open the editor with the new state\n set((state) => {\n state.panelEditor = editorState;\n });\n },\n\n openAddPanel(panelGroupId) {\n // If a panel group isn't supplied, add to the first group or create a group if there aren't any\n let newGroup: PanelGroupDefinition | undefined = undefined;\n panelGroupId ??= get().panelGroupOrder[0];\n if (panelGroupId === undefined) {\n newGroup = createEmptyPanelGroup();\n newGroup.title = 'Panel Group';\n panelGroupId = newGroup.id;\n }\n\n const editorState: PanelEditorState = {\n mode: 'Add',\n initialValues: {\n name: '',\n description: '',\n groupId: panelGroupId,\n kind: '',\n spec: {},\n },\n applyChanges: (next) => {\n const panelDef = createPanelDefinitionFromEditorValues(next);\n const uniquePanelKeys = getUniquePanelKeys(get().panels);\n let panelKey = removeWhiteSpacesAndSpecialCharacters(next.name);\n // append count if panel key already exists\n if (uniquePanelKeys[panelKey]) {\n panelKey += `-${uniquePanelKeys[panelKey]}`;\n }\n set((state) => {\n // Add a panel\n state.panels[panelKey] = panelDef;\n\n // Also add a panel group item referencing the panel\n const group = state.panelGroups[next.groupId];\n if (group === undefined) {\n throw new Error(`Missing panel group ${next.groupId}`);\n }\n const layout: PanelGroupItemLayout = {\n i: generateId().toString(),\n x: 0,\n y: getYForNewRow(group),\n w: 12,\n h: 6,\n };\n group.itemLayouts.push(layout);\n group.itemPanelKeys[layout.i] = panelKey;\n });\n },\n close: () => {\n set((state) => {\n state.panelEditor = undefined;\n });\n },\n };\n\n set((state) => {\n // Add the new panel group if one was created for the panel\n if (newGroup !== undefined) {\n addPanelGroup(state, newGroup);\n }\n\n // Open the editor with the new state\n state.panelEditor = editorState;\n });\n },\n });\n}\n\n// Helper to create PanelDefinitions when saving\nfunction createPanelDefinitionFromEditorValues(editorValues: PanelEditorValues): PanelDefinition {\n return {\n kind: 'Panel',\n spec: {\n display: {\n name: editorValues.name,\n description: editorValues.description !== '' ? editorValues.description : undefined,\n },\n plugin: {\n kind: editorValues.kind,\n spec: editorValues.spec,\n },\n },\n };\n}\n\n// Given a PanelGroup, will find the Y coordinate for adding a new row to the grid, taking into account the items present\nfunction getYForNewRow(group: PanelGroupDefinition) {\n let newRowY = 0;\n for (const layout of group.itemLayouts) {\n const itemMaxY = layout.y + layout.h;\n if (itemMaxY > newRowY) {\n newRowY = itemMaxY;\n }\n }\n return newRowY;\n}\n\n// Find all the unique panel keys\n// ex: cpu, cpu-1, cpu-2 count as the same panel key since these panels have the same name\nfunction getUniquePanelKeys(panels: Record<string, PanelDefinition>): Record<string, number> {\n const uniquePanelKeys: Record<string, number> = {};\n Object.keys(panels).forEach((panelKey) => {\n const key = panelKey.replace(/-([0-9]+)/, '');\n const count = uniquePanelKeys[key];\n if (count) {\n uniquePanelKeys[key] = count + 1;\n } else {\n uniquePanelKeys[key] = 1;\n }\n });\n return uniquePanelKeys;\n}\n"],"names":["removeWhiteSpacesAndSpecialCharacters","generateId","addPanelGroup","createEmptyPanelGroup","createPanelEditorSlice","set","get","panelEditor","undefined","openEditPanel","panelGroupItemId","panelGroups","panels","panelGroupId","panelGroupItemLayoutId","panelGroupLayoutId","panelKey","itemPanelKeys","Error","panelToEdit","editorState","mode","initialValues","name","spec","display","description","groupId","kind","plugin","applyChanges","next","panelDefinititon","createPanelDefinitionFromEditorValues","state","existingGroup","existingLayoutIdx","itemLayouts","findIndex","layout","i","existingLayout","existingPanelKey","splice","newGroup","push","x","y","getYForNewRow","w","h","close","openAddPanel","panelGroupOrder","title","id","panelDef","uniquePanelKeys","getUniquePanelKeys","group","toString","editorValues","newRowY","itemMaxY","Object","keys","forEach","key","replace","count"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;A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,EAAEmC,YAAY,CAACnC,WAAW,KAAK,EAAE,GAAGmC,YAAY,CAACnC,WAAW,GAAGlB,SAAS;aACpF;YACDqB,MAAM,EAAE;gBACND,IAAI,EAAEiC,YAAY,CAACjC,IAAI;gBACvBJ,IAAI,EAAEqC,YAAY,CAACrC,IAAI;aACxB;SACF;KACF,CAAC;AACJ,CAAC;AAED,yHAAyH;AACzH,SAASwB,aAAa,CAACW,KAA2B,EAAE;IAClD,IAAIG,OAAO,GAAG,CAAC,AAAC;IAChB,KAAK,MAAMvB,MAAM,IAAIoB,KAAK,CAACtB,WAAW,CAAE;QACtC,MAAM0B,QAAQ,GAAGxB,MAAM,CAACQ,CAAC,GAAGR,MAAM,CAACW,CAAC,AAAC;QACrC,IAAIa,QAAQ,GAAGD,OAAO,EAAE;YACtBA,OAAO,GAAGC,QAAQ,CAAC;QACrB,CAAC;IACH,CAAC;IACD,OAAOD,OAAO,CAAC;AACjB,CAAC;AAED,iCAAiC;AACjC,0FAA0F;AAC1F,SAASJ,kBAAkB,CAAC9C,MAAuC,EAA0B;IAC3F,MAAM6C,eAAe,GAA2B,EAAE,AAAC;IACnDO,MAAM,CAACC,IAAI,CAACrD,MAAM,CAAC,CAACsD,OAAO,CAAC,CAAClD,QAAQ,GAAK;QACxC,MAAMmD,GAAG,GAAGnD,QAAQ,CAACoD,OAAO,cAAc,EAAE,CAAC,AAAC;QAC9C,MAAMC,KAAK,GAAGZ,eAAe,CAACU,GAAG,CAAC,AAAC;QACnC,IAAIE,KAAK,EAAE;YACTZ,eAAe,CAACU,GAAG,CAAC,GAAGE,KAAK,GAAG,CAAC,CAAC;QACnC,OAAO;YACLZ,eAAe,CAACU,GAAG,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAOV,eAAe,CAAC;AACzB,CAAC"}
@@ -46,7 +46,9 @@ export function useVariableQueryParams(defs) {
46
46
  const name = getURLQueryParamName(def.spec.name);
47
47
  config[name] = VariableValueParam;
48
48
  });
49
- return useQueryParams(config);
49
+ return useQueryParams(config, {
50
+ updateType: 'replaceIn'
51
+ });
50
52
  }
51
53
  export function getInitalValuesFromQueryParameters(queryParamValues) {
52
54
  const values = {};
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/TemplateVariableProvider/query-params.ts"],"sourcesContent":["// Copyright 2022 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 { VariableValue, VariableDefinition } from '@perses-dev/core';\nimport { QueryParamConfig, useQueryParams } from 'use-query-params';\n\nconst variableQueryParameterPrefix = 'var-';\n\nexport function getURLQueryParamName(name: string) {\n return `${variableQueryParameterPrefix}${name}`;\n}\n\nexport function encodeVariableValue(value: VariableValue) {\n if (Array.isArray(value)) {\n return value.join(',');\n }\n return value;\n}\n\nexport function decodeVariableValue(value: string): VariableValue {\n if (!value) {\n return null;\n }\n const values = value.split(',');\n if (values.length === 1) {\n return values[0] as string;\n }\n return values;\n}\n\nconst VariableValueParam: QueryParamConfig<VariableValue> = {\n encode: encodeVariableValue,\n decode: (v) => {\n if (typeof v === 'string') {\n return decodeVariableValue(v);\n }\n return '';\n },\n};\n\nexport function useVariableQueryParams(defs: VariableDefinition[]) {\n const config: Record<string, typeof VariableValueParam> = {};\n defs.forEach((def) => {\n const name = getURLQueryParamName(def.spec.name);\n config[name] = VariableValueParam;\n });\n return useQueryParams(config);\n}\n\nexport function getInitalValuesFromQueryParameters(\n queryParamValues: Record<string, VariableValue>\n): Record<string, VariableValue> {\n const values: Record<string, VariableValue> = {};\n Object.keys(queryParamValues).forEach((key) => {\n const value = queryParamValues[key];\n if (!value) {\n return;\n }\n const name = key.replace(variableQueryParameterPrefix, '');\n values[name] = value;\n });\n return values;\n}\n"],"names":["useQueryParams","variableQueryParameterPrefix","getURLQueryParamName","name","encodeVariableValue","value","Array","isArray","join","decodeVariableValue","values","split","length","VariableValueParam","encode","decode","v","useVariableQueryParams","defs","config","forEach","def","spec","getInitalValuesFromQueryParameters","queryParamValues","Object","keys","key","replace"],"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,SAA2BA,cAAc,QAAQ,kBAAkB,CAAC;AAEpE,MAAMC,4BAA4B,GAAG,MAAM,AAAC;AAE5C,OAAO,SAASC,oBAAoB,CAACC,IAAY,EAAE;IACjD,OAAO,CAAC,EAAEF,4BAA4B,CAAC,EAAEE,IAAI,CAAC,CAAC,CAAC;AAClD,CAAC;AAED,OAAO,SAASC,mBAAmB,CAACC,KAAoB,EAAE;IACxD,IAAIC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,EAAE;QACxB,OAAOA,KAAK,CAACG,IAAI,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IACD,OAAOH,KAAK,CAAC;AACf,CAAC;AAED,OAAO,SAASI,mBAAmB,CAACJ,KAAa,EAAiB;IAChE,IAAI,CAACA,KAAK,EAAE;QACV,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAMK,MAAM,GAAGL,KAAK,CAACM,KAAK,CAAC,GAAG,CAAC,AAAC;IAChC,IAAID,MAAM,CAACE,MAAM,KAAK,CAAC,EAAE;QACvB,OAAOF,MAAM,CAAC,CAAC,CAAC,CAAW;IAC7B,CAAC;IACD,OAAOA,MAAM,CAAC;AAChB,CAAC;AAED,MAAMG,kBAAkB,GAAoC;IAC1DC,MAAM,EAAEV,mBAAmB;IAC3BW,MAAM,EAAE,CAACC,CAAC,GAAK;QACb,IAAI,OAAOA,CAAC,KAAK,QAAQ,EAAE;YACzB,OAAOP,mBAAmB,CAACO,CAAC,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;CACF,AAAC;AAEF,OAAO,SAASC,sBAAsB,CAACC,IAA0B,EAAE;IACjE,MAAMC,MAAM,GAA8C,EAAE,AAAC;IAC7DD,IAAI,CAACE,OAAO,CAAC,CAACC,GAAG,GAAK;QACpB,MAAMlB,IAAI,GAAGD,oBAAoB,CAACmB,GAAG,CAACC,IAAI,CAACnB,IAAI,CAAC,AAAC;QACjDgB,MAAM,CAAChB,IAAI,CAAC,GAAGU,kBAAkB,CAAC;IACpC,CAAC,CAAC,CAAC;IACH,OAAOb,cAAc,CAACmB,MAAM,CAAC,CAAC;AAChC,CAAC;AAED,OAAO,SAASI,kCAAkC,CAChDC,gBAA+C,EAChB;IAC/B,MAAMd,MAAM,GAAkC,EAAE,AAAC;IACjDe,MAAM,CAACC,IAAI,CAACF,gBAAgB,CAAC,CAACJ,OAAO,CAAC,CAACO,GAAG,GAAK;QAC7C,MAAMtB,KAAK,GAAGmB,gBAAgB,CAACG,GAAG,CAAC,AAAC;QACpC,IAAI,CAACtB,KAAK,EAAE;YACV,OAAO;QACT,CAAC;QACD,MAAMF,IAAI,GAAGwB,GAAG,CAACC,OAAO,CAAC3B,4BAA4B,EAAE,EAAE,CAAC,AAAC;QAC3DS,MAAM,CAACP,IAAI,CAAC,GAAGE,KAAK,CAAC;IACvB,CAAC,CAAC,CAAC;IACH,OAAOK,MAAM,CAAC;AAChB,CAAC"}
1
+ {"version":3,"sources":["../../../src/context/TemplateVariableProvider/query-params.ts"],"sourcesContent":["// Copyright 2022 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 { VariableValue, VariableDefinition } from '@perses-dev/core';\nimport { QueryParamConfig, useQueryParams } from 'use-query-params';\n\nconst variableQueryParameterPrefix = 'var-';\n\nexport function getURLQueryParamName(name: string) {\n return `${variableQueryParameterPrefix}${name}`;\n}\n\nexport function encodeVariableValue(value: VariableValue) {\n if (Array.isArray(value)) {\n return value.join(',');\n }\n return value;\n}\n\nexport function decodeVariableValue(value: string): VariableValue {\n if (!value) {\n return null;\n }\n const values = value.split(',');\n if (values.length === 1) {\n return values[0] as string;\n }\n return values;\n}\n\nconst VariableValueParam: QueryParamConfig<VariableValue> = {\n encode: encodeVariableValue,\n decode: (v) => {\n if (typeof v === 'string') {\n return decodeVariableValue(v);\n }\n return '';\n },\n};\n\nexport function useVariableQueryParams(defs: VariableDefinition[]) {\n const config: Record<string, typeof VariableValueParam> = {};\n defs.forEach((def) => {\n const name = getURLQueryParamName(def.spec.name);\n config[name] = VariableValueParam;\n });\n return useQueryParams(config, { updateType: 'replaceIn' });\n}\n\nexport function getInitalValuesFromQueryParameters(\n queryParamValues: Record<string, VariableValue>\n): Record<string, VariableValue> {\n const values: Record<string, VariableValue> = {};\n Object.keys(queryParamValues).forEach((key) => {\n const value = queryParamValues[key];\n if (!value) {\n return;\n }\n const name = key.replace(variableQueryParameterPrefix, '');\n values[name] = value;\n });\n return values;\n}\n"],"names":["useQueryParams","variableQueryParameterPrefix","getURLQueryParamName","name","encodeVariableValue","value","Array","isArray","join","decodeVariableValue","values","split","length","VariableValueParam","encode","decode","v","useVariableQueryParams","defs","config","forEach","def","spec","updateType","getInitalValuesFromQueryParameters","queryParamValues","Object","keys","key","replace"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;A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ACnB,IAAI,CAAC,AAAC;QACjDgB,MAAM,CAAChB,IAAI,CAAC,GAAGU,kBAAkB,CAAC;IACpC,CAAC,CAAC,CAAC;IACH,OAAOb,cAAc,CAACmB,MAAM,EAAE;QAAEI,UAAU,EAAE,WAAW;KAAE,CAAC,CAAC;AAC7D,CAAC;AAED,OAAO,SAASC,kCAAkC,CAChDC,gBAA+C,EAChB;IAC/B,MAAMf,MAAM,GAAkC,EAAE,AAAC;IACjDgB,MAAM,CAACC,IAAI,CAACF,gBAAgB,CAAC,CAACL,OAAO,CAAC,CAACQ,GAAG,GAAK;QAC7C,MAAMvB,KAAK,GAAGoB,gBAAgB,CAACG,GAAG,CAAC,AAAC;QACpC,IAAI,CAACvB,KAAK,EAAE;YACV,OAAO;QACT,CAAC;QACD,MAAMF,IAAI,GAAGyB,GAAG,CAACC,OAAO,CAAC5B,4BAA4B,EAAE,EAAE,CAAC,AAAC;QAC3DS,MAAM,CAACP,IAAI,CAAC,GAAGE,KAAK,CAAC;IACvB,CAAC,CAAC,CAAC;IACH,OAAOK,MAAM,CAAC;AAChB,CAAC"}
@@ -1,6 +1,5 @@
1
1
  export * from './DashboardProvider';
2
2
  export * from './DatasourceStoreProvider';
3
3
  export * from './TemplateVariableProvider';
4
- export * from './TimeRangeProvider';
5
4
  export * from './useDashboard';
6
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gBAAgB,CAAC"}
@@ -13,7 +13,6 @@
13
13
  export * from './DashboardProvider';
14
14
  export * from './DatasourceStoreProvider';
15
15
  export * from './TemplateVariableProvider';
16
- export * from './TimeRangeProvider';
17
16
  export * from './useDashboard';
18
17
 
19
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/context/index.ts"],"sourcesContent":["// Copyright 2022 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 './DashboardProvider';\nexport * from './DatasourceStoreProvider';\nexport * from './TemplateVariableProvider';\nexport * from './TimeRangeProvider';\nexport * from './useDashboard';\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,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"sources":["../../src/context/index.ts"],"sourcesContent":["// Copyright 2022 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 './DashboardProvider';\nexport * from './DatasourceStoreProvider';\nexport * from './TemplateVariableProvider';\nexport * from './useDashboard';\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,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gBAAgB,CAAC"}
@@ -4,6 +4,7 @@ export interface DashboardAppProps {
4
4
  dashboardResource: DashboardResource;
5
5
  dashboardTitleComponent?: JSX.Element;
6
6
  initialVariableIsSticky?: boolean;
7
+ isReadonly: boolean;
7
8
  }
8
9
  export declare const DashboardApp: (props: DashboardAppProps) => JSX.Element;
9
10
  //# sourceMappingURL=DashboardApp.d.ts.map
@@ -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;AAYrD,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,uBAAuB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACtC,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,eAAO,MAAM,YAAY,UAAW,iBAAiB,gBAoEpD,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;AAYrD,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,uBAAuB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACtC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,YAAY,UAAW,iBAAiB,gBAqEpD,CAAC"}
@@ -17,7 +17,7 @@ import { ErrorAlert, ErrorBoundary } from '@perses-dev/components';
17
17
  import { PanelDrawer, Dashboard, PanelGroupDialog, DeletePanelGroupDialog, UnsavedChangesConfirmationDialog, DashboardToolbar, DeletePanelDialog } from '../../components';
18
18
  import { useDashboard, useEditMode } from '../../context';
19
19
  export const DashboardApp = (props)=>{
20
- const { dashboardResource , dashboardTitleComponent , initialVariableIsSticky } = props;
20
+ const { dashboardResource , dashboardTitleComponent , initialVariableIsSticky , isReadonly } = props;
21
21
  const { setEditMode } = useEditMode();
22
22
  const { dashboard , setDashboard } = useDashboard();
23
23
  const [originalDashboard, setOriginalDashboard] = useState(undefined);
@@ -59,6 +59,7 @@ export const DashboardApp = (props)=>{
59
59
  dashboardName: dashboardResource.metadata.name,
60
60
  dashboardTitleComponent: dashboardTitleComponent,
61
61
  initialVariableIsSticky: initialVariableIsSticky,
62
+ isReadonly: isReadonly,
62
63
  onEditButtonClick: onEditButtonClick,
63
64
  onCancelButtonClick: onCancelButtonClick
64
65
  }),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"sourcesContent":["// Copyright 2022 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 UnsavedChangesConfirmationDialog,\n DashboardToolbar,\n DeletePanelDialog,\n} from '../../components';\nimport { useDashboard, useEditMode } from '../../context';\n\nexport interface DashboardAppProps {\n dashboardResource: DashboardResource;\n dashboardTitleComponent?: JSX.Element;\n initialVariableIsSticky?: boolean;\n}\n\nexport const DashboardApp = (props: DashboardAppProps) => {\n const { dashboardResource, dashboardTitleComponent, initialVariableIsSticky } = props;\n const { setEditMode } = useEditMode();\n const { dashboard, setDashboard } = useDashboard();\n const [originalDashboard, setOriginalDashboard] = useState<DashboardResource | undefined>(undefined);\n const [isUnsavedDashboardDialogOpen, setUnsavedDashboardDialogIsOpen] = useState(false);\n\n const saveDashboard = async () => {\n setEditMode(false);\n setUnsavedDashboardDialogIsOpen(false);\n };\n\n const cancelDashboard = () => {\n // Reset to the original spec and exit edit mode\n if (originalDashboard) {\n setDashboard(originalDashboard);\n }\n setUnsavedDashboardDialogIsOpen(false);\n setEditMode(false);\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 setUnsavedDashboardDialogIsOpen(true);\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 onEditButtonClick={onEditButtonClick}\n onCancelButtonClick={onCancelButtonClick}\n />\n <Box sx={{ padding: (theme) => theme.spacing(2) }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <Dashboard />\n </ErrorBoundary>\n <PanelDrawer />\n <PanelGroupDialog />\n <DeletePanelGroupDialog />\n <DeletePanelDialog />\n <UnsavedChangesConfirmationDialog\n isOpen={isUnsavedDashboardDialogOpen}\n onSave={saveDashboard}\n onClose={cancelDashboard}\n />\n </Box>\n </Box>\n );\n};\n"],"names":["useState","Box","ErrorAlert","ErrorBoundary","PanelDrawer","Dashboard","PanelGroupDialog","DeletePanelGroupDialog","UnsavedChangesConfirmationDialog","DashboardToolbar","DeletePanelDialog","useDashboard","useEditMode","DashboardApp","props","dashboardResource","dashboardTitleComponent","initialVariableIsSticky","setEditMode","dashboard","setDashboard","originalDashboard","setOriginalDashboard","undefined","isUnsavedDashboardDialogOpen","setUnsavedDashboardDialogIsOpen","saveDashboard","cancelDashboard","onEditButtonClick","onCancelButtonClick","JSON","stringify","sx","flexGrow","overflowX","overflowY","display","flexDirection","dashboardName","metadata","name","padding","theme","spacing","FallbackComponent","isOpen","onSave","onClose"],"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,QACZ,kBAAkB,CAAC;AAC1B,SAASC,YAAY,EAAEC,WAAW,QAAQ,eAAe,CAAC;AAQ1D,OAAO,MAAMC,YAAY,GAAG,CAACC,KAAwB,GAAK;IACxD,MAAM,EAAEC,iBAAiB,CAAA,EAAEC,uBAAuB,CAAA,EAAEC,uBAAuB,CAAA,EAAE,GAAGH,KAAK,AAAC;IACtF,MAAM,EAAEI,WAAW,CAAA,EAAE,GAAGN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,aAAa,EAAEvB,iBAAiB,CAACwB,QAAQ,CAACC,IAAI;gBAC9CxB,uBAAuB,EAAEA,uBAAuB;gBAChDC,uBAAuB,EAAEA,uBAAuB;gBAChDW,iBAAiB,EAAEA,iBAAiB;gBACpCC,mBAAmB,EAAEA,mBAAmB;cACxC;0BACF,MAAC5B,GAAG;gBAAC+B,EAAE,EAAE;oBAAES,OAAO,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,OAAO,CAAC,CAAC,CAAC;iBAAE;;kCAC/C,KAACxC,aAAa;wBAACyC,iBAAiB,EAAE1C,UAAU;kCAC1C,cAAA,KAACG,SAAS,KAAG;sBACC;kCAChB,KAACD,WAAW,KAAG;kCACf,KAACE,gBAAgB,KAAG;kCACpB,KAACC,sBAAsB,KAAG;kCAC1B,KAACG,iBAAiB,KAAG;kCACrB,KAACF,gCAAgC;wBAC/BqC,MAAM,EAAErB,4BAA4B;wBACpCsB,MAAM,EAAEpB,aAAa;wBACrBqB,OAAO,EAAEpB,eAAe;sBACxB;;cACE;;MACF,CACN;AACJ,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"sourcesContent":["// Copyright 2022 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 UnsavedChangesConfirmationDialog,\n DashboardToolbar,\n DeletePanelDialog,\n} from '../../components';\nimport { useDashboard, useEditMode } from '../../context';\n\nexport interface DashboardAppProps {\n dashboardResource: DashboardResource;\n dashboardTitleComponent?: JSX.Element;\n initialVariableIsSticky?: boolean;\n isReadonly: boolean;\n}\n\nexport const DashboardApp = (props: DashboardAppProps) => {\n const { dashboardResource, dashboardTitleComponent, initialVariableIsSticky, isReadonly } = props;\n const { setEditMode } = useEditMode();\n const { dashboard, setDashboard } = useDashboard();\n const [originalDashboard, setOriginalDashboard] = useState<DashboardResource | undefined>(undefined);\n const [isUnsavedDashboardDialogOpen, setUnsavedDashboardDialogIsOpen] = useState(false);\n\n const saveDashboard = async () => {\n setEditMode(false);\n setUnsavedDashboardDialogIsOpen(false);\n };\n\n const cancelDashboard = () => {\n // Reset to the original spec and exit edit mode\n if (originalDashboard) {\n setDashboard(originalDashboard);\n }\n setUnsavedDashboardDialogIsOpen(false);\n setEditMode(false);\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 setUnsavedDashboardDialogIsOpen(true);\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 isReadonly={isReadonly}\n onEditButtonClick={onEditButtonClick}\n onCancelButtonClick={onCancelButtonClick}\n />\n <Box sx={{ padding: (theme) => theme.spacing(2) }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <Dashboard />\n </ErrorBoundary>\n <PanelDrawer />\n <PanelGroupDialog />\n <DeletePanelGroupDialog />\n <DeletePanelDialog />\n <UnsavedChangesConfirmationDialog\n isOpen={isUnsavedDashboardDialogOpen}\n onSave={saveDashboard}\n onClose={cancelDashboard}\n />\n </Box>\n </Box>\n );\n};\n"],"names":["useState","Box","ErrorAlert","ErrorBoundary","PanelDrawer","Dashboard","PanelGroupDialog","DeletePanelGroupDialog","UnsavedChangesConfirmationDialog","DashboardToolbar","DeletePanelDialog","useDashboard","useEditMode","DashboardApp","props","dashboardResource","dashboardTitleComponent","initialVariableIsSticky","isReadonly","setEditMode","dashboard","setDashboard","originalDashboard","setOriginalDashboard","undefined","isUnsavedDashboardDialogOpen","setUnsavedDashboardDialogIsOpen","saveDashboard","cancelDashboard","onEditButtonClick","onCancelButtonClick","JSON","stringify","sx","flexGrow","overflowX","overflowY","display","flexDirection","dashboardName","metadata","name","padding","theme","spacing","FallbackComponent","isOpen","onSave","onClose"],"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,QACZ,kBAAkB,CAAC;AAC1B,SAASC,YAAY,EAAEC,WAAW,QAAQ,eAAe,CAAC;AAS1D,OAAO,MAAMC,YAAY,GAAG,CAACC,KAAwB,GAAK;IACxD,MAAM,EAAEC,iBAAiB,CAAA,EAAEC,uBAAuB,CAAA,EAAEC,uBAAuB,CAAA,EAAEC,UAAU,CAAA,EAAE,GAAGJ,KAAK,AAAC;IAClG,MAAM,EAAEK,WAAW,CAAA,EAAE,GAAGP,WAAW,EAAE,AAAC;IACtC,MAAM,EAAEQ,SAAS,CAAA,EAAEC,YAAY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AAuB,EAAEA,uBAAuB;gBAChDC,uBAAuB,EAAEA,uBAAuB;gBAChDC,UAAU,EAAEA,UAAU;gBACtBW,iBAAiB,EAAEA,iBAAiB;gBACpCC,mBAAmB,EAAEA,mBAAmB;cACxC;0BACF,MAAC7B,GAAG;gBAACgC,EAAE,EAAE;oBAAES,OAAO,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,OAAO,CAAC,CAAC,CAAC;iBAAE;;kCAC/C,KAACzC,aAAa;wBAAC0C,iBAAiB,EAAE3C,UAAU;kCAC1C,cAAA,KAACG,SAAS,KAAG;sBACC;kCAChB,KAACD,WAAW,KAAG;kCACf,KAACE,gBAAgB,KAAG;kCACpB,KAACC,sBAAsB,KAAG;kCAC1B,KAACG,iBAAiB,KAAG;kCACrB,KAACF,gCAAgC;wBAC/BsC,MAAM,EAAErB,4BAA4B;wBACpCsB,MAAM,EAAEpB,aAAa;wBACrBqB,OAAO,EAAEpB,eAAe;sBACxB;;cACE;;MACF,CACN;AACJ,CAAC,CAAC"}
@@ -7,6 +7,7 @@ export interface ViewDashboardProps extends Omit<BoxProps, 'children'> {
7
7
  datasourceApi: DatasourceStoreProviderProps['datasourceApi'];
8
8
  dashboardTitleComponent?: JSX.Element;
9
9
  initialVariableIsSticky?: boolean;
10
+ isReadonly: boolean;
10
11
  }
11
12
  /**
12
13
  * The View for displaying a Dashboard, along with the UI for selecting variable values.
@@ -1 +1 @@
1
- {"version":3,"file":"ViewDashboard.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/ViewDashboard.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAIL,4BAA4B,EAG7B,MAAM,eAAe,CAAC;AAGvB,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC;IACpE,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,aAAa,EAAE,4BAA4B,CAAC,eAAe,CAAC,CAAC;IAC7D,uBAAuB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACtC,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,eAoCtD"}
1
+ {"version":3,"file":"ViewDashboard.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/ViewDashboard.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,EAGL,4BAA4B,EAE7B,MAAM,eAAe,CAAC;AAGvB,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC;IACpE,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,aAAa,EAAE,4BAA4B,CAAC,eAAe,CAAC,CAAC;IAC7D,uBAAuB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACtC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,eA8CtD"}
@@ -13,12 +13,13 @@
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { Box } from '@mui/material';
15
15
  import { ErrorBoundary, ErrorAlert, combineSx } from '@perses-dev/components';
16
- import { TimeRangeProvider, TemplateVariableProvider, DashboardProvider, DatasourceStoreProvider, useInitialTimeRange } from '../../context';
16
+ import { TimeRangeProvider, useInitialTimeRange } from '@perses-dev/plugin-system';
17
+ import { TemplateVariableProvider, DashboardProvider, DatasourceStoreProvider } from '../../context';
17
18
  import { DashboardApp } from './DashboardApp';
18
19
  /**
19
20
  * The View for displaying a Dashboard, along with the UI for selecting variable values.
20
21
  */ export function ViewDashboard(props) {
21
- const { dashboardResource , datasourceApi , dashboardTitleComponent , initialVariableIsSticky , sx , ...others } = props;
22
+ const { dashboardResource , datasourceApi , dashboardTitleComponent , initialVariableIsSticky , isReadonly , sx , ...others } = props;
22
23
  const { spec } = dashboardResource;
23
24
  var _duration;
24
25
  const dashboardDuration = (_duration = spec.duration) !== null && _duration !== void 0 ? _duration : '1h';
@@ -49,7 +50,8 @@ import { DashboardApp } from './DashboardApp';
49
50
  children: /*#__PURE__*/ _jsx(DashboardApp, {
50
51
  dashboardResource: dashboardResource,
51
52
  dashboardTitleComponent: dashboardTitleComponent,
52
- initialVariableIsSticky: initialVariableIsSticky
53
+ initialVariableIsSticky: initialVariableIsSticky,
54
+ isReadonly: isReadonly
53
55
  })
54
56
  })
55
57
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/views/ViewDashboard/ViewDashboard.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, BoxProps } from '@mui/material';\nimport { DashboardResource } from '@perses-dev/core';\nimport { ErrorBoundary, ErrorAlert, combineSx } from '@perses-dev/components';\nimport {\n TimeRangeProvider,\n TemplateVariableProvider,\n DashboardProvider,\n DatasourceStoreProviderProps,\n DatasourceStoreProvider,\n useInitialTimeRange,\n} from '../../context';\nimport { DashboardApp } from './DashboardApp';\n\nexport interface ViewDashboardProps extends Omit<BoxProps, 'children'> {\n dashboardResource: DashboardResource;\n datasourceApi: DatasourceStoreProviderProps['datasourceApi'];\n dashboardTitleComponent?: JSX.Element;\n initialVariableIsSticky?: boolean;\n}\n\n/**\n * The View for displaying a Dashboard, along with the UI for selecting variable values.\n */\nexport function ViewDashboard(props: ViewDashboardProps) {\n const { dashboardResource, datasourceApi, dashboardTitleComponent, initialVariableIsSticky, sx, ...others } = props;\n const { spec } = dashboardResource;\n const dashboardDuration = spec.duration ?? '1h';\n const initialTimeRange = useInitialTimeRange(dashboardDuration);\n return (\n <DatasourceStoreProvider dashboardResource={dashboardResource} datasourceApi={datasourceApi}>\n <DashboardProvider initialState={{ dashboardResource }}>\n <TimeRangeProvider initialTimeRange={initialTimeRange} enabledURLParams={true}>\n <TemplateVariableProvider initialVariableDefinitions={spec.variables}>\n <Box\n sx={combineSx(\n {\n display: 'flex',\n width: '100%',\n height: '100%',\n position: 'relative',\n overflow: 'hidden',\n },\n sx\n )}\n {...others}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <DashboardApp\n dashboardResource={dashboardResource}\n dashboardTitleComponent={dashboardTitleComponent}\n initialVariableIsSticky={initialVariableIsSticky}\n />\n </ErrorBoundary>\n </Box>\n </TemplateVariableProvider>\n </TimeRangeProvider>\n </DashboardProvider>\n </DatasourceStoreProvider>\n );\n}\n"],"names":["Box","ErrorBoundary","ErrorAlert","combineSx","TimeRangeProvider","TemplateVariableProvider","DashboardProvider","DatasourceStoreProvider","useInitialTimeRange","DashboardApp","ViewDashboard","props","dashboardResource","datasourceApi","dashboardTitleComponent","initialVariableIsSticky","sx","others","spec","dashboardDuration","duration","initialTimeRange","initialState","enabledURLParams","initialVariableDefinitions","variables","display","width","height","position","overflow","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,GAAG,QAAkB,eAAe,CAAC;AAE9C,SAASC,aAAa,EAAEC,UAAU,EAAEC,SAAS,QAAQ,wBAAwB,CAAC;AAC9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YAAY;gCACXG,iBAAiB,EAAEA,iBAAiB;gCACpCE,uBAAuB,EAAEA,uBAAuB;gCAChDC,uBAAuB,EAAEA,uBAAuB;8BAChD;0BACY;sBACZ;kBACmB;cACT;UACF;MACI,CAC1B;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../../src/views/ViewDashboard/ViewDashboard.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, BoxProps } from '@mui/material';\nimport { DashboardResource } from '@perses-dev/core';\nimport { ErrorBoundary, ErrorAlert, combineSx } from '@perses-dev/components';\nimport { TimeRangeProvider, useInitialTimeRange } from '@perses-dev/plugin-system';\nimport {\n TemplateVariableProvider,\n DashboardProvider,\n DatasourceStoreProviderProps,\n DatasourceStoreProvider,\n} from '../../context';\nimport { DashboardApp } from './DashboardApp';\n\nexport interface ViewDashboardProps extends Omit<BoxProps, 'children'> {\n dashboardResource: DashboardResource;\n datasourceApi: DatasourceStoreProviderProps['datasourceApi'];\n dashboardTitleComponent?: JSX.Element;\n initialVariableIsSticky?: boolean;\n isReadonly: boolean;\n}\n\n/**\n * The View for displaying a Dashboard, along with the UI for selecting variable values.\n */\nexport function ViewDashboard(props: ViewDashboardProps) {\n const {\n dashboardResource,\n datasourceApi,\n dashboardTitleComponent,\n initialVariableIsSticky,\n isReadonly,\n sx,\n ...others\n } = props;\n const { spec } = dashboardResource;\n const dashboardDuration = spec.duration ?? '1h';\n const initialTimeRange = useInitialTimeRange(dashboardDuration);\n\n return (\n <DatasourceStoreProvider dashboardResource={dashboardResource} datasourceApi={datasourceApi}>\n <DashboardProvider initialState={{ dashboardResource }}>\n <TimeRangeProvider initialTimeRange={initialTimeRange} enabledURLParams={true}>\n <TemplateVariableProvider initialVariableDefinitions={spec.variables}>\n <Box\n sx={combineSx(\n {\n display: 'flex',\n width: '100%',\n height: '100%',\n position: 'relative',\n overflow: 'hidden',\n },\n sx\n )}\n {...others}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <DashboardApp\n dashboardResource={dashboardResource}\n dashboardTitleComponent={dashboardTitleComponent}\n initialVariableIsSticky={initialVariableIsSticky}\n isReadonly={isReadonly}\n />\n </ErrorBoundary>\n </Box>\n </TemplateVariableProvider>\n </TimeRangeProvider>\n </DashboardProvider>\n </DatasourceStoreProvider>\n );\n}\n"],"names":["Box","ErrorBoundary","ErrorAlert","combineSx","TimeRangeProvider","useInitialTimeRange","TemplateVariableProvider","DashboardProvider","DatasourceStoreProvider","DashboardApp","ViewDashboard","props","dashboardResource","datasourceApi","dashboardTitleComponent","initialVariableIsSticky","isReadonly","sx","others","spec","dashboardDuration","duration","initialTimeRange","initialState","enabledURLParams","initialVariableDefinitions","variables","display","width","height","position","overflow","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,GAAG,QAAkB,eAAe,CAAC;AAE9C,SAASC,aAAa,EAAEC,UAAU,EAAEC,SAAS,QAAQ,wBAAwB,CAAC;AAC9E,SAASC,iBAAiB,EAAEC,mBAAmB,QAAQ,2BAA2B,CAAC;AACnF,SACEC,wBAAwB,EACxBC,iBAAiB,EAEjBC,uBAAuB,QAClB,eAAe,CAAC;AACvB,SAASC,YAAY,QAAQ,gBAAgB,CAAC;AAU9C;;CAEC,GACD,OAAO,SAASC,aAAa,CAACC,KAAyB,EAAE;IACvD,MAAM,EACJ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
@@ -13,7 +13,8 @@
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { screen } from '@testing-library/react';
15
15
  import userEvent from '@testing-library/user-event';
16
- import { DashboardProvider, TemplateVariableProvider, TimeRangeProvider } from '../../../context';
16
+ import { TimeRangeProvider } from '@perses-dev/plugin-system';
17
+ import { DashboardProvider, TemplateVariableProvider } from '../../../context';
17
18
  import { getTestDashboard, renderWithContext } from '../../../test';
18
19
  import { DashboardApp } from '../DashboardApp';
19
20
  describe('Panel Groups', ()=>{
@@ -29,7 +30,8 @@ describe('Panel Groups', ()=>{
29
30
  isEditMode: true
30
31
  },
31
32
  children: /*#__PURE__*/ _jsx(DashboardApp, {
32
- dashboardResource: getTestDashboard()
33
+ dashboardResource: getTestDashboard(),
34
+ isReadonly: false
33
35
  })
34
36
  })
35
37
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/views/ViewDashboard/tests/panelGroups.test.tsx"],"sourcesContent":["// Copyright 2022 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 { screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { DashboardProvider, TemplateVariableProvider, TimeRangeProvider } from '../../../context';\nimport { getTestDashboard, renderWithContext } from '../../../test';\nimport { DashboardApp } from '../DashboardApp';\n\ndescribe('Panel Groups', () => {\n const renderDashboard = () => {\n renderWithContext(\n <TimeRangeProvider initialTimeRange={{ pastDuration: '30m' }}>\n <TemplateVariableProvider>\n <DashboardProvider initialState={{ dashboardResource: getTestDashboard(), isEditMode: true }}>\n <DashboardApp dashboardResource={getTestDashboard()} />\n </DashboardProvider>\n </TemplateVariableProvider>\n </TimeRangeProvider>\n );\n };\n it('should delete panel', () => {\n renderDashboard();\n const panelTitle = 'CPU';\n const deletePanelButton = screen.getByLabelText(`delete panel ${panelTitle}`);\n userEvent.click(deletePanelButton);\n screen.getByText('Delete Panel');\n const deleteButton = screen.getByText('Delete');\n userEvent.click(deleteButton);\n\n // The panel should disappear\n const deletedPanel = screen.queryByText(panelTitle);\n expect(deletedPanel).not.toBeInTheDocument();\n });\n\n it('should only delete panel from panel group if panel is not referenced more than once', () => {\n renderDashboard();\n\n const panelTitle = 'Disk I/O Utilization';\n const panels = screen.getAllByText(panelTitle);\n expect(panels).toHaveLength(2);\n\n const deletePanelButton = screen.getAllByLabelText(`delete panel ${panelTitle}`)[0];\n if (deletePanelButton === undefined) throw new Error('Missing delete button');\n\n userEvent.click(deletePanelButton);\n screen.getByText('Delete Panel');\n const deleteButton = screen.getByText('Delete');\n userEvent.click(deleteButton);\n\n // The deleted panel should still be on screen in the other group\n const deletedPanel = screen.queryByText(panelTitle);\n expect(deletedPanel).toBeInTheDocument();\n });\n\n it('should swap panels', () => {\n renderDashboard();\n\n // should move panel down\n const groupTitle1 = 'CPU Stats';\n const moveGroupDownBtn = screen.getByLabelText(`move group ${groupTitle1} down`);\n userEvent.click(moveGroupDownBtn);\n\n // should move panel up\n const groupTitle2 = 'Disk Stats';\n const moveGroupUpBtn = screen.getByLabelText(`move group ${groupTitle2} up`);\n userEvent.click(moveGroupUpBtn);\n\n /* TODO: Figure out how to test this visually without coupling to the store\n const layouts = storeApi.getState().layouts;\n expect(layouts[0]?.title).toBe(undefined);\n expect(layouts[1]?.title).toBe('Disk Stats');\n expect(layouts[2]?.title).toBe('CPU Stats');\n */\n });\n\n it('should delete a panel group', () => {\n renderDashboard();\n const groupTitle = 'CPU Stats';\n const deleteGroupIcon = screen.getByLabelText(`delete group ${groupTitle}`);\n userEvent.click(deleteGroupIcon);\n screen.getByText('Delete Panel Group');\n const deleteButton = screen.getByText('Delete');\n userEvent.click(deleteButton);\n\n // should remove group\n const deletedGroup = screen.queryByText(groupTitle);\n expect(deletedGroup).not.toBeInTheDocument();\n\n // CPU panel should be completely gone since it wasn't in any other group\n let panel = screen.queryByText('CPU');\n expect(panel).not.toBeInTheDocument();\n\n // A DiskIO panel should still be present in the other group that wasn't deleted\n panel = screen.queryByText('Disk I/O Utilization');\n expect(panel).toBeInTheDocument();\n });\n});\n"],"names":["screen","userEvent","DashboardProvider","TemplateVariableProvider","TimeRangeProvider","getTestDashboard","renderWithContext","DashboardApp","describe","renderDashboard","initialTimeRange","pastDuration","initialState","dashboardResource","isEditMode","it","panelTitle","deletePanelButton","getByLabelText","click","getByText","deleteButton","deletedPanel","queryByText","expect","not","toBeInTheDocument","panels","getAllByText","toHaveLength","getAllByLabelText","undefined","Error","groupTitle1","moveGroupDownBtn","groupTitle2","moveGroupUpBtn","groupTitle","deleteGroupIcon","deletedGroup","panel"],"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,MAAM,QAAQ,wBAAwB,CAAC;AAChD,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AACpD,SAASC,iBAAiB,EAAEC,wBAAwB,EAAEC,iBAAiB,QAAQ,kBAAkB,CAAC;AAClG,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,eAAe,CAAC;AACpE,SAASC,YAAY,QAAQ,iBAAiB,CAAC;AAE/CC,QAAQ,CAAC,cAAc,EAAE,IAAM;IAC7B,MAAMC,eAAe,GAAG,IAAM;QAC5BH,iBAAiB,eACf,KAACF,iBAAiB;YAACM,gBAAgB,EAAE;gBAAEC,YAAY,EAAE,KAAK;aAAE;sBAC1D,cAAA,KAACR,wBAAwB;0BACvB,cAAA,KAACD,iBAAiB;oBAACU,YAAY,EAAE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AAe,CAAC,CAAC;QACjCtC,MAAM,CAACoB,SAAS,CAAC,oBAAoB,CAAC,CAAC;QACvC,MAAMC,YAAY,GAAGrB,MAAM,CAACoB,SAAS,CAAC,QAAQ,CAAC,AAAC;QAChDnB,SAAS,CAACkB,KAAK,CAACE,YAAY,CAAC,CAAC;QAE9B,sBAAsB;QACtB,MAAMkB,YAAY,GAAGvC,MAAM,CAACuB,WAAW,CAACc,UAAU,CAAC,AAAC;QACpDb,MAAM,CAACe,YAAY,CAAC,CAACd,GAAG,CAACC,iBAAiB,EAAE,CAAC;QAE7C,yEAAyE;QACzE,IAAIc,KAAK,GAAGxC,MAAM,CAACuB,WAAW,CAAC,KAAK,CAAC,AAAC;QACtCC,MAAM,CAACgB,KAAK,CAAC,CAACf,GAAG,CAACC,iBAAiB,EAAE,CAAC;QAEtC,gFAAgF;QAChFc,KAAK,GAAGxC,MAAM,CAACuB,WAAW,CAAC,sBAAsB,CAAC,CAAC;QACnDC,MAAM,CAACgB,KAAK,CAAC,CAACd,iBAAiB,EAAE,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../../src/views/ViewDashboard/tests/panelGroups.test.tsx"],"sourcesContent":["// Copyright 2022 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 { screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { TimeRangeProvider } from '@perses-dev/plugin-system';\nimport { DashboardProvider, TemplateVariableProvider } from '../../../context';\nimport { getTestDashboard, renderWithContext } from '../../../test';\nimport { DashboardApp } from '../DashboardApp';\n\ndescribe('Panel Groups', () => {\n const renderDashboard = () => {\n renderWithContext(\n <TimeRangeProvider initialTimeRange={{ pastDuration: '30m' }}>\n <TemplateVariableProvider>\n <DashboardProvider initialState={{ dashboardResource: getTestDashboard(), isEditMode: true }}>\n <DashboardApp dashboardResource={getTestDashboard()} isReadonly={false} />\n </DashboardProvider>\n </TemplateVariableProvider>\n </TimeRangeProvider>\n );\n };\n it('should delete panel', () => {\n renderDashboard();\n const panelTitle = 'CPU';\n const deletePanelButton = screen.getByLabelText(`delete panel ${panelTitle}`);\n userEvent.click(deletePanelButton);\n screen.getByText('Delete Panel');\n const deleteButton = screen.getByText('Delete');\n userEvent.click(deleteButton);\n\n // The panel should disappear\n const deletedPanel = screen.queryByText(panelTitle);\n expect(deletedPanel).not.toBeInTheDocument();\n });\n\n it('should only delete panel from panel group if panel is not referenced more than once', () => {\n renderDashboard();\n\n const panelTitle = 'Disk I/O Utilization';\n const panels = screen.getAllByText(panelTitle);\n expect(panels).toHaveLength(2);\n\n const deletePanelButton = screen.getAllByLabelText(`delete panel ${panelTitle}`)[0];\n if (deletePanelButton === undefined) throw new Error('Missing delete button');\n\n userEvent.click(deletePanelButton);\n screen.getByText('Delete Panel');\n const deleteButton = screen.getByText('Delete');\n userEvent.click(deleteButton);\n\n // The deleted panel should still be on screen in the other group\n const deletedPanel = screen.queryByText(panelTitle);\n expect(deletedPanel).toBeInTheDocument();\n });\n\n it('should swap panels', () => {\n renderDashboard();\n\n // should move panel down\n const groupTitle1 = 'CPU Stats';\n const moveGroupDownBtn = screen.getByLabelText(`move group ${groupTitle1} down`);\n userEvent.click(moveGroupDownBtn);\n\n // should move panel up\n const groupTitle2 = 'Disk Stats';\n const moveGroupUpBtn = screen.getByLabelText(`move group ${groupTitle2} up`);\n userEvent.click(moveGroupUpBtn);\n\n /* TODO: Figure out how to test this visually without coupling to the store\n const layouts = storeApi.getState().layouts;\n expect(layouts[0]?.title).toBe(undefined);\n expect(layouts[1]?.title).toBe('Disk Stats');\n expect(layouts[2]?.title).toBe('CPU Stats');\n */\n });\n\n it('should delete a panel group', () => {\n renderDashboard();\n const groupTitle = 'CPU Stats';\n const deleteGroupIcon = screen.getByLabelText(`delete group ${groupTitle}`);\n userEvent.click(deleteGroupIcon);\n screen.getByText('Delete Panel Group');\n const deleteButton = screen.getByText('Delete');\n userEvent.click(deleteButton);\n\n // should remove group\n const deletedGroup = screen.queryByText(groupTitle);\n expect(deletedGroup).not.toBeInTheDocument();\n\n // CPU panel should be completely gone since it wasn't in any other group\n let panel = screen.queryByText('CPU');\n expect(panel).not.toBeInTheDocument();\n\n // A DiskIO panel should still be present in the other group that wasn't deleted\n panel = screen.queryByText('Disk I/O Utilization');\n expect(panel).toBeInTheDocument();\n });\n});\n"],"names":["screen","userEvent","TimeRangeProvider","DashboardProvider","TemplateVariableProvider","getTestDashboard","renderWithContext","DashboardApp","describe","renderDashboard","initialTimeRange","pastDuration","initialState","dashboardResource","isEditMode","isReadonly","it","panelTitle","deletePanelButton","getByLabelText","click","getByText","deleteButton","deletedPanel","queryByText","expect","not","toBeInTheDocument","panels","getAllByText","toHaveLength","getAllByLabelText","undefined","Error","groupTitle1","moveGroupDownBtn","groupTitle2","moveGroupUpBtn","groupTitle","deleteGroupIcon","deletedGroup","panel"],"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,MAAM,QAAQ,wBAAwB,CAAC;AAChD,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AACpD,SAASC,iBAAiB,QAAQ,2BAA2B,CAAC;AAC9D,SAASC,iBAAiB,EAAEC,wBAAwB,QAAQ,kBAAkB,CAAC;AAC/E,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,eAAe,CAAC;AACpE,SAASC,YAAY,QAAQ,iBAAiB,C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GACF,CAAC,CAAC,CAAC;IAEHrB,EAAE,CAAC,6BAA6B,EAAE,IAAM;QACtCP,eAAe,EAAE,CAAC;QAClB,MAAM6B,UAAU,GAAG,WAAW,AAAC;QAC/B,MAAMC,eAAe,GAAGvC,MAAM,CAACmB,cAAc,CAAC,CAAC,aAAa,EAAEmB,UAAU,CAAC,CAAC,CAAC,AAAC;QAC5ErC,SAAS,CAACmB,KAAK,CAACmB,eAAe,CAAC,CAAC;QACjCvC,MAAM,CAACqB,SAAS,CAAC,oBAAoB,CAAC,CAAC;QACvC,MAAMC,YAAY,GAAGtB,MAAM,CAACqB,SAAS,CAAC,QAAQ,CAAC,AAAC;QAChDpB,SAAS,CAACmB,KAAK,CAACE,YAAY,CAAC,CAAC;QAE9B,sBAAsB;QACtB,MAAMkB,YAAY,GAAGxC,MAAM,CAACwB,WAAW,CAACc,UAAU,CAAC,AAAC;QACpDb,MAAM,CAACe,YAAY,CAAC,CAACd,GAAG,CAACC,iBAAiB,EAAE,CAAC;QAE7C,yEAAyE;QACzE,IAAIc,KAAK,GAAGzC,MAAM,CAACwB,WAAW,CAAC,KAAK,CAAC,AAAC;QACtCC,MAAM,CAACgB,KAAK,CAAC,CAACf,GAAG,CAACC,iBAAiB,EAAE,CAAC;QAEtC,gFAAgF;QAChFc,KAAK,GAAGzC,MAAM,CAACwB,WAAW,CAAC,sBAAsB,CAAC,CAAC;QACnDC,MAAM,CAACgB,KAAK,CAAC,CAACd,iBAAiB,EAAE,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/dashboards",
3
- "version": "0.17.0",
3
+ "version": "0.19.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",
@@ -28,9 +28,9 @@
28
28
  "lint:fix": "eslint --fix src --ext .ts,.tsx"
29
29
  },
30
30
  "dependencies": {
31
- "@perses-dev/components": "^0.17.0",
32
- "@perses-dev/core": "^0.17.0",
33
- "@perses-dev/plugin-system": "^0.17.0",
31
+ "@perses-dev/components": "^0.19.0",
32
+ "@perses-dev/core": "^0.19.0",
33
+ "@perses-dev/plugin-system": "^0.19.0",
34
34
  "@types/react-grid-layout": "^1.3.2",
35
35
  "date-fns": "^2.28.0",
36
36
  "immer": "^9.0.15",
@@ -46,7 +46,7 @@
46
46
  "intersection-observer": "^0.12.2"
47
47
  },
48
48
  "peerDependencies": {
49
- "@mui/material": "^5.6.0",
49
+ "@mui/material": "^5.10.0",
50
50
  "@tanstack/react-query": "^4.7.1",
51
51
  "react": "^17.0.2 || ^18.0.0",
52
52
  "react-dom": "^17.0.2 || ^18.0.0"
@@ -1,91 +0,0 @@
1
- // Copyright 2022 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
- function _export(target, all) {
18
- for(var name in all)Object.defineProperty(target, name, {
19
- enumerable: true,
20
- get: all[name]
21
- });
22
- }
23
- _export(exports, {
24
- TimeRangeProvider: ()=>TimeRangeProvider,
25
- useDashboardTimeRange: ()=>useDashboardTimeRange
26
- });
27
- const _jsxRuntime = require("react/jsx-runtime");
28
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
29
- const _pluginSystem = require("@perses-dev/plugin-system");
30
- const _queryParams = require("./query-params");
31
- function _getRequireWildcardCache(nodeInterop) {
32
- if (typeof WeakMap !== "function") return null;
33
- var cacheBabelInterop = new WeakMap();
34
- var cacheNodeInterop = new WeakMap();
35
- return (_getRequireWildcardCache = function(nodeInterop) {
36
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
37
- })(nodeInterop);
38
- }
39
- function _interopRequireWildcard(obj, nodeInterop) {
40
- if (!nodeInterop && obj && obj.__esModule) {
41
- return obj;
42
- }
43
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
44
- return {
45
- default: obj
46
- };
47
- }
48
- var cache = _getRequireWildcardCache(nodeInterop);
49
- if (cache && cache.has(obj)) {
50
- return cache.get(obj);
51
- }
52
- var newObj = {};
53
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
54
- for(var key in obj){
55
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
56
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
57
- if (desc && (desc.get || desc.set)) {
58
- Object.defineProperty(newObj, key, desc);
59
- } else {
60
- newObj[key] = obj[key];
61
- }
62
- }
63
- }
64
- newObj.default = obj;
65
- if (cache) {
66
- cache.set(obj, newObj);
67
- }
68
- return newObj;
69
- }
70
- function TimeRangeProvider(props) {
71
- const { initialTimeRange , enabledURLParams , children } = props;
72
- const { timeRange , setTimeRange } = (0, _queryParams.useSetTimeRangeParams)(initialTimeRange, enabledURLParams);
73
- const ctx = (0, _react.useMemo)(()=>({
74
- timeRange,
75
- setTimeRange
76
- }), [
77
- timeRange,
78
- setTimeRange
79
- ]);
80
- return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.TimeRangeContext.Provider, {
81
- value: ctx,
82
- children: children
83
- });
84
- }
85
- function useDashboardTimeRange() {
86
- const { timeRange , setTimeRange } = (0, _pluginSystem.useTimeRangeContext)();
87
- return {
88
- timeRange,
89
- setTimeRange
90
- };
91
- }
@@ -1,29 +0,0 @@
1
- // Copyright 2022 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
- _exportStar(require("./TimeRangeProvider"), exports);
18
- _exportStar(require("./query-params"), exports);
19
- function _exportStar(from, to) {
20
- Object.keys(from).forEach(function(k) {
21
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
22
- enumerable: true,
23
- get: function() {
24
- return from[k];
25
- }
26
- });
27
- });
28
- return from;
29
- }