@perses-dev/dashboards 0.20.0 → 0.21.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 (104) hide show
  1. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +18 -5
  2. package/dist/cjs/components/DeletePanelDialog/DeletePanelDialog.js +2 -0
  3. package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +2 -0
  4. package/dist/cjs/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +74 -0
  5. package/dist/cjs/components/{UnsavedChangesConfirmationDialog → DiscardChangesConfirmationDialog}/index.js +1 -1
  6. package/dist/cjs/components/GridLayout/GridTitle.js +38 -22
  7. package/dist/cjs/components/Panel/PanelHeader.js +59 -26
  8. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +29 -8
  9. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +11 -6
  10. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +9 -2
  11. package/dist/cjs/components/Variables/Variable.js +5 -3
  12. package/dist/cjs/components/Variables/VariableEditor.js +115 -99
  13. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +67 -56
  14. package/dist/cjs/components/Variables/VariableList.js +7 -20
  15. package/dist/cjs/components/Variables/variable-model.js +12 -1
  16. package/dist/cjs/components/index.js +1 -1
  17. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +2 -0
  18. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +10 -1
  19. package/dist/cjs/context/DashboardProvider/discard-changes-dialog-slice.js +33 -0
  20. package/dist/cjs/views/ViewDashboard/DashboardApp.js +14 -14
  21. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +2 -1
  22. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +2 -0
  23. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  24. package/dist/components/DashboardToolbar/DashboardToolbar.js +19 -6
  25. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  26. package/dist/components/DeletePanelDialog/DeletePanelDialog.js +2 -0
  27. package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -1
  28. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
  29. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +2 -0
  30. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
  31. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts +3 -0
  32. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts.map +1 -0
  33. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +63 -0
  34. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -0
  35. package/dist/components/DiscardChangesConfirmationDialog/index.d.ts +2 -0
  36. package/dist/components/DiscardChangesConfirmationDialog/index.d.ts.map +1 -0
  37. package/dist/components/{UnsavedChangesConfirmationDialog → DiscardChangesConfirmationDialog}/index.js +1 -1
  38. package/dist/components/{UnsavedChangesConfirmationDialog → DiscardChangesConfirmationDialog}/index.js.map +1 -1
  39. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  40. package/dist/components/GridLayout/GridTitle.js +38 -22
  41. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  42. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  43. package/dist/components/Panel/PanelHeader.js +61 -28
  44. package/dist/components/Panel/PanelHeader.js.map +1 -1
  45. package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
  46. package/dist/components/PanelDrawer/PanelDrawer.js +32 -11
  47. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  48. package/dist/components/PanelDrawer/PanelEditorForm.d.ts +1 -1
  49. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  50. package/dist/components/PanelDrawer/PanelEditorForm.js +12 -7
  51. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  52. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +5 -1
  53. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  54. package/dist/components/TimeRangeControls/TimeRangeControls.js +9 -2
  55. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  56. package/dist/components/Variables/Variable.js +5 -3
  57. package/dist/components/Variables/Variable.js.map +1 -1
  58. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  59. package/dist/components/Variables/VariableEditor.js +115 -99
  60. package/dist/components/Variables/VariableEditor.js.map +1 -1
  61. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  62. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +68 -57
  63. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  64. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  65. package/dist/components/Variables/VariableList.js +7 -20
  66. package/dist/components/Variables/VariableList.js.map +1 -1
  67. package/dist/components/Variables/variable-model.d.ts +7 -0
  68. package/dist/components/Variables/variable-model.d.ts.map +1 -1
  69. package/dist/components/Variables/variable-model.js +10 -0
  70. package/dist/components/Variables/variable-model.js.map +1 -1
  71. package/dist/components/index.d.ts +1 -1
  72. package/dist/components/index.js +1 -1
  73. package/dist/components/index.js.map +1 -1
  74. package/dist/context/DashboardProvider/DashboardProvider.d.ts +2 -1
  75. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  76. package/dist/context/DashboardProvider/DashboardProvider.js +2 -0
  77. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  78. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +5 -0
  79. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  80. package/dist/context/DashboardProvider/dashboard-provider-api.js +8 -0
  81. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  82. package/dist/context/DashboardProvider/discard-changes-dialog-slice.d.ts +15 -0
  83. package/dist/context/DashboardProvider/discard-changes-dialog-slice.d.ts.map +1 -0
  84. package/dist/context/DashboardProvider/discard-changes-dialog-slice.js +27 -0
  85. package/dist/context/DashboardProvider/discard-changes-dialog-slice.js.map +1 -0
  86. package/dist/context/DashboardProvider/index.d.ts +1 -0
  87. package/dist/context/DashboardProvider/index.d.ts.map +1 -1
  88. package/dist/context/DashboardProvider/index.js.map +1 -1
  89. package/dist/views/ViewDashboard/DashboardApp.d.ts +1 -0
  90. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  91. package/dist/views/ViewDashboard/DashboardApp.js +16 -16
  92. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  93. package/dist/views/ViewDashboard/ViewDashboard.d.ts +1 -0
  94. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  95. package/dist/views/ViewDashboard/ViewDashboard.js +2 -1
  96. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  97. package/package.json +4 -4
  98. package/dist/cjs/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js +0 -67
  99. package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts +0 -8
  100. package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts.map +0 -1
  101. package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js +0 -56
  102. package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js.map +0 -1
  103. package/dist/components/UnsavedChangesConfirmationDialog/index.d.ts +0 -2
  104. package/dist/components/UnsavedChangesConfirmationDialog/index.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/DashboardProvider.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 { createStore, useStore } from 'zustand';\nimport type { StoreApi } from 'zustand';\nimport { devtools } from 'zustand/middleware';\nimport { immer } from 'zustand/middleware/immer';\nimport shallow from 'zustand/shallow';\nimport { createContext, useCallback, useContext, useState } from 'react';\nimport { DashboardResource, ProjectMetadata, RelativeTimeRange } from '@perses-dev/core';\nimport { createPanelGroupEditorSlice, PanelGroupEditorSlice } from './panel-group-editor-slice';\nimport { convertLayoutsToPanelGroups, createPanelGroupSlice, PanelGroupSlice } from './panel-group-slice';\nimport { createPanelEditorSlice, PanelEditorSlice } from './panel-editor-slice';\nimport { createPanelSlice, PanelSlice } from './panel-slice';\nimport { createDeletePanelGroupSlice, DeletePanelGroupSlice } from './delete-panel-group-slice';\nimport { createDeletePanelSlice, DeletePanelSlice } from './delete-panel-slice';\n\nexport interface DashboardStoreState\n extends PanelGroupSlice,\n PanelSlice,\n PanelGroupEditorSlice,\n DeletePanelGroupSlice,\n PanelEditorSlice,\n DeletePanelSlice {\n isEditMode: boolean;\n setEditMode: (isEditMode: boolean) => void;\n defaultTimeRange: RelativeTimeRange;\n setDashboard: (dashboard: DashboardResource) => void;\n metadata: ProjectMetadata;\n}\n\nexport interface DashboardStoreProps {\n dashboardResource: DashboardResource;\n isEditMode?: boolean;\n}\n\nexport interface DashboardProviderProps {\n initialState: DashboardStoreProps;\n children?: React.ReactNode;\n}\n\nexport const DashboardContext = createContext<StoreApi<DashboardStoreState> | undefined>(undefined);\n\nexport function useDashboardStore<T>(selector: (state: DashboardStoreState) => T) {\n const store = useContext(DashboardContext);\n if (store === undefined) {\n throw new Error('No DashboardContext found. Did you forget a Provider?');\n }\n return useStore(store, selector, shallow);\n}\n\nexport function DashboardProvider(props: DashboardProviderProps) {\n const createDashboardStore = useCallback(initStore, [props]);\n\n const [store] = useState(createDashboardStore(props)); // prevent calling createDashboardStore every time it rerenders\n\n return (\n <DashboardContext.Provider value={store as StoreApi<DashboardStoreState>}>\n {props.children}\n </DashboardContext.Provider>\n );\n}\n\nfunction initStore(props: DashboardProviderProps) {\n const {\n initialState: { dashboardResource, isEditMode },\n } = props;\n\n const {\n spec: { layouts, panels, duration },\n metadata,\n } = dashboardResource;\n const store = createStore<DashboardStoreState>()(\n immer(\n devtools((...args) => {\n const [set] = args;\n return {\n ...createPanelGroupSlice(layouts)(...args),\n ...createPanelSlice(panels)(...args),\n ...createPanelGroupEditorSlice(...args),\n ...createDeletePanelGroupSlice(...args),\n ...createPanelEditorSlice()(...args),\n ...createDeletePanelSlice()(...args),\n metadata,\n defaultTimeRange: { pastDuration: duration },\n isEditMode: !!isEditMode,\n setEditMode: (isEditMode: boolean) => set({ isEditMode }),\n setDashboard: ({ metadata, spec: { panels, layouts } }) => {\n set((state) => {\n state.metadata = metadata;\n const { panelGroups, panelGroupOrder } = convertLayoutsToPanelGroups(layouts);\n state.panels = panels;\n state.panelGroups = panelGroups;\n state.panelGroupOrder = panelGroupOrder;\n });\n },\n };\n })\n )\n );\n\n return store;\n}\n"],"names":["createStore","useStore","devtools","immer","shallow","createContext","useCallback","useContext","useState","createPanelGroupEditorSlice","convertLayoutsToPanelGroups","createPanelGroupSlice","createPanelEditorSlice","createPanelSlice","createDeletePanelGroupSlice","createDeletePanelSlice","DashboardContext","undefined","useDashboardStore","selector","store","Error","DashboardProvider","props","createDashboardStore","initStore","Provider","value","children","initialState","dashboardResource","isEditMode","spec","layouts","panels","duration","metadata","args","set","defaultTimeRange","pastDuration","setEditMode","setDashboard","state","panelGroups","panelGroupOrder"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEA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;oBAC1B,MAAM,EAAEQ,WAAW,CAAA,EAAEC,eAAe,CAAA,EAAE,GAAGnC,2BAA2B,CAACuB,OAAO,CAAC,AAAC;oBAC9EU,KAAK,CAACT,MAAM,GAAGA,MAAM,CAAC;oBACtBS,KAAK,CAACC,WAAW,GAAGA,WAAW,CAAC;oBAChCD,KAAK,CAACE,eAAe,GAAGA,eAAe,CAAC;gBAC1C,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC,CAAC,CACH,CACF,AAAC;IAEF,OAAOzB,KAAK,CAAC;AACf,CAAC"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/DashboardProvider.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 { createStore, useStore } from 'zustand';\nimport type { StoreApi } from 'zustand';\nimport { devtools } from 'zustand/middleware';\nimport { immer } from 'zustand/middleware/immer';\nimport shallow from 'zustand/shallow';\nimport { createContext, useCallback, useContext, useState } from 'react';\nimport { DashboardResource, ProjectMetadata, RelativeTimeRange } from '@perses-dev/core';\nimport { createPanelGroupEditorSlice, PanelGroupEditorSlice } from './panel-group-editor-slice';\nimport { convertLayoutsToPanelGroups, createPanelGroupSlice, PanelGroupSlice } from './panel-group-slice';\nimport { createPanelEditorSlice, PanelEditorSlice } from './panel-editor-slice';\nimport { createPanelSlice, PanelSlice } from './panel-slice';\nimport { createDeletePanelGroupSlice, DeletePanelGroupSlice } from './delete-panel-group-slice';\nimport { createDeletePanelSlice, DeletePanelSlice } from './delete-panel-slice';\nimport { createDiscardChangesDialogSlice, DiscardChangesConfirmationDialogSlice } from './discard-changes-dialog-slice';\n\nexport interface DashboardStoreState\n extends PanelGroupSlice,\n PanelSlice,\n PanelGroupEditorSlice,\n DeletePanelGroupSlice,\n PanelEditorSlice,\n DeletePanelSlice,\n DiscardChangesConfirmationDialogSlice {\n isEditMode: boolean;\n setEditMode: (isEditMode: boolean) => void;\n defaultTimeRange: RelativeTimeRange;\n setDashboard: (dashboard: DashboardResource) => void;\n metadata: ProjectMetadata;\n}\n\nexport interface DashboardStoreProps {\n dashboardResource: DashboardResource;\n isEditMode?: boolean;\n}\n\nexport interface DashboardProviderProps {\n initialState: DashboardStoreProps;\n children?: React.ReactNode;\n}\n\nexport const DashboardContext = createContext<StoreApi<DashboardStoreState> | undefined>(undefined);\n\nexport function useDashboardStore<T>(selector: (state: DashboardStoreState) => T) {\n const store = useContext(DashboardContext);\n if (store === undefined) {\n throw new Error('No DashboardContext found. Did you forget a Provider?');\n }\n return useStore(store, selector, shallow);\n}\n\nexport function DashboardProvider(props: DashboardProviderProps) {\n const createDashboardStore = useCallback(initStore, [props]);\n\n const [store] = useState(createDashboardStore(props)); // prevent calling createDashboardStore every time it rerenders\n\n return (\n <DashboardContext.Provider value={store as StoreApi<DashboardStoreState>}>\n {props.children}\n </DashboardContext.Provider>\n );\n}\n\nfunction initStore(props: DashboardProviderProps) {\n const {\n initialState: { dashboardResource, isEditMode },\n } = props;\n\n const {\n spec: { layouts, panels, duration },\n metadata,\n } = dashboardResource;\n const store = createStore<DashboardStoreState>()(\n immer(\n devtools((...args) => {\n const [set] = args;\n return {\n ...createPanelGroupSlice(layouts)(...args),\n ...createPanelSlice(panels)(...args),\n ...createPanelGroupEditorSlice(...args),\n ...createDeletePanelGroupSlice(...args),\n ...createPanelEditorSlice()(...args),\n ...createDeletePanelSlice()(...args),\n ...createDiscardChangesDialogSlice(...args),\n metadata,\n defaultTimeRange: { pastDuration: duration },\n isEditMode: !!isEditMode,\n setEditMode: (isEditMode: boolean) => set({ isEditMode }),\n setDashboard: ({ metadata, spec: { panels, layouts } }) => {\n set((state) => {\n state.metadata = metadata;\n const { panelGroups, panelGroupOrder } = convertLayoutsToPanelGroups(layouts);\n state.panels = panels;\n state.panelGroups = panelGroups;\n state.panelGroupOrder = panelGroupOrder;\n });\n },\n };\n })\n )\n );\n\n return store;\n}\n"],"names":["createStore","useStore","devtools","immer","shallow","createContext","useCallback","useContext","useState","createPanelGroupEditorSlice","convertLayoutsToPanelGroups","createPanelGroupSlice","createPanelEditorSlice","createPanelSlice","createDeletePanelGroupSlice","createDeletePanelSlice","createDiscardChangesDialogSlice","DashboardContext","undefined","useDashboardStore","selector","store","Error","DashboardProvider","props","createDashboardStore","initStore","Provider","value","children","initialState","dashboardResource","isEditMode","spec","layouts","panels","duration","metadata","args","set","defaultTimeRange","pastDuration","setEditMode","setDashboard","state","panelGroups","panelGroupOrder"],"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,QAAQ,QAAQ,SAAS,CAAC;AAEhD,SAASC,QAAQ,QAAQ,oBAAoB,CAAC;AAC9C,SAASC,KAAK,QAAQ,0BAA0B,CAAC;AACjD,OAAOC,OAAO,MAAM,iBAAiB,CAAC;AACtC,SAASC,aAAa,EAAEC,WAAW,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AAEzE,SAASC,2BAA2B,QAA+B,4BAA4B,CAAC;AAChG,SAASC,2BAA2B,EAAEC,qBAAqB,QAAyB,qBAAqB,CAAC;AAC1G,SAASC,sBAAsB,QAA0B,sBAAsB,CAAC;AAChF,SAASC,gBAAgB,QAAoB,eAAe,CAAC;AAC7D,SAASC,2BAA2B,QAA+B,4BAA4B,CAAC;AAChG,SAASC,sBAAsB,QAA0B,sBAAsB,CAAC;AAChF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qBAAqB,CAACuB,OAAO,CAAC,IAAII,IAAI,CAAC;YAC1C,GAAGzB,gBAAgB,CAACsB,MAAM,CAAC,IAAIG,IAAI,CAAC;YACpC,GAAG7B,2BAA2B,IAAI6B,IAAI,CAAC;YACvC,GAAGxB,2BAA2B,IAAIwB,IAAI,CAAC;YACvC,GAAG1B,sBAAsB,EAAE,IAAI0B,IAAI,CAAC;YACpC,GAAGvB,sBAAsB,EAAE,IAAIuB,IAAI,CAAC;YACpC,GAAGtB,+BAA+B,IAAIsB,IAAI,CAAC;YAC3CD,QAAQ;YACRG,gBAAgB,EAAE;gBAAEC,YAAY,EAAEL,QAAQ;aAAE;YAC5CJ,UAAU,EAAE,CAAC,CAACA,UAAU;YACxBU,WAAW,EAAE,CAACV,UAAmB,GAAKO,GAAG,CAAC;oBAAEP,UAAU;iBAAE,CAAC;YACzDW,YAAY,EAAE,CAAC,EAAEN,QAAQ,CAAA,EAAEJ,IAAI,EAAE,EAAEE,MAAM,CAAA,EAAED,OAAO,CAAA,EAAE,CAAA,EAAE,GAAK;gBACzDK,GAAG,CAAC,CAACK,KAAK,GAAK;oBACbA,KAAK,CAACP,QAAQ,GAAGA,QAAQ,CAAC;oBAC1B,MAAM,EAAEQ,WAAW,CAAA,EAAEC,eAAe,CAAA,EAAE,GAAGpC,2BAA2B,CAACwB,OAAO,CAAC,AAAC;oBAC9EU,KAAK,CAACT,MAAM,GAAGA,MAAM,CAAC;oBACtBS,KAAK,CAACC,WAAW,GAAGA,WAAW,CAAC;oBAChCD,KAAK,CAACE,eAAe,GAAGA,eAAe,CAAC;gBAC1C,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC,CAAC,CACH,CACF,AAAC;IAEF,OAAOzB,KAAK,CAAC;AACf,CAAC"}
@@ -71,4 +71,9 @@ export declare function useDeletePanelDialog(): {
71
71
  closeDeletePanelDialog: () => void;
72
72
  };
73
73
  export declare function useDefaultTimeRange(): import("@perses-dev/core").RelativeTimeRange;
74
+ export declare function useDiscardChangesConfirmationDialog(): {
75
+ discardChangesConfirmationDialog: import("./discard-changes-dialog-slice").DiscardChangesConfirmationDialogState | undefined;
76
+ openDiscardChangesConfirmationDialog: (discardChangesConfirmationDialog: import("./discard-changes-dialog-slice").DiscardChangesConfirmationDialogState) => void;
77
+ closeDiscardChangesConfirmationDialog: () => void;
78
+ };
74
79
  //# sourceMappingURL=dashboard-provider-api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dashboard-provider-api.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/dashboard-provider-api.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAG3F,wBAAgB,WAAW;;;EAE1B;AAOD;;GAEG;AACH,wBAAgB,mBAAmB;;;;EAOlC;AAGD;;GAEG;AACH,wBAAgB,gBAAgB,aAE/B;AAGD;;GAEG;AACH,wBAAgB,kBAAkB,yDAYjC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,YAAY,EAAE,YAAY,sDAMvD;AAaD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,YAAY;;;;;;2CAWpB,oBAAoB,EAAE;EAGhE;AA4BD;;GAEG;AACH,wBAAgB,mBAAmB,sEAElC;AAaD;;GAEG;AACH,wBAAgB,yBAAyB;;;;;EASxC;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,sFAiB1D;AAMD;;GAEG;AACH,wBAAgB,eAAe,CAAC,gBAAgB,EAAE,gBAAgB;;;EAMjE;AAGD;;GAEG;AACH,wBAAgB,cAAc,gEAE7B;AAQD;;GAEG;AACH,wBAAgB,oBAAoB;;;;EAGnC;AAGD,wBAAgB,mBAAmB,iDAElC"}
1
+ {"version":3,"file":"dashboard-provider-api.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/dashboard-provider-api.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAG3F,wBAAgB,WAAW;;;EAE1B;AAOD;;GAEG;AACH,wBAAgB,mBAAmB;;;;EAOlC;AAGD;;GAEG;AACH,wBAAgB,gBAAgB,aAE/B;AAGD;;GAEG;AACH,wBAAgB,kBAAkB,yDAYjC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,YAAY,EAAE,YAAY,sDAMvD;AAaD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,YAAY;;;;;;2CAWpB,oBAAoB,EAAE;EAGhE;AA4BD;;GAEG;AACH,wBAAgB,mBAAmB,sEAElC;AAaD;;GAEG;AACH,wBAAgB,yBAAyB;;;;;EASxC;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,sFAiB1D;AAMD;;GAEG;AACH,wBAAgB,eAAe,CAAC,gBAAgB,EAAE,gBAAgB;;;EAMjE;AAGD;;GAEG;AACH,wBAAgB,cAAc,gEAE7B;AAQD;;GAEG;AACH,wBAAgB,oBAAoB;;;;EAGnC;AAGD,wBAAgB,mBAAmB,iDAElC;AAWD,wBAAgB,mCAAmC;;;;EAElD"}
@@ -186,5 +186,13 @@ const selectDefaultTimeRange = (state)=>state.defaultTimeRange;
186
186
  export function useDefaultTimeRange() {
187
187
  return useDashboardStore(selectDefaultTimeRange);
188
188
  }
189
+ const selectDiscardChangesConfirmationDialog = ({ discardChangesConfirmationDialog , openDiscardChangesConfirmationDialog , closeDiscardChangesConfirmationDialog })=>({
190
+ discardChangesConfirmationDialog,
191
+ openDiscardChangesConfirmationDialog,
192
+ closeDiscardChangesConfirmationDialog
193
+ });
194
+ export function useDiscardChangesConfirmationDialog() {
195
+ return useDashboardStore(selectDiscardChangesConfirmationDialog);
196
+ }
189
197
 
190
198
  //# sourceMappingURL=dashboard-provider-api.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/dashboard-provider-api.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 { useCallback, useMemo } from 'react';\nimport { DashboardStoreState, useDashboardStore } from './DashboardProvider';\nimport { PanelGroupItemId, PanelGroupId, PanelGroupItemLayout } from './panel-group-slice';\n\nconst selectEditMode = ({ isEditMode, setEditMode }: DashboardStoreState) => ({ isEditMode, setEditMode });\nexport function useEditMode() {\n return useDashboardStore(selectEditMode);\n}\n\nconst selectDashboardActions = ({ setDashboard, openAddPanelGroup, openAddPanel }: DashboardStoreState) => ({\n setDashboard,\n openAddPanelGroup,\n openAddPanel,\n});\n/**\n * Returns actions that can be performed on the current dashboard.\n */\nexport function useDashboardActions() {\n const { setDashboard, openAddPanelGroup, openAddPanel } = useDashboardStore(selectDashboardActions);\n return {\n setDashboard,\n openAddPanelGroup: () => openAddPanelGroup(),\n openAddPanel: () => openAddPanel(),\n };\n}\n\nconst selectPanelGroupOrder = (state: DashboardStoreState) => state.panelGroupOrder;\n/**\n * Returns an array of PanelGroupIds in the order they appear in the dashboard.\n */\nexport function usePanelGroupIds() {\n return useDashboardStore(selectPanelGroupOrder);\n}\n\nconst selectPanelGroups = (state: DashboardStoreState) => state.panelGroups;\n/**\n * Returns an array of PanelGroupDefinitions in the order they appear in the dashboard.\n */\nexport function useListPanelGroups() {\n const panelGroupIds = usePanelGroupIds();\n const panelGroups = useDashboardStore(selectPanelGroups);\n return useMemo(() => {\n return panelGroupIds.map((id) => {\n const group = panelGroups[id];\n if (group === undefined) {\n throw new Error(`Invalid panel group Id found ${id}`);\n }\n return group;\n });\n }, [panelGroupIds, panelGroups]);\n}\n\n/**\n * Gets a specific panel group by its id. Throws if the panel group does not exist.\n */\nexport function usePanelGroup(panelGroupId: PanelGroupId) {\n const panelGroup = useDashboardStore(useCallback((state) => state.panelGroups[panelGroupId], [panelGroupId]));\n if (panelGroup === undefined) {\n throw new Error(`Panel group with Id ${panelGroupId} was not found`);\n }\n return panelGroup;\n}\n\nconst selectPanelGroupActions = ({\n openEditPanelGroup,\n deletePanelGroup,\n openAddPanel,\n updatePanelGroupLayouts,\n}: DashboardStoreState) => ({\n openEditPanelGroup,\n deletePanelGroup,\n openAddPanel,\n updatePanelGroupLayouts,\n});\n/**\n * Returns actions that can be performed on the given panel group.\n */\nexport function usePanelGroupActions(panelGroupId: PanelGroupId) {\n const { moveUp, moveDown } = useMovePanelGroup(panelGroupId);\n const { openEditPanelGroup, deletePanelGroup, openAddPanel, updatePanelGroupLayouts } =\n useDashboardStore(selectPanelGroupActions);\n\n return {\n openEditPanelGroup: () => openEditPanelGroup(panelGroupId),\n deletePanelGroup: () => deletePanelGroup(panelGroupId),\n openAddPanel: () => openAddPanel(panelGroupId),\n moveUp,\n moveDown,\n updatePanelGroupLayouts: (itemLayouts: PanelGroupItemLayout[]) =>\n updatePanelGroupLayouts(panelGroupId, itemLayouts),\n };\n}\n\nconst selectSwapPanelGroups = (state: DashboardStoreState) => state.swapPanelGroups;\nconst selectPanelGroupsLength = (state: DashboardStoreState) => state.panelGroupOrder.length;\n/**\n * Returns functions for moving a panel group up or down. A function will be undefined if the panel group can't be\n * moved in that direction.\n */\nfunction useMovePanelGroup(panelGroupId: PanelGroupId) {\n const currentIndex = useDashboardStore(\n useCallback((store) => store.panelGroupOrder.findIndex((id) => id === panelGroupId), [panelGroupId])\n );\n const panelGroupsLength = useDashboardStore(selectPanelGroupsLength);\n const swapPanelGroups = useDashboardStore(selectSwapPanelGroups);\n\n if (currentIndex < 0) {\n throw new Error(`Could not find panel group with Id ${panelGroupId} in order array`);\n }\n\n const moveUp = () => swapPanelGroups(currentIndex, currentIndex - 1);\n const moveDown = () => swapPanelGroups(currentIndex, currentIndex + 1);\n return {\n moveUp: currentIndex > 0 ? moveUp : undefined,\n moveDown: currentIndex < panelGroupsLength - 1 ? moveDown : undefined,\n };\n}\n\nconst selectPanelGroupEditor = (state: DashboardStoreState) => state.panelGroupEditor;\n/**\n * Gets the Panel Group editor state.\n */\nexport function usePanelGroupEditor() {\n return useDashboardStore(selectPanelGroupEditor);\n}\n\nconst selectDeletePanelGroupDialog = ({\n deletePanelGroupDialog,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog,\n deletePanelGroup,\n}: DashboardStoreState) => ({\n deletePanelGroupDialog,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog,\n deletePanelGroup,\n});\n/**\n * Gets the Delete Panel Group dialog state.\n */\nexport function useDeletePanelGroupDialog() {\n const { deletePanelGroupDialog, openDeletePanelGroupDialog, closeDeletePanelGroupDialog, deletePanelGroup } =\n useDashboardStore(selectDeletePanelGroupDialog);\n return {\n deletePanelGroupDialog,\n deletePanelGroup,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog: () => closeDeletePanelGroupDialog(),\n };\n}\n\n/**\n * Gets an individual panel in the store. Throws if the panel can't be found.\n */\nexport function usePanel(panelGroupItemId: PanelGroupItemId) {\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const panel = useDashboardStore(\n useCallback(\n (store) => {\n const panelKey = store.panelGroups[panelGroupId]?.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) return;\n return store.panels[panelKey];\n },\n [panelGroupId, panelGroupLayoutId]\n )\n );\n\n if (panel === undefined) {\n throw new Error(`Could not find panel for Id ${panelGroupItemId}`);\n }\n return panel;\n}\n\nconst selectPanelActions = ({ openEditPanel, openDeletePanelDialog }: DashboardStoreState) => ({\n openEditPanel,\n openDeletePanelDialog,\n});\n/**\n * Returns actions that can be performed on the given Panel.\n */\nexport function usePanelActions(panelGroupItemId: PanelGroupItemId) {\n const { openEditPanel, openDeletePanelDialog } = useDashboardStore(selectPanelActions);\n return {\n openEditPanel: () => openEditPanel(panelGroupItemId),\n openDeletePanelDialog: () => openDeletePanelDialog(panelGroupItemId),\n };\n}\n\nconst selectPanelEditor = (state: DashboardStoreState) => state.panelEditor;\n/**\n * Gets the state for the Panel Editor.\n */\nexport function usePanelEditor() {\n return useDashboardStore(selectPanelEditor);\n}\n\nconst selectDeletePanelDialog = ({ deletePanelDialog, deletePanel, closeDeletePanelDialog }: DashboardStoreState) => ({\n deletePanelDialog,\n deletePanel,\n closeDeletePanelDialog,\n});\n\n/**\n * Gets the state for the Delete Panel dialog.\n */\nexport function useDeletePanelDialog() {\n // TODO: Refactor similar to other dialogs/editors so these are on the editor state itself\n return useDashboardStore(selectDeletePanelDialog);\n}\n\nconst selectDefaultTimeRange = (state: DashboardStoreState) => state.defaultTimeRange;\nexport function useDefaultTimeRange() {\n return useDashboardStore(selectDefaultTimeRange);\n}\n"],"names":["useCallback","useMemo","useDashboardStore","selectEditMode","isEditMode","setEditMode","useEditMode","selectDashboardActions","setDashboard","openAddPanelGroup","openAddPanel","useDashboardActions","selectPanelGroupOrder","state","panelGroupOrder","usePanelGroupIds","selectPanelGroups","panelGroups","useListPanelGroups","panelGroupIds","map","id","group","undefined","Error","usePanelGroup","panelGroupId","panelGroup","selectPanelGroupActions","openEditPanelGroup","deletePanelGroup","updatePanelGroupLayouts","usePanelGroupActions","moveUp","moveDown","useMovePanelGroup","itemLayouts","selectSwapPanelGroups","swapPanelGroups","selectPanelGroupsLength","length","currentIndex","store","findIndex","panelGroupsLength","selectPanelGroupEditor","panelGroupEditor","usePanelGroupEditor","selectDeletePanelGroupDialog","deletePanelGroupDialog","openDeletePanelGroupDialog","closeDeletePanelGroupDialog","useDeletePanelGroupDialog","usePanel","panelGroupItemId","panelGroupItemLayoutId","panelGroupLayoutId","panel","panelKey","itemPanelKeys","panels","selectPanelActions","openEditPanel","openDeletePanelDialog","usePanelActions","selectPanelEditor","panelEditor","usePanelEditor","selectDeletePanelDialog","deletePanelDialog","deletePanel","closeDeletePanelDialog","useDeletePanelDialog","selectDefaultTimeRange","defaultTimeRange","useDefaultTimeRange"],"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,WAAW,EAAEC,OAAO,QAAQ,OAAO,CAAC;AAC7C,SAA8BC,iBAAiB,QAAQ,qBAAqB,CAAC;AAG7E,MAAMC,cAAc,GAAG,CAAC,EAAEC,UAAU,CAAA,EAAEC,WAAW,CAAA,EAAuB,GAAM,CAAA;QAAED,UAAU;QAAEC,WAAW;KAAE,CAAA,AAAC,AAAC;AAC3G,OAAO,SAASC,WAAW,GAAG;IAC5B,OAAOJ,iBAAiB,CAACC,cAAc,CAAC,CAAC;AAC3C,CAAC;AAED,MAAMI,sBAAsB,GAAG,CAAC,EAAEC,YAAY,CAAA,EAAEC,iBAAiB,CAAA,EAAEC,YAAY,CAAA,EAAuB,GAAM,CAAA;QAC1GF,YAAY;QACZC,iBAAiB;QACjBC,YAAY;KACb,CAAA,AAAC,AAAC;AACH;;CAEC,GACD,OAAO,SAASC,mBAAmB,GAAG;IACpC,MAAM,EAAEH,YAAY,CAAA,EAAEC,iBAAiB,CAAA,EAAEC,YAAY,CAAA,EAAE,GAAGR,iBAAiB,CAACK,sBAAsB,CAAC,AAAC;IACpG,OAAO;QACLC,YAAY;QACZC,iBAAiB,EAAE,IAAMA,iBAAiB,EAAE;QAC5CC,YAAY,EAAE,IAAMA,YAAY,EAAE;KACnC,CAAC;AACJ,CAAC;AAED,MAAME,qBAAqB,GAAG,CAACC,KAA0B,GAAKA,KAAK,CAACC,eAAe,AAAC;AACpF;;CAEC,GACD,OAAO,SAASC,gBAAgB,GAAG;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E,CAAC;AACJ,CAAC;AAED,MAAMW,iBAAiB,GAAG,CAACpD,KAA0B,GAAKA,KAAK,CAACqD,WAAW,AAAC;AAC5E;;CAEC,GACD,OAAO,SAASC,cAAc,GAAG;IAC/B,OAAOjE,iBAAiB,CAAC+D,iBAAiB,CAAC,CAAC;AAC9C,CAAC;AAED,MAAMG,uBAAuB,GAAG,CAAC,EAAEC,iBAAiB,CAAA,EAAEC,WAAW,CAAA,EAAEC,sBAAsB,CAAA,EAAuB,GAAM,CAAA;QACpHF,iBAAiB;QACjBC,WAAW;QACXC,sBAAsB;KACvB,CAAA,AAAC,AAAC;AAEH;;CAEC,GACD,OAAO,SAASC,oBAAoB,GAAG;IACrC,0FAA0F;IAC1F,OAAOtE,iBAAiB,CAACkE,uBAAuB,CAAC,CAAC;AACpD,CAAC;AAED,MAAMK,sBAAsB,GAAG,CAAC5D,KAA0B,GAAKA,KAAK,CAAC6D,gBAAgB,AAAC;AACtF,OAAO,SAASC,mBAAmB,GAAG;IACpC,OAAOzE,iBAAiB,CAACuE,sBAAsB,CAAC,CAAC;AACnD,CAAC"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/dashboard-provider-api.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 { useCallback, useMemo } from 'react';\nimport { DashboardStoreState, useDashboardStore } from './DashboardProvider';\nimport { PanelGroupItemId, PanelGroupId, PanelGroupItemLayout } from './panel-group-slice';\n\nconst selectEditMode = ({ isEditMode, setEditMode }: DashboardStoreState) => ({ isEditMode, setEditMode });\nexport function useEditMode() {\n return useDashboardStore(selectEditMode);\n}\n\nconst selectDashboardActions = ({ setDashboard, openAddPanelGroup, openAddPanel }: DashboardStoreState) => ({\n setDashboard,\n openAddPanelGroup,\n openAddPanel,\n});\n/**\n * Returns actions that can be performed on the current dashboard.\n */\nexport function useDashboardActions() {\n const { setDashboard, openAddPanelGroup, openAddPanel } = useDashboardStore(selectDashboardActions);\n return {\n setDashboard,\n openAddPanelGroup: () => openAddPanelGroup(),\n openAddPanel: () => openAddPanel(),\n };\n}\n\nconst selectPanelGroupOrder = (state: DashboardStoreState) => state.panelGroupOrder;\n/**\n * Returns an array of PanelGroupIds in the order they appear in the dashboard.\n */\nexport function usePanelGroupIds() {\n return useDashboardStore(selectPanelGroupOrder);\n}\n\nconst selectPanelGroups = (state: DashboardStoreState) => state.panelGroups;\n/**\n * Returns an array of PanelGroupDefinitions in the order they appear in the dashboard.\n */\nexport function useListPanelGroups() {\n const panelGroupIds = usePanelGroupIds();\n const panelGroups = useDashboardStore(selectPanelGroups);\n return useMemo(() => {\n return panelGroupIds.map((id) => {\n const group = panelGroups[id];\n if (group === undefined) {\n throw new Error(`Invalid panel group Id found ${id}`);\n }\n return group;\n });\n }, [panelGroupIds, panelGroups]);\n}\n\n/**\n * Gets a specific panel group by its id. Throws if the panel group does not exist.\n */\nexport function usePanelGroup(panelGroupId: PanelGroupId) {\n const panelGroup = useDashboardStore(useCallback((state) => state.panelGroups[panelGroupId], [panelGroupId]));\n if (panelGroup === undefined) {\n throw new Error(`Panel group with Id ${panelGroupId} was not found`);\n }\n return panelGroup;\n}\n\nconst selectPanelGroupActions = ({\n openEditPanelGroup,\n deletePanelGroup,\n openAddPanel,\n updatePanelGroupLayouts,\n}: DashboardStoreState) => ({\n openEditPanelGroup,\n deletePanelGroup,\n openAddPanel,\n updatePanelGroupLayouts,\n});\n/**\n * Returns actions that can be performed on the given panel group.\n */\nexport function usePanelGroupActions(panelGroupId: PanelGroupId) {\n const { moveUp, moveDown } = useMovePanelGroup(panelGroupId);\n const { openEditPanelGroup, deletePanelGroup, openAddPanel, updatePanelGroupLayouts } =\n useDashboardStore(selectPanelGroupActions);\n\n return {\n openEditPanelGroup: () => openEditPanelGroup(panelGroupId),\n deletePanelGroup: () => deletePanelGroup(panelGroupId),\n openAddPanel: () => openAddPanel(panelGroupId),\n moveUp,\n moveDown,\n updatePanelGroupLayouts: (itemLayouts: PanelGroupItemLayout[]) =>\n updatePanelGroupLayouts(panelGroupId, itemLayouts),\n };\n}\n\nconst selectSwapPanelGroups = (state: DashboardStoreState) => state.swapPanelGroups;\nconst selectPanelGroupsLength = (state: DashboardStoreState) => state.panelGroupOrder.length;\n/**\n * Returns functions for moving a panel group up or down. A function will be undefined if the panel group can't be\n * moved in that direction.\n */\nfunction useMovePanelGroup(panelGroupId: PanelGroupId) {\n const currentIndex = useDashboardStore(\n useCallback((store) => store.panelGroupOrder.findIndex((id) => id === panelGroupId), [panelGroupId])\n );\n const panelGroupsLength = useDashboardStore(selectPanelGroupsLength);\n const swapPanelGroups = useDashboardStore(selectSwapPanelGroups);\n\n if (currentIndex < 0) {\n throw new Error(`Could not find panel group with Id ${panelGroupId} in order array`);\n }\n\n const moveUp = () => swapPanelGroups(currentIndex, currentIndex - 1);\n const moveDown = () => swapPanelGroups(currentIndex, currentIndex + 1);\n return {\n moveUp: currentIndex > 0 ? moveUp : undefined,\n moveDown: currentIndex < panelGroupsLength - 1 ? moveDown : undefined,\n };\n}\n\nconst selectPanelGroupEditor = (state: DashboardStoreState) => state.panelGroupEditor;\n/**\n * Gets the Panel Group editor state.\n */\nexport function usePanelGroupEditor() {\n return useDashboardStore(selectPanelGroupEditor);\n}\n\nconst selectDeletePanelGroupDialog = ({\n deletePanelGroupDialog,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog,\n deletePanelGroup,\n}: DashboardStoreState) => ({\n deletePanelGroupDialog,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog,\n deletePanelGroup,\n});\n/**\n * Gets the Delete Panel Group dialog state.\n */\nexport function useDeletePanelGroupDialog() {\n const { deletePanelGroupDialog, openDeletePanelGroupDialog, closeDeletePanelGroupDialog, deletePanelGroup } =\n useDashboardStore(selectDeletePanelGroupDialog);\n return {\n deletePanelGroupDialog,\n deletePanelGroup,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog: () => closeDeletePanelGroupDialog(),\n };\n}\n\n/**\n * Gets an individual panel in the store. Throws if the panel can't be found.\n */\nexport function usePanel(panelGroupItemId: PanelGroupItemId) {\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const panel = useDashboardStore(\n useCallback(\n (store) => {\n const panelKey = store.panelGroups[panelGroupId]?.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) return;\n return store.panels[panelKey];\n },\n [panelGroupId, panelGroupLayoutId]\n )\n );\n\n if (panel === undefined) {\n throw new Error(`Could not find panel for Id ${panelGroupItemId}`);\n }\n return panel;\n}\n\nconst selectPanelActions = ({ openEditPanel, openDeletePanelDialog }: DashboardStoreState) => ({\n openEditPanel,\n openDeletePanelDialog,\n});\n/**\n * Returns actions that can be performed on the given Panel.\n */\nexport function usePanelActions(panelGroupItemId: PanelGroupItemId) {\n const { openEditPanel, openDeletePanelDialog } = useDashboardStore(selectPanelActions);\n return {\n openEditPanel: () => openEditPanel(panelGroupItemId),\n openDeletePanelDialog: () => openDeletePanelDialog(panelGroupItemId),\n };\n}\n\nconst selectPanelEditor = (state: DashboardStoreState) => state.panelEditor;\n/**\n * Gets the state for the Panel Editor.\n */\nexport function usePanelEditor() {\n return useDashboardStore(selectPanelEditor);\n}\n\nconst selectDeletePanelDialog = ({ deletePanelDialog, deletePanel, closeDeletePanelDialog }: DashboardStoreState) => ({\n deletePanelDialog,\n deletePanel,\n closeDeletePanelDialog,\n});\n\n/**\n * Gets the state for the Delete Panel dialog.\n */\nexport function useDeletePanelDialog() {\n // TODO: Refactor similar to other dialogs/editors so these are on the editor state itself\n return useDashboardStore(selectDeletePanelDialog);\n}\n\nconst selectDefaultTimeRange = (state: DashboardStoreState) => state.defaultTimeRange;\nexport function useDefaultTimeRange() {\n return useDashboardStore(selectDefaultTimeRange);\n}\n\nconst selectDiscardChangesConfirmationDialog = ({\n discardChangesConfirmationDialog,\n openDiscardChangesConfirmationDialog,\n closeDiscardChangesConfirmationDialog,\n}: DashboardStoreState) => ({\n discardChangesConfirmationDialog,\n openDiscardChangesConfirmationDialog,\n closeDiscardChangesConfirmationDialog,\n});\nexport function useDiscardChangesConfirmationDialog() {\n return useDashboardStore(selectDiscardChangesConfirmationDialog);\n}\n"],"names":["useCallback","useMemo","useDashboardStore","selectEditMode","isEditMode","setEditMode","useEditMode","selectDashboardActions","setDashboard","openAddPanelGroup","openAddPanel","useDashboardActions","selectPanelGroupOrder","state","panelGroupOrder","usePanelGroupIds","selectPanelGroups","panelGroups","useListPanelGroups","panelGroupIds","map","id","group","undefined","Error","usePanelGroup","panelGroupId","panelGroup","selectPanelGroupActions","openEditPanelGroup","deletePanelGroup","updatePanelGroupLayouts","usePanelGroupActions","moveUp","moveDown","useMovePanelGroup","itemLayouts","selectSwapPanelGroups","swapPanelGroups","selectPanelGroupsLength","length","currentIndex","store","findIndex","panelGroupsLength","selectPanelGroupEditor","panelGroupEditor","usePanelGroupEditor","selectDeletePanelGroupDialog","deletePanelGroupDialog","openDeletePanelGroupDialog","closeDeletePanelGroupDialog","useDeletePanelGroupDialog","usePanel","panelGroupItemId","panelGroupItemLayoutId","panelGroupLayoutId","panel","panelKey","itemPanelKeys","panels","selectPanelActions","openEditPanel","openDeletePanelDialog","usePanelActions","selectPanelEditor","panelEditor","usePanelEditor","selectDeletePanelDialog","deletePanelDialog","deletePanel","closeDeletePanelDialog","useDeletePanelDialog","selectDefaultTimeRange","defaultTimeRange","useDefaultTimeRange","selectDiscardChangesConfirmationDialog","discardChangesConfirmationDialog","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","useDiscardChangesConfirmationDialog"],"mappings":"AAAA,oCAAoC;AACpC,kEA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AAiB,CAAC,CAAC;AAC9C,CAAC;AAED,MAAMG,uBAAuB,GAAG,CAAC,EAAEC,iBAAiB,CAAA,EAAEC,WAAW,CAAA,EAAEC,sBAAsB,CAAA,EAAuB,GAAM,CAAA;QACpHF,iBAAiB;QACjBC,WAAW;QACXC,sBAAsB;KACvB,CAAA,AAAC,AAAC;AAEH;;CAEC,GACD,OAAO,SAASC,oBAAoB,GAAG;IACrC,0FAA0F;IAC1F,OAAOtE,iBAAiB,CAACkE,uBAAuB,CAAC,CAAC;AACpD,CAAC;AAED,MAAMK,sBAAsB,GAAG,CAAC5D,KAA0B,GAAKA,KAAK,CAAC6D,gBAAgB,AAAC;AACtF,OAAO,SAASC,mBAAmB,GAAG;IACpC,OAAOzE,iBAAiB,CAACuE,sBAAsB,CAAC,CAAC;AACnD,CAAC;AAED,MAAMG,sCAAsC,GAAG,CAAC,EAC9CC,gCAAgC,CAAA,EAChCC,oCAAoC,CAAA,EACpCC,qCAAqC,CAAA,EACjB,GAAM,CAAA;QAC1BF,gCAAgC;QAChCC,oCAAoC;QACpCC,qCAAqC;KACtC,CAAA,AAAC,AAAC;AACH,OAAO,SAASC,mCAAmC,GAAG;IACpD,OAAO9E,iBAAiB,CAAC0E,sCAAsC,CAAC,CAAC;AACnE,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { StateCreator } from 'zustand';
2
+ import { Middleware } from './common';
3
+ export interface DiscardChangesConfirmationDialogSlice {
4
+ discardChangesConfirmationDialog?: DiscardChangesConfirmationDialogState;
5
+ openDiscardChangesConfirmationDialog: (discardChangesConfirmationDialog: DiscardChangesConfirmationDialogState) => void;
6
+ closeDiscardChangesConfirmationDialog: () => void;
7
+ }
8
+ export interface DiscardChangesConfirmationDialogState {
9
+ onDiscardChanges: () => void;
10
+ onCancel: () => void;
11
+ description?: string;
12
+ }
13
+ export declare const createDiscardChangesDialogSlice: StateCreator<DiscardChangesConfirmationDialogSlice, Middleware, [
14
+ ], DiscardChangesConfirmationDialogSlice>;
15
+ //# sourceMappingURL=discard-changes-dialog-slice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discard-changes-dialog-slice.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/discard-changes-dialog-slice.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,MAAM,WAAW,qCAAqC;IACpD,gCAAgC,CAAC,EAAE,qCAAqC,CAAC;IACzE,oCAAoC,EAAE,CACpC,gCAAgC,EAAE,qCAAqC,KACpE,IAAI,CAAC;IACV,qCAAqC,EAAE,MAAM,IAAI,CAAC;CACnD;AAED,MAAM,WAAW,qCAAqC;IACpD,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,+BAA+B,EAAE,YAAY,CACxD,qCAAqC,EACrC,UAAU,EACV;CAAE,EACF,qCAAqC,CAerC,CAAC"}
@@ -0,0 +1,27 @@
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
+ export const createDiscardChangesDialogSlice = (set)=>({
14
+ isOpen: false,
15
+ openDiscardChangesConfirmationDialog (dialog) {
16
+ set((state)=>{
17
+ state.discardChangesConfirmationDialog = dialog;
18
+ });
19
+ },
20
+ closeDiscardChangesConfirmationDialog () {
21
+ set((state)=>{
22
+ state.discardChangesConfirmationDialog = undefined;
23
+ });
24
+ }
25
+ });
26
+
27
+ //# sourceMappingURL=discard-changes-dialog-slice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/discard-changes-dialog-slice.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 { StateCreator } from 'zustand';\nimport { Middleware } from './common';\n\nexport interface DiscardChangesConfirmationDialogSlice {\n discardChangesConfirmationDialog?: DiscardChangesConfirmationDialogState;\n openDiscardChangesConfirmationDialog: (\n discardChangesConfirmationDialog: DiscardChangesConfirmationDialogState\n ) => void;\n closeDiscardChangesConfirmationDialog: () => void;\n}\n\nexport interface DiscardChangesConfirmationDialogState {\n onDiscardChanges: () => void;\n onCancel: () => void;\n description?: string;\n}\n\nexport const createDiscardChangesDialogSlice: StateCreator<\n DiscardChangesConfirmationDialogSlice,\n Middleware,\n [],\n DiscardChangesConfirmationDialogSlice\n> = (set) => ({\n isOpen: false,\n\n openDiscardChangesConfirmationDialog(dialog) {\n set((state) => {\n state.discardChangesConfirmationDialog = dialog;\n });\n },\n\n closeDiscardChangesConfirmationDialog() {\n set((state) => {\n state.discardChangesConfirmationDialog = undefined;\n });\n },\n});\n"],"names":["createDiscardChangesDialogSlice","set","isOpen","openDiscardChangesConfirmationDialog","dialog","state","discardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","undefined"],"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;AAmBjC,OAAO,MAAMA,+BAA+B,GAKxC,CAACC,GAAG,GAAM,CAAA;QACZC,MAAM,EAAE,KAAK;QAEbC,oCAAoC,EAACC,MAAM,EAAE;YAC3CH,GAAG,CAAC,CAACI,KAAK,GAAK;gBACbA,KAAK,CAACC,gCAAgC,GAAGF,MAAM,CAAC;YAClD,CAAC,CAAC,CAAC;QACL,CAAC;QAEDG,qCAAqC,IAAG;YACtCN,GAAG,CAAC,CAACI,KAAK,GAAK;gBACbA,KAAK,CAACC,gCAAgC,GAAGE,SAAS,CAAC;YACrD,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAA,AAAC,CAAC"}
@@ -3,5 +3,6 @@ export * from './DashboardProvider';
3
3
  export type { PanelGroupId, PanelGroupDefinition, PanelGroupItemId, PanelGroupItemLayoutId as PanelGroupLayoutId, } from './panel-group-slice';
4
4
  export type { PanelGroupEditor, PanelGroupEditorValues } from './panel-group-editor-slice';
5
5
  export type { DeletePanelDialogState } from './delete-panel-slice';
6
+ export type { DiscardChangesConfirmationDialogState } from './discard-changes-dialog-slice';
6
7
  export type { PanelEditorValues } from './panel-editor-slice';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/index.ts"],"names":[],"mappings":"AAaA,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,YAAY,EACV,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,EAChB,sBAAsB,IAAI,kBAAkB,GAC7C,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAC3F,YAAY,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,YAAY,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/index.ts"],"names":[],"mappings":"AAaA,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,YAAY,EACV,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,EAChB,sBAAsB,IAAI,kBAAkB,GAC7C,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAC3F,YAAY,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,YAAY,EAAE,qCAAqC,EAAE,MAAM,gCAAgC,CAAC;AAC5F,YAAY,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/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 './dashboard-provider-api';\nexport * from './DashboardProvider';\nexport type {\n PanelGroupId,\n PanelGroupDefinition,\n PanelGroupItemId,\n PanelGroupItemLayoutId as PanelGroupLayoutId,\n} from './panel-group-slice';\nexport type { PanelGroupEditor, PanelGroupEditorValues } from './panel-group-editor-slice';\nexport type { DeletePanelDialogState } from './delete-panel-slice';\nexport type { PanelEditorValues } from './panel-editor-slice';\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,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/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 './dashboard-provider-api';\nexport * from './DashboardProvider';\nexport type {\n PanelGroupId,\n PanelGroupDefinition,\n PanelGroupItemId,\n PanelGroupItemLayoutId as PanelGroupLayoutId,\n} from './panel-group-slice';\nexport type { PanelGroupEditor, PanelGroupEditorValues } from './panel-group-editor-slice';\nexport type { DeletePanelDialogState } from './delete-panel-slice';\nexport type { DiscardChangesConfirmationDialogState } from './discard-changes-dialog-slice';\nexport type { PanelEditorValues } from './panel-editor-slice';\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,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC"}
@@ -3,6 +3,7 @@ import { DashboardResource } from '@perses-dev/core';
3
3
  export interface DashboardAppProps {
4
4
  dashboardResource: DashboardResource;
5
5
  dashboardTitleComponent?: JSX.Element;
6
+ onSave?: (entity: DashboardResource) => Promise<DashboardResource>;
6
7
  initialVariableIsSticky?: boolean;
7
8
  isReadonly: boolean;
8
9
  }
@@ -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;IAClC,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,YAAY,UAAW,iBAAiB,gBAqEpD,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,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACnE,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,YAAY,UAAW,iBAAiB,gBAsEpD,CAAC"}
@@ -14,25 +14,21 @@ 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, UnsavedChangesConfirmationDialog, DashboardToolbar, DeletePanelDialog } from '../../components';
18
- import { useDashboard, useEditMode } from '../../context';
17
+ import { PanelDrawer, Dashboard, PanelGroupDialog, DeletePanelGroupDialog, DiscardChangesConfirmationDialog, DashboardToolbar, DeletePanelDialog } from '../../components';
18
+ import { useDashboard, useDiscardChangesConfirmationDialog, useEditMode } from '../../context';
19
19
  export const DashboardApp = (props)=>{
20
- const { dashboardResource , dashboardTitleComponent , initialVariableIsSticky , isReadonly } = props;
20
+ const { dashboardResource , dashboardTitleComponent , onSave , initialVariableIsSticky , isReadonly } = props;
21
21
  const { setEditMode } = useEditMode();
22
22
  const { dashboard , setDashboard } = useDashboard();
23
23
  const [originalDashboard, setOriginalDashboard] = useState(undefined);
24
- const [isUnsavedDashboardDialogOpen, setUnsavedDashboardDialogIsOpen] = useState(false);
25
- const saveDashboard = async ()=>{
26
- setEditMode(false);
27
- setUnsavedDashboardDialogIsOpen(false);
28
- };
29
- const cancelDashboard = ()=>{
24
+ const { openDiscardChangesConfirmationDialog , closeDiscardChangesConfirmationDialog } = useDiscardChangesConfirmationDialog();
25
+ const handleDiscardChanges = ()=>{
30
26
  // Reset to the original spec and exit edit mode
31
27
  if (originalDashboard) {
32
28
  setDashboard(originalDashboard);
33
29
  }
34
- setUnsavedDashboardDialogIsOpen(false);
35
30
  setEditMode(false);
31
+ closeDiscardChangesConfirmationDialog();
36
32
  };
37
33
  const onEditButtonClick = ()=>{
38
34
  setEditMode(true);
@@ -43,7 +39,14 @@ export const DashboardApp = (props)=>{
43
39
  if (JSON.stringify(dashboard) === JSON.stringify(originalDashboard)) {
44
40
  setEditMode(false);
45
41
  } else {
46
- setUnsavedDashboardDialogIsOpen(true);
42
+ openDiscardChangesConfirmationDialog({
43
+ onDiscardChanges: ()=>{
44
+ handleDiscardChanges();
45
+ },
46
+ onCancel: ()=>{
47
+ closeDiscardChangesConfirmationDialog();
48
+ }
49
+ });
47
50
  }
48
51
  };
49
52
  return /*#__PURE__*/ _jsxs(Box, {
@@ -59,6 +62,7 @@ export const DashboardApp = (props)=>{
59
62
  dashboardName: dashboardResource.metadata.name,
60
63
  dashboardTitleComponent: dashboardTitleComponent,
61
64
  initialVariableIsSticky: initialVariableIsSticky,
65
+ onSave: onSave,
62
66
  isReadonly: isReadonly,
63
67
  onEditButtonClick: onEditButtonClick,
64
68
  onCancelButtonClick: onCancelButtonClick
@@ -76,11 +80,7 @@ export const DashboardApp = (props)=>{
76
80
  /*#__PURE__*/ _jsx(PanelGroupDialog, {}),
77
81
  /*#__PURE__*/ _jsx(DeletePanelGroupDialog, {}),
78
82
  /*#__PURE__*/ _jsx(DeletePanelDialog, {}),
79
- /*#__PURE__*/ _jsx(UnsavedChangesConfirmationDialog, {
80
- isOpen: isUnsavedDashboardDialogOpen,
81
- onSave: saveDashboard,
82
- onClose: cancelDashboard
83
- })
83
+ /*#__PURE__*/ _jsx(DiscardChangesConfirmationDialog, {})
84
84
  ]
85
85
  })
86
86
  ]
@@ -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 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,CAAA,EAAE,GAAGV,YAAY,EAAE,AAAC;IACnD,MAAM,CAACW,iBAAiB,EAAEC,oBAAoB,CAAC,GAAGvB,QAAQ,CAAgCwB,SAAS,CAAC,AAAC;IACrG,MAAM,CAACC,4BAA4B,EAAEC,+BAA+B,CAAC,GAAG1B,QAAQ,CAAC,KAAK,CAAC,AAAC;IAExF,MAAM2B,aAAa,GAAG,UAAY;QAChCR,WAAW,CAAC,KAAK,CAAC,CAAC;QACnBO,+BAA+B,CAAC,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BAAiB,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"}
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 DiscardChangesConfirmationDialog,\n DashboardToolbar,\n DeletePanelDialog,\n} from '../../components';\nimport { useDashboard, useDiscardChangesConfirmationDialog, useEditMode } from '../../context';\n\nexport interface DashboardAppProps {\n dashboardResource: DashboardResource;\n dashboardTitleComponent?: JSX.Element;\n onSave?: (entity: DashboardResource) => Promise<DashboardResource>;\n initialVariableIsSticky?: boolean;\n isReadonly: boolean;\n}\n\nexport const DashboardApp = (props: DashboardAppProps) => {\n const { dashboardResource, dashboardTitleComponent, onSave, initialVariableIsSticky, isReadonly } = 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 };\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) }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <Dashboard />\n </ErrorBoundary>\n <PanelDrawer />\n <PanelGroupDialog />\n <DeletePanelGroupDialog />\n <DeletePanelDialog />\n <DiscardChangesConfirmationDialog />\n </Box>\n </Box>\n );\n};\n"],"names":["useState","Box","ErrorAlert","ErrorBoundary","PanelDrawer","Dashboard","PanelGroupDialog","DeletePanelGroupDialog","DiscardChangesConfirmationDialog","DashboardToolbar","DeletePanelDialog","useDashboard","useDiscardChangesConfirmationDialog","useEditMode","DashboardApp","props","dashboardResource","dashboardTitleComponent","onSave","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","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,QACZ,kBAAkB,CAAC;AAC1B,SAASC,YAAY,EAAEC,mCAAmC,EAAEC,WAAW,QAAQ,eAAe,CAAC;AAU/F,OAAO,MAAMC,YAAY,GAAG,CAACC,KAAwB,GAAK;IACxD,MAAM,EAAEC,iBAAiB,CAAA,EAAEC,uBAAuB,CAAA,EAAEC,MAAM,CAAA,EAAEC,uBAAuB,CAAA,EAAEC,UAAU,CAAA,EAAE,GAAGL,KAAK,AAAC;IAC1G,MAAM,EAAEM,WAAW,CAAA,EAAE,GAAGR,WAAW,EAAE,AAAC;IACtC,MAAM,EAAES,SAAS,CAAA,EAAEC,YAAY,CAAA,EAAE,GAAGZ,YAAY,EAAE,AAAC;IACnD,MAAM,CAACa,iBAAiB,EAAEC,oBAAoB,CAAC,GAAGzB,QAAQ,CAAgC0B,SAAS,CAAC,AAAC;IAErG,MAAM,EAAEC,oCAAoC,CAAA,EAAEC,qCAAqC,CAAA,EAAE,GACnFhB,mCAAmC,EAAE,AAAC;IAExC,MAAMiB,oBAAoB,GAAG,IAAM;QAC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AAKA,KAAK,CAACC,OAAO,CAAC,CAAC,CAAC;iBAAE;;kCAC/C,KAAC5C,aAAa;wBAAC6C,iBAAiB,EAAE9C,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,KAAG;;cAChC;;MACF,CACN;AACJ,CAAC,CAAC"}
@@ -6,6 +6,7 @@ export interface ViewDashboardProps extends Omit<BoxProps, 'children'> {
6
6
  dashboardResource: DashboardResource;
7
7
  datasourceApi: DatasourceStoreProviderProps['datasourceApi'];
8
8
  dashboardTitleComponent?: JSX.Element;
9
+ onSave?: (entity: DashboardResource) => Promise<DashboardResource>;
9
10
  initialVariableIsSticky?: boolean;
10
11
  isReadonly: boolean;
11
12
  }
@@ -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;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"}
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,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACnE,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,eAgDtD"}
@@ -19,7 +19,7 @@ import { DashboardApp } from './DashboardApp';
19
19
  /**
20
20
  * The View for displaying a Dashboard, along with the UI for selecting variable values.
21
21
  */ export function ViewDashboard(props) {
22
- const { dashboardResource , datasourceApi , dashboardTitleComponent , initialVariableIsSticky , isReadonly , sx , ...others } = props;
22
+ const { dashboardResource , datasourceApi , dashboardTitleComponent , onSave , initialVariableIsSticky , isReadonly , sx , ...others } = props;
23
23
  const { spec } = dashboardResource;
24
24
  var _duration;
25
25
  const dashboardDuration = (_duration = spec.duration) !== null && _duration !== void 0 ? _duration : '1h';
@@ -50,6 +50,7 @@ import { DashboardApp } from './DashboardApp';
50
50
  children: /*#__PURE__*/ _jsx(DashboardApp, {
51
51
  dashboardResource: dashboardResource,
52
52
  dashboardTitleComponent: dashboardTitleComponent,
53
+ onSave: onSave,
53
54
  initialVariableIsSticky: initialVariableIsSticky,
54
55
  isReadonly: isReadonly
55
56
  })
@@ -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 { 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,EACJC,iBAAiB,CAAA,EACjBC,aAAa,CAAA,EACbC,uBAAuB,CAAA,EACvBC,uBAAuB,CAAA,EACvBC,UAAU,CAAA,EACVC,EAAE,CAAA,EACF,GAAGC,MAAM,EACV,GAAGP,KAAK,AAAC;IACV,MAAM,EAAEQ,IAAI,CAAA,EAAE,GAAGP,iBAAiB,AAAC;QACTO,SAAa;IAAvC,MAAMC,iBAAiB,GAAGD,CAAAA,SAAa,GAAbA,IAAI,CAACE,QAAQ,cAAbF,SAAa,cAAbA,SAAa,GAAI,IAAI,AAAC;IAChD,MAAMG,gBAAgB,GAAGjB,mBAAmB,CAACe,iBAAiB,CAAC,AAAC;IAEhE,qBACE,KAACZ,uBAAuB;QAACI,iBAAiB,EAAEA,iBAAiB;QAAEC,aAAa,EAAEA,aAAa;kBACzF,cAAA,KAACN,iBAAiB;YAACgB,YAAY,EAAE;gBAAEX,iBAAiB;aAAE;sBACpD,cAAA,KAACR,iBAAiB;gBAACkB,gBAAgB,EAAEA,gBAAgB;gBAAEE,gBAAgB,EAAE,IAAI;0BAC3E,cAAA,KAAClB,wBAAwB;oBAACmB,0BAA0B,EAAEN,IAAI,CAACO,SAAS;8BAClE,cAAA,KAAC1B,GAAG;wBACFiB,EAAE,EAAEd,SAAS,CACX;4BACEwB,OAAO,EAAE,MAAM;4BACfC,KAAK,EAAE,MAAM;4BACbC,MAAM,EAAE,MAAM;4BACdC,QAAQ,EAAE,UAAU;4BACpBC,QAAQ,EAAE,QAAQ;yBACnB,EACDd,EAAE,CACH;wBACA,GAAGC,MAAM;kCAEV,cAAA,KAACjB,aAAa;4BAAC+B,iBAAiB,EAAE9B,UAAU;sCAC1C,cAAA,KAACO,YAAY;gCACXG,iBAAiB,EAAEA,iBAAiB;gCACpCE,uBAAuB,EAAEA,uBAAuB;gCAChDC,uBAAuB,EAAEA,uBAAuB;gCAChDC,UAAU,EAAEA,UAAU;8BACtB;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 onSave?: (entity: DashboardResource) => Promise<DashboardResource>;\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 onSave,\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 onSave={onSave}\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","onSave","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;AAW9C;;CAEC,GACD,OAAO,SAASC,aAAa,CAACC,KAAyB,EAAE;IACvD,MAAM,EACJC,iBAAiB,CAAA,EACjBC,aAAa,CAAA,EACbC,uBAAuB,CAAA,EACvBC,MAAM,CAAA,EACNC,uBAAuB,CAAA,EACvBC,UAAU,CAAA,EACVC,EAAE,CAAA,EACF,GAAGC,MAAM,EACV,GAAGR,KAAK,AAAC;IACV,MAAM,EAAES,IAAI,CAAA,EAAE,GAAGR,iBAAiB,AAAC;QACTQ,SAAa;IAAvC,MAAMC,iBAAiB,GAAGD,CAAAA,SAAa,GAAbA,IAAI,CAACE,QAAQ,cAAbF,SAAa,cAAbA,SAAa,GAAI,IAAI,AAAC;IAChD,MAAMG,gBAAgB,GAAGlB,mBAAmB,CAACgB,iBAAiB,CAAC,AAAC;IAEhE,qBACE,KAACb,uBAAuB;QAACI,iBAAiB,EAAEA,iBAAiB;QAAEC,aAAa,EAAEA,aAAa;kBACzF,cAAA,KAACN,iBAAiB;YAACiB,YAAY,EAAE;gBAAEZ,iBAAiB;aAAE;sBACpD,cAAA,KAACR,iBAAiB;gBAACmB,gBAAgB,EAAEA,gBAAgB;gBAAEE,gBAAgB,EAAE,IAAI;0BAC3E,cAAA,KAACnB,wBAAwB;oBAACoB,0BAA0B,EAAEN,IAAI,CAACO,SAAS;8BAClE,cAAA,KAAC3B,GAAG;wBACFkB,EAAE,EAAEf,SAAS,CACX;4BACEyB,OAAO,EAAE,MAAM;4BACfC,KAAK,EAAE,MAAM;4BACbC,MAAM,EAAE,MAAM;4BACdC,QAAQ,EAAE,UAAU;4BACpBC,QAAQ,EAAE,QAAQ;yBACnB,EACDd,EAAE,CACH;wBACA,GAAGC,MAAM;kCAEV,cAAA,KAAClB,aAAa;4BAACgC,iBAAiB,EAAE/B,UAAU;sCAC1C,cAAA,KAACO,YAAY;gCACXG,iBAAiB,EAAEA,iBAAiB;gCACpCE,uBAAuB,EAAEA,uBAAuB;gCAChDC,MAAM,EAAEA,MAAM;gCACdC,uBAAuB,EAAEA,uBAAuB;gCAChDC,UAAU,EAAEA,UAAU;8BACtB;0BACY;sBACZ;kBACmB;cACT;UACF;MACI,CAC1B;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/dashboards",
3
- "version": "0.20.0",
3
+ "version": "0.21.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.20.0",
32
- "@perses-dev/core": "^0.20.0",
33
- "@perses-dev/plugin-system": "^0.20.0",
31
+ "@perses-dev/components": "0.21.0",
32
+ "@perses-dev/core": "0.21.0",
33
+ "@perses-dev/plugin-system": "0.21.0",
34
34
  "@types/react-grid-layout": "^1.3.2",
35
35
  "date-fns": "^2.28.0",
36
36
  "immer": "^9.0.15",
@@ -1,67 +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
- Object.defineProperty(exports, "UnsavedChangesConfirmationDialog", {
18
- enumerable: true,
19
- get: ()=>UnsavedChangesConfirmationDialog
20
- });
21
- const _jsxRuntime = require("react/jsx-runtime");
22
- const _material = require("@mui/material");
23
- const _close = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Close"));
24
- function _interopRequireDefault(obj) {
25
- return obj && obj.__esModule ? obj : {
26
- default: obj
27
- };
28
- }
29
- const UnsavedChangesConfirmationDialog = ({ isOpen , onSave , onClose })=>{
30
- return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Dialog, {
31
- open: isOpen,
32
- children: [
33
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.DialogTitle, {
34
- children: "Unsaved Changes"
35
- }),
36
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
37
- "aria-label": "Close",
38
- onClick: onClose,
39
- sx: (theme)=>({
40
- position: 'absolute',
41
- top: theme.spacing(0.5),
42
- right: theme.spacing(0.5)
43
- }),
44
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_close.default, {})
45
- }),
46
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.DialogContent, {
47
- sx: {
48
- width: '500px'
49
- },
50
- children: "You have unsaved changes in this dashboard. Would you like to save these changes?"
51
- }),
52
- /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.DialogActions, {
53
- children: [
54
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
55
- variant: "contained",
56
- onClick: onSave,
57
- children: "Save"
58
- }),
59
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
60
- onClick: onClose,
61
- children: "Cancel"
62
- })
63
- ]
64
- })
65
- ]
66
- });
67
- };
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- export interface UnsavedChangesConfirmationDialogProps {
3
- isOpen: boolean;
4
- onSave: () => void;
5
- onClose: () => void;
6
- }
7
- export declare const UnsavedChangesConfirmationDialog: ({ isOpen, onSave, onClose, }: UnsavedChangesConfirmationDialogProps) => JSX.Element;
8
- //# sourceMappingURL=UnsavedChangesConfirmationDialog.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UnsavedChangesConfirmationDialog.d.ts","sourceRoot":"","sources":["../../../src/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.tsx"],"names":[],"mappings":";AAeA,MAAM,WAAW,qCAAqC;IACpD,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,gCAAgC,iCAI1C,qCAAqC,gBA0BvC,CAAC"}
@@ -1,56 +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
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- import { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';
15
- import CloseIcon from 'mdi-material-ui/Close';
16
- export const UnsavedChangesConfirmationDialog = ({ isOpen , onSave , onClose })=>{
17
- return /*#__PURE__*/ _jsxs(Dialog, {
18
- open: isOpen,
19
- children: [
20
- /*#__PURE__*/ _jsx(DialogTitle, {
21
- children: "Unsaved Changes"
22
- }),
23
- /*#__PURE__*/ _jsx(IconButton, {
24
- "aria-label": "Close",
25
- onClick: onClose,
26
- sx: (theme)=>({
27
- position: 'absolute',
28
- top: theme.spacing(0.5),
29
- right: theme.spacing(0.5)
30
- }),
31
- children: /*#__PURE__*/ _jsx(CloseIcon, {})
32
- }),
33
- /*#__PURE__*/ _jsx(DialogContent, {
34
- sx: {
35
- width: '500px'
36
- },
37
- children: "You have unsaved changes in this dashboard. Would you like to save these changes?"
38
- }),
39
- /*#__PURE__*/ _jsxs(DialogActions, {
40
- children: [
41
- /*#__PURE__*/ _jsx(Button, {
42
- variant: "contained",
43
- onClick: onSave,
44
- children: "Save"
45
- }),
46
- /*#__PURE__*/ _jsx(Button, {
47
- onClick: onClose,
48
- children: "Cancel"
49
- })
50
- ]
51
- })
52
- ]
53
- });
54
- };
55
-
56
- //# sourceMappingURL=UnsavedChangesConfirmationDialog.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.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 { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nexport interface UnsavedChangesConfirmationDialogProps {\n isOpen: boolean;\n onSave: () => void;\n onClose: () => void;\n}\n\nexport const UnsavedChangesConfirmationDialog = ({\n isOpen,\n onSave,\n onClose,\n}: UnsavedChangesConfirmationDialogProps) => {\n return (\n <Dialog open={isOpen}>\n <DialogTitle>Unsaved Changes</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={onClose}\n sx={(theme) => ({\n position: 'absolute',\n top: theme.spacing(0.5),\n right: theme.spacing(0.5),\n })}\n >\n <CloseIcon />\n </IconButton>\n <DialogContent sx={{ width: '500px' }}>\n You have unsaved changes in this dashboard. Would you like to save these changes?\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" onClick={onSave}>\n Save\n </Button>\n <Button onClick={onClose}>Cancel</Button>\n </DialogActions>\n </Dialog>\n );\n};\n"],"names":["IconButton","Dialog","DialogTitle","DialogContent","DialogActions","Button","CloseIcon","UnsavedChangesConfirmationDialog","isOpen","onSave","onClose","open","aria-label","onClick","sx","theme","position","top","spacing","right","width","variant"],"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,UAAU,EAAEC,MAAM,EAAEC,WAAW,EAAEC,aAAa,EAAEC,aAAa,EAAEC,MAAM,QAAQ,eAAe,CAAC;AACtG,OAAOC,SAAS,MAAM,uBAAuB,CAAC;AAO9C,OAAO,MAAMC,gCAAgC,GAAG,CAAC,EAC/CC,MAAM,CAAA,EACNC,MAAM,CAAA,EACNC,OAAO,CAAA,EAC+B,GAAK;IAC3C,qBACE,MAACT,MAAM;QAACU,IAAI,EAAEH,MAAM;;0BAClB,KAACN,WAAW;0BAAC,iBAAe;cAAc;0BAC1C,KAACF,UAAU;gBACTY,YAAU,EAAC,OAAO;gBAClBC,OAAO,EAAEH,OAAO;gBAChBI,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;wBACdC,QAAQ,EAAE,UAAU;wBACpBC,GAAG,EAAEF,KAAK,CAACG,OAAO,CAAC,GAAG,CAAC;wBACvBC,KAAK,EAAEJ,KAAK,CAACG,OAAO,CAAC,GAAG,CAAC;qBAC1B,CAAA,AAAC;0BAEF,cAAA,KAACZ,SAAS,KAAG;cACF;0BACb,KAACH,aAAa;gBAACW,EAAE,EAAE;oBAAEM,KAAK,EAAE,OAAO;iBAAE;0BAAE,mFAEvC;cAAgB;0BAChB,MAAChB,aAAa;;kCACZ,KAACC,MAAM;wBAACgB,OAAO,EAAC,WAAW;wBAACR,OAAO,EAAEJ,MAAM;kCAAE,MAE7C;sBAAS;kCACT,KAACJ,MAAM;wBAACQ,OAAO,EAAEH,OAAO;kCAAE,QAAM;sBAAS;;cAC3B;;MACT,CACT;AACJ,CAAC,CAAC"}