@perses-dev/dashboards 0.0.0-snapshot-time-chart-rewrite-4667058 → 0.0.0-snapshot-panel-extra-content-3-17f9c42
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/EditJsonDialog/EditJsonDialog.js +2 -1
- package/dist/cjs/components/GridLayout/GridItemContent.js +3 -1
- package/dist/cjs/components/GridLayout/GridLayout.js +1 -0
- package/dist/cjs/components/GridLayout/index.js +3 -1
- 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/DashboardProvider/DashboardProvider.js +3 -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/views/ViewDashboard/DashboardApp.js +1 -1
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +6 -4
- 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/EditJsonDialog/EditJsonDialog.js +2 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.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/GridLayout/index.d.ts +3 -1
- package/dist/components/GridLayout/index.d.ts.map +1 -1
- package/dist/components/GridLayout/index.js +3 -1
- package/dist/components/GridLayout/index.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/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/DashboardProvider/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +3 -2
- package/dist/context/DashboardProvider/DashboardProvider.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/views/ViewDashboard/DashboardApp.js +2 -2
- 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 +6 -4
- 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
|
@@ -14,7 +14,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
14
14
|
import { useState } from 'react';
|
|
15
15
|
import { Box } from '@mui/material';
|
|
16
16
|
import { ErrorAlert, ErrorBoundary } from '@perses-dev/components';
|
|
17
|
-
import { PanelDrawer, Dashboard, PanelGroupDialog, DeletePanelGroupDialog,
|
|
17
|
+
import { PanelDrawer, Dashboard, PanelGroupDialog, DeletePanelGroupDialog, DashboardDiscardChangesConfirmationDialog, DashboardToolbar, DeletePanelDialog, EditJsonDialog, SaveChangesConfirmationDialog } from '../../components';
|
|
18
18
|
import { useDashboard, useDiscardChangesConfirmationDialog, useEditMode } from '../../context';
|
|
19
19
|
export const DashboardApp = (props)=>{
|
|
20
20
|
const { dashboardResource , dashboardTitleComponent , emptyDashboardProps , onSave , onDiscard , initialVariableIsSticky , isReadonly , } = props;
|
|
@@ -89,7 +89,7 @@ export const DashboardApp = (props)=>{
|
|
|
89
89
|
/*#__PURE__*/ _jsx(PanelGroupDialog, {}),
|
|
90
90
|
/*#__PURE__*/ _jsx(DeletePanelGroupDialog, {}),
|
|
91
91
|
/*#__PURE__*/ _jsx(DeletePanelDialog, {}),
|
|
92
|
-
/*#__PURE__*/ _jsx(
|
|
92
|
+
/*#__PURE__*/ _jsx(DashboardDiscardChangesConfirmationDialog, {}),
|
|
93
93
|
/*#__PURE__*/ _jsx(EditJsonDialog, {}),
|
|
94
94
|
/*#__PURE__*/ _jsx(SaveChangesConfirmationDialog, {})
|
|
95
95
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/views/ViewDashboard/DashboardApp.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 { useState } from 'react';\nimport { Box } from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { DashboardResource } from '@perses-dev/core';\nimport {\n PanelDrawer,\n Dashboard,\n PanelGroupDialog,\n DeletePanelGroupDialog,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/views/ViewDashboard/DashboardApp.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 { useState } from 'react';\nimport { Box } from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { DashboardResource } from '@perses-dev/core';\nimport {\n PanelDrawer,\n Dashboard,\n PanelGroupDialog,\n DeletePanelGroupDialog,\n DashboardDiscardChangesConfirmationDialog,\n DashboardToolbar,\n DeletePanelDialog,\n EmptyDashboardProps,\n EditJsonDialog,\n SaveChangesConfirmationDialog,\n} from '../../components';\nimport { OnSaveDashboard, useDashboard, useDiscardChangesConfirmationDialog, useEditMode } from '../../context';\n\nexport interface DashboardAppProps {\n emptyDashboardProps?: Partial<EmptyDashboardProps>;\n dashboardResource: DashboardResource;\n dashboardTitleComponent?: JSX.Element;\n onSave?: OnSaveDashboard;\n onDiscard?: (entity: DashboardResource) => void;\n initialVariableIsSticky?: boolean;\n isReadonly: boolean;\n}\n\nexport const DashboardApp = (props: DashboardAppProps) => {\n const {\n dashboardResource,\n dashboardTitleComponent,\n emptyDashboardProps,\n onSave,\n onDiscard,\n initialVariableIsSticky,\n isReadonly,\n } = props;\n const { setEditMode } = useEditMode();\n const { dashboard, setDashboard } = useDashboard();\n const [originalDashboard, setOriginalDashboard] = useState<DashboardResource | undefined>(undefined);\n\n const { openDiscardChangesConfirmationDialog, closeDiscardChangesConfirmationDialog } =\n useDiscardChangesConfirmationDialog();\n\n const handleDiscardChanges = () => {\n // Reset to the original spec and exit edit mode\n if (originalDashboard) {\n setDashboard(originalDashboard);\n }\n setEditMode(false);\n closeDiscardChangesConfirmationDialog();\n if (onDiscard) {\n onDiscard(dashboard);\n }\n };\n\n const onEditButtonClick = () => {\n setEditMode(true);\n setOriginalDashboard(dashboard);\n };\n\n const onCancelButtonClick = () => {\n // check if dashboard has been modified\n if (JSON.stringify(dashboard) === JSON.stringify(originalDashboard)) {\n setEditMode(false);\n } else {\n openDiscardChangesConfirmationDialog({\n onDiscardChanges: () => {\n handleDiscardChanges();\n },\n onCancel: () => {\n closeDiscardChangesConfirmationDialog();\n },\n });\n }\n };\n\n return (\n <Box\n sx={{\n flexGrow: 1,\n overflowX: 'hidden',\n overflowY: 'auto',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n <DashboardToolbar\n dashboardName={dashboardResource.metadata.name}\n dashboardTitleComponent={dashboardTitleComponent}\n initialVariableIsSticky={initialVariableIsSticky}\n onSave={onSave}\n isReadonly={isReadonly}\n onEditButtonClick={onEditButtonClick}\n onCancelButtonClick={onCancelButtonClick}\n />\n <Box sx={{ padding: (theme) => theme.spacing(2), height: '100%' }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <Dashboard\n emptyDashboardProps={{\n onEditButtonClick,\n ...emptyDashboardProps,\n }}\n />\n </ErrorBoundary>\n <PanelDrawer />\n <PanelGroupDialog />\n <DeletePanelGroupDialog />\n <DeletePanelDialog />\n <DashboardDiscardChangesConfirmationDialog />\n <EditJsonDialog />\n <SaveChangesConfirmationDialog />\n </Box>\n </Box>\n );\n};\n"],"names":["useState","Box","ErrorAlert","ErrorBoundary","PanelDrawer","Dashboard","PanelGroupDialog","DeletePanelGroupDialog","DashboardDiscardChangesConfirmationDialog","DashboardToolbar","DeletePanelDialog","EditJsonDialog","SaveChangesConfirmationDialog","useDashboard","useDiscardChangesConfirmationDialog","useEditMode","DashboardApp","props","dashboardResource","dashboardTitleComponent","emptyDashboardProps","onSave","onDiscard","initialVariableIsSticky","isReadonly","setEditMode","dashboard","setDashboard","originalDashboard","setOriginalDashboard","undefined","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","handleDiscardChanges","onEditButtonClick","onCancelButtonClick","JSON","stringify","onDiscardChanges","onCancel","sx","flexGrow","overflowX","overflowY","display","flexDirection","dashboardName","metadata","name","padding","theme","spacing","height","FallbackComponent"],"mappings":"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"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BoxProps } from '@mui/material';
|
|
3
|
-
import { DatasourceStoreProviderProps } from '../../context';
|
|
3
|
+
import { DatasourceStoreProviderProps, TemplateVariableProviderProps } from '../../context';
|
|
4
4
|
import { DashboardAppProps } from './DashboardApp';
|
|
5
5
|
export interface ViewDashboardProps extends Omit<BoxProps, 'children'>, DashboardAppProps {
|
|
6
6
|
datasourceApi: DatasourceStoreProviderProps['datasourceApi'];
|
|
7
|
+
externalVariableDefinitions?: TemplateVariableProviderProps['externalVariableDefinitions'];
|
|
7
8
|
isEditing?: boolean;
|
|
8
9
|
}
|
|
9
10
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewDashboard.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/ViewDashboard.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"ViewDashboard.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/ViewDashboard.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAI9C,OAAO,EAGL,4BAA4B,EAE5B,6BAA6B,EAC9B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAgB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEjE,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,iBAAiB;IACvF,aAAa,EAAE,4BAA4B,CAAC,eAAe,CAAC,CAAC;IAC7D,2BAA2B,CAAC,EAAE,6BAA6B,CAAC,6BAA6B,CAAC,CAAC;IAC3F,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,eA+DtD"}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { Box } from '@mui/material';
|
|
15
|
+
import { DEFAULT_DASHBOARD_DURATION, DEFAULT_REFRESH_INTERVAL } from '@perses-dev/core';
|
|
15
16
|
import { ErrorBoundary, ErrorAlert, combineSx } from '@perses-dev/components';
|
|
16
17
|
import { TimeRangeProvider, useInitialRefreshInterval, useInitialTimeRange } from '@perses-dev/plugin-system';
|
|
17
18
|
import { TemplateVariableProvider, DashboardProvider, DatasourceStoreProvider } from '../../context';
|
|
@@ -19,14 +20,14 @@ import { DashboardApp } from './DashboardApp';
|
|
|
19
20
|
/**
|
|
20
21
|
* The View for displaying a Dashboard, along with the UI for selecting variable values.
|
|
21
22
|
*/ export function ViewDashboard(props) {
|
|
22
|
-
const { dashboardResource , datasourceApi , dashboardTitleComponent , emptyDashboardProps , onSave , onDiscard , initialVariableIsSticky , isReadonly , isEditing , sx , ...others } = props;
|
|
23
|
+
const { dashboardResource , datasourceApi , externalVariableDefinitions , dashboardTitleComponent , emptyDashboardProps , onSave , onDiscard , initialVariableIsSticky , isReadonly , isEditing , sx , ...others } = props;
|
|
23
24
|
const { spec } = dashboardResource;
|
|
24
25
|
var _duration;
|
|
25
|
-
const dashboardDuration = (_duration = spec.duration) !== null && _duration !== void 0 ? _duration :
|
|
26
|
+
const dashboardDuration = (_duration = spec.duration) !== null && _duration !== void 0 ? _duration : DEFAULT_DASHBOARD_DURATION;
|
|
26
27
|
var _refreshInterval;
|
|
27
|
-
const
|
|
28
|
+
const dashboardRefreshInterval = (_refreshInterval = spec.refreshInterval) !== null && _refreshInterval !== void 0 ? _refreshInterval : DEFAULT_REFRESH_INTERVAL;
|
|
28
29
|
const initialTimeRange = useInitialTimeRange(dashboardDuration);
|
|
29
|
-
const initialRefreshInterval = useInitialRefreshInterval(
|
|
30
|
+
const initialRefreshInterval = useInitialRefreshInterval(dashboardRefreshInterval);
|
|
30
31
|
return /*#__PURE__*/ _jsx(DatasourceStoreProvider, {
|
|
31
32
|
dashboardResource: dashboardResource,
|
|
32
33
|
datasourceApi: datasourceApi,
|
|
@@ -41,6 +42,7 @@ import { DashboardApp } from './DashboardApp';
|
|
|
41
42
|
enabledURLParams: true,
|
|
42
43
|
children: /*#__PURE__*/ _jsx(TemplateVariableProvider, {
|
|
43
44
|
initialVariableDefinitions: spec.variables,
|
|
45
|
+
externalVariableDefinitions: externalVariableDefinitions,
|
|
44
46
|
children: /*#__PURE__*/ _jsx(Box, {
|
|
45
47
|
sx: combineSx({
|
|
46
48
|
display: 'flex',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/views/ViewDashboard/ViewDashboard.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, combineSx } from '@perses-dev/components';\nimport { TimeRangeProvider, useInitialRefreshInterval, useInitialTimeRange } from '@perses-dev/plugin-system';\nimport {\n TemplateVariableProvider,\n DashboardProvider,\n DatasourceStoreProviderProps,\n DatasourceStoreProvider,\n} from '../../context';\nimport { DashboardApp, DashboardAppProps } from './DashboardApp';\n\nexport interface ViewDashboardProps extends Omit<BoxProps, 'children'>, DashboardAppProps {\n datasourceApi: DatasourceStoreProviderProps['datasourceApi'];\n isEditing?: boolean;\n}\n\n/**\n * The View for displaying a Dashboard, along with the UI for selecting variable values.\n */\nexport function ViewDashboard(props: ViewDashboardProps) {\n const {\n dashboardResource,\n datasourceApi,\n dashboardTitleComponent,\n emptyDashboardProps,\n onSave,\n onDiscard,\n initialVariableIsSticky,\n isReadonly,\n isEditing,\n sx,\n ...others\n } = props;\n const { spec } = dashboardResource;\n const dashboardDuration = spec.duration ??
|
|
1
|
+
{"version":3,"sources":["../../../src/views/ViewDashboard/ViewDashboard.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 { DEFAULT_DASHBOARD_DURATION, DEFAULT_REFRESH_INTERVAL } from '@perses-dev/core';\nimport { ErrorBoundary, ErrorAlert, combineSx } from '@perses-dev/components';\nimport { TimeRangeProvider, useInitialRefreshInterval, useInitialTimeRange } from '@perses-dev/plugin-system';\nimport {\n TemplateVariableProvider,\n DashboardProvider,\n DatasourceStoreProviderProps,\n DatasourceStoreProvider,\n TemplateVariableProviderProps,\n} from '../../context';\nimport { DashboardApp, DashboardAppProps } from './DashboardApp';\n\nexport interface ViewDashboardProps extends Omit<BoxProps, 'children'>, DashboardAppProps {\n datasourceApi: DatasourceStoreProviderProps['datasourceApi'];\n externalVariableDefinitions?: TemplateVariableProviderProps['externalVariableDefinitions'];\n isEditing?: boolean;\n}\n\n/**\n * The View for displaying a Dashboard, along with the UI for selecting variable values.\n */\nexport function ViewDashboard(props: ViewDashboardProps) {\n const {\n dashboardResource,\n datasourceApi,\n externalVariableDefinitions,\n dashboardTitleComponent,\n emptyDashboardProps,\n onSave,\n onDiscard,\n initialVariableIsSticky,\n isReadonly,\n isEditing,\n sx,\n ...others\n } = props;\n const { spec } = dashboardResource;\n const dashboardDuration = spec.duration ?? DEFAULT_DASHBOARD_DURATION;\n const dashboardRefreshInterval = spec.refreshInterval ?? DEFAULT_REFRESH_INTERVAL;\n const initialTimeRange = useInitialTimeRange(dashboardDuration);\n const initialRefreshInterval = useInitialRefreshInterval(dashboardRefreshInterval);\n\n return (\n <DatasourceStoreProvider dashboardResource={dashboardResource} datasourceApi={datasourceApi}>\n <DashboardProvider initialState={{ dashboardResource, isEditMode: !!isEditing }}>\n <TimeRangeProvider\n initialTimeRange={initialTimeRange}\n initialRefreshInterval={initialRefreshInterval}\n enabledURLParams={true}\n >\n <TemplateVariableProvider\n initialVariableDefinitions={spec.variables}\n externalVariableDefinitions={externalVariableDefinitions}\n >\n <Box\n sx={combineSx(\n {\n display: 'flex',\n width: '100%',\n height: '100%',\n position: 'relative',\n overflow: 'hidden',\n },\n sx\n )}\n {...others}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <DashboardApp\n dashboardResource={dashboardResource}\n dashboardTitleComponent={dashboardTitleComponent}\n emptyDashboardProps={emptyDashboardProps}\n onSave={onSave}\n onDiscard={onDiscard}\n initialVariableIsSticky={initialVariableIsSticky}\n isReadonly={isReadonly}\n />\n </ErrorBoundary>\n </Box>\n </TemplateVariableProvider>\n </TimeRangeProvider>\n </DashboardProvider>\n </DatasourceStoreProvider>\n );\n}\n"],"names":["Box","DEFAULT_DASHBOARD_DURATION","DEFAULT_REFRESH_INTERVAL","ErrorBoundary","ErrorAlert","combineSx","TimeRangeProvider","useInitialRefreshInterval","useInitialTimeRange","TemplateVariableProvider","DashboardProvider","DatasourceStoreProvider","DashboardApp","ViewDashboard","props","dashboardResource","datasourceApi","externalVariableDefinitions","dashboardTitleComponent","emptyDashboardProps","onSave","onDiscard","initialVariableIsSticky","isReadonly","isEditing","sx","others","spec","dashboardDuration","duration","dashboardRefreshInterval","refreshInterval","initialTimeRange","initialRefreshInterval","initialState","isEditMode","enabledURLParams","initialVariableDefinitions","variables","display","width","height","position","overflow","FallbackComponent"],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perses-dev/dashboards",
|
|
3
|
-
"version": "0.0.0-snapshot-
|
|
3
|
+
"version": "0.0.0-snapshot-panel-extra-content-3-17f9c42",
|
|
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",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"lint:fix": "eslint --fix src --ext .ts,.tsx"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@perses-dev/components": "0.0.0-snapshot-
|
|
33
|
-
"@perses-dev/core": "0.0.0-snapshot-
|
|
34
|
-
"@perses-dev/plugin-system": "0.0.0-snapshot-
|
|
32
|
+
"@perses-dev/components": "0.0.0-snapshot-panel-extra-content-3-17f9c42",
|
|
33
|
+
"@perses-dev/core": "0.0.0-snapshot-panel-extra-content-3-17f9c42",
|
|
34
|
+
"@perses-dev/plugin-system": "0.0.0-snapshot-panel-extra-content-3-17f9c42",
|
|
35
35
|
"@types/react-grid-layout": "^1.3.2",
|
|
36
36
|
"date-fns": "^2.28.0",
|
|
37
37
|
"immer": "^9.0.15",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"zustand": "^4.3.3"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@perses-dev/internal-utils": "0.0.0-snapshot-
|
|
48
|
-
"@perses-dev/storybook": "0.0.0-snapshot-
|
|
47
|
+
"@perses-dev/internal-utils": "0.0.0-snapshot-panel-extra-content-3-17f9c42",
|
|
48
|
+
"@perses-dev/storybook": "0.0.0-snapshot-panel-extra-content-3-17f9c42",
|
|
49
49
|
"history": "^5.3.0",
|
|
50
50
|
"intersection-observer": "^0.12.2"
|
|
51
51
|
},
|
|
@@ -1,399 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 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, "VariableEditForm", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: ()=>VariableEditForm
|
|
20
|
-
});
|
|
21
|
-
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
23
|
-
const _material = require("@mui/material");
|
|
24
|
-
const _useImmer = require("use-immer");
|
|
25
|
-
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
26
|
-
const _components = require("@perses-dev/components");
|
|
27
|
-
const _variableModel = require("../variable-model");
|
|
28
|
-
const _variablePreview = require("./VariablePreview");
|
|
29
|
-
const _variableEditorFormModel = require("./variable-editor-form-model");
|
|
30
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
31
|
-
if (typeof WeakMap !== "function") return null;
|
|
32
|
-
var cacheBabelInterop = new WeakMap();
|
|
33
|
-
var cacheNodeInterop = new WeakMap();
|
|
34
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
35
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
36
|
-
})(nodeInterop);
|
|
37
|
-
}
|
|
38
|
-
function _interopRequireWildcard(obj, nodeInterop) {
|
|
39
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
40
|
-
return obj;
|
|
41
|
-
}
|
|
42
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
43
|
-
return {
|
|
44
|
-
default: obj
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
48
|
-
if (cache && cache.has(obj)) {
|
|
49
|
-
return cache.get(obj);
|
|
50
|
-
}
|
|
51
|
-
var newObj = {};
|
|
52
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
53
|
-
for(var key in obj){
|
|
54
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
55
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
56
|
-
if (desc && (desc.get || desc.set)) {
|
|
57
|
-
Object.defineProperty(newObj, key, desc);
|
|
58
|
-
} else {
|
|
59
|
-
newObj[key] = obj[key];
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
newObj.default = obj;
|
|
64
|
-
if (cache) {
|
|
65
|
-
cache.set(obj, newObj);
|
|
66
|
-
}
|
|
67
|
-
return newObj;
|
|
68
|
-
}
|
|
69
|
-
// TODO: Replace with proper validation library
|
|
70
|
-
function getValidation(state) {
|
|
71
|
-
/** Name validation */ let name = null;
|
|
72
|
-
if (!state.name) {
|
|
73
|
-
name = 'Name is required';
|
|
74
|
-
}
|
|
75
|
-
// name can only contain alphanumeric characters and underscores and no spaces
|
|
76
|
-
if (state.name && !/^[a-zA-Z0-9_-]+$/.test(state.name)) {
|
|
77
|
-
name = 'Name can only contain alphanumeric characters, underscores, and dashes';
|
|
78
|
-
}
|
|
79
|
-
return {
|
|
80
|
-
name,
|
|
81
|
-
isValid: !name
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
function FallbackPreview() {
|
|
85
|
-
return /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
86
|
-
children: "Error previewing values"
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
function VariableEditForm(props) {
|
|
90
|
-
const { initialVariableDefinition , onChange , onCancel } = props;
|
|
91
|
-
const [state, setState] = (0, _useImmer.useImmer)((0, _variableEditorFormModel.getInitialState)(initialVariableDefinition));
|
|
92
|
-
const validation = (0, _react.useMemo)(()=>getValidation(state), [
|
|
93
|
-
state
|
|
94
|
-
]);
|
|
95
|
-
const [previewKey, setPreviewKey] = (0, _react.useState)(0);
|
|
96
|
-
const refreshPreview = ()=>{
|
|
97
|
-
setPreviewKey((prev)=>prev + 1);
|
|
98
|
-
};
|
|
99
|
-
/** We use the `previewKey` that we increment to know when to explicitly update the
|
|
100
|
-
* spec that will be used for preview. The reason why we do this is to avoid
|
|
101
|
-
* having to re-fetch the values when the user is still editing the spec.
|
|
102
|
-
*/ const previewSpec = (0, _react.useMemo)(()=>{
|
|
103
|
-
return (0, _variableEditorFormModel.getVariableDefinitionFromState)(state);
|
|
104
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
105
|
-
}, [
|
|
106
|
-
previewKey
|
|
107
|
-
]);
|
|
108
|
-
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
109
|
-
children: [
|
|
110
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
111
|
-
sx: {
|
|
112
|
-
display: 'flex',
|
|
113
|
-
alignItems: 'center',
|
|
114
|
-
padding: (theme)=>theme.spacing(1, 2),
|
|
115
|
-
borderBottom: (theme)=>`1px solid ${theme.palette.divider}`
|
|
116
|
-
},
|
|
117
|
-
children: [
|
|
118
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
119
|
-
variant: "h2",
|
|
120
|
-
children: "Edit Variable"
|
|
121
|
-
}),
|
|
122
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
123
|
-
direction: "row",
|
|
124
|
-
spacing: 1,
|
|
125
|
-
sx: {
|
|
126
|
-
marginLeft: 'auto'
|
|
127
|
-
},
|
|
128
|
-
children: [
|
|
129
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
130
|
-
disabled: !validation.isValid,
|
|
131
|
-
variant: "contained",
|
|
132
|
-
onClick: ()=>{
|
|
133
|
-
onChange((0, _variableEditorFormModel.getVariableDefinitionFromState)(state));
|
|
134
|
-
},
|
|
135
|
-
children: "Update"
|
|
136
|
-
}),
|
|
137
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
138
|
-
color: "secondary",
|
|
139
|
-
variant: "outlined",
|
|
140
|
-
onClick: ()=>{
|
|
141
|
-
onCancel();
|
|
142
|
-
},
|
|
143
|
-
children: "Cancel"
|
|
144
|
-
})
|
|
145
|
-
]
|
|
146
|
-
})
|
|
147
|
-
]
|
|
148
|
-
}),
|
|
149
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
150
|
-
padding: 2,
|
|
151
|
-
sx: {
|
|
152
|
-
overflowY: 'scroll'
|
|
153
|
-
},
|
|
154
|
-
children: [
|
|
155
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
|
|
156
|
-
container: true,
|
|
157
|
-
spacing: 2,
|
|
158
|
-
mb: 2,
|
|
159
|
-
children: [
|
|
160
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
161
|
-
item: true,
|
|
162
|
-
xs: 8,
|
|
163
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
164
|
-
required: true,
|
|
165
|
-
error: !!validation.name,
|
|
166
|
-
fullWidth: true,
|
|
167
|
-
label: "Name",
|
|
168
|
-
value: state.name,
|
|
169
|
-
helperText: validation.name,
|
|
170
|
-
onChange: (v)=>{
|
|
171
|
-
setState((draft)=>{
|
|
172
|
-
draft.name = v.target.value;
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
})
|
|
176
|
-
}),
|
|
177
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
178
|
-
item: true,
|
|
179
|
-
xs: 4,
|
|
180
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
181
|
-
fullWidth: true,
|
|
182
|
-
label: "Display Label",
|
|
183
|
-
value: state.title || '',
|
|
184
|
-
onChange: (v)=>{
|
|
185
|
-
setState((draft)=>{
|
|
186
|
-
draft.title = v.target.value;
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
})
|
|
190
|
-
}),
|
|
191
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
192
|
-
item: true,
|
|
193
|
-
xs: 8,
|
|
194
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
195
|
-
fullWidth: true,
|
|
196
|
-
label: "Description",
|
|
197
|
-
value: state.description,
|
|
198
|
-
onChange: (v)=>{
|
|
199
|
-
setState((draft)=>{
|
|
200
|
-
draft.description = v.target.value;
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
})
|
|
204
|
-
}),
|
|
205
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
206
|
-
item: true,
|
|
207
|
-
xs: 4,
|
|
208
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.FormControl, {
|
|
209
|
-
fullWidth: true,
|
|
210
|
-
children: [
|
|
211
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.InputLabel, {
|
|
212
|
-
id: "variable-type-select-label",
|
|
213
|
-
children: "Type"
|
|
214
|
-
}),
|
|
215
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Select, {
|
|
216
|
-
labelId: "variable-type-select-label",
|
|
217
|
-
id: "variable-type-select",
|
|
218
|
-
label: "Type",
|
|
219
|
-
value: state.kind,
|
|
220
|
-
onChange: (v)=>{
|
|
221
|
-
setState((draft)=>{
|
|
222
|
-
draft.kind = v.target.value;
|
|
223
|
-
});
|
|
224
|
-
},
|
|
225
|
-
children: _variableModel.VARIABLE_TYPES.map((v)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.MenuItem, {
|
|
226
|
-
value: v.kind,
|
|
227
|
-
children: v.label
|
|
228
|
-
}, v.kind))
|
|
229
|
-
})
|
|
230
|
-
]
|
|
231
|
-
})
|
|
232
|
-
})
|
|
233
|
-
]
|
|
234
|
-
}),
|
|
235
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Divider, {}),
|
|
236
|
-
state.kind === 'TextVariable' && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
237
|
-
children: [
|
|
238
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
239
|
-
py: 1,
|
|
240
|
-
variant: "subtitle1",
|
|
241
|
-
children: "Text Options"
|
|
242
|
-
}),
|
|
243
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
244
|
-
spacing: 2,
|
|
245
|
-
children: [
|
|
246
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
247
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variablePreview.VariablePreview, {
|
|
248
|
-
values: [
|
|
249
|
-
state.textVariableFields.value
|
|
250
|
-
]
|
|
251
|
-
})
|
|
252
|
-
}),
|
|
253
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
254
|
-
label: "Value",
|
|
255
|
-
value: state.textVariableFields.value,
|
|
256
|
-
onChange: (v)=>{
|
|
257
|
-
setState((draft)=>{
|
|
258
|
-
draft.textVariableFields.value = v.target.value;
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
})
|
|
262
|
-
]
|
|
263
|
-
})
|
|
264
|
-
]
|
|
265
|
-
}),
|
|
266
|
-
state.kind === 'ListVariable' && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
267
|
-
children: [
|
|
268
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
269
|
-
py: 1,
|
|
270
|
-
variant: "subtitle1",
|
|
271
|
-
children: "List Options"
|
|
272
|
-
}),
|
|
273
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
274
|
-
spacing: 2,
|
|
275
|
-
mb: 2,
|
|
276
|
-
children: [
|
|
277
|
-
state.listVariableFields.plugin.kind ? /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
278
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
|
|
279
|
-
FallbackComponent: FallbackPreview,
|
|
280
|
-
resetKeys: [
|
|
281
|
-
previewSpec
|
|
282
|
-
],
|
|
283
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variablePreview.VariableListPreview, {
|
|
284
|
-
definition: previewSpec,
|
|
285
|
-
onRefresh: refreshPreview
|
|
286
|
-
})
|
|
287
|
-
})
|
|
288
|
-
}) : /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variablePreview.VariablePreview, {
|
|
289
|
-
isLoading: true
|
|
290
|
-
}),
|
|
291
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
292
|
-
children: [
|
|
293
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.ClickAwayListener, {
|
|
294
|
-
onClickAway: ()=>refreshPreview(),
|
|
295
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {})
|
|
296
|
-
}),
|
|
297
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.PluginEditor, {
|
|
298
|
-
width: "100%",
|
|
299
|
-
pluginType: "Variable",
|
|
300
|
-
pluginKindLabel: "Source",
|
|
301
|
-
value: state.listVariableFields.plugin,
|
|
302
|
-
onChange: (val)=>{
|
|
303
|
-
setState((draft)=>{
|
|
304
|
-
draft.listVariableFields.plugin = val;
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
})
|
|
308
|
-
]
|
|
309
|
-
}),
|
|
310
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Stack, {
|
|
311
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
312
|
-
label: "Capturing Regexp Filter",
|
|
313
|
-
value: state.listVariableFields.capturing_regexp || '',
|
|
314
|
-
onChange: (e)=>{
|
|
315
|
-
setState((draft)=>{
|
|
316
|
-
if (e.target.value) {
|
|
317
|
-
// TODO: do a better fix, if empty string => it should skip the filter
|
|
318
|
-
draft.listVariableFields.capturing_regexp = e.target.value;
|
|
319
|
-
} else {
|
|
320
|
-
draft.listVariableFields.capturing_regexp = undefined;
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
},
|
|
324
|
-
helperText: "Optional, if you want to filter on captured result."
|
|
325
|
-
})
|
|
326
|
-
})
|
|
327
|
-
]
|
|
328
|
-
}),
|
|
329
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Divider, {}),
|
|
330
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
331
|
-
py: 1,
|
|
332
|
-
variant: "subtitle1",
|
|
333
|
-
children: "Dropdown Options"
|
|
334
|
-
}),
|
|
335
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
336
|
-
spacing: "2",
|
|
337
|
-
children: [
|
|
338
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
339
|
-
children: [
|
|
340
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.FormControlLabel, {
|
|
341
|
-
control: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Switch, {
|
|
342
|
-
checked: state.listVariableFields.allowMultiple,
|
|
343
|
-
onChange: (e)=>{
|
|
344
|
-
setState((draft)=>{
|
|
345
|
-
draft.listVariableFields.allowMultiple = e.target.checked;
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
}),
|
|
349
|
-
label: "Allow Multiple Values"
|
|
350
|
-
}),
|
|
351
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
352
|
-
variant: "caption",
|
|
353
|
-
children: "Enables multiple values to be selected at the same time"
|
|
354
|
-
})
|
|
355
|
-
]
|
|
356
|
-
}),
|
|
357
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
358
|
-
children: [
|
|
359
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.FormControlLabel, {
|
|
360
|
-
control: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Switch, {
|
|
361
|
-
checked: state.listVariableFields.allowAll,
|
|
362
|
-
onChange: (e)=>{
|
|
363
|
-
setState((draft)=>{
|
|
364
|
-
draft.listVariableFields.allowAll = e.target.checked;
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
}),
|
|
368
|
-
label: "Allow All option"
|
|
369
|
-
}),
|
|
370
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
371
|
-
mb: 1,
|
|
372
|
-
variant: "caption",
|
|
373
|
-
children: "Enables an option to include all variable values"
|
|
374
|
-
}),
|
|
375
|
-
state.listVariableFields.allowAll && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
376
|
-
label: "Custom All Value",
|
|
377
|
-
value: state.listVariableFields.customAllValue,
|
|
378
|
-
onChange: (e)=>{
|
|
379
|
-
setState((draft)=>{
|
|
380
|
-
if (e.target.value) {
|
|
381
|
-
draft.listVariableFields.customAllValue = e.target.value;
|
|
382
|
-
} else {
|
|
383
|
-
draft.listVariableFields.customAllValue = undefined;
|
|
384
|
-
}
|
|
385
|
-
});
|
|
386
|
-
},
|
|
387
|
-
helperText: "When All is selected, this value will be used"
|
|
388
|
-
})
|
|
389
|
-
]
|
|
390
|
-
})
|
|
391
|
-
]
|
|
392
|
-
})
|
|
393
|
-
]
|
|
394
|
-
})
|
|
395
|
-
]
|
|
396
|
-
})
|
|
397
|
-
]
|
|
398
|
-
});
|
|
399
|
-
}
|