@perses-dev/dashboards 0.54.0-beta.1 → 0.54.0-beta.11
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/Annotations/AnnotationsEditor.js +302 -0
- package/dist/cjs/components/Annotations/EditAnnotationsButton.js +83 -0
- package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +4 -2
- package/dist/cjs/components/GridLayout/GridItemContent.js +2 -9
- package/dist/cjs/components/Panel/Panel.js +4 -1
- package/dist/cjs/components/PanelDrawer/PanelQueriesSharedControls.js +3 -16
- package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +20 -3
- package/dist/cjs/components/Variables/VariableEditor.js +52 -18
- package/dist/cjs/constants/user-interface-text.js +1 -0
- package/dist/cjs/context/AnnotationProvider/AnnotationHydrationWrapper.js +50 -0
- package/dist/cjs/context/AnnotationProvider/AnnotationProvider.js +145 -0
- package/dist/{model/DashboardResource.js → cjs/context/AnnotationProvider/index.js} +18 -6
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +9 -2
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +14 -11
- package/dist/cjs/context/DashboardProvider/use-save-dashboard.js +12 -4
- package/dist/cjs/context/DatasourceStoreProvider.js +38 -5
- package/dist/cjs/context/VariableProvider/VariableProvider.js +11 -6
- package/dist/cjs/context/index.js +1 -0
- package/dist/cjs/context/useDashboard.js +11 -1
- package/dist/cjs/model/index.js +1 -1
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +9 -1
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +30 -25
- package/dist/components/AddGroupButton/AddGroupButton.js +1 -1
- package/dist/components/AddGroupButton/AddGroupButton.js.map +1 -1
- package/dist/components/AddPanelButton/AddPanelButton.js +1 -1
- package/dist/components/AddPanelButton/AddPanelButton.js.map +1 -1
- package/dist/components/Annotations/AnnotationsEditor.d.ts +8 -0
- package/dist/components/Annotations/AnnotationsEditor.d.ts.map +1 -0
- package/dist/components/Annotations/AnnotationsEditor.js +289 -0
- package/dist/components/Annotations/AnnotationsEditor.js.map +1 -0
- package/dist/components/Annotations/EditAnnotationsButton.d.ts +18 -0
- package/dist/components/Annotations/EditAnnotationsButton.d.ts.map +1 -0
- package/dist/components/Annotations/EditAnnotationsButton.js +70 -0
- package/dist/components/Annotations/EditAnnotationsButton.js.map +1 -0
- package/dist/components/Dashboard/Dashboard.js +1 -1
- package/dist/components/Dashboard/Dashboard.js.map +1 -1
- package/dist/components/DashboardLinks/DashboardLinksEditor.js +1 -1
- package/dist/components/DashboardLinks/DashboardLinksEditor.js.map +1 -1
- package/dist/components/DashboardLinks/EditDashboardLinksButton.js +1 -1
- package/dist/components/DashboardLinks/EditDashboardLinksButton.js.map +1 -1
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +1 -1
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +2 -0
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js +5 -3
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/Datasources/DatasourceEditor.d.ts.map +1 -1
- package/dist/components/Datasources/DatasourceEditor.js +1 -1
- package/dist/components/Datasources/DatasourceEditor.js.map +1 -1
- package/dist/components/Datasources/EditDatasourcesButton.js +1 -1
- package/dist/components/Datasources/EditDatasourcesButton.js.map +1 -1
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +1 -1
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -1
- package/dist/components/DownloadButton/DownloadButton.js +1 -1
- package/dist/components/DownloadButton/DownloadButton.js.map +1 -1
- package/dist/components/DownloadButton/serializeDashboard.d.ts +1 -1
- package/dist/components/DownloadButton/serializeDashboard.d.ts.map +1 -1
- package/dist/components/DownloadButton/serializeDashboard.js.map +1 -1
- package/dist/components/EditButton/EditButton.js +1 -1
- package/dist/components/EditButton/EditButton.js.map +1 -1
- package/dist/components/EditJsonButton/EditJsonButton.js +1 -1
- package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.js +1 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
- package/dist/components/EmptyDashboard/EmptyDashboard.js +1 -1
- package/dist/components/EmptyDashboard/EmptyDashboard.js.map +1 -1
- package/dist/components/GridLayout/GridContainer.js +1 -1
- package/dist/components/GridLayout/GridContainer.js.map +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +3 -10
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +1 -1
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.js +1 -1
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- package/dist/components/GridLayout/Row.js +1 -1
- package/dist/components/GridLayout/Row.js.map +1 -1
- package/dist/components/LeaveDialog/LeaveDialog.d.ts +1 -1
- package/dist/components/LeaveDialog/LeaveDialog.d.ts.map +1 -1
- package/dist/components/LeaveDialog/LeaveDialog.js +1 -1
- package/dist/components/LeaveDialog/LeaveDialog.js.map +1 -1
- package/dist/components/LinksDisplay/LinksDisplay.js +1 -1
- package/dist/components/LinksDisplay/LinksDisplay.js.map +1 -1
- package/dist/components/Panel/Panel.js +5 -2
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/PanelActions.js +1 -1
- package/dist/components/Panel/PanelActions.js.map +1 -1
- package/dist/components/Panel/PanelContent.js +1 -1
- package/dist/components/Panel/PanelContent.js.map +1 -1
- package/dist/components/Panel/PanelHeader.js +1 -1
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- package/dist/components/Panel/PanelPluginLoader.js +1 -1
- package/dist/components/Panel/PanelPluginLoader.js.map +1 -1
- package/dist/components/Panel/useSelectionItemActions.js +1 -1
- package/dist/components/Panel/useSelectionItemActions.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/PanelDrawer/PanelQueriesSharedControls.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelQueriesSharedControls.js +5 -18
- package/dist/components/PanelDrawer/PanelQueriesSharedControls.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -1
- package/dist/components/QuerySummaryTable/QuerySummaryTable.js +1 -1
- package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -1
- package/dist/components/QueryViewerDialog/QueryViewerDialog.js +1 -1
- package/dist/components/QueryViewerDialog/QueryViewerDialog.js.map +1 -1
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -1
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +22 -5
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
- package/dist/components/Variables/EditVariablesButton.js +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.js +2 -2
- package/dist/components/Variables/Variable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditor.js +57 -23
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableList.js +1 -1
- package/dist/components/Variables/VariableList.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/AnnotationProvider/AnnotationHydrationWrapper.d.ts +7 -0
- package/dist/context/AnnotationProvider/AnnotationHydrationWrapper.d.ts.map +1 -0
- package/dist/context/AnnotationProvider/AnnotationHydrationWrapper.js +48 -0
- package/dist/context/AnnotationProvider/AnnotationHydrationWrapper.js.map +1 -0
- package/dist/context/AnnotationProvider/AnnotationProvider.d.ts +40 -0
- package/dist/context/AnnotationProvider/AnnotationProvider.d.ts.map +1 -0
- package/dist/context/AnnotationProvider/AnnotationProvider.js +114 -0
- package/dist/context/AnnotationProvider/AnnotationProvider.js.map +1 -0
- package/dist/context/AnnotationProvider/index.d.ts +2 -0
- package/dist/context/AnnotationProvider/index.d.ts.map +1 -0
- package/dist/{cjs/model/DashboardResource.js → context/AnnotationProvider/index.js} +3 -4
- package/dist/context/AnnotationProvider/index.js.map +1 -0
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +4 -2
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +10 -3
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/common.d.ts +1 -1
- 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 +2 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts +1 -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-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.js +14 -11
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
- package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts +8 -1
- package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -1
- package/dist/context/DashboardProvider/use-save-dashboard.d.ts.map +1 -1
- package/dist/context/DashboardProvider/use-save-dashboard.js +13 -5
- package/dist/context/DashboardProvider/use-save-dashboard.js.map +1 -1
- package/dist/context/DatasourceStoreProvider.d.ts +1 -2
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
- package/dist/context/DatasourceStoreProvider.js +40 -7
- package/dist/context/DatasourceStoreProvider.js.map +1 -1
- package/dist/context/PanelEditorProvider/PanelEditorProvider.js +1 -1
- package/dist/context/PanelEditorProvider/PanelEditorProvider.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 +13 -8
- package/dist/context/VariableProvider/VariableProvider.js.map +1 -1
- package/dist/context/index.d.ts +1 -0
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +1 -0
- package/dist/context/index.js.map +1 -1
- package/dist/context/useDashboard.d.ts +1 -1
- package/dist/context/useDashboard.d.ts.map +1 -1
- package/dist/context/useDashboard.js +11 -1
- package/dist/context/useDashboard.js.map +1 -1
- package/dist/keyboard-shortcuts/PanelFocusProvider.js +1 -1
- package/dist/keyboard-shortcuts/PanelFocusProvider.js.map +1 -1
- package/dist/model/index.d.ts +1 -1
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +1 -1
- package/dist/model/index.js.map +1 -1
- 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.d.ts +1 -1
- package/dist/test/datasource-provider.d.ts.map +1 -1
- package/dist/test/datasource-provider.js.map +1 -1
- package/dist/test/render.js +1 -1
- package/dist/test/render.js.map +1 -1
- package/dist/test/testDashboard.d.ts +1 -1
- package/dist/test/testDashboard.d.ts.map +1 -1
- package/dist/test/testDashboard.js.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.d.ts +3 -1
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +11 -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 +32 -27
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/package.json +9 -10
- package/dist/model/DashboardResource.d.ts +0 -15
- package/dist/model/DashboardResource.d.ts.map +0 -1
- package/dist/model/DashboardResource.js.map +0 -1
|
@@ -30,7 +30,7 @@ const _context = require("../../context");
|
|
|
30
30
|
const _DashboardProviderWithQueryParams = require("../../context/DashboardProvider/DashboardProviderWithQueryParams");
|
|
31
31
|
const _DashboardApp = require("./DashboardApp");
|
|
32
32
|
function ViewDashboard(props) {
|
|
33
|
-
const { dashboardResource, datasourceApi, externalVariableDefinitions, emptyDashboardProps, isReadonly, isVariableEnabled, isDatasourceEnabled, disableShortcuts, isEditing, isCreating, isInitialVariableSticky, isLeavingConfirmDialogEnabled, dashboardTitleComponent, onSave, onDiscard, sx, ...others } = props;
|
|
33
|
+
const { dashboardResource, datasourceApi, externalVariableDefinitions, emptyDashboardProps, isReadonly, isVariableEnabled, isAnnotationEnabled, isDatasourceEnabled, disableShortcuts, isEditing, isCreating, isInitialVariableSticky, isLeavingConfirmDialogEnabled, dashboardTitleComponent, onSave, onDiscard, sx, userPreferenceTimezone, ...others } = props;
|
|
34
34
|
const { spec } = dashboardResource;
|
|
35
35
|
const dashboardDuration = spec.duration ?? _constants.DEFAULT_DASHBOARD_DURATION;
|
|
36
36
|
const dashboardRefreshInterval = spec.refreshInterval ?? _constants.DEFAULT_REFRESH_INTERVAL;
|
|
@@ -90,30 +90,35 @@ function ViewDashboard(props) {
|
|
|
90
90
|
initialVariableDefinitions: spec.variables,
|
|
91
91
|
externalVariableDefinitions: externalVariableDefinitions,
|
|
92
92
|
builtinVariableDefinitions: builtinVariables,
|
|
93
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
93
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_context.AnnotationProvider, {
|
|
94
|
+
initialAnnotationSpecs: spec.annotations ?? [],
|
|
95
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
96
|
+
sx: (0, _components.combineSx)({
|
|
97
|
+
display: 'flex',
|
|
98
|
+
width: '100%',
|
|
99
|
+
height: '100%',
|
|
100
|
+
position: 'relative',
|
|
101
|
+
overflow: 'hidden'
|
|
102
|
+
}, sx),
|
|
103
|
+
...others,
|
|
104
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
|
|
105
|
+
FallbackComponent: _components.ErrorAlert,
|
|
106
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_DashboardApp.DashboardApp, {
|
|
107
|
+
dashboardResource: dashboardResource,
|
|
108
|
+
emptyDashboardProps: emptyDashboardProps,
|
|
109
|
+
isReadonly: isReadonly,
|
|
110
|
+
isVariableEnabled: isVariableEnabled,
|
|
111
|
+
isAnnotationEnabled: isAnnotationEnabled,
|
|
112
|
+
isDatasourceEnabled: isDatasourceEnabled,
|
|
113
|
+
disableShortcuts: disableShortcuts,
|
|
114
|
+
isCreating: isCreating,
|
|
115
|
+
isInitialVariableSticky: isInitialVariableSticky,
|
|
116
|
+
isLeavingConfirmDialogEnabled: isLeavingConfirmDialogEnabled,
|
|
117
|
+
dashboardTitleComponent: dashboardTitleComponent,
|
|
118
|
+
onSave: onSave,
|
|
119
|
+
onDiscard: onDiscard,
|
|
120
|
+
userPreferenceTimezone: userPreferenceTimezone
|
|
121
|
+
})
|
|
117
122
|
})
|
|
118
123
|
})
|
|
119
124
|
})
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
// Copyright The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { Button } from '@mui/material';
|
|
15
15
|
import AddGroupIcon from 'mdi-material-ui/PlusBoxOutline';
|
|
16
16
|
import { InfoTooltip } from '@perses-dev/components';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/AddGroupButton/AddGroupButton.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 { Button } from '@mui/material';\nimport AddGroupIcon from 'mdi-material-ui/PlusBoxOutline';\nimport { InfoTooltip } from '@perses-dev/components';\nimport { ReactElement } from 'react';\nimport { TOOLTIP_TEXT, editButtonStyle } from '../../constants';\nimport { useDashboardActions } from '../../context';\n\nexport const AddGroupButton = (): ReactElement => {\n const { openAddPanelGroup } = useDashboardActions();\n\n return (\n <InfoTooltip description={TOOLTIP_TEXT.addGroup}>\n <Button\n startIcon={<AddGroupIcon />}\n onClick={openAddPanelGroup}\n aria-label={TOOLTIP_TEXT.addGroup}\n sx={editButtonStyle}\n >\n Panel Group\n </Button>\n </InfoTooltip>\n );\n};\n"],"names":["Button","AddGroupIcon","InfoTooltip","TOOLTIP_TEXT","editButtonStyle","useDashboardActions","AddGroupButton","openAddPanelGroup","description","addGroup","startIcon","onClick","aria-label","sx"],"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
|
|
1
|
+
{"version":3,"sources":["../../../src/components/AddGroupButton/AddGroupButton.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 { Button } from '@mui/material';\nimport AddGroupIcon from 'mdi-material-ui/PlusBoxOutline';\nimport { InfoTooltip } from '@perses-dev/components';\nimport { ReactElement } from 'react';\nimport { TOOLTIP_TEXT, editButtonStyle } from '../../constants';\nimport { useDashboardActions } from '../../context';\n\nexport const AddGroupButton = (): ReactElement => {\n const { openAddPanelGroup } = useDashboardActions();\n\n return (\n <InfoTooltip description={TOOLTIP_TEXT.addGroup}>\n <Button\n startIcon={<AddGroupIcon />}\n onClick={openAddPanelGroup}\n aria-label={TOOLTIP_TEXT.addGroup}\n sx={editButtonStyle}\n >\n Panel Group\n </Button>\n </InfoTooltip>\n );\n};\n"],"names":["Button","AddGroupIcon","InfoTooltip","TOOLTIP_TEXT","editButtonStyle","useDashboardActions","AddGroupButton","openAddPanelGroup","description","addGroup","startIcon","onClick","aria-label","sx"],"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,MAAM,QAAQ,gBAAgB;AACvC,OAAOC,kBAAkB,iCAAiC;AAC1D,SAASC,WAAW,QAAQ,yBAAyB;AAErD,SAASC,YAAY,EAAEC,eAAe,QAAQ,kBAAkB;AAChE,SAASC,mBAAmB,QAAQ,gBAAgB;AAEpD,OAAO,MAAMC,iBAAiB;IAC5B,MAAM,EAAEC,iBAAiB,EAAE,GAAGF;IAE9B,qBACE,KAACH;QAAYM,aAAaL,aAAaM,QAAQ;kBAC7C,cAAA,KAACT;YACCU,yBAAW,KAACT;YACZU,SAASJ;YACTK,cAAYT,aAAaM,QAAQ;YACjCI,IAAIT;sBACL;;;AAKP,EAAE"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
// Copyright The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { Button } from '@mui/material';
|
|
15
15
|
import AddPanelIcon from 'mdi-material-ui/ChartBoxPlusOutline';
|
|
16
16
|
import { InfoTooltip } from '@perses-dev/components';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/AddPanelButton/AddPanelButton.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 { Button, ButtonProps } from '@mui/material';\nimport AddPanelIcon from 'mdi-material-ui/ChartBoxPlusOutline';\nimport { InfoTooltip } from '@perses-dev/components';\nimport { ReactElement } from 'react';\nimport { TOOLTIP_TEXT, editButtonStyle } from '../../constants';\nimport { useDashboardActions } from '../../context';\n\nexport interface AddPanelButtonProps extends Pick<ButtonProps, 'fullWidth'> {\n /**\n * The variant to use to display the button.\n */\n variant?: 'text' | 'outlined';\n\n /**\n * The color to use to display the button.\n */\n color?: 'primary' | 'secondary';\n\n /**\n * The label used inside the button.\n */\n label?: string;\n}\n\nexport const AddPanelButton = ({\n variant = 'text',\n color = 'primary',\n label = 'Panel',\n fullWidth,\n}: AddPanelButtonProps): ReactElement => {\n const { openAddPanel } = useDashboardActions();\n\n return (\n <InfoTooltip description={TOOLTIP_TEXT.addPanel}>\n <Button\n startIcon={<AddPanelIcon />}\n onClick={openAddPanel}\n aria-label={TOOLTIP_TEXT.addPanel}\n variant={variant}\n color={color}\n fullWidth={fullWidth}\n sx={editButtonStyle}\n >\n {label}\n </Button>\n </InfoTooltip>\n );\n};\n"],"names":["Button","AddPanelIcon","InfoTooltip","TOOLTIP_TEXT","editButtonStyle","useDashboardActions","AddPanelButton","variant","color","label","fullWidth","openAddPanel","description","addPanel","startIcon","onClick","aria-label","sx"],"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
|
|
1
|
+
{"version":3,"sources":["../../../src/components/AddPanelButton/AddPanelButton.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 { Button, ButtonProps } from '@mui/material';\nimport AddPanelIcon from 'mdi-material-ui/ChartBoxPlusOutline';\nimport { InfoTooltip } from '@perses-dev/components';\nimport { ReactElement } from 'react';\nimport { TOOLTIP_TEXT, editButtonStyle } from '../../constants';\nimport { useDashboardActions } from '../../context';\n\nexport interface AddPanelButtonProps extends Pick<ButtonProps, 'fullWidth'> {\n /**\n * The variant to use to display the button.\n */\n variant?: 'text' | 'outlined';\n\n /**\n * The color to use to display the button.\n */\n color?: 'primary' | 'secondary';\n\n /**\n * The label used inside the button.\n */\n label?: string;\n}\n\nexport const AddPanelButton = ({\n variant = 'text',\n color = 'primary',\n label = 'Panel',\n fullWidth,\n}: AddPanelButtonProps): ReactElement => {\n const { openAddPanel } = useDashboardActions();\n\n return (\n <InfoTooltip description={TOOLTIP_TEXT.addPanel}>\n <Button\n startIcon={<AddPanelIcon />}\n onClick={openAddPanel}\n aria-label={TOOLTIP_TEXT.addPanel}\n variant={variant}\n color={color}\n fullWidth={fullWidth}\n sx={editButtonStyle}\n >\n {label}\n </Button>\n </InfoTooltip>\n );\n};\n"],"names":["Button","AddPanelIcon","InfoTooltip","TOOLTIP_TEXT","editButtonStyle","useDashboardActions","AddPanelButton","variant","color","label","fullWidth","openAddPanel","description","addPanel","startIcon","onClick","aria-label","sx"],"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,MAAM,QAAqB,gBAAgB;AACpD,OAAOC,kBAAkB,sCAAsC;AAC/D,SAASC,WAAW,QAAQ,yBAAyB;AAErD,SAASC,YAAY,EAAEC,eAAe,QAAQ,kBAAkB;AAChE,SAASC,mBAAmB,QAAQ,gBAAgB;AAmBpD,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,UAAU,MAAM,EAChBC,QAAQ,SAAS,EACjBC,QAAQ,OAAO,EACfC,SAAS,EACW;IACpB,MAAM,EAAEC,YAAY,EAAE,GAAGN;IAEzB,qBACE,KAACH;QAAYU,aAAaT,aAAaU,QAAQ;kBAC7C,cAAA,KAACb;YACCc,yBAAW,KAACb;YACZc,SAASJ;YACTK,cAAYb,aAAaU,QAAQ;YACjCN,SAASA;YACTC,OAAOA;YACPE,WAAWA;YACXO,IAAIb;sBAEHK;;;AAIT,EAAE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { AnnotationSpec } from '@perses-dev/spec';
|
|
3
|
+
export declare function AnnotationEditor(props: {
|
|
4
|
+
annotationSpecs: AnnotationSpec[];
|
|
5
|
+
onChange: (annotationSpecs: AnnotationSpec[]) => void;
|
|
6
|
+
onCancel: () => void;
|
|
7
|
+
}): ReactElement;
|
|
8
|
+
//# sourceMappingURL=AnnotationsEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnnotationsEditor.d.ts","sourceRoot":"","sources":["../../../src/components/Annotations/AnnotationsEditor.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAqB,YAAY,EAAE,MAAM,OAAO,CAAC;AAkBxD,OAAO,EAAE,cAAc,EAA2B,MAAM,kBAAkB,CAAC;AA8B3E,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,QAAQ,EAAE,CAAC,eAAe,EAAE,cAAc,EAAE,KAAK,IAAI,CAAC;IACtD,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB,GAAG,YAAY,CAyMf"}
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
// Copyright The Perses Authors
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
import { useState, useMemo } from 'react';
|
|
15
|
+
import { Button, Stack, Box, TableContainer, TableBody, TableRow, TableCell as MuiTableCell, Table, TableHead, Switch, Typography, IconButton, Alert, styled } from '@mui/material';
|
|
16
|
+
import AddIcon from 'mdi-material-ui/Plus';
|
|
17
|
+
import { useImmer } from 'use-immer';
|
|
18
|
+
import PencilIcon from 'mdi-material-ui/Pencil';
|
|
19
|
+
import TrashIcon from 'mdi-material-ui/TrashCan';
|
|
20
|
+
import ArrowUp from 'mdi-material-ui/ArrowUp';
|
|
21
|
+
import ArrowDown from 'mdi-material-ui/ArrowDown';
|
|
22
|
+
import { ValidationProvider, AnnotationEditorForm } from '@perses-dev/plugin-system';
|
|
23
|
+
import { useDiscardChangesConfirmationDialog } from '../../context';
|
|
24
|
+
function validateAnnotationSpecs(annotationSpecs) {
|
|
25
|
+
const errors = [];
|
|
26
|
+
const annotationNames = [];
|
|
27
|
+
for (const annotationSpec of annotationSpecs){
|
|
28
|
+
if (annotationNames.includes(annotationSpec.display.name)) {
|
|
29
|
+
errors.push(`Duplicate annotation name: ${annotationSpec.display.name}`);
|
|
30
|
+
} else {
|
|
31
|
+
annotationNames.push(annotationSpec.display.name);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
errors: errors,
|
|
36
|
+
isValid: errors.length === 0
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export function AnnotationEditor(props) {
|
|
40
|
+
const [annotationSpecs, setAnnotationSpecs] = useImmer(props.annotationSpecs);
|
|
41
|
+
const [annotationEditIdx, setAnnotationEditIdx] = useState(null);
|
|
42
|
+
const [annotationFormAction, setAnnotationFormAction] = useState('update');
|
|
43
|
+
const validation = useMemo(()=>validateAnnotationSpecs(annotationSpecs), [
|
|
44
|
+
annotationSpecs
|
|
45
|
+
]);
|
|
46
|
+
const currentEditingAnnotationSpec = annotationEditIdx !== null ? annotationSpecs[annotationEditIdx] : undefined;
|
|
47
|
+
const { openDiscardChangesConfirmationDialog, closeDiscardChangesConfirmationDialog } = useDiscardChangesConfirmationDialog();
|
|
48
|
+
const handleCancel = ()=>{
|
|
49
|
+
if (JSON.stringify(props.annotationSpecs) !== JSON.stringify(annotationSpecs)) {
|
|
50
|
+
openDiscardChangesConfirmationDialog({
|
|
51
|
+
onDiscardChanges: ()=>{
|
|
52
|
+
closeDiscardChangesConfirmationDialog();
|
|
53
|
+
props.onCancel();
|
|
54
|
+
},
|
|
55
|
+
onCancel: ()=>{
|
|
56
|
+
closeDiscardChangesConfirmationDialog();
|
|
57
|
+
},
|
|
58
|
+
description: 'You have unapplied changes. Are you sure you want to discard these changes? Changes cannot be recovered.'
|
|
59
|
+
});
|
|
60
|
+
} else {
|
|
61
|
+
props.onCancel();
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const removeAnnotation = (index)=>{
|
|
65
|
+
setAnnotationSpecs((draft)=>{
|
|
66
|
+
draft.splice(index, 1);
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
const addAnnotation = ()=>{
|
|
70
|
+
setAnnotationFormAction('create');
|
|
71
|
+
setAnnotationSpecs((draft)=>{
|
|
72
|
+
draft.push({
|
|
73
|
+
display: {
|
|
74
|
+
name: 'NewAnnotation'
|
|
75
|
+
},
|
|
76
|
+
plugin: {}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
setAnnotationEditIdx(annotationSpecs.length);
|
|
80
|
+
};
|
|
81
|
+
const editAnnotation = (index)=>{
|
|
82
|
+
setAnnotationFormAction('update');
|
|
83
|
+
setAnnotationEditIdx(index);
|
|
84
|
+
};
|
|
85
|
+
const toggleAnnotationVisibility = (index, visible)=>{
|
|
86
|
+
setAnnotationSpecs((draft)=>{
|
|
87
|
+
const v = draft[index];
|
|
88
|
+
if (!v) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
v.display.hidden = !visible;
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
const changeAnnotationOrder = (index, direction)=>{
|
|
95
|
+
const step = direction === 'up' ? -1 : 1;
|
|
96
|
+
setAnnotationSpecs((draft)=>{
|
|
97
|
+
const current = draft[index];
|
|
98
|
+
const adjacent = draft[index + step];
|
|
99
|
+
if (!current || !adjacent) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
draft[index + step] = current;
|
|
103
|
+
draft[index] = adjacent;
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
return /*#__PURE__*/ _jsx(_Fragment, {
|
|
107
|
+
children: annotationEditIdx !== null && currentEditingAnnotationSpec ? /*#__PURE__*/ _jsx(ValidationProvider, {
|
|
108
|
+
children: /*#__PURE__*/ _jsx(AnnotationEditorForm, {
|
|
109
|
+
initialAnnotationSpec: currentEditingAnnotationSpec,
|
|
110
|
+
action: annotationFormAction,
|
|
111
|
+
isDraft: true,
|
|
112
|
+
onActionChange: setAnnotationFormAction,
|
|
113
|
+
onSave: (definition)=>{
|
|
114
|
+
setAnnotationSpecs((draft)=>{
|
|
115
|
+
draft[annotationEditIdx] = definition;
|
|
116
|
+
setAnnotationEditIdx(null);
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
onClose: ()=>{
|
|
120
|
+
if (annotationFormAction === 'create') {
|
|
121
|
+
removeAnnotation(annotationEditIdx);
|
|
122
|
+
}
|
|
123
|
+
setAnnotationEditIdx(null);
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
}) : /*#__PURE__*/ _jsxs(_Fragment, {
|
|
127
|
+
children: [
|
|
128
|
+
/*#__PURE__*/ _jsxs(Box, {
|
|
129
|
+
sx: {
|
|
130
|
+
display: 'flex',
|
|
131
|
+
alignItems: 'center',
|
|
132
|
+
padding: (theme)=>theme.spacing(1, 2),
|
|
133
|
+
borderBottom: (theme)=>`1px solid ${theme.palette.divider}`
|
|
134
|
+
},
|
|
135
|
+
children: [
|
|
136
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
137
|
+
variant: "h2",
|
|
138
|
+
children: "Edit Dashboard Annotations"
|
|
139
|
+
}),
|
|
140
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
141
|
+
direction: "row",
|
|
142
|
+
spacing: 1,
|
|
143
|
+
marginLeft: "auto",
|
|
144
|
+
children: [
|
|
145
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
146
|
+
disabled: props.annotationSpecs === annotationSpecs || !validation.isValid,
|
|
147
|
+
variant: "contained",
|
|
148
|
+
onClick: ()=>{
|
|
149
|
+
props.onChange(annotationSpecs);
|
|
150
|
+
},
|
|
151
|
+
children: "Apply"
|
|
152
|
+
}),
|
|
153
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
154
|
+
color: "secondary",
|
|
155
|
+
variant: "outlined",
|
|
156
|
+
onClick: handleCancel,
|
|
157
|
+
children: "Cancel"
|
|
158
|
+
})
|
|
159
|
+
]
|
|
160
|
+
})
|
|
161
|
+
]
|
|
162
|
+
}),
|
|
163
|
+
/*#__PURE__*/ _jsx(Box, {
|
|
164
|
+
padding: 2,
|
|
165
|
+
sx: {
|
|
166
|
+
overflowY: 'scroll'
|
|
167
|
+
},
|
|
168
|
+
children: /*#__PURE__*/ _jsx(Stack, {
|
|
169
|
+
spacing: 2,
|
|
170
|
+
children: /*#__PURE__*/ _jsxs(Stack, {
|
|
171
|
+
spacing: 2,
|
|
172
|
+
children: [
|
|
173
|
+
!validation.isValid && validation.errors.map((error)=>/*#__PURE__*/ _jsx(Alert, {
|
|
174
|
+
severity: "error",
|
|
175
|
+
children: error
|
|
176
|
+
}, error)),
|
|
177
|
+
/*#__PURE__*/ _jsx(TableContainer, {
|
|
178
|
+
children: /*#__PURE__*/ _jsxs(Table, {
|
|
179
|
+
sx: {
|
|
180
|
+
minWidth: 650
|
|
181
|
+
},
|
|
182
|
+
"aria-label": "table of annotations",
|
|
183
|
+
children: [
|
|
184
|
+
/*#__PURE__*/ _jsx(TableHead, {
|
|
185
|
+
children: /*#__PURE__*/ _jsxs(TableRow, {
|
|
186
|
+
children: [
|
|
187
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
188
|
+
children: "Visibility"
|
|
189
|
+
}),
|
|
190
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
191
|
+
children: "Name"
|
|
192
|
+
}),
|
|
193
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
194
|
+
children: "Type"
|
|
195
|
+
}),
|
|
196
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
197
|
+
children: "Description"
|
|
198
|
+
}),
|
|
199
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
200
|
+
align: "right",
|
|
201
|
+
children: "Actions"
|
|
202
|
+
})
|
|
203
|
+
]
|
|
204
|
+
})
|
|
205
|
+
}),
|
|
206
|
+
/*#__PURE__*/ _jsx(TableBody, {
|
|
207
|
+
children: annotationSpecs.map((v, idx)=>/*#__PURE__*/ _jsxs(TableRow, {
|
|
208
|
+
children: [
|
|
209
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
210
|
+
component: "th",
|
|
211
|
+
scope: "row",
|
|
212
|
+
children: /*#__PURE__*/ _jsx(Switch, {
|
|
213
|
+
checked: v.display?.hidden !== true,
|
|
214
|
+
onChange: (e)=>{
|
|
215
|
+
toggleAnnotationVisibility(idx, e.target.checked);
|
|
216
|
+
}
|
|
217
|
+
})
|
|
218
|
+
}),
|
|
219
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
220
|
+
component: "th",
|
|
221
|
+
scope: "row",
|
|
222
|
+
sx: {
|
|
223
|
+
fontWeight: 'bold'
|
|
224
|
+
},
|
|
225
|
+
children: v.display.name
|
|
226
|
+
}),
|
|
227
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
228
|
+
children: v.plugin.kind
|
|
229
|
+
}),
|
|
230
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
231
|
+
children: v.display?.description ?? ''
|
|
232
|
+
}),
|
|
233
|
+
/*#__PURE__*/ _jsxs(TableCell, {
|
|
234
|
+
align: "right",
|
|
235
|
+
sx: {
|
|
236
|
+
whiteSpace: 'nowrap'
|
|
237
|
+
},
|
|
238
|
+
children: [
|
|
239
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
240
|
+
onClick: ()=>changeAnnotationOrder(idx, 'up'),
|
|
241
|
+
disabled: idx === 0,
|
|
242
|
+
children: /*#__PURE__*/ _jsx(ArrowUp, {})
|
|
243
|
+
}),
|
|
244
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
245
|
+
onClick: ()=>changeAnnotationOrder(idx, 'down'),
|
|
246
|
+
disabled: idx === annotationSpecs.length - 1,
|
|
247
|
+
children: /*#__PURE__*/ _jsx(ArrowDown, {})
|
|
248
|
+
}),
|
|
249
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
250
|
+
onClick: ()=>editAnnotation(idx),
|
|
251
|
+
children: /*#__PURE__*/ _jsx(PencilIcon, {})
|
|
252
|
+
}),
|
|
253
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
254
|
+
onClick: ()=>removeAnnotation(idx),
|
|
255
|
+
children: /*#__PURE__*/ _jsx(TrashIcon, {})
|
|
256
|
+
})
|
|
257
|
+
]
|
|
258
|
+
})
|
|
259
|
+
]
|
|
260
|
+
}, v.display.name))
|
|
261
|
+
})
|
|
262
|
+
]
|
|
263
|
+
})
|
|
264
|
+
}),
|
|
265
|
+
/*#__PURE__*/ _jsx(Box, {
|
|
266
|
+
display: "flex",
|
|
267
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
268
|
+
variant: "contained",
|
|
269
|
+
startIcon: /*#__PURE__*/ _jsx(AddIcon, {}),
|
|
270
|
+
sx: {
|
|
271
|
+
marginLeft: 'auto'
|
|
272
|
+
},
|
|
273
|
+
onClick: addAnnotation,
|
|
274
|
+
children: "Add Annotation"
|
|
275
|
+
})
|
|
276
|
+
})
|
|
277
|
+
]
|
|
278
|
+
})
|
|
279
|
+
})
|
|
280
|
+
})
|
|
281
|
+
]
|
|
282
|
+
})
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
const TableCell = styled(MuiTableCell)(({ theme })=>({
|
|
286
|
+
borderBottom: `solid 1px ${theme.palette.divider}`
|
|
287
|
+
}));
|
|
288
|
+
|
|
289
|
+
//# sourceMappingURL=AnnotationsEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Annotations/AnnotationsEditor.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 { useState, useMemo, ReactElement } from 'react';\nimport {\n Button,\n Stack,\n Box,\n TableContainer,\n TableBody,\n TableRow,\n TableCell as MuiTableCell,\n Table,\n TableHead,\n Switch,\n Typography,\n IconButton,\n Alert,\n styled,\n} from '@mui/material';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport { AnnotationSpec, Definition, UnknownSpec } from '@perses-dev/spec';\nimport { useImmer } from 'use-immer';\nimport PencilIcon from 'mdi-material-ui/Pencil';\nimport TrashIcon from 'mdi-material-ui/TrashCan';\nimport ArrowUp from 'mdi-material-ui/ArrowUp';\nimport ArrowDown from 'mdi-material-ui/ArrowDown';\n\nimport { ValidationProvider, AnnotationEditorForm } from '@perses-dev/plugin-system';\nimport { Action } from '@perses-dev/client';\nimport { useDiscardChangesConfirmationDialog } from '../../context';\n\nfunction validateAnnotationSpecs(annotationSpecs: AnnotationSpec[]): { isValid: boolean; errors: string[] } {\n const errors: string[] = [];\n\n const annotationNames: string[] = [];\n\n for (const annotationSpec of annotationSpecs) {\n if (annotationNames.includes(annotationSpec.display.name)) {\n errors.push(`Duplicate annotation name: ${annotationSpec.display.name}`);\n } else {\n annotationNames.push(annotationSpec.display.name);\n }\n }\n\n return {\n errors: errors,\n isValid: errors.length === 0,\n };\n}\n\nexport function AnnotationEditor(props: {\n annotationSpecs: AnnotationSpec[];\n onChange: (annotationSpecs: AnnotationSpec[]) => void;\n onCancel: () => void;\n}): ReactElement {\n const [annotationSpecs, setAnnotationSpecs] = useImmer(props.annotationSpecs);\n const [annotationEditIdx, setAnnotationEditIdx] = useState<number | null>(null);\n const [annotationFormAction, setAnnotationFormAction] = useState<Action>('update');\n\n const validation = useMemo(() => validateAnnotationSpecs(annotationSpecs), [annotationSpecs]);\n const currentEditingAnnotationSpec: AnnotationSpec | undefined =\n annotationEditIdx !== null ? annotationSpecs[annotationEditIdx] : undefined;\n\n const { openDiscardChangesConfirmationDialog, closeDiscardChangesConfirmationDialog } =\n useDiscardChangesConfirmationDialog();\n const handleCancel = (): void => {\n if (JSON.stringify(props.annotationSpecs) !== JSON.stringify(annotationSpecs)) {\n openDiscardChangesConfirmationDialog({\n onDiscardChanges: () => {\n closeDiscardChangesConfirmationDialog();\n props.onCancel();\n },\n onCancel: () => {\n closeDiscardChangesConfirmationDialog();\n },\n description:\n 'You have unapplied changes. Are you sure you want to discard these changes? Changes cannot be recovered.',\n });\n } else {\n props.onCancel();\n }\n };\n\n const removeAnnotation = (index: number): void => {\n setAnnotationSpecs((draft) => {\n draft.splice(index, 1);\n });\n };\n\n const addAnnotation = (): void => {\n setAnnotationFormAction('create');\n setAnnotationSpecs((draft) => {\n draft.push({\n display: { name: 'NewAnnotation' },\n plugin: {} as Definition<UnknownSpec>,\n });\n });\n setAnnotationEditIdx(annotationSpecs.length);\n };\n\n const editAnnotation = (index: number): void => {\n setAnnotationFormAction('update');\n setAnnotationEditIdx(index);\n };\n\n const toggleAnnotationVisibility = (index: number, visible: boolean): void => {\n setAnnotationSpecs((draft) => {\n const v = draft[index];\n if (!v) {\n return;\n }\n v.display.hidden = !visible;\n });\n };\n\n const changeAnnotationOrder = (index: number, direction: 'up' | 'down'): void => {\n const step = direction === 'up' ? -1 : 1;\n\n setAnnotationSpecs((draft) => {\n const current = draft[index];\n const adjacent = draft[index + step];\n\n if (!current || !adjacent) {\n return;\n }\n\n draft[index + step] = current;\n draft[index] = adjacent;\n });\n };\n\n return (\n <>\n {annotationEditIdx !== null && currentEditingAnnotationSpec ? (\n <ValidationProvider>\n <AnnotationEditorForm\n initialAnnotationSpec={currentEditingAnnotationSpec}\n action={annotationFormAction}\n isDraft={true}\n onActionChange={setAnnotationFormAction}\n onSave={(definition: AnnotationSpec) => {\n setAnnotationSpecs((draft) => {\n draft[annotationEditIdx] = definition;\n setAnnotationEditIdx(null);\n });\n }}\n onClose={() => {\n if (annotationFormAction === 'create') {\n removeAnnotation(annotationEditIdx);\n }\n setAnnotationEditIdx(null);\n }}\n />\n </ValidationProvider>\n ) : (\n <>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">Edit Dashboard Annotations</Typography>\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\">\n <Button\n disabled={props.annotationSpecs === annotationSpecs || !validation.isValid}\n variant=\"contained\"\n onClick={() => {\n props.onChange(annotationSpecs);\n }}\n >\n Apply\n </Button>\n <Button color=\"secondary\" variant=\"outlined\" onClick={handleCancel}>\n Cancel\n </Button>\n </Stack>\n </Box>\n <Box padding={2} sx={{ overflowY: 'scroll' }}>\n <Stack spacing={2}>\n <Stack spacing={2}>\n {!validation.isValid &&\n validation.errors.map((error) => (\n <Alert severity=\"error\" key={error}>\n {error}\n </Alert>\n ))}\n <TableContainer>\n <Table sx={{ minWidth: 650 }} aria-label=\"table of annotations\">\n <TableHead>\n <TableRow>\n <TableCell>Visibility</TableCell>\n <TableCell>Name</TableCell>\n <TableCell>Type</TableCell>\n <TableCell>Description</TableCell>\n <TableCell align=\"right\">Actions</TableCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {annotationSpecs.map((v, idx) => (\n <TableRow key={v.display.name}>\n <TableCell component=\"th\" scope=\"row\">\n <Switch\n checked={v.display?.hidden !== true}\n onChange={(e) => {\n toggleAnnotationVisibility(idx, e.target.checked);\n }}\n />\n </TableCell>\n <TableCell component=\"th\" scope=\"row\" sx={{ fontWeight: 'bold' }}>\n {v.display.name}\n </TableCell>\n <TableCell>{v.plugin.kind}</TableCell>\n <TableCell>{v.display?.description ?? ''}</TableCell>\n <TableCell align=\"right\" sx={{ whiteSpace: 'nowrap' }}>\n <IconButton onClick={() => changeAnnotationOrder(idx, 'up')} disabled={idx === 0}>\n <ArrowUp />\n </IconButton>\n <IconButton\n onClick={() => changeAnnotationOrder(idx, 'down')}\n disabled={idx === annotationSpecs.length - 1}\n >\n <ArrowDown />\n </IconButton>\n <IconButton onClick={() => editAnnotation(idx)}>\n <PencilIcon />\n </IconButton>\n <IconButton onClick={() => removeAnnotation(idx)}>\n <TrashIcon />\n </IconButton>\n </TableCell>\n </TableRow>\n ))}\n </TableBody>\n </Table>\n </TableContainer>\n <Box display=\"flex\">\n <Button\n variant=\"contained\"\n startIcon={<AddIcon />}\n sx={{ marginLeft: 'auto' }}\n onClick={addAnnotation}\n >\n Add Annotation\n </Button>\n </Box>\n </Stack>\n </Stack>\n </Box>\n </>\n )}\n </>\n );\n}\n\nconst TableCell = styled(MuiTableCell)(({ theme }) => ({\n borderBottom: `solid 1px ${theme.palette.divider}`,\n}));\n"],"names":["useState","useMemo","Button","Stack","Box","TableContainer","TableBody","TableRow","TableCell","MuiTableCell","Table","TableHead","Switch","Typography","IconButton","Alert","styled","AddIcon","useImmer","PencilIcon","TrashIcon","ArrowUp","ArrowDown","ValidationProvider","AnnotationEditorForm","useDiscardChangesConfirmationDialog","validateAnnotationSpecs","annotationSpecs","errors","annotationNames","annotationSpec","includes","display","name","push","isValid","length","AnnotationEditor","props","setAnnotationSpecs","annotationEditIdx","setAnnotationEditIdx","annotationFormAction","setAnnotationFormAction","validation","currentEditingAnnotationSpec","undefined","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","handleCancel","JSON","stringify","onDiscardChanges","onCancel","description","removeAnnotation","index","draft","splice","addAnnotation","plugin","editAnnotation","toggleAnnotationVisibility","visible","v","hidden","changeAnnotationOrder","direction","step","current","adjacent","initialAnnotationSpec","action","isDraft","onActionChange","onSave","definition","onClose","sx","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","marginLeft","disabled","onClick","onChange","color","overflowY","map","error","severity","minWidth","aria-label","align","idx","component","scope","checked","e","target","fontWeight","kind","whiteSpace","startIcon"],"mappings":"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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { ButtonProps } from '@mui/material';
|
|
3
|
+
export interface EditAnnotationsButtonProps extends Pick<ButtonProps, 'fullWidth'> {
|
|
4
|
+
/**
|
|
5
|
+
* The variant to use to display the button.
|
|
6
|
+
*/
|
|
7
|
+
variant?: 'text' | 'outlined';
|
|
8
|
+
/**
|
|
9
|
+
* The color to use to display the button.
|
|
10
|
+
*/
|
|
11
|
+
color?: 'primary' | 'secondary';
|
|
12
|
+
/**
|
|
13
|
+
* The label used inside the button.
|
|
14
|
+
*/
|
|
15
|
+
label?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function EditAnnotationsButton({ variant, label, color, fullWidth, }: EditAnnotationsButtonProps): ReactElement;
|
|
18
|
+
//# sourceMappingURL=EditAnnotationsButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditAnnotationsButton.d.ts","sourceRoot":"","sources":["../../../src/components/Annotations/EditAnnotationsButton.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAU,WAAW,EAAE,MAAM,eAAe,CAAC;AAQpD,MAAM,WAAW,0BAA2B,SAAQ,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC;IAChF;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAE9B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IAEhC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,qBAAqB,CAAC,EACpC,OAAgB,EAChB,KAAqB,EACrB,KAAiB,EACjB,SAAS,GACV,EAAE,0BAA0B,GAAG,YAAY,CA6C3C"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
// Copyright The Perses Authors
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
import { useState } from 'react';
|
|
15
|
+
import { Button } from '@mui/material';
|
|
16
|
+
import PencilIcon from 'mdi-material-ui/PencilOutline';
|
|
17
|
+
import { Drawer, InfoTooltip } from '@perses-dev/components';
|
|
18
|
+
import { TOOLTIP_TEXT, editButtonStyle } from '../../constants';
|
|
19
|
+
import { useAnnotationActions, useAnnotationSpecs } from '../../context';
|
|
20
|
+
import { AnnotationEditor } from './AnnotationsEditor';
|
|
21
|
+
export function EditAnnotationsButton({ variant = 'text', label = 'Annotations', color = 'primary', fullWidth }) {
|
|
22
|
+
const [isAnnotationEditorOpen, setIsAnnotationEditorOpen] = useState(false);
|
|
23
|
+
const annotationSpecs = useAnnotationSpecs();
|
|
24
|
+
const { setAnnotationSpecs } = useAnnotationActions();
|
|
25
|
+
const openAnnotationEditor = ()=>{
|
|
26
|
+
setIsAnnotationEditorOpen(true);
|
|
27
|
+
};
|
|
28
|
+
const closeAnnotationEditor = ()=>{
|
|
29
|
+
setIsAnnotationEditorOpen(false);
|
|
30
|
+
};
|
|
31
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
32
|
+
children: [
|
|
33
|
+
/*#__PURE__*/ _jsx(InfoTooltip, {
|
|
34
|
+
description: TOOLTIP_TEXT.editAnnotations,
|
|
35
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
36
|
+
startIcon: /*#__PURE__*/ _jsx(PencilIcon, {}),
|
|
37
|
+
onClick: openAnnotationEditor,
|
|
38
|
+
"aria-label": TOOLTIP_TEXT.editAnnotations,
|
|
39
|
+
variant: variant,
|
|
40
|
+
color: color,
|
|
41
|
+
fullWidth: fullWidth,
|
|
42
|
+
sx: editButtonStyle,
|
|
43
|
+
children: label
|
|
44
|
+
})
|
|
45
|
+
}),
|
|
46
|
+
/*#__PURE__*/ _jsx(Drawer, {
|
|
47
|
+
isOpen: isAnnotationEditorOpen,
|
|
48
|
+
onClose: closeAnnotationEditor,
|
|
49
|
+
slotProps: {
|
|
50
|
+
paper: {
|
|
51
|
+
sx: {
|
|
52
|
+
width: '50%'
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"data-testid": "annotation-editor",
|
|
57
|
+
children: /*#__PURE__*/ _jsx(AnnotationEditor, {
|
|
58
|
+
annotationSpecs: annotationSpecs,
|
|
59
|
+
onCancel: closeAnnotationEditor,
|
|
60
|
+
onChange: (annotations)=>{
|
|
61
|
+
setAnnotationSpecs(annotations);
|
|
62
|
+
setIsAnnotationEditorOpen(false);
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
]
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=EditAnnotationsButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Annotations/EditAnnotationsButton.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 { ReactElement, useState } from 'react';\nimport { Button, ButtonProps } from '@mui/material';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport { Drawer, InfoTooltip } from '@perses-dev/components';\nimport { AnnotationSpec } from '@perses-dev/spec';\nimport { TOOLTIP_TEXT, editButtonStyle } from '../../constants';\nimport { useAnnotationActions, useAnnotationSpecs } from '../../context';\nimport { AnnotationEditor } from './AnnotationsEditor';\n\nexport interface EditAnnotationsButtonProps extends Pick<ButtonProps, 'fullWidth'> {\n /**\n * The variant to use to display the button.\n */\n variant?: 'text' | 'outlined';\n\n /**\n * The color to use to display the button.\n */\n color?: 'primary' | 'secondary';\n\n /**\n * The label used inside the button.\n */\n label?: string;\n}\n\nexport function EditAnnotationsButton({\n variant = 'text',\n label = 'Annotations',\n color = 'primary',\n fullWidth,\n}: EditAnnotationsButtonProps): ReactElement {\n const [isAnnotationEditorOpen, setIsAnnotationEditorOpen] = useState(false);\n const annotationSpecs: AnnotationSpec[] = useAnnotationSpecs();\n const { setAnnotationSpecs } = useAnnotationActions();\n\n const openAnnotationEditor = (): void => {\n setIsAnnotationEditorOpen(true);\n };\n\n const closeAnnotationEditor = (): void => {\n setIsAnnotationEditorOpen(false);\n };\n\n return (\n <>\n <InfoTooltip description={TOOLTIP_TEXT.editAnnotations}>\n <Button\n startIcon={<PencilIcon />}\n onClick={openAnnotationEditor}\n aria-label={TOOLTIP_TEXT.editAnnotations}\n variant={variant}\n color={color}\n fullWidth={fullWidth}\n sx={editButtonStyle}\n >\n {label}\n </Button>\n </InfoTooltip>\n <Drawer\n isOpen={isAnnotationEditorOpen}\n onClose={closeAnnotationEditor}\n slotProps={{ paper: { sx: { width: '50%' } } }}\n data-testid=\"annotation-editor\"\n >\n <AnnotationEditor\n annotationSpecs={annotationSpecs}\n onCancel={closeAnnotationEditor}\n onChange={(annotations: AnnotationSpec[]) => {\n setAnnotationSpecs(annotations);\n setIsAnnotationEditorOpen(false);\n }}\n />\n </Drawer>\n </>\n );\n}\n"],"names":["useState","Button","PencilIcon","Drawer","InfoTooltip","TOOLTIP_TEXT","editButtonStyle","useAnnotationActions","useAnnotationSpecs","AnnotationEditor","EditAnnotationsButton","variant","label","color","fullWidth","isAnnotationEditorOpen","setIsAnnotationEditorOpen","annotationSpecs","setAnnotationSpecs","openAnnotationEditor","closeAnnotationEditor","description","editAnnotations","startIcon","onClick","aria-label","sx","isOpen","onClose","slotProps","paper","width","data-testid","onCancel","onChange","annotations"],"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,SAAuBA,QAAQ,QAAQ,QAAQ;AAC/C,SAASC,MAAM,QAAqB,gBAAgB;AACpD,OAAOC,gBAAgB,gCAAgC;AACvD,SAASC,MAAM,EAAEC,WAAW,QAAQ,yBAAyB;AAE7D,SAASC,YAAY,EAAEC,eAAe,QAAQ,kBAAkB;AAChE,SAASC,oBAAoB,EAAEC,kBAAkB,QAAQ,gBAAgB;AACzE,SAASC,gBAAgB,QAAQ,sBAAsB;AAmBvD,OAAO,SAASC,sBAAsB,EACpCC,UAAU,MAAM,EAChBC,QAAQ,aAAa,EACrBC,QAAQ,SAAS,EACjBC,SAAS,EACkB;IAC3B,MAAM,CAACC,wBAAwBC,0BAA0B,GAAGhB,SAAS;IACrE,MAAMiB,kBAAoCT;IAC1C,MAAM,EAAEU,kBAAkB,EAAE,GAAGX;IAE/B,MAAMY,uBAAuB;QAC3BH,0BAA0B;IAC5B;IAEA,MAAMI,wBAAwB;QAC5BJ,0BAA0B;IAC5B;IAEA,qBACE;;0BACE,KAACZ;gBAAYiB,aAAahB,aAAaiB,eAAe;0BACpD,cAAA,KAACrB;oBACCsB,yBAAW,KAACrB;oBACZsB,SAASL;oBACTM,cAAYpB,aAAaiB,eAAe;oBACxCX,SAASA;oBACTE,OAAOA;oBACPC,WAAWA;oBACXY,IAAIpB;8BAEHM;;;0BAGL,KAACT;gBACCwB,QAAQZ;gBACRa,SAASR;gBACTS,WAAW;oBAAEC,OAAO;wBAAEJ,IAAI;4BAAEK,OAAO;wBAAM;oBAAE;gBAAE;gBAC7CC,eAAY;0BAEZ,cAAA,KAACvB;oBACCQ,iBAAiBA;oBACjBgB,UAAUb;oBACVc,UAAU,CAACC;wBACTjB,mBAAmBiB;wBACnBnB,0BAA0B;oBAC5B;;;;;AAKV"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
2
|
// Copyright The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { Box } from '@mui/material';
|
|
15
15
|
import { ErrorBoundary, ErrorAlert } from '@perses-dev/components';
|
|
16
16
|
import { useRef } from 'react';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Dashboard/Dashboard.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 { Box, BoxProps } from '@mui/material';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { ReactElement, useRef } from 'react';\nimport { usePanelGroupIds } from '../../context';\nimport { GridLayout } from '../GridLayout';\nimport { EmptyDashboard, EmptyDashboardProps } from '../EmptyDashboard';\nimport { PanelOptions } from '../Panel';\n\nexport type DashboardProps = BoxProps & {\n /**\n * Props for `EmptyDashboard` component that will be rendered when the dashboard\n * is empty (i.e. has no panel groups). If not specified, the defaults will\n * be used.\n */\n emptyDashboardProps?: EmptyDashboardProps;\n panelOptions?: PanelOptions;\n};\nconst HEADER_HEIGHT = 165; // Approximate height of the header in dashboard view (including the navbar and variables toolbar)\n\n/**\n * Renders a Dashboard for the provided Dashboard spec.\n */\nexport function Dashboard({ emptyDashboardProps, panelOptions, ...boxProps }: DashboardProps): ReactElement {\n const panelGroupIds = usePanelGroupIds();\n const boxRef = useRef<HTMLDivElement>(null);\n const isEmpty = !panelGroupIds.length;\n const dashboardTopPosition = boxRef.current?.getBoundingClientRect().top ?? HEADER_HEIGHT;\n const panelFullHeight = window.innerHeight - dashboardTopPosition - window.scrollY;\n\n return (\n <Box {...boxProps} sx={{ height: '100%' }} ref={boxRef}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n {isEmpty && (\n <Box sx={{ height: '100%', display: 'flex', alignItems: 'center' }}>\n <EmptyDashboard {...emptyDashboardProps} />\n </Box>\n )}\n {!isEmpty &&\n panelGroupIds.map((panelGroupId) => (\n <GridLayout\n key={panelGroupId}\n panelGroupId={panelGroupId}\n panelOptions={panelOptions}\n panelFullHeight={panelFullHeight}\n />\n ))}\n </ErrorBoundary>\n </Box>\n );\n}\n"],"names":["Box","ErrorBoundary","ErrorAlert","useRef","usePanelGroupIds","GridLayout","EmptyDashboard","HEADER_HEIGHT","Dashboard","emptyDashboardProps","panelOptions","boxProps","panelGroupIds","boxRef","isEmpty","length","dashboardTopPosition","current","getBoundingClientRect","top","panelFullHeight","window","innerHeight","scrollY","sx","height","ref","FallbackComponent","display","alignItems","map","panelGroupId"],"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
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Dashboard/Dashboard.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 { Box, BoxProps } from '@mui/material';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { ReactElement, useRef } from 'react';\nimport { usePanelGroupIds } from '../../context';\nimport { GridLayout } from '../GridLayout';\nimport { EmptyDashboard, EmptyDashboardProps } from '../EmptyDashboard';\nimport { PanelOptions } from '../Panel';\n\nexport type DashboardProps = BoxProps & {\n /**\n * Props for `EmptyDashboard` component that will be rendered when the dashboard\n * is empty (i.e. has no panel groups). If not specified, the defaults will\n * be used.\n */\n emptyDashboardProps?: EmptyDashboardProps;\n panelOptions?: PanelOptions;\n};\nconst HEADER_HEIGHT = 165; // Approximate height of the header in dashboard view (including the navbar and variables toolbar)\n\n/**\n * Renders a Dashboard for the provided Dashboard spec.\n */\nexport function Dashboard({ emptyDashboardProps, panelOptions, ...boxProps }: DashboardProps): ReactElement {\n const panelGroupIds = usePanelGroupIds();\n const boxRef = useRef<HTMLDivElement>(null);\n const isEmpty = !panelGroupIds.length;\n const dashboardTopPosition = boxRef.current?.getBoundingClientRect().top ?? HEADER_HEIGHT;\n const panelFullHeight = window.innerHeight - dashboardTopPosition - window.scrollY;\n\n return (\n <Box {...boxProps} sx={{ height: '100%' }} ref={boxRef}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n {isEmpty && (\n <Box sx={{ height: '100%', display: 'flex', alignItems: 'center' }}>\n <EmptyDashboard {...emptyDashboardProps} />\n </Box>\n )}\n {!isEmpty &&\n panelGroupIds.map((panelGroupId) => (\n <GridLayout\n key={panelGroupId}\n panelGroupId={panelGroupId}\n panelOptions={panelOptions}\n panelFullHeight={panelFullHeight}\n />\n ))}\n </ErrorBoundary>\n </Box>\n );\n}\n"],"names":["Box","ErrorBoundary","ErrorAlert","useRef","usePanelGroupIds","GridLayout","EmptyDashboard","HEADER_HEIGHT","Dashboard","emptyDashboardProps","panelOptions","boxProps","panelGroupIds","boxRef","isEmpty","length","dashboardTopPosition","current","getBoundingClientRect","top","panelFullHeight","window","innerHeight","scrollY","sx","height","ref","FallbackComponent","display","alignItems","map","panelGroupId"],"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,GAAG,QAAkB,gBAAgB;AAC9C,SAASC,aAAa,EAAEC,UAAU,QAAQ,yBAAyB;AACnE,SAAuBC,MAAM,QAAQ,QAAQ;AAC7C,SAASC,gBAAgB,QAAQ,gBAAgB;AACjD,SAASC,UAAU,QAAQ,gBAAgB;AAC3C,SAASC,cAAc,QAA6B,oBAAoB;AAYxE,MAAMC,gBAAgB,KAAK,kGAAkG;AAE7H;;CAEC,GACD,OAAO,SAASC,UAAU,EAAEC,mBAAmB,EAAEC,YAAY,EAAE,GAAGC,UAA0B;IAC1F,MAAMC,gBAAgBR;IACtB,MAAMS,SAASV,OAAuB;IACtC,MAAMW,UAAU,CAACF,cAAcG,MAAM;IACrC,MAAMC,uBAAuBH,OAAOI,OAAO,EAAEC,wBAAwBC,OAAOZ;IAC5E,MAAMa,kBAAkBC,OAAOC,WAAW,GAAGN,uBAAuBK,OAAOE,OAAO;IAElF,qBACE,KAACvB;QAAK,GAAGW,QAAQ;QAAEa,IAAI;YAAEC,QAAQ;QAAO;QAAGC,KAAKb;kBAC9C,cAAA,MAACZ;YAAc0B,mBAAmBzB;;gBAC/BY,yBACC,KAACd;oBAAIwB,IAAI;wBAAEC,QAAQ;wBAAQG,SAAS;wBAAQC,YAAY;oBAAS;8BAC/D,cAAA,KAACvB;wBAAgB,GAAGG,mBAAmB;;;gBAG1C,CAACK,WACAF,cAAckB,GAAG,CAAC,CAACC,6BACjB,KAAC1B;wBAEC0B,cAAcA;wBACdrB,cAAcA;wBACdU,iBAAiBA;uBAHZW;;;;AASnB"}
|