@perses-dev/dashboards 0.17.0 → 0.18.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 (83) hide show
  1. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +49 -32
  2. package/dist/cjs/components/GridLayout/GridContainer.js +2 -2
  3. package/dist/cjs/components/GridLayout/GridTitle.js +1 -1
  4. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +2 -1
  5. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +28 -5
  6. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +11 -5
  7. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +17 -2
  8. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +5 -4
  9. package/dist/cjs/components/Variables/VariableList.js +3 -0
  10. package/dist/cjs/components/Variables/variable-model.js +38 -6
  11. package/dist/cjs/components/Variables/variable-model.test.js +106 -0
  12. package/dist/cjs/context/TemplateVariableProvider/query-params.js +3 -1
  13. package/dist/cjs/context/index.js +0 -1
  14. package/dist/cjs/views/ViewDashboard/DashboardApp.js +2 -1
  15. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +6 -4
  16. package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +4 -2
  17. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +1 -0
  18. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  19. package/dist/components/DashboardToolbar/DashboardToolbar.js +50 -33
  20. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  21. package/dist/components/GridLayout/GridContainer.js +2 -2
  22. package/dist/components/GridLayout/GridContainer.js.map +1 -1
  23. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  24. package/dist/components/GridLayout/GridTitle.js +1 -1
  25. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  26. package/dist/components/PanelDrawer/PanelDrawer.js +2 -1
  27. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  28. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  29. package/dist/components/TimeRangeControls/TimeRangeControls.js +24 -7
  30. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  31. package/dist/components/TimeRangeControls/TimeRangeControls.test.js +11 -5
  32. package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -1
  33. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  34. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +17 -2
  35. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  36. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +1 -0
  37. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
  38. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +5 -4
  39. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  40. package/dist/components/Variables/VariableList.d.ts +2 -0
  41. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  42. package/dist/components/Variables/VariableList.js +3 -0
  43. package/dist/components/Variables/VariableList.js.map +1 -1
  44. package/dist/components/Variables/variable-model.d.ts +3 -2
  45. package/dist/components/Variables/variable-model.d.ts.map +1 -1
  46. package/dist/components/Variables/variable-model.js +38 -7
  47. package/dist/components/Variables/variable-model.js.map +1 -1
  48. package/dist/components/Variables/variable-model.test.d.ts +2 -0
  49. package/dist/components/Variables/variable-model.test.d.ts.map +1 -0
  50. package/dist/components/Variables/variable-model.test.js +104 -0
  51. package/dist/components/Variables/variable-model.test.js.map +1 -0
  52. package/dist/context/TemplateVariableProvider/query-params.js +3 -1
  53. package/dist/context/TemplateVariableProvider/query-params.js.map +1 -1
  54. package/dist/context/index.d.ts +0 -1
  55. package/dist/context/index.d.ts.map +1 -1
  56. package/dist/context/index.js +0 -1
  57. package/dist/context/index.js.map +1 -1
  58. package/dist/views/ViewDashboard/DashboardApp.d.ts +1 -0
  59. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  60. package/dist/views/ViewDashboard/DashboardApp.js +2 -1
  61. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  62. package/dist/views/ViewDashboard/ViewDashboard.d.ts +1 -0
  63. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  64. package/dist/views/ViewDashboard/ViewDashboard.js +5 -3
  65. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  66. package/dist/views/ViewDashboard/tests/panelGroups.test.js +4 -2
  67. package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -1
  68. package/package.json +5 -5
  69. package/dist/cjs/context/TimeRangeProvider/TimeRangeProvider.js +0 -91
  70. package/dist/cjs/context/TimeRangeProvider/index.js +0 -29
  71. package/dist/cjs/context/TimeRangeProvider/query-params.js +0 -157
  72. package/dist/context/TimeRangeProvider/TimeRangeProvider.d.ts +0 -19
  73. package/dist/context/TimeRangeProvider/TimeRangeProvider.d.ts.map +0 -1
  74. package/dist/context/TimeRangeProvider/TimeRangeProvider.js +0 -44
  75. package/dist/context/TimeRangeProvider/TimeRangeProvider.js.map +0 -1
  76. package/dist/context/TimeRangeProvider/index.d.ts +0 -3
  77. package/dist/context/TimeRangeProvider/index.d.ts.map +0 -1
  78. package/dist/context/TimeRangeProvider/index.js +0 -16
  79. package/dist/context/TimeRangeProvider/index.js.map +0 -1
  80. package/dist/context/TimeRangeProvider/query-params.d.ts +0 -25
  81. package/dist/context/TimeRangeProvider/query-params.d.ts.map +0 -1
  82. package/dist/context/TimeRangeProvider/query-params.js +0 -149
  83. package/dist/context/TimeRangeProvider/query-params.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/Variables/variable-model.test.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { VariableOption } from '@perses-dev/plugin-system';\nimport { filterVariableList } from './variable-model';\n\ndescribe('filterVariableList', () => {\n const testSuite = [\n {\n title: 'basic case',\n capturing_regexp: /([^-]*)-host-([^-]*)/g,\n originalValues: [\n { label: 'l1', value: 'us1-host-ahdix' },\n { label: 'l2', value: 'us1-host-diua' },\n { label: 'l3', value: 'eu1-host-adf' },\n { label: 'l4', value: 'bar' },\n ] as VariableOption[],\n result: [\n { label: 'l1', value: 'us1ahdix' },\n { label: 'l2', value: 'us1diua' },\n { label: 'l3', value: 'eu1adf' },\n ],\n },\n {\n title: 'duplicate captured value',\n capturing_regexp: /prometheus-(.+):\\d+/g,\n originalValues: [\n { label: 'l1', value: 'prometheus-app:9090' },\n { label: 'l2', value: 'prometheus-app:9091' },\n { label: 'l3', value: 'prometheus-platform:9091' },\n { label: 'l4', value: 'prometheus-database:9091' },\n { label: 'l5', value: 'prometheus-perses:9091' },\n ] as VariableOption[],\n result: [\n { label: 'l1', value: 'app' },\n { label: 'l3', value: 'platform' },\n { label: 'l4', value: 'database' },\n { label: 'l5', value: 'perses' },\n ],\n },\n ];\n testSuite.forEach(({ title, capturing_regexp, originalValues, result }) => {\n it(title, () => {\n expect(filterVariableList(originalValues, capturing_regexp)).toEqual(result);\n });\n });\n});\n"],"names":["filterVariableList","describe","testSuite","title","capturing_regexp","originalValues","label","value","result","forEach","it","expect","toEqual"],"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;AAGjC,SAASA,k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EAAE,UAAU;iBAAE;gBAClC;oBAAED,KAAK,EAAE,IAAI;oBAAEC,KAAK,EAAE,UAAU;iBAAE;gBAClC;oBAAED,KAAK,EAAE,IAAI;oBAAEC,KAAK,EAAE,QAAQ;iBAAE;aACjC;SACF;KACF,AAAC;IACFL,SAAS,CAACO,OAAO,CAAC,CAAC,EAAEN,KAAK,CAAA,EAAEC,gBAAgB,CAAA,EAAEC,cAAc,CAAA,EAAEG,MAAM,CAAA,EAAE,GAAK;QACzEE,EAAE,CAACP,KAAK,EAAE,IAAM;YACdQ,MAAM,CAACX,kBAAkB,CAACK,cAAc,EAAED,gBAAgB,CAAC,CAAC,CAACQ,OAAO,CAACJ,MAAM,CAAC,CAAC;QAC/E,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -46,7 +46,9 @@ export function useVariableQueryParams(defs) {
46
46
  const name = getURLQueryParamName(def.spec.name);
47
47
  config[name] = VariableValueParam;
48
48
  });
49
- return useQueryParams(config);
49
+ return useQueryParams(config, {
50
+ updateType: 'replaceIn'
51
+ });
50
52
  }
51
53
  export function getInitalValuesFromQueryParameters(queryParamValues) {
52
54
  const values = {};
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/TemplateVariableProvider/query-params.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { VariableValue, VariableDefinition } from '@perses-dev/core';\nimport { QueryParamConfig, useQueryParams } from 'use-query-params';\n\nconst variableQueryParameterPrefix = 'var-';\n\nexport function getURLQueryParamName(name: string) {\n return `${variableQueryParameterPrefix}${name}`;\n}\n\nexport function encodeVariableValue(value: VariableValue) {\n if (Array.isArray(value)) {\n return value.join(',');\n }\n return value;\n}\n\nexport function decodeVariableValue(value: string): VariableValue {\n if (!value) {\n return null;\n }\n const values = value.split(',');\n if (values.length === 1) {\n return values[0] as string;\n }\n return values;\n}\n\nconst VariableValueParam: QueryParamConfig<VariableValue> = {\n encode: encodeVariableValue,\n decode: (v) => {\n if (typeof v === 'string') {\n return decodeVariableValue(v);\n }\n return '';\n },\n};\n\nexport function useVariableQueryParams(defs: VariableDefinition[]) {\n const config: Record<string, typeof VariableValueParam> = {};\n defs.forEach((def) => {\n const name = getURLQueryParamName(def.spec.name);\n config[name] = VariableValueParam;\n });\n return useQueryParams(config);\n}\n\nexport function getInitalValuesFromQueryParameters(\n queryParamValues: Record<string, VariableValue>\n): Record<string, VariableValue> {\n const values: Record<string, VariableValue> = {};\n Object.keys(queryParamValues).forEach((key) => {\n const value = queryParamValues[key];\n if (!value) {\n return;\n }\n const name = key.replace(variableQueryParameterPrefix, '');\n values[name] = value;\n });\n return values;\n}\n"],"names":["useQueryParams","variableQueryParameterPrefix","getURLQueryParamName","name","encodeVariableValue","value","Array","isArray","join","decodeVariableValue","values","split","length","VariableValueParam","encode","decode","v","useVariableQueryParams","defs","config","forEach","def","spec","getInitalValuesFromQueryParameters","queryParamValues","Object","keys","key","replace"],"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;AAGjC,SAA2BA,cAAc,QAAQ,kBAAkB,CAAC;AAEpE,MAAMC,4BAA4B,GAAG,MAAM,AAAC;AAE5C,OAAO,SAASC,oBAAoB,CAACC,IAAY,EAAE;IACjD,OAAO,CAAC,EAAEF,4BAA4B,CAAC,EAAEE,IAAI,CAAC,CAAC,CAAC;AAClD,C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AI,CAACF,gBAAgB,CAAC,CAACJ,OAAO,CAAC,CAACO,GAAG,GAAK;QAC7C,MAAMtB,KAAK,GAAGmB,gBAAgB,CAACG,GAAG,CAAC,AAAC;QACpC,IAAI,CAACtB,KAAK,EAAE;YACV,OAAO;QACT,CAAC;QACD,MAAMF,IAAI,GAAGwB,GAAG,CAACC,OAAO,CAAC3B,4BAA4B,EAAE,EAAE,CAAC,AAAC;QAC3DS,MAAM,CAACP,IAAI,CAAC,GAAGE,KAAK,CAAC;IACvB,CAAC,CAAC,CAAC;IACH,OAAOK,MAAM,CAAC;AAChB,CAAC"}
1
+ {"version":3,"sources":["../../../src/context/TemplateVariableProvider/query-params.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { VariableValue, VariableDefinition } from '@perses-dev/core';\nimport { QueryParamConfig, useQueryParams } from 'use-query-params';\n\nconst variableQueryParameterPrefix = 'var-';\n\nexport function getURLQueryParamName(name: string) {\n return `${variableQueryParameterPrefix}${name}`;\n}\n\nexport function encodeVariableValue(value: VariableValue) {\n if (Array.isArray(value)) {\n return value.join(',');\n }\n return value;\n}\n\nexport function decodeVariableValue(value: string): VariableValue {\n if (!value) {\n return null;\n }\n const values = value.split(',');\n if (values.length === 1) {\n return values[0] as string;\n }\n return values;\n}\n\nconst VariableValueParam: QueryParamConfig<VariableValue> = {\n encode: encodeVariableValue,\n decode: (v) => {\n if (typeof v === 'string') {\n return decodeVariableValue(v);\n }\n return '';\n },\n};\n\nexport function useVariableQueryParams(defs: VariableDefinition[]) {\n const config: Record<string, typeof VariableValueParam> = {};\n defs.forEach((def) => {\n const name = getURLQueryParamName(def.spec.name);\n config[name] = VariableValueParam;\n });\n return useQueryParams(config, { updateType: 'replaceIn' });\n}\n\nexport function getInitalValuesFromQueryParameters(\n queryParamValues: Record<string, VariableValue>\n): Record<string, VariableValue> {\n const values: Record<string, VariableValue> = {};\n Object.keys(queryParamValues).forEach((key) => {\n const value = queryParamValues[key];\n if (!value) {\n return;\n }\n const name = key.replace(variableQueryParameterPrefix, '');\n values[name] = value;\n });\n return values;\n}\n"],"names":["useQueryParams","variableQueryParameterPrefix","getURLQueryParamName","name","encodeVariableValue","value","Array","isArray","join","decodeVariableValue","values","split","length","VariableValueParam","encode","decode","v","useVariableQueryParams","defs","config","forEach","def","spec","updateType","getInitalValuesFromQueryParameters","queryParamValues","Object","keys","key","replace"],"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;AAGjC,SAA2BA,cAAc,QAAQ,kBAAkB,CAAC;AAEpE,MAAMC,4BAA4B,GAAG,MAAM,AAAC;AAE5C,OAAO,SAASC,oBAAoB,CAACC,IAAY,EAAE;IACjD,OAAO,CAAC,EAAEF,4BAA4B,CAAC,EAAEE,IAAI,CAAC,CAAC,CAAC;AAClD,CAAC;AAED,OAAO,SAASC,mBAAmB,CAACC,KAAoB,EAAE;IACxD,IAAIC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,EAAE;QACxB,OAAOA,KAAK,CAACG,IAAI,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IACD,OAAOH,KAAK,CAAC;AACf,CAAC;AAED,OAAO,SAASI,mBAAmB,CAACJ,KAAa,EAAiB;IAChE,IAAI,CAACA,KAAK,EAAE;QACV,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAMK,MAAM,GAAGL,KAAK,CAACM,KAAK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,CAAC,CAAC,CAAC;IACH,OAAOK,MAAM,CAAC;AAChB,CAAC"}
@@ -1,6 +1,5 @@
1
1
  export * from './DashboardProvider';
2
2
  export * from './DatasourceStoreProvider';
3
3
  export * from './TemplateVariableProvider';
4
- export * from './TimeRangeProvider';
5
4
  export * from './useDashboard';
6
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gBAAgB,CAAC"}
@@ -13,7 +13,6 @@
13
13
  export * from './DashboardProvider';
14
14
  export * from './DatasourceStoreProvider';
15
15
  export * from './TemplateVariableProvider';
16
- export * from './TimeRangeProvider';
17
16
  export * from './useDashboard';
18
17
 
19
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/context/index.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './DashboardProvider';\nexport * from './DatasourceStoreProvider';\nexport * from './TemplateVariableProvider';\nexport * from './TimeRangeProvider';\nexport * from './useDashboard';\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,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"sources":["../../src/context/index.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './DashboardProvider';\nexport * from './DatasourceStoreProvider';\nexport * from './TemplateVariableProvider';\nexport * from './useDashboard';\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,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gBAAgB,CAAC"}
@@ -4,6 +4,7 @@ export interface DashboardAppProps {
4
4
  dashboardResource: DashboardResource;
5
5
  dashboardTitleComponent?: JSX.Element;
6
6
  initialVariableIsSticky?: boolean;
7
+ isReadonly: boolean;
7
8
  }
8
9
  export declare const DashboardApp: (props: DashboardAppProps) => JSX.Element;
9
10
  //# sourceMappingURL=DashboardApp.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardApp.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAYrD,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,uBAAuB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACtC,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,eAAO,MAAM,YAAY,UAAW,iBAAiB,gBAoEpD,CAAC"}
1
+ {"version":3,"file":"DashboardApp.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAYrD,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,uBAAuB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACtC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,YAAY,UAAW,iBAAiB,gBAqEpD,CAAC"}
@@ -17,7 +17,7 @@ import { ErrorAlert, ErrorBoundary } from '@perses-dev/components';
17
17
  import { PanelDrawer, Dashboard, PanelGroupDialog, DeletePanelGroupDialog, UnsavedChangesConfirmationDialog, DashboardToolbar, DeletePanelDialog } from '../../components';
18
18
  import { useDashboard, useEditMode } from '../../context';
19
19
  export const DashboardApp = (props)=>{
20
- const { dashboardResource , dashboardTitleComponent , initialVariableIsSticky } = props;
20
+ const { dashboardResource , dashboardTitleComponent , initialVariableIsSticky , isReadonly } = props;
21
21
  const { setEditMode } = useEditMode();
22
22
  const { dashboard , setDashboard } = useDashboard();
23
23
  const [originalDashboard, setOriginalDashboard] = useState(undefined);
@@ -59,6 +59,7 @@ export const DashboardApp = (props)=>{
59
59
  dashboardName: dashboardResource.metadata.name,
60
60
  dashboardTitleComponent: dashboardTitleComponent,
61
61
  initialVariableIsSticky: initialVariableIsSticky,
62
+ isReadonly: isReadonly,
62
63
  onEditButtonClick: onEditButtonClick,
63
64
  onCancelButtonClick: onCancelButtonClick
64
65
  }),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useState } from 'react';\nimport { Box } from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { DashboardResource } from '@perses-dev/core';\nimport {\n PanelDrawer,\n Dashboard,\n PanelGroupDialog,\n DeletePanelGroupDialog,\n UnsavedChangesConfirmationDialog,\n DashboardToolbar,\n DeletePanelDialog,\n} from '../../components';\nimport { useDashboard, useEditMode } from '../../context';\n\nexport interface DashboardAppProps {\n dashboardResource: DashboardResource;\n dashboardTitleComponent?: JSX.Element;\n initialVariableIsSticky?: boolean;\n}\n\nexport const DashboardApp = (props: DashboardAppProps) => {\n const { dashboardResource, dashboardTitleComponent, initialVariableIsSticky } = props;\n const { setEditMode } = useEditMode();\n const { dashboard, setDashboard } = useDashboard();\n const [originalDashboard, setOriginalDashboard] = useState<DashboardResource | undefined>(undefined);\n const [isUnsavedDashboardDialogOpen, setUnsavedDashboardDialogIsOpen] = useState(false);\n\n const saveDashboard = async () => {\n setEditMode(false);\n setUnsavedDashboardDialogIsOpen(false);\n };\n\n const cancelDashboard = () => {\n // Reset to the original spec and exit edit mode\n if (originalDashboard) {\n setDashboard(originalDashboard);\n }\n setUnsavedDashboardDialogIsOpen(false);\n setEditMode(false);\n };\n\n const onEditButtonClick = () => {\n setEditMode(true);\n setOriginalDashboard(dashboard);\n };\n\n const onCancelButtonClick = () => {\n // check if dashboard has been modified\n if (JSON.stringify(dashboard) === JSON.stringify(originalDashboard)) {\n setEditMode(false);\n } else {\n setUnsavedDashboardDialogIsOpen(true);\n }\n };\n\n return (\n <Box\n sx={{\n flexGrow: 1,\n overflowX: 'hidden',\n overflowY: 'auto',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n <DashboardToolbar\n dashboardName={dashboardResource.metadata.name}\n dashboardTitleComponent={dashboardTitleComponent}\n initialVariableIsSticky={initialVariableIsSticky}\n onEditButtonClick={onEditButtonClick}\n onCancelButtonClick={onCancelButtonClick}\n />\n <Box sx={{ padding: (theme) => theme.spacing(2) }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <Dashboard />\n </ErrorBoundary>\n <PanelDrawer />\n <PanelGroupDialog />\n <DeletePanelGroupDialog />\n <DeletePanelDialog />\n <UnsavedChangesConfirmationDialog\n isOpen={isUnsavedDashboardDialogOpen}\n onSave={saveDashboard}\n onClose={cancelDashboard}\n />\n </Box>\n </Box>\n );\n};\n"],"names":["useState","Box","ErrorAlert","ErrorBoundary","PanelDrawer","Dashboard","PanelGroupDialog","DeletePanelGroupDialog","UnsavedChangesConfirmationDialog","DashboardToolbar","DeletePanelDialog","useDashboard","useEditMode","DashboardApp","props","dashboardResource","dashboardTitleComponent","initialVariableIsSticky","setEditMode","dashboard","setDashboard","originalDashboard","setOriginalDashboard","undefined","isUnsavedDashboardDialogOpen","setUnsavedDashboardDialogIsOpen","saveDashboard","cancelDashboard","onEditButtonClick","onCancelButtonClick","JSON","stringify","sx","flexGrow","overflowX","overflowY","display","flexDirection","dashboardName","metadata","name","padding","theme","spacing","FallbackComponent","isOpen","onSave","onClose"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6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Ae;sBACxB;;cACE;;MACF,CACN;AACJ,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useState } from 'react';\nimport { Box } from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { DashboardResource } from '@perses-dev/core';\nimport {\n PanelDrawer,\n Dashboard,\n PanelGroupDialog,\n DeletePanelGroupDialog,\n UnsavedChangesConfirmationDialog,\n DashboardToolbar,\n DeletePanelDialog,\n} from '../../components';\nimport { useDashboard, useEditMode } from '../../context';\n\nexport interface DashboardAppProps {\n dashboardResource: DashboardResource;\n dashboardTitleComponent?: JSX.Element;\n initialVariableIsSticky?: boolean;\n isReadonly: boolean;\n}\n\nexport const DashboardApp = (props: DashboardAppProps) => {\n const { dashboardResource, dashboardTitleComponent, initialVariableIsSticky, isReadonly } = props;\n const { setEditMode } = useEditMode();\n const { dashboard, setDashboard } = useDashboard();\n const [originalDashboard, setOriginalDashboard] = useState<DashboardResource | undefined>(undefined);\n const [isUnsavedDashboardDialogOpen, setUnsavedDashboardDialogIsOpen] = useState(false);\n\n const saveDashboard = async () => {\n setEditMode(false);\n setUnsavedDashboardDialogIsOpen(false);\n };\n\n const cancelDashboard = () => {\n // Reset to the original spec and exit edit mode\n if (originalDashboard) {\n setDashboard(originalDashboard);\n }\n setUnsavedDashboardDialogIsOpen(false);\n setEditMode(false);\n };\n\n const onEditButtonClick = () => {\n setEditMode(true);\n setOriginalDashboard(dashboard);\n };\n\n const onCancelButtonClick = () => {\n // check if dashboard has been modified\n if (JSON.stringify(dashboard) === JSON.stringify(originalDashboard)) {\n setEditMode(false);\n } else {\n setUnsavedDashboardDialogIsOpen(true);\n }\n };\n\n return (\n <Box\n sx={{\n flexGrow: 1,\n overflowX: 'hidden',\n overflowY: 'auto',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n <DashboardToolbar\n dashboardName={dashboardResource.metadata.name}\n dashboardTitleComponent={dashboardTitleComponent}\n initialVariableIsSticky={initialVariableIsSticky}\n isReadonly={isReadonly}\n onEditButtonClick={onEditButtonClick}\n onCancelButtonClick={onCancelButtonClick}\n />\n <Box sx={{ padding: (theme) => theme.spacing(2) }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <Dashboard />\n </ErrorBoundary>\n <PanelDrawer />\n <PanelGroupDialog />\n <DeletePanelGroupDialog />\n <DeletePanelDialog />\n <UnsavedChangesConfirmationDialog\n isOpen={isUnsavedDashboardDialogOpen}\n onSave={saveDashboard}\n onClose={cancelDashboard}\n />\n </Box>\n </Box>\n );\n};\n"],"names":["useState","Box","ErrorAlert","ErrorBoundary","PanelDrawer","Dashboard","PanelGroupDialog","DeletePanelGroupDialog","UnsavedChangesConfirmationDialog","DashboardToolbar","DeletePanelDialog","useDashboard","useEditMode","DashboardApp","props","dashboardResource","dashboardTitleComponent","initialVariableIsSticky","isReadonly","setEditMode","dashboard","setDashboard","originalDashboard","setOriginalDashboard","undefined","isUnsavedDashboardDialogOpen","setUnsavedDashboardDialogIsOpen","saveDashboard","cancelDashboard","onEditButtonClick","onCancelButtonClick","JSON","stringify","sx","flexGrow","overflowX","overflowY","display","flexDirection","dashboardName","metadata","name","padding","theme","spacing","FallbackComponent","isOpen","onSave","onClose"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE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AC,CAAC"}
@@ -7,6 +7,7 @@ export interface ViewDashboardProps extends Omit<BoxProps, 'children'> {
7
7
  datasourceApi: DatasourceStoreProviderProps['datasourceApi'];
8
8
  dashboardTitleComponent?: JSX.Element;
9
9
  initialVariableIsSticky?: boolean;
10
+ isReadonly: boolean;
10
11
  }
11
12
  /**
12
13
  * The View for displaying a Dashboard, along with the UI for selecting variable values.
@@ -1 +1 @@
1
- {"version":3,"file":"ViewDashboard.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/ViewDashboard.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAIL,4BAA4B,EAG7B,MAAM,eAAe,CAAC;AAGvB,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC;IACpE,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,aAAa,EAAE,4BAA4B,CAAC,eAAe,CAAC,CAAC;IAC7D,uBAAuB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACtC,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,eAoCtD"}
1
+ {"version":3,"file":"ViewDashboard.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/ViewDashboard.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,EAGL,4BAA4B,EAE7B,MAAM,eAAe,CAAC;AAGvB,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC;IACpE,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,aAAa,EAAE,4BAA4B,CAAC,eAAe,CAAC,CAAC;IAC7D,uBAAuB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACtC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,eA6CtD"}
@@ -13,12 +13,13 @@
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { Box } from '@mui/material';
15
15
  import { ErrorBoundary, ErrorAlert, combineSx } from '@perses-dev/components';
16
- import { TimeRangeProvider, TemplateVariableProvider, DashboardProvider, DatasourceStoreProvider, useInitialTimeRange } from '../../context';
16
+ import { TimeRangeProvider, useInitialTimeRange } from '@perses-dev/plugin-system';
17
+ import { TemplateVariableProvider, DashboardProvider, DatasourceStoreProvider } from '../../context';
17
18
  import { DashboardApp } from './DashboardApp';
18
19
  /**
19
20
  * The View for displaying a Dashboard, along with the UI for selecting variable values.
20
21
  */ export function ViewDashboard(props) {
21
- const { dashboardResource , datasourceApi , dashboardTitleComponent , initialVariableIsSticky , sx , ...others } = props;
22
+ const { dashboardResource , datasourceApi , dashboardTitleComponent , initialVariableIsSticky , isReadonly , sx , ...others } = props;
22
23
  const { spec } = dashboardResource;
23
24
  var _duration;
24
25
  const dashboardDuration = (_duration = spec.duration) !== null && _duration !== void 0 ? _duration : '1h';
@@ -49,7 +50,8 @@ import { DashboardApp } from './DashboardApp';
49
50
  children: /*#__PURE__*/ _jsx(DashboardApp, {
50
51
  dashboardResource: dashboardResource,
51
52
  dashboardTitleComponent: dashboardTitleComponent,
52
- initialVariableIsSticky: initialVariableIsSticky
53
+ initialVariableIsSticky: initialVariableIsSticky,
54
+ isReadonly: isReadonly
53
55
  })
54
56
  })
55
57
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/views/ViewDashboard/ViewDashboard.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, BoxProps } from '@mui/material';\nimport { DashboardResource } from '@perses-dev/core';\nimport { ErrorBoundary, ErrorAlert, combineSx } from '@perses-dev/components';\nimport {\n TimeRangeProvider,\n TemplateVariableProvider,\n DashboardProvider,\n DatasourceStoreProviderProps,\n DatasourceStoreProvider,\n useInitialTimeRange,\n} from '../../context';\nimport { DashboardApp } from './DashboardApp';\n\nexport interface ViewDashboardProps extends Omit<BoxProps, 'children'> {\n dashboardResource: DashboardResource;\n datasourceApi: DatasourceStoreProviderProps['datasourceApi'];\n dashboardTitleComponent?: JSX.Element;\n initialVariableIsSticky?: boolean;\n}\n\n/**\n * The View for displaying a Dashboard, along with the UI for selecting variable values.\n */\nexport function ViewDashboard(props: ViewDashboardProps) {\n const { dashboardResource, datasourceApi, dashboardTitleComponent, initialVariableIsSticky, sx, ...others } = props;\n const { spec } = dashboardResource;\n const dashboardDuration = spec.duration ?? '1h';\n const initialTimeRange = useInitialTimeRange(dashboardDuration);\n return (\n <DatasourceStoreProvider dashboardResource={dashboardResource} datasourceApi={datasourceApi}>\n <DashboardProvider initialState={{ dashboardResource }}>\n <TimeRangeProvider initialTimeRange={initialTimeRange} enabledURLParams={true}>\n <TemplateVariableProvider initialVariableDefinitions={spec.variables}>\n <Box\n sx={combineSx(\n {\n display: 'flex',\n width: '100%',\n height: '100%',\n position: 'relative',\n overflow: 'hidden',\n },\n sx\n )}\n {...others}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <DashboardApp\n dashboardResource={dashboardResource}\n dashboardTitleComponent={dashboardTitleComponent}\n initialVariableIsSticky={initialVariableIsSticky}\n />\n </ErrorBoundary>\n </Box>\n </TemplateVariableProvider>\n </TimeRangeProvider>\n </DashboardProvider>\n </DatasourceStoreProvider>\n );\n}\n"],"names":["Box","ErrorBoundary","ErrorAlert","combineSx","TimeRangeProvider","TemplateVariableProvider","DashboardProvider","DatasourceStoreProvider","useInitialTimeRange","DashboardApp","ViewDashboard","props","dashboardResource","datasourceApi","dashboardTitleComponent","initialVariableIsSticky","sx","others","spec","dashboardDuration","duration","initialTimeRange","initialState","enabledURLParams","initialVariableDefinitions","variables","display","width","height","position","overflow","FallbackComponent"],"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;AAE9C,SAASC,aAAa,EAAEC,UAAU,EAAEC,SAAS,QAAQ,wBAAwB,CAAC;AAC9E,SACEC,iBAAiB,EACjBC,wBAAwB,EACxBC,iBAAiB,EAEjBC,uBAAuB,EACvBC,mBAAmB,QACd,eAAe,CAAC;AACvB,SAASC,YAAY,QAAQ,gBAAgB,CAAC;AAS9C;;CAEC,GACD,OAAO,SAASC,aAAa,CAACC,KAAyB,EAAE;IACvD,MAAM,EAAEC,iBAAiB,CAAA,EAAEC,aAAa,CAAA,EAAEC,uBAAuB,CAAA,EAAEC,uBAAuB,CAAA,EAAEC,EAAE,CAAA,EAAE,GAAGC,MAAM,EAAE,GAAGN,KAAK,AAAC;IACpH,MAAM,EAAEO,IAAI,CAAA,EAAE,GAAGN,iBAAiB,AAAC;QACTM,SAAa;IAAvC,MAAMC,iBAAiB,GAAGD,CAAAA,SAAa,GAAbA,IAAI,CAACE,QAAQ,cAAbF,SAAa,cAAbA,SAAa,GAAI,IAAI,AAAC;IAChD,MAAMG,gBAAgB,GAAGb,mBAAmB,CAACW,iBAAiB,CAAC,AAAC;IAChE,qBACE,KAACZ,uBAAuB;QAACK,iBAAiB,EAAEA,iBAAiB;QAAEC,aAAa,EAAEA,aAAa;kBACzF,cAAA,KAACP,iBAAiB;YAACgB,YAAY,EAAE;gBAAEV,iBAAiB;aAAE;sBACpD,cAAA,KAACR,iBAAiB;gBAACiB,gBAAgB,EAAEA,gBAAgB;gBAAEE,gBAAgB,EAAE,IAAI;0BAC3E,cAAA,KAAClB,wBAAwB;oBAACmB,0BAA0B,EAAEN,IAAI,CAACO,SAAS;8BAClE,cAAA,KAACzB,GAAG;wBACFgB,EAAE,EAAEb,SAAS,CACX;4BACEuB,OAAO,EAAE,MAAM;4BACfC,KAAK,EAAE,MAAM;4BACbC,MAAM,EAAE,MAAM;4BACdC,QAAQ,EAAE,UAAU;4BACpBC,QAAQ,EAAE,QAAQ;yBACnB,EACDd,EAAE,CACH;wBACA,GAAGC,MAAM;kCAEV,cAAA,KAAChB,aAAa;4BAAC8B,iBAAiB,EAAE7B,UAAU;sCAC1C,cAAA,KAACO,YAAY;gCACXG,iBAAiB,EAAEA,iBAAiB;gCACpCE,uBAAuB,EAAEA,uBAAuB;gCAChDC,uBAAuB,EAAEA,uBAAuB;8BAChD;0BACY;sBACZ;kBACmB;cACT;UACF;MACI,CAC1B;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../../src/views/ViewDashboard/ViewDashboard.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, BoxProps } from '@mui/material';\nimport { DashboardResource } from '@perses-dev/core';\nimport { ErrorBoundary, ErrorAlert, combineSx } from '@perses-dev/components';\nimport { TimeRangeProvider, useInitialTimeRange } from '@perses-dev/plugin-system';\nimport {\n TemplateVariableProvider,\n DashboardProvider,\n DatasourceStoreProviderProps,\n DatasourceStoreProvider,\n} from '../../context';\nimport { DashboardApp } from './DashboardApp';\n\nexport interface ViewDashboardProps extends Omit<BoxProps, 'children'> {\n dashboardResource: DashboardResource;\n datasourceApi: DatasourceStoreProviderProps['datasourceApi'];\n dashboardTitleComponent?: JSX.Element;\n initialVariableIsSticky?: boolean;\n isReadonly: boolean;\n}\n\n/**\n * The View for displaying a Dashboard, along with the UI for selecting variable values.\n */\nexport function ViewDashboard(props: ViewDashboardProps) {\n const {\n dashboardResource,\n datasourceApi,\n dashboardTitleComponent,\n initialVariableIsSticky,\n isReadonly,\n sx,\n ...others\n } = props;\n const { spec } = dashboardResource;\n const dashboardDuration = spec.duration ?? '1h';\n const initialTimeRange = useInitialTimeRange(dashboardDuration);\n return (\n <DatasourceStoreProvider dashboardResource={dashboardResource} datasourceApi={datasourceApi}>\n <DashboardProvider initialState={{ dashboardResource }}>\n <TimeRangeProvider initialTimeRange={initialTimeRange} enabledURLParams={true}>\n <TemplateVariableProvider initialVariableDefinitions={spec.variables}>\n <Box\n sx={combineSx(\n {\n display: 'flex',\n width: '100%',\n height: '100%',\n position: 'relative',\n overflow: 'hidden',\n },\n sx\n )}\n {...others}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <DashboardApp\n dashboardResource={dashboardResource}\n dashboardTitleComponent={dashboardTitleComponent}\n initialVariableIsSticky={initialVariableIsSticky}\n isReadonly={isReadonly}\n />\n </ErrorBoundary>\n </Box>\n </TemplateVariableProvider>\n </TimeRangeProvider>\n </DashboardProvider>\n </DatasourceStoreProvider>\n );\n}\n"],"names":["Box","ErrorBoundary","ErrorAlert","combineSx","TimeRangeProvider","useInitialTimeRange","TemplateVariableProvider","DashboardProvider","DatasourceStoreProvider","DashboardApp","ViewDashboard","props","dashboardResource","datasourceApi","dashboardTitleComponent","initialVariableIsSticky","isReadonly","sx","others","spec","dashboardDuration","duration","initialTimeRange","initialState","enabledURLParams","initialVariableDefinitions","variables","display","width","height","position","overflow","FallbackComponent"],"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;AAE9C,SAASC,aAAa,EAAEC,UAAU,EAAEC,SAAS,QAAQ,wBAAwB,CAAC;AAC9E,SAASC,iBAAiB,EAAEC,mBAAmB,QAAQ,2BAA2B,CAAC;AACnF,SACEC,wBAAwB,EACxBC,iBAAiB,EAEjBC,uBAAuB,QAClB,eAAe,CAAC;AACvB,SAASC,YAAY,QAAQ,gBAAgB,CAAC;AAU9C;;CAEC,GACD,OAAO,SAASC,aAAa,CAACC,KAAyB,EAAE;IACvD,MAAM,EACJC,iBAAiB,CAAA,EACjBC,aAAa,CAAA,EACbC,uBAAuB,CAAA,EACvBC,uBAAuB,CAAA,EACvBC,UAAU,CAAA,EACVC,EAAE,CAAA,EACF,GAAGC,MAAM,EACV,GAAGP,KAAK,AAAC;IACV,MAAM,EAAEQ,IAAI,CAAA,EAAE,GAAGP,iBAAiB,AAAC;QACTO,SAAa;IAAvC,MAAMC,iBAAiB,GAAGD,CAAAA,SAAa,GAAbA,IAAI,CAACE,QAAQ,cAAbF,SAAa,cAAbA,SAAa,GAAI,IAAI,AAAC;IAChD,MAAMG,gBAAgB,GAAGjB,mBAAmB,CAACe,iBAAiB,CAAC,AAAC;IAChE,qBACE,KAACZ,uBAAuB;QAACI,iBAAiB,EAAEA,iBAAiB;QAAEC,aAAa,EAAEA,aAAa;kBACzF,cAAA,KAACN,iBAAiB;YAACgB,YAAY,EAAE;gBAAEX,iBAAiB;aAAE;sBACpD,cAAA,KAACR,iBAAiB;gBAACkB,gBAAgB,EAAEA,gBAAgB;gBAAEE,gBAAgB,EAAE,IAAI;0BAC3E,cAAA,KAAClB,wBAAwB;oBAACmB,0BAA0B,EAAEN,IAAI,CAACO,SAAS;8BAClE,cAAA,KAAC1B,GAAG;wBACFiB,EAAE,EAAEd,SAAS,CACX;4BACEwB,OAAO,EAAE,MAAM;4BACfC,KAAK,EAAE,MAAM;4BACbC,MAAM,EAAE,MAAM;4BACdC,QAAQ,EAAE,UAAU;4BACpBC,QAAQ,EAAE,QAAQ;yBACnB,EACDd,EAAE,CACH;wBACA,GAAGC,MAAM;kCAEV,cAAA,KAACjB,aAAa;4BAAC+B,iBAAiB,EAAE9B,UAAU;sCAC1C,cAAA,KAACO,YAAY;gCACXG,iBAAiB,EAAEA,iBAAiB;gCACpCE,uBAAuB,EAAEA,uBAAuB;gCAChDC,uBAAuB,EAAEA,uBAAuB;gCAChDC,UAAU,EAAEA,UAAU;8BACtB;0BACY;sBACZ;kBACmB;cACT;UACF;MACI,CAC1B;AACJ,CAAC"}
@@ -13,7 +13,8 @@
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { screen } from '@testing-library/react';
15
15
  import userEvent from '@testing-library/user-event';
16
- import { DashboardProvider, TemplateVariableProvider, TimeRangeProvider } from '../../../context';
16
+ import { TimeRangeProvider } from '@perses-dev/plugin-system';
17
+ import { DashboardProvider, TemplateVariableProvider } from '../../../context';
17
18
  import { getTestDashboard, renderWithContext } from '../../../test';
18
19
  import { DashboardApp } from '../DashboardApp';
19
20
  describe('Panel Groups', ()=>{
@@ -29,7 +30,8 @@ describe('Panel Groups', ()=>{
29
30
  isEditMode: true
30
31
  },
31
32
  children: /*#__PURE__*/ _jsx(DashboardApp, {
32
- dashboardResource: getTestDashboard()
33
+ dashboardResource: getTestDashboard(),
34
+ isReadonly: false
33
35
  })
34
36
  })
35
37
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/views/ViewDashboard/tests/panelGroups.test.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { DashboardProvider, TemplateVariableProvider, TimeRangeProvider } from '../../../context';\nimport { getTestDashboard, renderWithContext } from '../../../test';\nimport { DashboardApp } from '../DashboardApp';\n\ndescribe('Panel Groups', () => {\n const renderDashboard = () => {\n renderWithContext(\n <TimeRangeProvider initialTimeRange={{ pastDuration: '30m' }}>\n <TemplateVariableProvider>\n <DashboardProvider initialState={{ dashboardResource: getTestDashboard(), isEditMode: true }}>\n <DashboardApp dashboardResource={getTestDashboard()} />\n </DashboardProvider>\n </TemplateVariableProvider>\n </TimeRangeProvider>\n );\n };\n it('should delete panel', () => {\n renderDashboard();\n const panelTitle = 'CPU';\n const deletePanelButton = screen.getByLabelText(`delete panel ${panelTitle}`);\n userEvent.click(deletePanelButton);\n screen.getByText('Delete Panel');\n const deleteButton = screen.getByText('Delete');\n userEvent.click(deleteButton);\n\n // The panel should disappear\n const deletedPanel = screen.queryByText(panelTitle);\n expect(deletedPanel).not.toBeInTheDocument();\n });\n\n it('should only delete panel from panel group if panel is not referenced more than once', () => {\n renderDashboard();\n\n const panelTitle = 'Disk I/O Utilization';\n const panels = screen.getAllByText(panelTitle);\n expect(panels).toHaveLength(2);\n\n const deletePanelButton = screen.getAllByLabelText(`delete panel ${panelTitle}`)[0];\n if (deletePanelButton === undefined) throw new Error('Missing delete button');\n\n userEvent.click(deletePanelButton);\n screen.getByText('Delete Panel');\n const deleteButton = screen.getByText('Delete');\n userEvent.click(deleteButton);\n\n // The deleted panel should still be on screen in the other group\n const deletedPanel = screen.queryByText(panelTitle);\n expect(deletedPanel).toBeInTheDocument();\n });\n\n it('should swap panels', () => {\n renderDashboard();\n\n // should move panel down\n const groupTitle1 = 'CPU Stats';\n const moveGroupDownBtn = screen.getByLabelText(`move group ${groupTitle1} down`);\n userEvent.click(moveGroupDownBtn);\n\n // should move panel up\n const groupTitle2 = 'Disk Stats';\n const moveGroupUpBtn = screen.getByLabelText(`move group ${groupTitle2} up`);\n userEvent.click(moveGroupUpBtn);\n\n /* TODO: Figure out how to test this visually without coupling to the store\n const layouts = storeApi.getState().layouts;\n expect(layouts[0]?.title).toBe(undefined);\n expect(layouts[1]?.title).toBe('Disk Stats');\n expect(layouts[2]?.title).toBe('CPU Stats');\n */\n });\n\n it('should delete a panel group', () => {\n renderDashboard();\n const groupTitle = 'CPU Stats';\n const deleteGroupIcon = screen.getByLabelText(`delete group ${groupTitle}`);\n userEvent.click(deleteGroupIcon);\n screen.getByText('Delete Panel Group');\n const deleteButton = screen.getByText('Delete');\n userEvent.click(deleteButton);\n\n // should remove group\n const deletedGroup = screen.queryByText(groupTitle);\n expect(deletedGroup).not.toBeInTheDocument();\n\n // CPU panel should be completely gone since it wasn't in any other group\n let panel = screen.queryByText('CPU');\n expect(panel).not.toBeInTheDocument();\n\n // A DiskIO panel should still be present in the other group that wasn't deleted\n panel = screen.queryByText('Disk I/O Utilization');\n expect(panel).toBeInTheDocument();\n });\n});\n"],"names":["screen","userEvent","DashboardProvider","TemplateVariableProvider","TimeRangeProvider","getTestDashboard","renderWithContext","DashboardApp","describe","renderDashboard","initialTimeRange","pastDuration","initialState","dashboardResource","isEditMode","it","panelTitle","deletePanelButton","getByLabelText","click","getByText","deleteButton","deletedPanel","queryByText","expect","not","toBeInTheDocument","panels","getAllByText","toHaveLength","getAllByLabelText","undefined","Error","groupTitle1","moveGroupDownBtn","groupTitle2","moveGroupUpBtn","groupTitle","deleteGroupIcon","deletedGroup","panel"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C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ACd,iBAAiB,EAAE,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../../src/views/ViewDashboard/tests/panelGroups.test.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { TimeRangeProvider } from '@perses-dev/plugin-system';\nimport { DashboardProvider, TemplateVariableProvider } from '../../../context';\nimport { getTestDashboard, renderWithContext } from '../../../test';\nimport { DashboardApp } from '../DashboardApp';\n\ndescribe('Panel Groups', () => {\n const renderDashboard = () => {\n renderWithContext(\n <TimeRangeProvider initialTimeRange={{ pastDuration: '30m' }}>\n <TemplateVariableProvider>\n <DashboardProvider initialState={{ dashboardResource: getTestDashboard(), isEditMode: true }}>\n <DashboardApp dashboardResource={getTestDashboard()} isReadonly={false} />\n </DashboardProvider>\n </TemplateVariableProvider>\n </TimeRangeProvider>\n );\n };\n it('should delete panel', () => {\n renderDashboard();\n const panelTitle = 'CPU';\n const deletePanelButton = screen.getByLabelText(`delete panel ${panelTitle}`);\n userEvent.click(deletePanelButton);\n screen.getByText('Delete Panel');\n const deleteButton = screen.getByText('Delete');\n userEvent.click(deleteButton);\n\n // The panel should disappear\n const deletedPanel = screen.queryByText(panelTitle);\n expect(deletedPanel).not.toBeInTheDocument();\n });\n\n it('should only delete panel from panel group if panel is not referenced more than once', () => {\n renderDashboard();\n\n const panelTitle = 'Disk I/O Utilization';\n const panels = screen.getAllByText(panelTitle);\n expect(panels).toHaveLength(2);\n\n const deletePanelButton = screen.getAllByLabelText(`delete panel ${panelTitle}`)[0];\n if (deletePanelButton === undefined) throw new Error('Missing delete button');\n\n userEvent.click(deletePanelButton);\n screen.getByText('Delete Panel');\n const deleteButton = screen.getByText('Delete');\n userEvent.click(deleteButton);\n\n // The deleted panel should still be on screen in the other group\n const deletedPanel = screen.queryByText(panelTitle);\n expect(deletedPanel).toBeInTheDocument();\n });\n\n it('should swap panels', () => {\n renderDashboard();\n\n // should move panel down\n const groupTitle1 = 'CPU Stats';\n const moveGroupDownBtn = screen.getByLabelText(`move group ${groupTitle1} down`);\n userEvent.click(moveGroupDownBtn);\n\n // should move panel up\n const groupTitle2 = 'Disk Stats';\n const moveGroupUpBtn = screen.getByLabelText(`move group ${groupTitle2} up`);\n userEvent.click(moveGroupUpBtn);\n\n /* TODO: Figure out how to test this visually without coupling to the store\n const layouts = storeApi.getState().layouts;\n expect(layouts[0]?.title).toBe(undefined);\n expect(layouts[1]?.title).toBe('Disk Stats');\n expect(layouts[2]?.title).toBe('CPU Stats');\n */\n });\n\n it('should delete a panel group', () => {\n renderDashboard();\n const groupTitle = 'CPU Stats';\n const deleteGroupIcon = screen.getByLabelText(`delete group ${groupTitle}`);\n userEvent.click(deleteGroupIcon);\n screen.getByText('Delete Panel Group');\n const deleteButton = screen.getByText('Delete');\n userEvent.click(deleteButton);\n\n // should remove group\n const deletedGroup = screen.queryByText(groupTitle);\n expect(deletedGroup).not.toBeInTheDocument();\n\n // CPU panel should be completely gone since it wasn't in any other group\n let panel = screen.queryByText('CPU');\n expect(panel).not.toBeInTheDocument();\n\n // A DiskIO panel should still be present in the other group that wasn't deleted\n panel = screen.queryByText('Disk I/O Utilization');\n expect(panel).toBeInTheDocument();\n });\n});\n"],"names":["screen","userEvent","TimeRangeProvider","DashboardProvider","TemplateVariableProvider","getTestDashboard","renderWithContext","DashboardApp","describe","renderDashboard","initialTimeRange","pastDuration","initialState","dashboardResource","isEditMode","isReadonly","it","panelTitle","deletePanelButton","getByLabelText","click","getByText","deleteButton","deletedPanel","queryByText","expect","not","toBeInTheDocument","panels","getAllByText","toHaveLength","getAllByLabelText","undefined","Error","groupTitle1","moveGroupDownBtn","groupTitle2","moveGroupUpBtn","groupTitle","deleteGroupIcon","deletedGroup","panel"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,MAAM,QAAQ,wBAAwB,CAAC;AAChD,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AACpD,SAASC,iBAAiB,QAAQ,2BAA2B,CAAC;AAC9D,SAASC,iBAAiB,EAAEC,wBAAwB,QAAQ,kBAAkB,CAAC;AAC/E,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,eAAe,CAAC;AACpE,SAASC,YAAY,QAAQ,iBAAiB,CAAC;AAE/CC,QAAQ,CAAC,cAAc,EAAE,IAAM;IAC7B,MAAMC,eAAe,GAAG,IAAM;QAC5BH,iBAAiB,eACf,KAACJ,iBAAiB;YAACQ,gBAAgB,EAAE;gBAAEC,YAAY,EAAE,KAAK;aAAE;sBAC1D,cAAA,KAACP,wBAAwB;0BACvB,cAAA,KAACD,iBAAiB;oBAACS,YAAY,EAAE;wBAAEC,iBAAiB,EAAER,gBAAgB,EAAE;wBAAES,UAAU,EAAE,IAAI;qBAAE;8BAC1F,cAAA,KAACP,YAAY;wBAACM,iBAAiB,EAAER,gBAAgB,EAAE;wBAAEU,UAAU,EAAE,KAAK;sBAAI;kBACxD;cACK;UACT,CACrB,CAAC;IACJ,CAAC,AAAC;IACFC,EAAE,CAAC,qBAAqB,EAAE,IAAM;QAC9BP,eAAe,EAAE,CAAC;QAClB,MAAMQ,UAAU,GAAG,KAAK,AAAC;QACzB,MAAMC,iBAAiB,GAAGlB,MAAM,CAACmB,cAAc,CAAC,CAAC,aAAa,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,yEAAyE;QACzE,IAAIc,KAAK,GAAGzC,MAAM,CAACwB,WAAW,CAAC,KAAK,CAAC,AAAC;QACtCC,MAAM,CAACgB,KAAK,CAAC,CAACf,GAAG,CAACC,iBAAiB,EAAE,CAAC;QAEtC,gFAAgF;QAChFc,KAAK,GAAGzC,MAAM,CAACwB,WAAW,CAAC,sBAAsB,CAAC,CAAC;QACnDC,MAAM,CAACgB,KAAK,CAAC,CAACd,iBAAiB,EAAE,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/dashboards",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "The dashboards feature in Perses",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -28,9 +28,9 @@
28
28
  "lint:fix": "eslint --fix src --ext .ts,.tsx"
29
29
  },
30
30
  "dependencies": {
31
- "@perses-dev/components": "^0.17.0",
32
- "@perses-dev/core": "^0.17.0",
33
- "@perses-dev/plugin-system": "^0.17.0",
31
+ "@perses-dev/components": "^0.18.0",
32
+ "@perses-dev/core": "^0.18.0",
33
+ "@perses-dev/plugin-system": "^0.18.0",
34
34
  "@types/react-grid-layout": "^1.3.2",
35
35
  "date-fns": "^2.28.0",
36
36
  "immer": "^9.0.15",
@@ -46,7 +46,7 @@
46
46
  "intersection-observer": "^0.12.2"
47
47
  },
48
48
  "peerDependencies": {
49
- "@mui/material": "^5.6.0",
49
+ "@mui/material": "^5.10.0",
50
50
  "@tanstack/react-query": "^4.7.1",
51
51
  "react": "^17.0.2 || ^18.0.0",
52
52
  "react-dom": "^17.0.2 || ^18.0.0"
@@ -1,91 +0,0 @@
1
- // Copyright 2022 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "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
- TimeRangeProvider: ()=>TimeRangeProvider,
25
- useDashboardTimeRange: ()=>useDashboardTimeRange
26
- });
27
- const _jsxRuntime = require("react/jsx-runtime");
28
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
29
- const _pluginSystem = require("@perses-dev/plugin-system");
30
- const _queryParams = require("./query-params");
31
- function _getRequireWildcardCache(nodeInterop) {
32
- if (typeof WeakMap !== "function") return null;
33
- var cacheBabelInterop = new WeakMap();
34
- var cacheNodeInterop = new WeakMap();
35
- return (_getRequireWildcardCache = function(nodeInterop) {
36
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
37
- })(nodeInterop);
38
- }
39
- function _interopRequireWildcard(obj, nodeInterop) {
40
- if (!nodeInterop && obj && obj.__esModule) {
41
- return obj;
42
- }
43
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
44
- return {
45
- default: obj
46
- };
47
- }
48
- var cache = _getRequireWildcardCache(nodeInterop);
49
- if (cache && cache.has(obj)) {
50
- return cache.get(obj);
51
- }
52
- var newObj = {};
53
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
54
- for(var key in obj){
55
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
56
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
57
- if (desc && (desc.get || desc.set)) {
58
- Object.defineProperty(newObj, key, desc);
59
- } else {
60
- newObj[key] = obj[key];
61
- }
62
- }
63
- }
64
- newObj.default = obj;
65
- if (cache) {
66
- cache.set(obj, newObj);
67
- }
68
- return newObj;
69
- }
70
- function TimeRangeProvider(props) {
71
- const { initialTimeRange , enabledURLParams , children } = props;
72
- const { timeRange , setTimeRange } = (0, _queryParams.useSetTimeRangeParams)(initialTimeRange, enabledURLParams);
73
- const ctx = (0, _react.useMemo)(()=>({
74
- timeRange,
75
- setTimeRange
76
- }), [
77
- timeRange,
78
- setTimeRange
79
- ]);
80
- return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.TimeRangeContext.Provider, {
81
- value: ctx,
82
- children: children
83
- });
84
- }
85
- function useDashboardTimeRange() {
86
- const { timeRange , setTimeRange } = (0, _pluginSystem.useTimeRangeContext)();
87
- return {
88
- timeRange,
89
- setTimeRange
90
- };
91
- }
@@ -1,29 +0,0 @@
1
- // Copyright 2022 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- _exportStar(require("./TimeRangeProvider"), exports);
18
- _exportStar(require("./query-params"), exports);
19
- function _exportStar(from, to) {
20
- Object.keys(from).forEach(function(k) {
21
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
22
- enumerable: true,
23
- get: function() {
24
- return from[k];
25
- }
26
- });
27
- });
28
- return from;
29
- }
@@ -1,157 +0,0 @@
1
- // Copyright 2022 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "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
- encodeTimeRangeValue: ()=>encodeTimeRangeValue,
25
- decodeTimeRangeValue: ()=>decodeTimeRangeValue,
26
- TimeRangeParam: ()=>TimeRangeParam,
27
- timeRangeQueryConfig: ()=>timeRangeQueryConfig,
28
- useInitialTimeRange: ()=>useInitialTimeRange,
29
- useSetTimeRangeParams: ()=>useSetTimeRangeParams
30
- });
31
- const _react = require("react");
32
- const _useQueryParams = require("use-query-params");
33
- const _dateFns = require("date-fns");
34
- const _core = require("@perses-dev/core");
35
- /* Interprets an encoded string and returns either the string or null/undefined if not available */ function getEncodedValue(input, allowEmptyString) {
36
- if (input == null) {
37
- return input;
38
- }
39
- // '' or []
40
- if (input.length === 0 && (!allowEmptyString || allowEmptyString && input !== '')) {
41
- return null;
42
- }
43
- const str = input instanceof Array ? input[0] : input;
44
- if (str == null) {
45
- return str;
46
- }
47
- if (!allowEmptyString && str === '') {
48
- return null;
49
- }
50
- return str;
51
- }
52
- function encodeTimeRangeValue(timeOptionValue) {
53
- if (!timeOptionValue) {
54
- return timeOptionValue;
55
- }
56
- if (typeof timeOptionValue === 'string') {
57
- if ((0, _core.isDurationString)(timeOptionValue)) {
58
- return timeOptionValue;
59
- }
60
- }
61
- return ((0, _dateFns.getUnixTime)(timeOptionValue) * 1000).toString();
62
- }
63
- function decodeTimeRangeValue(input) {
64
- const paramString = getEncodedValue(input);
65
- if (paramString == null) return paramString;
66
- return (0, _core.isDurationString)(paramString) ? paramString : new Date(Number(paramString));
67
- }
68
- const TimeRangeParam = {
69
- encode: encodeTimeRangeValue,
70
- decode: decodeTimeRangeValue,
71
- equals: (valueA, valueB)=>{
72
- if (valueA === valueB) return true;
73
- if (valueA == null || valueB == null) return valueA === valueB;
74
- return valueA.valueOf() === valueB.valueOf();
75
- }
76
- };
77
- const timeRangeQueryConfig = {
78
- start: TimeRangeParam,
79
- end: TimeRangeParam
80
- };
81
- function useInitialTimeRange(dashboardDuration) {
82
- const [query] = (0, _useQueryParams.useQueryParams)(timeRangeQueryConfig);
83
- const { start , end } = query;
84
- return (0, _react.useMemo)(()=>{
85
- let initialTimeRange = {
86
- pastDuration: dashboardDuration
87
- };
88
- if (!start) {
89
- return initialTimeRange;
90
- }
91
- const startStr = start.toString();
92
- if ((0, _core.isDurationString)(startStr)) {
93
- initialTimeRange = {
94
- pastDuration: startStr
95
- };
96
- } else if ((0, _dateFns.isDate)(start) && (0, _dateFns.isDate)(end)) {
97
- initialTimeRange = {
98
- start: start,
99
- end: end
100
- };
101
- }
102
- return initialTimeRange;
103
- }, [
104
- start,
105
- end,
106
- dashboardDuration
107
- ]);
108
- }
109
- function useSetTimeRangeParams(initialTimeRange, enabledURLParams = true) {
110
- const [query, setQuery] = (0, _useQueryParams.useQueryParams)(timeRangeQueryConfig);
111
- // determine whether initial param had previously been populated to fix back btn
112
- const [paramsLoaded, setParamsLoaded] = (0, _react.useState)(false);
113
- // optional fallback when app does not want query string as source of truth
114
- // this occurs when enabledURLParams is set to false on TimeRangeProvider
115
- const [timeRangeState, setTimeRangeState] = (0, _react.useState)(initialTimeRange);
116
- const { start } = query;
117
- (0, _react.useEffect)(()=>{
118
- // when dashboard loaded with no params, default to dashboard duration
119
- if (enabledURLParams && !paramsLoaded && !start) {
120
- if ((0, _core.isRelativeTimeRange)(initialTimeRange)) {
121
- setQuery({
122
- start: initialTimeRange.pastDuration,
123
- end: undefined
124
- });
125
- setParamsLoaded(true);
126
- }
127
- }
128
- }, [
129
- initialTimeRange,
130
- enabledURLParams,
131
- paramsLoaded,
132
- start,
133
- setQuery
134
- ]);
135
- const setTimeRange = (0, _react.useCallback)((value)=>{
136
- if ((0, _core.isRelativeTimeRange)(value)) {
137
- setQuery({
138
- start: value.pastDuration,
139
- end: undefined
140
- });
141
- } else {
142
- setQuery(value);
143
- }
144
- }, [
145
- setQuery
146
- ]);
147
- if (!enabledURLParams) {
148
- return {
149
- timeRange: timeRangeState,
150
- setTimeRange: setTimeRangeState
151
- };
152
- }
153
- return {
154
- timeRange: initialTimeRange,
155
- setTimeRange: setTimeRange
156
- };
157
- }
@@ -1,19 +0,0 @@
1
- import React from 'react';
2
- import { TimeRangeValue } from '@perses-dev/core';
3
- export interface TimeRangeProviderProps {
4
- initialTimeRange: TimeRangeValue;
5
- enabledURLParams?: boolean;
6
- children?: React.ReactNode;
7
- }
8
- /**
9
- * Provider implementation that supplies the time range state at runtime.
10
- */
11
- export declare function TimeRangeProvider(props: TimeRangeProviderProps): JSX.Element;
12
- /**
13
- * Internal version of time range hook to get all supported values
14
- */
15
- export declare function useDashboardTimeRange(): {
16
- timeRange: TimeRangeValue;
17
- setTimeRange: (value: TimeRangeValue) => void;
18
- };
19
- //# sourceMappingURL=TimeRangeProvider.d.ts.map