@perses-dev/dashboards 0.24.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/dist/cjs/components/AddPanelButton/AddPanelButton.js +9 -2
  2. package/dist/cjs/components/Dashboard/Dashboard.js +23 -6
  3. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +8 -17
  4. package/dist/cjs/components/EditButton/EditButton.js +41 -0
  5. package/dist/cjs/components/EditButton/index.js +28 -0
  6. package/dist/cjs/components/EditJsonButton/EditJsonButton.js +42 -0
  7. package/dist/cjs/components/EditJsonButton/index.js +28 -0
  8. package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +86 -0
  9. package/dist/cjs/components/EditJsonDialog/index.js +28 -0
  10. package/dist/cjs/components/EmptyDashboard/EmptyDashboard.js +127 -0
  11. package/dist/cjs/components/EmptyDashboard/index.js +28 -0
  12. package/dist/cjs/components/QuerySummaryTable/QuerySummaryTable.js +185 -0
  13. package/dist/cjs/components/QuerySummaryTable/index.js +28 -0
  14. package/dist/cjs/components/ToolbarIconButton/ToolbarIconButton.js +6 -3
  15. package/dist/cjs/components/Variables/EditVariablesButton.js +9 -2
  16. package/dist/cjs/components/index.js +4 -0
  17. package/dist/cjs/constants/user-interface-text.js +1 -0
  18. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +12 -6
  19. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +10 -1
  20. package/dist/cjs/context/DashboardProvider/edit-json-dialog-slice.js +36 -0
  21. package/dist/cjs/context/DatasourceStoreProvider.js +9 -3
  22. package/dist/cjs/stories/decorators/WithDashboard.js +60 -0
  23. package/dist/cjs/stories/decorators/WithPluginRegistry.js +91 -0
  24. package/dist/cjs/stories/decorators/WithQueryClient.js +29 -0
  25. package/dist/cjs/stories/decorators/WithQueryParams.js +29 -0
  26. package/dist/cjs/stories/decorators/WithTemplateVariables.js +27 -0
  27. package/dist/cjs/stories/decorators/index.js +32 -0
  28. package/dist/cjs/views/ViewDashboard/DashboardApp.js +11 -4
  29. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +2 -1
  30. package/dist/components/AddPanelButton/AddPanelButton.d.ts +16 -1
  31. package/dist/components/AddPanelButton/AddPanelButton.d.ts.map +1 -1
  32. package/dist/components/AddPanelButton/AddPanelButton.js +9 -2
  33. package/dist/components/AddPanelButton/AddPanelButton.js.map +1 -1
  34. package/dist/components/Dashboard/Dashboard.d.ts +10 -2
  35. package/dist/components/Dashboard/Dashboard.d.ts.map +1 -1
  36. package/dist/components/Dashboard/Dashboard.js +24 -7
  37. package/dist/components/Dashboard/Dashboard.js.map +1 -1
  38. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  39. package/dist/components/DashboardToolbar/DashboardToolbar.js +8 -12
  40. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  41. package/dist/components/EditButton/EditButton.d.ts +13 -0
  42. package/dist/components/EditButton/EditButton.d.ts.map +1 -0
  43. package/dist/components/EditButton/EditButton.js +30 -0
  44. package/dist/components/EditButton/EditButton.js.map +1 -0
  45. package/dist/components/EditButton/index.d.ts +2 -0
  46. package/dist/components/EditButton/index.d.ts.map +1 -0
  47. package/dist/components/EditButton/index.js +15 -0
  48. package/dist/components/EditButton/index.js.map +1 -0
  49. package/dist/components/EditJsonButton/EditJsonButton.d.ts +3 -0
  50. package/dist/components/EditJsonButton/EditJsonButton.d.ts.map +1 -0
  51. package/dist/components/EditJsonButton/EditJsonButton.js +31 -0
  52. package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -0
  53. package/dist/components/EditJsonButton/index.d.ts +2 -0
  54. package/dist/components/EditJsonButton/index.d.ts.map +1 -0
  55. package/dist/components/EditJsonButton/index.js +15 -0
  56. package/dist/components/EditJsonButton/index.js.map +1 -0
  57. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts +3 -0
  58. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts.map +1 -0
  59. package/dist/components/EditJsonDialog/EditJsonDialog.js +80 -0
  60. package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -0
  61. package/dist/components/EditJsonDialog/index.d.ts +2 -0
  62. package/dist/components/EditJsonDialog/index.d.ts.map +1 -0
  63. package/dist/components/EditJsonDialog/index.js +15 -0
  64. package/dist/components/EditJsonDialog/index.js.map +1 -0
  65. package/dist/components/EmptyDashboard/EmptyDashboard.d.ts +33 -0
  66. package/dist/components/EmptyDashboard/EmptyDashboard.d.ts.map +1 -0
  67. package/dist/components/EmptyDashboard/EmptyDashboard.js +123 -0
  68. package/dist/components/EmptyDashboard/EmptyDashboard.js.map +1 -0
  69. package/dist/components/EmptyDashboard/index.d.ts +2 -0
  70. package/dist/components/EmptyDashboard/index.d.ts.map +1 -0
  71. package/dist/components/EmptyDashboard/index.js +15 -0
  72. package/dist/components/EmptyDashboard/index.js.map +1 -0
  73. package/dist/components/QuerySummaryTable/QuerySummaryTable.d.ts +11 -0
  74. package/dist/components/QuerySummaryTable/QuerySummaryTable.d.ts.map +1 -0
  75. package/dist/components/QuerySummaryTable/QuerySummaryTable.js +179 -0
  76. package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -0
  77. package/dist/components/QuerySummaryTable/index.d.ts +2 -0
  78. package/dist/components/QuerySummaryTable/index.d.ts.map +1 -0
  79. package/dist/components/QuerySummaryTable/index.js +15 -0
  80. package/dist/components/QuerySummaryTable/index.js.map +1 -0
  81. package/dist/components/ToolbarIconButton/ToolbarIconButton.d.ts +1 -1
  82. package/dist/components/ToolbarIconButton/ToolbarIconButton.d.ts.map +1 -1
  83. package/dist/components/ToolbarIconButton/ToolbarIconButton.js +6 -3
  84. package/dist/components/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
  85. package/dist/components/Variables/EditVariablesButton.d.ts +16 -1
  86. package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
  87. package/dist/components/Variables/EditVariablesButton.js +9 -2
  88. package/dist/components/Variables/EditVariablesButton.js.map +1 -1
  89. package/dist/components/index.d.ts +4 -0
  90. package/dist/components/index.d.ts.map +1 -1
  91. package/dist/components/index.js +4 -0
  92. package/dist/components/index.js.map +1 -1
  93. package/dist/constants/user-interface-text.d.ts +1 -0
  94. package/dist/constants/user-interface-text.d.ts.map +1 -1
  95. package/dist/constants/user-interface-text.js +1 -0
  96. package/dist/constants/user-interface-text.js.map +1 -1
  97. package/dist/context/DashboardProvider/DashboardProvider.d.ts +2 -1
  98. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  99. package/dist/context/DashboardProvider/DashboardProvider.js +12 -6
  100. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  101. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +8 -0
  102. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  103. package/dist/context/DashboardProvider/dashboard-provider-api.js +10 -0
  104. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  105. package/dist/context/DashboardProvider/edit-json-dialog-slice.d.ts +12 -0
  106. package/dist/context/DashboardProvider/edit-json-dialog-slice.d.ts.map +1 -0
  107. package/dist/context/DashboardProvider/edit-json-dialog-slice.js +30 -0
  108. package/dist/context/DashboardProvider/edit-json-dialog-slice.js.map +1 -0
  109. package/dist/context/DatasourceStoreProvider.d.ts +2 -0
  110. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
  111. package/dist/context/DatasourceStoreProvider.js +9 -3
  112. package/dist/context/DatasourceStoreProvider.js.map +1 -1
  113. package/dist/stories/decorators/WithDashboard.js +48 -0
  114. package/dist/stories/decorators/WithDashboard.js.map +1 -0
  115. package/dist/stories/decorators/WithPluginRegistry.js +46 -0
  116. package/dist/stories/decorators/WithPluginRegistry.js.map +1 -0
  117. package/dist/stories/decorators/WithQueryClient.js +23 -0
  118. package/dist/stories/decorators/WithQueryClient.js.map +1 -0
  119. package/dist/stories/decorators/WithQueryParams.js +23 -0
  120. package/dist/stories/decorators/WithQueryParams.js.map +1 -0
  121. package/dist/stories/decorators/WithTemplateVariables.js +21 -0
  122. package/dist/stories/decorators/WithTemplateVariables.js.map +1 -0
  123. package/dist/stories/decorators/index.js +19 -0
  124. package/dist/stories/decorators/index.js.map +1 -0
  125. package/dist/views/ViewDashboard/DashboardApp.d.ts +2 -0
  126. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  127. package/dist/views/ViewDashboard/DashboardApp.js +12 -5
  128. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  129. package/dist/views/ViewDashboard/ViewDashboard.d.ts +2 -8
  130. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  131. package/dist/views/ViewDashboard/ViewDashboard.js +2 -1
  132. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  133. package/package.json +4 -4
@@ -0,0 +1,27 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "WithTemplateVariables", {
18
+ enumerable: true,
19
+ get: ()=>WithTemplateVariables
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _dashboards = require("@perses-dev/dashboards");
23
+ const WithTemplateVariables = (Story)=>{
24
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_dashboards.TemplateVariableProvider, {
25
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
26
+ });
27
+ };
@@ -0,0 +1,32 @@
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
+ _exportStar(require("./WithDashboard"), exports);
18
+ _exportStar(require("./WithPluginRegistry"), exports);
19
+ _exportStar(require("./WithQueryClient"), exports);
20
+ _exportStar(require("./WithQueryParams"), exports);
21
+ _exportStar(require("./WithTemplateVariables"), exports);
22
+ function _exportStar(from, to) {
23
+ Object.keys(from).forEach(function(k) {
24
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
25
+ enumerable: true,
26
+ get: function() {
27
+ return from[k];
28
+ }
29
+ });
30
+ });
31
+ return from;
32
+ }
@@ -25,7 +25,7 @@ const _components = require("@perses-dev/components");
25
25
  const _components1 = require("../../components");
26
26
  const _context = require("../../context");
27
27
  const DashboardApp = (props)=>{
28
- const { dashboardResource , dashboardTitleComponent , onSave , onDiscard , initialVariableIsSticky , isReadonly } = props;
28
+ const { dashboardResource , dashboardTitleComponent , emptyDashboardProps , onSave , onDiscard , initialVariableIsSticky , isReadonly , } = props;
29
29
  const { setEditMode } = (0, _context.useEditMode)();
30
30
  const { dashboard , setDashboard } = (0, _context.useDashboard)();
31
31
  const [originalDashboard, setOriginalDashboard] = (0, _react.useState)(undefined);
@@ -80,18 +80,25 @@ const DashboardApp = (props)=>{
80
80
  }),
81
81
  /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
82
82
  sx: {
83
- padding: (theme)=>theme.spacing(2)
83
+ padding: (theme)=>theme.spacing(2),
84
+ height: '100%'
84
85
  },
85
86
  children: [
86
87
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
87
88
  FallbackComponent: _components.ErrorAlert,
88
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.Dashboard, {})
89
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.Dashboard, {
90
+ emptyDashboardProps: {
91
+ onEditButtonClick,
92
+ ...emptyDashboardProps
93
+ }
94
+ })
89
95
  }),
90
96
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.PanelDrawer, {}),
91
97
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.PanelGroupDialog, {}),
92
98
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.DeletePanelGroupDialog, {}),
93
99
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.DeletePanelDialog, {}),
94
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.DiscardChangesConfirmationDialog, {})
100
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.DiscardChangesConfirmationDialog, {}),
101
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.EditJsonDialog, {})
95
102
  ]
96
103
  })
97
104
  ]
@@ -25,7 +25,7 @@ const _pluginSystem = require("@perses-dev/plugin-system");
25
25
  const _context = require("../../context");
26
26
  const _dashboardApp = require("./DashboardApp");
27
27
  function ViewDashboard(props) {
28
- const { dashboardResource , datasourceApi , dashboardTitleComponent , onSave , onDiscard , initialVariableIsSticky , isReadonly , isEditing , sx , ...others } = props;
28
+ const { dashboardResource , datasourceApi , dashboardTitleComponent , emptyDashboardProps , onSave , onDiscard , initialVariableIsSticky , isReadonly , isEditing , sx , ...others } = props;
29
29
  const { spec } = dashboardResource;
30
30
  var _duration;
31
31
  const dashboardDuration = (_duration = spec.duration) !== null && _duration !== void 0 ? _duration : '1h';
@@ -57,6 +57,7 @@ function ViewDashboard(props) {
57
57
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_dashboardApp.DashboardApp, {
58
58
  dashboardResource: dashboardResource,
59
59
  dashboardTitleComponent: dashboardTitleComponent,
60
+ emptyDashboardProps: emptyDashboardProps,
60
61
  onSave: onSave,
61
62
  onDiscard: onDiscard,
62
63
  initialVariableIsSticky: initialVariableIsSticky,
@@ -1,3 +1,18 @@
1
1
  /// <reference types="react" />
2
- export declare const AddPanelButton: () => JSX.Element;
2
+ import { ButtonProps } from '@mui/material';
3
+ export interface AddPanelButtonProps extends Pick<ButtonProps, 'fullWidth'> {
4
+ /**
5
+ * The variant to use to display the button.
6
+ */
7
+ variant?: 'text' | 'outlined';
8
+ /**
9
+ * The color to use to display the button.
10
+ */
11
+ color?: 'primary' | 'secondary';
12
+ /**
13
+ * The label used inside the button.
14
+ */
15
+ label?: string;
16
+ }
17
+ export declare const AddPanelButton: ({ variant, color, label, fullWidth, }: AddPanelButtonProps) => JSX.Element;
3
18
  //# sourceMappingURL=AddPanelButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AddPanelButton.d.ts","sourceRoot":"","sources":["../../../src/components/AddPanelButton/AddPanelButton.tsx"],"names":[],"mappings":";AAmBA,eAAO,MAAM,cAAc,mBAU1B,CAAC"}
1
+ {"version":3,"file":"AddPanelButton.d.ts","sourceRoot":"","sources":["../../../src/components/AddPanelButton/AddPanelButton.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAU,WAAW,EAAE,MAAM,eAAe,CAAC;AAMpD,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC;IACzE;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAE9B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IAEhC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,cAAc,0CAKxB,mBAAmB,gBAkBrB,CAAC"}
@@ -16,7 +16,7 @@ import AddPanelIcon from 'mdi-material-ui/ChartBoxPlusOutline';
16
16
  import { InfoTooltip } from '@perses-dev/components';
17
17
  import { TOOLTIP_TEXT } from '../../constants';
18
18
  import { useDashboardActions } from '../../context';
19
- export const AddPanelButton = ()=>{
19
+ export const AddPanelButton = ({ variant ='text' , color ='primary' , label ='Panel' , fullWidth })=>{
20
20
  const { openAddPanel } = useDashboardActions();
21
21
  return /*#__PURE__*/ _jsx(InfoTooltip, {
22
22
  description: TOOLTIP_TEXT.addPanel,
@@ -24,7 +24,14 @@ export const AddPanelButton = ()=>{
24
24
  startIcon: /*#__PURE__*/ _jsx(AddPanelIcon, {}),
25
25
  onClick: openAddPanel,
26
26
  "aria-label": TOOLTIP_TEXT.addPanel,
27
- children: "Panel"
27
+ variant: variant,
28
+ color: color,
29
+ fullWidth: fullWidth,
30
+ sx: {
31
+ whiteSpace: 'nowrap',
32
+ minWidth: 'auto'
33
+ },
34
+ children: label
28
35
  })
29
36
  });
30
37
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/AddPanelButton/AddPanelButton.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 AddPanelIcon from 'mdi-material-ui/ChartBoxPlusOutline';\nimport { InfoTooltip } from '@perses-dev/components';\nimport { TOOLTIP_TEXT } from '../../constants';\nimport { useDashboardActions } from '../../context';\n\nexport const AddPanelButton = () => {\n const { openAddPanel } = useDashboardActions();\n\n return (\n <InfoTooltip description={TOOLTIP_TEXT.addPanel}>\n <Button startIcon={<AddPanelIcon />} onClick={openAddPanel} aria-label={TOOLTIP_TEXT.addPanel}>\n Panel\n </Button>\n </InfoTooltip>\n );\n};\n"],"names":["Button","AddPanelIcon","InfoTooltip","TOOLTIP_TEXT","useDashboardActions","AddPanelButton","openAddPanel","description","addPanel","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;AAAA,SAASA,MAAM,QAAQ,eAAe,CAAC;AACvC,OAAOC,YAAY,MAAM,qCAAqC,CAAC;AAC/D,SAASC,WAAW,QAAQ,wBAAwB,CAAC;AACrD,SAASC,YAAY,QAAQ,iBAAiB,CAAC;AAC/C,SAASC,mBAAmB,QAAQ,eAAe,CAAC;AAEpD,OAAO,MAAMC,cAAc,GAAG,IAAM;IAClC,MAAM,EAAEC,YAAY,CAAA,EAAE,GAAGF,mBAAmB,EAAE,AAAC;IAE/C,qBACE,KAACF,WAAW;QAACK,WAAW,EAAEJ,YAAY,CAACK,QAAQ;kBAC7C,cAAA,KAACR,MAAM;YAACS,SAAS,gBAAE,KAACR,YAAY,KAAG;YAAES,OAAO,EAAEJ,YAAY;YAAEK,YAAU,EAAER,YAAY,CAACK,QAAQ;sBAAE,OAE/F;UAAS;MACG,CACd;AACJ,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/AddPanelButton/AddPanelButton.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, ButtonProps } from '@mui/material';\nimport AddPanelIcon from 'mdi-material-ui/ChartBoxPlusOutline';\nimport { InfoTooltip } from '@perses-dev/components';\nimport { TOOLTIP_TEXT } from '../../constants';\nimport { useDashboardActions } from '../../context';\n\nexport interface AddPanelButtonProps extends Pick<ButtonProps, 'fullWidth'> {\n /**\n * The variant to use to display the button.\n */\n variant?: 'text' | 'outlined';\n\n /**\n * The color to use to display the button.\n */\n color?: 'primary' | 'secondary';\n\n /**\n * The label used inside the button.\n */\n label?: string;\n}\n\nexport const AddPanelButton = ({\n variant = 'text',\n color = 'primary',\n label = 'Panel',\n fullWidth,\n}: AddPanelButtonProps) => {\n const { openAddPanel } = useDashboardActions();\n\n return (\n <InfoTooltip description={TOOLTIP_TEXT.addPanel}>\n <Button\n startIcon={<AddPanelIcon />}\n onClick={openAddPanel}\n aria-label={TOOLTIP_TEXT.addPanel}\n variant={variant}\n color={color}\n fullWidth={fullWidth}\n sx={{ whiteSpace: 'nowrap', minWidth: 'auto' }}\n >\n {label}\n </Button>\n </InfoTooltip>\n );\n};\n"],"names":["Button","AddPanelIcon","InfoTooltip","TOOLTIP_TEXT","useDashboardActions","AddPanelButton","variant","color","label","fullWidth","openAddPanel","description","addPanel","startIcon","onClick","aria-label","sx","whiteSpace","minWidth"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,MAAM,QAAqB,eAAe,CAAC;AACpD,OAAOC,YAAY,MAAM,qCAAqC,CAAC;AAC/D,SAASC,WAAW,QAAQ,wBAAwB,CAAC;AACrD,SAASC,YAAY,QAAQ,iBAAiB,CAAC;AAC/C,SAASC,mBAAmB,QAAQ,eAAe,CAAC;AAmBpD,OAAO,MAAMC,cAAc,GAAG,CAAC,EAC7BC,OAAO,EAAG,MAAM,CAAA,EAChBC,KAAK,EAAG,SAAS,CAAA,EACjBC,KAAK,EAAG,OAAO,CAAA,EACfC,SAAS,CAAA,EACW,GAAK;IACzB,MAAM,EAAEC,YAAY,CAAA,EAAE,GAAGN,mBAAmB,EAAE,AAAC;IAE/C,qBACE,KAACF,WAAW;QAACS,WAAW,EAAER,YAAY,CAACS,QAAQ;kBAC7C,cAAA,KAACZ,MAAM;YACLa,SAAS,gBAAE,KAACZ,YAAY,KAAG;YAC3Ba,OAAO,EAAEJ,YAAY;YACrBK,YAAU,EAAEZ,YAAY,CAACS,QAAQ;YACjCN,OAAO,EAAEA,OAAO;YAChBC,KAAK,EAAEA,KAAK;YACZE,SAAS,EAAEA,SAAS;YACpBO,EAAE,EAAE;gBAAEC,UAAU,EAAE,QAAQ;gBAAEC,QAAQ,EAAE,MAAM;aAAE;sBAE7CV,KAAK;UACC;MACG,CACd;AACJ,CAAC,CAAC"}
@@ -1,8 +1,16 @@
1
1
  /// <reference types="react" />
2
2
  import { BoxProps } from '@mui/material';
3
- export declare type DashboardProps = BoxProps;
3
+ import { EmptyDashboardProps } from '../EmptyDashboard';
4
+ export declare type DashboardProps = BoxProps & {
5
+ /**
6
+ * Props for `EmptyDashboard` component that will be rendered when the dashboard
7
+ * is empty (i.e. has no panel groups). If not specified, the defaults will
8
+ * be used.
9
+ */
10
+ emptyDashboardProps?: EmptyDashboardProps;
11
+ };
4
12
  /**
5
13
  * Renders a Dashboard for the provided Dashboard spec.
6
14
  */
7
- export declare function Dashboard(props: DashboardProps): JSX.Element;
15
+ export declare function Dashboard({ emptyDashboardProps, ...boxProps }: DashboardProps): JSX.Element;
8
16
  //# sourceMappingURL=Dashboard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Dashboard.d.ts","sourceRoot":"","sources":["../../../src/components/Dashboard/Dashboard.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAK9C,oBAAY,cAAc,GAAG,QAAQ,CAAC;AAEtC;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,eAW9C"}
1
+ {"version":3,"file":"Dashboard.d.ts","sourceRoot":"","sources":["../../../src/components/Dashboard/Dashboard.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAI9C,OAAO,EAAkB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExE,oBAAY,cAAc,GAAG,QAAQ,GAAG;IACtC;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,wBAAgB,SAAS,CAAC,EAAE,mBAAmB,EAAE,GAAG,QAAQ,EAAE,EAAE,cAAc,eAgB7E"}
@@ -10,22 +10,39 @@
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 } from "react/jsx-runtime";
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { Box } from '@mui/material';
15
15
  import { ErrorBoundary, ErrorAlert } from '@perses-dev/components';
16
16
  import { usePanelGroupIds } from '../../context';
17
17
  import { GridLayout } from '../GridLayout';
18
+ import { EmptyDashboard } from '../EmptyDashboard';
18
19
  /**
19
20
  * Renders a Dashboard for the provided Dashboard spec.
20
- */ export function Dashboard(props) {
21
+ */ export function Dashboard({ emptyDashboardProps , ...boxProps }) {
21
22
  const panelGroupIds = usePanelGroupIds();
23
+ const isEmpty = !panelGroupIds.length;
22
24
  return /*#__PURE__*/ _jsx(Box, {
23
- ...props,
24
- children: /*#__PURE__*/ _jsx(ErrorBoundary, {
25
+ ...boxProps,
26
+ sx: {
27
+ height: '100%'
28
+ },
29
+ children: /*#__PURE__*/ _jsxs(ErrorBoundary, {
25
30
  FallbackComponent: ErrorAlert,
26
- children: panelGroupIds.map((panelGroupId)=>/*#__PURE__*/ _jsx(GridLayout, {
27
- panelGroupId: panelGroupId
28
- }, panelGroupId))
31
+ children: [
32
+ isEmpty && /*#__PURE__*/ _jsx(Box, {
33
+ sx: {
34
+ height: '100%',
35
+ display: 'flex',
36
+ alignItems: 'center'
37
+ },
38
+ children: /*#__PURE__*/ _jsx(EmptyDashboard, {
39
+ ...emptyDashboardProps
40
+ })
41
+ }),
42
+ !isEmpty && panelGroupIds.map((panelGroupId)=>/*#__PURE__*/ _jsx(GridLayout, {
43
+ panelGroupId: panelGroupId
44
+ }, panelGroupId))
45
+ ]
29
46
  })
30
47
  });
31
48
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Dashboard/Dashboard.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, BoxProps } from '@mui/material';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { usePanelGroupIds } from '../../context';\nimport { GridLayout } from '../GridLayout';\n\nexport type DashboardProps = BoxProps;\n\n/**\n * Renders a Dashboard for the provided Dashboard spec.\n */\nexport function Dashboard(props: DashboardProps) {\n const panelGroupIds = usePanelGroupIds();\n return (\n <Box {...props}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n {panelGroupIds.map((panelGroupId) => (\n <GridLayout key={panelGroupId} panelGroupId={panelGroupId} />\n ))}\n </ErrorBoundary>\n </Box>\n );\n}\n"],"names":["Box","ErrorBoundary","ErrorAlert","usePanelGroupIds","GridLayout","Dashboard","props","panelGroupIds","FallbackComponent","map","panelGroupId"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,QAAkB,eAAe,CAAC;AAC9C,SAASC,aAAa,EAAEC,UAAU,QAAQ,wBAAwB,CAAC;AACnE,SAASC,gBAAgB,QAAQ,eAAe,CAAC;AACjD,SAASC,UAAU,QAAQ,eAAe,CAAC;AAI3C;;CAEC,GACD,OAAO,SAASC,SAAS,CAACC,KAAqB,EAAE;IAC/C,MAAMC,aAAa,GAAGJ,gBAAgB,EAAE,AAAC;IACzC,qBACE,KAACH,GAAG;QAAE,GAAGM,KAAK;kBACZ,cAAA,KAACL,aAAa;YAACO,iBAAiB,EAAEN,UAAU;sBACzCK,aAAa,CAACE,GAAG,CAAC,CAACC,YAAY,iBAC9B,KAACN,UAAU;oBAAoBM,YAAY,EAAEA,YAAY;mBAAxCA,YAAY,CAAgC,AAC9D,CAAC;UACY;MACZ,CACN;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/Dashboard/Dashboard.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, BoxProps } from '@mui/material';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { usePanelGroupIds } from '../../context';\nimport { GridLayout } from '../GridLayout';\nimport { EmptyDashboard, EmptyDashboardProps } from '../EmptyDashboard';\n\nexport type DashboardProps = BoxProps & {\n /**\n * Props for `EmptyDashboard` component that will be rendered when the dashboard\n * is empty (i.e. has no panel groups). If not specified, the defaults will\n * be used.\n */\n emptyDashboardProps?: EmptyDashboardProps;\n};\n\n/**\n * Renders a Dashboard for the provided Dashboard spec.\n */\nexport function Dashboard({ emptyDashboardProps, ...boxProps }: DashboardProps) {\n const panelGroupIds = usePanelGroupIds();\n const isEmpty = !panelGroupIds.length;\n\n return (\n <Box {...boxProps} sx={{ height: '100%' }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n {isEmpty && (\n <Box sx={{ height: '100%', display: 'flex', alignItems: 'center' }}>\n <EmptyDashboard {...emptyDashboardProps} />\n </Box>\n )}\n {!isEmpty && panelGroupIds.map((panelGroupId) => <GridLayout key={panelGroupId} panelGroupId={panelGroupId} />)}\n </ErrorBoundary>\n </Box>\n );\n}\n"],"names":["Box","ErrorBoundary","ErrorAlert","usePanelGroupIds","GridLayout","EmptyDashboard","Dashboard","emptyDashboardProps","boxProps","panelGroupIds","isEmpty","length","sx","height","FallbackComponent","display","alignItems","map","panelGroupId"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,QAAkB,eAAe,CAAC;AAC9C,SAASC,aAAa,EAAEC,UAAU,QAAQ,wBAAwB,CAAC;AACnE,SAASC,gBAAgB,QAAQ,eAAe,CAAC;AACjD,SAASC,UAAU,QAAQ,eAAe,CAAC;AAC3C,SAASC,cAAc,QAA6B,mBAAmB,CAAC;AAWxE;;CAEC,GACD,OAAO,SAASC,SAAS,CAAC,EAAEC,mBAAmB,CAAA,EAAE,GAAGC,QAAQ,EAAkB,EAAE;IAC9E,MAAMC,aAAa,GAAGN,gBAAgB,EAAE,AAAC;IACzC,MAAMO,OAAO,GAAG,CAACD,aAAa,CAACE,MAAM,AAAC;IAEtC,qBACE,KAACX,GAAG;QAAE,GAAGQ,QAAQ;QAAEI,EAAE,EAAE;YAAEC,MAAM,EAAE,MAAM;SAAE;kBACvC,cAAA,MAACZ,aAAa;YAACa,iBAAiB,EAAEZ,UAAU;;gBACzCQ,OAAO,kBACN,KAACV,GAAG;oBAACY,EAAE,EAAE;wBAAEC,MAAM,EAAE,MAAM;wBAAEE,OAAO,EAAE,MAAM;wBAAEC,UAAU,EAAE,QAAQ;qBAAE;8BAChE,cAAA,KAACX,cAAc;wBAAE,GAAGE,mBAAmB;sBAAI;kBACvC,AACP;gBACA,CAACG,OAAO,IAAID,aAAa,CAACQ,GAAG,CAAC,CAACC,YAAY,iBAAK,KAACd,UAAU;wBAAoBc,YAAY,EAAEA,YAAY;uBAAxCA,YAAY,CAAgC,CAAC;;UACjG;MACZ,CACN;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/DashboardToolbar/DashboardToolbar.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAQrD,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,uBAAuB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACtC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACpE;AAED,eAAO,MAAM,gBAAgB,UAAW,qBAAqB,gBA4I5D,CAAC"}
1
+ {"version":3,"file":"DashboardToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/DashboardToolbar/DashboardToolbar.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAUrD,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,uBAAuB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACtC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACpE;AAED,eAAO,MAAM,gBAAgB,UAAW,qBAAqB,gBAoI5D,CAAC"}
@@ -13,7 +13,6 @@
13
13
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
14
  import { useState } from 'react';
15
15
  import { Typography, Stack, Button, Box, useTheme, useMediaQuery, Alert } from '@mui/material';
16
- import PencilIcon from 'mdi-material-ui/PencilOutline';
17
16
  import { ErrorBoundary, ErrorAlert } from '@perses-dev/components';
18
17
  import { useDashboard, useEditMode } from '../../context';
19
18
  import { AddPanelButton } from '../AddPanelButton';
@@ -21,6 +20,8 @@ import { AddGroupButton } from '../AddGroupButton';
21
20
  import { DownloadButton } from '../DownloadButton';
22
21
  import { TimeRangeControls } from '../TimeRangeControls';
23
22
  import { TemplateVariableList, EditVariablesButton } from '../Variables';
23
+ import { EditButton } from '../EditButton';
24
+ import { EditJsonButton } from '../EditJsonButton';
24
25
  export const DashboardToolbar = (props)=>{
25
26
  const { dashboardName , dashboardTitleComponent , initialVariableIsSticky , isReadonly , onEditButtonClick , onCancelButtonClick , onSave , } = props;
26
27
  const dashboard = useDashboard();
@@ -117,7 +118,8 @@ export const DashboardToolbar = (props)=>{
117
118
  /*#__PURE__*/ _jsx(AddPanelButton, {}),
118
119
  /*#__PURE__*/ _jsx(AddGroupButton, {}),
119
120
  /*#__PURE__*/ _jsx(TimeRangeControls, {}),
120
- /*#__PURE__*/ _jsx(DownloadButton, {})
121
+ /*#__PURE__*/ _jsx(DownloadButton, {}),
122
+ /*#__PURE__*/ _jsx(EditJsonButton, {})
121
123
  ]
122
124
  }) : // On smaller screens, make it two rows
123
125
  /*#__PURE__*/ _jsxs(Stack, {
@@ -132,7 +134,8 @@ export const DashboardToolbar = (props)=>{
132
134
  },
133
135
  children: [
134
136
  /*#__PURE__*/ _jsx(TimeRangeControls, {}),
135
- /*#__PURE__*/ _jsx(DownloadButton, {})
137
+ /*#__PURE__*/ _jsx(DownloadButton, {}),
138
+ /*#__PURE__*/ _jsx(EditJsonButton, {})
136
139
  ]
137
140
  }),
138
141
  /*#__PURE__*/ _jsxs(Stack, {
@@ -172,15 +175,8 @@ export const DashboardToolbar = (props)=>{
172
175
  children: [
173
176
  /*#__PURE__*/ _jsx(TimeRangeControls, {}),
174
177
  /*#__PURE__*/ _jsx(DownloadButton, {}),
175
- isBiggerThanSm && /*#__PURE__*/ _jsx(Button, {
176
- variant: "outlined",
177
- color: "secondary",
178
- startIcon: /*#__PURE__*/ _jsx(PencilIcon, {}),
179
- onClick: onEditButtonClick,
180
- sx: {
181
- marginLeft: 'auto'
182
- },
183
- children: "Edit"
178
+ isBiggerThanSm && /*#__PURE__*/ _jsx(EditButton, {
179
+ onClick: onEditButtonClick
184
180
  })
185
181
  ]
186
182
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/DashboardToolbar/DashboardToolbar.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useState } from 'react';\nimport { Typography, Stack, Button, Box, useTheme, useMediaQuery, Alert } from '@mui/material';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { DashboardResource } from '@perses-dev/core';\nimport { useDashboard, useEditMode } from '../../context';\nimport { AddPanelButton } from '../AddPanelButton';\nimport { AddGroupButton } from '../AddGroupButton';\nimport { DownloadButton } from '../DownloadButton';\nimport { TimeRangeControls } from '../TimeRangeControls';\nimport { TemplateVariableList, EditVariablesButton } from '../Variables';\n\nexport interface DashboardToolbarProps {\n dashboardName: string;\n dashboardTitleComponent?: JSX.Element;\n initialVariableIsSticky?: boolean;\n isReadonly: boolean;\n onEditButtonClick: () => void;\n onCancelButtonClick: () => void;\n onSave?: (entity: DashboardResource) => Promise<DashboardResource>;\n}\n\nexport const DashboardToolbar = (props: DashboardToolbarProps) => {\n const {\n dashboardName,\n dashboardTitleComponent,\n initialVariableIsSticky,\n isReadonly,\n onEditButtonClick,\n onCancelButtonClick,\n onSave,\n } = props;\n\n const dashboard = useDashboard();\n const { isEditMode, setEditMode } = useEditMode();\n\n const isBiggerThanMd = useMediaQuery(useTheme().breakpoints.up('md'));\n const isBiggerThanSm = useMediaQuery(useTheme().breakpoints.up('sm'));\n\n const [isSavingDashboard, setSavingDashboard] = useState<boolean>(false);\n\n const dashboardTitle = dashboardTitleComponent ? (\n dashboardTitleComponent\n ) : (\n <Typography variant=\"h2\">{dashboardName}</Typography>\n );\n\n const onSaveButtonClick = () => {\n if (onSave !== undefined) {\n setSavingDashboard(true);\n onSave(dashboard.dashboard)\n .then(() => {\n setSavingDashboard(false);\n setEditMode(false);\n })\n .catch(() => {\n setSavingDashboard(false);\n });\n } else {\n setEditMode(false);\n }\n };\n\n const testId = 'dashboard-toolbar';\n\n return (\n <>\n {isEditMode ? (\n <Stack spacing={1} data-testid={testId}>\n <Box p={2} display=\"flex\" sx={{ backgroundColor: (theme) => theme.palette.primary.main + '30' }}>\n {dashboardTitle}\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\">\n {isReadonly && (\n <Alert severity={'warning'} sx={{ backgroundColor: 'transparent', padding: 0 }}>\n Dashboard managed via code only. Download JSON and commit changes to save.\n </Alert>\n )}\n <Button variant=\"contained\" onClick={onSaveButtonClick} disabled={isReadonly || isSavingDashboard}>\n Save\n </Button>\n <Button variant=\"outlined\" onClick={onCancelButtonClick}>\n Cancel\n </Button>\n </Stack>\n </Box>\n <Box\n sx={{\n display: 'flex',\n width: '100%',\n alignItems: 'start',\n padding: (theme) => theme.spacing(1, 2, 2, 2),\n }}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <TemplateVariableList\n initialVariableIsSticky={initialVariableIsSticky}\n sx={{\n backgroundColor: ({ palette }) =>\n palette.mode === 'dark' ? palette.background.default : palette.background.paper,\n }}\n />\n </ErrorBoundary>\n {isBiggerThanMd ? (\n // On bigger screens, make it one row\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\" sx={{ whiteSpace: 'nowrap' }}>\n <EditVariablesButton />\n <AddPanelButton />\n <AddGroupButton />\n <TimeRangeControls />\n <DownloadButton />\n </Stack>\n ) : (\n // On smaller screens, make it two rows\n <Stack spacing={1}>\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\" sx={{ whiteSpace: 'nowrap' }}>\n <TimeRangeControls />\n <DownloadButton />\n </Stack>\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\" sx={{ whiteSpace: 'nowrap' }}>\n <EditVariablesButton />\n <AddPanelButton />\n <AddGroupButton />\n </Stack>\n </Stack>\n )}\n </Box>\n </Stack>\n ) : (\n <Stack spacing={1} padding={2} data-testid={testId}>\n <Box sx={{ display: 'flex', width: '100%' }}>\n {dashboardTitle}\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\">\n <TimeRangeControls />\n <DownloadButton />\n {isBiggerThanSm && (\n <Button\n variant=\"outlined\"\n color=\"secondary\"\n startIcon={<PencilIcon />}\n onClick={onEditButtonClick}\n sx={{ marginLeft: 'auto' }}\n >\n Edit\n </Button>\n )}\n </Stack>\n </Box>\n <Box paddingY={2}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <TemplateVariableList\n initialVariableIsSticky={initialVariableIsSticky}\n sx={{\n backgroundColor: ({ palette }) =>\n palette.mode === 'dark' ? palette.background.default : palette.background.paper,\n }}\n />\n </ErrorBoundary>\n </Box>\n </Stack>\n )}\n </>\n );\n};\n"],"names":["useState","Typography","Stack","Button","Box","useTheme","useMediaQuery","Alert","PencilIcon","ErrorBoundary","ErrorAlert","useDashboard","useEditMode","AddPanelButton","AddGroupButton","DownloadButton","TimeRangeControls","TemplateVariableList","EditVariablesButton","DashboardToolbar","props","dashboardName","dashboardTitleComponent","initialVariableIsSticky","isReadonly","onEditButtonClick","onCancelButtonClick","onSave","dashboard","isEditMode","setEditMode","isBiggerThanMd","breakpoints","up","isBiggerThanSm","isSavingDashboard","setSavingDashboard","dashboardTitle","variant","onSaveButtonClick","undefined","then","catch","testId","spacing","data-testid","p","display","sx","backgroundColor","theme","palette","primary","main","direction","marginLeft","severity","padding","onClick","disabled","width","alignItems","FallbackComponent","mode","background","default","paper","whiteSpace","color","startIcon","paddingY"],"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,UAAU,EAAEC,KAAK,EAAEC,MAAM,EAAEC,GAAG,EAAEC,QAAQ,EAAEC,aAAa,EAAEC,KAAK,QAAQ,eAAe,CAAC;AAC/F,OAAOC,UAAU,MAAM,+BAA+B,CAAC;AACvD,SAASC,aAAa,EAAEC,UAAU,QAAQ,wBAAwB,CAAC;AAEnE,SAASC,YAAY,EAAEC,WAAW,QAAQ,eAAe,CAAC;AAC1D,SAASC,cA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L,cAAc,KAAG;sDAClB,KAACC,cAAc,KAAG;;kCACZ;;0BACF,AACT;;kBACG;;UACA,iBAER,MAACZ,KAAK;YAAC0C,OAAO,EAAE,CAAC;YAAEa,OAAO,EAAE,CAAC;YAAEZ,aAAW,EAAEF,MAAM;;8BAChD,MAACvC,GAAG;oBAAC4C,EAAE,EAAE;wBAAED,OAAO,EAAE,MAAM;wBAAEa,KAAK,EAAE,MAAM;qBAAE;;wBACxCvB,cAAc;sCACf,MAACnC,KAAK;4BAACoD,SAAS,EAAC,KAAK;4BAACV,OAAO,EAAE,CAAC;4BAAEW,UAAU,EAAC,MAAM;;8CAClD,KAACvC,iBAAiB,KAAG;8CACrB,KAACD,cAAc,KAAG;gCACjBmB,cAAc,kBACb,KAAC/B,MAAM;oCACLmC,OAAO,EAAC,UAAU;oCAClB8B,KAAK,EAAC,WAAW;oCACjBC,SAAS,gBAAE,KAAC7D,UAAU,KAAG;oCACzBkD,OAAO,EAAEjC,iBAAiB;oCAC1BuB,EAAE,EAAE;wCAAEO,UAAU,EAAE,MAAM;qCAAE;8CAC3B,MAED;kCAAS,AACV;;0BACK;;kBACJ;8BACN,KAACnD,GAAG;oBAACkE,QAAQ,EAAE,CAAC;8BACd,cAAA,KAAC7D,aAAa;wBAACqD,iBAAiB,EAAEpD,UAAU;kCAC1C,cAAA,KAACO,oBAAoB;4BACnBM,uBAAuB,EAAEA,uBAAuB;4BAChDyB,EAAE,EAAE;gCACFC,eAAe,EAAE,CAAC,EAAEE,OAAO,CAAA,EAAE,GAC3BA,OAAO,CAACY,IAAI,KAAK,MAAM,GAAGZ,OAAO,CAACa,UAAU,CAACC,OAAO,GAAGd,OAAO,CAACa,UAAU,CAACE,KAAK;6BAClF;0BACD;sBACY;kBACZ;;UACA,AACT;MACA,CACH;AACJ,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/DashboardToolbar/DashboardToolbar.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useState } from 'react';\nimport { Typography, Stack, Button, Box, useTheme, useMediaQuery, Alert } from '@mui/material';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { DashboardResource } from '@perses-dev/core';\nimport { useDashboard, useEditMode } from '../../context';\nimport { AddPanelButton } from '../AddPanelButton';\nimport { AddGroupButton } from '../AddGroupButton';\nimport { DownloadButton } from '../DownloadButton';\nimport { TimeRangeControls } from '../TimeRangeControls';\nimport { TemplateVariableList, EditVariablesButton } from '../Variables';\nimport { EditButton } from '../EditButton';\nimport { EditJsonButton } from '../EditJsonButton';\n\nexport interface DashboardToolbarProps {\n dashboardName: string;\n dashboardTitleComponent?: JSX.Element;\n initialVariableIsSticky?: boolean;\n isReadonly: boolean;\n onEditButtonClick: () => void;\n onCancelButtonClick: () => void;\n onSave?: (entity: DashboardResource) => Promise<DashboardResource>;\n}\n\nexport const DashboardToolbar = (props: DashboardToolbarProps) => {\n const {\n dashboardName,\n dashboardTitleComponent,\n initialVariableIsSticky,\n isReadonly,\n onEditButtonClick,\n onCancelButtonClick,\n onSave,\n } = props;\n\n const dashboard = useDashboard();\n const { isEditMode, setEditMode } = useEditMode();\n\n const isBiggerThanMd = useMediaQuery(useTheme().breakpoints.up('md'));\n const isBiggerThanSm = useMediaQuery(useTheme().breakpoints.up('sm'));\n\n const [isSavingDashboard, setSavingDashboard] = useState<boolean>(false);\n\n const dashboardTitle = dashboardTitleComponent ? (\n dashboardTitleComponent\n ) : (\n <Typography variant=\"h2\">{dashboardName}</Typography>\n );\n\n const onSaveButtonClick = () => {\n if (onSave !== undefined) {\n setSavingDashboard(true);\n onSave(dashboard.dashboard)\n .then(() => {\n setSavingDashboard(false);\n setEditMode(false);\n })\n .catch(() => {\n setSavingDashboard(false);\n });\n } else {\n setEditMode(false);\n }\n };\n\n const testId = 'dashboard-toolbar';\n\n return (\n <>\n {isEditMode ? (\n <Stack spacing={1} data-testid={testId}>\n <Box p={2} display=\"flex\" sx={{ backgroundColor: (theme) => theme.palette.primary.main + '30' }}>\n {dashboardTitle}\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\">\n {isReadonly && (\n <Alert severity={'warning'} sx={{ backgroundColor: 'transparent', padding: 0 }}>\n Dashboard managed via code only. Download JSON and commit changes to save.\n </Alert>\n )}\n <Button variant=\"contained\" onClick={onSaveButtonClick} disabled={isReadonly || isSavingDashboard}>\n Save\n </Button>\n <Button variant=\"outlined\" onClick={onCancelButtonClick}>\n Cancel\n </Button>\n </Stack>\n </Box>\n <Box\n sx={{\n display: 'flex',\n width: '100%',\n alignItems: 'start',\n padding: (theme) => theme.spacing(1, 2, 2, 2),\n }}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <TemplateVariableList\n initialVariableIsSticky={initialVariableIsSticky}\n sx={{\n backgroundColor: ({ palette }) =>\n palette.mode === 'dark' ? palette.background.default : palette.background.paper,\n }}\n />\n </ErrorBoundary>\n {isBiggerThanMd ? (\n // On bigger screens, make it one row\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\" sx={{ whiteSpace: 'nowrap' }}>\n <EditVariablesButton />\n <AddPanelButton />\n <AddGroupButton />\n <TimeRangeControls />\n <DownloadButton />\n <EditJsonButton />\n </Stack>\n ) : (\n // On smaller screens, make it two rows\n <Stack spacing={1}>\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\" sx={{ whiteSpace: 'nowrap' }}>\n <TimeRangeControls />\n <DownloadButton />\n <EditJsonButton />\n </Stack>\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\" sx={{ whiteSpace: 'nowrap' }}>\n <EditVariablesButton />\n <AddPanelButton />\n <AddGroupButton />\n </Stack>\n </Stack>\n )}\n </Box>\n </Stack>\n ) : (\n <Stack spacing={1} padding={2} data-testid={testId}>\n <Box sx={{ display: 'flex', width: '100%' }}>\n {dashboardTitle}\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\">\n <TimeRangeControls />\n <DownloadButton />\n {isBiggerThanSm && <EditButton onClick={onEditButtonClick} />}\n </Stack>\n </Box>\n <Box paddingY={2}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <TemplateVariableList\n initialVariableIsSticky={initialVariableIsSticky}\n sx={{\n backgroundColor: ({ palette }) =>\n palette.mode === 'dark' ? palette.background.default : palette.background.paper,\n }}\n />\n </ErrorBoundary>\n </Box>\n </Stack>\n )}\n </>\n );\n};\n"],"names":["useState","Typography","Stack","Button","Box","useTheme","useMediaQuery","Alert","ErrorBoundary","ErrorAlert","useDashboard","useEditMode","AddPanelButton","AddGroupButton","DownloadButton","TimeRangeControls","TemplateVariableList","EditVariablesButton","EditButton","EditJsonButton","DashboardToolbar","props","dashboardName","dashboardTitleComponent","initialVariableIsSticky","isReadonly","onEditButtonClick","onCancelButtonClick","onSave","dashboard","isEditMode","setEditMode","isBiggerThanMd","breakpoints","up","isBiggerThanSm","isSavingDashboard","setSavingDashboard","dashboardTitle","variant","onSaveButtonClick","undefined","then","catch","testId","spacing","data-testid","p","display","sx","backgroundColor","theme","palette","primary","main","direction","marginLeft","severity","padding","onClick","disabled","width","alignItems","FallbackComponent","mode","background","default","paper","whiteSpace","paddingY"],"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,UAAU,EAAEC,KAAK,EAAEC,MAAM,EAAEC,GAAG,EAAEC,QAA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,CACH;AACJ,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ export interface EditButtonProps {
3
+ /**
4
+ * The label used inside the button.
5
+ */
6
+ label?: string;
7
+ /**
8
+ * Handler that puts the dashboard into editing mode.
9
+ */
10
+ onClick: () => void;
11
+ }
12
+ export declare const EditButton: ({ label, onClick }: EditButtonProps) => JSX.Element;
13
+ //# sourceMappingURL=EditButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditButton.d.ts","sourceRoot":"","sources":["../../../src/components/EditButton/EditButton.tsx"],"names":[],"mappings":";AAgBA,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,UAAU,uBAAiC,eAAe,gBAYtE,CAAC"}
@@ -0,0 +1,30 @@
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
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { Button } from '@mui/material';
15
+ import PencilIcon from 'mdi-material-ui/PencilOutline';
16
+ export const EditButton = ({ label ='Edit' , onClick })=>{
17
+ return /*#__PURE__*/ _jsx(Button, {
18
+ onClick: onClick,
19
+ startIcon: /*#__PURE__*/ _jsx(PencilIcon, {}),
20
+ variant: "outlined",
21
+ color: "secondary",
22
+ sx: {
23
+ whiteSpace: 'nowrap',
24
+ minWidth: 'auto'
25
+ },
26
+ children: label
27
+ });
28
+ };
29
+
30
+ //# sourceMappingURL=EditButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/EditButton/EditButton.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 PencilIcon from 'mdi-material-ui/PencilOutline';\n\nexport interface EditButtonProps {\n /**\n * The label used inside the button.\n */\n label?: string;\n\n /**\n * Handler that puts the dashboard into editing mode.\n */\n onClick: () => void;\n}\n\nexport const EditButton = ({ label = 'Edit', onClick }: EditButtonProps) => {\n return (\n <Button\n onClick={onClick}\n startIcon={<PencilIcon />}\n variant=\"outlined\"\n color=\"secondary\"\n sx={{ whiteSpace: 'nowrap', minWidth: 'auto' }}\n >\n {label}\n </Button>\n );\n};\n"],"names":["Button","PencilIcon","EditButton","label","onClick","startIcon","variant","color","sx","whiteSpace","minWidth"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,MAAM,QAAQ,eAAe,CAAC;AACvC,OAAOC,UAAU,MAAM,+BAA+B,CAAC;AAcvD,OAAO,MAAMC,UAAU,GAAG,CAAC,EAAEC,KAAK,EAAG,MAAM,CAAA,EAAEC,OAAO,CAAA,EAAmB,GAAK;IAC1E,qBACE,KAACJ,MAAM;QACLI,OAAO,EAAEA,OAAO;QAChBC,SAAS,gBAAE,KAACJ,UAAU,KAAG;QACzBK,OAAO,EAAC,UAAU;QAClBC,KAAK,EAAC,WAAW;QACjBC,EAAE,EAAE;YAAEC,UAAU,EAAE,QAAQ;YAAEC,QAAQ,EAAE,MAAM;SAAE;kBAE7CP,KAAK;MACC,CACT;AACJ,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './EditButton';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/EditButton/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export * from './EditButton';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/EditButton/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './EditButton';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,cAAc,CAAC"}
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export declare const EditJsonButton: () => JSX.Element;
3
+ //# sourceMappingURL=EditJsonButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditJsonButton.d.ts","sourceRoot":"","sources":["../../../src/components/EditJsonButton/EditJsonButton.tsx"],"names":[],"mappings":";AAmBA,eAAO,MAAM,cAAc,mBAS1B,CAAC"}
@@ -0,0 +1,31 @@
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
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import CodeIcon from 'mdi-material-ui/CodeBraces';
15
+ import { InfoTooltip } from '@perses-dev/components';
16
+ import { TOOLTIP_TEXT } from '../../constants';
17
+ import { ToolbarIconButton } from '../ToolbarIconButton';
18
+ import { useEditJsonDialog } from '../../context';
19
+ export const EditJsonButton = ()=>{
20
+ const { openEditJsonDialog } = useEditJsonDialog();
21
+ return /*#__PURE__*/ _jsx(InfoTooltip, {
22
+ description: TOOLTIP_TEXT.editJson,
23
+ children: /*#__PURE__*/ _jsx(ToolbarIconButton, {
24
+ variant: "outlined",
25
+ onClick: ()=>openEditJsonDialog(),
26
+ children: /*#__PURE__*/ _jsx(CodeIcon, {})
27
+ })
28
+ });
29
+ };
30
+
31
+ //# sourceMappingURL=EditJsonButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/EditJsonButton/EditJsonButton.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 CodeIcon from 'mdi-material-ui/CodeBraces';\nimport { InfoTooltip } from '@perses-dev/components';\nimport { TOOLTIP_TEXT } from '../../constants';\nimport { ToolbarIconButton } from '../ToolbarIconButton';\nimport { useEditJsonDialog } from '../../context';\n\nexport const EditJsonButton = () => {\n const { openEditJsonDialog } = useEditJsonDialog();\n return (\n <InfoTooltip description={TOOLTIP_TEXT.editJson}>\n <ToolbarIconButton variant=\"outlined\" onClick={() => openEditJsonDialog()}>\n <CodeIcon />\n </ToolbarIconButton>\n </InfoTooltip>\n );\n};\n"],"names":["CodeIcon","InfoTooltip","TOOLTIP_TEXT","ToolbarIconButton","useEditJsonDialog","EditJsonButton","openEditJsonDialog","description","editJson","variant","onClick"],"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,QAAQ,MAAM,4BAA4B,CAAC;AAClD,SAASC,WAAW,QAAQ,wBAAwB,CAAC;AACrD,SAASC,YAAY,QAAQ,iBAAiB,CAAC;AAC/C,SAASC,iBAAiB,QAAQ,sBAAsB,CAAC;AACzD,SAASC,iBAAiB,QAAQ,eAAe,CAAC;AAElD,OAAO,MAAMC,cAAc,GAAG,IAAM;IAClC,MAAM,EAAEC,kBAAkB,CAAA,EAAE,GAAGF,iBAAiB,EAAE,AAAC;IACnD,qBACE,KAACH,WAAW;QAACM,WAAW,EAAEL,YAAY,CAACM,QAAQ;kBAC7C,cAAA,KAACL,iBAAiB;YAACM,OAAO,EAAC,UAAU;YAACC,OAAO,EAAE,IAAMJ,kBAAkB,EAAE;sBACvE,cAAA,KAACN,QAAQ,KAAG;UACM;MACR,CACd;AACJ,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './EditJsonButton';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/EditJsonButton/index.ts"],"names":[],"mappings":"AAaA,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export * from './EditJsonButton';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/EditJsonButton/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './EditJsonButton';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export declare const EditJsonDialog: () => JSX.Element;
3
+ //# sourceMappingURL=EditJsonDialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditJsonDialog.d.ts","sourceRoot":"","sources":["../../../src/components/EditJsonDialog/EditJsonDialog.tsx"],"names":[],"mappings":";AAmBA,eAAO,MAAM,cAAc,mBAS1B,CAAC"}