@perses-dev/dashboards 0.29.1 → 0.31.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/DashboardStickyToolbar/DashboardStickyToolbar.js +79 -0
- package/dist/cjs/{stories/decorators/WithQueryClient.js → components/DashboardStickyToolbar/index.js} +11 -12
- package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +8 -24
- package/dist/cjs/components/EditJsonButton/EditJsonButton.js +1 -0
- package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +5 -0
- package/dist/cjs/components/GridLayout/GridTitle.js +30 -9
- package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +88 -0
- package/dist/cjs/{stories/decorators/WithQueryParams.js → components/SaveChangesConfirmationDialog/index.js} +11 -12
- package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +78 -0
- package/dist/cjs/components/SaveDashboardButton/index.js +28 -0
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +5 -5
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +124 -198
- package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +178 -0
- package/dist/cjs/components/Variables/VariableEditorForm/index.js +1 -0
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +7 -8
- package/dist/cjs/components/Variables/VariableList.js +16 -55
- package/dist/cjs/components/Variables/index.js +1 -0
- package/dist/cjs/components/index.js +2 -0
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +5 -4
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +13 -4
- package/dist/cjs/context/DashboardProvider/save-changes-dialog-slice.js +33 -0
- package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +56 -7
- package/dist/cjs/context/TemplateVariableProvider/hydrationUtils.js +2 -0
- package/dist/cjs/context/TemplateVariableProvider/utils.js +37 -0
- package/dist/cjs/context/useDashboard.js +4 -4
- package/dist/cjs/stories/decorators/index.js +0 -5
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +2 -1
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts +9 -0
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts.map +1 -0
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +68 -0
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -0
- package/dist/components/DashboardStickyToolbar/index.d.ts +2 -0
- package/dist/components/DashboardStickyToolbar/index.d.ts.map +1 -0
- package/dist/{stories/decorators/WithQueryClient.js → components/DashboardStickyToolbar/index.js} +2 -10
- package/dist/components/DashboardStickyToolbar/index.js.map +1 -0
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js +10 -26
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/EditJsonButton/EditJsonButton.js +1 -0
- package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.d.ts.map +1 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.js +5 -0
- package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
- package/dist/components/GridLayout/GridTitle.js +30 -9
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts +3 -0
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -0
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +82 -0
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -0
- package/dist/components/SaveChangesConfirmationDialog/index.d.ts +2 -0
- package/dist/components/SaveChangesConfirmationDialog/index.d.ts.map +1 -0
- package/dist/{stories/decorators/WithQueryParams.js → components/SaveChangesConfirmationDialog/index.js} +2 -10
- package/dist/components/SaveChangesConfirmationDialog/index.js.map +1 -0
- package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts +10 -0
- package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -0
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js +72 -0
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -0
- package/dist/components/SaveDashboardButton/index.d.ts +2 -0
- package/dist/components/SaveDashboardButton/index.d.ts.map +1 -0
- package/dist/components/SaveDashboardButton/index.js +15 -0
- package/dist/components/SaveDashboardButton/index.js.map +1 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.js +6 -6
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +4 -2
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +127 -196
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +16 -0
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js +122 -0
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/index.d.ts +1 -0
- package/dist/components/Variables/VariableEditorForm/index.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/index.js +1 -0
- package/dist/components/Variables/VariableEditorForm/index.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +7 -8
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
- package/dist/components/Variables/VariableList.d.ts +1 -7
- package/dist/components/Variables/VariableList.d.ts.map +1 -1
- package/dist/components/Variables/VariableList.js +18 -52
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/components/Variables/index.d.ts +1 -0
- package/dist/components/Variables/index.d.ts.map +1 -1
- package/dist/components/Variables/index.js +1 -0
- package/dist/components/Variables/index.js.map +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +4 -3
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +5 -4
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +6 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js +11 -3
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts +15 -0
- package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/save-changes-dialog-slice.js +27 -0
- package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -0
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +4 -0
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +51 -7
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
- package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider/hydrationUtils.js +2 -0
- package/dist/context/TemplateVariableProvider/hydrationUtils.js.map +1 -1
- package/dist/context/TemplateVariableProvider/utils.d.ts +4 -0
- package/dist/context/TemplateVariableProvider/utils.d.ts.map +1 -0
- package/dist/context/TemplateVariableProvider/utils.js +33 -0
- package/dist/context/TemplateVariableProvider/utils.js.map +1 -0
- package/dist/context/useDashboard.d.ts.map +1 -1
- package/dist/context/useDashboard.js +4 -4
- package/dist/context/useDashboard.js.map +1 -1
- package/dist/stories/decorators/WithDashboard.js.map +1 -1
- package/dist/stories/decorators/WithDatasourceStore.js.map +1 -1
- package/dist/stories/decorators/WithTemplateVariables.js.map +1 -1
- package/dist/stories/decorators/index.js +0 -5
- package/dist/stories/decorators/index.js.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +3 -2
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/package.json +6 -6
- package/dist/cjs/stories/decorators/WithDataQueriesProvider.js +0 -39
- package/dist/cjs/stories/decorators/WithPluginRegistry.js +0 -94
- package/dist/cjs/stories/decorators/WithTimeRange.js +0 -38
- package/dist/stories/decorators/WithDataQueriesProvider.js +0 -33
- package/dist/stories/decorators/WithDataQueriesProvider.js.map +0 -1
- package/dist/stories/decorators/WithPluginRegistry.js +0 -49
- package/dist/stories/decorators/WithPluginRegistry.js.map +0 -1
- package/dist/stories/decorators/WithQueryClient.js.map +0 -1
- package/dist/stories/decorators/WithQueryParams.js.map +0 -1
- package/dist/stories/decorators/WithTimeRange.js +0 -32
- package/dist/stories/decorators/WithTimeRange.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/SaveDashboardButton/SaveDashboardButton.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 { Button, ButtonProps } from '@mui/material';\nimport { DashboardResource, isRelativeTimeRange } from '@perses-dev/core';\nimport { useTimeRange } from '@perses-dev/plugin-system';\nimport { useDashboard, useEditMode, useSaveChangesConfirmationDialog, useTemplateVariableActions } from '../../context';\n\nexport interface SaveDashboardButtonProps extends Pick<ButtonProps, 'fullWidth'> {\n onSave?: (entity: DashboardResource) => Promise<DashboardResource>;\n isDisabled: boolean;\n variant?: 'contained' | 'text' | 'outlined';\n}\n\nexport const SaveDashboardButton = ({ onSave, isDisabled, variant = 'contained' }: SaveDashboardButtonProps) => {\n const [isSavingDashboard, setSavingDashboard] = useState<boolean>(false);\n const { dashboard } = useDashboard();\n const { getSavedVariablesStatus, setVariableDefaultValues } = useTemplateVariableActions();\n const isSavedVariableModified = getSavedVariablesStatus();\n const { timeRange } = useTimeRange();\n const { setEditMode } = useEditMode();\n const { openSaveChangesConfirmationDialog, closeSaveChangesConfirmationDialog } = useSaveChangesConfirmationDialog();\n\n const onSaveButtonClick = () => {\n const isSavedDurationModified =\n isRelativeTimeRange(timeRange) && dashboard.spec.duration !== timeRange.pastDuration;\n\n // Save dashboard if active timeRange from plugin-system is relative and different than currently saved\n if (isSavedDurationModified || isSavedVariableModified) {\n openSaveChangesConfirmationDialog({\n onSaveChanges: (saveDefaultTimeRange, saveDefaultVariables) => {\n if (isRelativeTimeRange(timeRange) && saveDefaultTimeRange === true) {\n dashboard.spec.duration = timeRange.pastDuration;\n }\n if (saveDefaultVariables === true) {\n const variables = setVariableDefaultValues();\n dashboard.spec.variables = variables;\n }\n saveDashboard();\n },\n onCancel: () => {\n closeSaveChangesConfirmationDialog();\n },\n });\n } else {\n saveDashboard();\n }\n };\n\n const saveDashboard = () => {\n if (onSave !== undefined) {\n setSavingDashboard(true);\n onSave(dashboard)\n .then(() => {\n setSavingDashboard(false);\n closeSaveChangesConfirmationDialog();\n setEditMode(false);\n })\n .catch(() => {\n setSavingDashboard(false);\n });\n } else {\n setEditMode(false);\n }\n };\n\n return (\n <Button variant={variant} onClick={onSaveButtonClick} disabled={isDisabled || isSavingDashboard}>\n Save\n </Button>\n );\n};\n"],"names":["useState","Button","isRelativeTimeRange","useTimeRange","useDashboard","useEditMode","useSaveChangesConfirmationDialog","useTemplateVariableActions","SaveDashboardButton","onSave","isDisabled","variant","isSavingDashboard","setSavingDashboard","dashboard","getSavedVariablesStatus","setVariableDefaultValues","isSavedVariableModified","timeRange","setEditMode","openSaveChangesConfirmationDialog","closeSaveChangesConfirmationDialog","onSaveButtonClick","isSavedDurationModified","spec","duration","pastDuration","onSaveChanges","saveDefaultTimeRange","saveDefaultVariables","variables","saveDashboard","onCancel","undefined","then","catch","onClick","disabled"],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/SaveDashboardButton/index.tsx"],"names":[],"mappings":"AAaA,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
export * from './SaveDashboardButton';
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/SaveDashboardButton/index.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\nexport * from './SaveDashboardButton';\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,uBAAuB,CAAC"}
|
|
@@ -17,7 +17,7 @@ import { DateTimeRangePicker, InfoTooltip } from '@perses-dev/components';
|
|
|
17
17
|
import { useTimeRange } from '@perses-dev/plugin-system';
|
|
18
18
|
import { isDurationString } from '@perses-dev/core';
|
|
19
19
|
import { TOOLTIP_TEXT } from '../../constants';
|
|
20
|
-
import {
|
|
20
|
+
import { useDashboardDuration } from '../../context';
|
|
21
21
|
import { ToolbarIconButton } from '../ToolbarIconButton';
|
|
22
22
|
export const TIME_OPTIONS = [
|
|
23
23
|
{
|
|
@@ -79,17 +79,17 @@ const DEFAULT_HEIGHT = '34px';
|
|
|
79
79
|
export function TimeRangeControls({ heightPx , showRefresh =true }) {
|
|
80
80
|
const { timeRange , setTimeRange , refresh } = useTimeRange();
|
|
81
81
|
// TODO: Remove this since it couples to the dashboard context
|
|
82
|
-
const
|
|
82
|
+
const dashboardDuration = useDashboardDuration();
|
|
83
83
|
// Convert height to a string, then use the string for styling
|
|
84
84
|
const height = heightPx === undefined ? DEFAULT_HEIGHT : `${heightPx}px`;
|
|
85
85
|
// add time shortcut if one does not match duration from dashboard JSON
|
|
86
|
-
if (!TIME_OPTIONS.some((option)=>option.value.pastDuration ===
|
|
87
|
-
if (isDurationString(
|
|
86
|
+
if (!TIME_OPTIONS.some((option)=>option.value.pastDuration === dashboardDuration)) {
|
|
87
|
+
if (isDurationString(dashboardDuration)) {
|
|
88
88
|
TIME_OPTIONS.push({
|
|
89
89
|
value: {
|
|
90
|
-
pastDuration:
|
|
90
|
+
pastDuration: dashboardDuration
|
|
91
91
|
},
|
|
92
|
-
display: `Last ${
|
|
92
|
+
display: `Last ${dashboardDuration}`
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/TimeRangeControls/TimeRangeControls.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 RefreshIcon from 'mdi-material-ui/Refresh';\nimport { Stack } from '@mui/material';\nimport { DateTimeRangePicker, InfoTooltip, TimeOption } from '@perses-dev/components';\nimport { useTimeRange } from '@perses-dev/plugin-system';\nimport { isDurationString } from '@perses-dev/core';\nimport { TOOLTIP_TEXT } from '../../constants';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/components/TimeRangeControls/TimeRangeControls.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 RefreshIcon from 'mdi-material-ui/Refresh';\nimport { Stack } from '@mui/material';\nimport { DateTimeRangePicker, InfoTooltip, TimeOption } from '@perses-dev/components';\nimport { useTimeRange } from '@perses-dev/plugin-system';\nimport { isDurationString } from '@perses-dev/core';\nimport { TOOLTIP_TEXT } from '../../constants';\nimport { useDashboardDuration } from '../../context';\nimport { ToolbarIconButton } from '../ToolbarIconButton';\n\nexport const TIME_OPTIONS: TimeOption[] = [\n { value: { pastDuration: '5m' }, display: 'Last 5 minutes' },\n { value: { pastDuration: '15m' }, display: 'Last 15 minutes' },\n { value: { pastDuration: '30m' }, display: 'Last 30 minutes' },\n { value: { pastDuration: '1h' }, display: 'Last 1 hour' },\n { value: { pastDuration: '6h' }, display: 'Last 6 hours' },\n { value: { pastDuration: '12h' }, display: 'Last 12 hours' },\n { value: { pastDuration: '24h' }, display: 'Last 1 day' },\n { value: { pastDuration: '7d' }, display: 'Last 7 days' },\n { value: { pastDuration: '14d' }, display: 'Last 14 days' },\n];\n\nconst DEFAULT_HEIGHT = '34px';\n\ninterface TimeRangeControlsProps {\n // The controls look best at heights >= 28 pixels\n heightPx?: number;\n\n // Whether to show the refresh button or not\n showRefresh?: boolean;\n}\n\nexport function TimeRangeControls({ heightPx, showRefresh = true }: TimeRangeControlsProps) {\n const { timeRange, setTimeRange, refresh } = useTimeRange();\n // TODO: Remove this since it couples to the dashboard context\n const dashboardDuration = useDashboardDuration();\n\n // Convert height to a string, then use the string for styling\n const height = heightPx === undefined ? DEFAULT_HEIGHT : `${heightPx}px`;\n\n // add time shortcut if one does not match duration from dashboard JSON\n if (!TIME_OPTIONS.some((option) => option.value.pastDuration === dashboardDuration)) {\n if (isDurationString(dashboardDuration)) {\n TIME_OPTIONS.push({\n value: { pastDuration: dashboardDuration },\n display: `Last ${dashboardDuration}`,\n });\n }\n }\n\n return (\n <Stack direction=\"row\" spacing={1}>\n <DateTimeRangePicker timeOptions={TIME_OPTIONS} value={timeRange} onChange={setTimeRange} height={height} />\n {showRefresh && (\n <InfoTooltip description={TOOLTIP_TEXT.refreshDashboard}>\n <ToolbarIconButton aria-label={TOOLTIP_TEXT.refreshDashboard} onClick={refresh} sx={{ height }}>\n <RefreshIcon />\n </ToolbarIconButton>\n </InfoTooltip>\n )}\n </Stack>\n );\n}\n"],"names":["RefreshIcon","Stack","DateTimeRangePicker","InfoTooltip","useTimeRange","isDurationString","TOOLTIP_TEXT","useDashboardDuration","ToolbarIconButton","TIME_OPTIONS","value","pastDuration","display","DEFAULT_HEIGHT","TimeRangeControls","heightPx","showRefresh","timeRange","setTimeRange","refresh","dashboardDuration","height","undefined","some","option","push","direction","spacing","timeOptions","onChange","description","refreshDashboard","aria-label","onClick","sx"],"mappings":"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"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { VariableDefinition } from '@perses-dev/core';
|
|
3
|
-
|
|
3
|
+
interface VariableEditFormProps {
|
|
4
4
|
initialVariableDefinition: VariableDefinition;
|
|
5
5
|
onChange: (def: VariableDefinition) => void;
|
|
6
6
|
onCancel: () => void;
|
|
7
|
-
}
|
|
7
|
+
}
|
|
8
|
+
export declare function VariableEditForm(props: VariableEditFormProps): JSX.Element;
|
|
9
|
+
export {};
|
|
8
10
|
//# sourceMappingURL=VariableEditorForm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VariableEditorForm.d.ts","sourceRoot":"","sources":["../../../../src/components/Variables/VariableEditorForm/VariableEditorForm.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"VariableEditorForm.d.ts","sourceRoot":"","sources":["../../../../src/components/Variables/VariableEditorForm/VariableEditorForm.tsx"],"names":[],"mappings":";AAgCA,OAAO,EAAE,kBAAkB,EAA0B,MAAM,kBAAkB,CAAC;AA6B9E,UAAU,qBAAqB;IAC7B,yBAAyB,EAAE,kBAAkB,CAAC;IAC9C,QAAQ,EAAE,CAAC,GAAG,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC5C,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,eA+O5D"}
|
|
@@ -12,16 +12,13 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
14
|
import React, { useMemo, useState } from 'react';
|
|
15
|
-
import { Box, Typography, Switch, TextField, Grid, FormControl, InputLabel, MenuItem, Select, Button, Stack,
|
|
15
|
+
import { Box, Typography, Switch, TextField, Grid, FormControl, FormControlLabel, InputLabel, MenuItem, Select, Button, Stack, ClickAwayListener, Divider } from '@mui/material';
|
|
16
16
|
import { useImmer } from 'use-immer';
|
|
17
17
|
import { PluginEditor } from '@perses-dev/plugin-system';
|
|
18
|
-
import { ErrorBoundary
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import { TOOLTIP_TEXT } from '../../../constants';
|
|
22
|
-
import { useListVariablePluginValues, VARIABLE_TYPES } from '../variable-model';
|
|
18
|
+
import { ErrorBoundary } from '@perses-dev/components';
|
|
19
|
+
import { VARIABLE_TYPES } from '../variable-model';
|
|
20
|
+
import { VariableListPreview, VariablePreview } from './VariablePreview';
|
|
23
21
|
import { getVariableDefinitionFromState, getInitialState } from './variable-editor-form-model';
|
|
24
|
-
const DEFAULT_MAX_PREVIEW_VALUES = 50;
|
|
25
22
|
// TODO: Replace with proper validation library
|
|
26
23
|
function getValidation(state) {
|
|
27
24
|
/** Name validation */ let name = null;
|
|
@@ -37,100 +34,22 @@ function getValidation(state) {
|
|
|
37
34
|
isValid: !name
|
|
38
35
|
};
|
|
39
36
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
children: children
|
|
44
|
-
});
|
|
45
|
-
function VariableListPreview({ definition , onRefresh }) {
|
|
46
|
-
const { data , isFetching , error } = useListVariablePluginValues(definition);
|
|
47
|
-
const [maxValues, setMaxValues] = useState(DEFAULT_MAX_PREVIEW_VALUES);
|
|
48
|
-
const showAll = ()=>{
|
|
49
|
-
setMaxValues(undefined);
|
|
50
|
-
};
|
|
51
|
-
let notShown = 0;
|
|
52
|
-
if (data && (data === null || data === void 0 ? void 0 : data.length) > 0 && maxValues) {
|
|
53
|
-
notShown = data.length - maxValues;
|
|
54
|
-
}
|
|
55
|
-
const errorMessage = error === null || error === void 0 ? void 0 : error.message;
|
|
56
|
-
return /*#__PURE__*/ _jsxs(Box, {
|
|
57
|
-
children: [
|
|
58
|
-
/*#__PURE__*/ _jsxs(Stack, {
|
|
59
|
-
direction: 'row',
|
|
60
|
-
spacing: 1,
|
|
61
|
-
alignItems: "center",
|
|
62
|
-
children: [
|
|
63
|
-
/*#__PURE__*/ _jsx(Typography, {
|
|
64
|
-
variant: "caption",
|
|
65
|
-
children: "Preview Values"
|
|
66
|
-
}),
|
|
67
|
-
/*#__PURE__*/ _jsx(InfoTooltip, {
|
|
68
|
-
description: TOOLTIP_TEXT.refreshVariableValues,
|
|
69
|
-
children: /*#__PURE__*/ _jsx(IconButton, {
|
|
70
|
-
onClick: onRefresh,
|
|
71
|
-
size: "small",
|
|
72
|
-
children: /*#__PURE__*/ _jsx(Refresh, {})
|
|
73
|
-
})
|
|
74
|
-
}),
|
|
75
|
-
/*#__PURE__*/ _jsx(InfoTooltip, {
|
|
76
|
-
description: TOOLTIP_TEXT.copyVariableValues,
|
|
77
|
-
children: /*#__PURE__*/ _jsx(IconButton, {
|
|
78
|
-
onClick: async ()=>{
|
|
79
|
-
if (data === null || data === void 0 ? void 0 : data.length) {
|
|
80
|
-
await navigator.clipboard.writeText(data.map((d)=>d.label).join(','));
|
|
81
|
-
alert('Copied to clipboard!');
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
size: "small",
|
|
85
|
-
children: /*#__PURE__*/ _jsx(Clipboard, {})
|
|
86
|
-
})
|
|
87
|
-
})
|
|
88
|
-
]
|
|
89
|
-
}),
|
|
90
|
-
errorMessage && /*#__PURE__*/ _jsx(Alert, {
|
|
91
|
-
severity: "error",
|
|
92
|
-
children: errorMessage
|
|
93
|
-
}),
|
|
94
|
-
isFetching && 'Loading...',
|
|
95
|
-
(data === null || data === void 0 ? void 0 : data.length) === 0 && /*#__PURE__*/ _jsx(Alert, {
|
|
96
|
-
severity: "info",
|
|
97
|
-
children: "No results"
|
|
98
|
-
}),
|
|
99
|
-
/*#__PURE__*/ _jsxs(_Fragment, {
|
|
100
|
-
children: [
|
|
101
|
-
data === null || data === void 0 ? void 0 : data.slice(0, maxValues).map((val)=>/*#__PURE__*/ _jsx(Chip, {
|
|
102
|
-
sx: {
|
|
103
|
-
mr: 1,
|
|
104
|
-
mb: 1
|
|
105
|
-
},
|
|
106
|
-
size: "small",
|
|
107
|
-
label: val.label
|
|
108
|
-
}, val.value)),
|
|
109
|
-
notShown > 0 && /*#__PURE__*/ _jsx(Chip, {
|
|
110
|
-
onClick: showAll,
|
|
111
|
-
variant: "outlined",
|
|
112
|
-
sx: {
|
|
113
|
-
mr: 1,
|
|
114
|
-
mb: 1
|
|
115
|
-
},
|
|
116
|
-
size: "small",
|
|
117
|
-
label: `+${notShown} more`
|
|
118
|
-
})
|
|
119
|
-
]
|
|
120
|
-
})
|
|
121
|
-
]
|
|
37
|
+
function FallbackPreview() {
|
|
38
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
39
|
+
children: "Error previewing values"
|
|
122
40
|
});
|
|
123
41
|
}
|
|
124
|
-
export function VariableEditForm(
|
|
42
|
+
export function VariableEditForm(props) {
|
|
43
|
+
const { initialVariableDefinition , onChange , onCancel } = props;
|
|
125
44
|
const [state, setState] = useImmer(getInitialState(initialVariableDefinition));
|
|
126
45
|
const validation = useMemo(()=>getValidation(state), [
|
|
127
46
|
state
|
|
128
47
|
]);
|
|
129
|
-
const [previewKey, setPreviewKey] =
|
|
48
|
+
const [previewKey, setPreviewKey] = useState(0);
|
|
130
49
|
const refreshPreview = ()=>{
|
|
131
50
|
setPreviewKey((prev)=>prev + 1);
|
|
132
51
|
};
|
|
133
|
-
/** We use the `previewKey` that we increment to know when to
|
|
52
|
+
/** We use the `previewKey` that we increment to know when to explicitly update the
|
|
134
53
|
* spec that will be used for preview. The reason why we do this is to avoid
|
|
135
54
|
* having to re-fetch the values when the user is still editing the spec.
|
|
136
55
|
*/ const previewSpec = useMemo(()=>{
|
|
@@ -186,9 +105,6 @@ export function VariableEditForm({ initialVariableDefinition , onChange , onCanc
|
|
|
186
105
|
overflowY: 'scroll'
|
|
187
106
|
},
|
|
188
107
|
children: [
|
|
189
|
-
/*#__PURE__*/ _jsx(SectionHeader, {
|
|
190
|
-
children: "General"
|
|
191
|
-
}),
|
|
192
108
|
/*#__PURE__*/ _jsxs(Grid, {
|
|
193
109
|
container: true,
|
|
194
110
|
spacing: 2,
|
|
@@ -196,7 +112,7 @@ export function VariableEditForm({ initialVariableDefinition , onChange , onCanc
|
|
|
196
112
|
children: [
|
|
197
113
|
/*#__PURE__*/ _jsx(Grid, {
|
|
198
114
|
item: true,
|
|
199
|
-
xs:
|
|
115
|
+
xs: 8,
|
|
200
116
|
children: /*#__PURE__*/ _jsx(TextField, {
|
|
201
117
|
required: true,
|
|
202
118
|
error: !!validation.name,
|
|
@@ -213,7 +129,35 @@ export function VariableEditForm({ initialVariableDefinition , onChange , onCanc
|
|
|
213
129
|
}),
|
|
214
130
|
/*#__PURE__*/ _jsx(Grid, {
|
|
215
131
|
item: true,
|
|
216
|
-
xs:
|
|
132
|
+
xs: 4,
|
|
133
|
+
children: /*#__PURE__*/ _jsx(TextField, {
|
|
134
|
+
fullWidth: true,
|
|
135
|
+
label: "Display Label",
|
|
136
|
+
value: state.title || '',
|
|
137
|
+
onChange: (v)=>{
|
|
138
|
+
setState((draft)=>{
|
|
139
|
+
draft.title = v.target.value;
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
}),
|
|
144
|
+
/*#__PURE__*/ _jsx(Grid, {
|
|
145
|
+
item: true,
|
|
146
|
+
xs: 8,
|
|
147
|
+
children: /*#__PURE__*/ _jsx(TextField, {
|
|
148
|
+
fullWidth: true,
|
|
149
|
+
label: "Description",
|
|
150
|
+
value: state.description,
|
|
151
|
+
onChange: (v)=>{
|
|
152
|
+
setState((draft)=>{
|
|
153
|
+
draft.description = v.target.value;
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
})
|
|
157
|
+
}),
|
|
158
|
+
/*#__PURE__*/ _jsx(Grid, {
|
|
159
|
+
item: true,
|
|
160
|
+
xs: 4,
|
|
217
161
|
children: /*#__PURE__*/ _jsxs(FormControl, {
|
|
218
162
|
fullWidth: true,
|
|
219
163
|
children: [
|
|
@@ -238,50 +182,28 @@ export function VariableEditForm({ initialVariableDefinition , onChange , onCanc
|
|
|
238
182
|
})
|
|
239
183
|
]
|
|
240
184
|
})
|
|
241
|
-
}),
|
|
242
|
-
/*#__PURE__*/ _jsx(Grid, {
|
|
243
|
-
item: true,
|
|
244
|
-
xs: 6,
|
|
245
|
-
children: /*#__PURE__*/ _jsx(TextField, {
|
|
246
|
-
fullWidth: true,
|
|
247
|
-
label: "Display Label",
|
|
248
|
-
value: state.title || '',
|
|
249
|
-
onChange: (v)=>{
|
|
250
|
-
setState((draft)=>{
|
|
251
|
-
draft.title = v.target.value;
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
})
|
|
255
|
-
}),
|
|
256
|
-
/*#__PURE__*/ _jsx(Grid, {
|
|
257
|
-
item: true,
|
|
258
|
-
xs: 12,
|
|
259
|
-
children: /*#__PURE__*/ _jsx(TextField, {
|
|
260
|
-
fullWidth: true,
|
|
261
|
-
label: "Description",
|
|
262
|
-
value: state.description,
|
|
263
|
-
onChange: (v)=>{
|
|
264
|
-
setState((draft)=>{
|
|
265
|
-
draft.description = v.target.value;
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
})
|
|
269
185
|
})
|
|
270
186
|
]
|
|
271
187
|
}),
|
|
188
|
+
/*#__PURE__*/ _jsx(Divider, {}),
|
|
272
189
|
state.kind === 'TextVariable' && /*#__PURE__*/ _jsxs(_Fragment, {
|
|
273
190
|
children: [
|
|
274
|
-
/*#__PURE__*/ _jsx(
|
|
191
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
192
|
+
py: 1,
|
|
193
|
+
variant: "subtitle1",
|
|
275
194
|
children: "Text Options"
|
|
276
195
|
}),
|
|
277
|
-
/*#__PURE__*/
|
|
278
|
-
container: true,
|
|
196
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
279
197
|
spacing: 2,
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
198
|
+
children: [
|
|
199
|
+
/*#__PURE__*/ _jsx(Box, {
|
|
200
|
+
children: /*#__PURE__*/ _jsx(VariablePreview, {
|
|
201
|
+
values: [
|
|
202
|
+
state.textVariableFields.value
|
|
203
|
+
]
|
|
204
|
+
})
|
|
205
|
+
}),
|
|
206
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
285
207
|
label: "Value",
|
|
286
208
|
value: state.textVariableFields.value,
|
|
287
209
|
onChange: (v)=>{
|
|
@@ -290,30 +212,43 @@ export function VariableEditForm({ initialVariableDefinition , onChange , onCanc
|
|
|
290
212
|
});
|
|
291
213
|
}
|
|
292
214
|
})
|
|
293
|
-
|
|
215
|
+
]
|
|
294
216
|
})
|
|
295
217
|
]
|
|
296
218
|
}),
|
|
297
219
|
state.kind === 'ListVariable' && /*#__PURE__*/ _jsxs(_Fragment, {
|
|
298
220
|
children: [
|
|
299
|
-
/*#__PURE__*/ _jsx(
|
|
221
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
222
|
+
py: 1,
|
|
223
|
+
variant: "subtitle1",
|
|
300
224
|
children: "List Options"
|
|
301
225
|
}),
|
|
302
|
-
/*#__PURE__*/ _jsxs(
|
|
303
|
-
container: true,
|
|
226
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
304
227
|
spacing: 2,
|
|
305
228
|
mb: 2,
|
|
306
229
|
children: [
|
|
307
|
-
/*#__PURE__*/
|
|
308
|
-
|
|
309
|
-
|
|
230
|
+
state.listVariableFields.plugin.kind ? /*#__PURE__*/ _jsx(Box, {
|
|
231
|
+
children: /*#__PURE__*/ _jsx(ErrorBoundary, {
|
|
232
|
+
FallbackComponent: FallbackPreview,
|
|
233
|
+
resetKeys: [
|
|
234
|
+
previewSpec
|
|
235
|
+
],
|
|
236
|
+
children: /*#__PURE__*/ _jsx(VariableListPreview, {
|
|
237
|
+
definition: previewSpec,
|
|
238
|
+
onRefresh: refreshPreview
|
|
239
|
+
})
|
|
240
|
+
})
|
|
241
|
+
}) : /*#__PURE__*/ _jsx(VariablePreview, {
|
|
242
|
+
isLoading: true
|
|
243
|
+
}),
|
|
244
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
310
245
|
children: [
|
|
311
246
|
/*#__PURE__*/ _jsx(ClickAwayListener, {
|
|
312
247
|
onClickAway: ()=>refreshPreview(),
|
|
313
248
|
children: /*#__PURE__*/ _jsx(Box, {})
|
|
314
249
|
}),
|
|
315
250
|
/*#__PURE__*/ _jsx(PluginEditor, {
|
|
316
|
-
width:
|
|
251
|
+
width: "100%",
|
|
317
252
|
pluginType: "Variable",
|
|
318
253
|
pluginKindLabel: "Source",
|
|
319
254
|
value: state.listVariableFields.plugin,
|
|
@@ -325,73 +260,69 @@ export function VariableEditForm({ initialVariableDefinition , onChange , onCanc
|
|
|
325
260
|
})
|
|
326
261
|
]
|
|
327
262
|
}),
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
label: "Capturing Regexp Filter",
|
|
337
|
-
value: state.listVariableFields.capturing_regexp || '',
|
|
338
|
-
onChange: (e)=>{
|
|
339
|
-
setState((draft)=>{
|
|
263
|
+
/*#__PURE__*/ _jsx(Stack, {
|
|
264
|
+
children: /*#__PURE__*/ _jsx(TextField, {
|
|
265
|
+
label: "Capturing Regexp Filter",
|
|
266
|
+
value: state.listVariableFields.capturing_regexp || '',
|
|
267
|
+
onChange: (e)=>{
|
|
268
|
+
setState((draft)=>{
|
|
269
|
+
if (e.target.value) {
|
|
270
|
+
// TODO: do a better fix, if empty string => it should skip the filter
|
|
340
271
|
draft.listVariableFields.capturing_regexp = e.target.value;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
resetKeys: [
|
|
349
|
-
previewSpec
|
|
350
|
-
],
|
|
351
|
-
children: /*#__PURE__*/ _jsx(VariableListPreview, {
|
|
352
|
-
onRefresh: refreshPreview,
|
|
353
|
-
definition: previewSpec
|
|
354
|
-
})
|
|
355
|
-
})
|
|
356
|
-
]
|
|
272
|
+
} else {
|
|
273
|
+
draft.listVariableFields.capturing_regexp = undefined;
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
},
|
|
277
|
+
helperText: "Optional, if you want to filter on captured result."
|
|
278
|
+
})
|
|
357
279
|
})
|
|
358
280
|
]
|
|
359
281
|
}),
|
|
360
|
-
/*#__PURE__*/ _jsx(
|
|
282
|
+
/*#__PURE__*/ _jsx(Divider, {}),
|
|
283
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
284
|
+
py: 1,
|
|
285
|
+
variant: "subtitle1",
|
|
361
286
|
children: "Dropdown Options"
|
|
362
287
|
}),
|
|
363
|
-
/*#__PURE__*/ _jsxs(
|
|
364
|
-
|
|
365
|
-
spacing: 1,
|
|
366
|
-
mb: 1,
|
|
288
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
289
|
+
spacing: "2",
|
|
367
290
|
children: [
|
|
368
|
-
/*#__PURE__*/ _jsxs(
|
|
369
|
-
item: true,
|
|
370
|
-
xs: 12,
|
|
291
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
371
292
|
children: [
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
293
|
+
/*#__PURE__*/ _jsx(FormControlLabel, {
|
|
294
|
+
control: /*#__PURE__*/ _jsx(Switch, {
|
|
295
|
+
checked: state.listVariableFields.allowMultiple,
|
|
296
|
+
onChange: (e)=>{
|
|
297
|
+
setState((draft)=>{
|
|
298
|
+
draft.listVariableFields.allowMultiple = e.target.checked;
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
}),
|
|
302
|
+
label: "Allow Multiple Values"
|
|
303
|
+
}),
|
|
304
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
305
|
+
variant: "caption",
|
|
306
|
+
children: "Enables multiple values to be selected at the same time"
|
|
380
307
|
})
|
|
381
308
|
]
|
|
382
309
|
}),
|
|
383
|
-
/*#__PURE__*/ _jsxs(
|
|
384
|
-
item: true,
|
|
385
|
-
xs: 12,
|
|
310
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
386
311
|
children: [
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
312
|
+
/*#__PURE__*/ _jsx(FormControlLabel, {
|
|
313
|
+
control: /*#__PURE__*/ _jsx(Switch, {
|
|
314
|
+
checked: state.listVariableFields.allowAll,
|
|
315
|
+
onChange: (e)=>{
|
|
316
|
+
setState((draft)=>{
|
|
317
|
+
draft.listVariableFields.allowAll = e.target.checked;
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
}),
|
|
321
|
+
label: "Allow All option"
|
|
322
|
+
}),
|
|
323
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
324
|
+
variant: "caption",
|
|
325
|
+
children: "Enables an option to include all variable values"
|
|
395
326
|
})
|
|
396
327
|
]
|
|
397
328
|
})
|