@perses-dev/dashboards 0.0.0-snapshot-time-range-height-80d08fc → 0.0.0-snapshot-embed-import-errors-8906900
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/DashboardToolbar/DashboardToolbar.js +19 -5
- package/dist/cjs/components/DeletePanelDialog/DeletePanelDialog.js +2 -0
- package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +2 -0
- package/dist/cjs/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +74 -0
- package/dist/cjs/components/{UnsavedChangesConfirmationDialog → DiscardChangesConfirmationDialog}/index.js +1 -1
- package/dist/cjs/components/DownloadButton/DownloadButton.js +2 -8
- package/dist/cjs/components/GridLayout/GridTitle.js +38 -22
- package/dist/cjs/components/Panel/PanelHeader.js +59 -26
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +29 -8
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +11 -6
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +2 -8
- package/dist/cjs/components/ToolbarIconButton/ToolbarIconButton.js +35 -0
- package/dist/cjs/components/ToolbarIconButton/index.js +28 -0
- package/dist/cjs/components/Variables/VariableEditor.js +19 -3
- package/dist/cjs/components/Variables/VariableList.js +1 -1
- package/dist/cjs/components/index.js +2 -1
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +2 -0
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +10 -1
- package/dist/cjs/context/DashboardProvider/discard-changes-dialog-slice.js +33 -0
- package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +7 -7
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +14 -14
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +2 -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 +20 -6
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/DeletePanelDialog/DeletePanelDialog.js +2 -0
- package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -1
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +2 -0
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts +3 -0
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts.map +1 -0
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +63 -0
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -0
- package/dist/components/DiscardChangesConfirmationDialog/index.d.ts +2 -0
- package/dist/components/DiscardChangesConfirmationDialog/index.d.ts.map +1 -0
- package/dist/components/{UnsavedChangesConfirmationDialog → DiscardChangesConfirmationDialog}/index.js +1 -1
- package/dist/components/{UnsavedChangesConfirmationDialog → DiscardChangesConfirmationDialog}/index.js.map +1 -1
- package/dist/components/DownloadButton/DownloadButton.js +2 -8
- package/dist/components/DownloadButton/DownloadButton.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
- package/dist/components/GridLayout/GridTitle.js +38 -22
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
- package/dist/components/Panel/PanelHeader.js +61 -28
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +32 -11
- 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 +12 -7
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +2 -8
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/ToolbarIconButton/ToolbarIconButton.d.ts +6 -0
- package/dist/components/ToolbarIconButton/ToolbarIconButton.d.ts.map +1 -0
- package/dist/components/ToolbarIconButton/ToolbarIconButton.js +29 -0
- package/dist/components/ToolbarIconButton/ToolbarIconButton.js.map +1 -0
- package/dist/components/ToolbarIconButton/index.d.ts +2 -0
- package/dist/components/ToolbarIconButton/index.d.ts.map +1 -0
- package/dist/components/ToolbarIconButton/index.js +15 -0
- package/dist/components/ToolbarIconButton/index.js.map +1 -0
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditor.js +19 -3
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableList.d.ts.map +1 -1
- package/dist/components/Variables/VariableList.js +1 -1
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -1
- package/dist/components/index.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +2 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +2 -0
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +5 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js +8 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- package/dist/context/DashboardProvider/discard-changes-dialog-slice.d.ts +15 -0
- package/dist/context/DashboardProvider/discard-changes-dialog-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/discard-changes-dialog-slice.js +27 -0
- package/dist/context/DashboardProvider/discard-changes-dialog-slice.js.map +1 -0
- package/dist/context/DashboardProvider/index.d.ts +1 -0
- package/dist/context/DashboardProvider/index.d.ts.map +1 -1
- package/dist/context/DashboardProvider/index.js.map +1 -1
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +7 -7
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.d.ts +1 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +16 -16
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.d.ts +1 -0
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +2 -1
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/package.json +4 -4
- package/dist/cjs/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js +0 -67
- package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts +0 -8
- package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts.map +0 -1
- package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js +0 -56
- package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js.map +0 -1
- package/dist/components/UnsavedChangesConfirmationDialog/index.d.ts +0 -2
- package/dist/components/UnsavedChangesConfirmationDialog/index.d.ts.map +0 -1
|
@@ -26,6 +26,7 @@ const _pencil = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Pe
|
|
|
26
26
|
const _trashCan = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/TrashCan"));
|
|
27
27
|
const _arrowUp = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/ArrowUp"));
|
|
28
28
|
const _arrowDown = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/ArrowDown"));
|
|
29
|
+
const _context = require("../../context");
|
|
29
30
|
const _variableEditorForm = require("./VariableEditorForm");
|
|
30
31
|
const _variableModel = require("./variable-model");
|
|
31
32
|
function _interopRequireDefault(obj) {
|
|
@@ -56,6 +57,23 @@ function VariableEditor(props) {
|
|
|
56
57
|
variableDefinitions
|
|
57
58
|
]);
|
|
58
59
|
const currentEditingVariableDefinition = typeof variableEditIdx === 'number' && variableDefinitions[variableEditIdx];
|
|
60
|
+
const { openDiscardChangesConfirmationDialog , closeDiscardChangesConfirmationDialog } = (0, _context.useDiscardChangesConfirmationDialog)();
|
|
61
|
+
const handleCancel = ()=>{
|
|
62
|
+
if (JSON.stringify(props.variableDefinitions) !== JSON.stringify(variableDefinitions)) {
|
|
63
|
+
openDiscardChangesConfirmationDialog({
|
|
64
|
+
onDiscardChanges: ()=>{
|
|
65
|
+
closeDiscardChangesConfirmationDialog();
|
|
66
|
+
props.onCancel();
|
|
67
|
+
},
|
|
68
|
+
onCancel: ()=>{
|
|
69
|
+
closeDiscardChangesConfirmationDialog();
|
|
70
|
+
},
|
|
71
|
+
description: 'You have unapplied changes. Are you sure you want to discard these changes? Changes cannot be recovered.'
|
|
72
|
+
});
|
|
73
|
+
} else {
|
|
74
|
+
props.onCancel();
|
|
75
|
+
}
|
|
76
|
+
};
|
|
59
77
|
const removeVariable = (index)=>{
|
|
60
78
|
setVariableDefinitions((draft)=>{
|
|
61
79
|
draft.splice(index, 1);
|
|
@@ -152,9 +170,7 @@ function VariableEditor(props) {
|
|
|
152
170
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
153
171
|
color: "secondary",
|
|
154
172
|
variant: "outlined",
|
|
155
|
-
onClick:
|
|
156
|
-
props.onCancel();
|
|
157
|
-
},
|
|
173
|
+
onClick: handleCancel,
|
|
158
174
|
children: "Cancel"
|
|
159
175
|
})
|
|
160
176
|
]
|
|
@@ -128,7 +128,7 @@ function TemplateVariableList(props) {
|
|
|
128
128
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Stack, {
|
|
129
129
|
direction: "row",
|
|
130
130
|
spacing: 1,
|
|
131
|
-
children:
|
|
131
|
+
children: variableDefinitions.map((v)=>{
|
|
132
132
|
var ref;
|
|
133
133
|
/*#__PURE__*/ return (0, _jsxRuntime.jsx)(_material.Box, {
|
|
134
134
|
display: ((ref = v.spec.display) === null || ref === void 0 ? void 0 : ref.hidden) ? 'none' : undefined,
|
|
@@ -18,13 +18,14 @@ _exportStar(require("./Dashboard"), exports);
|
|
|
18
18
|
_exportStar(require("./DashboardToolbar"), exports);
|
|
19
19
|
_exportStar(require("./DeletePanelDialog"), exports);
|
|
20
20
|
_exportStar(require("./DeletePanelGroupDialog"), exports);
|
|
21
|
+
_exportStar(require("./DiscardChangesConfirmationDialog"), exports);
|
|
21
22
|
_exportStar(require("./DownloadButton"), exports);
|
|
22
23
|
_exportStar(require("./GridLayout"), exports);
|
|
23
24
|
_exportStar(require("./Panel"), exports);
|
|
24
25
|
_exportStar(require("./PanelDrawer"), exports);
|
|
25
26
|
_exportStar(require("./PanelGroupDialog"), exports);
|
|
26
27
|
_exportStar(require("./TimeRangeControls"), exports);
|
|
27
|
-
_exportStar(require("./
|
|
28
|
+
_exportStar(require("./ToolbarIconButton"), exports);
|
|
28
29
|
_exportStar(require("./Variables"), exports);
|
|
29
30
|
function _exportStar(from, to) {
|
|
30
31
|
Object.keys(from).forEach(function(k) {
|
|
@@ -37,6 +37,7 @@ const _panelEditorSlice = require("./panel-editor-slice");
|
|
|
37
37
|
const _panelSlice = require("./panel-slice");
|
|
38
38
|
const _deletePanelGroupSlice = require("./delete-panel-group-slice");
|
|
39
39
|
const _deletePanelSlice = require("./delete-panel-slice");
|
|
40
|
+
const _discardChangesDialogSlice = require("./discard-changes-dialog-slice");
|
|
40
41
|
function _interopRequireDefault(obj) {
|
|
41
42
|
return obj && obj.__esModule ? obj : {
|
|
42
43
|
default: obj
|
|
@@ -72,6 +73,7 @@ function initStore(props) {
|
|
|
72
73
|
...(0, _deletePanelGroupSlice.createDeletePanelGroupSlice)(...args),
|
|
73
74
|
...(0, _panelEditorSlice.createPanelEditorSlice)()(...args),
|
|
74
75
|
...(0, _deletePanelSlice.createDeletePanelSlice)()(...args),
|
|
76
|
+
...(0, _discardChangesDialogSlice.createDiscardChangesDialogSlice)(...args),
|
|
75
77
|
metadata,
|
|
76
78
|
defaultTimeRange: {
|
|
77
79
|
pastDuration: duration
|
|
@@ -33,7 +33,8 @@ _export(exports, {
|
|
|
33
33
|
usePanelActions: ()=>usePanelActions,
|
|
34
34
|
usePanelEditor: ()=>usePanelEditor,
|
|
35
35
|
useDeletePanelDialog: ()=>useDeletePanelDialog,
|
|
36
|
-
useDefaultTimeRange: ()=>useDefaultTimeRange
|
|
36
|
+
useDefaultTimeRange: ()=>useDefaultTimeRange,
|
|
37
|
+
useDiscardChangesConfirmationDialog: ()=>useDiscardChangesConfirmationDialog
|
|
37
38
|
});
|
|
38
39
|
const _react = require("react");
|
|
39
40
|
const _dashboardProvider = require("./DashboardProvider");
|
|
@@ -189,3 +190,11 @@ const selectDefaultTimeRange = (state)=>state.defaultTimeRange;
|
|
|
189
190
|
function useDefaultTimeRange() {
|
|
190
191
|
return (0, _dashboardProvider.useDashboardStore)(selectDefaultTimeRange);
|
|
191
192
|
}
|
|
193
|
+
const selectDiscardChangesConfirmationDialog = ({ discardChangesConfirmationDialog , openDiscardChangesConfirmationDialog , closeDiscardChangesConfirmationDialog })=>({
|
|
194
|
+
discardChangesConfirmationDialog,
|
|
195
|
+
openDiscardChangesConfirmationDialog,
|
|
196
|
+
closeDiscardChangesConfirmationDialog
|
|
197
|
+
});
|
|
198
|
+
function useDiscardChangesConfirmationDialog() {
|
|
199
|
+
return (0, _dashboardProvider.useDashboardStore)(selectDiscardChangesConfirmationDialog);
|
|
200
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "createDiscardChangesDialogSlice", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>createDiscardChangesDialogSlice
|
|
20
|
+
});
|
|
21
|
+
const createDiscardChangesDialogSlice = (set)=>({
|
|
22
|
+
isOpen: false,
|
|
23
|
+
openDiscardChangesConfirmationDialog (dialog) {
|
|
24
|
+
set((state)=>{
|
|
25
|
+
state.discardChangesConfirmationDialog = dialog;
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
closeDiscardChangesConfirmationDialog () {
|
|
29
|
+
set((state)=>{
|
|
30
|
+
state.discardChangesConfirmationDialog = undefined;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
});
|
|
@@ -187,25 +187,25 @@ function TemplateVariableProvider({ children , initialVariableDefinitions =[] }
|
|
|
187
187
|
})
|
|
188
188
|
});
|
|
189
189
|
}
|
|
190
|
-
/** Helpers */ function hydrateTemplateVariableState(
|
|
191
|
-
const v = definition;
|
|
192
|
-
var ref;
|
|
190
|
+
/** Helpers */ function hydrateTemplateVariableState(variable, initialValue) {
|
|
193
191
|
const varState = {
|
|
194
|
-
value:
|
|
192
|
+
value: null,
|
|
195
193
|
loading: false
|
|
196
194
|
};
|
|
197
|
-
switch(
|
|
195
|
+
switch(variable.kind){
|
|
198
196
|
case 'TextVariable':
|
|
199
|
-
varState.value = initialValue !== null && initialValue !== void 0 ? initialValue :
|
|
197
|
+
varState.value = initialValue !== null && initialValue !== void 0 ? initialValue : variable.spec.value;
|
|
200
198
|
break;
|
|
201
199
|
case 'ListVariable':
|
|
202
200
|
varState.options = [];
|
|
201
|
+
var ref;
|
|
202
|
+
varState.value = (ref = initialValue !== null && initialValue !== void 0 ? initialValue : variable.spec.default_value) !== null && ref !== void 0 ? ref : null;
|
|
203
203
|
if (varState.options.length > 0 && !varState.value) {
|
|
204
204
|
var ref1;
|
|
205
205
|
var ref2;
|
|
206
206
|
const firstOptionValue = (ref2 = (ref1 = varState.options[0]) === null || ref1 === void 0 ? void 0 : ref1.value) !== null && ref2 !== void 0 ? ref2 : null;
|
|
207
207
|
if (firstOptionValue !== null) {
|
|
208
|
-
varState.value =
|
|
208
|
+
varState.value = variable.spec.allow_multiple ? [
|
|
209
209
|
firstOptionValue
|
|
210
210
|
] : firstOptionValue;
|
|
211
211
|
}
|
|
@@ -25,22 +25,18 @@ const _components = require("@perses-dev/components");
|
|
|
25
25
|
const _components1 = require("../../components");
|
|
26
26
|
const _context = require("../../context");
|
|
27
27
|
const DashboardApp = (props)=>{
|
|
28
|
-
const { dashboardResource , dashboardTitleComponent , initialVariableIsSticky , isReadonly } = props;
|
|
28
|
+
const { dashboardResource , dashboardTitleComponent , onSave , initialVariableIsSticky , isReadonly } = props;
|
|
29
29
|
const { setEditMode } = (0, _context.useEditMode)();
|
|
30
30
|
const { dashboard , setDashboard } = (0, _context.useDashboard)();
|
|
31
31
|
const [originalDashboard, setOriginalDashboard] = (0, _react.useState)(undefined);
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
setEditMode(false);
|
|
35
|
-
setUnsavedDashboardDialogIsOpen(false);
|
|
36
|
-
};
|
|
37
|
-
const cancelDashboard = ()=>{
|
|
32
|
+
const { openDiscardChangesConfirmationDialog , closeDiscardChangesConfirmationDialog } = (0, _context.useDiscardChangesConfirmationDialog)();
|
|
33
|
+
const handleDiscardChanges = ()=>{
|
|
38
34
|
// Reset to the original spec and exit edit mode
|
|
39
35
|
if (originalDashboard) {
|
|
40
36
|
setDashboard(originalDashboard);
|
|
41
37
|
}
|
|
42
|
-
setUnsavedDashboardDialogIsOpen(false);
|
|
43
38
|
setEditMode(false);
|
|
39
|
+
closeDiscardChangesConfirmationDialog();
|
|
44
40
|
};
|
|
45
41
|
const onEditButtonClick = ()=>{
|
|
46
42
|
setEditMode(true);
|
|
@@ -51,7 +47,14 @@ const DashboardApp = (props)=>{
|
|
|
51
47
|
if (JSON.stringify(dashboard) === JSON.stringify(originalDashboard)) {
|
|
52
48
|
setEditMode(false);
|
|
53
49
|
} else {
|
|
54
|
-
|
|
50
|
+
openDiscardChangesConfirmationDialog({
|
|
51
|
+
onDiscardChanges: ()=>{
|
|
52
|
+
handleDiscardChanges();
|
|
53
|
+
},
|
|
54
|
+
onCancel: ()=>{
|
|
55
|
+
closeDiscardChangesConfirmationDialog();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
55
58
|
}
|
|
56
59
|
};
|
|
57
60
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
@@ -67,6 +70,7 @@ const DashboardApp = (props)=>{
|
|
|
67
70
|
dashboardName: dashboardResource.metadata.name,
|
|
68
71
|
dashboardTitleComponent: dashboardTitleComponent,
|
|
69
72
|
initialVariableIsSticky: initialVariableIsSticky,
|
|
73
|
+
onSave: onSave,
|
|
70
74
|
isReadonly: isReadonly,
|
|
71
75
|
onEditButtonClick: onEditButtonClick,
|
|
72
76
|
onCancelButtonClick: onCancelButtonClick
|
|
@@ -84,11 +88,7 @@ const DashboardApp = (props)=>{
|
|
|
84
88
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.PanelGroupDialog, {}),
|
|
85
89
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.DeletePanelGroupDialog, {}),
|
|
86
90
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.DeletePanelDialog, {}),
|
|
87
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.
|
|
88
|
-
isOpen: isUnsavedDashboardDialogOpen,
|
|
89
|
-
onSave: saveDashboard,
|
|
90
|
-
onClose: cancelDashboard
|
|
91
|
-
})
|
|
91
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.DiscardChangesConfirmationDialog, {})
|
|
92
92
|
]
|
|
93
93
|
})
|
|
94
94
|
]
|
|
@@ -25,7 +25,7 @@ const _pluginSystem = require("@perses-dev/plugin-system");
|
|
|
25
25
|
const _context = require("../../context");
|
|
26
26
|
const _dashboardApp = require("./DashboardApp");
|
|
27
27
|
function ViewDashboard(props) {
|
|
28
|
-
const { dashboardResource , datasourceApi , dashboardTitleComponent , initialVariableIsSticky , isReadonly , sx , ...others } = props;
|
|
28
|
+
const { dashboardResource , datasourceApi , dashboardTitleComponent , onSave , initialVariableIsSticky , isReadonly , sx , ...others } = props;
|
|
29
29
|
const { spec } = dashboardResource;
|
|
30
30
|
var _duration;
|
|
31
31
|
const dashboardDuration = (_duration = spec.duration) !== null && _duration !== void 0 ? _duration : '1h';
|
|
@@ -56,6 +56,7 @@ function ViewDashboard(props) {
|
|
|
56
56
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_dashboardApp.DashboardApp, {
|
|
57
57
|
dashboardResource: dashboardResource,
|
|
58
58
|
dashboardTitleComponent: dashboardTitleComponent,
|
|
59
|
+
onSave: onSave,
|
|
59
60
|
initialVariableIsSticky: initialVariableIsSticky,
|
|
60
61
|
isReadonly: isReadonly
|
|
61
62
|
})
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { DashboardResource } from '@perses-dev/core';
|
|
2
3
|
export interface DashboardToolbarProps {
|
|
3
4
|
dashboardName: string;
|
|
4
5
|
dashboardTitleComponent?: JSX.Element;
|
|
@@ -6,6 +7,7 @@ export interface DashboardToolbarProps {
|
|
|
6
7
|
isReadonly: boolean;
|
|
7
8
|
onEditButtonClick: () => void;
|
|
8
9
|
onCancelButtonClick: () => void;
|
|
10
|
+
onSave?: (entity: DashboardResource) => Promise<DashboardResource>;
|
|
9
11
|
}
|
|
10
12
|
export declare const DashboardToolbar: (props: DashboardToolbarProps) => JSX.Element;
|
|
11
13
|
//# sourceMappingURL=DashboardToolbar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/DashboardToolbar/DashboardToolbar.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"DashboardToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/DashboardToolbar/DashboardToolbar.tsx"],"names":[],"mappings":";AAkBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAOrD,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,uBAAuB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACtC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACpE;AAED,eAAO,MAAM,gBAAgB,UAAW,qBAAqB,gBA0H5D,CAAC"}
|
|
@@ -16,21 +16,34 @@ import PencilIcon from 'mdi-material-ui/PencilOutline';
|
|
|
16
16
|
import AddPanelGroupIcon from 'mdi-material-ui/PlusBoxOutline';
|
|
17
17
|
import AddPanelIcon from 'mdi-material-ui/ChartBoxPlusOutline';
|
|
18
18
|
import { ErrorBoundary, ErrorAlert } from '@perses-dev/components';
|
|
19
|
-
import {
|
|
19
|
+
import { useState } from 'react';
|
|
20
|
+
import { useDashboard, useDashboardActions, useEditMode } from '../../context';
|
|
20
21
|
import { TemplateVariableList } from '../Variables';
|
|
21
22
|
import { TimeRangeControls } from '../TimeRangeControls';
|
|
22
23
|
import { DownloadButton } from '../DownloadButton';
|
|
23
24
|
export const DashboardToolbar = (props)=>{
|
|
24
|
-
const { dashboardName , dashboardTitleComponent , initialVariableIsSticky , isReadonly , onEditButtonClick , onCancelButtonClick , } = props;
|
|
25
|
+
const { dashboardName , dashboardTitleComponent , initialVariableIsSticky , isReadonly , onEditButtonClick , onCancelButtonClick , onSave , } = props;
|
|
25
26
|
const { isEditMode , setEditMode } = useEditMode();
|
|
27
|
+
const [isSavingDashboard, setSavingDashboard] = useState(false);
|
|
28
|
+
const dashboard = useDashboard();
|
|
26
29
|
const { openAddPanelGroup , openAddPanel } = useDashboardActions();
|
|
27
30
|
const isLaptopSize = useMediaQuery(useTheme().breakpoints.up('sm'));
|
|
28
31
|
const dashboardTitle = dashboardTitleComponent ? dashboardTitleComponent : /*#__PURE__*/ _jsx(Typography, {
|
|
29
32
|
variant: "h2",
|
|
30
33
|
children: dashboardName
|
|
31
34
|
});
|
|
32
|
-
const
|
|
33
|
-
|
|
35
|
+
const onSaveButtonClick = ()=>{
|
|
36
|
+
if (onSave !== undefined) {
|
|
37
|
+
setSavingDashboard(true);
|
|
38
|
+
onSave(dashboard.dashboard).then(()=>{
|
|
39
|
+
setSavingDashboard(false);
|
|
40
|
+
setEditMode(false);
|
|
41
|
+
}).catch(()=>{
|
|
42
|
+
setSavingDashboard(false);
|
|
43
|
+
});
|
|
44
|
+
} else {
|
|
45
|
+
setEditMode(false);
|
|
46
|
+
}
|
|
34
47
|
};
|
|
35
48
|
return /*#__PURE__*/ _jsx(_Fragment, {
|
|
36
49
|
children: isEditMode ? /*#__PURE__*/ _jsxs(Stack, {
|
|
@@ -59,8 +72,8 @@ export const DashboardToolbar = (props)=>{
|
|
|
59
72
|
}),
|
|
60
73
|
/*#__PURE__*/ _jsx(Button, {
|
|
61
74
|
variant: "contained",
|
|
62
|
-
onClick:
|
|
63
|
-
disabled: isReadonly,
|
|
75
|
+
onClick: onSaveButtonClick,
|
|
76
|
+
disabled: isReadonly || isSavingDashboard,
|
|
64
77
|
children: "Save"
|
|
65
78
|
}),
|
|
66
79
|
/*#__PURE__*/ _jsx(Button, {
|
|
@@ -134,6 +147,7 @@ export const DashboardToolbar = (props)=>{
|
|
|
134
147
|
/*#__PURE__*/ _jsx(DownloadButton, {}),
|
|
135
148
|
isLaptopSize && /*#__PURE__*/ _jsx(Button, {
|
|
136
149
|
variant: "outlined",
|
|
150
|
+
color: "secondary",
|
|
137
151
|
startIcon: /*#__PURE__*/ _jsx(PencilIcon, {}),
|
|
138
152
|
onClick: onEditButtonClick,
|
|
139
153
|
sx: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/DashboardToolbar/DashboardToolbar.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Typography, Stack, Button, Box, useTheme, useMediaQuery, Alert } from '@mui/material';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport AddPanelGroupIcon from 'mdi-material-ui/PlusBoxOutline';\nimport AddPanelIcon from 'mdi-material-ui/ChartBoxPlusOutline';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { useDashboardActions, useEditMode } from '../../context';\nimport { TemplateVariableList } from '../Variables';\nimport { TimeRangeControls } from '../TimeRangeControls';\nimport { DownloadButton } from '../DownloadButton';\n\nexport interface DashboardToolbarProps {\n dashboardName: string;\n dashboardTitleComponent?: JSX.Element;\n initialVariableIsSticky?: boolean;\n isReadonly: boolean;\n onEditButtonClick: () => void;\n onCancelButtonClick: () => void;\n}\n\nexport const DashboardToolbar = (props: DashboardToolbarProps) => {\n const {\n dashboardName,\n dashboardTitleComponent,\n initialVariableIsSticky,\n isReadonly,\n onEditButtonClick,\n onCancelButtonClick,\n } = props;\n\n const { isEditMode, setEditMode } = useEditMode();\n const { openAddPanelGroup, openAddPanel } = useDashboardActions();\n const isLaptopSize = useMediaQuery(useTheme().breakpoints.up('sm'));\n const dashboardTitle = dashboardTitleComponent ? (\n dashboardTitleComponent\n ) : (\n <Typography variant=\"h2\">{dashboardName}</Typography>\n );\n\n const onSave = () => {\n setEditMode(false);\n };\n\n return (\n <>\n {isEditMode ? (\n <Stack spacing={1}>\n <Box p={2} display=\"flex\" sx={{ backgroundColor: (theme) => theme.palette.primary.main + '30' }}>\n {dashboardTitle}\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\">\n {isReadonly && (\n <Alert severity={'warning'} sx={{ backgroundColor: 'transparent', padding: 0 }}>\n Dashboard managed via code only. Download JSON and commit changes to save.\n </Alert>\n )}\n <Button variant=\"contained\" onClick={onSave} disabled={isReadonly}>\n Save\n </Button>\n <Button variant=\"outlined\" onClick={onCancelButtonClick}>\n Cancel\n </Button>\n </Stack>\n </Box>\n <Box\n sx={{\n display: 'flex',\n width: '100%',\n alignItems: 'flex-start',\n padding: (theme) => theme.spacing(0, 2, 2, 2),\n }}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <TemplateVariableList\n initialVariableIsSticky={initialVariableIsSticky}\n sx={{\n backgroundColor: ({ palette }) =>\n palette.mode === 'dark' ? palette.background.default : palette.background.paper,\n }}\n />\n </ErrorBoundary>\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\" sx={{ whiteSpace: 'nowrap' }}>\n <Button startIcon={<AddPanelGroupIcon />} onClick={openAddPanelGroup}>\n Add Panel Group\n </Button>\n <Button startIcon={<AddPanelIcon />} onClick={openAddPanel}>\n Add Panel\n </Button>\n <TimeRangeControls />\n <DownloadButton />\n </Stack>\n </Box>\n </Stack>\n ) : (\n <Stack spacing={1} padding={2}>\n <Box sx={{ display: 'flex', width: '100%' }}>\n {dashboardTitle}\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\">\n <TimeRangeControls />\n <DownloadButton />\n {isLaptopSize && (\n <Button\n variant=\"outlined\"\n startIcon={<PencilIcon />}\n onClick={onEditButtonClick}\n sx={{ marginLeft: 'auto' }}\n >\n Edit\n </Button>\n )}\n </Stack>\n </Box>\n <Box paddingY={2}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <TemplateVariableList\n initialVariableIsSticky={initialVariableIsSticky}\n sx={{\n backgroundColor: ({ palette }) =>\n palette.mode === 'dark' ? palette.background.default : palette.background.paper,\n }}\n />\n </ErrorBoundary>\n </Box>\n </Stack>\n )}\n </>\n );\n};\n"],"names":["Typography","Stack","Button","Box","useTheme","useMediaQuery","Alert","PencilIcon","AddPanelGroupIcon","AddPanelIcon","ErrorBoundary","ErrorAlert","useDashboardActions","useEditMode","TemplateVariableList","TimeRangeControls","DownloadButton","DashboardToolbar","props","dashboardName","dashboardTitleComponent","initialVariableIsSticky","isReadonly","onEditButtonClick","onCancelButtonClick","isEditMode","setEditMode","openAddPanelGroup","openAddPanel","isLaptopSize","breakpoints","up","dashboardTitle","variant","onSave","spacing","p","display","sx","backgroundColor","theme","palette","primary","main","direction","marginLeft","severity","padding","onClick","disabled","width","alignItems","FallbackComponent","mode","background","default","paper","whiteSpace","startIcon","paddingY"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC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oBAAoB;4BACnBO,uBAAuB,EAAEA,uBAAuB;4BAChDiB,EAAE,EAAE;gCACFC,eAAe,EAAE,CAAC,EAAEE,OAAO,CAAA,EAAE,GAC3BA,OAAO,CAACY,IAAI,KAAK,MAAM,GAAGZ,OAAO,CAACa,UAAU,CAACC,OAAO,GAAGd,OAAO,CAACa,UAAU,CAACE,KAAK;6BAClF;0BACD;sBACY;kBACZ;;UACA,AACT;MACA,CACH;AACJ,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/DashboardToolbar/DashboardToolbar.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Typography, Stack, Button, Box, useTheme, useMediaQuery, Alert } from '@mui/material';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport AddPanelGroupIcon from 'mdi-material-ui/PlusBoxOutline';\nimport AddPanelIcon from 'mdi-material-ui/ChartBoxPlusOutline';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { DashboardResource } from '@perses-dev/core';\nimport { useState } from 'react';\nimport { useDashboard, useDashboardActions, useEditMode } from '../../context';\nimport { TemplateVariableList } from '../Variables';\nimport { TimeRangeControls } from '../TimeRangeControls';\nimport { DownloadButton } from '../DownloadButton';\n\nexport interface DashboardToolbarProps {\n dashboardName: string;\n dashboardTitleComponent?: JSX.Element;\n initialVariableIsSticky?: boolean;\n isReadonly: boolean;\n onEditButtonClick: () => void;\n onCancelButtonClick: () => void;\n onSave?: (entity: DashboardResource) => Promise<DashboardResource>;\n}\n\nexport const DashboardToolbar = (props: DashboardToolbarProps) => {\n const {\n dashboardName,\n dashboardTitleComponent,\n initialVariableIsSticky,\n isReadonly,\n onEditButtonClick,\n onCancelButtonClick,\n onSave,\n } = props;\n\n const { isEditMode, setEditMode } = useEditMode();\n const [isSavingDashboard, setSavingDashboard] = useState<boolean>(false);\n const dashboard = useDashboard();\n const { openAddPanelGroup, openAddPanel } = useDashboardActions();\n const isLaptopSize = useMediaQuery(useTheme().breakpoints.up('sm'));\n const dashboardTitle = dashboardTitleComponent ? (\n dashboardTitleComponent\n ) : (\n <Typography variant=\"h2\">{dashboardName}</Typography>\n );\n\n const onSaveButtonClick = () => {\n if (onSave !== undefined) {\n setSavingDashboard(true);\n onSave(dashboard.dashboard)\n .then(() => {\n setSavingDashboard(false);\n setEditMode(false);\n })\n .catch(() => {\n setSavingDashboard(false);\n });\n } else {\n setEditMode(false);\n }\n };\n\n return (\n <>\n {isEditMode ? (\n <Stack spacing={1}>\n <Box p={2} display=\"flex\" sx={{ backgroundColor: (theme) => theme.palette.primary.main + '30' }}>\n {dashboardTitle}\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\">\n {isReadonly && (\n <Alert severity={'warning'} sx={{ backgroundColor: 'transparent', padding: 0 }}>\n Dashboard managed via code only. Download JSON and commit changes to save.\n </Alert>\n )}\n <Button variant=\"contained\" onClick={onSaveButtonClick} disabled={isReadonly || isSavingDashboard}>\n Save\n </Button>\n <Button variant=\"outlined\" onClick={onCancelButtonClick}>\n Cancel\n </Button>\n </Stack>\n </Box>\n <Box\n sx={{\n display: 'flex',\n width: '100%',\n alignItems: 'flex-start',\n padding: (theme) => theme.spacing(0, 2, 2, 2),\n }}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <TemplateVariableList\n initialVariableIsSticky={initialVariableIsSticky}\n sx={{\n backgroundColor: ({ palette }) =>\n palette.mode === 'dark' ? palette.background.default : palette.background.paper,\n }}\n />\n </ErrorBoundary>\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\" sx={{ whiteSpace: 'nowrap' }}>\n <Button startIcon={<AddPanelGroupIcon />} onClick={openAddPanelGroup}>\n Add Panel Group\n </Button>\n <Button startIcon={<AddPanelIcon />} onClick={openAddPanel}>\n Add Panel\n </Button>\n <TimeRangeControls />\n <DownloadButton />\n </Stack>\n </Box>\n </Stack>\n ) : (\n <Stack spacing={1} padding={2}>\n <Box sx={{ display: 'flex', width: '100%' }}>\n {dashboardTitle}\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\">\n <TimeRangeControls />\n <DownloadButton />\n {isLaptopSize && (\n <Button\n variant=\"outlined\"\n color=\"secondary\"\n startIcon={<PencilIcon />}\n onClick={onEditButtonClick}\n sx={{ marginLeft: 'auto' }}\n >\n Edit\n </Button>\n )}\n </Stack>\n </Box>\n <Box paddingY={2}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <TemplateVariableList\n initialVariableIsSticky={initialVariableIsSticky}\n sx={{\n backgroundColor: ({ palette }) =>\n palette.mode === 'dark' ? palette.background.default : palette.background.paper,\n }}\n />\n </ErrorBoundary>\n </Box>\n </Stack>\n )}\n </>\n );\n};\n"],"names":["Typography","Stack","Button","Box","useTheme","useMediaQuery","Alert","PencilIcon","AddPanelGroupIcon","AddPanelIcon","ErrorBoundary","ErrorAlert","useState","useDashboard","useDashboardActions","useEditMode","TemplateVariableList","TimeRangeControls","DownloadButton","DashboardToolbar","props","dashboardName","dashboardTitleComponent","initialVariableIsSticky","isReadonly","onEditButtonClick","onCancelButtonClick","onSave","isEditMode","setEditMode","isSavingDashboard","setSavingDashboard","dashboard","openAddPanelGroup","openAddPanel","isLaptopSize","breakpoints","up","dashboardTitle","variant","onSaveButtonClick","undefined","then","catch","spacing","p","display","sx","backgroundColor","theme","palette","primary","main","direction","marginLeft","severity","padding","onClick","disabled","width","alignItems","FallbackComponent","mode","background","default","paper","whiteSpace","startIcon","color","paddingY"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,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AACjB,KAAK;YAAC2C,OAAO,EAAE,CAAC;YAAEY,OAAO,EAAE,CAAC;;8BAC3B,MAACrD,GAAG;oBAAC4C,EAAE,EAAE;wBAAED,OAAO,EAAE,MAAM;wBAAEa,KAAK,EAAE,MAAM;qBAAE;;wBACxCrB,cAAc;sCACf,MAACrC,KAAK;4BAACoD,SAAS,EAAC,KAAK;4BAACT,OAAO,EAAE,CAAC;4BAAEU,UAAU,EAAC,MAAM;;8CAClD,KAACrC,iBAAiB,KAAG;8CACrB,KAACC,cAAc,KAAG;gCACjBiB,YAAY,kBACX,KAACjC,MAAM;oCACLqC,OAAO,EAAC,UAAU;oCAClB6B,KAAK,EAAC,WAAW;oCACjBD,SAAS,gBAAE,KAAC5D,UAAU,KAAG;oCACzBkD,OAAO,EAAEhC,iBAAiB;oCAC1BsB,EAAE,EAAE;wCAAEO,UAAU,EAAE,MAAM;qCAAE;8CAC3B,MAED;kCAAS,AACV;;0BACK;;kBACJ;8BACN,KAACnD,GAAG;oBAACkE,QAAQ,EAAE,CAAC;8BACd,cAAA,KAAC3D,aAAa;wBAACmD,iBAAiB,EAAElD,UAAU;kCAC1C,cAAA,KAACK,oBAAoB;4BACnBO,uBAAuB,EAAEA,uBAAuB;4BAChDwB,EAAE,EAAE;gCACFC,eAAe,EAAE,CAAC,EAAEE,OAAO,CAAA,EAAE,GAC3BA,OAAO,CAACY,IAAI,KAAK,MAAM,GAAGZ,OAAO,CAACa,UAAU,CAACC,OAAO,GAAGd,OAAO,CAACa,UAAU,CAACE,KAAK;6BAClF;0BACD;sBACY;kBACZ;;UACA,AACT;MACA,CACH;AACJ,CAAC,CAAC"}
|
|
@@ -50,6 +50,7 @@ const DeletePanelForm = ({ deletePanelDialog })=>{
|
|
|
50
50
|
onSubmit: handleDelete,
|
|
51
51
|
children: [
|
|
52
52
|
/*#__PURE__*/ _jsxs(DialogContent, {
|
|
53
|
+
dividers: true,
|
|
53
54
|
sx: {
|
|
54
55
|
width: '500px'
|
|
55
56
|
},
|
|
@@ -69,6 +70,7 @@ const DeletePanelForm = ({ deletePanelDialog })=>{
|
|
|
69
70
|
children: "Delete"
|
|
70
71
|
}),
|
|
71
72
|
/*#__PURE__*/ _jsx(Button, {
|
|
73
|
+
variant: "outlined",
|
|
72
74
|
onClick: ()=>closeDeletePanelDialog(),
|
|
73
75
|
children: "Cancel"
|
|
74
76
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/DeletePanelDialog/DeletePanelDialog.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FormEvent } from 'react';\nimport { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { useDeletePanelDialog, DeletePanelDialogState } from '../../context';\n\nexport const DeletePanelDialog = () => {\n const { deletePanelDialog, closeDeletePanelDialog } = useDeletePanelDialog();\n\n return (\n <Dialog open={deletePanelDialog !== undefined}>\n <DialogTitle>Delete Panel</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={() => closeDeletePanelDialog()}\n sx={(theme) => ({\n position: 'absolute',\n top: theme.spacing(0.5),\n right: theme.spacing(0.5),\n })}\n >\n <CloseIcon />\n </IconButton>\n {deletePanelDialog && <DeletePanelForm deletePanelDialog={deletePanelDialog} />}\n </Dialog>\n );\n};\n\ninterface DeletePanelFormProps {\n deletePanelDialog: DeletePanelDialogState;\n}\n\nconst DeletePanelForm = ({ deletePanelDialog }: DeletePanelFormProps) => {\n const { deletePanel, closeDeletePanelDialog } = useDeletePanelDialog();\n\n const handleDelete = (e: FormEvent) => {\n e.preventDefault();\n const { panelGroupItemId } = deletePanelDialog;\n deletePanel(panelGroupItemId);\n closeDeletePanelDialog();\n };\n return (\n <form onSubmit={handleDelete}>\n <DialogContent sx={{ width: '500px' }}>\n Are you sure you want to delete {deletePanelDialog.panelName} from {deletePanelDialog.panelGroupName}? This\n action cannot be undone.\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" type=\"submit\">\n Delete\n </Button>\n <Button onClick={() => closeDeletePanelDialog()}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/DeletePanelDialog/DeletePanelDialog.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FormEvent } from 'react';\nimport { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { useDeletePanelDialog, DeletePanelDialogState } from '../../context';\n\nexport const DeletePanelDialog = () => {\n const { deletePanelDialog, closeDeletePanelDialog } = useDeletePanelDialog();\n\n return (\n <Dialog open={deletePanelDialog !== undefined}>\n <DialogTitle>Delete Panel</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={() => closeDeletePanelDialog()}\n sx={(theme) => ({\n position: 'absolute',\n top: theme.spacing(0.5),\n right: theme.spacing(0.5),\n })}\n >\n <CloseIcon />\n </IconButton>\n {deletePanelDialog && <DeletePanelForm deletePanelDialog={deletePanelDialog} />}\n </Dialog>\n );\n};\n\ninterface DeletePanelFormProps {\n deletePanelDialog: DeletePanelDialogState;\n}\n\nconst DeletePanelForm = ({ deletePanelDialog }: DeletePanelFormProps) => {\n const { deletePanel, closeDeletePanelDialog } = useDeletePanelDialog();\n\n const handleDelete = (e: FormEvent) => {\n e.preventDefault();\n const { panelGroupItemId } = deletePanelDialog;\n deletePanel(panelGroupItemId);\n closeDeletePanelDialog();\n };\n return (\n <form onSubmit={handleDelete}>\n <DialogContent dividers sx={{ width: '500px' }}>\n Are you sure you want to delete {deletePanelDialog.panelName} from {deletePanelDialog.panelGroupName}? This\n action cannot be undone.\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" type=\"submit\">\n Delete\n </Button>\n <Button variant=\"outlined\" onClick={() => closeDeletePanelDialog()}>\n Cancel\n </Button>\n </DialogActions>\n </form>\n );\n};\n"],"names":["IconButton","Dialog","DialogTitle","DialogContent","DialogActions","Button","CloseIcon","useDeletePanelDialog","DeletePanelDialog","deletePanelDialog","closeDeletePanelDialog","open","undefined","aria-label","onClick","sx","theme","position","top","spacing","right","DeletePanelForm","deletePanel","handleDelete","e","preventDefault","panelGroupItemId","form","onSubmit","dividers","width","panelName","panelGroupName","variant","type"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AACA,SAASA,UAAU,EAAEC,MAAM,EAAEC,WAAW,EAAEC,aAAa,EAAEC,aAAa,EAAEC,MAAM,QAAQ,eAAe,CAAC;AACtG,OAAOC,SAAS,MAAM,uBAAuB,CAAC;AAC9C,SAASC,oBAAoB,QAAgC,eAAe,CAAC;AAE7E,OAAO,MAAMC,iBAAiB,GAAG,IAAM;IACrC,MAAM,EAAEC,iBAAiB,CAAA,EAAEC,sBAAsB,CAAA,EAAE,GAAGH,oBAAoB,EAAE,AAAC;IAE7E,qBACE,MAACN,MAAM;QAACU,IAAI,EAAEF,iBAAiB,KAAKG,SAAS;;0BAC3C,KA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T,KAAC7B,MAAM;wBAAC4B,OAAO,EAAC,UAAU;wBAACnB,OAAO,EAAE,IAAMJ,sBAAsB,EAAE;kCAAE,QAEpE;sBAAS;;cACK;;MACX,CACP;AACJ,CAAC,AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeletePanelGroupDialog.d.ts","sourceRoot":"","sources":["../../../src/components/DeletePanelGroupDialog/DeletePanelGroupDialog.tsx"],"names":[],"mappings":";AAkBA,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"DeletePanelGroupDialog.d.ts","sourceRoot":"","sources":["../../../src/components/DeletePanelGroupDialog/DeletePanelGroupDialog.tsx"],"names":[],"mappings":";AAkBA,eAAO,MAAM,sBAAsB,mBA4ClC,CAAC"}
|
|
@@ -46,6 +46,7 @@ export const DeletePanelGroupDialog = ()=>{
|
|
|
46
46
|
onSubmit: handleDelete,
|
|
47
47
|
children: [
|
|
48
48
|
/*#__PURE__*/ _jsxs(DialogContent, {
|
|
49
|
+
dividers: true,
|
|
49
50
|
sx: {
|
|
50
51
|
width: '500px'
|
|
51
52
|
},
|
|
@@ -63,6 +64,7 @@ export const DeletePanelGroupDialog = ()=>{
|
|
|
63
64
|
children: "Delete"
|
|
64
65
|
}),
|
|
65
66
|
/*#__PURE__*/ _jsx(Button, {
|
|
67
|
+
variant: "outlined",
|
|
66
68
|
onClick: ()=>closeDeletePanelGroupDialog(),
|
|
67
69
|
children: "Cancel"
|
|
68
70
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/DeletePanelGroupDialog/DeletePanelGroupDialog.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FormEvent } from 'react';\nimport { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { useDeletePanelGroupDialog } from '../../context';\n\nexport const DeletePanelGroupDialog = () => {\n const { deletePanelGroupDialog, closeDeletePanelGroupDialog, deletePanelGroup } = useDeletePanelGroupDialog();\n\n const panelGroupId = deletePanelGroupDialog?.panelGroupId;\n\n const handleDelete = (e: FormEvent) => {\n e.preventDefault();\n if (panelGroupId == undefined) {\n throw new Error('group index is undefined');\n }\n deletePanelGroup(panelGroupId);\n closeDeletePanelGroupDialog();\n };\n\n return (\n <Dialog open={deletePanelGroupDialog !== undefined}>\n <DialogTitle>Delete Panel Group</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={() => closeDeletePanelGroupDialog()}\n sx={(theme) => ({\n position: 'absolute',\n top: theme.spacing(0.5),\n right: theme.spacing(0.5),\n })}\n >\n <CloseIcon />\n </IconButton>\n <form onSubmit={handleDelete}>\n <DialogContent sx={{ width: '500px' }}>\n Are you sure you want to delete {deletePanelGroupDialog?.panelGroupName ?? 'panel group'}? This will delete\n all the panels within the group.\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" type=\"submit\">\n Delete\n </Button>\n <Button onClick={() => closeDeletePanelGroupDialog()}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/DeletePanelGroupDialog/DeletePanelGroupDialog.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FormEvent } from 'react';\nimport { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { useDeletePanelGroupDialog } from '../../context';\n\nexport const DeletePanelGroupDialog = () => {\n const { deletePanelGroupDialog, closeDeletePanelGroupDialog, deletePanelGroup } = useDeletePanelGroupDialog();\n\n const panelGroupId = deletePanelGroupDialog?.panelGroupId;\n\n const handleDelete = (e: FormEvent) => {\n e.preventDefault();\n if (panelGroupId == undefined) {\n throw new Error('group index is undefined');\n }\n deletePanelGroup(panelGroupId);\n closeDeletePanelGroupDialog();\n };\n\n return (\n <Dialog open={deletePanelGroupDialog !== undefined}>\n <DialogTitle>Delete Panel Group</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={() => closeDeletePanelGroupDialog()}\n sx={(theme) => ({\n position: 'absolute',\n top: theme.spacing(0.5),\n right: theme.spacing(0.5),\n })}\n >\n <CloseIcon />\n </IconButton>\n <form onSubmit={handleDelete}>\n <DialogContent dividers sx={{ width: '500px' }}>\n Are you sure you want to delete {deletePanelGroupDialog?.panelGroupName ?? 'panel group'}? This will delete\n all the panels within the group.\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" type=\"submit\">\n Delete\n </Button>\n <Button variant=\"outlined\" onClick={() => closeDeletePanelGroupDialog()}>\n Cancel\n </Button>\n </DialogActions>\n </form>\n </Dialog>\n );\n};\n"],"names":["IconButton","Dialog","DialogTitle","DialogContent","DialogActions","Button","CloseIcon","useDeletePanelGroupDialog","DeletePanelGroupDialog","deletePanelGroupDialog","closeDeletePanelGroupDialog","deletePanelGroup","panelGroupId","handleDelete","e","preventDefault","undefined","Error","open","aria-label","onClick","sx","theme","position","top","spacing","right","form","onSubmit","dividers","width","panelGroupName","variant","type"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,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AA,KAACnB,SAAS,KAAG;cACF;0BACb,MAACqB,MAAI;gBAACC,QAAQ,EAAEf,YAAY;;kCAC1B,MAACV,aAAa;wBAAC0B,QAAQ;wBAACR,EAAE,EAAE;4BAAES,KAAK,EAAE,OAAO;yBAAE;;4BAAE,kCACd;4BAACrB,CAAAA,GAAsC,GAAtCA,sBAAsB,aAAtBA,sBAAsB,WAAgB,GAAtCA,KAAAA,CAAsC,GAAtCA,sBAAsB,CAAEsB,cAAc,cAAtCtB,GAAsC,cAAtCA,GAAsC,GAAI,aAAa;4BAAC,qDAE3F;;sBAAgB;kCAChB,MAACL,aAAa;;0CACZ,KAACC,MAAM;gCAAC2B,OAAO,EAAC,WAAW;gCAACC,IAAI,EAAC,QAAQ;0CAAC,QAE1C;8BAAS;0CACT,KAAC5B,MAAM;gCAAC2B,OAAO,EAAC,UAAU;gCAACZ,OAAO,EAAE,IAAMV,2BAA2B,EAAE;0CAAE,QAEzE;8BAAS;;sBACK;;cACX;;MACA,CACT;AACJ,CAAC,CAAC"}
|
package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DiscardChangesConfirmationDialog.d.ts","sourceRoot":"","sources":["../../../src/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.tsx"],"names":[],"mappings":";AAiBA,eAAO,MAAM,gCAAgC,mBAoC5C,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
+
import { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';
|
|
15
|
+
import CloseIcon from 'mdi-material-ui/Close';
|
|
16
|
+
import { useDiscardChangesConfirmationDialog } from '../../context';
|
|
17
|
+
export const DiscardChangesConfirmationDialog = ()=>{
|
|
18
|
+
const { discardChangesConfirmationDialog: dialog } = useDiscardChangesConfirmationDialog();
|
|
19
|
+
const isOpen = dialog !== undefined;
|
|
20
|
+
return /*#__PURE__*/ _jsx(Dialog, {
|
|
21
|
+
open: isOpen,
|
|
22
|
+
children: dialog !== undefined && /*#__PURE__*/ _jsxs(_Fragment, {
|
|
23
|
+
children: [
|
|
24
|
+
/*#__PURE__*/ _jsx(DialogTitle, {
|
|
25
|
+
children: "Discard Changes"
|
|
26
|
+
}),
|
|
27
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
28
|
+
"aria-label": "Close",
|
|
29
|
+
onClick: dialog.onCancel,
|
|
30
|
+
sx: (theme)=>({
|
|
31
|
+
position: 'absolute',
|
|
32
|
+
top: theme.spacing(0.5),
|
|
33
|
+
right: theme.spacing(0.5)
|
|
34
|
+
}),
|
|
35
|
+
children: /*#__PURE__*/ _jsx(CloseIcon, {})
|
|
36
|
+
}),
|
|
37
|
+
/*#__PURE__*/ _jsx(DialogContent, {
|
|
38
|
+
dividers: true,
|
|
39
|
+
sx: {
|
|
40
|
+
width: '500px'
|
|
41
|
+
},
|
|
42
|
+
children: dialog.description || 'You have unsaved changes in this dashboard. Are you sure you want to discard these changes? Changes cannot be recovered.'
|
|
43
|
+
}),
|
|
44
|
+
/*#__PURE__*/ _jsxs(DialogActions, {
|
|
45
|
+
children: [
|
|
46
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
47
|
+
variant: "contained",
|
|
48
|
+
onClick: dialog.onDiscardChanges,
|
|
49
|
+
children: "Discard Changes"
|
|
50
|
+
}),
|
|
51
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
52
|
+
variant: "outlined",
|
|
53
|
+
onClick: dialog.onCancel,
|
|
54
|
+
children: "Cancel"
|
|
55
|
+
})
|
|
56
|
+
]
|
|
57
|
+
})
|
|
58
|
+
]
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=DiscardChangesConfirmationDialog.js.map
|
package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { useDiscardChangesConfirmationDialog } from '../../context';\n\nexport const DiscardChangesConfirmationDialog = () => {\n const { discardChangesConfirmationDialog: dialog } = useDiscardChangesConfirmationDialog();\n const isOpen = dialog !== undefined;\n\n return (\n <Dialog open={isOpen}>\n {dialog !== undefined && (\n <>\n <DialogTitle>Discard Changes</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={dialog.onCancel}\n sx={(theme) => ({\n position: 'absolute',\n top: theme.spacing(0.5),\n right: theme.spacing(0.5),\n })}\n >\n <CloseIcon />\n </IconButton>\n <DialogContent dividers sx={{ width: '500px' }}>\n {dialog.description ||\n 'You have unsaved changes in this dashboard. Are you sure you want to discard these changes? Changes cannot be recovered.'}\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" onClick={dialog.onDiscardChanges}>\n Discard Changes\n </Button>\n <Button variant=\"outlined\" onClick={dialog.onCancel}>\n Cancel\n </Button>\n </DialogActions>\n </>\n )}\n </Dialog>\n );\n};\n"],"names":["IconButton","Dialog","DialogTitle","DialogContent","DialogActions","Button","CloseIcon","useDiscardChangesConfirmationDialog","DiscardChangesConfirmationDialog","discardChangesConfirmationDialog","dialog","isOpen","undefined","open","aria-label","onClick","onCancel","sx","theme","position","top","spacing","right","dividers","width","description","variant","onDiscardChanges"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,UAAU,EAAEC,MAAM,EAAEC,WAAW,EAAEC,aAAa,EAAEC,aAAa,EAAEC,MAAM,QAAQ,eAAe,CAAC;AACtG,OAAOC,SAAS,MAAM,uBAAuB,CAAC;AAC9C,SAASC,mCAAmC,QAAQ,eAAe,CAAC;AAEpE,OAAO,MAAMC,gCAAgC,GAAG,IAAM;IACpD,MAAM,EAAEC,gCAAgC,EAAEC,MAAM,CAAA,EAAE,GAAGH,mCAAmC,EAAE,AAAC;IAC3F,MAAMI,MAAM,GAAGD,MAAM,KAAKE,SAAS,AAAC;IAEpC,qBACE,KAACX,MAAM;QAACY,IAAI,EAAEF,MAAM;kBACjBD,MAAM,KAAKE,SAAS,kBACnB;;8BACE,KAACV,WAAW;8BAAC,iBAAe;kBAAc;8BAC1C,KAACF,UAAU;oBACTc,YAAU,EAAC,OAAO;oBAClBC,OAAO,EAAEL,MAAM,CAACM,QAAQ;oBACxBC,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;4BACdC,QAAQ,EAAE,UAAU;4BACpBC,GAAG,EAAEF,KAAK,CAACG,OAAO,CAAC,GAAG,CAAC;4BACvBC,KAAK,EAAEJ,KAAK,CAACG,OAAO,CAAC,GAAG,CAAC;yBAC1B,CAAA,AAAC;8BAEF,cAAA,KAACf,SAAS,KAAG;kBACF;8BACb,KAACH,aAAa;oBAACoB,QAAQ;oBAACN,EAAE,EAAE;wBAAEO,KAAK,EAAE,OAAO;qBAAE;8BAC3Cd,MAAM,CAACe,WAAW,IACjB,0HAA0H;kBAC9G;8BAChB,MAACrB,aAAa;;sCACZ,KAACC,MAAM;4BAACqB,OAAO,EAAC,WAAW;4BAACX,OAAO,EAAEL,MAAM,CAACiB,gBAAgB;sCAAE,iBAE9D;0BAAS;sCACT,KAACtB,MAAM;4BAACqB,OAAO,EAAC,UAAU;4BAACX,OAAO,EAAEL,MAAM,CAACM,QAAQ;sCAAE,QAErD;0BAAS;;kBACK;;UACf,AACJ;MACM,CACT;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DiscardChangesConfirmationDialog/index.ts"],"names":[],"mappings":"AAaA,cAAc,oCAAoC,CAAC"}
|
|
@@ -10,6 +10,6 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
export * from './
|
|
13
|
+
export * from './DiscardChangesConfirmationDialog';
|
|
14
14
|
|
|
15
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/
|
|
1
|
+
{"version":3,"sources":["../../../src/components/DiscardChangesConfirmationDialog/index.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './DiscardChangesConfirmationDialog';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,oCAAoC,CAAC"}
|