@perses-dev/dashboards 0.53.0 → 0.54.0-beta.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.
- package/dist/cjs/components/DashboardLinks/DashboardLinksEditor.js +366 -0
- package/dist/cjs/components/DashboardLinks/EditDashboardLinksButton.js +81 -0
- package/dist/cjs/components/DashboardLinks/index.js +31 -0
- package/dist/cjs/components/DashboardShortcuts/index.js +23 -0
- package/dist/cjs/components/DashboardShortcuts/useDashboardShortcuts.js +373 -0
- package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +16 -1
- package/dist/cjs/components/Datasources/EditDatasourcesButton.js +1 -7
- package/dist/cjs/components/GridLayout/GridItemContent.js +19 -6
- package/dist/cjs/components/{Panel/PanelLinks.js → LinksDisplay/LinksDisplay.js} +59 -10
- package/dist/cjs/components/LinksDisplay/index.js +30 -0
- package/dist/cjs/components/Panel/PanelActions.js +58 -35
- package/dist/cjs/components/PanelDrawer/PanelQueriesSharedControls.js +16 -1
- package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +4 -4
- package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +3 -61
- package/dist/cjs/components/Variables/ListVariableListBox.js +6 -6
- package/dist/cjs/components/Variables/Variable.js +3 -3
- package/dist/cjs/components/index.js +2 -0
- package/dist/cjs/constants/user-interface-text.js +1 -0
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +5 -1
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +16 -0
- package/dist/cjs/context/DashboardProvider/index.js +7 -0
- package/dist/cjs/context/DashboardProvider/links-slice.js +32 -0
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +2 -2
- package/dist/cjs/context/DashboardProvider/use-save-dashboard.js +104 -0
- package/dist/cjs/context/DatasourceStoreProvider.js +3 -9
- package/dist/cjs/context/VariableProvider/VariableProvider.js +7 -6
- package/dist/cjs/context/VariableProvider/hydrationUtils.js +3 -3
- package/dist/cjs/context/useDashboard.js +7 -4
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/keyboard-shortcuts/PanelFocusProvider.js +157 -0
- package/dist/cjs/keyboard-shortcuts/default-shortcuts/dashboard.js +75 -0
- package/dist/cjs/keyboard-shortcuts/default-shortcuts/global.js +121 -0
- package/dist/cjs/keyboard-shortcuts/default-shortcuts/index.js +33 -0
- package/dist/cjs/keyboard-shortcuts/default-shortcuts/panel.js +90 -0
- package/dist/cjs/keyboard-shortcuts/default-shortcuts/time-range.js +142 -0
- package/dist/cjs/keyboard-shortcuts/events.js +93 -0
- package/dist/cjs/keyboard-shortcuts/index.js +89 -0
- package/dist/cjs/keyboard-shortcuts/types.js +42 -0
- package/dist/cjs/keyboard-shortcuts/utils.js +76 -0
- package/dist/cjs/model/DashboardResource.js +16 -0
- package/dist/cjs/model/index.js +30 -0
- package/dist/cjs/test/render.js +18 -3
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +17 -2
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +2 -1
- package/dist/components/Dashboard/Dashboard.d.ts.map +1 -1
- package/dist/components/Dashboard/Dashboard.js.map +1 -1
- package/dist/components/DashboardLinks/DashboardLinksEditor.d.ts +9 -0
- package/dist/components/DashboardLinks/DashboardLinksEditor.d.ts.map +1 -0
- package/dist/components/DashboardLinks/DashboardLinksEditor.js +353 -0
- package/dist/components/DashboardLinks/DashboardLinksEditor.js.map +1 -0
- package/dist/components/DashboardLinks/EditDashboardLinksButton.d.ts +18 -0
- package/dist/components/DashboardLinks/EditDashboardLinksButton.d.ts.map +1 -0
- package/dist/components/DashboardLinks/EditDashboardLinksButton.js +68 -0
- package/dist/components/DashboardLinks/EditDashboardLinksButton.js.map +1 -0
- package/dist/components/DashboardLinks/index.d.ts +3 -0
- package/dist/components/DashboardLinks/index.d.ts.map +1 -0
- package/dist/components/DashboardLinks/index.js +16 -0
- package/dist/components/DashboardLinks/index.js.map +1 -0
- package/dist/components/DashboardShortcuts/index.d.ts +3 -0
- package/dist/components/DashboardShortcuts/index.d.ts.map +1 -0
- package/dist/components/DashboardShortcuts/index.js +15 -0
- package/dist/components/DashboardShortcuts/index.js.map +1 -0
- package/dist/components/DashboardShortcuts/useDashboardShortcuts.d.ts +12 -0
- package/dist/components/DashboardShortcuts/useDashboardShortcuts.d.ts.map +1 -0
- package/dist/components/DashboardShortcuts/useDashboardShortcuts.js +365 -0
- package/dist/components/DashboardShortcuts/useDashboardShortcuts.js.map +1 -0
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +1 -0
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js +17 -2
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/Datasources/DatasourceEditor.d.ts +1 -1
- package/dist/components/Datasources/DatasourceEditor.d.ts.map +1 -1
- package/dist/components/Datasources/DatasourceEditor.js.map +1 -1
- package/dist/components/Datasources/EditDatasourcesButton.d.ts.map +1 -1
- package/dist/components/Datasources/EditDatasourcesButton.js +1 -7
- package/dist/components/Datasources/EditDatasourcesButton.js.map +1 -1
- package/dist/components/DownloadButton/serializeDashboard.d.ts +2 -2
- package/dist/components/DownloadButton/serializeDashboard.d.ts.map +1 -1
- package/dist/components/DownloadButton/serializeDashboard.js.map +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +21 -8
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.d.ts +1 -1
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.d.ts +1 -1
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- package/dist/components/GridLayout/Row.d.ts +2 -1
- package/dist/components/GridLayout/Row.d.ts.map +1 -1
- package/dist/components/GridLayout/Row.js.map +1 -1
- package/dist/components/LeaveDialog/LeaveDialog.d.ts +3 -3
- package/dist/components/LeaveDialog/LeaveDialog.d.ts.map +1 -1
- package/dist/components/LeaveDialog/LeaveDialog.js.map +1 -1
- package/dist/components/LinksDisplay/LinksDisplay.d.ts +10 -0
- package/dist/components/LinksDisplay/LinksDisplay.d.ts.map +1 -0
- package/dist/components/{Panel/PanelLinks.js → LinksDisplay/LinksDisplay.js} +59 -10
- package/dist/components/LinksDisplay/LinksDisplay.js.map +1 -0
- package/dist/components/LinksDisplay/index.d.ts +2 -0
- package/dist/components/LinksDisplay/index.d.ts.map +1 -0
- package/dist/components/LinksDisplay/index.js +15 -0
- package/dist/components/LinksDisplay/index.js.map +1 -0
- package/dist/components/Panel/Panel.d.ts +2 -1
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/PanelActions.d.ts +1 -1
- package/dist/components/Panel/PanelActions.d.ts.map +1 -1
- package/dist/components/Panel/PanelActions.js +59 -36
- package/dist/components/Panel/PanelActions.js.map +1 -1
- package/dist/components/Panel/PanelContent.d.ts +1 -1
- package/dist/components/Panel/PanelContent.js.map +1 -1
- package/dist/components/Panel/PanelHeader.d.ts +1 -1
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- package/dist/components/Panel/PanelPluginLoader.d.ts +1 -1
- package/dist/components/Panel/PanelPluginLoader.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts +2 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.d.ts +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/PanelDrawer/PanelQueriesSharedControls.d.ts +1 -1
- package/dist/components/PanelDrawer/PanelQueriesSharedControls.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelQueriesSharedControls.js +16 -1
- package/dist/components/PanelDrawer/PanelQueriesSharedControls.js.map +1 -1
- package/dist/components/PanelDrawer/usePanelEditor.d.ts +1 -1
- package/dist/components/PanelDrawer/usePanelEditor.js.map +1 -1
- package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -1
- package/dist/components/QueryViewerDialog/QueryViewerDialog.d.ts +1 -1
- package/dist/components/QueryViewerDialog/QueryViewerDialog.js.map +1 -1
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +1 -1
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
- package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -1
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js +4 -62
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
- package/dist/components/Variables/BuiltinVariableAccordions.d.ts +1 -1
- package/dist/components/Variables/BuiltinVariableAccordions.js.map +1 -1
- package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
- package/dist/components/Variables/EditVariablesButton.js.map +1 -1
- package/dist/components/Variables/ListVariableListBox.js +1 -1
- package/dist/components/Variables/ListVariableListBox.js.map +1 -1
- package/dist/components/Variables/Variable.d.ts +1 -1
- package/dist/components/Variables/Variable.js +1 -1
- package/dist/components/Variables/Variable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.d.ts +2 -1
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableList.d.ts +1 -1
- package/dist/components/Variables/VariableList.d.ts.map +1 -1
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -1
- package/dist/constants/user-interface-text.d.ts +1 -0
- package/dist/constants/user-interface-text.d.ts.map +1 -1
- package/dist/constants/user-interface-text.js +1 -0
- package/dist/constants/user-interface-text.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +8 -6
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +5 -1
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/common.d.ts +3 -2
- package/dist/context/DashboardProvider/common.d.ts.map +1 -1
- package/dist/context/DashboardProvider/common.js.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +15 -2
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js +14 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts +1 -1
- package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +1 -1
- package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -1
- package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
- package/dist/context/DashboardProvider/index.d.ts +2 -0
- package/dist/context/DashboardProvider/index.d.ts.map +1 -1
- package/dist/context/DashboardProvider/index.js +1 -0
- package/dist/context/DashboardProvider/index.js.map +1 -1
- package/dist/context/DashboardProvider/links-slice.d.ts +19 -0
- package/dist/context/DashboardProvider/links-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/links-slice.js +27 -0
- package/dist/context/DashboardProvider/links-slice.js.map +1 -0
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts +2 -1
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +1 -1
- package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.d.ts +2 -1
- package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.js +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-slice.d.ts +1 -1
- package/dist/context/DashboardProvider/panel-slice.js.map +1 -1
- package/dist/context/DashboardProvider/use-save-dashboard.d.ts +25 -0
- package/dist/context/DashboardProvider/use-save-dashboard.d.ts.map +1 -0
- package/dist/context/DashboardProvider/use-save-dashboard.js +105 -0
- package/dist/context/DashboardProvider/use-save-dashboard.js.map +1 -0
- package/dist/context/DashboardProvider/view-panel-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/view-panel-slice.js.map +1 -1
- package/dist/context/DatasourceStoreProvider.d.ts +4 -2
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
- package/dist/context/DatasourceStoreProvider.js +3 -9
- package/dist/context/DatasourceStoreProvider.js.map +1 -1
- package/dist/context/VariableProvider/VariableProvider.d.ts +2 -1
- package/dist/context/VariableProvider/VariableProvider.d.ts.map +1 -1
- package/dist/context/VariableProvider/VariableProvider.js +2 -1
- package/dist/context/VariableProvider/VariableProvider.js.map +1 -1
- package/dist/context/VariableProvider/hydrationUtils.d.ts +2 -1
- package/dist/context/VariableProvider/hydrationUtils.d.ts.map +1 -1
- package/dist/context/VariableProvider/hydrationUtils.js +1 -1
- package/dist/context/VariableProvider/hydrationUtils.js.map +1 -1
- package/dist/context/VariableProvider/query-params.d.ts +1 -1
- package/dist/context/VariableProvider/query-params.js.map +1 -1
- package/dist/context/VariableProvider/utils.d.ts +2 -1
- package/dist/context/VariableProvider/utils.d.ts.map +1 -1
- package/dist/context/VariableProvider/utils.js.map +1 -1
- package/dist/context/useDashboard.d.ts +11 -3
- package/dist/context/useDashboard.d.ts.map +1 -1
- package/dist/context/useDashboard.js +6 -3
- package/dist/context/useDashboard.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/keyboard-shortcuts/PanelFocusProvider.d.ts +12 -0
- package/dist/keyboard-shortcuts/PanelFocusProvider.d.ts.map +1 -0
- package/dist/keyboard-shortcuts/PanelFocusProvider.js +97 -0
- package/dist/keyboard-shortcuts/PanelFocusProvider.js.map +1 -0
- package/dist/keyboard-shortcuts/default-shortcuts/dashboard.d.ts +6 -0
- package/dist/keyboard-shortcuts/default-shortcuts/dashboard.d.ts.map +1 -0
- package/dist/keyboard-shortcuts/default-shortcuts/dashboard.js +53 -0
- package/dist/keyboard-shortcuts/default-shortcuts/dashboard.js.map +1 -0
- package/dist/keyboard-shortcuts/default-shortcuts/global.d.ts +9 -0
- package/dist/keyboard-shortcuts/default-shortcuts/global.d.ts.map +1 -0
- package/dist/keyboard-shortcuts/default-shortcuts/global.js +90 -0
- package/dist/keyboard-shortcuts/default-shortcuts/global.js.map +1 -0
- package/dist/keyboard-shortcuts/default-shortcuts/index.d.ts +5 -0
- package/dist/keyboard-shortcuts/default-shortcuts/index.d.ts.map +1 -0
- package/dist/keyboard-shortcuts/default-shortcuts/index.js +18 -0
- package/dist/keyboard-shortcuts/default-shortcuts/index.js.map +1 -0
- package/dist/keyboard-shortcuts/default-shortcuts/panel.d.ts +7 -0
- package/dist/keyboard-shortcuts/default-shortcuts/panel.d.ts.map +1 -0
- package/dist/keyboard-shortcuts/default-shortcuts/panel.js +65 -0
- package/dist/keyboard-shortcuts/default-shortcuts/panel.js.map +1 -0
- package/dist/keyboard-shortcuts/default-shortcuts/time-range.d.ts +10 -0
- package/dist/keyboard-shortcuts/default-shortcuts/time-range.d.ts.map +1 -0
- package/dist/keyboard-shortcuts/default-shortcuts/time-range.js +108 -0
- package/dist/keyboard-shortcuts/default-shortcuts/time-range.js.map +1 -0
- package/dist/keyboard-shortcuts/events.d.ts +18 -0
- package/dist/keyboard-shortcuts/events.d.ts.map +1 -0
- package/dist/keyboard-shortcuts/events.js +35 -0
- package/dist/keyboard-shortcuts/events.js.map +1 -0
- package/dist/keyboard-shortcuts/index.d.ts +9 -0
- package/dist/keyboard-shortcuts/index.d.ts.map +1 -0
- package/dist/keyboard-shortcuts/index.js +21 -0
- package/dist/keyboard-shortcuts/index.js.map +1 -0
- package/dist/keyboard-shortcuts/types.d.ts +37 -0
- package/dist/keyboard-shortcuts/types.d.ts.map +1 -0
- package/dist/keyboard-shortcuts/types.js +26 -0
- package/dist/keyboard-shortcuts/types.js.map +1 -0
- package/dist/keyboard-shortcuts/utils.d.ts +12 -0
- package/dist/keyboard-shortcuts/utils.d.ts.map +1 -0
- package/dist/keyboard-shortcuts/utils.js +51 -0
- package/dist/keyboard-shortcuts/utils.js.map +1 -0
- package/dist/model/DashboardResource.d.ts +15 -0
- package/dist/model/DashboardResource.d.ts.map +1 -0
- package/dist/model/DashboardResource.js +18 -0
- package/dist/model/DashboardResource.js.map +1 -0
- package/dist/model/index.d.ts +2 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/index.js +15 -0
- package/dist/model/index.js.map +1 -0
- package/dist/test/dashboard-provider.d.ts +1 -1
- package/dist/test/dashboard-provider.d.ts.map +1 -1
- package/dist/test/dashboard-provider.js.map +1 -1
- package/dist/test/datasource-provider.js.map +1 -1
- package/dist/test/plugin-registry.js.map +1 -1
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +18 -3
- package/dist/test/render.js.map +1 -1
- package/dist/test/testDashboard.d.ts +11 -2
- package/dist/test/testDashboard.d.ts.map +1 -1
- package/dist/test/testDashboard.js.map +1 -1
- package/dist/utils/panelUtils.js.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.d.ts +5 -3
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +18 -3
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +3 -2
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/package.json +6 -4
- package/dist/components/Panel/PanelLinks.d.ts +0 -6
- package/dist/components/Panel/PanelLinks.d.ts.map +0 -1
- package/dist/components/Panel/PanelLinks.js.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { StoreApi } from 'zustand';
|
|
2
2
|
import { ReactElement, ReactNode } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { Display, DurationString, DatasourceSpec } from '@perses-dev/spec';
|
|
4
|
+
import { DashboardMetaData, DashboardKind, DashboardResource } from '../../model/DashboardResource';
|
|
4
5
|
import { PanelGroupEditorSlice } from './panel-group-editor-slice';
|
|
5
6
|
import { PanelGroupSlice } from './panel-group-slice';
|
|
6
7
|
import { PanelEditorSlice } from './panel-editor-slice';
|
|
@@ -12,12 +13,13 @@ import { SaveChangesConfirmationDialogSlice } from './save-changes-dialog-slice'
|
|
|
12
13
|
import { DuplicatePanelSlice } from './duplicate-panel-slice';
|
|
13
14
|
import { EditJsonDialogSlice } from './edit-json-dialog-slice';
|
|
14
15
|
import { ViewPanelSlice, VirtualPanelRef } from './view-panel-slice';
|
|
15
|
-
|
|
16
|
+
import { LinksSlice } from './links-slice';
|
|
17
|
+
export interface DashboardStoreState extends PanelGroupSlice, PanelSlice, PanelGroupEditorSlice, DeletePanelGroupSlice, PanelEditorSlice, DeletePanelSlice, DiscardChangesConfirmationDialogSlice, DuplicatePanelSlice, EditJsonDialogSlice, SaveChangesConfirmationDialogSlice, ViewPanelSlice, LinksSlice {
|
|
16
18
|
isEditMode: boolean;
|
|
17
19
|
setEditMode: (isEditMode: boolean) => void;
|
|
18
|
-
setDashboard: (dashboard: DashboardResource
|
|
19
|
-
kind:
|
|
20
|
-
metadata:
|
|
20
|
+
setDashboard: (dashboard: DashboardResource) => void;
|
|
21
|
+
kind: DashboardKind;
|
|
22
|
+
metadata: DashboardMetaData;
|
|
21
23
|
duration: DurationString;
|
|
22
24
|
refreshInterval: DurationString;
|
|
23
25
|
display?: Display;
|
|
@@ -27,7 +29,7 @@ export interface DashboardStoreState extends PanelGroupSlice, PanelSlice, PanelG
|
|
|
27
29
|
export declare const DashboardContext: import("react").Context<StoreApi<DashboardStoreState> | undefined>;
|
|
28
30
|
export declare function useDashboardStore<T>(selector: (state: DashboardStoreState) => T): T;
|
|
29
31
|
export interface DashboardStoreProps {
|
|
30
|
-
dashboardResource: DashboardResource
|
|
32
|
+
dashboardResource: DashboardResource;
|
|
31
33
|
isEditMode?: boolean;
|
|
32
34
|
viewPanelRef?: VirtualPanelRef;
|
|
33
35
|
setViewPanelRef?: (viewPanelRef: VirtualPanelRef | undefined) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardProvider.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/DashboardProvider.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAIxC,OAAO,EAAiB,YAAY,EAAE,SAAS,EAAgD,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"DashboardProvider.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/DashboardProvider.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAIxC,OAAO,EAAiB,YAAY,EAAE,SAAS,EAAgD,MAAM,OAAO,CAAC;AAE7G,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE3E,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACpG,OAAO,EAA+B,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,EAAsD,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC1G,OAAO,EAA0B,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAoB,UAAU,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAA+B,qBAAqB,EAAE,MAAM,4BAA4B,CA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AC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,eAAe,CAAC;IAC/B,eAAe,CAAC,EAAE,CAAC,YAAY,EAAE,eAAe,GAAG,SAAS,KAAK,IAAI,CAAC;CACvE;AAED,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,mBAAmB,CAAC;IAClC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,GAAG,YAAY,CA0B7E"}
|
|
@@ -31,6 +31,7 @@ import { createDuplicatePanelSlice } from './duplicate-panel-slice';
|
|
|
31
31
|
import { createEditJsonDialogSlice } from './edit-json-dialog-slice';
|
|
32
32
|
import { createPanelDefinition } from './common';
|
|
33
33
|
import { createViewPanelSlice } from './view-panel-slice';
|
|
34
|
+
import { createLinksSlice } from './links-slice';
|
|
34
35
|
export const DashboardContext = /*#__PURE__*/ createContext(undefined);
|
|
35
36
|
export function useDashboardStore(selector) {
|
|
36
37
|
const store = useContext(DashboardContext);
|
|
@@ -71,6 +72,7 @@ export function DashboardProvider(props) {
|
|
|
71
72
|
function initStore(props) {
|
|
72
73
|
const { initialState: { dashboardResource, isEditMode, viewPanelRef, setViewPanelRef } } = props;
|
|
73
74
|
const { kind, metadata, spec: { display, duration, refreshInterval = DEFAULT_REFRESH_INTERVAL, datasources, layouts = [], panels = {} } } = dashboardResource;
|
|
75
|
+
const links = dashboardResource.spec.links ?? [];
|
|
74
76
|
const ttl = 'ttl' in dashboardResource.spec ? dashboardResource.spec.ttl : undefined;
|
|
75
77
|
const store = createStore()(immer(devtools((...args)=>{
|
|
76
78
|
const [set] = args;
|
|
@@ -83,6 +85,7 @@ function initStore(props) {
|
|
|
83
85
|
...createDeletePanelSlice()(...args),
|
|
84
86
|
...createDuplicatePanelSlice()(...args),
|
|
85
87
|
...createViewPanelSlice(viewPanelRef, setViewPanelRef)(...args),
|
|
88
|
+
/* Links */ ...createLinksSlice(links)(...args),
|
|
86
89
|
/* General */ ...createDiscardChangesDialogSlice(...args),
|
|
87
90
|
...createEditJsonDialogSlice(...args),
|
|
88
91
|
...createSaveChangesDialogSlice(...args),
|
|
@@ -99,7 +102,7 @@ function initStore(props) {
|
|
|
99
102
|
isEditMode
|
|
100
103
|
});
|
|
101
104
|
},
|
|
102
|
-
setDashboard: ({ kind, metadata, spec: { display, panels = {}, layouts = [], duration, refreshInterval, datasources = {} } })=>{
|
|
105
|
+
setDashboard: ({ kind, metadata, spec: { display, panels = {}, layouts = [], duration, refreshInterval, datasources = {}, links = [] } })=>{
|
|
103
106
|
set((state)=>{
|
|
104
107
|
state.kind = kind;
|
|
105
108
|
state.metadata = metadata;
|
|
@@ -111,6 +114,7 @@ function initStore(props) {
|
|
|
111
114
|
state.duration = duration;
|
|
112
115
|
state.refreshInterval = refreshInterval ?? DEFAULT_REFRESH_INTERVAL;
|
|
113
116
|
state.datasources = datasources;
|
|
117
|
+
state.links = links;
|
|
114
118
|
// TODO: add ttl here to e.g allow edition from JSON view, but probably requires quite some refactoring
|
|
115
119
|
});
|
|
116
120
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/DashboardProvider/DashboardProvider.tsx"],"sourcesContent":["// Copyright 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 } from 'zustand';\nimport { useStoreWithEqualityFn } from 'zustand/traditional';\nimport type { StoreApi } from 'zustand';\nimport { devtools } from 'zustand/middleware';\nimport { immer } from 'zustand/middleware/immer';\nimport { shallow } from 'zustand/shallow';\nimport { createContext, ReactElement, ReactNode, useCallback, useContext, useEffect, useState } from 'react';\nimport {\n DashboardResource,\n Display,\n ProjectMetadata,\n DurationString,\n DEFAULT_REFRESH_INTERVAL,\n DatasourceSpec,\n EphemeralDashboardResource,\n} from '@perses-dev/core';\nimport { usePlugin, usePluginRegistry } from '@perses-dev/plugin-system';\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';\nimport { createSaveChangesDialogSlice, SaveChangesConfirmationDialogSlice } from './save-changes-dialog-slice';\nimport { createDuplicatePanelSlice, DuplicatePanelSlice } from './duplicate-panel-slice';\nimport { createEditJsonDialogSlice, EditJsonDialogSlice } from './edit-json-dialog-slice';\nimport { createPanelDefinition } from './common';\nimport { createViewPanelSlice, ViewPanelSlice, VirtualPanelRef } from './view-panel-slice';\n\nexport interface DashboardStoreState\n extends PanelGroupSlice,\n PanelSlice,\n PanelGroupEditorSlice,\n DeletePanelGroupSlice,\n PanelEditorSlice,\n DeletePanelSlice,\n DiscardChangesConfirmationDialogSlice,\n DuplicatePanelSlice,\n EditJsonDialogSlice,\n SaveChangesConfirmationDialogSlice,\n ViewPanelSlice {\n isEditMode: boolean;\n setEditMode: (isEditMode: boolean) => void;\n setDashboard: (dashboard: DashboardResource | EphemeralDashboardResource) => void;\n kind: DashboardResource['kind'] | EphemeralDashboardResource['kind'];\n metadata: ProjectMetadata;\n duration: DurationString;\n refreshInterval: DurationString;\n display?: Display;\n datasources?: Record<string, DatasourceSpec>;\n ttl?: DurationString;\n}\n\nexport const DashboardContext = createContext<StoreApi<DashboardStoreState> | undefined>(undefined);\n\nexport function useDashboardStore<T>(selector: (state: DashboardStoreState) => T): 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 useStoreWithEqualityFn(store, selector, shallow);\n}\n\nexport interface DashboardStoreProps {\n dashboardResource: DashboardResource | EphemeralDashboardResource;\n isEditMode?: boolean;\n viewPanelRef?: VirtualPanelRef;\n setViewPanelRef?: (viewPanelRef: VirtualPanelRef | undefined) => void;\n}\n\nexport interface DashboardProviderProps {\n initialState: DashboardStoreProps;\n children?: ReactNode;\n}\n\nexport function DashboardProvider(props: DashboardProviderProps): ReactElement {\n // Prevent calling createDashboardStore every time it rerenders\n const createDashboardStore = useCallback(initStore, [props]);\n const [store] = useState(createDashboardStore(props));\n\n // load plugin to retrieve initial spec if default panel kind is defined\n const { defaultPluginKinds } = usePluginRegistry();\n const defaultPanelKind = defaultPluginKinds?.['Panel'] ?? '';\n const { data: plugin } = usePlugin('Panel', defaultPanelKind);\n\n useEffect(() => {\n if (plugin === undefined) return;\n const defaultPanelSpec = plugin.createInitialOptions ? plugin.createInitialOptions() : {};\n // set default panel kind, spec, and queries for add panel editor\n store.setState({\n initialValues: {\n panelDefinition: createPanelDefinition(defaultPanelKind, defaultPanelSpec),\n },\n });\n }, [plugin, store, defaultPanelKind]);\n\n return (\n <DashboardContext.Provider value={store as StoreApi<DashboardStoreState>}>\n {props.children}\n </DashboardContext.Provider>\n );\n}\n\nfunction initStore(props: DashboardProviderProps): StoreApi<DashboardStoreState> {\n const {\n initialState: { dashboardResource, isEditMode, viewPanelRef, setViewPanelRef },\n } = props;\n\n const {\n kind,\n metadata,\n spec: { display, duration, refreshInterval = DEFAULT_REFRESH_INTERVAL, datasources, layouts = [], panels = {} },\n } = dashboardResource;\n\n const ttl = 'ttl' in dashboardResource.spec ? dashboardResource.spec.ttl : undefined;\n\n const store = createStore<DashboardStoreState>()(\n immer(\n devtools((...args) => {\n const [set] = args;\n return {\n /* Groups */\n ...createPanelGroupSlice(layouts)(...args),\n ...createPanelGroupEditorSlice(...args),\n ...createDeletePanelGroupSlice(...args),\n /* Panels */\n ...createPanelSlice(panels)(...args),\n ...createPanelEditorSlice()(...args),\n ...createDeletePanelSlice()(...args),\n ...createDuplicatePanelSlice()(...args),\n ...createViewPanelSlice(viewPanelRef, setViewPanelRef)(...args),\n /* General */\n ...createDiscardChangesDialogSlice(...args),\n ...createEditJsonDialogSlice(...args),\n ...createSaveChangesDialogSlice(...args),\n kind,\n metadata,\n display,\n duration,\n refreshInterval,\n datasources,\n ttl,\n isEditMode: !!isEditMode,\n setEditMode: (isEditMode: boolean): void => {\n set({ isEditMode });\n },\n setDashboard: ({\n kind,\n metadata,\n spec: { display, panels = {}, layouts = [], duration, refreshInterval, datasources = {} },\n }): void => {\n set((state) => {\n state.kind = kind;\n state.metadata = metadata;\n state.display = display;\n state.panels = panels;\n const { panelGroups, panelGroupOrder } = convertLayoutsToPanelGroups(layouts);\n state.panelGroups = panelGroups;\n state.panelGroupOrder = panelGroupOrder;\n state.duration = duration;\n state.refreshInterval = refreshInterval ?? DEFAULT_REFRESH_INTERVAL;\n state.datasources = datasources;\n // TODO: add ttl here to e.g allow edition from JSON view, but probably requires quite some refactoring\n });\n },\n };\n })\n )\n );\n\n return store;\n}\n"],"names":["createStore","useStoreWithEqualityFn","devtools","immer","shallow","createContext","useCallback","useContext","useEffect","useState","DEFAULT_REFRESH_INTERVAL","usePlugin","usePluginRegistry","createPanelGroupEditorSlice","convertLayoutsToPanelGroups","createPanelGroupSlice","createPanelEditorSlice","createPanelSlice","createDeletePanelGroupSlice","createDeletePanelSlice","createDiscardChangesDialogSlice","createSaveChangesDialogSlice","createDuplicatePanelSlice","createEditJsonDialogSlice","createPanelDefinition","createViewPanelSlice","DashboardContext","undefined","useDashboardStore","selector","store","Error","DashboardProvider","props","createDashboardStore","initStore","defaultPluginKinds","defaultPanelKind","data","plugin","defaultPanelSpec","createInitialOptions","setState","initialValues","panelDefinition","Provider","value","children","initialState","dashboardResource","isEditMode","viewPanelRef","setViewPanelRef","kind","metadata","spec","display","duration","refreshInterval","datasources","layouts","panels","ttl","args","set","setEditMode","setDashboard","state","panelGroups","panelGroupOrder"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,WAAW,QAAQ,UAAU;AACtC,SAASC,sBAAsB,QAAQ,sBAAsB;AAE7D,SAASC,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,KAAK,QAAQ,2BAA2B;AACjD,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,aAAa,EAA2BC,WAAW,EAAEC,UAAU,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAC7G,SAKEC,wBAAwB,QAGnB,mBAAmB;AAC1B,SAASC,SAAS,EAAEC,iBAAiB,QAAQ,4BAA4B;AACzE,SAASC,2BAA2B,QAA+B,6BAA6B;AAChG,SAASC,2BAA2B,EAAEC,qBAAqB,QAAyB,sBAAsB;AAC1G,SAASC,sBAAsB,QAA0B,uBAAuB;AAChF,SAASC,gBAAgB,QAAoB,gBAAgB;AAC7D,SAASC,2BAA2B,QAA+B,6BAA6B;AAChG,SAASC,sBAAsB,QAA0B,uBAAuB;AAChF,SAASC,+BAA+B,QAA+C,iCAAiC;AACxH,SAASC,4BAA4B,QAA4C,8BAA8B;AAC/G,SAASC,yBAAyB,QAA6B,0BAA0B;AACzF,SAASC,yBAAyB,QAA6B,2BAA2B;AAC1F,SAASC,qBAAqB,QAAQ,WAAW;AACjD,SAASC,oBAAoB,QAAyC,qBAAqB;AA0B3F,OAAO,MAAMC,iCAAmBrB,cAAyDsB,WAAW;AAEpG,OAAO,SAASC,kBAAqBC,QAA2C;IAC9E,MAAMC,QAAQvB,WAAWmB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":["// Copyright 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 } from 'zustand';\nimport { useStoreWithEqualityFn } from 'zustand/traditional';\nimport type { StoreApi } from 'zustand';\nimport { devtools } from 'zustand/middleware';\nimport { immer } from 'zustand/middleware/immer';\nimport { shallow } from 'zustand/shallow';\nimport { createContext, ReactElement, ReactNode, useCallback, useContext, useEffect, useState } from 'react';\nimport { DEFAULT_REFRESH_INTERVAL } from '@perses-dev/core';\nimport { Display, DurationString, DatasourceSpec } from '@perses-dev/spec';\nimport { usePlugin, usePluginRegistry } from '@perses-dev/plugin-system';\nimport { DashboardMetaData, DashboardKind, DashboardResource } from '../../model/DashboardResource';\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';\nimport { createSaveChangesDialogSlice, SaveChangesConfirmationDialogSlice } from './save-changes-dialog-slice';\nimport { createDuplicatePanelSlice, DuplicatePanelSlice } from './duplicate-panel-slice';\nimport { createEditJsonDialogSlice, EditJsonDialogSlice } from './edit-json-dialog-slice';\nimport { createPanelDefinition } from './common';\nimport { createViewPanelSlice, ViewPanelSlice, VirtualPanelRef } from './view-panel-slice';\nimport { createLinksSlice, LinksSlice } from './links-slice';\n\nexport interface DashboardStoreState\n extends PanelGroupSlice,\n PanelSlice,\n PanelGroupEditorSlice,\n DeletePanelGroupSlice,\n PanelEditorSlice,\n DeletePanelSlice,\n DiscardChangesConfirmationDialogSlice,\n DuplicatePanelSlice,\n EditJsonDialogSlice,\n SaveChangesConfirmationDialogSlice,\n ViewPanelSlice,\n LinksSlice {\n isEditMode: boolean;\n setEditMode: (isEditMode: boolean) => void;\n setDashboard: (dashboard: DashboardResource) => void;\n kind: DashboardKind;\n metadata: DashboardMetaData;\n duration: DurationString;\n refreshInterval: DurationString;\n display?: Display;\n datasources?: Record<string, DatasourceSpec>;\n ttl?: DurationString;\n}\n\nexport const DashboardContext = createContext<StoreApi<DashboardStoreState> | undefined>(undefined);\n\nexport function useDashboardStore<T>(selector: (state: DashboardStoreState) => T): 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 useStoreWithEqualityFn(store, selector, shallow);\n}\n\nexport interface DashboardStoreProps {\n dashboardResource: DashboardResource;\n isEditMode?: boolean;\n viewPanelRef?: VirtualPanelRef;\n setViewPanelRef?: (viewPanelRef: VirtualPanelRef | undefined) => void;\n}\n\nexport interface DashboardProviderProps {\n initialState: DashboardStoreProps;\n children?: ReactNode;\n}\n\nexport function DashboardProvider(props: DashboardProviderProps): ReactElement {\n // Prevent calling createDashboardStore every time it rerenders\n const createDashboardStore = useCallback(initStore, [props]);\n const [store] = useState(createDashboardStore(props));\n\n // load plugin to retrieve initial spec if default panel kind is defined\n const { defaultPluginKinds } = usePluginRegistry();\n const defaultPanelKind = defaultPluginKinds?.['Panel'] ?? '';\n const { data: plugin } = usePlugin('Panel', defaultPanelKind);\n\n useEffect(() => {\n if (plugin === undefined) return;\n const defaultPanelSpec = plugin.createInitialOptions ? plugin.createInitialOptions() : {};\n // set default panel kind, spec, and queries for add panel editor\n store.setState({\n initialValues: {\n panelDefinition: createPanelDefinition(defaultPanelKind, defaultPanelSpec),\n },\n });\n }, [plugin, store, defaultPanelKind]);\n\n return (\n <DashboardContext.Provider value={store as StoreApi<DashboardStoreState>}>\n {props.children}\n </DashboardContext.Provider>\n );\n}\n\nfunction initStore(props: DashboardProviderProps): StoreApi<DashboardStoreState> {\n const {\n initialState: { dashboardResource, isEditMode, viewPanelRef, setViewPanelRef },\n } = props;\n\n const {\n kind,\n metadata,\n spec: { display, duration, refreshInterval = DEFAULT_REFRESH_INTERVAL, datasources, layouts = [], panels = {} },\n } = dashboardResource;\n\n const links = dashboardResource.spec.links ?? [];\n\n const ttl = 'ttl' in dashboardResource.spec ? (dashboardResource.spec.ttl as DurationString) : undefined;\n\n const store = createStore<DashboardStoreState>()(\n immer(\n devtools((...args) => {\n const [set] = args;\n return {\n /* Groups */\n ...createPanelGroupSlice(layouts)(...args),\n ...createPanelGroupEditorSlice(...args),\n ...createDeletePanelGroupSlice(...args),\n /* Panels */\n ...createPanelSlice(panels)(...args),\n ...createPanelEditorSlice()(...args),\n ...createDeletePanelSlice()(...args),\n ...createDuplicatePanelSlice()(...args),\n ...createViewPanelSlice(viewPanelRef, setViewPanelRef)(...args),\n /* Links */\n ...createLinksSlice(links)(...args),\n /* General */\n ...createDiscardChangesDialogSlice(...args),\n ...createEditJsonDialogSlice(...args),\n ...createSaveChangesDialogSlice(...args),\n kind,\n metadata,\n display,\n duration,\n refreshInterval,\n datasources,\n ttl,\n isEditMode: !!isEditMode,\n setEditMode: (isEditMode: boolean): void => {\n set({ isEditMode });\n },\n setDashboard: ({\n kind,\n metadata,\n spec: { display, panels = {}, layouts = [], duration, refreshInterval, datasources = {}, links = [] },\n }): void => {\n set((state) => {\n state.kind = kind;\n state.metadata = metadata;\n state.display = display;\n state.panels = panels;\n const { panelGroups, panelGroupOrder } = convertLayoutsToPanelGroups(layouts);\n state.panelGroups = panelGroups;\n state.panelGroupOrder = panelGroupOrder;\n state.duration = duration;\n state.refreshInterval = refreshInterval ?? DEFAULT_REFRESH_INTERVAL;\n state.datasources = datasources;\n state.links = links;\n // TODO: add ttl here to e.g allow edition from JSON view, but probably requires quite some refactoring\n });\n },\n };\n })\n )\n );\n\n return store;\n}\n"],"names":["createStore","useStoreWithEqualityFn","devtools","immer","shallow","createContext","useCallback","useContext","useEffect","useState","DEFAULT_REFRESH_INTERVAL","usePlugin","usePluginRegistry","createPanelGroupEditorSlice","convertLayoutsToPanelGroups","createPanelGroupSlice","createPanelEditorSlice","createPanelSlice","createDeletePanelGroupSlice","createDeletePanelSlice","createDiscardChangesDialogSlice","createSaveChangesDialogSlice","createDuplicatePanelSlice","createEditJsonDialogSlice","createPanelDefinition","createViewPanelSlice","createLinksSlice","DashboardContext","undefined","useDashboardStore","selector","store","Error","DashboardProvider","props","createDashboardStore","initStore","defaultPluginKinds","defaultPanelKind","data","plugin","defaultPanelSpec","createInitialOptions","setState","initialValues","panelDefinition","Provider","value","children","initialState","dashboardResource","isEditMode","viewPanelRef","setViewPanelRef","kind","metadata","spec","display","duration","refreshInterval","datasources","layouts","panels","links","ttl","args","set","setEditMode","setDashboard","state","panelGroups","panelGroupOrder"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,WAAW,QAAQ,UAAU;AACtC,SAASC,sBAAsB,QAAQ,sBAAsB;AAE7D,SAASC,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,KAAK,QAAQ,2BAA2B;AACjD,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,aAAa,EAA2BC,WAAW,EAAEC,UAAU,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAC7G,SAASC,wBAAwB,QAAQ,mBAAmB;AAE5D,SAASC,SAAS,EAAEC,iBAAiB,QAAQ,4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AAC,CAACA;YACdgB,aAAa,CAAChB;gBACZe,IAAI;oBAAEf;gBAAW;YACnB;YACAiB,cAAc,CAAC,EACbd,IAAI,EACJC,QAAQ,EACRC,MAAM,EAAEC,OAAO,EAAEK,SAAS,CAAC,CAAC,EAAED,UAAU,EAAE,EAAEH,QAAQ,EAAEC,eAAe,EAAEC,cAAc,CAAC,CAAC,EAAEG,QAAQ,EAAE,EAAE,EACtG;gBACCG,IAAI,CAACG;oBACHA,MAAMf,IAAI,GAAGA;oBACbe,MAAMd,QAAQ,GAAGA;oBACjBc,MAAMZ,OAAO,GAAGA;oBAChBY,MAAMP,MAAM,GAAGA;oBACf,MAAM,EAAEQ,WAAW,EAAEC,eAAe,EAAE,GAAGzD,4BAA4B+C;oBACrEQ,MAAMC,WAAW,GAAGA;oBACpBD,MAAME,eAAe,GAAGA;oBACxBF,MAAMX,QAAQ,GAAGA;oBACjBW,MAAMV,eAAe,GAAGA,mBAAmBjD;oBAC3C2D,MAAMT,WAAW,GAAGA;oBACpBS,MAAMN,KAAK,GAAGA;gBACd,uGAAuG;gBACzG;YACF;QACF;IACF;IAIJ,OAAOhC;AACT"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { PanelDefinition, UnknownSpec } from '@perses-dev/spec';
|
|
2
|
+
import { DashboardResource } from '../../model';
|
|
3
|
+
export type OnSaveDashboard = (dashboard: DashboardResource) => Promise<unknown>;
|
|
3
4
|
/**
|
|
4
5
|
* The middleware applied to the DashboardStore (can be used as generic argument in StateCreator).
|
|
5
6
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/common.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/common.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,MAAM,eAAe,GAAG,CAAC,SAAS,EAAE,iBAAiB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAEjF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC,CAAC;AAEjF,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAKnC;AAGD,wBAAgB,qBAAqB,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,WAAW,GAAG,eAAe,CAehH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/DashboardProvider/common.ts"],"sourcesContent":["// Copyright 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 {
|
|
1
|
+
{"version":3,"sources":["../../../src/context/DashboardProvider/common.ts"],"sourcesContent":["// Copyright 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/spec';\nimport { DashboardResource } from '../../model';\n\nexport type OnSaveDashboard = (dashboard: DashboardResource) => Promise<unknown>;\n\n/**\n * The middleware applied to the DashboardStore (can be used as generic argument in StateCreator).\n */\nexport type Middleware = [['zustand/immer', never], ['zustand/devtools', never]];\n\ndeclare global {\n // eslint-disable-next-line no-var\n var dashboardStoreId: number | undefined;\n}\n\n/**\n * Helper function to generate unique IDs for things in the dashboard store that don't have a \"natural\" ID.\n */\nexport function generateId(): number {\n if (globalThis.dashboardStoreId === undefined) {\n globalThis.dashboardStoreId = 0;\n }\n return globalThis.dashboardStoreId++;\n}\n\n// Helper function to create initial PanelDefinitions\nexport function createPanelDefinition(defaultPanelKind?: string, defaultPanelSpec?: UnknownSpec): PanelDefinition {\n return {\n kind: 'Panel',\n spec: {\n display: {\n name: '',\n description: undefined,\n },\n plugin: {\n kind: defaultPanelKind ?? '',\n spec: defaultPanelSpec ?? {},\n },\n queries: [],\n },\n };\n}\n"],"names":["generateId","globalThis","dashboardStoreId","undefined","createPanelDefinition","defaultPanelKind","defaultPanelSpec","kind","spec","display","name","description","plugin","queries"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAiBjC;;CAEC,GACD,OAAO,SAASA;IACd,IAAIC,WAAWC,gBAAgB,KAAKC,WAAW;QAC7CF,WAAWC,gBAAgB,GAAG;IAChC;IACA,OAAOD,WAAWC,gBAAgB;AACpC;AAEA,qDAAqD;AACrD,OAAO,SAASE,sBAAsBC,gBAAyB,EAAEC,gBAA8B;IAC7F,OAAO;QACLC,MAAM;QACNC,MAAM;YACJC,SAAS;gBACPC,MAAM;gBACNC,aAAaR;YACf;YACAS,QAAQ;gBACNL,MAAMF,oBAAoB;gBAC1BG,MAAMF,oBAAoB,CAAC;YAC7B;YACAO,SAAS,EAAE;QACb;IACF;AACF"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PanelGroupItemLayout, PanelGroupDefinition, PanelGroupItemId } from '@perses-dev/core';
|
|
2
|
+
import { DurationString, Link, PanelDefinition, PanelGroupId } from '@perses-dev/spec';
|
|
3
|
+
import { DashboardResource } from '../../model';
|
|
2
4
|
import { DeletePanelGroupDialogState } from './delete-panel-group-slice';
|
|
3
5
|
import { PanelGroupEditor } from './panel-group-editor-slice';
|
|
4
6
|
import { PanelEditorState } from './panel-editor-slice';
|
|
@@ -17,8 +19,19 @@ export declare function useEditMode(): {
|
|
|
17
19
|
export declare function useDashboardActions(): {
|
|
18
20
|
openAddPanelGroup: () => void;
|
|
19
21
|
openAddPanel: () => void;
|
|
20
|
-
setDashboard: (dashboard: DashboardResource
|
|
22
|
+
setDashboard: (dashboard: DashboardResource) => void;
|
|
21
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Returns the dashboard links.
|
|
26
|
+
*/
|
|
27
|
+
export declare function useDashboardLinks(): Link[];
|
|
28
|
+
export interface DashboardLinksActions {
|
|
29
|
+
setLinks?: (links: Link[]) => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns actions that can be performed on dashboard links.
|
|
33
|
+
*/
|
|
34
|
+
export declare function useDashboardLinksActions(): DashboardLinksActions;
|
|
22
35
|
/**
|
|
23
36
|
* Returns an array of PanelGroupIds in the order they appear in the dashboard.
|
|
24
37
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard-provider-api.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/dashboard-provider-api.ts"],"names":[],"mappings":"AAcA,OAAO,
|
|
1
|
+
{"version":3,"file":"dashboard-provider-api.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/dashboard-provider-api.ts"],"names":[],"mappings":"AAcA,O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A"}
|
|
@@ -34,6 +34,20 @@ const selectDashboardActions = ({ setDashboard, openAddPanelGroup, openAddPanel
|
|
|
34
34
|
openAddPanel: ()=>openAddPanel()
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
+
const selectDashboardLinks = (state)=>state.links;
|
|
38
|
+
/**
|
|
39
|
+
* Returns the dashboard links.
|
|
40
|
+
*/ export function useDashboardLinks() {
|
|
41
|
+
return useDashboardStore(selectDashboardLinks) ?? [];
|
|
42
|
+
}
|
|
43
|
+
const selectDashboardLinksActions = (state)=>({
|
|
44
|
+
setLinks: state.setLinks
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Returns actions that can be performed on dashboard links.
|
|
48
|
+
*/ export function useDashboardLinksActions() {
|
|
49
|
+
return useDashboardStore(selectDashboardLinksActions);
|
|
50
|
+
}
|
|
37
51
|
const selectPanelGroupOrder = (state)=>state.panelGroupOrder;
|
|
38
52
|
/**
|
|
39
53
|
* Returns an array of PanelGroupIds in the order they appear in the dashboard.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/DashboardProvider/dashboard-provider-api.ts"],"sourcesContent":["// Copyright 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 {\n DashboardResource,\n DurationString,\n EphemeralDashboardResource,\n PanelDefinition,\n PanelGroupId,\n PanelGroupDefinition,\n PanelGroupItemId,\n PanelGroupItemLayout,\n} from '@perses-dev/core';\nimport { DashboardStoreState, useDashboardStore } from './DashboardProvider';\nimport { DeletePanelGroupDialogState } from './delete-panel-group-slice';\nimport { PanelGroupEditor } from './panel-group-editor-slice';\nimport { PanelEditorState } from './panel-editor-slice';\nimport { DeletePanelDialogState } from './delete-panel-slice';\nimport { SaveChangesConfirmationDialogState } from './save-changes-dialog-slice';\nimport { DiscardChangesConfirmationDialogState } from './discard-changes-dialog-slice';\nimport { EditJsonDialogState } from './edit-json-dialog-slice';\nimport { ViewPanelSlice } from './view-panel-slice';\n\nconst selectEditMode: ({ isEditMode, setEditMode }: DashboardStoreState) => {\n setEditMode: (isEditMode: boolean) => void;\n isEditMode: boolean;\n} = ({ isEditMode, setEditMode }: DashboardStoreState) => ({ isEditMode, setEditMode });\nexport function useEditMode(): { setEditMode: (isEditMode: boolean) => void; isEditMode: boolean } {\n return useDashboardStore(selectEditMode);\n}\n\nconst selectDashboardActions: ({ setDashboard, openAddPanelGroup, openAddPanel }: DashboardStoreState) => {\n openAddPanelGroup: () => void;\n openAddPanel: (panelGroupId?: PanelGroupId) => void;\n setDashboard: (dashboard: DashboardResource | EphemeralDashboardResource) => void;\n} = ({ 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 openAddPanelGroup: () => void;\n openAddPanel: () => void;\n setDashboard: (dashboard: DashboardResource | EphemeralDashboardResource) => void;\n} {\n const { setDashboard, openAddPanelGroup, openAddPanel } = useDashboardStore(selectDashboardActions);\n return {\n setDashboard,\n openAddPanelGroup: () => openAddPanelGroup(),\n openAddPanel: () => openAddPanel(),\n };\n}\n\nconst selectPanelGroupOrder = (state: DashboardStoreState): number[] => state.panelGroupOrder;\n/**\n * Returns an array of PanelGroupIds in the order they appear in the dashboard.\n */\nexport function usePanelGroupIds(): number[] {\n return useDashboardStore(selectPanelGroupOrder);\n}\n\nconst selectPanelGroups: (state: DashboardStoreState) => Record<number, PanelGroupDefinition> = (\n state: DashboardStoreState\n) => state.panelGroups;\n/**\n * Returns an array of PanelGroupDefinitions in the order they appear in the dashboard.\n */\nexport function useListPanelGroups(): PanelGroupDefinition[] {\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): PanelGroupDefinition {\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 updatePanelGroupLayouts: (panelGroupId: PanelGroupId, itemLayouts: PanelGroupDefinition['itemLayouts']) => void;\n openEditPanelGroup: (panelGroupId: PanelGroupId) => void;\n openAddPanel: (panelGroupId?: PanelGroupId) => void;\n deletePanelGroup: (panelGroupId: PanelGroupId) => void;\n} = ({ openEditPanelGroup, deletePanelGroup, openAddPanel, updatePanelGroupLayouts }: 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 updatePanelGroupLayouts: (itemLayouts: PanelGroupItemLayout[]) => void;\n openEditPanelGroup: () => void;\n openAddPanel: () => void;\n moveDown: (() => void) | undefined;\n deletePanelGroup: () => void;\n moveUp: (() => void) | undefined;\n} {\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) => (xIndex: number, yIndex: number) => void = (\n state: DashboardStoreState\n) => state.swapPanelGroups;\nconst selectPanelGroupsLength: (state: DashboardStoreState) => number = (state: DashboardStoreState) =>\n 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 moveDown: (() => void) | undefined;\n moveUp: (() => void) | undefined;\n} {\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: () => void = () => swapPanelGroups(currentIndex, currentIndex - 1);\n const moveDown: () => void = () => 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) => PanelGroupEditor | undefined = (\n state: DashboardStoreState\n) => state.panelGroupEditor;\n/**\n * Gets the Panel Group editor state.\n */\nexport function usePanelGroupEditor(): PanelGroupEditor | undefined {\n return useDashboardStore(selectPanelGroupEditor);\n}\n\nconst selectDeletePanelGroupDialog: ({\n deletePanelGroupDialog,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog,\n deletePanelGroup,\n}: DashboardStoreState) => {\n deletePanelGroupDialog: DeletePanelGroupDialogState | undefined;\n closeDeletePanelGroupDialog: () => void;\n openDeletePanelGroupDialog: (panelGroupId: PanelGroupId) => void;\n deletePanelGroup: (panelGroupId: PanelGroupId) => void;\n} = ({\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 deletePanelGroupDialog: DeletePanelGroupDialogState | undefined;\n closeDeletePanelGroupDialog: () => void;\n openDeletePanelGroupDialog: (panelGroupId: PanelGroupId) => void;\n deletePanelGroup: (panelGroupId: PanelGroupId) => void;\n} {\n const { deletePanelGroupDialog, openDeletePanelGroupDialog, closeDeletePanelGroupDialog, deletePanelGroup } =\n useDashboardStore(selectDeletePanelGroupDialog);\n return {\n deletePanelGroupDialog,\n deletePanelGroup,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog: () => closeDeletePanelGroupDialog(),\n };\n}\n\nexport function usePanelKey(panelGroupItemId?: PanelGroupItemId): string | undefined {\n const panelKey = useDashboardStore(\n useCallback(\n (store) => {\n if (panelGroupItemId === undefined) {\n return undefined;\n }\n\n return store.panelGroups[panelGroupItemId.panelGroupId]?.itemPanelKeys[panelGroupItemId.panelGroupItemLayoutId];\n },\n [panelGroupItemId]\n )\n );\n return panelKey;\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): PanelDefinition {\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: ({\n openEditPanel,\n openDeletePanelDialog,\n duplicatePanel,\n setViewPanel,\n}: DashboardStoreState) => {\n openDeletePanelDialog: (panelGroupItemId: PanelGroupItemId) => void;\n duplicatePanel: (panelGroupItemId: PanelGroupItemId) => void;\n openEditPanel: (panelGroupItemId: PanelGroupItemId) => void;\n setViewPanel: (panelGroupItemId?: PanelGroupItemId) => void;\n} = ({ openEditPanel, openDeletePanelDialog, duplicatePanel, setViewPanel }: DashboardStoreState) => ({\n openEditPanel,\n openDeletePanelDialog,\n duplicatePanel,\n setViewPanel,\n});\n\n/**\n * Returns actions that can be performed on the given Panel.\n */\nexport function usePanelActions(panelGroupItemId: PanelGroupItemId): {\n openDeletePanelDialog: () => void;\n duplicatePanel: () => void;\n openEditPanel: () => void;\n viewPanel: (panelGroupItemId?: PanelGroupItemId) => void;\n} {\n const { openEditPanel, openDeletePanelDialog, duplicatePanel, setViewPanel } = useDashboardStore(selectPanelActions);\n return {\n openEditPanel: () => openEditPanel(panelGroupItemId),\n openDeletePanelDialog: () => openDeletePanelDialog(panelGroupItemId),\n duplicatePanel: () => duplicatePanel(panelGroupItemId),\n viewPanel: (panelGroupItemId?: PanelGroupItemId) => setViewPanel(panelGroupItemId),\n };\n}\n\nconst selectPanelEditor: (state: DashboardStoreState) => PanelEditorState | undefined = (state: DashboardStoreState) =>\n state.panelEditor;\n/**\n * Gets the state for the Panel Editor.\n */\nexport function usePanelEditor(): PanelEditorState | undefined {\n return useDashboardStore(selectPanelEditor);\n}\n\nconst selectDeletePanelDialog: ({ deletePanelDialog, deletePanel, closeDeletePanelDialog }: DashboardStoreState) => {\n deletePanelDialog: DeletePanelDialogState | undefined;\n closeDeletePanelDialog: () => void;\n deletePanel: (panelGroupItemId: PanelGroupItemId) => void;\n} = ({ 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 deletePanelDialog: DeletePanelDialogState | undefined;\n closeDeletePanelDialog: () => void;\n deletePanel: (panelGroupItemId: PanelGroupItemId) => void;\n} {\n // TODO: Refactor similar to other dialogs/editors so these are on the editor state itself\n return useDashboardStore(selectDeletePanelDialog);\n}\n\nconst selectDashboardDuration: (state: DashboardStoreState) => DurationString = (state: DashboardStoreState) =>\n state.duration;\nexport function useDashboardDuration(): DurationString {\n return useDashboardStore(selectDashboardDuration);\n}\n\nconst selectViewPanel: (state: DashboardStoreState) => {\n setViewPanel: DashboardStoreState['setViewPanel'];\n getViewPanel: DashboardStoreState['getViewPanel'];\n viewPanelId: DashboardStoreState['viewPanel']['panelGroupItemId'];\n} = (state: DashboardStoreState) => ({\n setViewPanel: state.setViewPanel,\n getViewPanel: state.getViewPanel,\n viewPanelId: state.getViewPanel(),\n});\n/**\n * Returns actions related to the ViewPanel.\n */\nexport function useViewPanel(): {\n setViewPanel: ViewPanelSlice['setViewPanel'];\n getViewPanel: ViewPanelSlice['getViewPanel'];\n viewPanelId: ViewPanelSlice['viewPanel']['panelGroupItemId'];\n} {\n return useDashboardStore(selectViewPanel);\n}\n\nconst selectViewPanelGroup: (state: DashboardStoreState) => PanelGroupItemId | undefined = (\n state: DashboardStoreState\n) => state.getViewPanel();\n/**\n * Gets the Panel Group for the view panel.\n */\nexport function useViewPanelGroup(): PanelGroupItemId | undefined {\n return useDashboardStore(selectViewPanelGroup);\n}\n\nconst selectSaveChangesConfirmationDialog: ({\n saveChangesConfirmationDialog,\n openSaveChangesConfirmationDialog,\n closeSaveChangesConfirmationDialog,\n}: DashboardStoreState) => {\n closeSaveChangesConfirmationDialog: () => void;\n openSaveChangesConfirmationDialog: (saveChangesConfirmationDialog: SaveChangesConfirmationDialogState) => void;\n saveChangesConfirmationDialog: SaveChangesConfirmationDialogState | undefined;\n} = ({\n saveChangesConfirmationDialog,\n openSaveChangesConfirmationDialog,\n closeSaveChangesConfirmationDialog,\n}: DashboardStoreState) => ({\n saveChangesConfirmationDialog,\n openSaveChangesConfirmationDialog,\n closeSaveChangesConfirmationDialog,\n});\nexport function useSaveChangesConfirmationDialog(): {\n closeSaveChangesConfirmationDialog: () => void;\n openSaveChangesConfirmationDialog: (saveChangesConfirmationDialog: SaveChangesConfirmationDialogState) => void;\n saveChangesConfirmationDialog: SaveChangesConfirmationDialogState | undefined;\n} {\n return useDashboardStore(selectSaveChangesConfirmationDialog);\n}\n\nconst selectDiscardChangesConfirmationDialog: ({\n discardChangesConfirmationDialog,\n openDiscardChangesConfirmationDialog,\n closeDiscardChangesConfirmationDialog,\n}: DashboardStoreState) => {\n discardChangesConfirmationDialog: DiscardChangesConfirmationDialogState | undefined;\n closeDiscardChangesConfirmationDialog: () => void;\n openDiscardChangesConfirmationDialog: (\n discardChangesConfirmationDialog: DiscardChangesConfirmationDialogState\n ) => void;\n} = ({\n discardChangesConfirmationDialog,\n openDiscardChangesConfirmationDialog,\n closeDiscardChangesConfirmationDialog,\n}: DashboardStoreState) => ({\n discardChangesConfirmationDialog,\n openDiscardChangesConfirmationDialog,\n closeDiscardChangesConfirmationDialog,\n});\nexport function useDiscardChangesConfirmationDialog(): {\n discardChangesConfirmationDialog: DiscardChangesConfirmationDialogState | undefined;\n closeDiscardChangesConfirmationDialog: () => void;\n openDiscardChangesConfirmationDialog: (\n discardChangesConfirmationDialog: DiscardChangesConfirmationDialogState\n ) => void;\n} {\n return useDashboardStore(selectDiscardChangesConfirmationDialog);\n}\n\nconst selectEditJsonDialog: ({ editJsonDialog, openEditJsonDialog, closeEditJsonDialog }: DashboardStoreState) => {\n openEditJsonDialog: () => void;\n closeEditJsonDialog: () => void;\n editJsonDialog: EditJsonDialogState | undefined;\n} = ({ editJsonDialog, openEditJsonDialog, closeEditJsonDialog }: DashboardStoreState) => ({\n editJsonDialog,\n openEditJsonDialog,\n closeEditJsonDialog,\n});\n/**\n * Gets the state for the edit JSON dialog.\n */\nexport function useEditJsonDialog(): {\n openEditJsonDialog: () => void;\n closeEditJsonDialog: () => void;\n editJsonDialog: EditJsonDialogState | undefined;\n} {\n return useDashboardStore(selectEditJsonDialog);\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","usePanelKey","panelGroupItemId","panelKey","itemPanelKeys","panelGroupItemLayoutId","usePanel","panelGroupLayoutId","panel","panels","selectPanelActions","openEditPanel","openDeletePanelDialog","duplicatePanel","setViewPanel","usePanelActions","viewPanel","selectPanelEditor","panelEditor","usePanelEditor","selectDeletePanelDialog","deletePanelDialog","deletePanel","closeDeletePanelDialog","useDeletePanelDialog","selectDashboardDuration","duration","useDashboardDuration","selectViewPanel","getViewPanel","viewPanelId","useViewPanel","selectViewPanelGroup","useViewPanelGroup","selectSaveChangesConfirmationDialog","saveChangesConfirmationDialog","openSaveChangesConfirmationDialog","closeSaveChangesConfirmationDialog","useSaveChangesConfirmationDialog","selectDiscardChangesConfirmationDialog","discardChangesConfirmationDialog","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","useDiscardChangesConfirmationDialog","selectEditJsonDialog","editJsonDialog","openEditJsonDialog","closeEditJsonDialog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C,GACD,OAAO,SAASI;IACd,OAAOnF,kBAAkBkF;AAC3B;AAEA,MAAME,sCAQF,CAAC,EACHC,6BAA6B,EAC7BC,iCAAiC,EACjCC,kCAAkC,EACd,GAAM,CAAA;QAC1BF;QACAC;QACAC;IACF,CAAA;AACA,OAAO,SAASC;IAKd,OAAOxF,kBAAkBoF;AAC3B;AAEA,MAAMK,yCAUF,CAAC,EACHC,gCAAgC,EAChCC,oCAAoC,EACpCC,qCAAqC,EACjB,GAAM,CAAA;QAC1BF;QACAC;QACAC;IACF,CAAA;AACA,OAAO,SAASC;IAOd,OAAO7F,kBAAkByF;AAC3B;AAEA,MAAMK,uBAIF,CAAC,EAAEC,cAAc,EAAEC,kBAAkB,EAAEC,mBAAmB,EAAuB,GAAM,CAAA;QACzFF;QACAC;QACAC;IACF,CAAA;AACA;;CAEC,GACD,OAAO,SAASC;IAKd,OAAOlG,kBAAkB8F;AAC3B"}
|
|
1
|
+
{"version":3,"sources":["../../../src/context/DashboardProvider/dashboard-provider-api.ts"],"sourcesContent":["// Copyright 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 { PanelGroupItemLayout, PanelGroupDefinition, PanelGroupItemId } from '@perses-dev/core'; // TODO\nimport { DurationString, Link, PanelDefinition, PanelGroupId } from '@perses-dev/spec';\nimport { DashboardResource } from '../../model';\nimport { DashboardStoreState, useDashboardStore } from './DashboardProvider';\nimport { DeletePanelGroupDialogState } from './delete-panel-group-slice';\nimport { PanelGroupEditor } from './panel-group-editor-slice';\nimport { PanelEditorState } from './panel-editor-slice';\nimport { DeletePanelDialogState } from './delete-panel-slice';\nimport { SaveChangesConfirmationDialogState } from './save-changes-dialog-slice';\nimport { DiscardChangesConfirmationDialogState } from './discard-changes-dialog-slice';\nimport { EditJsonDialogState } from './edit-json-dialog-slice';\nimport { ViewPanelSlice } from './view-panel-slice';\n\nconst selectEditMode: ({ isEditMode, setEditMode }: DashboardStoreState) => {\n setEditMode: (isEditMode: boolean) => void;\n isEditMode: boolean;\n} = ({ isEditMode, setEditMode }: DashboardStoreState) => ({ isEditMode, setEditMode });\nexport function useEditMode(): { setEditMode: (isEditMode: boolean) => void; isEditMode: boolean } {\n return useDashboardStore(selectEditMode);\n}\n\nconst selectDashboardActions: ({ setDashboard, openAddPanelGroup, openAddPanel }: DashboardStoreState) => {\n openAddPanelGroup: () => void;\n openAddPanel: (panelGroupId?: PanelGroupId) => void;\n setDashboard: (dashboard: DashboardResource) => void;\n} = ({ 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 openAddPanelGroup: () => void;\n openAddPanel: () => void;\n setDashboard: (dashboard: DashboardResource) => void;\n} {\n const { setDashboard, openAddPanelGroup, openAddPanel } = useDashboardStore(selectDashboardActions);\n return {\n setDashboard,\n openAddPanelGroup: () => openAddPanelGroup(),\n openAddPanel: () => openAddPanel(),\n };\n}\n\nconst selectDashboardLinks: (state: DashboardStoreState) => Link[] | undefined = (state: DashboardStoreState) =>\n state.links;\n/**\n * Returns the dashboard links.\n */\nexport function useDashboardLinks(): Link[] {\n return useDashboardStore(selectDashboardLinks) ?? [];\n}\n\nexport interface DashboardLinksActions {\n setLinks?: (links: Link[]) => void;\n}\n\nconst selectDashboardLinksActions: (state: DashboardStoreState) => DashboardLinksActions = (\n state: DashboardStoreState\n) => ({\n setLinks: state.setLinks,\n});\n/**\n * Returns actions that can be performed on dashboard links.\n */\nexport function useDashboardLinksActions(): DashboardLinksActions {\n return useDashboardStore(selectDashboardLinksActions);\n}\n\nconst selectPanelGroupOrder = (state: DashboardStoreState): number[] => state.panelGroupOrder;\n/**\n * Returns an array of PanelGroupIds in the order they appear in the dashboard.\n */\nexport function usePanelGroupIds(): number[] {\n return useDashboardStore(selectPanelGroupOrder);\n}\n\nconst selectPanelGroups: (state: DashboardStoreState) => Record<number, PanelGroupDefinition> = (\n state: DashboardStoreState\n) => state.panelGroups;\n/**\n * Returns an array of PanelGroupDefinitions in the order they appear in the dashboard.\n */\nexport function useListPanelGroups(): PanelGroupDefinition[] {\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): PanelGroupDefinition {\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 updatePanelGroupLayouts: (panelGroupId: PanelGroupId, itemLayouts: PanelGroupDefinition['itemLayouts']) => void;\n openEditPanelGroup: (panelGroupId: PanelGroupId) => void;\n openAddPanel: (panelGroupId?: PanelGroupId) => void;\n deletePanelGroup: (panelGroupId: PanelGroupId) => void;\n} = ({ openEditPanelGroup, deletePanelGroup, openAddPanel, updatePanelGroupLayouts }: 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 updatePanelGroupLayouts: (itemLayouts: PanelGroupItemLayout[]) => void;\n openEditPanelGroup: () => void;\n openAddPanel: () => void;\n moveDown: (() => void) | undefined;\n deletePanelGroup: () => void;\n moveUp: (() => void) | undefined;\n} {\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) => (xIndex: number, yIndex: number) => void = (\n state: DashboardStoreState\n) => state.swapPanelGroups;\nconst selectPanelGroupsLength: (state: DashboardStoreState) => number = (state: DashboardStoreState) =>\n 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 moveDown: (() => void) | undefined;\n moveUp: (() => void) | undefined;\n} {\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: () => void = () => swapPanelGroups(currentIndex, currentIndex - 1);\n const moveDown: () => void = () => 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) => PanelGroupEditor | undefined = (\n state: DashboardStoreState\n) => state.panelGroupEditor;\n/**\n * Gets the Panel Group editor state.\n */\nexport function usePanelGroupEditor(): PanelGroupEditor | undefined {\n return useDashboardStore(selectPanelGroupEditor);\n}\n\nconst selectDeletePanelGroupDialog: ({\n deletePanelGroupDialog,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog,\n deletePanelGroup,\n}: DashboardStoreState) => {\n deletePanelGroupDialog: DeletePanelGroupDialogState | undefined;\n closeDeletePanelGroupDialog: () => void;\n openDeletePanelGroupDialog: (panelGroupId: PanelGroupId) => void;\n deletePanelGroup: (panelGroupId: PanelGroupId) => void;\n} = ({\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 deletePanelGroupDialog: DeletePanelGroupDialogState | undefined;\n closeDeletePanelGroupDialog: () => void;\n openDeletePanelGroupDialog: (panelGroupId: PanelGroupId) => void;\n deletePanelGroup: (panelGroupId: PanelGroupId) => void;\n} {\n const { deletePanelGroupDialog, openDeletePanelGroupDialog, closeDeletePanelGroupDialog, deletePanelGroup } =\n useDashboardStore(selectDeletePanelGroupDialog);\n return {\n deletePanelGroupDialog,\n deletePanelGroup,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog: () => closeDeletePanelGroupDialog(),\n };\n}\n\nexport function usePanelKey(panelGroupItemId?: PanelGroupItemId): string | undefined {\n const panelKey = useDashboardStore(\n useCallback(\n (store) => {\n if (panelGroupItemId === undefined) {\n return undefined;\n }\n\n return store.panelGroups[panelGroupItemId.panelGroupId]?.itemPanelKeys[panelGroupItemId.panelGroupItemLayoutId];\n },\n [panelGroupItemId]\n )\n );\n return panelKey;\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): PanelDefinition {\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: ({\n openEditPanel,\n openDeletePanelDialog,\n duplicatePanel,\n setViewPanel,\n}: DashboardStoreState) => {\n openDeletePanelDialog: (panelGroupItemId: PanelGroupItemId) => void;\n duplicatePanel: (panelGroupItemId: PanelGroupItemId) => void;\n openEditPanel: (panelGroupItemId: PanelGroupItemId) => void;\n setViewPanel: (panelGroupItemId?: PanelGroupItemId) => void;\n} = ({ openEditPanel, openDeletePanelDialog, duplicatePanel, setViewPanel }: DashboardStoreState) => ({\n openEditPanel,\n openDeletePanelDialog,\n duplicatePanel,\n setViewPanel,\n});\n\n/**\n * Returns actions that can be performed on the given Panel.\n */\nexport function usePanelActions(panelGroupItemId: PanelGroupItemId): {\n openDeletePanelDialog: () => void;\n duplicatePanel: () => void;\n openEditPanel: () => void;\n viewPanel: (panelGroupItemId?: PanelGroupItemId) => void;\n} {\n const { openEditPanel, openDeletePanelDialog, duplicatePanel, setViewPanel } = useDashboardStore(selectPanelActions);\n return {\n openEditPanel: () => openEditPanel(panelGroupItemId),\n openDeletePanelDialog: () => openDeletePanelDialog(panelGroupItemId),\n duplicatePanel: () => duplicatePanel(panelGroupItemId),\n viewPanel: (panelGroupItemId?: PanelGroupItemId) => setViewPanel(panelGroupItemId),\n };\n}\n\nconst selectPanelEditor: (state: DashboardStoreState) => PanelEditorState | undefined = (state: DashboardStoreState) =>\n state.panelEditor;\n/**\n * Gets the state for the Panel Editor.\n */\nexport function usePanelEditor(): PanelEditorState | undefined {\n return useDashboardStore(selectPanelEditor);\n}\n\nconst selectDeletePanelDialog: ({ deletePanelDialog, deletePanel, closeDeletePanelDialog }: DashboardStoreState) => {\n deletePanelDialog: DeletePanelDialogState | undefined;\n closeDeletePanelDialog: () => void;\n deletePanel: (panelGroupItemId: PanelGroupItemId) => void;\n} = ({ 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 deletePanelDialog: DeletePanelDialogState | undefined;\n closeDeletePanelDialog: () => void;\n deletePanel: (panelGroupItemId: PanelGroupItemId) => void;\n} {\n // TODO: Refactor similar to other dialogs/editors so these are on the editor state itself\n return useDashboardStore(selectDeletePanelDialog);\n}\n\nconst selectDashboardDuration: (state: DashboardStoreState) => DurationString = (state: DashboardStoreState) =>\n state.duration;\nexport function useDashboardDuration(): DurationString {\n return useDashboardStore(selectDashboardDuration);\n}\n\nconst selectViewPanel: (state: DashboardStoreState) => {\n setViewPanel: DashboardStoreState['setViewPanel'];\n getViewPanel: DashboardStoreState['getViewPanel'];\n viewPanelId: DashboardStoreState['viewPanel']['panelGroupItemId'];\n} = (state: DashboardStoreState) => ({\n setViewPanel: state.setViewPanel,\n getViewPanel: state.getViewPanel,\n viewPanelId: state.getViewPanel(),\n});\n/**\n * Returns actions related to the ViewPanel.\n */\nexport function useViewPanel(): {\n setViewPanel: ViewPanelSlice['setViewPanel'];\n getViewPanel: ViewPanelSlice['getViewPanel'];\n viewPanelId: ViewPanelSlice['viewPanel']['panelGroupItemId'];\n} {\n return useDashboardStore(selectViewPanel);\n}\n\nconst selectViewPanelGroup: (state: DashboardStoreState) => PanelGroupItemId | undefined = (\n state: DashboardStoreState\n) => state.getViewPanel();\n/**\n * Gets the Panel Group for the view panel.\n */\nexport function useViewPanelGroup(): PanelGroupItemId | undefined {\n return useDashboardStore(selectViewPanelGroup);\n}\n\nconst selectSaveChangesConfirmationDialog: ({\n saveChangesConfirmationDialog,\n openSaveChangesConfirmationDialog,\n closeSaveChangesConfirmationDialog,\n}: DashboardStoreState) => {\n closeSaveChangesConfirmationDialog: () => void;\n openSaveChangesConfirmationDialog: (saveChangesConfirmationDialog: SaveChangesConfirmationDialogState) => void;\n saveChangesConfirmationDialog: SaveChangesConfirmationDialogState | undefined;\n} = ({\n saveChangesConfirmationDialog,\n openSaveChangesConfirmationDialog,\n closeSaveChangesConfirmationDialog,\n}: DashboardStoreState) => ({\n saveChangesConfirmationDialog,\n openSaveChangesConfirmationDialog,\n closeSaveChangesConfirmationDialog,\n});\nexport function useSaveChangesConfirmationDialog(): {\n closeSaveChangesConfirmationDialog: () => void;\n openSaveChangesConfirmationDialog: (saveChangesConfirmationDialog: SaveChangesConfirmationDialogState) => void;\n saveChangesConfirmationDialog: SaveChangesConfirmationDialogState | undefined;\n} {\n return useDashboardStore(selectSaveChangesConfirmationDialog);\n}\n\nconst selectDiscardChangesConfirmationDialog: ({\n discardChangesConfirmationDialog,\n openDiscardChangesConfirmationDialog,\n closeDiscardChangesConfirmationDialog,\n}: DashboardStoreState) => {\n discardChangesConfirmationDialog: DiscardChangesConfirmationDialogState | undefined;\n closeDiscardChangesConfirmationDialog: () => void;\n openDiscardChangesConfirmationDialog: (\n discardChangesConfirmationDialog: DiscardChangesConfirmationDialogState\n ) => void;\n} = ({\n discardChangesConfirmationDialog,\n openDiscardChangesConfirmationDialog,\n closeDiscardChangesConfirmationDialog,\n}: DashboardStoreState) => ({\n discardChangesConfirmationDialog,\n openDiscardChangesConfirmationDialog,\n closeDiscardChangesConfirmationDialog,\n});\nexport function useDiscardChangesConfirmationDialog(): {\n discardChangesConfirmationDialog: DiscardChangesConfirmationDialogState | undefined;\n closeDiscardChangesConfirmationDialog: () => void;\n openDiscardChangesConfirmationDialog: (\n discardChangesConfirmationDialog: DiscardChangesConfirmationDialogState\n ) => void;\n} {\n return useDashboardStore(selectDiscardChangesConfirmationDialog);\n}\n\nconst selectEditJsonDialog: ({ editJsonDialog, openEditJsonDialog, closeEditJsonDialog }: DashboardStoreState) => {\n openEditJsonDialog: () => void;\n closeEditJsonDialog: () => void;\n editJsonDialog: EditJsonDialogState | undefined;\n} = ({ editJsonDialog, openEditJsonDialog, closeEditJsonDialog }: DashboardStoreState) => ({\n editJsonDialog,\n openEditJsonDialog,\n closeEditJsonDialog,\n});\n/**\n * Gets the state for the edit JSON dialog.\n */\nexport function useEditJsonDialog(): {\n openEditJsonDialog: () => void;\n closeEditJsonDialog: () => void;\n editJsonDialog: EditJsonDialogState | undefined;\n} {\n return useDashboardStore(selectEditJsonDialog);\n}\n"],"names":["useCallback","useMemo","useDashboardStore","selectEditMode","isEditMode","setEditMode","useEditMode","selectDashboardActions","setDashboard","openAddPanelGroup","openAddPanel","useDashboardActions","selectDashboardLinks","state","links","useDashboardLinks","selectDashboardLinksActions","setLinks","useDashboardLinksActions","selectPanelGroupOrder","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","usePanelKey","panelGroupItemId","panelKey","itemPanelKeys","panelGroupItemLayoutId","usePanel","panelGroupLayoutId","panel","panels","selectPanelActions","openEditPanel","openDeletePanelDialog","duplicatePanel","setViewPanel","usePanelActions","viewPanel","selectPanelEditor","panelEditor","usePanelEditor","selectDeletePanelDialog","deletePanelDialog","deletePanel","closeDeletePanelDialog","useDeletePanelDialog","selectDashboardDuration","duration","useDashboardDuration","selectViewPanel","getViewPanel","viewPanelId","useViewPanel","selectViewPanelGroup","useViewPanelGroup","selectSaveChangesConfirmationDialog","saveChangesConfirmationDialog","openSaveChangesConfirmationDialog","closeSaveChangesConfirmationDialog","useSaveChangesConfirmationDialog","selectDiscardChangesConfirmationDialog","discardChangesConfirmationDialog","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","useDiscardChangesConfirmationDialog","selectEditJsonDialog","editJsonDialog","openEditJsonDialog","closeEditJsonDialog","useEditJsonDialog"],"mappings":"AAAA,+BAA+B;AAC/B,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,QAAQ;AAI7C,SAA8BC,iBAAiB,QAAQ,sBAAsB;AAU7E,MAAMC,iBAGF,CAAC,EAAEC,UAAU,EAAEC,WAAW,EAAuB,GAAM,CAAA;QAAED;QAAYC;IAAY,CAAA;AACrF,OAAO,SAASC;IACd,OAAOJ,kBAAkBC;AAC3B;AAEA,MAAMI,yBAIF,CAAC,EAAEC,YAAY,EAAEC,iBAAiB,EAAEC,YAAY,EAAuB,GAAM,CAAA;QAC/EF;QACAC;QACAC;IACF,CAAA;AACA;;CAEC,GACD,OAAO,SAASC;IAKd,MAAM,EAAEH,YAAY,EAAEC,iBAAiB,EAAEC,YAAY,EAAE,GAAGR,kBAAkBK;IAC5E,OAAO;QACLC;QACAC,mBAAmB,IAAMA;QACzBC,cAAc,IAAMA;IACtB;AACF;AAEA,MAAME,uBAA2E,CAACC,QAChFA,MAAMC,KAAK;AACb;;CAEC,GACD,OAAO,SAASC;IACd,OAAOb,kBAAkBU,yBAAyB,EAAE;AACtD;AAMA,MAAMI,8BAAqF,CACzFH,QACI,CAAA;QACJ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reator } from 'zustand';
|
|
2
|
-
import { PanelGroupId } from '@perses-dev/
|
|
2
|
+
import { PanelGroupId } from '@perses-dev/spec';
|
|
3
3
|
import { Middleware } from './common';
|
|
4
4
|
import { PanelGroupSlice } from './panel-group-slice';
|
|
5
5
|
import { PanelSlice } from './panel-slice';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/DashboardProvider/delete-panel-group-slice.ts"],"sourcesContent":["// Copyright 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 { PanelGroupId } from '@perses-dev/
|
|
1
|
+
{"version":3,"sources":["../../../src/context/DashboardProvider/delete-panel-group-slice.ts"],"sourcesContent":["// Copyright 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 { PanelGroupId } from '@perses-dev/spec';\nimport { Middleware } from './common';\nimport { PanelGroupSlice } from './panel-group-slice';\nimport { PanelSlice } from './panel-slice';\n\n/**\n * Slice that handles the visual editor state and related actions for deleting a Panel Group.\n */\nexport interface DeletePanelGroupSlice {\n deletePanelGroupDialog?: DeletePanelGroupDialogState;\n\n /**\n * Delete panel group and all the panels within the group\n */\n deletePanelGroup: (panelGroupId: PanelGroupId) => void;\n\n openDeletePanelGroupDialog: (panelGroupId: PanelGroupId) => void;\n closeDeletePanelGroupDialog: () => void;\n}\n\nexport interface DeletePanelGroupDialogState {\n panelGroupId: PanelGroupId;\n panelGroupName?: string;\n}\n\nexport const createDeletePanelGroupSlice: StateCreator<\n // Actions in here need to modify both Panels and Panel Groups state\n DeletePanelGroupSlice & PanelGroupSlice & PanelSlice,\n Middleware,\n [],\n DeletePanelGroupSlice\n> = (set, get) => ({\n deletePanelGroup(panelGroupId): void {\n const { panelGroups, panelGroupOrder } = get();\n const group = panelGroups[panelGroupId];\n const idIndex = panelGroupOrder.findIndex((id) => id === panelGroupId);\n if (group === undefined || idIndex === -1) {\n throw new Error(`Panel group ${panelGroupId} not found`);\n }\n\n // Get the panel keys for all the panel items in the group we're going to delete\n const panelKeys = Object.values(group.itemPanelKeys);\n\n set((draft) => {\n // Delete the panel group which also deletes all its items\n delete draft.panelGroups[panelGroupId];\n draft.panelGroupOrder.splice(idIndex, 1);\n\n // Get all remaining panel keys in use\n const usedPanelKeys = getUsedPanelKeys(draft.panelGroups);\n\n // For the panel keys of the items that were just deleted, see if they're still used and if not, also delete the\n // panel definition\n for (const panelKey of panelKeys) {\n if (usedPanelKeys.has(panelKey)) continue;\n\n delete draft.panels[panelKey];\n }\n });\n },\n\n openDeletePanelGroupDialog: (panelGroupId): void => {\n const panelGroup = get().panelGroups[panelGroupId];\n if (panelGroup === undefined) {\n throw new Error(`Panel group with Id ${panelGroupId} not found`);\n }\n set((state) => {\n state.deletePanelGroupDialog = { panelGroupId, panelGroupName: panelGroup.title };\n });\n },\n\n closeDeletePanelGroupDialog: () =>\n set((state) => {\n state.deletePanelGroupDialog = undefined;\n }),\n});\n\n// Helper to get the panel keys of all groups, returning a set to eliminate duplicates\nfunction getUsedPanelKeys(panelGroups: PanelGroupSlice['panelGroups']): Set<string> {\n const usedPanelKeys = new Set<string>();\n for (const group of Object.values(panelGroups)) {\n for (const panelKey of Object.values(group.itemPanelKeys)) {\n usedPanelKeys.add(panelKey);\n }\n }\n return usedPanelKeys;\n}\n"],"names":["createDeletePanelGroupSlice","set","get","deletePanelGroup","panelGroupId","panelGroups","panelGroupOrder","group","idIndex","findIndex","id","undefined","Error","panelKeys","Object","values","itemPanelKeys","draft","splice","usedPanelKeys","getUsedPanelKeys","panelKey","has","panels","openDeletePanelGroupDialog","panelGroup","state","deletePanelGroupDialog","panelGroupName","title","closeDeletePanelGroupDialog","Set","add"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AA4BjC,OAAO,MAAMA,8BAMT,CAACC,KAAKC,MAAS,CAAA;QACjBC,kBAAiBC,YAAY;YAC3B,MAAM,EAAEC,WAAW,EAAEC,eAAe,EAAE,GAAGJ;YACzC,MAAMK,QAAQF,WAAW,CAACD,aAAa;YACvC,MAAMI,UAAUF,gBAAgBG,SAAS,CAAC,CAACC,KAAOA,OAAON;YACzD,IAAIG,UAAUI,aAAaH,YAAY,CAAC,GAAG;gBACzC,MAAM,IAAII,MAAM,CAAC,YAAY,EAAER,aAAa,UAAU,CAAC;YACzD;YAEA,gFAAgF;YAChF,MAAMS,YAAYC,OAAOC,MAAM,CAACR,MAAMS,aAAa;YAEnDf,IAAI,CAACgB;gBACH,0DAA0D;gBAC1D,OAAOA,MAAMZ,WAAW,CAACD,aAAa;gBACtCa,MAAMX,eAAe,CAACY,MAAM,CAACV,SAAS;gBAEtC,sCAAsC;gBACtC,MAAMW,gBAAgBC,iBAAiBH,MAAMZ,WAAW;gBAExD,gHAAgH;gBAChH,mBAAmB;gBACnB,KAAK,MAAMgB,YAAYR,UAAW;oBAChC,IAAIM,cAAcG,GAAG,CAACD,WAAW;oBAEjC,OAAOJ,MAAMM,MAAM,CAACF,SAAS;gBAC/B;YACF;QACF;QAEAG,4BAA4B,CAACpB;YAC3B,MAAMqB,aAAavB,MAAMG,WAAW,CAACD,aAAa;YAClD,IAAIqB,eAAed,WAAW;gBAC5B,MAAM,IAAIC,MAAM,CAAC,oBAAoB,EAAER,aAAa,UAAU,CAAC;YACjE;YACAH,IAAI,CAACyB;gBACHA,MAAMC,sBAAsB,GAAG;oBAAEvB;oBAAcwB,gBAAgBH,WAAWI,KAAK;gBAAC;YAClF;QACF;QAEAC,6BAA6B,IAC3B7B,IAAI,CAACyB;gBACHA,MAAMC,sBAAsB,GAAGhB;YACjC;IACJ,CAAA,EAAG;AAEH,sFAAsF;AACtF,SAASS,iBAAiBf,WAA2C;IACnE,MAAMc,gBAAgB,IAAIY;IAC1B,KAAK,MAAMxB,SAASO,OAAOC,MAAM,CAACV,aAAc;QAC9C,KAAK,MAAMgB,YAAYP,OAAOC,MAAM,CAACR,MAAMS,aAAa,EAAG;YACzDG,cAAca,GAAG,CAACX;QACpB;IACF;IACA,OAAOF;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/DashboardProvider/delete-panel-slice.ts"],"sourcesContent":["// Copyright 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 { PanelGroupItemId } from '@perses-dev/core'
|
|
1
|
+
{"version":3,"sources":["../../../src/context/DashboardProvider/delete-panel-slice.ts"],"sourcesContent":["// Copyright 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 { PanelGroupItemId } from '@perses-dev/core'; // TODO\nimport { Middleware } from './common';\nimport { PanelGroupSlice } from './panel-group-slice';\nimport { PanelSlice } from './panel-slice';\n\n/**\n * Slice that handles the visual editor state and actions for deleting Panels.\n */\nexport interface DeletePanelSlice {\n /**\n * Delete panels\n */\n deletePanel: (panelGroupItemId: PanelGroupItemId) => void;\n\n /**\n * State for the delete panel dialog when it's open, otherwise undefined when it's closed.\n */\n deletePanelDialog?: DeletePanelDialogState;\n\n /**\n * Open delete panel dialog\n */\n openDeletePanelDialog: (panelGroupItemId: PanelGroupItemId) => void;\n\n /**\n * Close delete panel dialog\n */\n closeDeletePanelDialog: () => void;\n}\n\nexport interface DeletePanelDialogState {\n panelGroupItemId: PanelGroupItemId;\n panelName: string;\n panelGroupName: string;\n}\n\n/**\n * Curried function for creating the PanelDeleteSlice.\n */\nexport function createDeletePanelSlice(): StateCreator<\n // Actions in here need to modify both Panels and Panel Groups state\n DeletePanelSlice & PanelSlice & PanelGroupSlice,\n Middleware,\n [],\n DeletePanelSlice\n> {\n // Return the state creator function for Zustand that uses the panels provided as intitial state\n return (set, get) => ({\n deletePanel(panelGroupItemId: PanelGroupItemId): void {\n set((draft) => {\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const existingGroup = draft.panelGroups[panelGroupId];\n if (existingGroup === undefined) {\n throw new Error(`Missing panel group ${panelGroupId}`);\n }\n const existingLayoutIdx = existingGroup.itemLayouts.findIndex((layout) => layout.i === panelGroupLayoutId);\n const existingPanelKey = existingGroup.itemPanelKeys[panelGroupLayoutId];\n if (existingLayoutIdx === -1 || existingPanelKey === undefined) {\n throw new Error(`Missing panel group item ${panelGroupLayoutId}`);\n }\n\n // remove panel from panel group\n existingGroup.itemLayouts.splice(existingLayoutIdx, 1);\n delete existingGroup.itemPanelKeys[panelGroupLayoutId];\n\n // See if panel key is still used and if not, delete it\n if (isPanelKeyStillUsed(draft.panelGroups, existingPanelKey) === false) {\n delete draft.panels[existingPanelKey];\n }\n });\n },\n\n openDeletePanelDialog(panelGroupItemId: PanelGroupItemId): void {\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n\n const { panels, panelGroups } = get();\n const panelGroup = panelGroups[panelGroupId];\n if (panelGroup === undefined) {\n throw new Error(`Panel group not found ${panelGroupId}`);\n }\n\n const panelKey = panelGroup.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) {\n throw new Error(`Could not find Panel Group item ${panelGroupLayoutId}`);\n }\n\n const panel = panels[panelKey];\n if (panel === undefined) {\n throw new Error(`Could not find panel ${panelKey}`);\n }\n\n set((state) => {\n state.deletePanelDialog = {\n panelGroupItemId: panelGroupItemId,\n panelName: panel.spec.display?.name ?? panelKey,\n panelGroupName: panelGroup.title ?? '',\n };\n });\n },\n\n closeDeletePanelDialog(): void {\n set((state) => {\n state.deletePanelDialog = undefined;\n });\n },\n });\n}\n\n// Helper function to determine if a panel key is still being used somewhere in Panel Groups\nfunction isPanelKeyStillUsed(panelGroups: PanelGroupSlice['panelGroups'], panelKey: string): boolean {\n for (const group of Object.values(panelGroups)) {\n const found = Object.values(group.itemPanelKeys).find((key) => key === panelKey);\n if (found !== undefined) {\n return true;\n }\n }\n return false;\n}\n"],"names":["createDeletePanelSlice","set","get","deletePanel","panelGroupItemId","draft","panelGroupId","panelGroupItemLayoutId","panelGroupLayoutId","existingGroup","panelGroups","undefined","Error","existingLayoutIdx","itemLayouts","findIndex","layout","i","existingPanelKey","itemPanelKeys","splice","isPanelKeyStillUsed","panels","openDeletePanelDialog","panelGroup","panelKey","panel","state","deletePanelDialog","panelName","spec","display","name","panelGroupName","title","closeDeletePanelDialog","group","Object","values","found","find","key"],"mappings":"AAA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BAC5B,MAAM,IAAIC,MAAM,CAAC,sBAAsB,EAAEN,cAAc;gBACzD;gBAEA,MAAMmB,WAAWD,WAAWL,aAAa,CAACX,mBAAmB;gBAC7D,IAAIiB,aAAad,WAAW;oBAC1B,MAAM,IAAIC,MAAM,CAAC,gCAAgC,EAAEJ,oBAAoB;gBACzE;gBAEA,MAAMkB,QAAQJ,MAAM,CAACG,SAAS;gBAC9B,IAAIC,UAAUf,WAAW;oBACvB,MAAM,IAAIC,MAAM,CAAC,qBAAqB,EAAEa,UAAU;gBACpD;gBAEAxB,IAAI,CAAC0B;oBACHA,MAAMC,iBAAiB,GAAG;wBACxBxB,kBAAkBA;wBAClByB,WAAWH,MAAMI,IAAI,CAACC,OAAO,EAAEC,QAAQP;wBACvCQ,gBAAgBT,WAAWU,KAAK,IAAI;oBACtC;gBACF;YACF;YAEAC;gBACElC,IAAI,CAAC0B;oBACHA,MAAMC,iBAAiB,GAAGjB;gBAC5B;YACF;QACF,CAAA;AACF;AAEA,4FAA4F;AAC5F,SAASU,oBAAoBX,WAA2C,EAAEe,QAAgB;IACxF,KAAK,MAAMW,SAASC,OAAOC,MAAM,CAAC5B,aAAc;QAC9C,MAAM6B,QAAQF,OAAOC,MAAM,CAACF,MAAMjB,aAAa,EAAEqB,IAAI,CAAC,CAACC,MAAQA,QAAQhB;QACvE,IAAIc,UAAU5B,WAAW;YACvB,OAAO;QACT;IACF;IACA,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/DashboardProvider/duplicate-panel-slice.ts"],"sourcesContent":["// Copyright 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 { PanelGroupItemId } from '@perses-dev/core'
|
|
1
|
+
{"version":3,"sources":["../../../src/context/DashboardProvider/duplicate-panel-slice.ts"],"sourcesContent":["// Copyright 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 { PanelGroupItemId } from '@perses-dev/core'; // TODO\nimport { generatePanelKey, insertPanelInLayout, UnpositionedPanelGroupItemLayout } from '../../utils/panelUtils';\nimport { generateId, Middleware } from './common';\nimport { PanelGroupSlice } from './panel-group-slice';\nimport { PanelSlice } from './panel-slice';\n\n/**\n * Slice that handles duplicating Panels.\n */\nexport interface DuplicatePanelSlice {\n /**\n * Duplicate panel.\n */\n duplicatePanel: (panelGroupItemId: PanelGroupItemId) => void;\n}\n\n/**\n * Curried function for duplicating a panel.\n */\nexport function createDuplicatePanelSlice(): StateCreator<\n // Actions in here need to modify both Panels and Panel Groups state\n DuplicatePanelSlice & PanelSlice & PanelGroupSlice,\n Middleware,\n [],\n DuplicatePanelSlice\n> {\n return (set) => ({\n duplicatePanel(panelGroupItemId: PanelGroupItemId): void {\n set((state) => {\n const panels = state.panels;\n\n // Figure out the panel key at that location\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const group = state.panelGroups[panelGroupId];\n if (group === undefined) {\n throw new Error(`Missing panel group ${panelGroupId}`);\n }\n const panelKey = group.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 panelToDupe = panels[panelKey];\n if (panelToDupe === undefined) {\n throw new Error(`Cannot find Panel with key '${panelKey}'`);\n }\n\n // Find the layout for the item being duped\n const matchingLayout = group.itemLayouts.find((itemLayout) => {\n return itemLayout.i === panelGroupLayoutId;\n });\n\n if (matchingLayout === undefined) {\n throw new Error(`Cannot find layout for Panel with key '${panelKey}'`);\n }\n\n const dupePanelKey = generatePanelKey();\n\n state.panels[dupePanelKey] = panelToDupe;\n\n const duplicateLayout: UnpositionedPanelGroupItemLayout = {\n i: generateId().toString(),\n w: matchingLayout.w,\n h: matchingLayout.h,\n };\n\n group.itemLayouts = insertPanelInLayout(duplicateLayout, matchingLayout, group.itemLayouts);\n\n group.itemPanelKeys[duplicateLayout.i] = dupePanelKey;\n });\n },\n });\n}\n"],"names":["generatePanelKey","insertPanelInLayout","generateId","createDuplicatePanelSlice","set","duplicatePanel","panelGroupItemId","state","panels","panelGroupId","panelGroupItemLayoutId","panelGroupLayoutId","group","panelGroups","undefined","Error","panelKey","itemPanelKeys","panelToDupe","matchingLayout","itemLayouts","find","itemLayout","i","dupePanelKey","duplicateLayout","toString","w","h"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,SAASA,gBAAgB,EAAEC,mBAAmB,QAA0C,yBAAyB;AACjH,SAASC,UAAU,QAAoB,WAAW;AAclD;;CAEC,GACD,OAAO,SAASC;IAOd,OAAO,CAACC,MAAS,CAAA;YACfC,gBAAeC,gBAAkC;gBAC/CF,IAAI,CAACG;oBACH,MAAMC,SAASD,MAAMC,MAAM;oBAE3B,4CAA4C;oBAC5C,MAAM,EAAEC,YAAY,EAAEC,wBAAwBC,kBAAkB,EAAE,GAAGL;oBACrE,MAAMM,QAAQL,MAAMM,WAAW,CAACJ,aAAa;oBAC7C,IAAIG,UAAUE,WAAW;wBACvB,MAAM,IAAIC,MAAM,CAAC,oBAAoB,EAAEN,cAAc;oBACvD;oBACA,MAAMO,WAAWJ,MAAMK,aAAa,CAACN,mBAAmB;oBACxD,IAAIK,aAAaF,WAAW;wBAC1B,MAAM,IAAIC,MAAM,CAAC,gCAAgC,EAAET,kBAAkB;oBACvE;oBAEA,yBAAyB;oBACzB,MAAMY,cAAcV,MAAM,CAACQ,SAAS;oBACpC,IAAIE,gBAAgBJ,WAAW;wBAC7B,MAAM,IAAIC,MAAM,CAAC,4BAA4B,EAAEC,SAAS,CAAC,CAAC;oBAC5D;oBAEA,2CAA2C;oBAC3C,MAAMG,iBAAiBP,MAAMQ,WAAW,CAACC,IAAI,CAAC,CAACC;wBAC7C,OAAOA,WAAWC,CAAC,KAAKZ;oBAC1B;oBAEA,IAAIQ,mBAAmBL,WAAW;wBAChC,MAAM,IAAIC,MAAM,CAAC,uCAAuC,EAAEC,SAAS,CAAC,CAAC;oBACvE;oBAEA,MAAMQ,eAAexB;oBAErBO,MAAMC,MAAM,CAACgB,aAAa,GAAGN;oBAE7B,MAAMO,kBAAoD;wBACxDF,GAAGrB,aAAawB,QAAQ;wBACxBC,GAAGR,eAAeQ,CAAC;wBACnBC,GAAGT,eAAeS,CAAC;oBACrB;oBAEAhB,MAAMQ,WAAW,GAAGnB,oBAAoBwB,iBAAiBN,gBAAgBP,MAAMQ,WAAW;oBAE1FR,MAAMK,aAAa,CAACQ,gBAAgBF,CAAC,CAAC,GAAGC;gBAC3C;YACF;QACF,CAAA;AACF"}
|
|
@@ -4,4 +4,6 @@ export * from './DashboardProvider';
|
|
|
4
4
|
export type { PanelGroupEditor, PanelGroupEditorValues } from './panel-group-editor-slice';
|
|
5
5
|
export type { DeletePanelDialogState } from './delete-panel-slice';
|
|
6
6
|
export type { DiscardChangesConfirmationDialogState } from './discard-changes-dialog-slice';
|
|
7
|
+
export { useSaveDashboard } from './use-save-dashboard';
|
|
8
|
+
export type { SaveDashboardResult } from './use-save-dashboard';
|
|
7
9
|
//# 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,UAAU,CAAC;AACzB,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,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"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/index.ts"],"names":[],"mappings":"AAaA,cAAc,UAAU,CAAC;AACzB,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,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,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/DashboardProvider/index.ts"],"sourcesContent":["// Copyright 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 './common';\nexport * from './dashboard-provider-api';\nexport * from './DashboardProvider';\nexport type { PanelGroupEditor, PanelGroupEditorValues } from './panel-group-editor-slice';\nexport type { DeletePanelDialogState } from './delete-panel-slice';\nexport type { DiscardChangesConfirmationDialogState } from './discard-changes-dialog-slice';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,WAAW;AACzB,cAAc,2BAA2B;AACzC,cAAc,sBAAsB"}
|
|
1
|
+
{"version":3,"sources":["../../../src/context/DashboardProvider/index.ts"],"sourcesContent":["// Copyright 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 './common';\nexport * from './dashboard-provider-api';\nexport * from './DashboardProvider';\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 { useSaveDashboard } from './use-save-dashboard';\nexport type { SaveDashboardResult } from './use-save-dashboard';\n"],"names":["useSaveDashboard"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,WAAW;AACzB,cAAc,2BAA2B;AACzC,cAAc,sBAAsB;AAIpC,SAASA,gBAAgB,QAAQ,uBAAuB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Link } from '@perses-dev/spec';
|
|
2
|
+
import { StateCreator } from 'zustand';
|
|
3
|
+
import { Middleware } from './common';
|
|
4
|
+
/**
|
|
5
|
+
* Slice that handles the state and actions for Dashboard Links.
|
|
6
|
+
*/
|
|
7
|
+
export interface LinksSlice {
|
|
8
|
+
links?: Link[];
|
|
9
|
+
/**
|
|
10
|
+
* Replaces all links with the provided array.
|
|
11
|
+
*/
|
|
12
|
+
setLinks: (links: Link[]) => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Creates a slice for managing dashboard links state.
|
|
16
|
+
* @param initLinks - Initial links array from the dashboard spec.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createLinksSlice(initLinks?: Link[]): StateCreator<LinksSlice, Middleware, [], LinksSlice>;
|
|
19
|
+
//# sourceMappingURL=links-slice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"links-slice.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/links-slice.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf;;OAEG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;CACnC;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,YAAY,CAAC,UAAU,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,CAAC,CASzG"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
/**
|
|
14
|
+
* Creates a slice for managing dashboard links state.
|
|
15
|
+
* @param initLinks - Initial links array from the dashboard spec.
|
|
16
|
+
*/ export function createLinksSlice(initLinks) {
|
|
17
|
+
return (set)=>({
|
|
18
|
+
links: initLinks,
|
|
19
|
+
setLinks: (links)=>{
|
|
20
|
+
set((state)=>{
|
|
21
|
+
state.links = links;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=links-slice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/context/DashboardProvider/links-slice.ts"],"sourcesContent":["// Copyright 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 { Link } from '@perses-dev/spec';\nimport { StateCreator } from 'zustand';\nimport { Middleware } from './common';\n\n/**\n * Slice that handles the state and actions for Dashboard Links.\n */\nexport interface LinksSlice {\n links?: Link[];\n /**\n * Replaces all links with the provided array.\n */\n setLinks: (links: Link[]) => void;\n}\n\n/**\n * Creates a slice for managing dashboard links state.\n * @param initLinks - Initial links array from the dashboard spec.\n */\nexport function createLinksSlice(initLinks?: Link[]): StateCreator<LinksSlice, Middleware, [], LinksSlice> {\n return (set) => ({\n links: initLinks,\n setLinks: (links: Link[]): void => {\n set((state) => {\n state.links = links;\n });\n },\n });\n}\n"],"names":["createLinksSlice","initLinks","set","links","setLinks","state"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAiBjC;;;CAGC,GACD,OAAO,SAASA,iBAAiBC,SAAkB;IACjD,OAAO,CAACC,MAAS,CAAA;YACfC,OAAOF;YACPG,UAAU,CAACD;gBACTD,IAAI,CAACG;oBACHA,MAAMF,KAAK,GAAGA;gBAChB;YACF;QACF,CAAA;AACF"}
|