@perses-dev/dashboards 0.42.1 → 0.43.0-rc1

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 (62) hide show
  1. package/dist/cjs/components/AddGroupButton/AddGroupButton.js +1 -0
  2. package/dist/cjs/components/AddPanelButton/AddPanelButton.js +1 -4
  3. package/dist/cjs/components/DashboardStickyToolbar/DashboardStickyToolbar.js +36 -7
  4. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +55 -80
  5. package/dist/cjs/components/Datasources/DatasourceEditor.js +1 -0
  6. package/dist/cjs/components/Datasources/EditDatasourcesButton.js +1 -4
  7. package/dist/cjs/components/EditJsonButton/EditJsonButton.js +5 -3
  8. package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +12 -7
  9. package/dist/cjs/components/Variables/EditVariablesButton.js +1 -4
  10. package/dist/cjs/components/Variables/TemplateVariable.js +25 -17
  11. package/dist/cjs/components/Variables/VariableList.js +4 -6
  12. package/dist/cjs/constants/index.js +1 -0
  13. package/dist/cjs/constants/styles.js +42 -0
  14. package/dist/cjs/constants/user-interface-text.js +1 -0
  15. package/dist/cjs/views/ViewDashboard/DashboardApp.js +2 -1
  16. package/dist/components/AddGroupButton/AddGroupButton.d.ts.map +1 -1
  17. package/dist/components/AddGroupButton/AddGroupButton.js +2 -1
  18. package/dist/components/AddGroupButton/AddGroupButton.js.map +1 -1
  19. package/dist/components/AddPanelButton/AddPanelButton.js +2 -5
  20. package/dist/components/AddPanelButton/AddPanelButton.js.map +1 -1
  21. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts.map +1 -1
  22. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +37 -8
  23. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
  24. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  25. package/dist/components/DashboardToolbar/DashboardToolbar.js +55 -80
  26. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  27. package/dist/components/Datasources/DatasourceEditor.d.ts.map +1 -1
  28. package/dist/components/Datasources/DatasourceEditor.js +1 -0
  29. package/dist/components/Datasources/DatasourceEditor.js.map +1 -1
  30. package/dist/components/Datasources/EditDatasourcesButton.js +2 -5
  31. package/dist/components/Datasources/EditDatasourcesButton.js.map +1 -1
  32. package/dist/components/EditJsonButton/EditJsonButton.d.ts +4 -1
  33. package/dist/components/EditJsonButton/EditJsonButton.d.ts.map +1 -1
  34. package/dist/components/EditJsonButton/EditJsonButton.js +5 -3
  35. package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -1
  36. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts +1 -0
  37. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts.map +1 -1
  38. package/dist/components/EditJsonDialog/EditJsonDialog.js +12 -7
  39. package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
  40. package/dist/components/Variables/EditVariablesButton.js +2 -5
  41. package/dist/components/Variables/EditVariablesButton.js.map +1 -1
  42. package/dist/components/Variables/TemplateVariable.d.ts.map +1 -1
  43. package/dist/components/Variables/TemplateVariable.js +25 -17
  44. package/dist/components/Variables/TemplateVariable.js.map +1 -1
  45. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  46. package/dist/components/Variables/VariableList.js +4 -6
  47. package/dist/components/Variables/VariableList.js.map +1 -1
  48. package/dist/constants/index.d.ts +1 -0
  49. package/dist/constants/index.d.ts.map +1 -1
  50. package/dist/constants/index.js +1 -0
  51. package/dist/constants/index.js.map +1 -1
  52. package/dist/constants/styles.d.ts +5 -0
  53. package/dist/constants/styles.d.ts.map +1 -0
  54. package/dist/constants/styles.js +23 -0
  55. package/dist/constants/styles.js.map +1 -0
  56. package/dist/constants/user-interface-text.d.ts +1 -0
  57. package/dist/constants/user-interface-text.d.ts.map +1 -1
  58. package/dist/constants/user-interface-text.js +1 -0
  59. package/dist/constants/user-interface-text.js.map +1 -1
  60. package/dist/views/ViewDashboard/DashboardApp.js +2 -1
  61. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  62. package/package.json +6 -6
@@ -39,6 +39,7 @@ const AddGroupButton = ()=>{
39
39
  startIcon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_PlusBoxOutline.default, {}),
40
40
  onClick: openAddPanelGroup,
41
41
  "aria-label": _constants.TOOLTIP_TEXT.addGroup,
42
+ sx: _constants.editButtonStyle,
42
43
  children: "Panel Group"
43
44
  })
44
45
  });
@@ -42,10 +42,7 @@ const AddPanelButton = ({ variant ='text' , color ='primary' , label ='Panel' ,
42
42
  variant: variant,
43
43
  color: color,
44
44
  fullWidth: fullWidth,
45
- sx: {
46
- whiteSpace: 'nowrap',
47
- minWidth: 'auto'
48
- },
45
+ sx: _constants.editButtonStyle,
49
46
  children: label
50
47
  })
51
48
  });
@@ -38,6 +38,7 @@ function DashboardStickyToolbar(props) {
38
38
  disableHysteresis: true
39
39
  });
40
40
  const isSticky = scrollTrigger && props.initialVariableIsSticky && isPin;
41
+ const isBiggerThanMd = (0, _material.useMediaQuery)((0, _material.useTheme)().breakpoints.up('md'));
41
42
  return(// marginBottom={-1} counteracts the marginBottom={1} on every variable input.
42
43
  // The margin on the inputs is for spacing between inputs, but is not meant to add space to bottom of the container.
43
44
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
@@ -54,24 +55,52 @@ function DashboardStickyToolbar(props) {
54
55
  children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
55
56
  display: "flex",
56
57
  justifyContent: "space-between",
58
+ sx: {
59
+ flexDirection: isBiggerThanMd ? 'row' : 'column'
60
+ },
57
61
  children: [
58
62
  /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
59
63
  display: "flex",
60
- flexWrap: "wrap",
61
- alignItems: "start",
62
- mt: isSticky ? 1.5 : 0,
63
- ml: isSticky ? 2 : 0,
64
+ flexWrap: !isSticky && isBiggerThanMd ? 'wrap' : 'nowrap',
65
+ maxWidth: isSticky || !isBiggerThanMd ? '100vw' : '100%',
66
+ maxHeight: "150px" // Limit the vertical space used to ~3 rows of variables
67
+ ,
68
+ pt: 1,
69
+ pl: isSticky ? 1 : 0,
70
+ mt: isSticky && isBiggerThanMd ? 0.5 : 0,
71
+ ml: isSticky && isBiggerThanMd ? 0.5 : 0,
72
+ sx: {
73
+ overflowX: !isSticky && isBiggerThanMd ? 'hidden' : 'auto',
74
+ // Firefox:
75
+ scrollbarWidth: 'thin',
76
+ // Safari and Chrome:
77
+ '&::-webkit-scrollbar': {
78
+ height: '8px',
79
+ backgroundColor: (theme)=>theme.palette.grey['300']
80
+ },
81
+ '&::-webkit-scrollbar-thumb': {
82
+ background: (theme)=>theme.palette.grey['600']
83
+ }
84
+ },
85
+ gap: 1,
64
86
  children: [
65
87
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_Variables.TemplateVariableList, {}),
66
88
  props.initialVariableIsSticky && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
89
+ style: {
90
+ width: 'fit-content',
91
+ height: 'fit-content'
92
+ },
67
93
  onClick: ()=>setIsPin(!isPin),
68
94
  children: isPin ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_PinOutline.default, {}) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_PinOffOutline.default, {})
69
95
  })
70
96
  ]
71
97
  }),
72
- isSticky && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
73
- mt: 1.5,
74
- mr: 2,
98
+ isSticky && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
99
+ m: isBiggerThanMd ? 1.5 : 1,
100
+ mt: isBiggerThanMd ? 1.5 : 0,
101
+ ml: isBiggerThanMd ? 1.5 : 'auto',
102
+ direction: "row",
103
+ justifyContent: "end",
75
104
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_TimeRangeControls.TimeRangeControls, {})
76
105
  })
77
106
  ]
@@ -38,15 +38,14 @@ const DashboardToolbar = (props)=>{
38
38
  const { dashboardName , dashboardTitleComponent , initialVariableIsSticky , isReadonly , onEditButtonClick , onCancelButtonClick , onSave } = props;
39
39
  const { isEditMode } = (0, _context.useEditMode)();
40
40
  const isBiggerThanSm = (0, _material.useMediaQuery)((0, _material.useTheme)().breakpoints.up('sm'));
41
- const isBiggerThanLg = (0, _material.useMediaQuery)((0, _material.useTheme)().breakpoints.up('lg'));
41
+ const isBiggerThanMd = (0, _material.useMediaQuery)((0, _material.useTheme)().breakpoints.up('md'));
42
42
  const dashboardTitle = dashboardTitleComponent ? dashboardTitleComponent : /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
43
43
  variant: "h2",
44
44
  children: dashboardName
45
45
  });
46
46
  const testId = 'dashboard-toolbar';
47
47
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
48
- children: isEditMode ? /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
49
- spacing: 1,
48
+ children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
50
49
  "data-testid": testId,
51
50
  children: [
52
51
  /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
@@ -54,11 +53,11 @@ const DashboardToolbar = (props)=>{
54
53
  py: 1.5,
55
54
  display: "flex",
56
55
  sx: {
57
- backgroundColor: (theme)=>theme.palette.primary.main + '30'
56
+ backgroundColor: (theme)=>theme.palette.primary.main + (isEditMode ? '30' : '0')
58
57
  },
59
58
  children: [
60
59
  dashboardTitle,
61
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
60
+ isEditMode ? /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
62
61
  direction: "row",
63
62
  gap: 1,
64
63
  ml: "auto",
@@ -71,6 +70,18 @@ const DashboardToolbar = (props)=>{
71
70
  },
72
71
  children: "Dashboard managed via code only. Download JSON and commit changes to save."
73
72
  }),
73
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
74
+ direction: "row",
75
+ spacing: 0.5,
76
+ ml: 1,
77
+ whiteSpace: "nowrap",
78
+ children: [
79
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_Variables.EditVariablesButton, {}),
80
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_Datasources.EditDatasourcesButton, {}),
81
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_AddPanelButton.AddPanelButton, {}),
82
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_AddGroupButton.AddGroupButton, {})
83
+ ]
84
+ }),
74
85
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_SaveDashboardButton.SaveDashboardButton, {
75
86
  onSave: onSave,
76
87
  isDisabled: isReadonly
@@ -81,6 +92,15 @@ const DashboardToolbar = (props)=>{
81
92
  children: "Cancel"
82
93
  })
83
94
  ]
95
+ }) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
96
+ children: isBiggerThanSm && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
97
+ direction: "row",
98
+ gap: 1,
99
+ ml: "auto",
100
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_EditButton.EditButton, {
101
+ onClick: onEditButtonClick
102
+ })
103
+ })
84
104
  })
85
105
  ]
86
106
  }),
@@ -89,89 +109,44 @@ const DashboardToolbar = (props)=>{
89
109
  display: 'flex',
90
110
  width: '100%',
91
111
  alignItems: 'start',
92
- padding: (theme)=>theme.spacing(1, 2, 0, 2)
112
+ padding: (theme)=>theme.spacing(1, 2, 0, 2),
113
+ flexDirection: isBiggerThanMd ? 'row' : 'column',
114
+ flexWrap: 'nowrap',
115
+ gap: 1
93
116
  },
94
117
  children: [
95
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
96
- FallbackComponent: _components.ErrorAlert,
97
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_DashboardStickyToolbar.DashboardStickyToolbar, {
98
- initialVariableIsSticky: initialVariableIsSticky,
99
- sx: {
100
- backgroundColor: ({ palette })=>palette.background.default
101
- }
118
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
119
+ width: "100%",
120
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
121
+ FallbackComponent: _components.ErrorAlert,
122
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_DashboardStickyToolbar.DashboardStickyToolbar, {
123
+ initialVariableIsSticky: initialVariableIsSticky,
124
+ sx: {
125
+ backgroundColor: ({ palette })=>palette.background.default
126
+ }
127
+ })
102
128
  })
103
129
  }),
104
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
105
- ml: "auto",
130
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
106
131
  direction: "row",
107
- flexWrap: isBiggerThanLg ? 'nowrap' : 'wrap-reverse',
132
+ ml: "auto",
133
+ flexWrap: "wrap",
108
134
  justifyContent: "end",
109
- children: [
110
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
111
- direction: "row",
112
- spacing: 1,
113
- ml: 1,
114
- whiteSpace: "nowrap",
115
- children: [
116
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_Variables.EditVariablesButton, {}),
117
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_Datasources.EditDatasourcesButton, {}),
118
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_AddPanelButton.AddPanelButton, {}),
119
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_AddGroupButton.AddGroupButton, {})
120
- ]
121
- }),
122
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
123
- direction: "row",
124
- spacing: 1,
125
- ml: 1,
126
- children: [
127
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_TimeRangeControls.TimeRangeControls, {}),
128
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_DownloadButton.DownloadButton, {}),
129
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_EditJsonButton.EditJsonButton, {})
130
- ]
131
- })
132
- ]
133
- })
134
- ]
135
- })
136
- ]
137
- }) : /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
138
- gap: 1,
139
- mx: 2,
140
- mt: 1.5,
141
- "data-testid": testId,
142
- children: [
143
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
144
- sx: {
145
- display: 'flex',
146
- width: '100%'
147
- },
148
- children: [
149
- dashboardTitle,
150
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
151
- direction: "row",
152
- spacing: 1,
153
- marginLeft: "auto",
154
- children: [
155
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_TimeRangeControls.TimeRangeControls, {}),
156
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_DownloadButton.DownloadButton, {}),
157
- isBiggerThanSm && /*#__PURE__*/ (0, _jsxruntime.jsx)(_EditButton.EditButton, {
158
- onClick: onEditButtonClick
159
- })
160
- ]
135
+ children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
136
+ direction: "row",
137
+ spacing: 1,
138
+ mt: 1,
139
+ ml: 1,
140
+ children: [
141
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_TimeRangeControls.TimeRangeControls, {}),
142
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_DownloadButton.DownloadButton, {}),
143
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_EditJsonButton.EditJsonButton, {
144
+ isReadonly: !isEditMode
145
+ })
146
+ ]
147
+ })
161
148
  })
162
149
  ]
163
- }),
164
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
165
- mt: 1,
166
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
167
- FallbackComponent: _components.ErrorAlert,
168
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_DashboardStickyToolbar.DashboardStickyToolbar, {
169
- initialVariableIsSticky: initialVariableIsSticky,
170
- sx: {
171
- backgroundColor: ({ palette })=>palette.background.default
172
- }
173
- })
174
- })
175
150
  })
176
151
  ]
177
152
  })
@@ -91,6 +91,7 @@ function DatasourceEditor(props) {
91
91
  isDraft: true,
92
92
  onSave: (name, spec)=>{
93
93
  setDatasources((draft)=>{
94
+ delete draft[datasourceEdit.name]; // to tackle the case where datasource name has been changed
94
95
  draft[name] = spec;
95
96
  setDatasourceEdit(null);
96
97
  });
@@ -82,10 +82,7 @@ function EditDatasourcesButton() {
82
82
  "aria-label": _constants.TOOLTIP_TEXT.editDatasources,
83
83
  variant: "text",
84
84
  color: "primary",
85
- sx: {
86
- whiteSpace: 'nowrap',
87
- minWidth: 'auto'
88
- },
85
+ sx: _constants.editButtonStyle,
89
86
  children: "Datasources"
90
87
  })
91
88
  }),
@@ -31,12 +31,14 @@ function _interop_require_default(obj) {
31
31
  default: obj
32
32
  };
33
33
  }
34
- const EditJsonButton = ()=>{
34
+ const EditJsonButton = (props)=>{
35
+ const { isReadonly } = props;
35
36
  const { openEditJsonDialog } = (0, _context.useEditJsonDialog)();
37
+ const info = isReadonly ? _constants.TOOLTIP_TEXT.viewJson : _constants.TOOLTIP_TEXT.editJson;
36
38
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
37
- description: _constants.TOOLTIP_TEXT.editJson,
39
+ description: info,
38
40
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_ToolbarIconButton.ToolbarIconButton, {
39
- "aria-label": _constants.TOOLTIP_TEXT.editJson,
41
+ "aria-label": info,
40
42
  variant: "outlined",
41
43
  onClick: ()=>openEditJsonDialog(),
42
44
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_CodeBraces.default, {})
@@ -28,7 +28,7 @@ const _pluginsystem = require("@perses-dev/plugin-system");
28
28
  const _DashboardProvider = require("../../context/DashboardProvider");
29
29
  const _useDashboard = require("../../context/useDashboard");
30
30
  const EditJsonDialog = (props)=>{
31
- const { disableMetadataEdition } = props;
31
+ const { isReadonly , disableMetadataEdition } = props;
32
32
  const { editJsonDialog , closeEditJsonDialog } = (0, _DashboardProvider.useEditJsonDialog)();
33
33
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.Dialog, {
34
34
  open: !!(editJsonDialog === null || editJsonDialog === void 0 ? void 0 : editJsonDialog.isOpen),
@@ -36,18 +36,22 @@ const EditJsonDialog = (props)=>{
36
36
  fullWidth: true,
37
37
  maxWidth: "lg",
38
38
  children: [
39
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.Dialog.Header, {
39
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.Dialog.Header, {
40
40
  onClose: ()=>closeEditJsonDialog(),
41
- children: "Edit Dashboard JSON"
41
+ children: [
42
+ !isReadonly && 'Edit ',
43
+ " Dashboard JSON"
44
+ ]
42
45
  }),
43
46
  (editJsonDialog === null || editJsonDialog === void 0 ? void 0 : editJsonDialog.isOpen) && /*#__PURE__*/ (0, _jsxruntime.jsx)(EditJsonDialogForm, {
47
+ isReadonly: isReadonly,
44
48
  disableMetadataEdition: disableMetadataEdition
45
49
  })
46
50
  ]
47
51
  });
48
52
  };
49
53
  const EditJsonDialogForm = (props)=>{
50
- const { disableMetadataEdition } = props;
54
+ const { isReadonly , disableMetadataEdition } = props;
51
55
  const { closeEditJsonDialog } = (0, _DashboardProvider.useEditJsonDialog)();
52
56
  const { setTimeRange , setRefreshInterval } = (0, _pluginsystem.useTimeRange)();
53
57
  const { dashboard , setDashboard } = (0, _useDashboard.useDashboard)();
@@ -81,7 +85,7 @@ const EditJsonDialogForm = (props)=>{
81
85
  width: '100%'
82
86
  },
83
87
  children: [
84
- disableMetadataEdition && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Alert, {
88
+ disableMetadataEdition && !isReadonly && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Alert, {
85
89
  sx: {
86
90
  marginBottom: (theme)=>theme.spacing(1)
87
91
  },
@@ -94,12 +98,13 @@ const EditJsonDialogForm = (props)=>{
94
98
  minHeight: "300px",
95
99
  maxHeight: "70vh",
96
100
  value: draftDashboard,
97
- onChange: (value)=>completeDraftDashboard(value)
101
+ onChange: (value)=>completeDraftDashboard(value),
102
+ readOnly: isReadonly
98
103
  })
99
104
  })
100
105
  ]
101
106
  }),
102
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.Dialog.Actions, {
107
+ !isReadonly && /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.Dialog.Actions, {
103
108
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.Dialog.PrimaryButton, {
104
109
  onClick: handleApply,
105
110
  children: "Apply"
@@ -57,10 +57,7 @@ function EditVariablesButton({ variant ='text' , label ='Variables' , color ='pr
57
57
  variant: variant,
58
58
  color: color,
59
59
  fullWidth: fullWidth,
60
- sx: {
61
- whiteSpace: 'nowrap',
62
- minWidth: 'auto'
63
- },
60
+ sx: _constants.editButtonStyle,
64
61
  children: label
65
62
  })
66
63
  }),
@@ -34,6 +34,7 @@ const _material = require("@mui/material");
34
34
  const _core = require("@perses-dev/core");
35
35
  const _pluginsystem = require("@perses-dev/plugin-system");
36
36
  const _context = require("../../context");
37
+ const _constants = require("../../constants");
37
38
  function variableOptionToVariableValue(options) {
38
39
  if (options === null) {
39
40
  return null;
@@ -190,6 +191,18 @@ const StyledPopper = (props)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Poppe
190
191
  },
191
192
  placement: "bottom-start"
192
193
  });
194
+ const LETTER_HSIZE = 8; // approximation
195
+ const ARROW_OFFSET = 40; // right offset for list variables (= take into account the dropdown toggle size)
196
+ const getWidthPx = (inputValue, kind)=>{
197
+ const width = (inputValue.length + 1) * LETTER_HSIZE + (kind == 'list' ? ARROW_OFFSET : 0);
198
+ if (width < _constants.MIN_TEMPLATE_VARIABLE_WIDTH) {
199
+ return _constants.MIN_TEMPLATE_VARIABLE_WIDTH;
200
+ } else if (width > _constants.MAX_TEMPLATE_VARIABLE_WIDTH) {
201
+ return _constants.MAX_TEMPLATE_VARIABLE_WIDTH;
202
+ } else {
203
+ return width;
204
+ }
205
+ };
193
206
  function ListVariable({ name , source }) {
194
207
  var _definition_spec_display;
195
208
  const ctx = (0, _context.useTemplateVariable)(name, source);
@@ -198,6 +211,7 @@ function ListVariable({ name , source }) {
198
211
  const { setVariableValue , setVariableLoading , setVariableOptions } = (0, _context.useTemplateVariableActions)();
199
212
  const { selectedOptions , value , loading , options , viewOptions } = useListVariableState(definition === null || definition === void 0 ? void 0 : definition.spec, ctx.state, variablesOptionsQuery);
200
213
  const [inputValue, setInputValue] = (0, _react.useState)('');
214
+ const [inputWidth, setInputWidth] = (0, _react.useState)(_constants.MIN_TEMPLATE_VARIABLE_WIDTH);
201
215
  var _definition_spec_display_name;
202
216
  const title = (_definition_spec_display_name = (_definition_spec_display = definition === null || definition === void 0 ? void 0 : definition.spec.display) === null || _definition_spec_display === void 0 ? void 0 : _definition_spec_display.name) !== null && _definition_spec_display_name !== void 0 ? _definition_spec_display_name : name;
203
217
  const allowMultiple = (definition === null || definition === void 0 ? void 0 : definition.spec.allowMultiple) === true;
@@ -233,21 +247,6 @@ function ListVariable({ name , source }) {
233
247
  options,
234
248
  source
235
249
  ]);
236
- const LETTER_HSIZE = 8; // approximation
237
- const ARROW_OFFSET = 40;
238
- const MIN_INPUT_WIDTH = 120;
239
- const MAX_INPUT_WIDTH = 500;
240
- const [inputWidth, setInputWidth] = (0, _react.useState)(MIN_INPUT_WIDTH);
241
- const handleInputResize = (newInputValue)=>{
242
- const newInputValueSize = (newInputValue.length + 1) * LETTER_HSIZE + ARROW_OFFSET;
243
- if (newInputValueSize < MIN_INPUT_WIDTH) {
244
- setInputWidth(MIN_INPUT_WIDTH);
245
- } else if (newInputValueSize > MAX_INPUT_WIDTH) {
246
- setInputWidth(MAX_INPUT_WIDTH);
247
- } else {
248
- setInputWidth(newInputValueSize);
249
- }
250
- };
251
250
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
252
251
  children: [
253
252
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Autocomplete, {
@@ -292,7 +291,7 @@ function ListVariable({ name , source }) {
292
291
  onInputChange: (_, newInputValue)=>{
293
292
  setInputValue(newInputValue);
294
293
  if (!allowMultiple) {
295
- handleInputResize(newInputValue);
294
+ setInputWidth(getWidthPx(newInputValue, 'list'));
296
295
  }
297
296
  },
298
297
  options: viewOptions
@@ -308,6 +307,7 @@ function TextVariable({ name , source }) {
308
307
  const definition = ctx.definition;
309
308
  var _state_value;
310
309
  const [tempValue, setTempValue] = (0, _react.useState)((_state_value = state === null || state === void 0 ? void 0 : state.value) !== null && _state_value !== void 0 ? _state_value : '');
310
+ const [inputWidth, setInputWidth] = (0, _react.useState)(getWidthPx(tempValue, 'text'));
311
311
  const { setVariableValue } = (0, _context.useTemplateVariableActions)();
312
312
  (0, _react.useEffect)(()=>{
313
313
  var _state_value;
@@ -319,7 +319,11 @@ function TextVariable({ name , source }) {
319
319
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
320
320
  title: tempValue,
321
321
  value: tempValue,
322
- onChange: (e)=>setTempValue(e.target.value),
322
+ //onChange={(e) => setTempValue(e.target.value)}
323
+ onChange: (e)=>{
324
+ setTempValue(e.target.value);
325
+ setInputWidth(getWidthPx(e.target.value, 'text'));
326
+ },
323
327
  onBlur: ()=>setVariableValue(name, tempValue, source),
324
328
  placeholder: name,
325
329
  label: (_definition_spec_display_name = (_definition_spec_display = definition === null || definition === void 0 ? void 0 : definition.spec.display) === null || _definition_spec_display === void 0 ? void 0 : _definition_spec_display.name) !== null && _definition_spec_display_name !== void 0 ? _definition_spec_display_name : name,
@@ -327,8 +331,12 @@ function TextVariable({ name , source }) {
327
331
  readOnly: (_definition_spec_constant = definition === null || definition === void 0 ? void 0 : definition.spec.constant) !== null && _definition_spec_constant !== void 0 ? _definition_spec_constant : false
328
332
  },
329
333
  sx: {
334
+ width: `${inputWidth}px`,
330
335
  '& .MuiInputBase-root': {
331
336
  minHeight: '38px'
337
+ },
338
+ '& .MuiInputBase-input': {
339
+ textOverflow: 'ellipsis'
332
340
  }
333
341
  }
334
342
  });
@@ -31,9 +31,8 @@ _export(exports, {
31
31
  const _jsxruntime = require("react/jsx-runtime");
32
32
  const _material = require("@mui/material");
33
33
  const _context = require("../../context");
34
+ const _constants = require("../../constants");
34
35
  const _TemplateVariable = require("./TemplateVariable");
35
- const VARIABLE_INPUT_MIN_WIDTH = '120px';
36
- const VARIABLE_INPUT_MAX_WIDTH = '500px';
37
36
  function TemplateVariableList() {
38
37
  const variableDefinitions = (0, _context.useTemplateVariableDefinitions)();
39
38
  const externalVariableDefinitions = (0, _context.useTemplateExternalVariableDefinitions)();
@@ -56,10 +55,9 @@ function TemplateVariableListItem({ spec , source }) {
56
55
  var _ref, _ref1;
57
56
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
58
57
  display: ((_ctx_state = ctx.state) === null || _ctx_state === void 0 ? void 0 : _ctx_state.overridden) || ((_spec_display = spec.display) === null || _spec_display === void 0 ? void 0 : _spec_display.hidden) ? 'none' : undefined,
59
- minWidth: VARIABLE_INPUT_MIN_WIDTH,
60
- maxWidth: VARIABLE_INPUT_MAX_WIDTH,
61
- marginBottom: 1,
62
- marginRight: 1,
58
+ minWidth: `${_constants.MIN_TEMPLATE_VARIABLE_WIDTH}px`,
59
+ maxWidth: `${_constants.MAX_TEMPLATE_VARIABLE_WIDTH}px`,
60
+ flexShrink: 0,
63
61
  "data-testid": 'template-variable-' + spec.name,
64
62
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_TemplateVariable.TemplateVariable, {
65
63
  name: spec.name,
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
17
  _export_star(require("./grid-layout-config"), exports);
18
+ _export_star(require("./styles"), exports);
18
19
  _export_star(require("./user-interface-text"), exports);
19
20
  function _export_star(from, to) {
20
21
  Object.keys(from).forEach(function(k) {
@@ -0,0 +1,42 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ editButtonStyle: function() {
25
+ return editButtonStyle;
26
+ },
27
+ MIN_TEMPLATE_VARIABLE_WIDTH: function() {
28
+ return MIN_TEMPLATE_VARIABLE_WIDTH;
29
+ },
30
+ MAX_TEMPLATE_VARIABLE_WIDTH: function() {
31
+ return MAX_TEMPLATE_VARIABLE_WIDTH;
32
+ }
33
+ });
34
+ const editButtonStyle = {
35
+ whiteSpace: 'nowrap',
36
+ minWidth: 'auto',
37
+ '& .MuiButton-startIcon': {
38
+ marginRight: 0.5
39
+ }
40
+ };
41
+ const MIN_TEMPLATE_VARIABLE_WIDTH = 120;
42
+ const MAX_TEMPLATE_VARIABLE_WIDTH = 500;
@@ -38,6 +38,7 @@ const TOOLTIP_TEXT = {
38
38
  editVariables: 'Edit variables',
39
39
  refreshDashboard: 'Refresh dashboard',
40
40
  refreshDashboardInterval: 'Auto refresh interval',
41
+ viewJson: 'View JSON',
41
42
  // Group buttons
42
43
  addPanelToGroup: 'Add panel to group',
43
44
  deleteGroup: 'Delete group',
@@ -30,7 +30,7 @@ const _context = require("../../context");
30
30
  const DashboardApp = (props)=>{
31
31
  const { dashboardResource , dashboardTitleComponent , emptyDashboardProps , onSave , onDiscard , initialVariableIsSticky , isReadonly , isCreating } = props;
32
32
  const chartsTheme = (0, _components.useChartsTheme)();
33
- const { setEditMode } = (0, _context.useEditMode)();
33
+ const { isEditMode , setEditMode } = (0, _context.useEditMode)();
34
34
  const { dashboard , setDashboard } = (0, _context.useDashboard)();
35
35
  const [originalDashboard, setOriginalDashboard] = (0, _react.useState)(undefined);
36
36
  const { setSavedDatasources } = (0, _pluginsystem.useDatasourceStore)();
@@ -110,6 +110,7 @@ const DashboardApp = (props)=>{
110
110
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_components1.DeletePanelDialog, {}),
111
111
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_components1.DashboardDiscardChangesConfirmationDialog, {}),
112
112
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_components1.EditJsonDialog, {
113
+ isReadonly: !isEditMode,
113
114
  disableMetadataEdition: !isCreating
114
115
  }),
115
116
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_components1.SaveChangesConfirmationDialog, {})
@@ -1 +1 @@
1
- {"version":3,"file":"AddGroupButton.d.ts","sourceRoot":"","sources":["../../../src/components/AddGroupButton/AddGroupButton.tsx"],"names":[],"mappings":";AAmBA,eAAO,MAAM,cAAc,mBAU1B,CAAC"}
1
+ {"version":3,"file":"AddGroupButton.d.ts","sourceRoot":"","sources":["../../../src/components/AddGroupButton/AddGroupButton.tsx"],"names":[],"mappings":";AAmBA,eAAO,MAAM,cAAc,mBAe1B,CAAC"}
@@ -14,7 +14,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { Button } from '@mui/material';
15
15
  import AddGroupIcon from 'mdi-material-ui/PlusBoxOutline';
16
16
  import { InfoTooltip } from '@perses-dev/components';
17
- import { TOOLTIP_TEXT } from '../../constants';
17
+ import { TOOLTIP_TEXT, editButtonStyle } from '../../constants';
18
18
  import { useDashboardActions } from '../../context';
19
19
  export const AddGroupButton = ()=>{
20
20
  const { openAddPanelGroup } = useDashboardActions();
@@ -24,6 +24,7 @@ export const AddGroupButton = ()=>{
24
24
  startIcon: /*#__PURE__*/ _jsx(AddGroupIcon, {}),
25
25
  onClick: openAddPanelGroup,
26
26
  "aria-label": TOOLTIP_TEXT.addGroup,
27
+ sx: editButtonStyle,
27
28
  children: "Panel Group"
28
29
  })
29
30
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/AddGroupButton/AddGroupButton.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 { Button } from '@mui/material';\nimport AddGroupIcon from 'mdi-material-ui/PlusBoxOutline';\nimport { InfoTooltip } from '@perses-dev/components';\nimport { TOOLTIP_TEXT } from '../../constants';\nimport { useDashboardActions } from '../../context';\n\nexport const AddGroupButton = () => {\n const { openAddPanelGroup } = useDashboardActions();\n\n return (\n <InfoTooltip description={TOOLTIP_TEXT.addGroup}>\n <Button startIcon={<AddGroupIcon />} onClick={openAddPanelGroup} aria-label={TOOLTIP_TEXT.addGroup}>\n Panel Group\n </Button>\n </InfoTooltip>\n );\n};\n"],"names":["Button","AddGroupIcon","InfoTooltip","TOOLTIP_TEXT","useDashboardActions","AddGroupButton","openAddPanelGroup","description","addGroup","startIcon","onClick","aria-label"],"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,SAASA,MAAM,QAAQ,gBAAgB;AACvC,OAAOC,kBAAkB,iCAAiC;AAC1D,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,mBAAmB,QAAQ,gBAAgB;AAEpD,OAAO,MAAMC,iBAAiB;IAC5B,MAAM,EAAEC,kBAAiB,EAAE,GAAGF;IAE9B,qBACE,KAACF;QAAYK,aAAaJ,aAAaK;kBACrC,cAAA,KAACR;YAAOS,yBAAW,KAACR;YAAiBS,SAASJ;YAAmBK,cAAYR,aAAaK;sBAAU;;;AAK1G,EAAE"}
1
+ {"version":3,"sources":["../../../src/components/AddGroupButton/AddGroupButton.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 { Button } from '@mui/material';\nimport AddGroupIcon from 'mdi-material-ui/PlusBoxOutline';\nimport { InfoTooltip } from '@perses-dev/components';\nimport { TOOLTIP_TEXT, editButtonStyle } from '../../constants';\nimport { useDashboardActions } from '../../context';\n\nexport const AddGroupButton = () => {\n const { openAddPanelGroup } = useDashboardActions();\n\n return (\n <InfoTooltip description={TOOLTIP_TEXT.addGroup}>\n <Button\n startIcon={<AddGroupIcon />}\n onClick={openAddPanelGroup}\n aria-label={TOOLTIP_TEXT.addGroup}\n sx={editButtonStyle}\n >\n Panel Group\n </Button>\n </InfoTooltip>\n );\n};\n"],"names":["Button","AddGroupIcon","InfoTooltip","TOOLTIP_TEXT","editButtonStyle","useDashboardActions","AddGroupButton","openAddPanelGroup","description","addGroup","startIcon","onClick","aria-label","sx"],"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,SAASA,MAAM,QAAQ,gBAAgB;AACvC,OAAOC,kBAAkB,iCAAiC;AAC1D,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,YAAY,EAAEC,eAAe,QAAQ,kBAAkB;AAChE,SAASC,mBAAmB,QAAQ,gBAAgB;AAEpD,OAAO,MAAMC,iBAAiB;IAC5B,MAAM,EAAEC,kBAAiB,EAAE,GAAGF;IAE9B,qBACE,KAACH;QAAYM,aAAaL,aAAaM;kBACrC,cAAA,KAACT;YACCU,yBAAW,KAACT;YACZU,SAASJ;YACTK,cAAYT,aAAaM;YACzBI,IAAIT;sBACL;;;AAKP,EAAE"}