@perses-dev/dashboards 0.37.2 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Dashboard/Dashboard.js +3 -2
- package/dist/cjs/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +12 -52
- package/dist/cjs/components/GridLayout/GridItemContent.js +3 -1
- package/dist/cjs/components/GridLayout/GridLayout.js +1 -0
- package/dist/cjs/components/Panel/Panel.js +8 -3
- package/dist/cjs/components/Panel/PanelHeader.js +7 -3
- package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +3 -1
- package/dist/cjs/components/Variables/EditVariablesButton.js +2 -0
- package/dist/cjs/components/Variables/TemplateVariable.js +22 -18
- package/dist/cjs/components/Variables/VariableEditor.js +271 -99
- package/dist/cjs/components/Variables/VariableList.js +38 -18
- package/dist/cjs/components/Variables/index.js +0 -2
- package/dist/cjs/context/DatasourceStoreProvider.js +22 -18
- package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +71 -24
- package/dist/cjs/context/TemplateVariableProvider/hydrationUtils.js +55 -5
- package/dist/cjs/context/TemplateVariableProvider/utils.js +39 -7
- package/dist/cjs/test/render.js +1 -1
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +7 -2
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +4 -3
- package/dist/components/Dashboard/Dashboard.d.ts +3 -1
- package/dist/components/Dashboard/Dashboard.d.ts.map +1 -1
- package/dist/components/Dashboard/Dashboard.js +3 -2
- package/dist/components/Dashboard/Dashboard.js.map +1 -1
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts +1 -1
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts.map +1 -1
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +11 -46
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts +2 -0
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +3 -1
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.d.ts +2 -0
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +1 -0
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/Panel/Panel.d.ts +20 -0
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +8 -3
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/PanelHeader.d.ts +2 -1
- package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
- package/dist/components/Panel/PanelHeader.js +7 -3
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -1
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js +3 -1
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
- package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
- package/dist/components/Variables/EditVariablesButton.js +3 -1
- package/dist/components/Variables/EditVariablesButton.js.map +1 -1
- package/dist/components/Variables/TemplateVariable.d.ts +2 -1
- package/dist/components/Variables/TemplateVariable.d.ts.map +1 -1
- package/dist/components/Variables/TemplateVariable.js +21 -17
- package/dist/components/Variables/TemplateVariable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.d.ts +7 -0
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditor.js +261 -95
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableList.d.ts +5 -0
- package/dist/components/Variables/VariableList.d.ts.map +1 -1
- package/dist/components/Variables/VariableList.js +31 -17
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/components/Variables/index.d.ts +0 -2
- package/dist/components/Variables/index.d.ts.map +1 -1
- package/dist/components/Variables/index.js +0 -2
- package/dist/components/Variables/index.js.map +1 -1
- package/dist/context/DatasourceStoreProvider.d.ts +4 -3
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
- package/dist/context/DatasourceStoreProvider.js +22 -18
- package/dist/context/DatasourceStoreProvider.js.map +1 -1
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +39 -10
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +76 -27
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
- package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts +9 -2
- package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider/hydrationUtils.js +60 -5
- package/dist/context/TemplateVariableProvider/hydrationUtils.js.map +1 -1
- package/dist/context/TemplateVariableProvider/utils.d.ts +27 -2
- package/dist/context/TemplateVariableProvider/utils.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider/utils.js +46 -4
- package/dist/context/TemplateVariableProvider/utils.js.map +1 -1
- package/dist/test/render.js +2 -2
- package/dist/test/render.js.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +9 -4
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.d.ts +2 -1
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +4 -3
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/package.json +6 -6
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +0 -399
- package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +0 -178
- package/dist/cjs/components/Variables/VariableEditorForm/index.js +0 -29
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +0 -91
- package/dist/cjs/components/Variables/variable-model.js +0 -117
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +0 -10
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +0 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +0 -354
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +0 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +0 -16
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +0 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js +0 -122
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +0 -1
- package/dist/components/Variables/VariableEditorForm/index.d.ts +0 -3
- package/dist/components/Variables/VariableEditorForm/index.d.ts.map +0 -1
- package/dist/components/Variables/VariableEditorForm/index.js +0 -16
- package/dist/components/Variables/VariableEditorForm/index.js.map +0 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +0 -23
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +0 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +0 -79
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +0 -1
- package/dist/components/Variables/variable-model.d.ts +0 -16
- package/dist/components/Variables/variable-model.d.ts.map +0 -1
- package/dist/components/Variables/variable-model.js +0 -105
- package/dist/components/Variables/variable-model.js.map +0 -1
|
@@ -21,10 +21,12 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
+
useTemplateVariableStoreCtx: ()=>useTemplateVariableStoreCtx,
|
|
24
25
|
useTemplateVariableValues: ()=>useTemplateVariableValues,
|
|
25
26
|
useTemplateVariable: ()=>useTemplateVariable,
|
|
26
27
|
useTemplateVariableActions: ()=>useTemplateVariableActions,
|
|
27
28
|
useTemplateVariableDefinitions: ()=>useTemplateVariableDefinitions,
|
|
29
|
+
useTemplateExternalVariableDefinitions: ()=>useTemplateExternalVariableDefinitions,
|
|
28
30
|
useTemplateVariableStore: ()=>useTemplateVariableStore,
|
|
29
31
|
TemplateVariableProvider: ()=>TemplateVariableProvider
|
|
30
32
|
});
|
|
@@ -54,29 +56,51 @@ function useTemplateVariableStoreCtx() {
|
|
|
54
56
|
}
|
|
55
57
|
function useTemplateVariableValues(variableNames) {
|
|
56
58
|
const store = useTemplateVariableStoreCtx();
|
|
57
|
-
|
|
58
|
-
const names = variableNames !== null && variableNames !== void 0 ? variableNames : Object.keys(s.variableState);
|
|
59
|
+
return (0, _zustand.useStore)(store, (s)=>{
|
|
59
60
|
const vars = {};
|
|
61
|
+
// Collect values of local variables, from the variable state
|
|
62
|
+
const names = variableNames !== null && variableNames !== void 0 ? variableNames : s.variableDefinitions.map((value)=>value.spec.name);
|
|
60
63
|
names.forEach((name)=>{
|
|
61
|
-
const varState = s.variableState
|
|
62
|
-
|
|
64
|
+
const varState = s.variableState.get({
|
|
65
|
+
name
|
|
66
|
+
});
|
|
67
|
+
if (!varState || varState.overridden) {
|
|
63
68
|
return;
|
|
64
69
|
}
|
|
65
70
|
vars[name] = varState;
|
|
66
71
|
});
|
|
72
|
+
// Collect values of external variables, from the variable state
|
|
73
|
+
s.externalVariableDefinitions.forEach((d)=>{
|
|
74
|
+
const source = d.source;
|
|
75
|
+
d.definitions.forEach((value)=>{
|
|
76
|
+
const name = value.spec.name;
|
|
77
|
+
const varState = s.variableState.get({
|
|
78
|
+
name,
|
|
79
|
+
source
|
|
80
|
+
});
|
|
81
|
+
if (!varState || varState.overridden) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
vars[name] = varState;
|
|
85
|
+
});
|
|
86
|
+
});
|
|
67
87
|
return vars;
|
|
68
88
|
}, (left, right)=>{
|
|
69
89
|
return JSON.stringify(left) === JSON.stringify(right);
|
|
70
90
|
});
|
|
71
|
-
return state;
|
|
72
91
|
}
|
|
73
|
-
function useTemplateVariable(name) {
|
|
92
|
+
function useTemplateVariable(name, source) {
|
|
74
93
|
const store = useTemplateVariableStoreCtx();
|
|
75
94
|
return (0, _zustand.useStore)(store, (s)=>{
|
|
76
|
-
|
|
77
|
-
const
|
|
95
|
+
var ref;
|
|
96
|
+
const state = s.variableState.get({
|
|
97
|
+
name,
|
|
98
|
+
source
|
|
99
|
+
});
|
|
100
|
+
const definitions = source ? (ref = s.externalVariableDefinitions.find((v)=>v.source === source)) === null || ref === void 0 ? void 0 : ref.definitions : s.variableDefinitions;
|
|
101
|
+
const definition = (definitions || []).find((v)=>v.spec.name === name);
|
|
78
102
|
return {
|
|
79
|
-
state
|
|
103
|
+
state,
|
|
80
104
|
definition
|
|
81
105
|
};
|
|
82
106
|
});
|
|
@@ -98,6 +122,10 @@ function useTemplateVariableDefinitions() {
|
|
|
98
122
|
const store = useTemplateVariableStoreCtx();
|
|
99
123
|
return (0, _zustand.useStore)(store, (s)=>s.variableDefinitions);
|
|
100
124
|
}
|
|
125
|
+
function useTemplateExternalVariableDefinitions() {
|
|
126
|
+
const store = useTemplateVariableStoreCtx();
|
|
127
|
+
return (0, _zustand.useStore)(store, (s)=>s.externalVariableDefinitions);
|
|
128
|
+
}
|
|
101
129
|
function useTemplateVariableStore() {
|
|
102
130
|
const store = useTemplateVariableStoreCtx();
|
|
103
131
|
return (0, _zustand.useStore)(store);
|
|
@@ -105,6 +133,7 @@ function useTemplateVariableStore() {
|
|
|
105
133
|
function PluginProvider({ children }) {
|
|
106
134
|
const originalValues = useTemplateVariableValues();
|
|
107
135
|
const definitions = useTemplateVariableDefinitions();
|
|
136
|
+
const externalDefinitions = useTemplateExternalVariableDefinitions();
|
|
108
137
|
const values = (0, _react.useMemo)(()=>{
|
|
109
138
|
const contextValues = {};
|
|
110
139
|
// This will loop through all the current variables values
|
|
@@ -115,7 +144,7 @@ function PluginProvider({ children }) {
|
|
|
115
144
|
...originalValues[name]
|
|
116
145
|
};
|
|
117
146
|
if (v.value === _core.DEFAULT_ALL_VALUE) {
|
|
118
|
-
const definition =
|
|
147
|
+
const definition = (0, _utils.findVariableDefinitionByName)(name, definitions, externalDefinitions);
|
|
119
148
|
// If the variable is a list variable and has a custom all value, then use that value instead
|
|
120
149
|
if ((definition === null || definition === void 0 ? void 0 : definition.kind) === 'ListVariable' && definition.spec.custom_all_value) {
|
|
121
150
|
v.value = definition.spec.custom_all_value;
|
|
@@ -130,7 +159,8 @@ function PluginProvider({ children }) {
|
|
|
130
159
|
return contextValues;
|
|
131
160
|
}, [
|
|
132
161
|
originalValues,
|
|
133
|
-
definitions
|
|
162
|
+
definitions,
|
|
163
|
+
externalDefinitions
|
|
134
164
|
]);
|
|
135
165
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.TemplateVariableContext.Provider, {
|
|
136
166
|
value: {
|
|
@@ -139,40 +169,50 @@ function PluginProvider({ children }) {
|
|
|
139
169
|
children: children
|
|
140
170
|
});
|
|
141
171
|
}
|
|
142
|
-
function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , queryParams }) {
|
|
172
|
+
function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , externalVariableDefinitions =[] , queryParams }) {
|
|
143
173
|
const initialParams = (0, _queryParams.getInitalValuesFromQueryParameters)(queryParams ? queryParams[0] : {});
|
|
144
174
|
const store = (0, _zustand.createStore)()((0, _middleware.devtools)((0, _immer.immer)((set, get)=>{
|
|
145
175
|
return {
|
|
146
|
-
variableState: (0, _hydrationUtils.hydrateTemplateVariableStates)(initialVariableDefinitions, initialParams),
|
|
176
|
+
variableState: (0, _hydrationUtils.hydrateTemplateVariableStates)(initialVariableDefinitions, initialParams, externalVariableDefinitions),
|
|
147
177
|
variableDefinitions: initialVariableDefinitions,
|
|
178
|
+
externalVariableDefinitions: externalVariableDefinitions,
|
|
148
179
|
setVariableDefinitions (definitions) {
|
|
149
180
|
set((state)=>{
|
|
150
181
|
state.variableDefinitions = definitions;
|
|
151
|
-
state.variableState = (0, _hydrationUtils.hydrateTemplateVariableStates)(definitions, initialParams);
|
|
182
|
+
state.variableState = (0, _hydrationUtils.hydrateTemplateVariableStates)(definitions, initialParams, externalVariableDefinitions);
|
|
152
183
|
}, false, '[Variables] setVariableDefinitions' // Used for action name in Redux devtools
|
|
153
184
|
);
|
|
154
185
|
},
|
|
155
|
-
setVariableOptions (name, options) {
|
|
186
|
+
setVariableOptions (name, options, source) {
|
|
156
187
|
set((state)=>{
|
|
157
|
-
const varState = state.variableState
|
|
188
|
+
const varState = state.variableState.get({
|
|
189
|
+
name,
|
|
190
|
+
source
|
|
191
|
+
});
|
|
158
192
|
if (!varState) {
|
|
159
193
|
return;
|
|
160
194
|
}
|
|
161
195
|
varState.options = options;
|
|
162
196
|
}, false, '[Variables] setVariableOptions');
|
|
163
197
|
},
|
|
164
|
-
setVariableLoading (name, loading) {
|
|
198
|
+
setVariableLoading (name, loading, source) {
|
|
165
199
|
set((state)=>{
|
|
166
|
-
const varState = state.variableState
|
|
200
|
+
const varState = state.variableState.get({
|
|
201
|
+
name,
|
|
202
|
+
source
|
|
203
|
+
});
|
|
167
204
|
if (!varState) {
|
|
168
205
|
return;
|
|
169
206
|
}
|
|
170
207
|
varState.loading = loading;
|
|
171
208
|
}, false, '[Variables] setVariableLoading');
|
|
172
209
|
},
|
|
173
|
-
setVariableValue: (name, value)=>set((state)=>{
|
|
210
|
+
setVariableValue: (name, value, source)=>set((state)=>{
|
|
174
211
|
let val = value;
|
|
175
|
-
const varState = state.variableState
|
|
212
|
+
const varState = state.variableState.get({
|
|
213
|
+
name,
|
|
214
|
+
source
|
|
215
|
+
});
|
|
176
216
|
if (!varState) {
|
|
177
217
|
return;
|
|
178
218
|
}
|
|
@@ -197,8 +237,11 @@ function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , query
|
|
|
197
237
|
const variableState = get().variableState;
|
|
198
238
|
const updatedVariables = (0, _immer1.default)(variableDefinitions, (draft)=>{
|
|
199
239
|
draft.forEach((variable, index)=>{
|
|
240
|
+
const name = variable.spec.name;
|
|
200
241
|
if (variable.kind === 'ListVariable') {
|
|
201
|
-
const currentVariable = variableState
|
|
242
|
+
const currentVariable = variableState.get({
|
|
243
|
+
name
|
|
244
|
+
});
|
|
202
245
|
if ((currentVariable === null || currentVariable === void 0 ? void 0 : currentVariable.value) !== undefined) {
|
|
203
246
|
draft[index] = {
|
|
204
247
|
kind: 'ListVariable',
|
|
@@ -208,7 +251,9 @@ function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , query
|
|
|
208
251
|
};
|
|
209
252
|
}
|
|
210
253
|
} else if (variable.kind === 'TextVariable') {
|
|
211
|
-
const currentVariable1 = variableState
|
|
254
|
+
const currentVariable1 = variableState.get({
|
|
255
|
+
name
|
|
256
|
+
});
|
|
212
257
|
const currentVariableValue = typeof (currentVariable1 === null || currentVariable1 === void 0 ? void 0 : currentVariable1.value) === 'string' ? currentVariable1.value : '';
|
|
213
258
|
if ((currentVariable1 === null || currentVariable1 === void 0 ? void 0 : currentVariable1.value) !== undefined) {
|
|
214
259
|
draft[index] = {
|
|
@@ -233,10 +278,12 @@ function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , query
|
|
|
233
278
|
})));
|
|
234
279
|
return store;
|
|
235
280
|
}
|
|
236
|
-
function TemplateVariableProvider({ children , initialVariableDefinitions =[] }) {
|
|
237
|
-
const
|
|
281
|
+
function TemplateVariableProvider({ children , initialVariableDefinitions =[] , externalVariableDefinitions =[] }) {
|
|
282
|
+
const allVariableDefs = (0, _utils.mergeVariableDefinitions)(initialVariableDefinitions, externalVariableDefinitions);
|
|
283
|
+
const queryParams = (0, _queryParams.useVariableQueryParams)(allVariableDefs);
|
|
238
284
|
const [store] = (0, _react.useState)(createTemplateVariableSrvStore({
|
|
239
285
|
initialVariableDefinitions,
|
|
286
|
+
externalVariableDefinitions,
|
|
240
287
|
queryParams
|
|
241
288
|
}));
|
|
242
289
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(TemplateVariableStoreContext.Provider, {
|
|
@@ -19,11 +19,14 @@ Object.defineProperty(exports, "hydrateTemplateVariableStates", {
|
|
|
19
19
|
get: ()=>hydrateTemplateVariableStates
|
|
20
20
|
});
|
|
21
21
|
const _core = require("@perses-dev/core");
|
|
22
|
+
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
22
23
|
// TODO: move to TemplateVariableProvider/utils.ts
|
|
23
24
|
function hydrateTemplateVariableState(variable, initialValue) {
|
|
24
25
|
const varState = {
|
|
25
26
|
value: null,
|
|
26
|
-
loading: false
|
|
27
|
+
loading: false,
|
|
28
|
+
overriding: false,
|
|
29
|
+
overridden: false
|
|
27
30
|
};
|
|
28
31
|
switch(variable.kind){
|
|
29
32
|
case 'TextVariable':
|
|
@@ -58,13 +61,60 @@ function hydrateTemplateVariableState(variable, initialValue) {
|
|
|
58
61
|
}
|
|
59
62
|
return varState;
|
|
60
63
|
}
|
|
61
|
-
function hydrateTemplateVariableStates(
|
|
62
|
-
const state =
|
|
63
|
-
definitions
|
|
64
|
+
function hydrateTemplateVariableStates(localDefinitions, initialValues, externalDefinitions = []) {
|
|
65
|
+
const state = new _pluginSystem.VariableStoreStateMap();
|
|
66
|
+
// Collect the names used by local definitions
|
|
67
|
+
let overridingNames = {};
|
|
68
|
+
localDefinitions.forEach((v)=>{
|
|
69
|
+
overridingNames[v.spec.name] = true;
|
|
70
|
+
}, {});
|
|
71
|
+
// Then populate the external variables state,
|
|
72
|
+
// taking care of well flagging each name as used, so the overridden state can be filled accordingly.
|
|
73
|
+
const overriddenNames = {};
|
|
74
|
+
externalDefinitions.forEach((externalDef)=>{
|
|
75
|
+
const source = externalDef.source;
|
|
76
|
+
externalDef.definitions.forEach((v)=>{
|
|
77
|
+
const name = v.spec.name;
|
|
78
|
+
const param = initialValues[name];
|
|
79
|
+
const initialValue = param ? param : null;
|
|
80
|
+
state.set({
|
|
81
|
+
source,
|
|
82
|
+
name
|
|
83
|
+
}, {
|
|
84
|
+
...hydrateTemplateVariableState(v, initialValue),
|
|
85
|
+
overridden: !!overridingNames[name]
|
|
86
|
+
});
|
|
87
|
+
overridingNames[name] = true;
|
|
88
|
+
overriddenNames[v.spec.name] = true;
|
|
89
|
+
});
|
|
90
|
+
}, {});
|
|
91
|
+
// Then populate the local variables state,
|
|
92
|
+
// taking care the overriding state is filled according to the names used in external variables.
|
|
93
|
+
localDefinitions.forEach((v)=>{
|
|
64
94
|
const name = v.spec.name;
|
|
65
95
|
const param = initialValues[name];
|
|
66
96
|
const initialValue = param ? param : null;
|
|
67
|
-
state
|
|
97
|
+
state.set({
|
|
98
|
+
name
|
|
99
|
+
}, {
|
|
100
|
+
...hydrateTemplateVariableState(v, initialValue),
|
|
101
|
+
overriding: !!overriddenNames[name]
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
overridingNames = {};
|
|
105
|
+
externalDefinitions.slice().reverse().forEach((externalDef)=>{
|
|
106
|
+
const source = externalDef.source;
|
|
107
|
+
externalDef.definitions.forEach((v)=>{
|
|
108
|
+
const name = v.spec.name;
|
|
109
|
+
const value = state.get({
|
|
110
|
+
source,
|
|
111
|
+
name
|
|
112
|
+
});
|
|
113
|
+
if (value) {
|
|
114
|
+
value.overriding = !!overridingNames[name];
|
|
115
|
+
}
|
|
116
|
+
overridingNames[name] = true;
|
|
117
|
+
});
|
|
68
118
|
});
|
|
69
119
|
return state;
|
|
70
120
|
}
|
|
@@ -14,25 +14,38 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
checkSavedDefaultVariableStatus: ()=>checkSavedDefaultVariableStatus,
|
|
25
|
+
mergeVariableDefinitions: ()=>mergeVariableDefinitions,
|
|
26
|
+
findVariableDefinitionByName: ()=>findVariableDefinitionByName,
|
|
27
|
+
forEachVariableDefinition: ()=>forEachVariableDefinition
|
|
20
28
|
});
|
|
21
29
|
function checkSavedDefaultVariableStatus(definitions, varState) {
|
|
22
30
|
let isSavedVariableModified = false;
|
|
23
31
|
const modifiedVariableNames = [];
|
|
24
32
|
for (const savedVariable of definitions){
|
|
33
|
+
const name = savedVariable.spec.name;
|
|
25
34
|
if (savedVariable.kind === 'ListVariable') {
|
|
26
|
-
const currentVariable = varState
|
|
35
|
+
const currentVariable = varState.get({
|
|
36
|
+
name
|
|
37
|
+
});
|
|
27
38
|
if ((currentVariable === null || currentVariable === void 0 ? void 0 : currentVariable.value) !== null && (currentVariable === null || currentVariable === void 0 ? void 0 : currentVariable.value) !== savedVariable.spec.default_value) {
|
|
28
|
-
modifiedVariableNames.push(
|
|
39
|
+
modifiedVariableNames.push(name);
|
|
29
40
|
isSavedVariableModified = true;
|
|
30
41
|
}
|
|
31
42
|
} else if (savedVariable.kind === 'TextVariable') {
|
|
32
|
-
const currentVariable1 = varState
|
|
43
|
+
const currentVariable1 = varState.get({
|
|
44
|
+
name
|
|
45
|
+
});
|
|
33
46
|
const currentVariableValue = typeof (currentVariable1 === null || currentVariable1 === void 0 ? void 0 : currentVariable1.value) === 'string' ? currentVariable1.value : '';
|
|
34
47
|
if (savedVariable.spec.value !== currentVariableValue) {
|
|
35
|
-
modifiedVariableNames.push(
|
|
48
|
+
modifiedVariableNames.push(name);
|
|
36
49
|
isSavedVariableModified = true;
|
|
37
50
|
}
|
|
38
51
|
}
|
|
@@ -42,3 +55,22 @@ function checkSavedDefaultVariableStatus(definitions, varState) {
|
|
|
42
55
|
modifiedVariableNames
|
|
43
56
|
};
|
|
44
57
|
}
|
|
58
|
+
function mergeVariableDefinitions(locals, externals) {
|
|
59
|
+
const pushed = {};
|
|
60
|
+
const result = [];
|
|
61
|
+
// Append the value only if it's not already appended
|
|
62
|
+
forEachVariableDefinition(locals, externals, (value, name)=>{
|
|
63
|
+
if (!pushed[name]) {
|
|
64
|
+
result.push(value);
|
|
65
|
+
pushed[name] = true;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
function findVariableDefinitionByName(name, localDefinitions, externalDefinitions) {
|
|
71
|
+
return mergeVariableDefinitions(localDefinitions, externalDefinitions).find((d)=>d.spec.name === name);
|
|
72
|
+
}
|
|
73
|
+
function forEachVariableDefinition(locals, externals, callbackFn) {
|
|
74
|
+
locals.forEach((v)=>callbackFn(v, v.spec.name));
|
|
75
|
+
externals.forEach((ext)=>ext.definitions.forEach((v)=>callbackFn(v, v.spec.name, ext.source)));
|
|
76
|
+
}
|
package/dist/cjs/test/render.js
CHANGED
|
@@ -69,7 +69,7 @@ function renderWithContext(ui, options, history) {
|
|
|
69
69
|
vertical: 'bottom',
|
|
70
70
|
horizontal: 'right'
|
|
71
71
|
},
|
|
72
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.
|
|
72
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ChartsProvider, {
|
|
73
73
|
chartsTheme: _components.testChartsTheme,
|
|
74
74
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.PluginRegistry, {
|
|
75
75
|
...(0, _pluginSystem.mockPluginRegistry)(..._pluginRegistry.MOCK_PLUGINS),
|
|
@@ -26,6 +26,7 @@ const _components1 = require("../../components");
|
|
|
26
26
|
const _context = require("../../context");
|
|
27
27
|
const DashboardApp = (props)=>{
|
|
28
28
|
const { dashboardResource , dashboardTitleComponent , emptyDashboardProps , onSave , onDiscard , initialVariableIsSticky , isReadonly , } = props;
|
|
29
|
+
const chartsTheme = (0, _components.useChartsTheme)();
|
|
29
30
|
const { setEditMode } = (0, _context.useEditMode)();
|
|
30
31
|
const { dashboard , setDashboard } = (0, _context.useDashboard)();
|
|
31
32
|
const [originalDashboard, setOriginalDashboard] = (0, _react.useState)(undefined);
|
|
@@ -93,11 +94,15 @@ const DashboardApp = (props)=>{
|
|
|
93
94
|
}
|
|
94
95
|
})
|
|
95
96
|
}),
|
|
96
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(
|
|
97
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ChartsProvider, {
|
|
98
|
+
chartsTheme: chartsTheme,
|
|
99
|
+
enablePinning: false,
|
|
100
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.PanelDrawer, {})
|
|
101
|
+
}),
|
|
97
102
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.PanelGroupDialog, {}),
|
|
98
103
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.DeletePanelGroupDialog, {}),
|
|
99
104
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.DeletePanelDialog, {}),
|
|
100
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.
|
|
105
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.DashboardDiscardChangesConfirmationDialog, {}),
|
|
101
106
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.EditJsonDialog, {}),
|
|
102
107
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.SaveChangesConfirmationDialog, {})
|
|
103
108
|
]
|
|
@@ -26,14 +26,14 @@ const _pluginSystem = require("@perses-dev/plugin-system");
|
|
|
26
26
|
const _context = require("../../context");
|
|
27
27
|
const _dashboardApp = require("./DashboardApp");
|
|
28
28
|
function ViewDashboard(props) {
|
|
29
|
-
const { dashboardResource , datasourceApi , dashboardTitleComponent , emptyDashboardProps , onSave , onDiscard , initialVariableIsSticky , isReadonly , isEditing , sx , ...others } = props;
|
|
29
|
+
const { dashboardResource , datasourceApi , externalVariableDefinitions , dashboardTitleComponent , emptyDashboardProps , onSave , onDiscard , initialVariableIsSticky , isReadonly , isEditing , sx , ...others } = props;
|
|
30
30
|
const { spec } = dashboardResource;
|
|
31
31
|
var _duration;
|
|
32
32
|
const dashboardDuration = (_duration = spec.duration) !== null && _duration !== void 0 ? _duration : _core.DEFAULT_DASHBOARD_DURATION;
|
|
33
33
|
var _refreshInterval;
|
|
34
|
-
const
|
|
34
|
+
const dashboardRefreshInterval = (_refreshInterval = spec.refreshInterval) !== null && _refreshInterval !== void 0 ? _refreshInterval : _core.DEFAULT_REFRESH_INTERVAL;
|
|
35
35
|
const initialTimeRange = (0, _pluginSystem.useInitialTimeRange)(dashboardDuration);
|
|
36
|
-
const initialRefreshInterval = (0, _pluginSystem.useInitialRefreshInterval)(
|
|
36
|
+
const initialRefreshInterval = (0, _pluginSystem.useInitialRefreshInterval)(dashboardRefreshInterval);
|
|
37
37
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_context.DatasourceStoreProvider, {
|
|
38
38
|
dashboardResource: dashboardResource,
|
|
39
39
|
datasourceApi: datasourceApi,
|
|
@@ -48,6 +48,7 @@ function ViewDashboard(props) {
|
|
|
48
48
|
enabledURLParams: true,
|
|
49
49
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_context.TemplateVariableProvider, {
|
|
50
50
|
initialVariableDefinitions: spec.variables,
|
|
51
|
+
externalVariableDefinitions: externalVariableDefinitions,
|
|
51
52
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
52
53
|
sx: (0, _components.combineSx)({
|
|
53
54
|
display: 'flex',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BoxProps } from '@mui/material';
|
|
3
3
|
import { EmptyDashboardProps } from '../EmptyDashboard';
|
|
4
|
+
import { PanelOptions } from '../Panel';
|
|
4
5
|
export declare type DashboardProps = BoxProps & {
|
|
5
6
|
/**
|
|
6
7
|
* Props for `EmptyDashboard` component that will be rendered when the dashboard
|
|
@@ -8,9 +9,10 @@ export declare type DashboardProps = BoxProps & {
|
|
|
8
9
|
* be used.
|
|
9
10
|
*/
|
|
10
11
|
emptyDashboardProps?: EmptyDashboardProps;
|
|
12
|
+
panelOptions?: PanelOptions;
|
|
11
13
|
};
|
|
12
14
|
/**
|
|
13
15
|
* Renders a Dashboard for the provided Dashboard spec.
|
|
14
16
|
*/
|
|
15
|
-
export declare function Dashboard({ emptyDashboardProps, ...boxProps }: DashboardProps): JSX.Element;
|
|
17
|
+
export declare function Dashboard({ emptyDashboardProps, panelOptions, ...boxProps }: DashboardProps): JSX.Element;
|
|
16
18
|
//# sourceMappingURL=Dashboard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dashboard.d.ts","sourceRoot":"","sources":["../../../src/components/Dashboard/Dashboard.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAI9C,OAAO,EAAkB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"Dashboard.d.ts","sourceRoot":"","sources":["../../../src/components/Dashboard/Dashboard.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAI9C,OAAO,EAAkB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,oBAAY,cAAc,GAAG,QAAQ,GAAG;IACtC;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,wBAAgB,SAAS,CAAC,EAAE,mBAAmB,EAAE,YAAY,EAAE,GAAG,QAAQ,EAAE,EAAE,cAAc,eAmB3F"}
|
|
@@ -18,7 +18,7 @@ import { GridLayout } from '../GridLayout';
|
|
|
18
18
|
import { EmptyDashboard } from '../EmptyDashboard';
|
|
19
19
|
/**
|
|
20
20
|
* Renders a Dashboard for the provided Dashboard spec.
|
|
21
|
-
*/ export function Dashboard({ emptyDashboardProps , ...boxProps }) {
|
|
21
|
+
*/ export function Dashboard({ emptyDashboardProps , panelOptions , ...boxProps }) {
|
|
22
22
|
const panelGroupIds = usePanelGroupIds();
|
|
23
23
|
const isEmpty = !panelGroupIds.length;
|
|
24
24
|
return /*#__PURE__*/ _jsx(Box, {
|
|
@@ -40,7 +40,8 @@ import { EmptyDashboard } from '../EmptyDashboard';
|
|
|
40
40
|
})
|
|
41
41
|
}),
|
|
42
42
|
!isEmpty && panelGroupIds.map((panelGroupId)=>/*#__PURE__*/ _jsx(GridLayout, {
|
|
43
|
-
panelGroupId: panelGroupId
|
|
43
|
+
panelGroupId: panelGroupId,
|
|
44
|
+
panelOptions: panelOptions
|
|
44
45
|
}, panelGroupId))
|
|
45
46
|
]
|
|
46
47
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Dashboard/Dashboard.tsx"],"sourcesContent":["// Copyright 2023 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 { usePanelGroupIds } from '../../context';\nimport { GridLayout } from '../GridLayout';\nimport { EmptyDashboard, EmptyDashboardProps } from '../EmptyDashboard';\
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Dashboard/Dashboard.tsx"],"sourcesContent":["// Copyright 2023 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 { usePanelGroupIds } from '../../context';\nimport { GridLayout } from '../GridLayout';\nimport { EmptyDashboard, EmptyDashboardProps } from '../EmptyDashboard';\nimport { PanelOptions } from '../Panel';\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};\n\n/**\n * Renders a Dashboard for the provided Dashboard spec.\n */\nexport function Dashboard({ emptyDashboardProps, panelOptions, ...boxProps }: DashboardProps) {\n const panelGroupIds = usePanelGroupIds();\n const isEmpty = !panelGroupIds.length;\n\n return (\n <Box {...boxProps} sx={{ height: '100%' }}>\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 key={panelGroupId} panelGroupId={panelGroupId} panelOptions={panelOptions} />\n ))}\n </ErrorBoundary>\n </Box>\n );\n}\n"],"names":["Box","ErrorBoundary","ErrorAlert","usePanelGroupIds","GridLayout","EmptyDashboard","Dashboard","emptyDashboardProps","panelOptions","boxProps","panelGroupIds","isEmpty","length","sx","height","FallbackComponent","display","alignItems","map","panelGroupId"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,QAAkB,eAAe,CAAC;AAC9C,SAASC,aAAa,EAAEC,UAAU,QAAQ,wBAAwB,CAAC;AACnE,SAASC,gBAAgB,QAAQ,eAAe,CAAC;AACjD,SAASC,UAAU,QAAQ,eAAe,CAAC;AAC3C,SAASC,cAAc,QAA6B,mBAAmB,CAAC;AAYxE;;CAEC,GACD,OAAO,SAASC,SAAS,CAAC,EAAEC,mBAAmB,CAAA,EAAEC,YAAY,CAAA,EAAE,GAAGC,QAAQ,EAAkB,EAAE;IAC5F,MAAMC,aAAa,GAAGP,gBAAgB,EAAE,AAAC;IACzC,MAAMQ,OAAO,GAAG,CAACD,aAAa,CAACE,MAAM,AAAC;IAEtC,qBACE,KAACZ,GAAG;QAAE,GAAGS,QAAQ;QAAEI,EAAE,EAAE;YAAEC,MAAM,EAAE,MAAM;SAAE;kBACvC,cAAA,MAACb,aAAa;YAACc,iBAAiB,EAAEb,UAAU;;gBACzCS,OAAO,kBACN,KAACX,GAAG;oBAACa,EAAE,EAAE;wBAAEC,MAAM,EAAE,MAAM;wBAAEE,OAAO,EAAE,MAAM;wBAAEC,UAAU,EAAE,QAAQ;qBAAE;8BAChE,cAAA,KAACZ,cAAc;wBAAE,GAAGE,mBAAmB;sBAAI;kBACvC,AACP;gBACA,CAACI,OAAO,IACPD,aAAa,CAACQ,GAAG,CAAC,CAACC,YAAY,iBAC7B,KAACf,UAAU;wBAAoBe,YAAY,EAAEA,YAAY;wBAAEX,YAAY,EAAEA,YAAY;uBAApEW,YAAY,CAA4D,AAC1F,CAAC;;UACU;MACZ,CACN;AACJ,CAAC"}
|
package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiscardChangesConfirmationDialog.d.ts","sourceRoot":"","sources":["../../../src/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"DiscardChangesConfirmationDialog.d.ts","sourceRoot":"","sources":["../../../src/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.tsx"],"names":[],"mappings":";AAgBA,eAAO,MAAM,yCAAyC,0BAgBrD,CAAC"}
|
package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js
CHANGED
|
@@ -10,54 +10,19 @@
|
|
|
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
|
-
import { jsx as _jsx
|
|
14
|
-
import {
|
|
15
|
-
import CloseIcon from 'mdi-material-ui/Close';
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { DiscardChangesConfirmationDialog } from '@perses-dev/components';
|
|
16
15
|
import { useDiscardChangesConfirmationDialog } from '../../context';
|
|
17
|
-
export const
|
|
16
|
+
export const DashboardDiscardChangesConfirmationDialog = ()=>{
|
|
18
17
|
const { discardChangesConfirmationDialog: dialog } = useDiscardChangesConfirmationDialog();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
color: "secondary",
|
|
54
|
-
onClick: dialog.onCancel,
|
|
55
|
-
children: "Cancel"
|
|
56
|
-
})
|
|
57
|
-
]
|
|
58
|
-
})
|
|
59
|
-
]
|
|
60
|
-
})
|
|
18
|
+
if (dialog === undefined) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return /*#__PURE__*/ _jsx(DiscardChangesConfirmationDialog, {
|
|
22
|
+
description: dialog.description || 'You have unsaved changes in this dashboard. Are you sure you want to discard these changes? Changes cannot be recovered.',
|
|
23
|
+
isOpen: true,
|
|
24
|
+
onCancel: dialog.onCancel,
|
|
25
|
+
onDiscardChanges: dialog.onDiscardChanges
|
|
61
26
|
});
|
|
62
27
|
};
|
|
63
28
|
|
package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.tsx"],"sourcesContent":["// Copyright 2023 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 { DiscardChangesConfirmationDialog } from '@perses-dev/components';\nimport { useDiscardChangesConfirmationDialog } from '../../context';\n\nexport const DashboardDiscardChangesConfirmationDialog = () => {\n const { discardChangesConfirmationDialog: dialog } = useDiscardChangesConfirmationDialog();\n if (dialog === undefined) {\n return null;\n }\n return (\n <DiscardChangesConfirmationDialog\n description={\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 }\n isOpen={true}\n onCancel={dialog.onCancel}\n onDiscardChanges={dialog.onDiscardChanges}\n />\n );\n};\n"],"names":["DiscardChangesConfirmationDialog","useDiscardChangesConfirmationDialog","DashboardDiscardChangesConfirmationDialog","discardChangesConfirmationDialog","dialog","undefined","description","isOpen","onCancel","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,gCAAgC,QAAQ,wBAAwB,CAAC;AAC1E,SAASC,mCAAmC,QAAQ,eAAe,CAAC;AAEpE,OAAO,MAAMC,yCAAyC,GAAG,IAAM;IAC7D,MAAM,EAAEC,gCAAgC,EAAEC,MAAM,CAAA,EAAE,GAAGH,mCAAmC,EAAE,AAAC;IAC3F,IAAIG,MAAM,KAAKC,SAAS,EAAE;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,qBACE,KAACL,gCAAgC;QAC/BM,WAAW,EACTF,MAAM,CAACE,WAAW,IAClB,0HAA0H;QAE5HC,MAAM,EAAE,IAAI;QACZC,QAAQ,EAAEJ,MAAM,CAACI,QAAQ;QACzBC,gBAAgB,EAAEL,MAAM,CAACK,gBAAgB;MACzC,CACF;AACJ,CAAC,CAAC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { PanelGroupItemId } from '../../context';
|
|
3
|
+
import { PanelOptions } from '../Panel';
|
|
3
4
|
export interface GridItemContentProps {
|
|
4
5
|
panelGroupItemId: PanelGroupItemId;
|
|
5
6
|
width: number;
|
|
7
|
+
panelOptions?: PanelOptions;
|
|
6
8
|
}
|
|
7
9
|
/**
|
|
8
10
|
* Resolves the reference to panel content in a GridItemDefinition and renders the panel.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridItemContent.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridItemContent.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"GridItemContent.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridItemContent.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,gBAAgB,EAA0C,MAAM,eAAe,CAAC;AAGzF,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,MAAM,WAAW,oBAAoB;IACnC,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eAuC1D"}
|
|
@@ -48,7 +48,9 @@ import { Panel } from '../Panel/Panel';
|
|
|
48
48
|
},
|
|
49
49
|
children: /*#__PURE__*/ _jsx(Panel, {
|
|
50
50
|
definition: panelDefinition,
|
|
51
|
-
editHandlers: editHandlers
|
|
51
|
+
editHandlers: editHandlers,
|
|
52
|
+
panelOptions: props.panelOptions,
|
|
53
|
+
panelGroupItemId: panelGroupItemId
|
|
52
54
|
})
|
|
53
55
|
});
|
|
54
56
|
}
|