@perses-dev/dashboards 0.12.0 → 0.14.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} +15 -34
- 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.js +1 -2
- package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +9 -15
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +7 -5
- 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 +1 -1
- 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 -2
- package/dist/cjs/utils/component-ids.js +31 -0
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +42 -11
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +4 -3
- 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} +3 -0
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -0
- package/dist/components/{DashboardToolbar.js → DashboardToolbar/DashboardToolbar.js} +11 -30
- 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.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +1 -2
- package/dist/components/PanelDrawer/PanelDrawer.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/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +8 -6
- package/dist/components/PanelDrawer/PanelEditorForm.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 +1 -1
- 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 -2
- 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 +1 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +42 -6
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.d.ts +1 -0
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +4 -3
- 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 +5 -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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PanelDrawer/PanelEditorForm.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 { FormEventHandler, useState } from 'react';\nimport {\n FormControl,\n FormHelperText,\n Grid,\n InputLabel,\n MenuItem,\n Select,\n SelectProps,\n TextField,\n Typography,\n} from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { PluginKindSelect, PluginSpecEditor, usePluginEditor } from '@perses-dev/plugin-system';\nimport { useListPanelGroups } from '../../context';\nimport { PanelEditorValues } from '../../context/DashboardProvider/panel-editor-slice';\nimport { PanelPreview } from './PanelPreview';\n\nexport interface PanelEditorFormProps {\n initialValues: PanelEditorValues;\n onSubmit: (values: PanelEditorValues) => void;\n}\n\nexport function PanelEditorForm(props: PanelEditorFormProps) {\n const { initialValues, onSubmit } = props;\n\n const panelGroups = useListPanelGroups();\n\n const [name, setName] = useState(initialValues.name);\n const [description, setDescription] = useState(initialValues.description);\n const [groupId, setGroupId] = useState(initialValues.groupId);\n const [kind, setKind] = useState(initialValues.kind);\n const [spec, setSpec] = useState(initialValues.spec);\n\n // Use common plugin editor logic even though we've split the inputs up in this form\n const pluginEditor = usePluginEditor({\n pluginType: 'Panel',\n value: { kind, spec },\n onChange: (plugin) => {\n setKind(plugin.kind);\n setSpec(plugin.spec);\n },\n });\n\n // Ignore string values (which would be an \"empty\" value from the Select) since we don't allow them to unset it\n const handleGroupChange: SelectProps<number>['onChange'] = (e) => {\n const { value } = e.target;\n if (typeof value === 'string') {\n return;\n }\n setGroupId(value);\n };\n\n const handleSubmit: FormEventHandler = (e) => {\n e.preventDefault();\n const values: PanelEditorValues = { name, description, groupId, kind, spec };\n onSubmit(values);\n };\n\n return (\n // Grid maxHeight allows user to scroll inside Drawer to see all content\n <form id={panelEditorFormId} onSubmit={handleSubmit}>\n <Grid container spacing={2} sx={{ overflowY: 'scroll', maxHeight: '90vh' }}>\n <Grid item xs={8}>\n <TextField\n required\n fullWidth\n label=\"Name\"\n value={name}\n variant=\"outlined\"\n onChange={(e) => setName(e.target.value)}\n />\n </Grid>\n <Grid item xs={4}>\n <FormControl fullWidth>\n <InputLabel id=\"select-group\">Group</InputLabel>\n <Select required labelId=\"select-group\" label=\"Group\" value={groupId} onChange={handleGroupChange}>\n {panelGroups.map((panelGroup, index) => (\n <MenuItem key={panelGroup.id} value={panelGroup.id}>\n {panelGroup.title ?? `Group ${index + 1}`}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n </Grid>\n <Grid item xs={8}>\n <TextField\n fullWidth\n label=\"Description\"\n value={description}\n variant=\"outlined\"\n onChange={(e) => setDescription(e.target.value)}\n />\n </Grid>\n <Grid item xs={4}>\n <FormControl fullWidth disabled={pluginEditor.isLoading} error={pluginEditor.error !== null}>\n <InputLabel id=\"panel-type-label\">Type</InputLabel>\n <PluginKindSelect\n pluginType=\"Panel\"\n required\n labelId=\"panel-type-label\"\n label=\"Type\"\n value={pluginEditor.pendingKind ? pluginEditor.pendingKind : kind}\n onChange={pluginEditor.onKindChange}\n />\n </FormControl>\n <FormHelperText>{pluginEditor.error?.message ?? ''}</FormHelperText>\n </Grid>\n <Grid item xs={12}>\n <Typography variant=\"h4\" marginBottom={1}>\n Preview\n </Typography>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PanelPreview kind={kind} name={name} description={description} spec={spec} groupId={groupId} />\n </ErrorBoundary>\n </Grid>\n <Grid item xs={12}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PluginSpecEditor pluginType=\"Panel\" pluginKind={kind} value={spec} onChange={pluginEditor.onSpecChange} />\n </ErrorBoundary>\n </Grid>\n </Grid>\n </form>\n );\n}\n\n/**\n * The `id` attribute added to the `PanelEditorForm` component, allowing submit buttons to live outside the form.\n */\nexport const panelEditorFormId = 'panel-editor-form';\n"],"names":["useState","FormControl","FormHelperText","Grid","InputLabel","MenuItem","Select","TextField","Typography","ErrorAlert","ErrorBoundary","PluginKindSelect","PluginSpecEditor","usePluginEditor","useListPanelGroups","PanelPreview","PanelEditorForm","props","pluginEditor","initialValues","onSubmit","panelGroups","name","setName","description","setDescription","groupId","setGroupId","kind","setKind","spec","setSpec","pluginType","value","onChange","plugin","handleGroupChange","e","target","handleSubmit","preventDefault","values","panelGroup","form","id","panelEditorFormId","container","spacing","sx","overflowY","maxHeight","item","xs","required","fullWidth","label","variant","labelId","map","index","title","disabled","isLoading","error","pendingKind","onKindChange","message","marginBottom","FallbackComponent","pluginKind","onSpecChange"],"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,SAA2BA,QAAQ,QAAQ,OAAO,CAAC;AACnD,SACEC,WAAW,EACXC,cAAc,EACdC,IAAI,EACJC,UAAU,EACVC,QAAQ,EACRC,MAAM,EAENC,SAAS,EACTC,UAAU,QACL,eAAe,CAAC;AACvB,SAASC,UAAU,EAAEC,aAAa,QAAQ,wBAAwB,CAAC;AACnE,SAASC,gBAAgB,EAAEC,gBAAgB,EAAEC,eAAe,QAAQ,2BAA2B,CAAC;AAChG,SAASC,kBAAkB,QAAQ,eAAe,CAAC;AAEnD,SAASC,YAAY,QAAQ,gBAAgB,CAAC;AAO9C,OAAO,SAASC,eAAe,CAACC,KAA2B,EAAE;QAmFlCC,GAAkB;IAlF3C,MAAM,EAAEC,aAAa,CAAA,EAAEC,QAAQ,CAAA,EAAE,GAAGH,KAAK,AAAC;IAE1C,MAAMI,WAAW,GAAGP,kBAAkB,EAAE,AAAC;IAEzC,MAAM,CAACQ,IAAI,EAAEC,OAAO,CAAC,GAAGvB,QAAQ,CAACmB,aAAa,CAACG,IAAI,CAAC,AAAC;IACrD,MAAM,CAACE,WAAW,EAAEC,cAAc,CAAC,GAAGzB,QAAQ,CAACmB,aAAa,CAACK,WAAW,CAAC,AAAC;IAC1E,MAAM,CAACE,OAAO,EAAEC,UAAU,CAAC,GAAG3B,QAAQ,CAACmB,aAAa,CAACO,OAAO,CAAC,AAAC;IAC9D,MAAM,CAACE,IAAI,EAAEC,OAAO,CAAC,GAAG7B,QAAQ,CAACmB,aAAa,CAACS,I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3D,UAAU;kCAC1C,cAAA,KAACG,gBAAgB;4BAACoB,UAAU,EAAC,OAAO;4BAACqC,UAAU,EAAEzC,IAAI;4BAAEK,KAAK,EAAEH,IAAI;4BAAEI,QAAQ,EAAEhB,YAAY,CAACoD,YAAY;0BAAI;sBAC7F;kBACX;;UACF;MACF,EACP;AACJ,CAAC;AAED;;CAEC,GACD,OAAO,MAAMzB,iBAAiB,GAAG,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PanelDrawer/PanelEditorForm.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 { FormEventHandler, useState } from 'react';\nimport {\n Box,\n FormControl,\n FormHelperText,\n Grid,\n InputLabel,\n MenuItem,\n Select,\n SelectProps,\n TextField,\n Typography,\n} from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { PluginKindSelect, PluginSpecEditor, usePluginEditor } from '@perses-dev/plugin-system';\nimport { useListPanelGroups } from '../../context';\nimport { PanelEditorValues } from '../../context/DashboardProvider/panel-editor-slice';\nimport { PanelPreview } from './PanelPreview';\n\nexport interface PanelEditorFormProps {\n initialValues: PanelEditorValues;\n onSubmit: (values: PanelEditorValues) => void;\n}\n\nexport function PanelEditorForm(props: PanelEditorFormProps) {\n const { initialValues, onSubmit } = props;\n\n const panelGroups = useListPanelGroups();\n\n const [name, setName] = useState(initialValues.name);\n const [description, setDescription] = useState(initialValues.description);\n const [groupId, setGroupId] = useState(initialValues.groupId);\n const [kind, setKind] = useState(initialValues.kind);\n const [spec, setSpec] = useState(initialValues.spec);\n\n // Use common plugin editor logic even though we've split the inputs up in this form\n const pluginEditor = usePluginEditor({\n pluginType: 'Panel',\n value: { kind, spec },\n onChange: (plugin) => {\n setKind(plugin.kind);\n setSpec(plugin.spec);\n },\n });\n\n // Ignore string values (which would be an \"empty\" value from the Select) since we don't allow them to unset it\n const handleGroupChange: SelectProps<number>['onChange'] = (e) => {\n const { value } = e.target;\n if (typeof value === 'string') {\n return;\n }\n setGroupId(value);\n };\n\n const handleSubmit: FormEventHandler = (e) => {\n e.preventDefault();\n const values: PanelEditorValues = { name, description, groupId, kind, spec };\n onSubmit(values);\n };\n\n return (\n // Grid maxHeight allows user to scroll inside Drawer to see all content\n <Box\n component=\"form\"\n id={panelEditorFormId}\n onSubmit={handleSubmit}\n sx={{ flex: 1, overflowY: 'scroll', padding: (theme) => theme.spacing(2) }}\n >\n <Grid container spacing={2}>\n <Grid item xs={8}>\n <TextField\n required\n fullWidth\n label=\"Name\"\n value={name}\n variant=\"outlined\"\n onChange={(e) => setName(e.target.value)}\n />\n </Grid>\n <Grid item xs={4}>\n <FormControl fullWidth>\n <InputLabel id=\"select-group\">Group</InputLabel>\n <Select required labelId=\"select-group\" label=\"Group\" value={groupId} onChange={handleGroupChange}>\n {panelGroups.map((panelGroup, index) => (\n <MenuItem key={panelGroup.id} value={panelGroup.id}>\n {panelGroup.title ?? `Group ${index + 1}`}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n </Grid>\n <Grid item xs={8}>\n <TextField\n fullWidth\n label=\"Description\"\n value={description}\n variant=\"outlined\"\n onChange={(e) => setDescription(e.target.value)}\n />\n </Grid>\n <Grid item xs={4}>\n <FormControl fullWidth disabled={pluginEditor.isLoading} error={pluginEditor.error !== null}>\n <InputLabel id=\"panel-type-label\">Type</InputLabel>\n <PluginKindSelect\n pluginType=\"Panel\"\n required\n labelId=\"panel-type-label\"\n label=\"Type\"\n value={pluginEditor.pendingKind ? pluginEditor.pendingKind : kind}\n onChange={pluginEditor.onKindChange}\n />\n </FormControl>\n <FormHelperText>{pluginEditor.error?.message ?? ''}</FormHelperText>\n </Grid>\n <Grid item xs={12}>\n <Typography variant=\"h4\" marginBottom={1}>\n Preview\n </Typography>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PanelPreview kind={kind} name={name} description={description} spec={spec} groupId={groupId} />\n </ErrorBoundary>\n </Grid>\n <Grid item xs={12}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PluginSpecEditor pluginType=\"Panel\" pluginKind={kind} value={spec} onChange={pluginEditor.onSpecChange} />\n </ErrorBoundary>\n </Grid>\n </Grid>\n </Box>\n );\n}\n\n/**\n * The `id` attribute added to the `PanelEditorForm` component, allowing submit buttons to live outside the form.\n */\nexport const panelEditorFormId = 'panel-editor-form';\n"],"names":["useState","Box","FormControl","FormHelperText","Grid","InputLabel","MenuItem","Select","TextField","Typography","ErrorAlert","ErrorBoundary","PluginKindSelect","PluginSpecEditor","usePluginEditor","useListPanelGroups","PanelPreview","PanelEditorForm","props","pluginEditor","initialValues","onSubmit","panelGroups","name","setName","description","setDescription","groupId","setGroupId","kind","setKind","spec","setSpec","pluginType","value","onChange","plugin","handleGroupChange","e","target","handleSubmit","preventDefault","values","panelGroup","component","id","panelEditorFormId","sx","flex","overflowY","padding","theme","spacing","container","item","xs","required","fullWidth","label","variant","labelId","map","index","title","disabled","isLoading","error","pendingKind","onKindChange","message","marginBottom","FallbackComponent","pluginKind","onSpecChange"],"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,SAA2BA,QAAQ,QAAQ,OAAO,CAAC;AACnD,SACEC,GAAG,EACHC,WAAW,EACXC,cAAc,EACdC,IAAI,EACJC,UAAU,EACVC,QAAQ,EACRC,MAAM,EAENC,SAAS,EACTC,UAAU,Q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context
|
|
3
|
-
export declare function PanelPreview({ name, description, kind, spec
|
|
2
|
+
import { PanelEditorValues } from '../../context';
|
|
3
|
+
export declare function PanelPreview({ name, description, kind, spec }: PanelEditorValues): JSX.Element | null;
|
|
4
4
|
//# sourceMappingURL=PanelPreview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanelPreview.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelPreview.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"PanelPreview.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelPreview.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGlD,wBAAgB,YAAY,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,iBAAiB,sBAwBhF"}
|
|
@@ -13,34 +13,27 @@
|
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { Box } from '@mui/material';
|
|
15
15
|
import { Panel } from '../Panel';
|
|
16
|
-
export function PanelPreview({ name , description , kind , spec
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
spec
|
|
28
|
-
}
|
|
16
|
+
export function PanelPreview({ name , description , kind , spec }) {
|
|
17
|
+
const definition = {
|
|
18
|
+
kind: 'Panel',
|
|
19
|
+
spec: {
|
|
20
|
+
display: {
|
|
21
|
+
name,
|
|
22
|
+
description: description === '' ? undefined : description
|
|
23
|
+
},
|
|
24
|
+
plugin: {
|
|
25
|
+
kind,
|
|
26
|
+
spec
|
|
29
27
|
}
|
|
30
|
-
},
|
|
31
|
-
// TODO: this shouldn't be necessary for preview
|
|
32
|
-
panelGroupItemId: {
|
|
33
|
-
panelGroupId: groupId,
|
|
34
|
-
panelGroupItemLayoutId: ''
|
|
35
28
|
}
|
|
36
29
|
};
|
|
37
|
-
if (
|
|
30
|
+
if (kind === '') {
|
|
38
31
|
return null;
|
|
39
32
|
}
|
|
40
33
|
return /*#__PURE__*/ _jsx(Box, {
|
|
41
34
|
height: 300,
|
|
42
35
|
children: /*#__PURE__*/ _jsx(Panel, {
|
|
43
|
-
|
|
36
|
+
definition: definition
|
|
44
37
|
})
|
|
45
38
|
});
|
|
46
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PanelDrawer/PanelPreview.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 } from '@mui/material';\nimport { PanelEditorValues } from '../../context
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PanelDrawer/PanelPreview.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 } from '@mui/material';\nimport { PanelEditorValues } from '../../context';\nimport { Panel, PanelProps } from '../Panel';\n\nexport function PanelPreview({ name, description, kind, spec }: PanelEditorValues) {\n const definition: PanelProps['definition'] = {\n kind: 'Panel',\n spec: {\n display: {\n name,\n description: description === '' ? undefined : description,\n },\n plugin: {\n kind,\n spec,\n },\n },\n };\n\n if (kind === '') {\n return null;\n }\n\n return (\n <Box height={300}>\n <Panel definition={definition} />\n </Box>\n );\n}\n"],"names":["Box","Panel","PanelPreview","name","description","kind","spec","definition","display","undefined","plugin","height"],"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,QAAQ,eAAe,CAAC;AAEpC,SAASC,KAAK,QAAoB,UAAU,CAAC;AAE7C,OAAO,SAASC,YAAY,CAAC,EAAEC,IAAI,CAAA,EAAEC,WAAW,CAAA,EAAEC,IAAI,CAAA,EAAEC,IAAI,CAAA,EAAqB,EAAE;IACjF,MAAMC,UAAU,GAA6B;QAC3CF,IAAI,EAAE,OAAO;QACbC,IAAI,EAAE;YACJE,OAAO,EAAE;gBACPL,IAAI;gBACJC,WAAW,EAAEA,WAAW,KAAK,EAAE,GAAGK,SAAS,GAAGL,WAAW;aAC1D;YACDM,MAAM,EAAE;gBACNL,IAAI;gBACJC,IAAI;aACL;SACF;KACF,AAAC;IAEF,IAAID,IAAI,KAAK,EAAE,EAAE;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAED,qBACE,KAACL,GAAG;QAACW,MAAM,EAAE,GAAG;kBACd,cAAA,KAACV,KAAK;YAACM,UAAU,EAAEA,UAAU;UAAI;MAC7B,CACN;AACJ,CAAC"}
|
|
@@ -22,7 +22,7 @@ describe('Add Panel Group', ()=>{
|
|
|
22
22
|
const { store , DashboardProviderSpy } = createDashboardProviderSpy();
|
|
23
23
|
renderWithContext(/*#__PURE__*/ _jsxs(DashboardProvider, {
|
|
24
24
|
initialState: {
|
|
25
|
-
|
|
25
|
+
dashboardResource: getTestDashboard(),
|
|
26
26
|
isEditMode: true
|
|
27
27
|
},
|
|
28
28
|
children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PanelGroupDialog/PanelGroupDialog.test.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 { screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { act } from 'react-dom/test-utils';\nimport { DashboardProvider } from '../../context';\nimport { createDashboardProviderSpy, getTestDashboard, renderWithContext } from '../../test';\nimport { PanelGroupDialog } from './PanelGroupDialog';\n\ndescribe('Add Panel Group', () => {\n const renderDialog = () => {\n const { store, DashboardProviderSpy } = createDashboardProviderSpy();\n\n renderWithContext(\n <DashboardProvider initialState={{
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PanelGroupDialog/PanelGroupDialog.test.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 { screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { act } from 'react-dom/test-utils';\nimport { DashboardProvider } from '../../context';\nimport { createDashboardProviderSpy, getTestDashboard, renderWithContext } from '../../test';\nimport { PanelGroupDialog } from './PanelGroupDialog';\n\ndescribe('Add Panel Group', () => {\n const renderDialog = () => {\n const { store, DashboardProviderSpy } = createDashboardProviderSpy();\n\n renderWithContext(\n <DashboardProvider initialState={{ dashboardResource: getTestDashboard(), isEditMode: true }}>\n <DashboardProviderSpy />\n <PanelGroupDialog />\n </DashboardProvider>\n );\n\n const { value: storeApi } = store;\n if (storeApi === undefined) {\n throw new Error('Expected dashboard store to be set after initial render');\n }\n\n return storeApi;\n };\n\n it('should add new panel group', async () => {\n const storeApi = renderDialog();\n\n // Open the dialog for a new panel group\n act(() => storeApi.getState().openAddPanelGroup());\n\n const nameInput = await screen.findByLabelText(/Name/);\n userEvent.type(nameInput, 'New Panel Group');\n userEvent.click(screen.getByText('Add'));\n\n // TODO: Figure out how to test this without coupling to the store state\n const panelGroups = Object.values(storeApi.getState().panelGroups);\n expect(panelGroups).toContainEqual({\n id: expect.any(Number),\n title: 'New Panel Group',\n isCollapsed: false,\n itemLayouts: expect.any(Array),\n itemPanelKeys: expect.any(Object),\n });\n });\n\n it('should edit existing panel group', async () => {\n const storeApi = renderDialog();\n\n // Open the dialog for an existing panel group\n const group = Object.values(storeApi.getState().panelGroups).find((group) => group.title === 'CPU Stats');\n if (group === undefined) {\n throw new Error('Missing test group');\n }\n act(() => storeApi.getState().openEditPanelGroup(group.id));\n\n const nameInput = await screen.findByLabelText(/Name/);\n userEvent.clear(nameInput);\n userEvent.type(nameInput, 'New Name');\n userEvent.click(screen.getByText('Apply'));\n\n // TODO: Figure out how to test this without coupling to the store state\n const panelGroups = storeApi.getState().panelGroups;\n expect(panelGroups).toMatchObject({\n [group.id]: {\n id: group.id,\n title: 'New Name',\n isCollapsed: false,\n },\n });\n });\n});\n"],"names":["screen","userEvent","act","DashboardProvider","createDashboardProviderSpy","getTestDashboard","renderWithContext","PanelGroupDialog","describe","renderDialog","store","DashboardProviderSpy","initialState","dashboardResource","isEditMode","value","storeApi","undefined","Error","it","getState","openAddPanelGroup","nameInput","findByLabelText","type","click","getByText","panelGroups","Object","values","expect","toContainEqual","id","any","Number","title","isCollapsed","itemLayouts","Array","itemPanelKeys","group","find","openEditPanelGroup","clear","toMatchObject"],"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,MAAM,QAAQ,wBAAwB,CAAC;AAChD,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AACpD,SAASC,GAAG,QAAQ,sBAAsB,CAAC;AAC3C,SAASC,iBAAiB,QAAQ,eAAe,CAAC;AAClD,SAASC,0BAA0B,EAAEC,gBAAgB,EAAEC,iBAAiB,QAAQ,YAAY,CAAC;AAC7F,SAASC,gBAAgB,QAAQ,oBAAoB,CAAC;AAEtDC,QAAQ,CAAC,iBAAiB,EAAE,IAAM;IAChC,MAAMC,YAAY,GAAG,IAAM;QACzB,MAAM,EAAEC,KAAK,CAAA,EAAEC,oBAAoB,CAAA,EAAE,GAAGP,0BAA0B,EAAE,AAAC;QAErEE,iBAAiB,eACf,MAACH,iBAAiB;YAACS,YAAY,EAAE;gBAAEC,iBAAiB,EAAER,gBAAgB,EAAE;gBAAES,UAAU,EAAE,IAAI;aAAE;;8BAC1F,KAACH,oBAAoB,KAAG;8BACxB,KAACJ,gBAAgB,KAAG;;UACF,CACrB,CAAC;QAEF,MAAM,EAAEQ,KAAK,EAAEC,QAAQ,CAAA,EAAE,GAAGN,KAAK,AAAC;QAClC,IAAIM,QAAQ,KAAKC,SAAS,EAAE;YAC1B,MAAM,IAAIC,KAAK,CAAC,yDAAyD,CAAC,CAAC;QAC7E,CAAC;QAED,OAAOF,QAAQ,CAAC;IAClB,CAAC,AAAC;IAEFG,EAAE,CAAC,4BAA4B,EAAE,UAAY;QAC3C,MAAMH,QAAQ,GAAGP,YAAY,EAAE,AAAC;QAEhC,wCAAwC;QACxCP,GAAG,CAAC,I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AG,MAAMtB,MAAM,CAACuB,eAAe,QAAQ,AAAC;QACvDtB,SAAS,CAAC0C,KAAK,CAACrB,SAAS,CAAC,CAAC;QAC3BrB,SAAS,CAACuB,IAAI,CAACF,SAAS,EAAE,UAAU,CAAC,CAAC;QACtCrB,SAAS,CAACwB,KAAK,CAACzB,MAAM,CAAC0B,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QAE3C,wEAAwE;QACxE,MAAMC,WAAW,GAAGX,QAAQ,CAACI,QAAQ,EAAE,CAACO,WAAW,AAAC;QACpDG,MAAM,CAACH,WAAW,CAAC,CAACiB,aAAa,CAAC;YAChC,CAACJ,KAAK,CAACR,EAAE,CAAC,EAAE;gBACVA,EAAE,EAAEQ,KAAK,CAACR,EAAE;gBACZG,KAAK,EAAE,UAAU;gBACjBC,WAAW,EAAE,KAAK;aACnB;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PanelGroupDialog/index.ts"],"names":[],"mappings":"AAaA,cAAc,oBAAoB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PanelGroupDialog/index.ts"],"names":[],"mappings":"AAaA,cAAc,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PanelGroupDialog/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 './PanelGroupDialog';\
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PanelGroupDialog/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 './PanelGroupDialog';\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,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/TimeRangeControls/TimeRangeControls.test.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 { generatePath } from 'react-router';\nimport { createMemoryHistory } from 'history';\nimport userEvent from '@testing-library/user-event';\nimport { screen } from '@testing-library/react';\nimport { renderWithContext } from '../../test';\nimport testDashboard from '../../test/testDashboard';\nimport { DashboardProvider, DashboardStoreProps, TimeRangeProvider } from '../../context';\nimport { TimeRangeControls } from './TimeRangeControls';\n\nconst history = createMemoryHistory({\n initialEntries: [generatePath('/dashboards/:id', { id: 'test' })],\n});\n\ndescribe('TimeRangeControls', () => {\n let initialState: DashboardStoreProps;\n const testDefaultTimeRange = { pastDuration: testDashboard.spec.duration };\n\n beforeEach(() => {\n initialState = {\n
|
|
1
|
+
{"version":3,"sources":["../../../src/components/TimeRangeControls/TimeRangeControls.test.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 { generatePath } from 'react-router';\nimport { createMemoryHistory } from 'history';\nimport userEvent from '@testing-library/user-event';\nimport { screen } from '@testing-library/react';\nimport { renderWithContext } from '../../test';\nimport testDashboard from '../../test/testDashboard';\nimport { DashboardProvider, DashboardStoreProps, TimeRangeProvider } from '../../context';\nimport { TimeRangeControls } from './TimeRangeControls';\n\nconst history = createMemoryHistory({\n initialEntries: [generatePath('/dashboards/:id', { id: 'test' })],\n});\n\ndescribe('TimeRangeControls', () => {\n let initialState: DashboardStoreProps;\n const testDefaultTimeRange = { pastDuration: testDashboard.spec.duration };\n\n beforeEach(() => {\n initialState = {\n dashboardResource: testDashboard,\n };\n });\n\n const renderTimeRangeControls = () => {\n renderWithContext(\n <DashboardProvider initialState={initialState}>\n <TimeRangeProvider timeRange={testDefaultTimeRange}>\n <TimeRangeControls />\n </TimeRangeProvider>\n </DashboardProvider>,\n undefined,\n history\n );\n };\n\n it('should render correct initial relative time shortcut', async () => {\n renderTimeRangeControls();\n expect(screen.getByText('Last 5 minutes')).toBeInTheDocument();\n });\n\n // TODO: fix setTimeRange no-op, test query params\n it('should be able to select the first option', () => {\n renderTimeRangeControls();\n const dateButton = screen.getByRole('button');\n userEvent.click(dateButton);\n const firstOption = screen.getByRole('option', { name: 'Last 5 minutes' });\n userEvent.click(firstOption);\n expect(dateButton).toHaveTextContent(/5 minutes/i);\n });\n\n // TODO: add additional tests for absolute time selection, other inputs, form validation, etc.\n});\n"],"names":["generatePath","createMemoryHistory","userEvent","screen","renderWithContext","testDashboard","DashboardProvider","TimeRangeProvider","TimeRangeControls","history","initialEntries","id","describe","initialState","testDefaultTimeRange","pastDuration","spec","duration","beforeEach","dashboardResource","renderTimeRangeControls","timeRange","undefined","it","expect","getByText","toBeInTheDocument","dateButton","getByRole","click","firstOption","name","toHaveTextContent"],"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,YAAY,QAAQ,cAAc,CAAC;AAC5C,SAASC,mBAAmB,QAAQ,SAAS,CAAC;AAC9C,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AACpD,SAASC,MAAM,QAAQ,wBAAwB,CAAC;AAChD,SAASC,iBAAiB,QAAQ,YAAY,CAAC;AAC/C,OAAOC,aAAa,MAAM,0BAA0B,CAAC;AACrD,SAASC,iBAAiB,EAAuBC,iBAAiB,QAAQ,eAAe,CAAC;AAC1F,SAASC,iBAAiB,QAAQ,qBAAqB,CAAC;AAExD,MAAMC,OAAO,GAAGR,mBAAmB,CAAC;IAClCS,cAAc,EAAE;QAACV,YAAY,CAAC,iBAAiB,EAAE;YAAEW,EAAE,EAAE,MAAM;SAAE,CAAC;KAAC;CAClE,CAAC,AAAC;AAEHC,QAAQ,CAAC,mBAAmB,EAAE,IAAM;IAClC,IAAIC,YAAY,AAAqB,AAAC;IACtC,MAAMC,oBAAoB,GAAG;QAAEC,YAAY,EAAEV,aAAa,CAACW,IAAI,CAACC,QAAQ;KAAE,AAAC;IAE3EC,UAAU,CAAC,IAAM;QACfL,YAAY,GAAG;YACbM,iBAAiB,EAAEd,aAAa;SACjC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAMe,uBAAuB,GAAG,IAAM;QACpChB,iBAAiB,eACf,KAACE,iBAAiB;YAACO,YAAY,EAAEA,YAAY;sBAC3C,cAAA,KAACN,iBAAiB;gBAACc,SAAS,EAAEP,oBAAoB;0BAChD,cAAA,KAACN,iBAAiB,KAAG;cACH;UACF,EACpBc,SAAS,EACTb,OAAO,CACR,CAAC;IACJ,CAAC,AAAC;IAEFc,EAAE,CAAC,sDAAsD,EAAE,UAAY;QACrEH,uBAAuB,EAAE,CAAC;QAC1BI,MAAM,CAACrB,MAAM,CAACsB,SAAS,CAAC,gBAAgB,CAAC,CAAC,CAACC,iBAAiB,EAAE,CAAC;IACjE,CAAC,CAAC,CAAC;IAEH,kDAAkD;IAClDH,EAAE,CAAC,2CAA2C,EAAE,IAAM;QACpDH,uBAAuB,EAAE,CAAC;QAC1B,MAAMO,UAAU,GAAGxB,MAAM,CAACyB,SAAS,CAAC,QAAQ,CAAC,AAAC;QAC9C1B,SAAS,CAAC2B,KAAK,CAACF,UAAU,CAAC,CAAC;QAC5B,MAAMG,WAAW,GAAG3B,MAAM,CAACyB,SAAS,CAAC,QAAQ,EAAE;YAAEG,IAAI,EAAE,gBAAgB;SAAE,CAAC,AAAC;QAC3E7B,SAAS,CAAC2B,KAAK,CAACC,WAAW,CAAC,CAAC;QAC7BN,MAAM,CAACG,UAAU,CAAC,CAACK,iBAAiB,cAAc,CAAC;IACrD,CAAC,CAAC,CAAC;AAEH,8FAA8F;AAChG,CAAC,CAAC,CAAC"}
|
package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface UnsavedChangesConfirmationDialogProps {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
onSave: () => void;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const UnsavedChangesConfirmationDialog: ({ isOpen, onSave, onClose, }: UnsavedChangesConfirmationDialogProps) => JSX.Element;
|
|
8
|
+
//# sourceMappingURL=UnsavedChangesConfirmationDialog.d.ts.map
|
package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnsavedChangesConfirmationDialog.d.ts","sourceRoot":"","sources":["../../../src/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.tsx"],"names":[],"mappings":";AAeA,MAAM,WAAW,qCAAqC;IACpD,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,gCAAgC,iCAI1C,qCAAqC,gBA0BvC,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';
|
|
15
|
+
import CloseIcon from 'mdi-material-ui/Close';
|
|
16
|
+
export const UnsavedChangesConfirmationDialog = ({ isOpen , onSave , onClose })=>{
|
|
17
|
+
return /*#__PURE__*/ _jsxs(Dialog, {
|
|
18
|
+
open: isOpen,
|
|
19
|
+
children: [
|
|
20
|
+
/*#__PURE__*/ _jsx(DialogTitle, {
|
|
21
|
+
children: "Unsaved Changes"
|
|
22
|
+
}),
|
|
23
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
24
|
+
"aria-label": "Close",
|
|
25
|
+
onClick: onClose,
|
|
26
|
+
sx: (theme)=>({
|
|
27
|
+
position: 'absolute',
|
|
28
|
+
top: theme.spacing(0.5),
|
|
29
|
+
right: theme.spacing(0.5)
|
|
30
|
+
}),
|
|
31
|
+
children: /*#__PURE__*/ _jsx(CloseIcon, {})
|
|
32
|
+
}),
|
|
33
|
+
/*#__PURE__*/ _jsx(DialogContent, {
|
|
34
|
+
sx: {
|
|
35
|
+
width: '500px'
|
|
36
|
+
},
|
|
37
|
+
children: "You have unsaved changes in this dashboard. Would you like to save these changes?"
|
|
38
|
+
}),
|
|
39
|
+
/*#__PURE__*/ _jsxs(DialogActions, {
|
|
40
|
+
children: [
|
|
41
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
42
|
+
variant: "contained",
|
|
43
|
+
onClick: onSave,
|
|
44
|
+
children: "Save"
|
|
45
|
+
}),
|
|
46
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
47
|
+
onClick: onClose,
|
|
48
|
+
children: "Cancel"
|
|
49
|
+
})
|
|
50
|
+
]
|
|
51
|
+
})
|
|
52
|
+
]
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=UnsavedChangesConfirmationDialog.js.map
|
package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nexport interface UnsavedChangesConfirmationDialogProps {\n isOpen: boolean;\n onSave: () => void;\n onClose: () => void;\n}\n\nexport const UnsavedChangesConfirmationDialog = ({\n isOpen,\n onSave,\n onClose,\n}: UnsavedChangesConfirmationDialogProps) => {\n return (\n <Dialog open={isOpen}>\n <DialogTitle>Unsaved Changes</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={onClose}\n sx={(theme) => ({\n position: 'absolute',\n top: theme.spacing(0.5),\n right: theme.spacing(0.5),\n })}\n >\n <CloseIcon />\n </IconButton>\n <DialogContent sx={{ width: '500px' }}>\n You have unsaved changes in this dashboard. Would you like to save these changes?\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" onClick={onSave}>\n Save\n </Button>\n <Button onClick={onClose}>Cancel</Button>\n </DialogActions>\n </Dialog>\n );\n};\n"],"names":["IconButton","Dialog","DialogTitle","DialogContent","DialogActions","Button","CloseIcon","UnsavedChangesConfirmationDialog","isOpen","onSave","onClose","open","aria-label","onClick","sx","theme","position","top","spacing","right","width","variant"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,UAAU,EAAEC,MAAM,EAAEC,WAAW,EAAEC,aAAa,EAAEC,aAAa,EAAEC,MAAM,QAAQ,eAAe,CAAC;AACtG,OAAOC,SAAS,MAAM,uBAAuB,CAAC;AAO9C,OAAO,MAAMC,gCAAgC,GAAG,CAAC,EAC/CC,MAAM,CAAA,EACNC,MAAM,CAAA,EACNC,OAAO,CAAA,EAC+B,GAAK;IAC3C,qBACE,MAACT,MAAM;QAACU,IAAI,EAAEH,MAAM;;0BAClB,KAACN,WAAW;0BAAC,iBAAe;cAAc;0BAC1C,KAACF,UAAU;gBACTY,YAAU,EAAC,OAAO;gBAClBC,OAAO,EAAEH,OAAO;gBAChBI,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;wBACdC,QAAQ,EAAE,UAAU;wBACpBC,GAAG,EAAEF,KAAK,CAACG,OAAO,CAAC,GAAG,CAAC;wBACvBC,KAAK,EAAEJ,KAAK,CAACG,OAAO,CAAC,GAAG,CAAC;qBAC1B,CAAA,AAAC;0BAEF,cAAA,KAACZ,SAAS,KAAG;cACF;0BACb,KAACH,aAAa;gBAACW,EAAE,EAAE;oBAAEM,KAAK,EAAE,OAAO;iBAAE;0BAAE,mFAEvC;cAAgB;0BAChB,MAAChB,aAAa;;kCACZ,KAACC,MAAM;wBAACgB,OAAO,EAAC,WAAW;wBAACR,OAAO,EAAEJ,MAAM;kCAAE,MAE7C;sBAAS;kCACT,KAACJ,MAAM;wBAACQ,OAAO,EAAEH,OAAO;kCAAE,QAAM;sBAAS;;cAC3B;;MACT,CACT;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/UnsavedChangesConfirmationDialog/index.ts"],"names":[],"mappings":"AAaA,cAAc,oCAAoC,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 './UnsavedChangesConfirmationDialog';
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/UnsavedChangesConfirmationDialog/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 './UnsavedChangesConfirmationDialog';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,oCAAoC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Variable.d.ts","sourceRoot":"","sources":["../../../src/components/Variables/Variable.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,YAAY,EAAyC,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"Variable.d.ts","sourceRoot":"","sources":["../../../src/components/Variables/Variable.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,YAAY,EAAyC,MAAM,kBAAkB,CAAC;AAYvF,aAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,EAAE,IAAI,EAAE,EAAE,qBAAqB,eAW/D"}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { useEffect, useMemo, useState } from 'react';
|
|
15
15
|
import { Select, FormControl, InputLabel, MenuItem, Box, LinearProgress, TextField } from '@mui/material';
|
|
16
|
-
import { usePlugin, DEFAULT_ALL_VALUE, useTemplateVariableValues, useDatasourceStore } from '@perses-dev/plugin-system';
|
|
16
|
+
import { usePlugin, DEFAULT_ALL_VALUE, useTemplateVariableValues, useDatasourceStore, useTimeRange } from '@perses-dev/plugin-system';
|
|
17
17
|
import { useQuery } from '@tanstack/react-query';
|
|
18
18
|
import { useTemplateVariable, useTemplateVariableActions } from '../../context';
|
|
19
19
|
export function TemplateVariable({ name }) {
|
|
@@ -67,14 +67,17 @@ function ListVariable({ name }) {
|
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
const variablesValueKey = getVariableValuesKey(variables);
|
|
70
|
+
const { timeRange } = useTimeRange();
|
|
70
71
|
const variablesOptionsQuery = useQuery([
|
|
71
72
|
name,
|
|
72
73
|
definition,
|
|
73
|
-
variablesValueKey
|
|
74
|
+
variablesValueKey,
|
|
75
|
+
timeRange
|
|
74
76
|
], async ()=>{
|
|
75
77
|
const resp = await (variablePlugin === null || variablePlugin === void 0 ? void 0 : variablePlugin.getVariableOptions(spec, {
|
|
76
78
|
datasourceStore,
|
|
77
|
-
variables
|
|
79
|
+
variables,
|
|
80
|
+
timeRange
|
|
78
81
|
}));
|
|
79
82
|
var ref;
|
|
80
83
|
return (ref = resp === null || resp === void 0 ? void 0 : resp.data) !== null && ref !== void 0 ? ref : [];
|
|
@@ -120,22 +123,26 @@ function ListVariable({ name }) {
|
|
|
120
123
|
options,
|
|
121
124
|
allowAllValue
|
|
122
125
|
]);
|
|
123
|
-
|
|
124
|
-
const firstOption = finalOptions === null || finalOptions === void 0 ? void 0 : finalOptions[0];
|
|
125
|
-
const valueIsInOptions = Boolean(finalOptions.find((v)=>{
|
|
126
|
+
const valueIsInOptions = useMemo(()=>Boolean(finalOptions.find((v)=>{
|
|
126
127
|
if (allowMultiple) {
|
|
127
128
|
return value.includes(v.value);
|
|
128
129
|
}
|
|
129
130
|
return value === v.value;
|
|
130
|
-
}))
|
|
131
|
+
})), [
|
|
132
|
+
finalOptions,
|
|
133
|
+
value,
|
|
134
|
+
allowMultiple
|
|
135
|
+
]);
|
|
136
|
+
let selectValue = value;
|
|
137
|
+
if (!valueIsInOptions) {
|
|
138
|
+
selectValue = allowMultiple ? [] : '';
|
|
139
|
+
}
|
|
140
|
+
useEffect(()=>{
|
|
141
|
+
const firstOption = finalOptions === null || finalOptions === void 0 ? void 0 : finalOptions[0];
|
|
131
142
|
// If there is no value but there are options, set the value to the first option.
|
|
132
143
|
if (!value && firstOption) {
|
|
133
144
|
setVariableValue(name, firstOption.value);
|
|
134
145
|
}
|
|
135
|
-
// If there is a value but it's not in the options, select the first value or set to null
|
|
136
|
-
if (value && !valueIsInOptions && !definition.spec.default_value) {
|
|
137
|
-
setVariableValue(name, (firstOption === null || firstOption === void 0 ? void 0 : firstOption.value) || null);
|
|
138
|
-
}
|
|
139
146
|
}, [
|
|
140
147
|
finalOptions,
|
|
141
148
|
setVariableValue,
|
|
@@ -159,7 +166,7 @@ function ListVariable({ name }) {
|
|
|
159
166
|
},
|
|
160
167
|
id: name,
|
|
161
168
|
label: name,
|
|
162
|
-
value:
|
|
169
|
+
value: selectValue,
|
|
163
170
|
onChange: (e)=>{
|
|
164
171
|
// Must be selected
|
|
165
172
|
if (e.target.value === null || e.target.value.length === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Variables/Variable.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 { useEffect, useMemo, useState } from 'react';\nimport { Select, FormControl, InputLabel, MenuItem, Box, LinearProgress, TextField } from '@mui/material';\nimport { VariableName, ListVariableDefinition, VariableValue } from '@perses-dev/core';\nimport {\n usePlugin,\n DEFAULT_ALL_VALUE,\n useTemplateVariableValues,\n VariableStateMap,\n useDatasourceStore,\n} from '@perses-dev/plugin-system';\nimport { useQuery } from '@tanstack/react-query';\nimport { useTemplateVariable, useTemplateVariableActions } from '../../context';\n\ntype TemplateVariableProps = {\n name: VariableName;\n};\n\nexport function TemplateVariable({ name }: TemplateVariableProps) {\n const ctx = useTemplateVariable(name);\n const kind = ctx.definition?.kind;\n switch (kind) {\n case 'TextVariable':\n return <TextVariable name={name} />;\n case 'ListVariable':\n return <ListVariable name={name} />;\n }\n\n return <div>Unsupported Variable Kind: ${kind}</div>;\n}\n\n/**\n * Returns a serialized string of the current state of variable values.\n */\nfunction getVariableValuesKey(v: VariableStateMap) {\n return Object.values(v)\n .map((v) => JSON.stringify(v.value))\n .join(',');\n}\n\nfunction ListVariable({ name }: TemplateVariableProps) {\n const ctx = useTemplateVariable(name);\n const definition = ctx.definition as ListVariableDefinition;\n const { data: variablePlugin } = usePlugin('Variable', definition.spec.plugin.kind);\n const { setVariableValue, setVariableLoading, setVariableOptions } = useTemplateVariableActions();\n const datasourceStore = useDatasourceStore();\n\n const spec = definition.spec.plugin.spec;\n\n let dependsOnVariables: string[] | undefined;\n if (variablePlugin?.dependsOn) {\n dependsOnVariables = variablePlugin.dependsOn(spec);\n }\n\n const variables = useTemplateVariableValues(dependsOnVariables);\n const allowMultiple = definition?.spec.allow_multiple === true;\n const allowAllValue = definition?.spec.allow_all_value === true;\n const label = definition?.spec.display?.label ?? name;\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],\n async () => {\n const resp = await variablePlugin?.getVariableOptions(spec, { datasourceStore, variables });\n return resp?.data ?? [];\n },\n { enabled: !!variablePlugin || waitToLoad }\n );\n\n useEffect(() => {\n setVariableLoading(name, variablesOptionsQuery.isFetching);\n if (variablesOptionsQuery.data) {\n setVariableOptions(name, variablesOptionsQuery.data);\n }\n }, [variablesOptionsQuery, name, setVariableLoading, setVariableOptions]);\n\n let value = ctx.state?.value;\n const options = ctx.state?.options;\n const loading = ctx.state?.loading;\n\n // Make sure value is an array if allowMultiple is true\n if (allowMultiple && !Array.isArray(value)) {\n value = typeof value === 'string' ? [value] : [];\n }\n\n const finalOptions = useMemo(() => {\n let computedOptions = options ? [...options] : [];\n\n // Add the all value if it's allowed\n if (allowAllValue) {\n computedOptions = [{ value: DEFAULT_ALL_VALUE, label: 'All' }, ...computedOptions];\n }\n return computedOptions;\n }, [options, allowAllValue]);\n\n useEffect(() => {\n const firstOption = finalOptions?.[0];\n const valueIsInOptions = Boolean(\n finalOptions.find((v) => {\n if (allowMultiple) {\n return (value as string[]).includes(v.value);\n }\n return value === v.value;\n })\n );\n\n // If there is no value but there are options, set the value to the first option.\n if (!value && firstOption) {\n setVariableValue(name, firstOption.value);\n }\n\n // If there is a value but it's not in the options, select the first value or set to null\n if (value && !valueIsInOptions && !definition.spec.default_value) {\n setVariableValue(name, firstOption?.value || null);\n }\n }, [finalOptions, setVariableValue, value, name, allowMultiple]);\n\n return (\n <Box display={'flex'}>\n <FormControl fullWidth>\n <InputLabel id={name}>{label}</InputLabel>\n <Select\n sx={{ minWidth: 100, maxWidth: 250 }}\n id={name}\n label={name}\n value={value ?? ''}\n onChange={(e) => {\n // Must be selected\n if (e.target.value === null || e.target.value.length === 0) {\n if (allowAllValue) {\n setVariableValue(name, DEFAULT_ALL_VALUE);\n }\n return;\n }\n setVariableValue(name, e.target.value as VariableValue);\n }}\n multiple={allowMultiple}\n >\n {loading && (\n <MenuItem value=\"loading\" disabled>\n Loading\n </MenuItem>\n )}\n {finalOptions.map((option) => (\n <MenuItem key={option.value} value={option.value}>\n {option.label}\n </MenuItem>\n ))}\n </Select>\n {loading && <LinearProgress />}\n </FormControl>\n </Box>\n );\n}\n\nfunction TextVariable({ name }: TemplateVariableProps) {\n const { state } = useTemplateVariable(name);\n const [tempValue, setTempValue] = useState(state?.value ?? '');\n const { setVariableValue } = useTemplateVariableActions();\n\n useEffect(() => {\n setTempValue(state?.value ?? '');\n }, [state?.value]);\n\n return (\n <TextField\n value={tempValue}\n onChange={(e) => setTempValue(e.target.value)}\n onBlur={() => setVariableValue(name, tempValue)}\n placeholder={name}\n label={name}\n />\n );\n}\n"],"names":["useEffect","useMemo","useState","Select","FormControl","InputLabel","MenuItem","Box","LinearProgress","TextField","usePlugin","DEFAULT_ALL_VALUE","useTemplateVariableValues","useDatasourceStore","useQuery","useTemplateVariable","useTemplateVariableActions","TemplateVariable","name","ctx","kind","definition","TextVariable","ListVariable","div","getVariableValuesKey","v","Object","values","map","JSON","stringify","value","join","data","variablePlugin","spec","plugin","setVariableValue","setVariableLoading","setVariableOptions","datasourceStore","dependsOnVariables","dependsOn","variables","allowMultiple","allow_multiple","allowAllValue","allow_all_value","label","display","waitToLoad","some","loading","variablesValueKey","variablesOptionsQuery","resp","getVariableOptions","enabled","isFetching","state","options","Array","isArray","finalOptions","computedOptions","firstOption","valueIsInOptions","Boolean","find","includes","default_value","fullWidth","id","sx","minWidth","maxWidth","onChange","e","target","length","multiple","disabled","option","tempValue","setTempValue","onBlur","placeholder"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF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AI,EAAE,CAAC,AAAC;IAC/D,MAAM,EAAEtB,gBAAgB,CAAA,EAAE,GAAGtB,0BAA0B,EAAE,AAAC;IAE1DhB,SAAS,CAAC,IAAM;YACD4D,GAAY;QAAzByB,YAAY,CAACzB,CAAAA,GAAY,GAAZA,KAAK,aAALA,KAAK,WAAO,GAAZA,KAAAA,CAAY,GAAZA,KAAK,CAAE5B,KAAK,cAAZ4B,GAAY,cAAZA,GAAY,GAAI,EAAE,CAAC,CAAC;IACnC,CAAC,EAAE;QAACA,KAAK,aAALA,KAAK,WAAO,GAAZA,KAAAA,CAAY,GAAZA,KAAK,CAAE5B,KAAK;KAAC,CAAC,CAAC;IAEnB,qBACE,KAACvB,SAAS;QACRuB,KAAK,EAAEoD,SAAS;QAChBP,QAAQ,EAAE,CAACC,CAAC,GAAKO,YAAY,CAACP,CAAC,CAACC,MAAM,CAAC/C,KAAK,CAAC;QAC7CsD,MAAM,EAAE,IAAMhD,gBAAgB,CAACpB,IAAI,EAAEkE,SAAS,CAAC;QAC/CG,WAAW,EAAErE,IAAI;QACjB+B,KAAK,EAAE/B,IAAI;MACX,CACF;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Variables/Variable.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 { useEffect, useMemo, useState } from 'react';\nimport { Select, FormControl, InputLabel, MenuItem, Box, LinearProgress, TextField } from '@mui/material';\nimport { VariableName, ListVariableDefinition, VariableValue } from '@perses-dev/core';\nimport {\n usePlugin,\n DEFAULT_ALL_VALUE,\n useTemplateVariableValues,\n VariableStateMap,\n useDatasourceStore,\n useTimeRange,\n} from '@perses-dev/plugin-system';\nimport { useQuery } from '@tanstack/react-query';\nimport { useTemplateVariable, useTemplateVariableActions } from '../../context';\n\ntype TemplateVariableProps = {\n name: VariableName;\n};\n\nexport function TemplateVariable({ name }: TemplateVariableProps) {\n const ctx = useTemplateVariable(name);\n const kind = ctx.definition?.kind;\n switch (kind) {\n case 'TextVariable':\n return <TextVariable name={name} />;\n case 'ListVariable':\n return <ListVariable name={name} />;\n }\n\n return <div>Unsupported Variable Kind: ${kind}</div>;\n}\n\n/**\n * Returns a serialized string of the current state of variable values.\n */\nfunction getVariableValuesKey(v: VariableStateMap) {\n return Object.values(v)\n .map((v) => JSON.stringify(v.value))\n .join(',');\n}\n\nfunction ListVariable({ name }: TemplateVariableProps) {\n const ctx = useTemplateVariable(name);\n const definition = ctx.definition as ListVariableDefinition;\n const { data: variablePlugin } = usePlugin('Variable', definition.spec.plugin.kind);\n const { setVariableValue, setVariableLoading, setVariableOptions } = useTemplateVariableActions();\n const datasourceStore = useDatasourceStore();\n\n const spec = definition.spec.plugin.spec;\n\n let dependsOnVariables: string[] | undefined;\n if (variablePlugin?.dependsOn) {\n dependsOnVariables = variablePlugin.dependsOn(spec);\n }\n\n const variables = useTemplateVariableValues(dependsOnVariables);\n const allowMultiple = definition?.spec.allow_multiple === true;\n const allowAllValue = definition?.spec.allow_all_value === true;\n const label = definition?.spec.display?.label ?? name;\n\n let waitToLoad = false;\n if (dependsOnVariables) {\n waitToLoad = dependsOnVariables.some((v) => variables[v]?.loading);\n }\n\n const variablesValueKey = getVariableValuesKey(variables);\n const { timeRange } = useTimeRange();\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 useEffect(() => {\n setVariableLoading(name, variablesOptionsQuery.isFetching);\n if (variablesOptionsQuery.data) {\n setVariableOptions(name, variablesOptionsQuery.data);\n }\n }, [variablesOptionsQuery, name, setVariableLoading, setVariableOptions]);\n\n let value = ctx.state?.value;\n const options = ctx.state?.options;\n const loading = ctx.state?.loading;\n\n // Make sure value is an array if allowMultiple is true\n if (allowMultiple && !Array.isArray(value)) {\n value = typeof value === 'string' ? [value] : [];\n }\n\n const finalOptions = useMemo(() => {\n let computedOptions = options ? [...options] : [];\n\n // Add the all value if it's allowed\n if (allowAllValue) {\n computedOptions = [{ value: DEFAULT_ALL_VALUE, label: 'All' }, ...computedOptions];\n }\n return computedOptions;\n }, [options, allowAllValue]);\n\n const valueIsInOptions = useMemo(\n () =>\n Boolean(\n finalOptions.find((v) => {\n if (allowMultiple) {\n return (value as string[]).includes(v.value);\n }\n return value === v.value;\n })\n ),\n [finalOptions, value, allowMultiple]\n );\n\n let selectValue = value;\n if (!valueIsInOptions) {\n selectValue = allowMultiple ? [] : '';\n }\n\n useEffect(() => {\n const firstOption = finalOptions?.[0];\n\n // If there is no value but there are options, set the value to the first option.\n if (!value && firstOption) {\n setVariableValue(name, firstOption.value);\n }\n }, [finalOptions, setVariableValue, value, name, allowMultiple]);\n\n return (\n <Box display={'flex'}>\n <FormControl fullWidth>\n <InputLabel id={name}>{label}</InputLabel>\n <Select\n sx={{ minWidth: 100, maxWidth: 250 }}\n id={name}\n label={name}\n value={selectValue}\n onChange={(e) => {\n // Must be selected\n if (e.target.value === null || e.target.value.length === 0) {\n if (allowAllValue) {\n setVariableValue(name, DEFAULT_ALL_VALUE);\n }\n return;\n }\n setVariableValue(name, e.target.value as VariableValue);\n }}\n multiple={allowMultiple}\n >\n {loading && (\n <MenuItem value=\"loading\" disabled>\n Loading\n </MenuItem>\n )}\n {finalOptions.map((option) => (\n <MenuItem key={option.value} value={option.value}>\n {option.label}\n </MenuItem>\n ))}\n </Select>\n {loading && <LinearProgress />}\n </FormControl>\n </Box>\n );\n}\n\nfunction TextVariable({ name }: TemplateVariableProps) {\n const { state } = useTemplateVariable(name);\n const [tempValue, setTempValue] = useState(state?.value ?? '');\n const { setVariableValue } = useTemplateVariableActions();\n\n useEffect(() => {\n setTempValue(state?.value ?? '');\n }, [state?.value]);\n\n return (\n <TextField\n value={tempValue}\n onChange={(e) => setTempValue(e.target.value)}\n onBlur={() => setVariableValue(name, tempValue)}\n placeholder={name}\n label={name}\n />\n );\n}\n"],"names":["useEffect","useMemo","useState","Select","FormControl","InputLabel","MenuItem","Box","LinearProgress","TextField","usePlugin","DEFAULT_ALL_VALUE","useTemplateVariableValues","useDatasourceStore","useTimeRange","useQuery","useTemplateVariable","useTemplateVariableActions","TemplateVariable","name","ctx","kind","definition","TextVariable","ListVariable","div","getVariableValuesKey","v","Object","values","map","JSON","stringify","value","join","data","variablePlugin","spec","plugin","setVariableValue","setVariableLoading","setVariableOptions","datasourceStore","dependsOnVariables","dependsOn","variables","allowMultiple","allow_multiple","allowAllValue","allow_all_value","label","display","waitToLoad","some","loading","variablesValueKey","timeRange","variablesOptionsQuery","resp","getVariableOptions","enabled","isFetching","state","options","Array","isArray","finalOptions","computedOptions","valueIsInOptions","Boolean","find","includes","selectValue","firstOption","fullWidth","id","sx","minWidth","maxWidth","onChange","e","target","length","multiple","disabled","option","tempValue","setTempValue","onBlur","placeholder"],"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,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AACrD,SAASC,MAAM,EAAEC,WAAW,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,GAAG,EAAEC,cAAc,EAAEC,SAAS,QAAQ,eAAe,CAAC;AAE1G,SACEC,SAAS,EACTC,iBAAiB,EACjBC,yBAAyB,EAEzBC,kBAAkB,EACl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CAAC,EAAE;QAACA,KAAK,aAALA,KAAK,WAAO,GAAZA,KAAAA,CAAY,GAAZA,KAAK,CAAE7B,KAAK;KAAC,CAAC,CAAC;IAEnB,qBACE,KAACxB,SAAS;QACRwB,KAAK,EAAEqD,SAAS;QAChBP,QAAQ,EAAE,CAACC,CAAC,GAAKO,YAAY,CAACP,CAAC,CAACC,MAAM,CAAChD,KAAK,CAAC;QAC7CuD,MAAM,EAAE,IAAMjD,gBAAgB,CAACpB,IAAI,EAAEmE,SAAS,CAAC;QAC/CG,WAAW,EAAEtE,IAAI;QACjB+B,KAAK,EAAE/B,IAAI;MACX,CACF;AACJ,CAAC"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export * from './Dashboard';
|
|
2
|
+
export * from './DashboardToolbar';
|
|
3
|
+
export * from './DeletePanelDialog';
|
|
4
|
+
export * from './DeletePanelGroupDialog';
|
|
2
5
|
export * from './GridLayout';
|
|
3
6
|
export * from './Panel';
|
|
4
7
|
export * from './PanelDrawer';
|
|
5
8
|
export * from './PanelGroupDialog';
|
|
6
9
|
export * from './TimeRangeControls';
|
|
10
|
+
export * from './UnsavedChangesConfirmationDialog';
|
|
7
11
|
export * from './Variables';
|
|
8
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAaA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAaA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oCAAoC,CAAC;AACnD,cAAc,aAAa,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -11,11 +11,15 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
export * from './Dashboard';
|
|
14
|
+
export * from './DashboardToolbar';
|
|
15
|
+
export * from './DeletePanelDialog';
|
|
16
|
+
export * from './DeletePanelGroupDialog';
|
|
14
17
|
export * from './GridLayout';
|
|
15
18
|
export * from './Panel';
|
|
16
19
|
export * from './PanelDrawer';
|
|
17
20
|
export * from './PanelGroupDialog';
|
|
18
21
|
export * from './TimeRangeControls';
|
|
22
|
+
export * from './UnsavedChangesConfirmationDialog';
|
|
19
23
|
export * from './Variables';
|
|
20
24
|
|
|
21
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/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';\nexport * from './GridLayout';\nexport * from './Panel';\nexport * from './PanelDrawer';\nexport * from './PanelGroupDialog';\nexport * from './TimeRangeControls';\nexport * from './Variables';\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;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/components/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';\nexport * from './DashboardToolbar';\nexport * from './DeletePanelDialog';\nexport * from './DeletePanelGroupDialog';\nexport * from './GridLayout';\nexport * from './Panel';\nexport * from './PanelDrawer';\nexport * from './PanelGroupDialog';\nexport * from './TimeRangeControls';\nexport * from './UnsavedChangesConfirmationDialog';\nexport * from './Variables';\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;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oCAAoC,CAAC;AACnD,cAAc,aAAa,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { StoreApi } from 'zustand';
|
|
3
|
-
import {
|
|
3
|
+
import { DashboardResource, ProjectMetadata, RelativeTimeRange } from '@perses-dev/core';
|
|
4
4
|
import { PanelGroupEditorSlice } from './panel-group-editor-slice';
|
|
5
5
|
import { PanelGroupSlice } from './panel-group-slice';
|
|
6
6
|
import { PanelEditorSlice } from './panel-editor-slice';
|
|
@@ -11,11 +11,11 @@ export interface DashboardStoreState extends PanelGroupSlice, PanelSlice, PanelG
|
|
|
11
11
|
isEditMode: boolean;
|
|
12
12
|
setEditMode: (isEditMode: boolean) => void;
|
|
13
13
|
defaultTimeRange: RelativeTimeRange;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
setDashboard: (dashboard: DashboardResource) => void;
|
|
15
|
+
metadata: ProjectMetadata;
|
|
16
16
|
}
|
|
17
17
|
export interface DashboardStoreProps {
|
|
18
|
-
|
|
18
|
+
dashboardResource: DashboardResource;
|
|
19
19
|
isEditMode?: boolean;
|
|
20
20
|
}
|
|
21
21
|
export interface DashboardProviderProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardProvider.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/DashboardProvider.tsx"],"names":[],"mappings":";AAcA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAKxC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"DashboardProvider.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/DashboardProvider.tsx"],"names":[],"mappings":";AAcA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAKxC,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAA+B,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,EAAsD,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