@perses-dev/dashboards 0.20.0 → 0.21.1

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.
Files changed (104) hide show
  1. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +18 -5
  2. package/dist/cjs/components/DeletePanelDialog/DeletePanelDialog.js +2 -0
  3. package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +2 -0
  4. package/dist/cjs/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +74 -0
  5. package/dist/cjs/components/{UnsavedChangesConfirmationDialog → DiscardChangesConfirmationDialog}/index.js +1 -1
  6. package/dist/cjs/components/GridLayout/GridTitle.js +38 -22
  7. package/dist/cjs/components/Panel/PanelHeader.js +59 -26
  8. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +29 -8
  9. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +11 -6
  10. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +9 -2
  11. package/dist/cjs/components/Variables/Variable.js +5 -3
  12. package/dist/cjs/components/Variables/VariableEditor.js +115 -99
  13. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +67 -56
  14. package/dist/cjs/components/Variables/VariableList.js +7 -20
  15. package/dist/cjs/components/Variables/variable-model.js +12 -1
  16. package/dist/cjs/components/index.js +1 -1
  17. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +2 -0
  18. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +10 -1
  19. package/dist/cjs/context/DashboardProvider/discard-changes-dialog-slice.js +33 -0
  20. package/dist/cjs/views/ViewDashboard/DashboardApp.js +14 -14
  21. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +2 -1
  22. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +2 -0
  23. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  24. package/dist/components/DashboardToolbar/DashboardToolbar.js +19 -6
  25. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  26. package/dist/components/DeletePanelDialog/DeletePanelDialog.js +2 -0
  27. package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -1
  28. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
  29. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +2 -0
  30. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
  31. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts +3 -0
  32. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts.map +1 -0
  33. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +63 -0
  34. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -0
  35. package/dist/components/DiscardChangesConfirmationDialog/index.d.ts +2 -0
  36. package/dist/components/DiscardChangesConfirmationDialog/index.d.ts.map +1 -0
  37. package/dist/components/{UnsavedChangesConfirmationDialog → DiscardChangesConfirmationDialog}/index.js +1 -1
  38. package/dist/components/{UnsavedChangesConfirmationDialog → DiscardChangesConfirmationDialog}/index.js.map +1 -1
  39. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  40. package/dist/components/GridLayout/GridTitle.js +38 -22
  41. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  42. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  43. package/dist/components/Panel/PanelHeader.js +61 -28
  44. package/dist/components/Panel/PanelHeader.js.map +1 -1
  45. package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
  46. package/dist/components/PanelDrawer/PanelDrawer.js +32 -11
  47. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  48. package/dist/components/PanelDrawer/PanelEditorForm.d.ts +1 -1
  49. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  50. package/dist/components/PanelDrawer/PanelEditorForm.js +12 -7
  51. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  52. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +5 -1
  53. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  54. package/dist/components/TimeRangeControls/TimeRangeControls.js +9 -2
  55. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  56. package/dist/components/Variables/Variable.js +5 -3
  57. package/dist/components/Variables/Variable.js.map +1 -1
  58. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  59. package/dist/components/Variables/VariableEditor.js +115 -99
  60. package/dist/components/Variables/VariableEditor.js.map +1 -1
  61. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  62. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +68 -57
  63. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  64. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  65. package/dist/components/Variables/VariableList.js +7 -20
  66. package/dist/components/Variables/VariableList.js.map +1 -1
  67. package/dist/components/Variables/variable-model.d.ts +7 -0
  68. package/dist/components/Variables/variable-model.d.ts.map +1 -1
  69. package/dist/components/Variables/variable-model.js +10 -0
  70. package/dist/components/Variables/variable-model.js.map +1 -1
  71. package/dist/components/index.d.ts +1 -1
  72. package/dist/components/index.js +1 -1
  73. package/dist/components/index.js.map +1 -1
  74. package/dist/context/DashboardProvider/DashboardProvider.d.ts +2 -1
  75. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  76. package/dist/context/DashboardProvider/DashboardProvider.js +2 -0
  77. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  78. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +5 -0
  79. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  80. package/dist/context/DashboardProvider/dashboard-provider-api.js +8 -0
  81. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  82. package/dist/context/DashboardProvider/discard-changes-dialog-slice.d.ts +15 -0
  83. package/dist/context/DashboardProvider/discard-changes-dialog-slice.d.ts.map +1 -0
  84. package/dist/context/DashboardProvider/discard-changes-dialog-slice.js +27 -0
  85. package/dist/context/DashboardProvider/discard-changes-dialog-slice.js.map +1 -0
  86. package/dist/context/DashboardProvider/index.d.ts +1 -0
  87. package/dist/context/DashboardProvider/index.d.ts.map +1 -1
  88. package/dist/context/DashboardProvider/index.js.map +1 -1
  89. package/dist/views/ViewDashboard/DashboardApp.d.ts +1 -0
  90. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  91. package/dist/views/ViewDashboard/DashboardApp.js +16 -16
  92. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  93. package/dist/views/ViewDashboard/ViewDashboard.d.ts +1 -0
  94. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  95. package/dist/views/ViewDashboard/ViewDashboard.js +2 -1
  96. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  97. package/package.json +4 -4
  98. package/dist/cjs/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js +0 -67
  99. package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts +0 -8
  100. package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts.map +0 -1
  101. package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js +0 -56
  102. package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js.map +0 -1
  103. package/dist/components/UnsavedChangesConfirmationDialog/index.d.ts +0 -2
  104. package/dist/components/UnsavedChangesConfirmationDialog/index.d.ts.map +0 -1
@@ -10,9 +10,9 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
14
  import { CardHeader, Typography, Stack, IconButton, styled } from '@mui/material';
15
- import { InfoTooltip, TooltipPlacement, combineSx } from '@perses-dev/components';
15
+ import { InfoTooltip, combineSx } from '@perses-dev/components';
16
16
  import InformationOutlineIcon from 'mdi-material-ui/InformationOutline';
17
17
  import PencilIcon from 'mdi-material-ui/PencilOutline';
18
18
  import DeleteIcon from 'mdi-material-ui/DeleteOutline';
@@ -20,49 +20,62 @@ import DragIcon from 'mdi-material-ui/DragVertical';
20
20
  export function PanelHeader({ id , title , description , editHandlers , isHovered , sx , ...rest }) {
21
21
  const titleElementId = `${id}-title`;
22
22
  const descriptionTooltipId = `${id}-description`;
23
- let action = undefined;
23
+ let actions = undefined;
24
24
  if (editHandlers !== undefined) {
25
25
  // If there are edit handlers, always just show the edit buttons
26
- action = /*#__PURE__*/ _jsxs(Stack, {
27
- direction: "row",
28
- spacing: 0.5,
29
- alignItems: "center",
26
+ actions = /*#__PURE__*/ _jsxs(_Fragment, {
30
27
  children: [
31
- /*#__PURE__*/ _jsx(HeaderIconButton, {
32
- "aria-label": `edit panel ${title}`,
33
- size: "small",
34
- onClick: editHandlers.onEditPanelClick,
35
- children: /*#__PURE__*/ _jsx(PencilIcon, {})
28
+ /*#__PURE__*/ _jsx(InfoTooltip, {
29
+ description: "Edit",
30
+ children: /*#__PURE__*/ _jsx(HeaderIconButton, {
31
+ "aria-label": `edit panel ${title}`,
32
+ size: "small",
33
+ onClick: editHandlers.onEditPanelClick,
34
+ children: /*#__PURE__*/ _jsx(PencilIcon, {
35
+ fontSize: "inherit"
36
+ })
37
+ })
36
38
  }),
37
- /*#__PURE__*/ _jsx(HeaderIconButton, {
38
- "aria-label": `delete panel ${title}`,
39
- size: "small",
40
- onClick: editHandlers.onDeletePanelClick,
41
- children: /*#__PURE__*/ _jsx(DeleteIcon, {})
39
+ /*#__PURE__*/ _jsx(InfoTooltip, {
40
+ description: "Delete",
41
+ children: /*#__PURE__*/ _jsx(HeaderIconButton, {
42
+ "aria-label": `delete panel ${title}`,
43
+ size: "small",
44
+ onClick: editHandlers.onDeletePanelClick,
45
+ children: /*#__PURE__*/ _jsx(DeleteIcon, {
46
+ fontSize: "inherit"
47
+ })
48
+ })
42
49
  }),
43
- /*#__PURE__*/ _jsx(HeaderIconButton, {
44
- "aria-label": `move panel ${title}`,
45
- size: "small",
46
- children: /*#__PURE__*/ _jsx(DragIcon, {
47
- className: "drag-handle",
48
- sx: {
49
- cursor: 'grab'
50
- }
50
+ /*#__PURE__*/ _jsx(InfoTooltip, {
51
+ description: "Drag and drop panel to reorganize",
52
+ children: /*#__PURE__*/ _jsx(HeaderIconButton, {
53
+ "aria-label": `move panel ${title}`,
54
+ size: "small",
55
+ children: /*#__PURE__*/ _jsx(DragIcon, {
56
+ className: "drag-handle",
57
+ sx: {
58
+ cursor: 'grab'
59
+ },
60
+ fontSize: "inherit"
61
+ })
51
62
  })
52
63
  })
53
64
  ]
54
65
  });
55
66
  } else if (description !== undefined && isHovered) {
56
67
  // If there aren't edit handlers and we have a description, show a button with a tooltip for the panel description
57
- action = /*#__PURE__*/ _jsx(InfoTooltip, {
68
+ actions = /*#__PURE__*/ _jsx(InfoTooltip, {
58
69
  id: descriptionTooltipId,
59
70
  description: description,
60
- placement: TooltipPlacement.Bottom,
71
+ enterDelay: 100,
61
72
  children: /*#__PURE__*/ _jsx(HeaderIconButton, {
62
73
  "aria-label": "Panel Description",
74
+ size: "small",
63
75
  children: /*#__PURE__*/ _jsx(InformationOutlineIcon, {
64
76
  "aria-describedby": "info-tooltip",
65
77
  "aria-hidden": false,
78
+ fontSize: "inherit",
66
79
  sx: {
67
80
  color: (theme)=>theme.palette.grey[700]
68
81
  }
@@ -90,12 +103,24 @@ export function PanelHeader({ id , title , description , editHandlers , isHovere
90
103
  },
91
104
  children: title
92
105
  }),
93
- action: action,
106
+ action: /*#__PURE__*/ _jsx(HeaderActionWrapper, {
107
+ direction: "row",
108
+ spacing: 0.25,
109
+ alignItems: "center",
110
+ children: actions
111
+ }),
94
112
  sx: combineSx((theme)=>({
95
113
  padding: theme.spacing(1),
96
114
  borderBottom: `solid 1px ${theme.palette.divider}`,
97
115
  '.MuiCardHeader-content': {
98
116
  overflow: 'hidden'
117
+ },
118
+ '.MuiCardHeader-action': {
119
+ // Overriding the negative margins from MUI's defaults, so we
120
+ // can vertically center the icons. Moving these values to a wrapper
121
+ // inside the action in `HeaderActionWrapper` below.
122
+ // https://github.com/mui/material-ui/blob/master/packages/mui-material/src/CardHeader/CardHeader.js#L56-L58
123
+ margin: 'auto'
99
124
  }
100
125
  }), sx),
101
126
  ...rest
@@ -105,5 +130,13 @@ const HeaderIconButton = styled(IconButton)(({ theme })=>({
105
130
  borderRadius: theme.shape.borderRadius,
106
131
  padding: '4px'
107
132
  }));
133
+ const HeaderActionWrapper = styled(Stack)(()=>({
134
+ // Adding back the negative margins from MUI's defaults for actions, so we
135
+ // avoid increasing the header size when actions are present while also being
136
+ // able to vertically center the actions.
137
+ // https://github.com/mui/material-ui/blob/master/packages/mui-material/src/CardHeader/CardHeader.js#L56-L58
138
+ marginTop: -4,
139
+ marginBottom: -4
140
+ }));
108
141
 
109
142
  //# sourceMappingURL=PanelHeader.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Panel/PanelHeader.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 { CardHeader, Typography, Stack, IconButton, CardHeaderProps, styled } from '@mui/material';\nimport { InfoTooltip, TooltipPlacement, combineSx } from '@perses-dev/components';\nimport InformationOutlineIcon from 'mdi-material-ui/InformationOutline';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport DragIcon from 'mdi-material-ui/DragVertical';\n\ntype OmittedProps = 'children' | 'action' | 'title' | 'disableTypography';\n\nexport interface PanelHeaderProps extends Omit<CardHeaderProps, OmittedProps> {\n id: string;\n title: string;\n description?: string;\n editHandlers?: {\n onEditPanelClick: () => void;\n onDeletePanelClick: () => void;\n };\n isHovered: boolean;\n}\n\nexport function PanelHeader({ id, title, description, editHandlers, isHovered, sx, ...rest }: PanelHeaderProps) {\n const titleElementId = `${id}-title`;\n const descriptionTooltipId = `${id}-description`;\n\n let action: CardHeaderProps['action'] = undefined;\n if (editHandlers !== undefined) {\n // If there are edit handlers, always just show the edit buttons\n action = (\n <Stack direction=\"row\" spacing={0.5} alignItems=\"center\">\n <HeaderIconButton aria-label={`edit panel ${title}`} size=\"small\" onClick={editHandlers.onEditPanelClick}>\n <PencilIcon />\n </HeaderIconButton>\n <HeaderIconButton aria-label={`delete panel ${title}`} size=\"small\" onClick={editHandlers.onDeletePanelClick}>\n <DeleteIcon />\n </HeaderIconButton>\n <HeaderIconButton aria-label={`move panel ${title}`} size=\"small\">\n <DragIcon className=\"drag-handle\" sx={{ cursor: 'grab' }} />\n </HeaderIconButton>\n </Stack>\n );\n } else if (description !== undefined && isHovered) {\n // If there aren't edit handlers and we have a description, show a button with a tooltip for the panel description\n action = (\n <InfoTooltip id={descriptionTooltipId} description={description} placement={TooltipPlacement.Bottom}>\n <HeaderIconButton aria-label=\"Panel Description\">\n <InformationOutlineIcon\n aria-describedby=\"info-tooltip\"\n aria-hidden={false}\n sx={{ color: (theme) => theme.palette.grey[700] }}\n />\n </HeaderIconButton>\n </InfoTooltip>\n );\n }\n\n return (\n <CardHeader\n id={id}\n component=\"header\"\n aria-labelledby={titleElementId}\n aria-describedby={descriptionTooltipId}\n disableTypography\n title={\n <Typography\n id={titleElementId}\n variant=\"subtitle1\"\n sx={{\n // `minHeight` guarantees that the header has the correct height\n // when there is no title (i.e. in the preview)\n lineHeight: '24px',\n minHeight: '24px',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n }}\n >\n {title}\n </Typography>\n }\n action={action}\n sx={combineSx(\n (theme) => ({\n padding: theme.spacing(1),\n borderBottom: `solid 1px ${theme.palette.divider}`,\n '.MuiCardHeader-content': {\n overflow: 'hidden',\n },\n }),\n sx\n )}\n {...rest}\n />\n );\n}\n\nconst HeaderIconButton = styled(IconButton)(({ theme }) => ({\n borderRadius: theme.shape.borderRadius,\n padding: '4px',\n}));\n"],"names":["CardHeader","Typography","Stack","IconButton","styled","InfoTooltip","TooltipPlacement","combineSx","InformationOutlineIcon","PencilIcon","DeleteIcon","DragIcon","PanelHeader","id","title","description","editHandlers","isHovered","sx","rest","titleElementId","descriptionTooltipId","action","undefined","direction","spacing","alignItems","HeaderIconButton","aria-label","size","onClick","onEditPanelClick","onDeletePanelClick","className","cursor","placement","Bottom","aria-describedby","aria-hidden","color","theme","palette","grey","component","aria-labelledby","disableTypography","variant","lineHeight","minHeight","whiteSpace","overflow","textOverflow","padding","borderBottom","divider","borderRadius","shape"],"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,UAAU,EAAEC,KAAK,EAAEC,UAAU,EAAmBC,MAAM,QAAQ,eAAe,CAAC;AACnG,SAASC,WAAW,EAAEC,gBAAgB,EAAEC,SAAS,QAAQ,wBAAwB,CAAC;AAClF,OAAOC,sBAAsB,MAAM,oCAAoC,CAAC;AACxE,OAAOC,UAAU,MAAM,+BAA+B,CAAC;AACvD,OAAOC,UAAU,MAAM,+BAA+B,CAAC;AAC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;QACA,GAAGC,IAAI;MACR,CACF;AACJ,CAAC;AAED,MAAMQ,gBAAgB,GAAGvB,MAAM,CAACD,UAAU,CAAC,CAAC,CAAC,EAAEqC,KAAK,CAAA,EAAE,GAAM,CAAA;QAC1De,YAAY,EAAEf,KAAK,CAACgB,KAAK,CAACD,YAAY;QACtCH,OAAO,EAAE,KAAK;KACf,CAAA,AAAC,CAAC,AAAC"}
1
+ {"version":3,"sources":["../../../src/components/Panel/PanelHeader.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 { CardHeader, Typography, Stack, IconButton, CardHeaderProps, styled } from '@mui/material';\nimport { InfoTooltip, combineSx } from '@perses-dev/components';\nimport InformationOutlineIcon from 'mdi-material-ui/InformationOutline';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport DragIcon from 'mdi-material-ui/DragVertical';\n\ntype OmittedProps = 'children' | 'action' | 'title' | 'disableTypography';\n\nexport interface PanelHeaderProps extends Omit<CardHeaderProps, OmittedProps> {\n id: string;\n title: string;\n description?: string;\n editHandlers?: {\n onEditPanelClick: () => void;\n onDeletePanelClick: () => void;\n };\n isHovered: boolean;\n}\n\nexport function PanelHeader({ id, title, description, editHandlers, isHovered, sx, ...rest }: PanelHeaderProps) {\n const titleElementId = `${id}-title`;\n const descriptionTooltipId = `${id}-description`;\n\n let actions: CardHeaderProps['action'] = undefined;\n if (editHandlers !== undefined) {\n // If there are edit handlers, always just show the edit buttons\n actions = (\n <>\n <InfoTooltip description=\"Edit\">\n <HeaderIconButton aria-label={`edit panel ${title}`} size=\"small\" onClick={editHandlers.onEditPanelClick}>\n <PencilIcon fontSize=\"inherit\" />\n </HeaderIconButton>\n </InfoTooltip>\n <InfoTooltip description=\"Delete\">\n <HeaderIconButton aria-label={`delete panel ${title}`} size=\"small\" onClick={editHandlers.onDeletePanelClick}>\n <DeleteIcon fontSize=\"inherit\" />\n </HeaderIconButton>\n </InfoTooltip>\n <InfoTooltip description=\"Drag and drop panel to reorganize\">\n <HeaderIconButton aria-label={`move panel ${title}`} size=\"small\">\n <DragIcon className=\"drag-handle\" sx={{ cursor: 'grab' }} fontSize=\"inherit\" />\n </HeaderIconButton>\n </InfoTooltip>\n </>\n );\n } else if (description !== undefined && isHovered) {\n // If there aren't edit handlers and we have a description, show a button with a tooltip for the panel description\n actions = (\n <InfoTooltip id={descriptionTooltipId} description={description} enterDelay={100}>\n <HeaderIconButton aria-label=\"Panel Description\" size=\"small\">\n <InformationOutlineIcon\n aria-describedby=\"info-tooltip\"\n aria-hidden={false}\n fontSize=\"inherit\"\n sx={{ color: (theme) => theme.palette.grey[700] }}\n />\n </HeaderIconButton>\n </InfoTooltip>\n );\n }\n\n return (\n <CardHeader\n id={id}\n component=\"header\"\n aria-labelledby={titleElementId}\n aria-describedby={descriptionTooltipId}\n disableTypography\n title={\n <Typography\n id={titleElementId}\n variant=\"subtitle1\"\n sx={{\n // `minHeight` guarantees that the header has the correct height\n // when there is no title (i.e. in the preview)\n lineHeight: '24px',\n minHeight: '24px',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n }}\n >\n {title}\n </Typography>\n }\n action={\n <HeaderActionWrapper direction=\"row\" spacing={0.25} alignItems=\"center\">\n {actions}\n </HeaderActionWrapper>\n }\n sx={combineSx(\n (theme) => ({\n padding: theme.spacing(1),\n borderBottom: `solid 1px ${theme.palette.divider}`,\n '.MuiCardHeader-content': {\n overflow: 'hidden',\n },\n '.MuiCardHeader-action': {\n // Overriding the negative margins from MUI's defaults, so we\n // can vertically center the icons. Moving these values to a wrapper\n // inside the action in `HeaderActionWrapper` below.\n // https://github.com/mui/material-ui/blob/master/packages/mui-material/src/CardHeader/CardHeader.js#L56-L58\n margin: 'auto',\n },\n }),\n sx\n )}\n {...rest}\n />\n );\n}\n\nconst HeaderIconButton = styled(IconButton)(({ theme }) => ({\n borderRadius: theme.shape.borderRadius,\n padding: '4px',\n}));\n\nconst HeaderActionWrapper = styled(Stack)(() => ({\n // Adding back the negative margins from MUI's defaults for actions, so we\n // avoid increasing the header size when actions are present while also being\n // able to vertically center the actions.\n // https://github.com/mui/material-ui/blob/master/packages/mui-material/src/CardHeader/CardHeader.js#L56-L58\n marginTop: -4,\n marginBottom: -4,\n}));\n"],"names":["CardHeader","Typography","Stack","IconButton","styled","InfoTooltip","combineSx","InformationOutlineIcon","PencilIcon","DeleteIcon","DragIcon","PanelHeader","id","title","description","editHandlers","isHovered","sx","rest","titleElementId","descriptionTooltipId","actions","undefined","HeaderIconButton","aria-label","size","onClick","onEditPanelClick","fontSize","onDeletePanelClick","className","cursor","enterDelay","aria-describedby","aria-hidden","color","theme","palette","grey","component","aria-labelledby","disableTypography","variant","lineHeight","minHeight","whiteSpace","overflow","textOverflow","action","HeaderActionWrapper","direction","spacing","alignItems","padding","borderBottom","divider","margin","borderRadius","shape","marginTop","marginBottom"],"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,UAAU,EAAEC,KAAK,EAAEC,UAAU,EAAmBC,MAAM,QAAQ,eAAe,CAAC;AACnG,SAASC,WAAW,EAAEC,SAAS,QAAQ,wBAAwB,CAAC;AAChE,OAAOC,sBAAsB,MAAM,oCAAoC,CAAC;AACxE,OAAOC,UAAU,MAAM,+BAA+B,CAAC;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E,IAAI;YAAEC,UAAU,EAAC,QAAQ;sBACpE/B,OAAO;UACY;QAExBJ,EAAE,EAAEX,SAAS,CACX,CAAC8B,KAAK,GAAM,CAAA;gBACViB,OAAO,EAAEjB,KAAK,CAACe,OAAO,CAAC,CAAC,CAAC;gBACzBG,YAAY,EAAE,CAAC,UAAU,EAAElB,KAAK,CAACC,OAAO,CAACkB,OAAO,CAAC,CAAC;gBAClD,wBAAwB,EAAE;oBACxBT,QAAQ,EAAE,QAAQ;iBACnB;gBACD,uBAAuB,EAAE;oBACvB,6DAA6D;oBAC7D,oEAAoE;oBACpE,oDAAoD;oBACpD,4GAA4G;oBAC5GU,MAAM,EAAE,MAAM;iBACf;aACF,CAAA,AAAC,EACFvC,EAAE,CACH;QACA,GAAGC,IAAI;MACR,CACF;AACJ,CAAC;AAED,MAAMK,gBAAgB,GAAGnB,MAAM,CAACD,UAAU,CAAC,CAAC,CAAC,EAAEiC,KAAK,CAAA,EAAE,GAAM,CAAA;QAC1DqB,YAAY,EAAErB,KAAK,CAACsB,KAAK,CAACD,YAAY;QACtCJ,OAAO,EAAE,KAAK;KACf,CAAA,AAAC,CAAC,AAAC;AAEJ,MAAMJ,mBAAmB,GAAG7C,MAAM,CAACF,KAAK,CAAC,CAAC,IAAO,CAAA;QAC/C,0EAA0E;QAC1E,6EAA6E;QAC7E,yCAAyC;QACzC,4GAA4G;QAC5GyD,SAAS,EAAE,CAAC,CAAC;QACbC,YAAY,EAAE,CAAC,CAAC;KACjB,CAAA,AAAC,CAAC,AAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"PanelDrawer.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelDrawer.tsx"],"names":[],"mappings":";AAmBA;;GAEG;AACH,eAAO,MAAM,WAAW,mBAsDvB,CAAC"}
1
+ {"version":3,"file":"PanelDrawer.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelDrawer.tsx"],"names":[],"mappings":";AAoBA;;GAEG;AACH,eAAO,MAAM,WAAW,mBA+EvB,CAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ /* eslint-disable @typescript-eslint/no-empty-function */ // Copyright 2022 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -11,18 +11,36 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
- import { useState } from 'react';
14
+ import { useCallback, useState } from 'react';
15
15
  import { Stack, Box, Button, Typography } from '@mui/material';
16
16
  import { Drawer } from '@perses-dev/components';
17
- import { usePanelEditor } from '../../context';
18
- import { PanelEditorForm, panelEditorFormId } from './PanelEditorForm';
17
+ import { useDiscardChangesConfirmationDialog, usePanelEditor } from '../../context';
18
+ import { PanelEditorForm } from './PanelEditorForm';
19
19
  /**
20
20
  * The Add/Edit panel drawer for editing a panel's options.
21
21
  */ export const PanelDrawer = ()=>{
22
22
  const panelEditor = usePanelEditor();
23
+ const { openDiscardChangesConfirmationDialog , closeDiscardChangesConfirmationDialog } = useDiscardChangesConfirmationDialog();
24
+ const [values, setValues] = useState(undefined);
23
25
  // When the user clicks close, start closing but don't call the store yet to keep values stable during animtation
24
26
  const [isClosing, setIsClosing] = useState(false);
25
- const handleClose = ()=>setIsClosing(true);
27
+ const handleClose = ()=>{
28
+ const isModified = JSON.stringify(panelEditor === null || panelEditor === void 0 ? void 0 : panelEditor.initialValues) !== JSON.stringify(values);
29
+ if (isModified) {
30
+ openDiscardChangesConfirmationDialog({
31
+ onDiscardChanges: ()=>{
32
+ closeDiscardChangesConfirmationDialog();
33
+ setIsClosing(true);
34
+ },
35
+ onCancel: ()=>{
36
+ closeDiscardChangesConfirmationDialog();
37
+ },
38
+ description: 'You have unapplied changes in this panel. Are you sure you want to discard these changes? Changes cannot be recovered.'
39
+ });
40
+ } else {
41
+ setIsClosing(true);
42
+ }
43
+ };
26
44
  // Don't call closeDrawer on the store until the Drawer has completely transitioned out
27
45
  const handleExited = ()=>{
28
46
  panelEditor === null || panelEditor === void 0 ? void 0 : panelEditor.close();
@@ -30,14 +48,17 @@ import { PanelEditorForm, panelEditorFormId } from './PanelEditorForm';
30
48
  };
31
49
  // Drawer is open if we have a model and we're not transitioning out
32
50
  const isOpen = panelEditor !== undefined && isClosing === false;
33
- const handleSubmit = (values)=>{
51
+ const handleSubmit = ()=>{
34
52
  // This shouldn't happen since we don't render the submit button until we have a model, but check to make TS happy
35
- if (panelEditor === undefined) {
53
+ if (panelEditor === undefined || values === undefined) {
36
54
  throw new Error('Cannot apply changes');
37
55
  }
38
56
  panelEditor.applyChanges(values);
39
- handleClose();
57
+ setIsClosing(true);
40
58
  };
59
+ const handleChange = useCallback((values)=>{
60
+ setValues(values);
61
+ }, []);
41
62
  return /*#__PURE__*/ _jsx(Drawer, {
42
63
  isOpen: isOpen,
43
64
  onClose: handleClose,
@@ -69,7 +90,7 @@ import { PanelEditorForm, panelEditorFormId } from './PanelEditorForm';
69
90
  /*#__PURE__*/ _jsx(Button, {
70
91
  type: "submit",
71
92
  variant: "contained",
72
- form: panelEditorFormId,
93
+ onClick: handleSubmit,
73
94
  children: panelEditor.mode === 'Add' ? 'Add' : 'Apply'
74
95
  }),
75
96
  /*#__PURE__*/ _jsx(Button, {
@@ -83,8 +104,8 @@ import { PanelEditorForm, panelEditorFormId } from './PanelEditorForm';
83
104
  ]
84
105
  }),
85
106
  /*#__PURE__*/ _jsx(PanelEditorForm, {
86
- onSubmit: handleSubmit,
87
- initialValues: panelEditor.initialValues
107
+ initialValues: panelEditor.initialValues,
108
+ onChange: handleChange
88
109
  })
89
110
  ]
90
111
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PanelDrawer/PanelDrawer.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 { useState } from 'react';\nimport { Stack, Box, Button, Typography } from '@mui/material';\nimport { Drawer } from '@perses-dev/components';\nimport { usePanelEditor } from '../../context';\nimport { PanelEditorForm, panelEditorFormId, PanelEditorFormProps } from './PanelEditorForm';\n\n/**\n * The Add/Edit panel drawer for editing a panel's options.\n */\nexport const PanelDrawer = () => {\n const panelEditor = usePanelEditor();\n\n // When the user clicks close, start closing but don't call the store yet to keep values stable during animtation\n const [isClosing, setIsClosing] = useState(false);\n const handleClose = () => setIsClosing(true);\n\n // Don't call closeDrawer on the store until the Drawer has completely transitioned out\n const handleExited = () => {\n panelEditor?.close();\n setIsClosing(false);\n };\n\n // Drawer is open if we have a model and we're not transitioning out\n const isOpen = panelEditor !== undefined && isClosing === false;\n\n const handleSubmit: PanelEditorFormProps['onSubmit'] = (values) => {\n // This shouldn't happen since we don't render the submit button until we have a model, but check to make TS happy\n if (panelEditor === undefined) {\n throw new Error('Cannot apply changes');\n }\n panelEditor.applyChanges(values);\n handleClose();\n };\n\n return (\n <Drawer isOpen={isOpen} onClose={handleClose} SlideProps={{ onExited: handleExited }}>\n {/* When the drawer is opened, we should have panel editor state (this also ensures the form state gets reset between opens) */}\n {panelEditor !== undefined && (\n <>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">{panelEditor.mode} Panel</Typography>\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\">\n {/* Using the 'form' attribute lets us have a submit button like this outside the form element */}\n <Button type=\"submit\" variant=\"contained\" form={panelEditorFormId}>\n {panelEditor.mode === 'Add' ? 'Add' : 'Apply'}\n </Button>\n <Button color=\"secondary\" variant=\"outlined\" onClick={handleClose}>\n Cancel\n </Button>\n </Stack>\n </Box>\n <PanelEditorForm onSubmit={handleSubmit} initialValues={panelEditor.initialValues} />\n </>\n )}\n </Drawer>\n );\n};\n"],"names":["useState","Stack","Box","Button","Typography","Drawer","usePanelEditor","PanelEditorForm","panelEditorFormId","PanelDrawer","panelEditor","isClosing","setIsClosing","handleClose","handleExited","close","isOpen","undefined","handleSubmit","values","Error","applyChanges","onClose","SlideProps","onExited","sx","display","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","mode","direction","marginLeft","type","form","color","onClick","onSubmit","initialValues"],"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,QAAQ,QAAQ,OAAO,CAAC;AACjC,SAASC,KAAK,EAAEC,GAAG,EAAEC,MAAM,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAC/D,SAASC,MAAM,QAAQ,wBAAwB,CAAC;AAChD,SAASC,cAAc,QAAQ,eAAe,CAAC;AAC/C,SAASC,eAAe,EAAEC,iBAAiB,QAA8B,mBAAmB,CAAC;AAE7F;;CAEC,GACD,OAAO,MAAMC,WAAW,GAAG,IAAM;IAC/B,MAAMC,WAAW,GAAGJ,cAAc,EAAE,AAAC;IAErC,iHAAiH;IACjH,MAAM,CAACK,SAAS,EAAEC,YAAY,CAAC,GAAGZ,QAAQ,CAAC,KAAK,CAAC,AAAC;IAClD,MAAMa,WAAW,GAAG,IAAMD,YAAY,CAAC,IAAI,CAAC,AAAC;IAE7C,uFAAuF;IACvF,MAAME,YAAY,GAAG,IAAM;QACzBJ,WAAW,aAAXA,WAAW,WAAO,GAAlBA,KAAAA,CAAkB,GAA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KAAK,GAAG,KAAK,GAAG,OAAO;kCACtC;8CACT,KAAChC,MAAM;oCAACqC,KAAK,EAAC,WAAW;oCAACN,OAAO,EAAC,UAAU;oCAACO,OAAO,EAAE5B,WAAW;8CAAE,QAEnE;kCAAS;;0BACH;;kBACJ;8BACN,KAACN,eAAe;oBAACmC,QAAQ,EAAExB,YAAY;oBAAEyB,aAAa,EAAEjC,WAAW,CAACiC,aAAa;kBAAI;;UACpF,AACJ;MACM,CACT;AACJ,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/PanelDrawer/PanelDrawer.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-empty-function */\n// 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 { useCallback, useState } from 'react';\nimport { Stack, Box, Button, Typography } from '@mui/material';\nimport { Drawer } from '@perses-dev/components';\nimport { PanelEditorValues, useDiscardChangesConfirmationDialog, usePanelEditor } from '../../context';\nimport { PanelEditorForm, PanelEditorFormProps } from './PanelEditorForm';\n\n/**\n * The Add/Edit panel drawer for editing a panel's options.\n */\nexport const PanelDrawer = () => {\n const panelEditor = usePanelEditor();\n const { openDiscardChangesConfirmationDialog, closeDiscardChangesConfirmationDialog } =\n useDiscardChangesConfirmationDialog();\n\n const [values, setValues] = useState<PanelEditorValues | undefined>(undefined);\n\n // When the user clicks close, start closing but don't call the store yet to keep values stable during animtation\n const [isClosing, setIsClosing] = useState(false);\n const handleClose = () => {\n const isModified = JSON.stringify(panelEditor?.initialValues) !== JSON.stringify(values);\n if (isModified) {\n openDiscardChangesConfirmationDialog({\n onDiscardChanges: () => {\n closeDiscardChangesConfirmationDialog();\n setIsClosing(true);\n },\n onCancel: () => {\n closeDiscardChangesConfirmationDialog();\n },\n description:\n 'You have unapplied changes in this panel. Are you sure you want to discard these changes? Changes cannot be recovered.',\n });\n } else {\n setIsClosing(true);\n }\n };\n\n // Don't call closeDrawer on the store until the Drawer has completely transitioned out\n const handleExited = () => {\n panelEditor?.close();\n setIsClosing(false);\n };\n\n // Drawer is open if we have a model and we're not transitioning out\n const isOpen = panelEditor !== undefined && isClosing === false;\n\n const handleSubmit = () => {\n // This shouldn't happen since we don't render the submit button until we have a model, but check to make TS happy\n if (panelEditor === undefined || values === undefined) {\n throw new Error('Cannot apply changes');\n }\n panelEditor.applyChanges(values);\n setIsClosing(true);\n };\n\n const handleChange: PanelEditorFormProps['onChange'] = useCallback((values) => {\n setValues(values);\n }, []);\n\n return (\n <Drawer isOpen={isOpen} onClose={handleClose} SlideProps={{ onExited: handleExited }}>\n {/* When the drawer is opened, we should have panel editor state (this also ensures the form state gets reset between opens) */}\n {panelEditor !== undefined && (\n <>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">{panelEditor.mode} Panel</Typography>\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\">\n {/* Using the 'form' attribute lets us have a submit button like this outside the form element */}\n <Button type=\"submit\" variant=\"contained\" onClick={handleSubmit}>\n {panelEditor.mode === 'Add' ? 'Add' : 'Apply'}\n </Button>\n <Button color=\"secondary\" variant=\"outlined\" onClick={handleClose}>\n Cancel\n </Button>\n </Stack>\n </Box>\n <PanelEditorForm initialValues={panelEditor.initialValues} onChange={handleChange} />\n </>\n )}\n </Drawer>\n );\n};\n"],"names":["useCallback","useState","Stack","Box","Button","Typography","Drawer","useDiscardChangesConfirmationDialog","usePanelEditor","PanelEditorForm","PanelDrawer","panelEditor","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","values","setValues","undefined","isClosing","setIsClosing","handleClose","isModified","JSON","stringify","initialValues","onDiscardChanges","onCancel","description","handleExited","close","isOpen","handleSubmit","Error","applyChanges","handleChange","onClose","SlideProps","onExited","sx","display","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","mode","direction","marginLeft","type","onClick","color","onChange"],"mappings":"AAAA,uDAAuD,GACvD,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,WAAW,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AAC9C,SAASC,KAAK,EAAEC,GAAG,EAAEC,MAAM,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAC/D,SAASC,MAAM,QAAQ,wBAAwB,CAAC;AAChD,SAA4BC,mCAAmC,EAAEC,cAAc,QAAQ,eAAe,CAAC;AACvG,SAASC,eAAe,QAA8B,mBAAmB,CAAC;AAE1E;;CAEC,GACD,OAAO,MAAMC,WAAW,GAAG,IAAM;IAC/B,MAAMC,WAAW,GAAGH,cAAc,EAAE,AAAC;IACrC,MAAM,EAAEI,oCAAoC,CAAA,EAAEC,qCAAqC,CAAA,EAAE,GACnFN,mCAAmC,EAAE,AAAC;IAExC,MAAM,CAACO,MAAM,EAAEC,SAAS,CAAC,GAAGd,QAAQ,CAAgCe,SAAS,CAAC,AAAC;IAE/E,iHAAiH;IACjH,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGjB,QAAQ,CAAC,KAAK,CAAC,AAAC;IAClD,MAAMkB,WAAW,GAAG,IAAM;QACxB,MAAMC,UAAU,GAAGC,IAAI,CAACC,SAAS,CAACX,WAAW,aAAXA,WAAW,WAAe,GAA1BA,KAAAA,CAA0B,GAA1BA,WAAW,CAAEY,aAAa,CAAC,KAAKF,IAAI,CAACC,SAAS,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,SAAS,kBACxB;;8BACE,MAACb,GAAG;oBACFkC,EAAE,EAAE;wBACFC,OAAO,EAAE,MAAM;wBACfC,UAAU,EAAE,QAAQ;wBACpBC,OAAO,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;wBACvCC,YAAY,EAAE,CAACF,KAAK,GAAK,CAAC,UAAU,EAAEA,KAAK,CAACG,OAAO,CAACC,OAAO,CAAC,CAAC;qBAC9D;;sCAED,MAACxC,UAAU;4BAACyC,OAAO,EAAC,IAAI;;gCAAEnC,WAAW,CAACoC,IAAI;gCAAC,QAAM;;0BAAa;sCAC9D,MAAC7C,KAAK;4BAAC8C,SAAS,EAAC,KAAK;4BAACN,OAAO,EAAE,CAAC;4BAAEO,UAAU,EAAC,MAAM;;8CAElD,KAAC7C,MAAM;oCAAC8C,IAAI,EAAC,QAAQ;oCAACJ,OAAO,EAAC,WAAW;oCAACK,OAAO,EAAErB,YAAY;8CAC5DnB,WAAW,CAACoC,IAAI,KAAK,KAAK,GAAG,KAAK,GAAG,OAAO;kCACtC;8CACT,KAAC3C,MAAM;oCAACgD,KAAK,EAAC,WAAW;oCAACN,OAAO,EAAC,UAAU;oCAACK,OAAO,EAAEhC,WAAW;8CAAE,QAEnE;kCAAS;;0BACH;;kBACJ;8BACN,KAACV,eAAe;oBAACc,aAAa,EAAEZ,WAAW,CAACY,aAAa;oBAAE8B,QAAQ,EAAEpB,YAAY;kBAAI;;UACpF,AACJ;MACM,CACT;AACJ,CAAC,CAAC"}
@@ -2,7 +2,7 @@
2
2
  import { PanelEditorValues } from '../../context/DashboardProvider/panel-editor-slice';
3
3
  export interface PanelEditorFormProps {
4
4
  initialValues: PanelEditorValues;
5
- onSubmit: (values: PanelEditorValues) => void;
5
+ onChange: (values: PanelEditorValues) => void;
6
6
  }
7
7
  export declare function PanelEditorForm(props: PanelEditorFormProps): JSX.Element;
8
8
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"PanelEditorForm.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelEditorForm.tsx"],"names":[],"mappings":";AA6BA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AAGvF,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,iBAAiB,CAAC;IACjC,QAAQ,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAC/C;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eA0G1D;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,sBAAsB,CAAC"}
1
+ {"version":3,"file":"PanelEditorForm.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelEditorForm.tsx"],"names":[],"mappings":";AA6BA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AAGvF,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,iBAAiB,CAAC;IACjC,QAAQ,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAC/C;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eAwG1D;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,sBAAsB,CAAC"}
@@ -11,7 +11,7 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- import { useState } from 'react';
14
+ import { useEffect, useState } from 'react';
15
15
  import { Box, FormControl, FormHelperText, Grid, InputLabel, MenuItem, Select, TextField, Typography } from '@mui/material';
16
16
  import { ErrorAlert, ErrorBoundary } from '@perses-dev/components';
17
17
  import { PluginKindSelect, PluginSpecEditor, usePluginEditor } from '@perses-dev/plugin-system';
@@ -19,7 +19,7 @@ import { useListPanelGroups } from '../../context';
19
19
  import { PanelPreview } from './PanelPreview';
20
20
  export function PanelEditorForm(props) {
21
21
  var ref;
22
- const { initialValues , onSubmit } = props;
22
+ const { initialValues , onChange } = props;
23
23
  const panelGroups = useListPanelGroups();
24
24
  const [name, setName] = useState(initialValues.name);
25
25
  const [description, setDescription] = useState(initialValues.description);
@@ -46,8 +46,7 @@ export function PanelEditorForm(props) {
46
46
  }
47
47
  setGroupId(value);
48
48
  };
49
- const handleSubmit = (e)=>{
50
- e.preventDefault();
49
+ useEffect(()=>{
51
50
  const values = {
52
51
  name,
53
52
  description,
@@ -55,14 +54,20 @@ export function PanelEditorForm(props) {
55
54
  kind,
56
55
  spec
57
56
  };
58
- onSubmit(values);
59
- };
57
+ onChange(values);
58
+ }, [
59
+ name,
60
+ description,
61
+ groupId,
62
+ kind,
63
+ spec,
64
+ onChange
65
+ ]);
60
66
  var _title, ref1;
61
67
  return(// Grid maxHeight allows user to scroll inside Drawer to see all content
62
68
  /*#__PURE__*/ _jsx(Box, {
63
69
  component: "form",
64
70
  id: panelEditorFormId,
65
- onSubmit: handleSubmit,
66
71
  sx: {
67
72
  flex: 1,
68
73
  overflowY: 'scroll',
@@ -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 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"],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,cAAA,KAACG,gBAAgB;4BAACoB,UAAU,EAAC,OAAO;4BAACuC,UAAU,EAAE3C,IAAI;4BAAEK,KAAK,EAAEH,IAAI;4BAAEI,QAAQ,EAAEhB,YAAY,CAACsD,YAAY;0BAAI;sBAC7F;kBACX;;UACF;MACH,EACN;AACJ,CAAC;AAED;;CAEC,GACD,OAAO,MAAM3B,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 { useEffect, 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 onChange: (values: PanelEditorValues) => void;\n}\n\nexport function PanelEditorForm(props: PanelEditorFormProps) {\n const { initialValues, onChange } = 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 useEffect(() => {\n const values: PanelEditorValues = { name, description, groupId, kind, spec };\n onChange(values);\n }, [name, description, groupId, kind, spec, onChange]);\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 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":["useEffect","useState","Box","FormControl","FormHelperText","Grid","InputLabel","MenuItem","Select","TextField","Typography","ErrorAlert","ErrorBoundary","PluginKindSelect","PluginSpecEditor","usePluginEditor","useListPanelGroups","PanelPreview","PanelEditorForm","props","pluginEditor","initialValues","onChange","panelGroups","name","setName","description","setDescription","groupId","setGroupId","kind","setKind","spec","setSpec","pluginType","value","plugin","handleGroupChange","e","target","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,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AAC5C,SACEC,GAAG,EACHC,WAAW,EACXC,cAAc,EACdC,IAAI,EACJC,UAAU,EACVC,QAAQ,EACRC,MAAM,EAENC,SAAS,EACTC,UAAU,QACL,eAAe,CAAC;AACvB,SAASC,UAAU,EAAEC,aAAa,QAAQ,wBAAw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C6C,WAAW,GAAG7C,YAAY,CAAC6C,WAAW,GAAGnC,IAAI;oCACjER,QAAQ,EAAEF,YAAY,CAAC8C,YAAY;kCACnC;;0BACU;sCACd,KAAC9D,cAAc;sCAAEgB,CAAAA,IAA2B,GAA3BA,CAAAA,GAAkB,GAAlBA,YAAY,CAAC4C,KAAK,cAAlB5C,GAAkB,WAAS,GAA3BA,KAAAA,CAA2B,GAA3BA,GAAkB,CAAE+C,OAAO,cAA3B/C,IAA2B,cAA3BA,IAA2B,GAAI,EAAE;0BAAkB;;kBAC/D;8BACP,MAACf,IAAI;oBAAC+C,IAAI;oBAACC,EAAE,EAAE,EAAE;;sCACf,KAAC3C,UAAU;4BAAC+C,OAAO,EAAC,IAAI;4BAACW,YAAY,EAAE,CAAC;sCAAE,SAE1C;0BAAa;sCACb,KAACxD,aAAa;4BAACyD,iBAAiB,EAAE1D,UAAU;sCAC1C,cAAA,KAACM,YAAY;gCAACa,IAAI,EAAEA,IAAI;gCAAEN,IAAI,EAAEA,IAAI;gCAAEE,WAAW,EAAEA,WAAW;gCAAEM,IAAI,EAAEA,IAAI;gCAAEJ,OAAO,EAAEA,OAAO;8BAAI;0BAClF;;kBACX;8BACP,KAACvB,IAAI;oBAAC+C,IAAI;oBAACC,EAAE,EAAE,EAAE;8BACf,cAAA,KAACzC,aAAa;wBAACyD,iBAAiB,EAAE1D,UAAU;kCAC1C,cAAA,KAACG,gBAAgB;4BAACoB,UAAU,EAAC,OAAO;4BAACoC,UAAU,EAAExC,IAAI;4BAAEK,KAAK,EAAEH,IAAI;4BAAEV,QAAQ,EAAEF,YAAY,CAACmD,YAAY;0BAAI;sBAC7F;kBACX;;UACF;MACH,EACN;AACJ,CAAC;AAED;;CAEC,GACD,OAAO,MAAM3B,iBAAiB,GAAG,mBAAmB,CAAC"}
@@ -1,5 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  import { TimeOption } from '@perses-dev/components';
3
3
  export declare const TIME_OPTIONS: TimeOption[];
4
- export declare function TimeRangeControls(): JSX.Element;
4
+ interface TimeRangeControlsProps {
5
+ heightPx?: number;
6
+ }
7
+ export declare function TimeRangeControls({ heightPx }: TimeRangeControlsProps): JSX.Element;
8
+ export {};
5
9
  //# sourceMappingURL=TimeRangeControls.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TimeRangeControls.d.ts","sourceRoot":"","sources":["../../../src/components/TimeRangeControls/TimeRangeControls.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAuB,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAKzE,eAAO,MAAM,YAAY,EAAE,UAAU,EAUpC,CAAC;AAEF,wBAAgB,iBAAiB,gBAsBhC"}
1
+ {"version":3,"file":"TimeRangeControls.d.ts","sourceRoot":"","sources":["../../../src/components/TimeRangeControls/TimeRangeControls.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAuB,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAKzE,eAAO,MAAM,YAAY,EAAE,UAAU,EAUpC,CAAC;AAIF,UAAU,sBAAsB;IAI9B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,EAAE,sBAAsB,eAyBrE"}
@@ -73,9 +73,12 @@ export const TIME_OPTIONS = [
73
73
  display: 'Last 14 days'
74
74
  }
75
75
  ];
76
- export function TimeRangeControls() {
76
+ const DEFAULT_HEIGHT = '34px';
77
+ export function TimeRangeControls({ heightPx }) {
77
78
  const { timeRange , setTimeRange , refresh } = useTimeRange();
78
79
  const defaultTimeRange = useDefaultTimeRange();
80
+ // Convert height as a number to height as a string, then use this value for styling
81
+ const height = heightPx === undefined ? DEFAULT_HEIGHT : `${heightPx}px`;
79
82
  // add time shortcut if one does not match duration from dashboard JSON
80
83
  if (!TIME_OPTIONS.some((option)=>option.value.pastDuration === defaultTimeRange.pastDuration)) {
81
84
  if (isDurationString(defaultTimeRange.pastDuration)) {
@@ -92,11 +95,15 @@ export function TimeRangeControls() {
92
95
  /*#__PURE__*/ _jsx(DateTimeRangePicker, {
93
96
  timeOptions: TIME_OPTIONS,
94
97
  value: timeRange,
95
- onChange: setTimeRange
98
+ onChange: setTimeRange,
99
+ height: height
96
100
  }),
97
101
  /*#__PURE__*/ _jsx(RefreshIconButton, {
98
102
  "aria-label": "Refresh Dashboard",
99
103
  onClick: refresh,
104
+ sx: {
105
+ height
106
+ },
100
107
  children: /*#__PURE__*/ _jsx(RefreshIcon, {})
101
108
  })
102
109
  ]
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/TimeRangeControls/TimeRangeControls.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 RefreshIcon from 'mdi-material-ui/Refresh';\nimport { IconButton, styled } from '@mui/material';\nimport { DateTimeRangePicker, TimeOption } from '@perses-dev/components';\nimport { useTimeRange } from '@perses-dev/plugin-system';\nimport { isDurationString } from '@perses-dev/core';\nimport { useDefaultTimeRange } from '../../context';\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\nexport function TimeRangeControls() {\n const { timeRange, setTimeRange, refresh } = useTimeRange();\n const defaultTimeRange = useDefaultTimeRange();\n\n // add time shortcut if one does not match duration from dashboard JSON\n if (!TIME_OPTIONS.some((option) => option.value.pastDuration === defaultTimeRange.pastDuration)) {\n if (isDurationString(defaultTimeRange.pastDuration)) {\n TIME_OPTIONS.push({\n value: { pastDuration: defaultTimeRange.pastDuration },\n display: `Last ${defaultTimeRange.pastDuration}`,\n });\n }\n }\n\n return (\n <>\n <DateTimeRangePicker timeOptions={TIME_OPTIONS} value={timeRange} onChange={setTimeRange} />\n <RefreshIconButton aria-label=\"Refresh Dashboard\" onClick={refresh}>\n <RefreshIcon />\n </RefreshIconButton>\n </>\n );\n}\n\nconst RefreshIconButton = styled(IconButton)(({ theme }) => ({\n border: `1px solid ${theme.palette.grey[300]}`,\n borderRadius: theme.shape.borderRadius,\n padding: theme.spacing(0.5),\n color: theme.palette.grey[900],\n}));\n"],"names":["RefreshIcon","IconButton","styled","DateTimeRangePicker","useTimeRange","isDurationString","useDefaultTimeRange","TIME_OPTIONS","value","pastDuration","display","TimeRangeControls","timeRange","setTimeRange","refresh","defaultTimeRange","some","option","push","timeOptions","onChange","RefreshIconButton","aria-label","onClick","theme","border","palette","grey","borderRadius","shape","padding","spacing","color"],"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,OAAOA,WAAW,MAAM,yBAAyB,CAAC;AAClD,SAASC,UAAU,EAAEC,MAAM,QAAQ,eAAe,CAAC;AACnD,SAASC,mBAAmB,QAAoB,wBAAwB,CAAC;AACzE,SAASC,YAAY,QAAQ,2BAA2B,CAAC;AACzD,SAASC,gBAAgB,QAAQ,kBAAkB,CAAC;AACpD,SAASC,mBAAmB,QAAQ,eAAe,CAAC;AAEpD,OAAO,M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nDF,YAAY,CAACW,IAAI,CAAC;gBAChBV,KAAK,EAAE;oBAAEC,YAAY,EAAEM,gBAAgB,CAACN,YAAY;iBAAE;gBACtDC,OAAO,EAAE,CAAC,KAAK,EAAEK,gBAAgB,CAACN,YAAY,CAAC,CAAC;aACjD,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,qBACE;;0BACE,KAACN,mBAAmB;gBAACgB,WAAW,EAAEZ,YAAY;gBAAEC,KAAK,EAAEI,SAAS;gBAAEQ,QAAQ,EAAEP,YAAY;cAAI;0BAC5F,KAACQ,iBAAiB;gBAACC,YAAU,EAAC,mBAAmB;gBAACC,OAAO,EAAET,OAAO;0BAChE,cAAA,KAACd,WAAW,KAAG;cACG;;MACnB,CACH;AACJ,CAAC;AAED,MAAMqB,iBAAiB,GAAGnB,MAAM,CAACD,UAAU,CAAC,CAAC,CAAC,EAAEuB,KAAK,CAAA,EAAE,GAAM,CAAA;QAC3DC,MAAM,EAAE,CAAC,UAAU,EAAED,KAAK,CAACE,OAAO,CAACC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAC9CC,YAAY,EAAEJ,KAAK,CAACK,KAAK,CAACD,YAAY;QACtCE,OAAO,EAAEN,KAAK,CAACO,OAAO,CAAC,GAAG,CAAC;QAC3BC,KAAK,EAAER,KAAK,CAACE,OAAO,CAACC,IAAI,CAAC,GAAG,CAAC;KAC/B,CAAA,AAAC,CAAC,AAAC"}
1
+ {"version":3,"sources":["../../../src/components/TimeRangeControls/TimeRangeControls.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 RefreshIcon from 'mdi-material-ui/Refresh';\nimport { IconButton, styled } from '@mui/material';\nimport { DateTimeRangePicker, TimeOption } from '@perses-dev/components';\nimport { useTimeRange } from '@perses-dev/plugin-system';\nimport { isDurationString } from '@perses-dev/core';\nimport { useDefaultTimeRange } from '../../context';\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 // Height of the controls in pixels.\n // The controls look best at heights >= 28 pixels.\n // You can use values less than 28, but it won't look great.\n heightPx?: number;\n}\n\nexport function TimeRangeControls({ heightPx }: TimeRangeControlsProps) {\n const { timeRange, setTimeRange, refresh } = useTimeRange();\n const defaultTimeRange = useDefaultTimeRange();\n\n // Convert height as a number to height as a string, then use this value 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 === defaultTimeRange.pastDuration)) {\n if (isDurationString(defaultTimeRange.pastDuration)) {\n TIME_OPTIONS.push({\n value: { pastDuration: defaultTimeRange.pastDuration },\n display: `Last ${defaultTimeRange.pastDuration}`,\n });\n }\n }\n\n return (\n <>\n <DateTimeRangePicker timeOptions={TIME_OPTIONS} value={timeRange} onChange={setTimeRange} height={height} />\n <RefreshIconButton aria-label=\"Refresh Dashboard\" onClick={refresh} sx={{ height }}>\n <RefreshIcon />\n </RefreshIconButton>\n </>\n );\n}\n\nconst RefreshIconButton = styled(IconButton)(({ theme }) => ({\n border: `1px solid ${theme.palette.grey[300]}`,\n borderRadius: theme.shape.borderRadius,\n padding: theme.spacing(0.5),\n color: theme.palette.grey[900],\n}));\n"],"names":["RefreshIcon","IconButton","styled","DateTimeRangePicker","useTimeRange","isDurationString","useDefaultTimeRange","TIME_OPTIONS","value","pastDuration","display","DEFAULT_HEIGHT","TimeRangeControls","heightPx","timeRange","setTimeRange","refresh","defaultTimeRange","height","undefined","some","option","push","timeOptions","onChange","RefreshIconButton","aria-label","onClick","sx","theme","border","palette","grey","borderRadius","shape","padding","spacing","color"],"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,OAAOA,WAAW,MAAM,yBAAyB,CAAC;AAClD,SAASC,UAAU,EAAEC,MAAM,QAAQ,eAAe,CAAC;AACnD,SAASC,mBAAmB,QAAoB,wBAAwB,CAAC;AACzE,SAASC,YAAY,QAAQ,2BAA2B,CAAC;AACzD,SAASC,gBAAgB,QAAQ,kBAAkB,CAAC;AACpD,SAASC,mBAAmB,QAAQ,eAAe,CAAC;AAEpD,OAAO,MAAMC,YAAY,GAAiB;IACxC;QAAEC,KAAK,EAAE;YAAEC,YAAY,EAAE,IAAI;SAAE;QAAEC,OAAO,EAAE,gBAAgB;KAAE;IAC5D;QAAEF,KAAK,EAAE;YAAEC,YAAY,EAAE,KAAK;SAAE;QAAEC,OAAO,EAAE,iBAAiB;KAAE;IAC9D;QAAEF,KAAK,EAAE;YAAEC,YAAY,EAAE,KAAK;SAAE;QAAEC,OAAO,EAAE,iBAAiB;KAAE;IAC9D;QAAEF,KAAK,EAAE;YAAEC,YAAY,EAAE,IAAI;SAAE;QAAEC,OAAO,EAAE,aAAa;KAAE;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AC,CAAC;QACL,CAAC;IACH,CAAC;IAED,qBACE;;0BACE,KAACN,mBAAmB;gBAACoB,WAAW,EAAEhB,YAAY;gBAAEC,KAAK,EAAEM,SAAS;gBAAEU,QAAQ,EAAET,YAAY;gBAAEG,MAAM,EAAEA,MAAM;cAAI;0BAC5G,KAACO,iBAAiB;gBAACC,YAAU,EAAC,mBAAmB;gBAACC,OAAO,EAAEX,OAAO;gBAAEY,EAAE,EAAE;oBAAEV,MAAM;iBAAE;0BAChF,cAAA,KAAClB,WAAW,KAAG;cACG;;MACnB,CACH;AACJ,CAAC;AAED,MAAMyB,iBAAiB,GAAGvB,MAAM,CAACD,UAAU,CAAC,CAAC,CAAC,EAAE4B,KAAK,CAAA,EAAE,GAAM,CAAA;QAC3DC,MAAM,EAAE,CAAC,UAAU,EAAED,KAAK,CAACE,OAAO,CAACC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAC9CC,YAAY,EAAEJ,KAAK,CAACK,KAAK,CAACD,YAAY;QACtCE,OAAO,EAAEN,KAAK,CAACO,OAAO,CAAC,GAAG,CAAC;QAC3BC,KAAK,EAAER,KAAK,CAACE,OAAO,CAACC,IAAI,CAAC,GAAG,CAAC;KAC/B,CAAA,AAAC,CAAC,AAAC"}
@@ -164,9 +164,10 @@ function ListVariable({ name }) {
164
164
  });
165
165
  }
166
166
  function TextVariable({ name }) {
167
- const { state } = useTemplateVariable(name);
168
167
  var ref;
169
- const [tempValue, setTempValue] = useState((ref = state === null || state === void 0 ? void 0 : state.value) !== null && ref !== void 0 ? ref : '');
168
+ const { state , definition } = useTemplateVariable(name);
169
+ var ref1;
170
+ const [tempValue, setTempValue] = useState((ref1 = state === null || state === void 0 ? void 0 : state.value) !== null && ref1 !== void 0 ? ref1 : '');
170
171
  const { setVariableValue } = useTemplateVariableActions();
171
172
  useEffect(()=>{
172
173
  var ref;
@@ -174,12 +175,13 @@ function TextVariable({ name }) {
174
175
  }, [
175
176
  state === null || state === void 0 ? void 0 : state.value
176
177
  ]);
178
+ var ref2;
177
179
  return /*#__PURE__*/ _jsx(TextField, {
178
180
  value: tempValue,
179
181
  onChange: (e)=>setTempValue(e.target.value),
180
182
  onBlur: ()=>setVariableValue(name, tempValue),
181
183
  placeholder: name,
182
- label: name
184
+ label: (ref2 = (ref = definition === null || definition === void 0 ? void 0 : definition.spec.display) === null || ref === void 0 ? void 0 : ref.name) !== null && ref2 !== void 0 ? ref2 : name
183
185
  });
184
186
  }
185
187