@perses-dev/dashboards 0.16.0 → 0.17.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/DashboardToolbar/DashboardToolbar.js +6 -12
- package/dist/cjs/components/GridLayout/GridLayout.js +13 -2
- package/dist/cjs/components/GridLayout/GridTitle.js +3 -5
- package/dist/cjs/components/Panel/PanelHeader.js +1 -1
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +1 -3
- package/dist/cjs/components/Variables/Variable.js +2 -46
- package/dist/cjs/components/Variables/VariableEditor.js +142 -130
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +303 -167
- package/dist/cjs/components/Variables/VariableList.js +10 -8
- package/dist/cjs/components/Variables/variable-model.js +74 -0
- package/dist/components/DashboardToolbar/DashboardToolbar.js +6 -12
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +13 -2
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.js +3 -5
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- package/dist/components/Panel/PanelHeader.js +1 -1
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +1 -3
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
- package/dist/components/Variables/Variable.d.ts.map +1 -1
- package/dist/components/Variables/Variable.js +3 -47
- package/dist/components/Variables/Variable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditor.js +142 -130
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +300 -169
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
- package/dist/components/Variables/VariableList.d.ts.map +1 -1
- package/dist/components/Variables/VariableList.js +10 -8
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/components/Variables/variable-model.d.ts +8 -0
- package/dist/components/Variables/variable-model.d.ts.map +1 -0
- package/dist/components/Variables/variable-model.js +64 -0
- package/dist/components/Variables/variable-model.js.map +1 -0
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VariableList.d.ts","sourceRoot":"","sources":["../../../src/components/Variables/VariableList.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"VariableList.d.ts","sourceRoot":"","sources":["../../../src/components/Variables/VariableList.tsx"],"names":[],"mappings":";AAwBA,UAAU,yBAAyB;IACjC,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,eAuDpE"}
|
|
@@ -12,11 +12,12 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import React, { useState } from 'react';
|
|
15
|
-
import { Button, Stack, Box,
|
|
15
|
+
import { Button, Stack, Box, AppBar, useScrollTrigger, IconButton } from '@mui/material';
|
|
16
16
|
import EyeIcon from 'mdi-material-ui/Eye';
|
|
17
17
|
import PencilIcon from 'mdi-material-ui/Pencil';
|
|
18
18
|
import PinOutline from 'mdi-material-ui/PinOutline';
|
|
19
19
|
import PinOffOutline from 'mdi-material-ui/PinOffOutline';
|
|
20
|
+
import { Drawer } from '@perses-dev/components';
|
|
20
21
|
import { useTemplateVariableDefinitions, useEditMode, useTemplateVariableActions } from '../../context';
|
|
21
22
|
import { TemplateVariable } from './Variable';
|
|
22
23
|
import { VariableEditor } from './VariableEditor';
|
|
@@ -32,21 +33,22 @@ export function TemplateVariableList(props) {
|
|
|
32
33
|
disableHysteresis: true
|
|
33
34
|
});
|
|
34
35
|
const isSticky = scrollTrigger && props.initialVariableIsSticky && isPin;
|
|
36
|
+
const onClose = ()=>{
|
|
37
|
+
setIsEditing(false);
|
|
38
|
+
};
|
|
35
39
|
return /*#__PURE__*/ _jsxs(Box, {
|
|
36
40
|
children: [
|
|
37
41
|
/*#__PURE__*/ _jsx(Drawer, {
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
isOpen: isEditing,
|
|
43
|
+
onClose: onClose,
|
|
40
44
|
PaperProps: {
|
|
41
45
|
sx: {
|
|
42
46
|
width: '50%'
|
|
43
47
|
}
|
|
44
48
|
},
|
|
45
49
|
children: /*#__PURE__*/ _jsx(VariableEditor, {
|
|
46
|
-
onCancel: ()=>{
|
|
47
|
-
setIsEditing(false);
|
|
48
|
-
},
|
|
49
50
|
variableDefinitions: variableDefinitions,
|
|
51
|
+
onCancel: onClose,
|
|
50
52
|
onChange: (v)=>{
|
|
51
53
|
setVariableDefinitions(v);
|
|
52
54
|
setIsEditing(false);
|
|
@@ -82,8 +84,8 @@ export function TemplateVariableList(props) {
|
|
|
82
84
|
ml: isSticky ? 2 : 0,
|
|
83
85
|
children: [
|
|
84
86
|
/*#__PURE__*/ _jsx(Stack, {
|
|
85
|
-
direction:
|
|
86
|
-
spacing:
|
|
87
|
+
direction: "row",
|
|
88
|
+
spacing: 1,
|
|
87
89
|
children: showVariables && variableDefinitions.map((v)=>{
|
|
88
90
|
var ref;
|
|
89
91
|
/*#__PURE__*/ return _jsx(Box, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Variables/VariableList.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 React, { useState } from 'react';\nimport { Button, Stack, Box,
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Variables/VariableList.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 React, { useState } from 'react';\nimport { Button, Stack, Box, AppBar, useScrollTrigger, IconButton } from '@mui/material';\nimport EyeIcon from 'mdi-material-ui/Eye';\nimport PencilIcon from 'mdi-material-ui/Pencil';\nimport PinOutline from 'mdi-material-ui/PinOutline';\nimport PinOffOutline from 'mdi-material-ui/PinOffOutline';\nimport { Drawer } from '@perses-dev/components';\nimport { useTemplateVariableDefinitions, useEditMode, useTemplateVariableActions } from '../../context';\nimport { TemplateVariable } from './Variable';\nimport { VariableEditor } from './VariableEditor';\n\ninterface TemplateVariableListProps {\n initialVariableIsSticky?: boolean;\n}\n\nexport function TemplateVariableList(props: TemplateVariableListProps) {\n const [isEditing, setIsEditing] = useState(false);\n const [isPin, setIsPin] = useState(props.initialVariableIsSticky);\n const variableDefinitions = useTemplateVariableDefinitions();\n const { isEditMode } = useEditMode();\n const [showVariablesInEditMode, setShowVariablesInEditMode] = useState(true);\n const showVariables = isEditMode ? showVariablesInEditMode : true;\n const { setVariableDefinitions } = useTemplateVariableActions();\n const scrollTrigger = useScrollTrigger({ disableHysteresis: true });\n const isSticky = scrollTrigger && props.initialVariableIsSticky && isPin;\n\n const onClose = () => {\n setIsEditing(false);\n };\n\n return (\n <Box>\n <Drawer isOpen={isEditing} onClose={onClose} PaperProps={{ sx: { width: '50%' } }}>\n <VariableEditor\n variableDefinitions={variableDefinitions}\n onCancel={onClose}\n onChange={(v) => {\n setVariableDefinitions(v);\n setIsEditing(false);\n }}\n />\n </Drawer>\n {isEditMode && (\n <Box pb={2}>\n <Button onClick={() => setShowVariablesInEditMode(!showVariablesInEditMode)} startIcon={<EyeIcon />}>\n {showVariablesInEditMode ? 'Hide' : 'Show'} Variables\n </Button>\n <Button onClick={() => setIsEditing(true)} startIcon={<PencilIcon />}>\n Edit Variables\n </Button>\n </Box>\n )}\n\n <AppBar color={'inherit'} position={isSticky ? 'fixed' : 'static'} elevation={isSticky ? 4 : 0}>\n <Box display={'flex'} justifyContent=\"space-between\" my={isSticky ? 2 : 0} ml={isSticky ? 2 : 0}>\n <Stack direction=\"row\" spacing={1}>\n {showVariables &&\n variableDefinitions.map((v) => (\n <Box key={v.spec.name} display={v.spec.display?.hidden ? 'none' : undefined}>\n <TemplateVariable key={v.spec.name} name={v.spec.name} />\n </Box>\n ))}\n </Stack>\n {props.initialVariableIsSticky && (\n <IconButton onClick={() => setIsPin(!isPin)}>{isPin ? <PinOutline /> : <PinOffOutline />}</IconButton>\n )}\n </Box>\n </AppBar>\n </Box>\n );\n}\n"],"names":["React","useState","Button","Stack","Box","AppBar","useScrollTrigger","IconButton","EyeIcon","PencilIcon","PinOutline","PinOffOutline","Drawer","useTemplateVariableDefinitions","useEditMode","useTemplateVariableActions","TemplateVariable","VariableEditor","TemplateVariableList","props","isEditing","setIsEditing","isPin","setIsPin","initialVariableIsSticky","variableDefinitions","isEditMode","showVariablesInEditMode","setShowVariablesInEditMode","showVariables","setVariableDefinitions","scrollTrigger","disableHysteresis","isSticky","onClose","isOpen","PaperProps","sx","width","onCancel","onChange","v","pb","onClick","startIcon","color","position","elevation","display","justifyContent","my","ml","direction","spacing","map","spec","hidden","undefined","name"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;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AAe;oBAACC,EAAE,EAAEjB,QAAQ,GAAG,CAAC,GAAG,CAAC;oBAAEkB,EAAE,EAAElB,QAAQ,GAAG,CAAC,GAAG,CAAC;;sCAC7F,KAAC9B,KAAK;4BAACiD,SAAS,EAAC,KAAK;4BAACC,OAAO,EAAE,CAAC;sCAC9BxB,aAAa,IACZJ,mBAAmB,CAAC6B,GAAG,CAAC,CAACb,CAAC;oCACQA,GAAc;8CAA9C,OAAA,KAACrC,GAAG;oCAAmB4C,OAAO,EAAEP,CAAAA,CAAAA,GAAc,GAAdA,CAAC,CAACc,IAAI,CAACP,OAAO,cAAdP,GAAc,WAAQ,GAAtBA,KAAAA,CAAsB,GAAtBA,GAAc,CAAEe,MAAM,CAAA,GAAG,MAAM,GAAGC,SAAS;8CACzE,cAAA,KAACzC,gBAAgB;wCAAmB0C,IAAI,EAAEjB,CAAC,CAACc,IAAI,CAACG,IAAI;uCAA9BjB,CAAC,CAACc,IAAI,CAACG,IAAI,CAAuB;mCADjDjB,CAAC,CAACc,IAAI,CAACG,IAAI,CAEf,CAAA;6BACP,CAAC;0BACE;wBACPvC,KAAK,CAACK,uBAAuB,kBAC5B,KAACjB,UAAU;4BAACoC,OAAO,EAAE,IAAMpB,QAAQ,CAAC,CAACD,KAAK,CAAC;sCAAGA,KAAK,iBAAG,KAACZ,UAAU,KAAG,iBAAG,KAACC,aAAa,KAAG;0BAAc,AACvG;;kBACG;cACC;;MACL,CACN;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ListVariableDefinition } from '@perses-dev/core';
|
|
2
|
+
import { VariableStateMap } from '@perses-dev/plugin-system';
|
|
3
|
+
export declare function useListVariablePluginValues(definition: ListVariableDefinition): import("@tanstack/react-query").UseQueryResult<import("@perses-dev/plugin-system").VariableOption[], unknown>;
|
|
4
|
+
/**
|
|
5
|
+
* Returns a serialized string of the current state of variable values.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getVariableValuesKey(v: VariableStateMap): string;
|
|
8
|
+
//# sourceMappingURL=variable-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variable-model.d.ts","sourceRoot":"","sources":["../../../src/components/Variables/variable-model.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAKL,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AAGnC,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,sBAAsB,iHAmC7E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,gBAAgB,UAIvD"}
|
|
@@ -0,0 +1,64 @@
|
|
|
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 { usePlugin, useTemplateVariableValues, useDatasourceStore, useTimeRange } from '@perses-dev/plugin-system';
|
|
14
|
+
import { useQuery } from '@tanstack/react-query';
|
|
15
|
+
export function useListVariablePluginValues(definition) {
|
|
16
|
+
const { data: variablePlugin } = usePlugin('Variable', definition.spec.plugin.kind);
|
|
17
|
+
const datasourceStore = useDatasourceStore();
|
|
18
|
+
const allVariables = useTemplateVariableValues();
|
|
19
|
+
const { timeRange } = useTimeRange();
|
|
20
|
+
const variablePluginCtx = {
|
|
21
|
+
timeRange,
|
|
22
|
+
datasourceStore,
|
|
23
|
+
variables: allVariables
|
|
24
|
+
};
|
|
25
|
+
const spec = definition.spec.plugin.spec;
|
|
26
|
+
let dependsOnVariables;
|
|
27
|
+
if (variablePlugin === null || variablePlugin === void 0 ? void 0 : variablePlugin.dependsOn) {
|
|
28
|
+
const dependencies = variablePlugin.dependsOn(spec, variablePluginCtx);
|
|
29
|
+
dependsOnVariables = dependencies.variables;
|
|
30
|
+
}
|
|
31
|
+
const variables = useTemplateVariableValues(dependsOnVariables);
|
|
32
|
+
let waitToLoad = false;
|
|
33
|
+
if (dependsOnVariables) {
|
|
34
|
+
waitToLoad = dependsOnVariables.some((v)=>{
|
|
35
|
+
var ref;
|
|
36
|
+
return (ref = variables[v]) === null || ref === void 0 ? void 0 : ref.loading;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
const variablesValueKey = getVariableValuesKey(variables);
|
|
40
|
+
const variablesOptionsQuery = useQuery([
|
|
41
|
+
name,
|
|
42
|
+
definition,
|
|
43
|
+
variablesValueKey,
|
|
44
|
+
timeRange
|
|
45
|
+
], async ()=>{
|
|
46
|
+
const resp = await (variablePlugin === null || variablePlugin === void 0 ? void 0 : variablePlugin.getVariableOptions(spec, {
|
|
47
|
+
datasourceStore,
|
|
48
|
+
variables,
|
|
49
|
+
timeRange
|
|
50
|
+
}));
|
|
51
|
+
var ref;
|
|
52
|
+
return (ref = resp === null || resp === void 0 ? void 0 : resp.data) !== null && ref !== void 0 ? ref : [];
|
|
53
|
+
}, {
|
|
54
|
+
enabled: !!variablePlugin || waitToLoad
|
|
55
|
+
});
|
|
56
|
+
return variablesOptionsQuery;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Returns a serialized string of the current state of variable values.
|
|
60
|
+
*/ export function getVariableValuesKey(v) {
|
|
61
|
+
return Object.values(v).map((v)=>JSON.stringify(v.value)).join(',');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=variable-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Variables/variable-model.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\nimport { ListVariableDefinition } from '@perses-dev/core';\nimport {\n usePlugin,\n useTemplateVariableValues,\n useDatasourceStore,\n useTimeRange,\n VariableStateMap,\n} from '@perses-dev/plugin-system';\nimport { useQuery } from '@tanstack/react-query';\n\nexport function useListVariablePluginValues(definition: ListVariableDefinition) {\n const { data: variablePlugin } = usePlugin('Variable', definition.spec.plugin.kind);\n const datasourceStore = useDatasourceStore();\n const allVariables = useTemplateVariableValues();\n const { timeRange } = useTimeRange();\n\n const variablePluginCtx = { timeRange, datasourceStore, variables: allVariables };\n\n const spec = definition.spec.plugin.spec;\n\n let dependsOnVariables: string[] | undefined;\n if (variablePlugin?.dependsOn) {\n const dependencies = variablePlugin.dependsOn(spec, variablePluginCtx);\n dependsOnVariables = dependencies.variables;\n }\n\n const variables = useTemplateVariableValues(dependsOnVariables);\n\n let waitToLoad = false;\n if (dependsOnVariables) {\n waitToLoad = dependsOnVariables.some((v) => variables[v]?.loading);\n }\n\n const variablesValueKey = getVariableValuesKey(variables);\n\n const variablesOptionsQuery = useQuery(\n [name, definition, variablesValueKey, timeRange],\n async () => {\n const resp = await variablePlugin?.getVariableOptions(spec, { datasourceStore, variables, timeRange });\n return resp?.data ?? [];\n },\n { enabled: !!variablePlugin || waitToLoad }\n );\n\n return variablesOptionsQuery;\n}\n\n/**\n * Returns a serialized string of the current state of variable values.\n */\nexport function getVariableValuesKey(v: VariableStateMap) {\n return Object.values(v)\n .map((v) => JSON.stringify(v.value))\n .join(',');\n}\n"],"names":["usePlugin","useTemplateVariableValues","useDatasourceStore","useTimeRange","useQuery","useListVariablePluginValues","definition","data","variablePlugin","spec","plugin","kind","datasourceStore","allVariables","timeRange","variablePluginCtx","variables","dependsOnVariables","dependsOn","dependencies","waitToLoad","some","v","loading","variablesValueKey","getVariableValuesKey","variablesOptionsQuery","name","resp","getVariableOptions","enabled","Object","values","map","JSON","stringify","value","join"],"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;AAGjC,SACEA,SAAS,EACTC,yBAAyB,EACzBC,kBAAkB,EAClBC,YAAY,QAEP,2BAA2B,CAAC;AACnC,SAASC,QAAQ,QAAQ,uBAAuB,CAAC;AAEjD,OAAO,SAASC,2BAA2B,CAACC,UAAkC,EAAE;IAC9E,MAAM,EAAEC,IAAI,EAAEC,cAAc,CAAA,EAAE,GAAGR,SAAS,CAAC,UAAU,EAAEM,UAAU,CAACG,IAAI,CAACC,MAAM,CAACC,IAAI,CAAC,AAAC;IACpF,MAAMC,eAAe,GAAGV,kBAAkB,EAAE,AAAC;IAC7C,MAAMW,YAAY,GAAGZ,yBAAyB,EAAE,AAAC;IACjD,MAAM,EAAEa,SAAS,CAAA,EAAE,GAAGX,YAAY,EAAE,AAAC;IAErC,MAAMY,iBAAiB,GAAG;QAAED,SAAS;QAAEF,eAAe;QAAEI,SAAS,EAAEH,YAAY;KAAE,AAAC;IAElF,MAAMJ,IAAI,GAAGH,UAAU,CAACG,IAAI,CAACC,MAAM,CAACD,IAAI,AAAC;IAEzC,IAAIQ,kBAAkB,AAAsB,AAAC;IAC7C,IAAIT,cAAc,aAAdA,cAAc,WAAW,GAAzBA,KAAAA,CAAyB,GAAzBA,cAAc,CAAEU,SAAS,EAAE;QAC7B,MAAMC,YAAY,GAAGX,cAAc,CAACU,SAAS,CAACT,IAAI,EAAEM,iBAA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AC,CAACX,CAAC,GAAKY,IAAI,CAACC,SAAS,CAACb,CAAC,CAACc,KAAK,CAAC,CAAC,CACnCC,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perses-dev/dashboards",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "The dashboards feature in Perses",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/perses/perses/blob/main/README.md",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"lint:fix": "eslint --fix src --ext .ts,.tsx"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@perses-dev/components": "^0.
|
|
32
|
-
"@perses-dev/core": "^0.
|
|
33
|
-
"@perses-dev/plugin-system": "^0.
|
|
31
|
+
"@perses-dev/components": "^0.17.0",
|
|
32
|
+
"@perses-dev/core": "^0.17.0",
|
|
33
|
+
"@perses-dev/plugin-system": "^0.17.0",
|
|
34
34
|
"@types/react-grid-layout": "^1.3.2",
|
|
35
35
|
"date-fns": "^2.28.0",
|
|
36
36
|
"immer": "^9.0.15",
|