@perses-dev/dashboards 0.12.0 → 0.13.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.js → Dashboard/Dashboard.js} +2 -2
- package/dist/cjs/components/Dashboard/index.js +28 -0
- package/dist/cjs/components/{DashboardToolbar.js → DashboardToolbar/DashboardToolbar.js} +9 -23
- package/dist/cjs/components/DashboardToolbar/index.js +28 -0
- package/dist/cjs/components/{Panel → DeletePanelDialog}/DeletePanelDialog.js +2 -3
- package/dist/cjs/components/DeletePanelDialog/index.js +28 -0
- package/dist/cjs/components/{PanelGroupDialog → DeletePanelGroupDialog}/DeletePanelGroupDialog.js +0 -0
- package/dist/cjs/components/DeletePanelGroupDialog/index.js +28 -0
- package/dist/cjs/components/GridLayout/GridItemContent.js +11 -1
- package/dist/cjs/components/Panel/Panel.js +30 -89
- package/dist/cjs/components/Panel/Panel.test.js +93 -47
- package/dist/cjs/components/Panel/PanelHeader.js +116 -0
- package/dist/cjs/components/Panel/index.js +0 -1
- package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +9 -15
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +13 -20
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +1 -1
- package/dist/cjs/components/PanelGroupDialog/index.js +0 -1
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +1 -1
- package/dist/cjs/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js +67 -0
- package/dist/cjs/components/UnsavedChangesConfirmationDialog/index.js +28 -0
- package/dist/cjs/components/Variables/Variable.js +18 -11
- package/dist/cjs/components/index.js +4 -0
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +24 -18
- package/dist/cjs/context/DashboardProvider/common.js +3 -3
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +2 -4
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +47 -52
- package/dist/cjs/context/DashboardProvider/panel-slice.js +2 -13
- package/dist/cjs/context/{TemplateVariableProvider.js → TemplateVariableProvider/TemplateVariableProvider.js} +25 -12
- package/dist/cjs/context/TemplateVariableProvider/index.js +28 -0
- package/dist/cjs/context/TemplateVariableProvider/query-params.js +79 -0
- package/dist/cjs/context/TemplateVariableProvider/query-params.test.js +82 -0
- package/dist/cjs/context/index.js +1 -1
- package/dist/cjs/context/{useDashboardSpec.js → useDashboard.js} +20 -16
- package/dist/cjs/test/plugin-registry.js +14 -54
- package/dist/cjs/test/render.js +6 -1
- package/dist/cjs/utils/component-ids.js +31 -0
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +40 -10
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +1 -1
- package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +1 -1
- package/dist/components/{Dashboard.d.ts → Dashboard/Dashboard.d.ts} +0 -0
- package/dist/components/Dashboard/Dashboard.d.ts.map +1 -0
- package/dist/components/{Dashboard.js → Dashboard/Dashboard.js} +2 -2
- package/dist/components/Dashboard/Dashboard.js.map +1 -0
- package/dist/components/Dashboard/index.d.ts +2 -0
- package/dist/components/Dashboard/index.d.ts.map +1 -0
- package/dist/components/Dashboard/index.js +15 -0
- package/dist/components/Dashboard/index.js.map +1 -0
- package/dist/components/{DashboardToolbar.d.ts → DashboardToolbar/DashboardToolbar.d.ts} +2 -0
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -0
- package/dist/components/{DashboardToolbar.js → DashboardToolbar/DashboardToolbar.js} +5 -19
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -0
- package/dist/components/DashboardToolbar/index.d.ts +2 -0
- package/dist/components/DashboardToolbar/index.d.ts.map +1 -0
- package/dist/components/DashboardToolbar/index.js +15 -0
- package/dist/components/DashboardToolbar/index.js.map +1 -0
- package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts +3 -0
- package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts.map +1 -0
- package/dist/components/{Panel → DeletePanelDialog}/DeletePanelDialog.js +1 -2
- package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -0
- package/dist/components/DeletePanelDialog/index.d.ts +2 -0
- package/dist/components/DeletePanelDialog/index.d.ts.map +1 -0
- package/dist/components/DeletePanelDialog/index.js +15 -0
- package/dist/components/DeletePanelDialog/index.js.map +1 -0
- package/dist/components/{PanelGroupDialog → DeletePanelGroupDialog}/DeletePanelGroupDialog.d.ts +0 -0
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -0
- package/dist/components/{PanelGroupDialog → DeletePanelGroupDialog}/DeletePanelGroupDialog.js +0 -0
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -0
- package/dist/components/DeletePanelGroupDialog/index.d.ts +2 -0
- package/dist/components/DeletePanelGroupDialog/index.d.ts.map +1 -0
- package/dist/components/DeletePanelGroupDialog/index.js +15 -0
- package/dist/components/DeletePanelGroupDialog/index.js.map +1 -0
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +12 -2
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/Panel/Panel.d.ts +3 -3
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +32 -91
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/Panel.test.js +95 -49
- package/dist/components/Panel/Panel.test.js.map +1 -1
- package/dist/components/Panel/PanelHeader.d.ts +16 -0
- package/dist/components/Panel/PanelHeader.d.ts.map +1 -0
- package/dist/components/Panel/PanelHeader.js +105 -0
- package/dist/components/Panel/PanelHeader.js.map +1 -0
- package/dist/components/Panel/index.d.ts +0 -1
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +0 -1
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.test.js +10 -16
- package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.d.ts +2 -2
- package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js +13 -20
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -1
- package/dist/components/PanelGroupDialog/index.d.ts +0 -1
- package/dist/components/PanelGroupDialog/index.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/index.js +0 -1
- package/dist/components/PanelGroupDialog/index.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -1
- package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts +8 -0
- package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts.map +1 -0
- package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js +56 -0
- package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js.map +1 -0
- package/dist/components/UnsavedChangesConfirmationDialog/index.d.ts +2 -0
- package/dist/components/UnsavedChangesConfirmationDialog/index.d.ts.map +1 -0
- package/dist/components/UnsavedChangesConfirmationDialog/index.js +15 -0
- package/dist/components/UnsavedChangesConfirmationDialog/index.js.map +1 -0
- package/dist/components/Variables/Variable.d.ts.map +1 -1
- package/dist/components/Variables/Variable.js +19 -12
- package/dist/components/Variables/Variable.js.map +1 -1
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +4 -0
- package/dist/components/index.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +4 -4
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +26 -20
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/common.d.ts +1 -1
- package/dist/context/DashboardProvider/common.d.ts.map +1 -1
- package/dist/context/DashboardProvider/common.js +4 -4
- package/dist/context/DashboardProvider/common.js.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +1 -2
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js +2 -4
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- 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/DashboardProvider/panel-group-slice.d.ts +1 -15
- package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.js +38 -49
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-slice.d.ts +0 -9
- package/dist/context/DashboardProvider/panel-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-slice.js +2 -13
- package/dist/context/DashboardProvider/panel-slice.js.map +1 -1
- package/dist/context/{TemplateVariableProvider.d.ts → TemplateVariableProvider/TemplateVariableProvider.d.ts} +0 -0
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -0
- package/dist/context/{TemplateVariableProvider.js → TemplateVariableProvider/TemplateVariableProvider.js} +25 -12
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -0
- package/dist/context/TemplateVariableProvider/index.d.ts +2 -0
- package/dist/context/TemplateVariableProvider/index.d.ts.map +1 -0
- package/dist/context/TemplateVariableProvider/index.js +15 -0
- package/dist/context/TemplateVariableProvider/index.js.map +1 -0
- package/dist/context/TemplateVariableProvider/query-params.d.ts +12 -0
- package/dist/context/TemplateVariableProvider/query-params.d.ts.map +1 -0
- package/dist/context/TemplateVariableProvider/query-params.js +64 -0
- package/dist/context/TemplateVariableProvider/query-params.js.map +1 -0
- package/dist/context/TemplateVariableProvider/query-params.test.d.ts +2 -0
- package/dist/context/TemplateVariableProvider/query-params.test.d.ts.map +1 -0
- package/dist/context/TemplateVariableProvider/query-params.test.js +80 -0
- package/dist/context/TemplateVariableProvider/query-params.test.js.map +1 -0
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +1 -1
- package/dist/context/index.js.map +1 -1
- package/dist/context/useDashboard.d.ts +6 -0
- package/dist/context/useDashboard.d.ts.map +1 -0
- package/dist/context/{useDashboardSpec.js → useDashboard.js} +19 -15
- package/dist/context/useDashboard.js.map +1 -0
- package/dist/test/plugin-registry.d.ts +2 -11
- package/dist/test/plugin-registry.d.ts.map +1 -1
- package/dist/test/plugin-registry.js +12 -49
- package/dist/test/plugin-registry.js.map +1 -1
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +6 -1
- package/dist/test/render.js.map +1 -1
- package/dist/utils/component-ids.d.ts +8 -0
- package/dist/utils/component-ids.d.ts.map +1 -0
- package/dist/utils/component-ids.js +27 -0
- package/dist/utils/component-ids.js.map +1 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +40 -5
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/dist/views/ViewDashboard/tests/panelGroups.test.js +1 -1
- package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -1
- package/package.json +4 -4
- package/dist/components/Dashboard.d.ts.map +0 -1
- package/dist/components/Dashboard.js.map +0 -1
- package/dist/components/DashboardToolbar.d.ts.map +0 -1
- package/dist/components/DashboardToolbar.js.map +0 -1
- package/dist/components/Panel/DeletePanelDialog.d.ts +0 -4
- package/dist/components/Panel/DeletePanelDialog.d.ts.map +0 -1
- package/dist/components/Panel/DeletePanelDialog.js.map +0 -1
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts.map +0 -1
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js.map +0 -1
- package/dist/context/TemplateVariableProvider.d.ts.map +0 -1
- package/dist/context/TemplateVariableProvider.js.map +0 -1
- package/dist/context/useDashboardSpec.d.ts +0 -11
- package/dist/context/useDashboardSpec.d.ts.map +0 -1
- package/dist/context/useDashboardSpec.js.map +0 -1
|
@@ -34,6 +34,7 @@ const _zustand = require("zustand");
|
|
|
34
34
|
const _immer = require("zustand/middleware/immer");
|
|
35
35
|
const _middleware = require("zustand/middleware");
|
|
36
36
|
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
37
|
+
const _queryParams = require("./query-params");
|
|
37
38
|
const TemplateVariableStoreContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
|
|
38
39
|
function useTemplateVariableStoreCtx() {
|
|
39
40
|
const context = (0, _react.useContext)(TemplateVariableStoreContext);
|
|
@@ -119,14 +120,15 @@ function PluginProvider({ children }) {
|
|
|
119
120
|
children: children
|
|
120
121
|
});
|
|
121
122
|
}
|
|
122
|
-
function createTemplateVariableSrvStore({ initialVariableDefinitions =[] }) {
|
|
123
|
+
function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , queryParams }) {
|
|
124
|
+
const initialParams = (0, _queryParams.getInitalValuesFromQueryParameters)(queryParams ? queryParams[0] : {});
|
|
123
125
|
const store = (0, _zustand.createStore)()((0, _middleware.devtools)((0, _immer.immer)((set)=>({
|
|
124
|
-
variableState: hydrateTemplateVariableStates(initialVariableDefinitions),
|
|
126
|
+
variableState: hydrateTemplateVariableStates(initialVariableDefinitions, initialParams),
|
|
125
127
|
variableDefinitions: initialVariableDefinitions,
|
|
126
128
|
setVariableDefinitions (definitions) {
|
|
127
129
|
set((state)=>{
|
|
128
130
|
state.variableDefinitions = definitions;
|
|
129
|
-
state.variableState = hydrateTemplateVariableStates(definitions);
|
|
131
|
+
state.variableState = hydrateTemplateVariableStates(definitions, initialParams);
|
|
130
132
|
});
|
|
131
133
|
},
|
|
132
134
|
setVariableOptions (name, options) {
|
|
@@ -161,14 +163,22 @@ function createTemplateVariableSrvStore({ initialVariableDefinitions =[] }) {
|
|
|
161
163
|
val = val.filter((v)=>v !== _pluginSystem.DEFAULT_ALL_VALUE);
|
|
162
164
|
}
|
|
163
165
|
}
|
|
166
|
+
if (queryParams) {
|
|
167
|
+
const setQueryParams = queryParams[1];
|
|
168
|
+
setQueryParams({
|
|
169
|
+
[(0, _queryParams.getURLQueryParamName)(name)]: val
|
|
170
|
+
});
|
|
171
|
+
}
|
|
164
172
|
varState.value = val;
|
|
165
173
|
})
|
|
166
174
|
}))));
|
|
167
175
|
return store;
|
|
168
176
|
}
|
|
169
177
|
function TemplateVariableProvider({ children , initialVariableDefinitions =[] }) {
|
|
178
|
+
const queryParams = (0, _queryParams.useVariableQueryParams)(initialVariableDefinitions);
|
|
170
179
|
const [store] = (0, _react.useState)(createTemplateVariableSrvStore({
|
|
171
|
-
initialVariableDefinitions
|
|
180
|
+
initialVariableDefinitions,
|
|
181
|
+
queryParams
|
|
172
182
|
}));
|
|
173
183
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(TemplateVariableStoreContext.Provider, {
|
|
174
184
|
value: store,
|
|
@@ -177,23 +187,23 @@ function TemplateVariableProvider({ children , initialVariableDefinitions =[] }
|
|
|
177
187
|
})
|
|
178
188
|
});
|
|
179
189
|
}
|
|
180
|
-
/** Helpers */ function hydrateTemplateVariableState(definition) {
|
|
190
|
+
/** Helpers */ function hydrateTemplateVariableState(definition, initialValue) {
|
|
181
191
|
const v = definition;
|
|
182
|
-
var
|
|
192
|
+
var ref;
|
|
183
193
|
const varState = {
|
|
184
|
-
value: (
|
|
194
|
+
value: (ref = initialValue !== null && initialValue !== void 0 ? initialValue : v.spec.default_value) !== null && ref !== void 0 ? ref : null,
|
|
185
195
|
loading: false
|
|
186
196
|
};
|
|
187
197
|
switch(v.kind){
|
|
188
198
|
case 'TextVariable':
|
|
189
|
-
varState.value = v.spec.value;
|
|
199
|
+
varState.value = initialValue !== null && initialValue !== void 0 ? initialValue : v.spec.value;
|
|
190
200
|
break;
|
|
191
201
|
case 'ListVariable':
|
|
192
202
|
varState.options = [];
|
|
193
203
|
if (varState.options.length > 0 && !varState.value) {
|
|
194
|
-
var ref;
|
|
195
204
|
var ref1;
|
|
196
|
-
|
|
205
|
+
var ref2;
|
|
206
|
+
const firstOptionValue = (ref2 = (ref1 = varState.options[0]) === null || ref1 === void 0 ? void 0 : ref1.value) !== null && ref2 !== void 0 ? ref2 : null;
|
|
197
207
|
if (firstOptionValue !== null) {
|
|
198
208
|
varState.value = v.spec.allow_multiple ? [
|
|
199
209
|
firstOptionValue
|
|
@@ -206,10 +216,13 @@ function TemplateVariableProvider({ children , initialVariableDefinitions =[] }
|
|
|
206
216
|
}
|
|
207
217
|
return varState;
|
|
208
218
|
}
|
|
209
|
-
function hydrateTemplateVariableStates(definitions) {
|
|
219
|
+
function hydrateTemplateVariableStates(definitions, initialValues) {
|
|
210
220
|
const state = {};
|
|
211
221
|
definitions.forEach((v)=>{
|
|
212
|
-
|
|
222
|
+
const name = v.spec.name;
|
|
223
|
+
const param = initialValues[name];
|
|
224
|
+
const initialValue = param ? param : null;
|
|
225
|
+
state[name] = hydrateTemplateVariableState(v, initialValue);
|
|
213
226
|
});
|
|
214
227
|
return state;
|
|
215
228
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
_exportStar(require("./TemplateVariableProvider"), exports);
|
|
18
|
+
function _exportStar(from, to) {
|
|
19
|
+
Object.keys(from).forEach(function(k) {
|
|
20
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function() {
|
|
23
|
+
return from[k];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
return from;
|
|
28
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
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
|
+
getURLQueryParamName: ()=>getURLQueryParamName,
|
|
25
|
+
encodeVariableValue: ()=>encodeVariableValue,
|
|
26
|
+
decodeVariableValue: ()=>decodeVariableValue,
|
|
27
|
+
useVariableQueryParams: ()=>useVariableQueryParams,
|
|
28
|
+
getInitalValuesFromQueryParameters: ()=>getInitalValuesFromQueryParameters
|
|
29
|
+
});
|
|
30
|
+
const _useQueryParams = require("use-query-params");
|
|
31
|
+
const variableQueryParameterPrefix = 'var-';
|
|
32
|
+
function getURLQueryParamName(name) {
|
|
33
|
+
return `${variableQueryParameterPrefix}${name}`;
|
|
34
|
+
}
|
|
35
|
+
function encodeVariableValue(value) {
|
|
36
|
+
if (Array.isArray(value)) {
|
|
37
|
+
return value.join(',');
|
|
38
|
+
}
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
function decodeVariableValue(value) {
|
|
42
|
+
if (!value) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const values = value.split(',');
|
|
46
|
+
if (values.length === 1) {
|
|
47
|
+
return values[0];
|
|
48
|
+
}
|
|
49
|
+
return values;
|
|
50
|
+
}
|
|
51
|
+
const VariableValueParam = {
|
|
52
|
+
encode: encodeVariableValue,
|
|
53
|
+
decode: (v)=>{
|
|
54
|
+
if (typeof v === 'string') {
|
|
55
|
+
return decodeVariableValue(v);
|
|
56
|
+
}
|
|
57
|
+
return '';
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
function useVariableQueryParams(defs) {
|
|
61
|
+
const config = {};
|
|
62
|
+
defs.forEach((def)=>{
|
|
63
|
+
const name = getURLQueryParamName(def.spec.name);
|
|
64
|
+
config[name] = VariableValueParam;
|
|
65
|
+
});
|
|
66
|
+
return (0, _useQueryParams.useQueryParams)(config);
|
|
67
|
+
}
|
|
68
|
+
function getInitalValuesFromQueryParameters(queryParamValues) {
|
|
69
|
+
const values = {};
|
|
70
|
+
Object.keys(queryParamValues).forEach((key)=>{
|
|
71
|
+
const value = queryParamValues[key];
|
|
72
|
+
if (!value) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const name = key.replace(variableQueryParameterPrefix, '');
|
|
76
|
+
values[name] = value;
|
|
77
|
+
});
|
|
78
|
+
return values;
|
|
79
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
const _queryParams = require("./query-params");
|
|
18
|
+
describe('getInitalValuesFromQueryParameters', ()=>{
|
|
19
|
+
test('base case', ()=>{
|
|
20
|
+
expect((0, _queryParams.getInitalValuesFromQueryParameters)({
|
|
21
|
+
'var-foo': 'bar',
|
|
22
|
+
'var-baz': [
|
|
23
|
+
'qux',
|
|
24
|
+
'quux'
|
|
25
|
+
]
|
|
26
|
+
})).toEqual({
|
|
27
|
+
foo: 'bar',
|
|
28
|
+
baz: [
|
|
29
|
+
'qux',
|
|
30
|
+
'quux'
|
|
31
|
+
]
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
describe('encodeVariableValue', ()=>{
|
|
36
|
+
const testCases = [
|
|
37
|
+
{
|
|
38
|
+
input: 'foo',
|
|
39
|
+
expected: 'foo'
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
input: [
|
|
43
|
+
'foo',
|
|
44
|
+
'bar'
|
|
45
|
+
],
|
|
46
|
+
expected: 'foo,bar'
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
input: '$__all',
|
|
50
|
+
expected: '$__all'
|
|
51
|
+
}
|
|
52
|
+
];
|
|
53
|
+
testCases.forEach(({ input , expected })=>{
|
|
54
|
+
test(`encodes ${input} as ${expected}`, ()=>{
|
|
55
|
+
expect((0, _queryParams.encodeVariableValue)(input)).toEqual(expected);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
describe('decodeVariableValue', ()=>{
|
|
60
|
+
const testCases = [
|
|
61
|
+
{
|
|
62
|
+
input: 'foo',
|
|
63
|
+
expected: 'foo'
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
input: 'foo,bar',
|
|
67
|
+
expected: [
|
|
68
|
+
'foo',
|
|
69
|
+
'bar'
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
input: '$__all',
|
|
74
|
+
expected: '$__all'
|
|
75
|
+
}
|
|
76
|
+
];
|
|
77
|
+
testCases.forEach(({ input , expected })=>{
|
|
78
|
+
test(`encodes ${input} as ${expected}`, ()=>{
|
|
79
|
+
expect((0, _queryParams.decodeVariableValue)(input)).toEqual(expected);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -18,7 +18,7 @@ _exportStar(require("./DashboardProvider"), exports);
|
|
|
18
18
|
_exportStar(require("./DatasourceStoreProvider"), exports);
|
|
19
19
|
_exportStar(require("./TemplateVariableProvider"), exports);
|
|
20
20
|
_exportStar(require("./TimeRangeProvider"), exports);
|
|
21
|
-
_exportStar(require("./
|
|
21
|
+
_exportStar(require("./useDashboard"), exports);
|
|
22
22
|
function _exportStar(from, to) {
|
|
23
23
|
Object.keys(from).forEach(function(k) {
|
|
24
24
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
@@ -14,38 +14,42 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
Object.defineProperty(exports, "
|
|
17
|
+
Object.defineProperty(exports, "useDashboard", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: ()=>
|
|
19
|
+
get: ()=>useDashboard
|
|
20
20
|
});
|
|
21
21
|
const _core = require("@perses-dev/core");
|
|
22
22
|
const _dashboardProvider = require("./DashboardProvider");
|
|
23
23
|
const _templateVariableProvider = require("./TemplateVariableProvider");
|
|
24
|
-
function
|
|
25
|
-
const { panels , panelGroups , panelGroupOrder , defaultTimeRange ,
|
|
24
|
+
function useDashboard() {
|
|
25
|
+
const { panels , panelGroups , panelGroupOrder , defaultTimeRange , metadata , setDashboard: setDashboardResource , } = (0, _dashboardProvider.useDashboardStore)(({ panels , panelGroups , panelGroupOrder , defaultTimeRange , setDashboard , metadata })=>({
|
|
26
26
|
panels,
|
|
27
27
|
panelGroups,
|
|
28
28
|
panelGroupOrder,
|
|
29
29
|
defaultTimeRange,
|
|
30
|
-
|
|
30
|
+
setDashboard,
|
|
31
|
+
metadata
|
|
31
32
|
}));
|
|
32
33
|
const { setVariableDefinitions } = (0, _templateVariableProvider.useTemplateVariableActions)();
|
|
33
34
|
const variables = (0, _templateVariableProvider.useTemplateVariableDefinitions)();
|
|
34
35
|
const layouts = convertPanelGroupsToLayouts(panelGroups, panelGroupOrder);
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
const dashboard = {
|
|
37
|
+
kind: 'Dashboard',
|
|
38
|
+
metadata,
|
|
39
|
+
spec: {
|
|
40
|
+
panels,
|
|
41
|
+
layouts,
|
|
42
|
+
variables,
|
|
43
|
+
duration: defaultTimeRange.pastDuration
|
|
44
|
+
}
|
|
40
45
|
};
|
|
41
|
-
const
|
|
42
|
-
setVariableDefinitions(spec.variables);
|
|
43
|
-
|
|
44
|
-
resetDashboardStore();
|
|
46
|
+
const setDashboard = (dashboardResource)=>{
|
|
47
|
+
setVariableDefinitions(dashboardResource.spec.variables);
|
|
48
|
+
setDashboardResource(dashboardResource);
|
|
45
49
|
};
|
|
46
50
|
return {
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
dashboard,
|
|
52
|
+
setDashboard
|
|
49
53
|
};
|
|
50
54
|
}
|
|
51
55
|
function convertPanelGroupsToLayouts(panelGroups, panelGroupOrder) {
|
|
@@ -14,69 +14,29 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
get: all[name]
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
_export(exports, {
|
|
24
|
-
mockPluginRegistryProps: ()=>mockPluginRegistryProps,
|
|
25
|
-
FAKE_PANEL_PLUGIN: ()=>FAKE_PANEL_PLUGIN
|
|
17
|
+
Object.defineProperty(exports, "MOCK_PLUGINS", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>MOCK_PLUGINS
|
|
26
20
|
});
|
|
27
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
28
|
-
|
|
29
|
-
const mockPluginResource = {
|
|
30
|
-
kind: 'PluginModule',
|
|
31
|
-
metadata: {
|
|
32
|
-
name: 'Fake Plugin Module for Tests',
|
|
33
|
-
created_at: '',
|
|
34
|
-
updated_at: '',
|
|
35
|
-
version: 0
|
|
36
|
-
},
|
|
37
|
-
spec: {
|
|
38
|
-
plugins: []
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
const mockPluginModule = {};
|
|
42
|
-
// Allow adding mock plugins in tests
|
|
43
|
-
const addMockPlugin = (pluginType, kind, plugin)=>{
|
|
44
|
-
mockPluginResource.spec.plugins.push({
|
|
45
|
-
pluginType,
|
|
46
|
-
kind,
|
|
47
|
-
display: {
|
|
48
|
-
name: `Fake ${pluginType} Plugin for ${kind}`
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
// "Export" on the module under the same name as the kind the plugin handles
|
|
52
|
-
mockPluginModule[kind] = plugin;
|
|
53
|
-
};
|
|
54
|
-
const pluginRegistryProps = {
|
|
55
|
-
getInstalledPlugins () {
|
|
56
|
-
return Promise.resolve([
|
|
57
|
-
mockPluginResource
|
|
58
|
-
]);
|
|
59
|
-
},
|
|
60
|
-
importPluginModule () {
|
|
61
|
-
return Promise.resolve(mockPluginModule);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
return {
|
|
65
|
-
pluginRegistryProps,
|
|
66
|
-
addMockPlugin
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
const FAKE_PANEL_PLUGIN = {
|
|
22
|
+
const FakeTimeSeriesPlugin = {
|
|
70
23
|
PanelComponent: ()=>{
|
|
71
24
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
72
|
-
|
|
73
|
-
children: "FakePanel chart"
|
|
25
|
+
children: "TimeSeriesChart panel"
|
|
74
26
|
});
|
|
75
27
|
},
|
|
76
28
|
OptionsEditorComponent: ()=>{
|
|
77
29
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
78
|
-
children: "
|
|
30
|
+
children: "TimeSeriesChart options"
|
|
79
31
|
});
|
|
80
32
|
},
|
|
81
33
|
createInitialOptions: ()=>({})
|
|
82
34
|
};
|
|
35
|
+
const MOCK_TIME_SERIES_PANEL = {
|
|
36
|
+
pluginType: 'Panel',
|
|
37
|
+
kind: 'TimeSeriesChart',
|
|
38
|
+
plugin: FakeTimeSeriesPlugin
|
|
39
|
+
};
|
|
40
|
+
const MOCK_PLUGINS = [
|
|
41
|
+
MOCK_TIME_SERIES_PANEL
|
|
42
|
+
];
|
package/dist/cjs/test/render.js
CHANGED
|
@@ -26,6 +26,8 @@ const _useQueryParams = require("use-query-params");
|
|
|
26
26
|
const _reactRouter6 = require("use-query-params/adapters/react-router-6");
|
|
27
27
|
const _reactQuery = require("@tanstack/react-query");
|
|
28
28
|
const _components = require("@perses-dev/components");
|
|
29
|
+
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
30
|
+
const _pluginRegistry = require("./plugin-registry");
|
|
29
31
|
function renderWithContext(ui, options, history) {
|
|
30
32
|
// Create a new QueryClient for each test to avoid caching issues
|
|
31
33
|
const queryClient = new _reactQuery.QueryClient({
|
|
@@ -48,7 +50,10 @@ function renderWithContext(ui, options, history) {
|
|
|
48
50
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ChartsThemeProvider, {
|
|
49
51
|
themeName: "perses",
|
|
50
52
|
chartsTheme: _components.testChartsTheme,
|
|
51
|
-
children:
|
|
53
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.PluginRegistry, {
|
|
54
|
+
...(0, _pluginSystem.mockPluginRegistry)(..._pluginRegistry.MOCK_PLUGINS),
|
|
55
|
+
children: ui
|
|
56
|
+
})
|
|
52
57
|
})
|
|
53
58
|
})
|
|
54
59
|
})
|
|
@@ -0,0 +1,31 @@
|
|
|
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, "useId", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>useId
|
|
20
|
+
});
|
|
21
|
+
const _react = require("react");
|
|
22
|
+
if (globalThis.useIdValue === undefined) {
|
|
23
|
+
globalThis.useIdValue = 0;
|
|
24
|
+
}
|
|
25
|
+
function useId(prefix) {
|
|
26
|
+
const id = (0, _react.useRef)(undefined);
|
|
27
|
+
if (id.current === undefined) {
|
|
28
|
+
id.current = `${prefix}-${globalThis.useIdValue++}`;
|
|
29
|
+
}
|
|
30
|
+
return id.current;
|
|
31
|
+
}
|
|
@@ -19,18 +19,41 @@ Object.defineProperty(exports, "DashboardApp", {
|
|
|
19
19
|
get: ()=>DashboardApp
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _react = require("react");
|
|
22
23
|
const _material = require("@mui/material");
|
|
23
24
|
const _components = require("@perses-dev/components");
|
|
24
25
|
const _components1 = require("../../components");
|
|
25
|
-
const
|
|
26
|
-
const _deletePanelDialog = /*#__PURE__*/ _interopRequireDefault(require("../../components/Panel/DeletePanelDialog"));
|
|
27
|
-
function _interopRequireDefault(obj) {
|
|
28
|
-
return obj && obj.__esModule ? obj : {
|
|
29
|
-
default: obj
|
|
30
|
-
};
|
|
31
|
-
}
|
|
26
|
+
const _context = require("../../context");
|
|
32
27
|
const DashboardApp = (props)=>{
|
|
33
28
|
const { dashboardResource } = props;
|
|
29
|
+
const { setEditMode } = (0, _context.useEditMode)();
|
|
30
|
+
const { dashboard , setDashboard } = (0, _context.useDashboard)();
|
|
31
|
+
const [originalDashboard, setOriginalDashboard] = (0, _react.useState)(undefined);
|
|
32
|
+
const [isUnsavedDashboardDialogOpen, setUnsavedDashboardDialogIsOpen] = (0, _react.useState)(false);
|
|
33
|
+
const saveDashboard = async ()=>{
|
|
34
|
+
setEditMode(false);
|
|
35
|
+
setUnsavedDashboardDialogIsOpen(false);
|
|
36
|
+
};
|
|
37
|
+
const cancelDashboard = ()=>{
|
|
38
|
+
// Reset to the original spec and exit edit mode
|
|
39
|
+
if (originalDashboard) {
|
|
40
|
+
setDashboard(originalDashboard);
|
|
41
|
+
}
|
|
42
|
+
setUnsavedDashboardDialogIsOpen(false);
|
|
43
|
+
setEditMode(false);
|
|
44
|
+
};
|
|
45
|
+
const onEditButtonClick = ()=>{
|
|
46
|
+
setEditMode(true);
|
|
47
|
+
setOriginalDashboard(dashboard);
|
|
48
|
+
};
|
|
49
|
+
const onCancelButtonClick = ()=>{
|
|
50
|
+
// check if dashboard has been modified
|
|
51
|
+
if (JSON.stringify(dashboard) === JSON.stringify(originalDashboard)) {
|
|
52
|
+
setEditMode(false);
|
|
53
|
+
} else {
|
|
54
|
+
setUnsavedDashboardDialogIsOpen(true);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
34
57
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
35
58
|
sx: {
|
|
36
59
|
flexGrow: 1,
|
|
@@ -40,8 +63,10 @@ const DashboardApp = (props)=>{
|
|
|
40
63
|
flexDirection: 'column'
|
|
41
64
|
},
|
|
42
65
|
children: [
|
|
43
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(
|
|
44
|
-
dashboardName: dashboardResource.metadata.name
|
|
66
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.DashboardToolbar, {
|
|
67
|
+
dashboardName: dashboardResource.metadata.name,
|
|
68
|
+
onEditButtonClick: onEditButtonClick,
|
|
69
|
+
onCancelButtonClick: onCancelButtonClick
|
|
45
70
|
}),
|
|
46
71
|
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
47
72
|
sx: {
|
|
@@ -55,7 +80,12 @@ const DashboardApp = (props)=>{
|
|
|
55
80
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.PanelDrawer, {}),
|
|
56
81
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.PanelGroupDialog, {}),
|
|
57
82
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.DeletePanelGroupDialog, {}),
|
|
58
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(
|
|
83
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.DeletePanelDialog, {}),
|
|
84
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.UnsavedChangesConfirmationDialog, {
|
|
85
|
+
isOpen: isUnsavedDashboardDialogOpen,
|
|
86
|
+
onSave: saveDashboard,
|
|
87
|
+
onClose: cancelDashboard
|
|
88
|
+
})
|
|
59
89
|
]
|
|
60
90
|
})
|
|
61
91
|
]
|
|
@@ -36,7 +36,7 @@ function ViewDashboard(props) {
|
|
|
36
36
|
datasourceApi: datasourceApi,
|
|
37
37
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_context.DashboardProvider, {
|
|
38
38
|
initialState: {
|
|
39
|
-
|
|
39
|
+
dashboardResource
|
|
40
40
|
},
|
|
41
41
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_context.TimeRangeProvider, {
|
|
42
42
|
timeRange: timeRange,
|
|
@@ -34,7 +34,7 @@ describe('Panel Groups', ()=>{
|
|
|
34
34
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_context.TemplateVariableProvider, {
|
|
35
35
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_context.DashboardProvider, {
|
|
36
36
|
initialState: {
|
|
37
|
-
|
|
37
|
+
dashboardResource: (0, _test.getTestDashboard)(),
|
|
38
38
|
isEditMode: true
|
|
39
39
|
},
|
|
40
40
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_dashboardApp.DashboardApp, {
|
|
File without changes
|
|
@@ -0,0 +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;AAK9C,oBAAY,cAAc,GAAG,QAAQ,CAAC;AAEtC;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,eAW9C"}
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { Box } from '@mui/material';
|
|
15
15
|
import { ErrorBoundary, ErrorAlert } from '@perses-dev/components';
|
|
16
|
-
import { usePanelGroupIds } from '
|
|
17
|
-
import { GridLayout } from '
|
|
16
|
+
import { usePanelGroupIds } from '../../context';
|
|
17
|
+
import { GridLayout } from '../GridLayout';
|
|
18
18
|
/**
|
|
19
19
|
* Renders a Dashboard for the provided Dashboard spec.
|
|
20
20
|
*/ export function Dashboard(props) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Dashboard/Dashboard.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, BoxProps } from '@mui/material';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { usePanelGroupIds } from '../../context';\nimport { GridLayout } from '../GridLayout';\n\nexport type DashboardProps = BoxProps;\n\n/**\n * Renders a Dashboard for the provided Dashboard spec.\n */\nexport function Dashboard(props: DashboardProps) {\n const panelGroupIds = usePanelGroupIds();\n return (\n <Box {...props}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n {panelGroupIds.map((panelGroupId) => (\n <GridLayout key={panelGroupId} panelGroupId={panelGroupId} />\n ))}\n </ErrorBoundary>\n </Box>\n );\n}\n"],"names":["Box","ErrorBoundary","ErrorAlert","usePanelGroupIds","GridLayout","Dashboard","props","panelGroupIds","FallbackComponent","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;AAI3C;;CAEC,GACD,OAAO,SAASC,SAAS,CAACC,KAAqB,EAAE;IAC/C,MAAMC,aAAa,GAAGJ,gBAAgB,EAAE,AAAC;IACzC,qBACE,KAACH,GAAG;QAAE,GAAGM,KAAK;kBACZ,cAAA,KAACL,aAAa;YAACO,iBAAiB,EAAEN,UAAU;sBACzCK,aAAa,CAACE,GAAG,CAAC,CAACC,YAAY,iBAC9B,KAACN,UAAU;oBAAoBM,YAAY,EAAEA,YAAY;mBAAxCA,YAAY,CAAgC,AAC9D,CAAC;UACY;MACZ,CACN;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Dashboard/index.ts"],"names":[],"mappings":"AAaA,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
export * from './Dashboard';
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Dashboard/index.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './Dashboard';\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,aAAa,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export interface DashboardToolbarProps {
|
|
3
3
|
dashboardName: string;
|
|
4
|
+
onEditButtonClick: () => void;
|
|
5
|
+
onCancelButtonClick: () => void;
|
|
4
6
|
}
|
|
5
7
|
export declare const DashboardToolbar: (props: DashboardToolbarProps) => JSX.Element;
|
|
6
8
|
//# sourceMappingURL=DashboardToolbar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DashboardToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/DashboardToolbar/DashboardToolbar.tsx"],"names":[],"mappings":";AAsBA,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,mBAAmB,EAAE,MAAM,IAAI,CAAC;CACjC;AAED,eAAO,MAAM,gBAAgB,UAAW,qBAAqB,gBA6E5D,CAAC"}
|