@perses-dev/dashboards 0.54.0-beta.3 → 0.54.0-beta.5

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.
@@ -78,23 +78,26 @@ function convertLayoutsToPanelGroups(layouts) {
78
78
  const itemLayouts = [];
79
79
  const itemPanelKeys = {};
80
80
  // Split layout information from panel keys to make it easier to update just layouts on move/resize of panels
81
- for (const item of layout.spec.items){
82
- const panelGroupLayoutId = (0, _common.generateId)().toString();
83
- itemLayouts.push({
84
- i: panelGroupLayoutId,
85
- w: item.width,
86
- h: item.height,
87
- x: item.x,
88
- y: item.y
89
- });
90
- itemPanelKeys[panelGroupLayoutId] = (0, _spec.getPanelKeyFromRef)(item.content);
81
+ if ('items' in layout.spec) {
82
+ for (const item of layout.spec.items){
83
+ const panelGroupLayoutId = (0, _common.generateId)().toString();
84
+ itemLayouts.push({
85
+ i: panelGroupLayoutId,
86
+ w: item.width,
87
+ h: item.height,
88
+ x: item.x,
89
+ y: item.y
90
+ });
91
+ itemPanelKeys[panelGroupLayoutId] = (0, _spec.getPanelKeyFromRef)(item.content);
92
+ }
91
93
  }
92
94
  // Create the panel group and keep track of the ID order
95
+ const repeatVariable = 'repeatVariable' in layout.spec ? layout.spec.repeatVariable : undefined;
93
96
  const panelGroupId = (0, _common.generateId)();
94
97
  panelGroups[panelGroupId] = {
95
98
  id: panelGroupId,
96
99
  isCollapsed: layout.spec.display?.collapse?.open === false,
97
- repeatVariable: layout.spec.repeatVariable,
100
+ repeatVariable,
98
101
  title: layout.spec.display?.title,
99
102
  itemLayouts,
100
103
  itemPanelKeys
@@ -16,6 +16,7 @@ Object.defineProperty(exports, "__esModule", {
16
16
  });
17
17
  _export_star(require("./DashboardResource"), exports);
18
18
  _export_star(require("./PanelGroupDefinition"), exports);
19
+ _export_star(require("./VariableDefinition"), exports);
19
20
  function _export_star(from, to) {
20
21
  Object.keys(from).forEach(function(k) {
21
22
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
@@ -1,7 +1,8 @@
1
1
  import type { StoreApi } from 'zustand';
2
2
  import { ReactElement, ReactNode } from 'react';
3
3
  import { Display, DurationString, DatasourceSpec } from '@perses-dev/spec';
4
- import { DashboardMetaData, DashboardKind, DashboardResource } from '../../model/DashboardResource';
4
+ import { ProjectMetadata } from '@perses-dev/client';
5
+ import { DashboardKind, DashboardResource } from '../../model/DashboardResource';
5
6
  import { PanelGroupEditorSlice } from './panel-group-editor-slice';
6
7
  import { PanelGroupSlice } from './panel-group-slice';
7
8
  import { PanelEditorSlice } from './panel-editor-slice';
@@ -19,7 +20,7 @@ export interface DashboardStoreState extends PanelGroupSlice, PanelSlice, PanelG
19
20
  setEditMode: (isEditMode: boolean) => void;
20
21
  setDashboard: (dashboard: DashboardResource) => void;
21
22
  kind: DashboardKind;
22
- metadata: DashboardMetaData;
23
+ metadata: ProjectMetadata;
23
24
  duration: DurationString;
24
25
  refreshInterval: DurationString;
25
26
  display?: Display;
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardProvider.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/DashboardProvider.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAIxC,OAAO,EAAiB,YAAY,EAAE,SAAS,EAAgD,MAAM,OAAO,CAAC;AAC7G,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE3E,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAEpG,OAAO,EAA+B,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,EAAsD,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC1G,OAAO,EAA0B,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAoB,UAAU,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAA+B,qBA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AS,CAAC;CACtB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,GAAG,YAAY,CA0B7E"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/DashboardProvider.tsx"],"sourcesContent":["// Copyright 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 { createStore } from 'zustand';\nimport { useStoreWithEqualityFn } from 'zustand/traditional';\nimport type { StoreApi } from 'zustand';\nimport { devtools } from 'zustand/middleware';\nimport { immer } from 'zustand/middleware/immer';\nimport { shallow } from 'zustand/shallow';\nimport { createContext, ReactElement, ReactNode, useCallback, useContext, useEffect, useState } from 'react';\nimport { Display, DurationString, DatasourceSpec } from '@perses-dev/spec';\nimport { usePlugin, usePluginRegistry } from '@perses-dev/plugin-system';\nimport { DashboardMetaData, DashboardKind, DashboardResource } from '../../model/DashboardResource';\nimport { DEFAULT_REFRESH_INTERVAL } from '../../constants';\nimport { createPanelGroupEditorSlice, PanelGroupEditorSlice } from './panel-group-editor-slice';\nimport { convertLayoutsToPanelGroups, createPanelGroupSlice, PanelGroupSlice } from './panel-group-slice';\nimport { createPanelEditorSlice, PanelEditorSlice } from './panel-editor-slice';\nimport { createPanelSlice, PanelSlice } from './panel-slice';\nimport { createDeletePanelGroupSlice, DeletePanelGroupSlice } from './delete-panel-group-slice';\nimport { createDeletePanelSlice, DeletePanelSlice } from './delete-panel-slice';\nimport { createDiscardChangesDialogSlice, DiscardChangesConfirmationDialogSlice } from './discard-changes-dialog-slice';\nimport { createSaveChangesDialogSlice, SaveChangesConfirmationDialogSlice } from './save-changes-dialog-slice';\nimport { createDuplicatePanelSlice, DuplicatePanelSlice } from './duplicate-panel-slice';\nimport { createEditJsonDialogSlice, EditJsonDialogSlice } from './edit-json-dialog-slice';\nimport { createPanelDefinition } from './common';\nimport { createViewPanelSlice, ViewPanelSlice, VirtualPanelRef } from './view-panel-slice';\nimport { createLinksSlice, LinksSlice } from './links-slice';\n\nexport interface DashboardStoreState\n extends\n PanelGroupSlice,\n PanelSlice,\n PanelGroupEditorSlice,\n DeletePanelGroupSlice,\n PanelEditorSlice,\n DeletePanelSlice,\n DiscardChangesConfirmationDialogSlice,\n DuplicatePanelSlice,\n EditJsonDialogSlice,\n SaveChangesConfirmationDialogSlice,\n ViewPanelSlice,\n LinksSlice {\n isEditMode: boolean;\n setEditMode: (isEditMode: boolean) => void;\n setDashboard: (dashboard: DashboardResource) => void;\n kind: DashboardKind;\n metadata: DashboardMetaData;\n duration: DurationString;\n refreshInterval: DurationString;\n display?: Display;\n datasources?: Record<string, DatasourceSpec>;\n ttl?: DurationString;\n}\n\nexport const DashboardContext = createContext<StoreApi<DashboardStoreState> | undefined>(undefined);\n\nexport function useDashboardStore<T>(selector: (state: DashboardStoreState) => T): T {\n const store = useContext(DashboardContext);\n if (store === undefined) {\n throw new Error('No DashboardContext found. Did you forget a Provider?');\n }\n return useStoreWithEqualityFn(store, selector, shallow);\n}\n\nexport interface DashboardStoreProps {\n dashboardResource: DashboardResource;\n isEditMode?: boolean;\n viewPanelRef?: VirtualPanelRef;\n setViewPanelRef?: (viewPanelRef: VirtualPanelRef | undefined) => void;\n}\n\nexport interface DashboardProviderProps {\n initialState: DashboardStoreProps;\n children?: ReactNode;\n}\n\nexport function DashboardProvider(props: DashboardProviderProps): ReactElement {\n // Prevent calling createDashboardStore every time it rerenders\n const createDashboardStore = useCallback(initStore, [props]);\n const [store] = useState(createDashboardStore(props));\n\n // load plugin to retrieve initial spec if default panel kind is defined\n const { defaultPluginKinds } = usePluginRegistry();\n const defaultPanelKind = defaultPluginKinds?.['Panel'] ?? '';\n const { data: plugin } = usePlugin('Panel', defaultPanelKind);\n\n useEffect(() => {\n if (plugin === undefined) return;\n const defaultPanelSpec = plugin.createInitialOptions ? plugin.createInitialOptions() : {};\n // set default panel kind, spec, and queries for add panel editor\n store.setState({\n initialValues: {\n panelDefinition: createPanelDefinition(defaultPanelKind, defaultPanelSpec),\n },\n });\n }, [plugin, store, defaultPanelKind]);\n\n return (\n <DashboardContext.Provider value={store as StoreApi<DashboardStoreState>}>\n {props.children}\n </DashboardContext.Provider>\n );\n}\n\nfunction initStore(props: DashboardProviderProps): StoreApi<DashboardStoreState> {\n const {\n initialState: { dashboardResource, isEditMode, viewPanelRef, setViewPanelRef },\n } = props;\n\n const {\n kind,\n metadata,\n spec: { display, duration, refreshInterval = DEFAULT_REFRESH_INTERVAL, datasources, layouts = [], panels = {} },\n } = dashboardResource;\n\n const links = dashboardResource.spec.links ?? [];\n\n const ttl = 'ttl' in dashboardResource.spec ? (dashboardResource.spec.ttl as DurationString) : undefined;\n\n const store = createStore<DashboardStoreState>()(\n immer(\n devtools((...args) => {\n const [set] = args;\n return {\n /* Groups */\n ...createPanelGroupSlice(layouts)(...args),\n ...createPanelGroupEditorSlice(...args),\n ...createDeletePanelGroupSlice(...args),\n /* Panels */\n ...createPanelSlice(panels)(...args),\n ...createPanelEditorSlice()(...args),\n ...createDeletePanelSlice()(...args),\n ...createDuplicatePanelSlice()(...args),\n ...createViewPanelSlice(viewPanelRef, setViewPanelRef)(...args),\n /* Links */\n ...createLinksSlice(links)(...args),\n /* General */\n ...createDiscardChangesDialogSlice(...args),\n ...createEditJsonDialogSlice(...args),\n ...createSaveChangesDialogSlice(...args),\n kind,\n metadata,\n display,\n duration,\n refreshInterval,\n datasources,\n ttl,\n isEditMode: !!isEditMode,\n setEditMode: (isEditMode: boolean): void => {\n set({ isEditMode });\n },\n setDashboard: ({\n kind,\n metadata,\n spec: { display, panels = {}, layouts = [], duration, refreshInterval, datasources = {}, links = [] },\n }): void => {\n set((state) => {\n state.kind = kind;\n state.metadata = metadata;\n state.display = display;\n state.panels = panels;\n const { panelGroups, panelGroupOrder } = convertLayoutsToPanelGroups(layouts);\n state.panelGroups = panelGroups;\n state.panelGroupOrder = panelGroupOrder;\n state.duration = duration;\n state.refreshInterval = refreshInterval ?? DEFAULT_REFRESH_INTERVAL;\n state.datasources = datasources;\n state.links = links;\n // TODO: add ttl here to e.g allow edition from JSON view, but probably requires quite some refactoring\n });\n },\n };\n })\n )\n );\n\n return store;\n}\n"],"names":["createStore","useStoreWithEqualityFn","devtools","immer","shallow","createContext","useCallback","useContext","useEffect","useState","usePlugin","usePluginRegistry","DEFAULT_REFRESH_INTERVAL","createPanelGroupEditorSlice","convertLayoutsToPanelGroups","createPanelGroupSlice","createPanelEditorSlice","createPanelSlice","createDeletePanelGroupSlice","createDeletePanelSlice","createDiscardChangesDialogSlice","createSaveChangesDialogSlice","createDuplicatePanelSlice","createEditJsonDialogSlice","createPanelDefinition","createViewPanelSlice","createLinksSlice","DashboardContext","undefined","useDashboardStore","selector","store","Error","DashboardProvider","props","createDashboardStore","initStore","defaultPluginKinds","defaultPanelKind","data","plugin","defaultPanelSpec","createInitialOptions","setState","initialValues","panelDefinition","Provider","value","children","initialState","dashboardResource","isEditMode","viewPanelRef","setViewPanelRef","kind","metadata","spec","display","duration","refreshInterval","datasources","layouts","panels","links","ttl","args","set","setEditMode","setDashboard","state","panelGroups","panelGroupOrder"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,WAAW,QAAQ,UAAU;AACtC,SAASC,sBAAsB,QAAQ,sBAAsB;AAE7D,SAASC,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,KAAK,QAAQ,2BAA2B;AACjD,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,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WAAW,GACX,GAAG7C,mCAAmC6C,KAAK;YAC3C,GAAG1C,6BAA6B0C,KAAK;YACrC,GAAG5C,gCAAgC4C,KAAK;YACxCX;YACAC;YACAE;YACAC;YACAC;YACAC;YACAI;YACAb,YAAY,CAAC,CAACA;YACdgB,aAAa,CAAChB;gBACZe,IAAI;oBAAEf;gBAAW;YACnB;YACAiB,cAAc,CAAC,EACbd,IAAI,EACJC,QAAQ,EACRC,MAAM,EAAEC,OAAO,EAAEK,SAAS,CAAC,CAAC,EAAED,UAAU,EAAE,EAAEH,QAAQ,EAAEC,eAAe,EAAEC,cAAc,CAAC,CAAC,EAAEG,QAAQ,EAAE,EAAE,EACtG;gBACCG,IAAI,CAACG;oBACHA,MAAMf,IAAI,GAAGA;oBACbe,MAAMd,QAAQ,GAAGA;oBACjBc,MAAMZ,OAAO,GAAGA;oBAChBY,MAAMP,MAAM,GAAGA;oBACf,MAAM,EAAEQ,WAAW,EAAEC,eAAe,EAAE,GAAGzD,4BAA4B+C;oBACrEQ,MAAMC,WAAW,GAAGA;oBACpBD,MAAME,eAAe,GAAGA;oBACxBF,MAAMX,QAAQ,GAAGA;oBACjBW,MAAMV,eAAe,GAAGA,mBAAmB/C;oBAC3CyD,MAAMT,WAAW,GAAGA;oBACpBS,MAAMN,KAAK,GAAGA;gBACd,uGAAuG;gBACzG;YACF;QACF;IACF;IAIJ,OAAOhC;AACT"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/DashboardProvider.tsx"],"sourcesContent":["// Copyright 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 { createStore } from 'zustand';\nimport { useStoreWithEqualityFn } from 'zustand/traditional';\nimport type { StoreApi } from 'zustand';\nimport { devtools } from 'zustand/middleware';\nimport { immer } from 'zustand/middleware/immer';\nimport { shallow } from 'zustand/shallow';\nimport { createContext, ReactElement, ReactNode, useCallback, useContext, useEffect, useState } from 'react';\nimport { Display, DurationString, DatasourceSpec } from '@perses-dev/spec';\nimport { usePlugin, usePluginRegistry } from '@perses-dev/plugin-system';\nimport { ProjectMetadata } from '@perses-dev/client';\nimport { DashboardKind, DashboardResource } from '../../model/DashboardResource';\nimport { DEFAULT_REFRESH_INTERVAL } from '../../constants';\nimport { createPanelGroupEditorSlice, PanelGroupEditorSlice } from './panel-group-editor-slice';\nimport { convertLayoutsToPanelGroups, createPanelGroupSlice, PanelGroupSlice } from './panel-group-slice';\nimport { createPanelEditorSlice, PanelEditorSlice } from './panel-editor-slice';\nimport { createPanelSlice, PanelSlice } from './panel-slice';\nimport { createDeletePanelGroupSlice, DeletePanelGroupSlice } from './delete-panel-group-slice';\nimport { createDeletePanelSlice, DeletePanelSlice } from './delete-panel-slice';\nimport { createDiscardChangesDialogSlice, DiscardChangesConfirmationDialogSlice } from './discard-changes-dialog-slice';\nimport { createSaveChangesDialogSlice, SaveChangesConfirmationDialogSlice } from './save-changes-dialog-slice';\nimport { createDuplicatePanelSlice, DuplicatePanelSlice } from './duplicate-panel-slice';\nimport { createEditJsonDialogSlice, EditJsonDialogSlice } from './edit-json-dialog-slice';\nimport { createPanelDefinition } from './common';\nimport { createViewPanelSlice, ViewPanelSlice, VirtualPanelRef } from './view-panel-slice';\nimport { createLinksSlice, LinksSlice } from './links-slice';\n\nexport interface DashboardStoreState\n extends\n PanelGroupSlice,\n PanelSlice,\n PanelGroupEditorSlice,\n DeletePanelGroupSlice,\n PanelEditorSlice,\n DeletePanelSlice,\n DiscardChangesConfirmationDialogSlice,\n DuplicatePanelSlice,\n EditJsonDialogSlice,\n SaveChangesConfirmationDialogSlice,\n ViewPanelSlice,\n LinksSlice {\n isEditMode: boolean;\n setEditMode: (isEditMode: boolean) => void;\n setDashboard: (dashboard: DashboardResource) => void;\n kind: DashboardKind;\n metadata: ProjectMetadata;\n duration: DurationString;\n refreshInterval: DurationString;\n display?: Display;\n datasources?: Record<string, DatasourceSpec>;\n ttl?: DurationString;\n}\n\nexport const DashboardContext = createContext<StoreApi<DashboardStoreState> | undefined>(undefined);\n\nexport function useDashboardStore<T>(selector: (state: DashboardStoreState) => T): T {\n const store = useContext(DashboardContext);\n if (store === undefined) {\n throw new Error('No DashboardContext found. Did you forget a Provider?');\n }\n return useStoreWithEqualityFn(store, selector, shallow);\n}\n\nexport interface DashboardStoreProps {\n dashboardResource: DashboardResource;\n isEditMode?: boolean;\n viewPanelRef?: VirtualPanelRef;\n setViewPanelRef?: (viewPanelRef: VirtualPanelRef | undefined) => void;\n}\n\nexport interface DashboardProviderProps {\n initialState: DashboardStoreProps;\n children?: ReactNode;\n}\n\nexport function DashboardProvider(props: DashboardProviderProps): ReactElement {\n // Prevent calling createDashboardStore every time it rerenders\n const createDashboardStore = useCallback(initStore, [props]);\n const [store] = useState(createDashboardStore(props));\n\n // load plugin to retrieve initial spec if default panel kind is defined\n const { defaultPluginKinds } = usePluginRegistry();\n const defaultPanelKind = defaultPluginKinds?.['Panel'] ?? '';\n const { data: plugin } = usePlugin('Panel', defaultPanelKind);\n\n useEffect(() => {\n if (plugin === undefined) return;\n const defaultPanelSpec = plugin.createInitialOptions ? plugin.createInitialOptions() : {};\n // set default panel kind, spec, and queries for add panel editor\n store.setState({\n initialValues: {\n panelDefinition: createPanelDefinition(defaultPanelKind, defaultPanelSpec),\n },\n });\n }, [plugin, store, defaultPanelKind]);\n\n return (\n <DashboardContext.Provider value={store as StoreApi<DashboardStoreState>}>\n {props.children}\n </DashboardContext.Provider>\n );\n}\n\nfunction initStore(props: DashboardProviderProps): StoreApi<DashboardStoreState> {\n const {\n initialState: { dashboardResource, isEditMode, viewPanelRef, setViewPanelRef },\n } = props;\n\n const {\n kind,\n metadata,\n spec: { display, duration, refreshInterval = DEFAULT_REFRESH_INTERVAL, datasources, layouts = [], panels = {} },\n } = dashboardResource;\n\n const links = dashboardResource.spec.links ?? [];\n\n const ttl = 'ttl' in dashboardResource.spec ? (dashboardResource.spec.ttl as DurationString) : undefined;\n\n const store = createStore<DashboardStoreState>()(\n immer(\n devtools((...args) => {\n const [set] = args;\n return {\n /* Groups */\n ...createPanelGroupSlice(layouts)(...args),\n ...createPanelGroupEditorSlice(...args),\n ...createDeletePanelGroupSlice(...args),\n /* Panels */\n ...createPanelSlice(panels)(...args),\n ...createPanelEditorSlice()(...args),\n ...createDeletePanelSlice()(...args),\n ...createDuplicatePanelSlice()(...args),\n ...createViewPanelSlice(viewPanelRef, setViewPanelRef)(...args),\n /* Links */\n ...createLinksSlice(links)(...args),\n /* General */\n ...createDiscardChangesDialogSlice(...args),\n ...createEditJsonDialogSlice(...args),\n ...createSaveChangesDialogSlice(...args),\n kind,\n metadata,\n display,\n duration,\n refreshInterval,\n datasources,\n ttl,\n isEditMode: !!isEditMode,\n setEditMode: (isEditMode: boolean): void => {\n set({ isEditMode });\n },\n setDashboard: ({\n kind,\n metadata,\n spec: { display, panels = {}, layouts = [], duration, refreshInterval, datasources = {}, links = [] },\n }): void => {\n set((state) => {\n state.kind = kind;\n state.metadata = metadata;\n state.display = display;\n state.panels = panels;\n const { panelGroups, panelGroupOrder } = convertLayoutsToPanelGroups(layouts);\n state.panelGroups = panelGroups;\n state.panelGroupOrder = panelGroupOrder;\n state.duration = duration;\n state.refreshInterval = refreshInterval ?? DEFAULT_REFRESH_INTERVAL;\n state.datasources = datasources;\n state.links = links;\n // TODO: add ttl here to e.g allow edition from JSON view, but probably requires quite some refactoring\n });\n },\n };\n })\n )\n );\n\n return store;\n}\n"],"names":["createStore","useStoreWithEqualityFn","devtools","immer","shallow","createContext","useCallback","useContext","useEffect","useState","usePlugin","usePluginRegistry","DEFAULT_REFRESH_INTERVAL","createPanelGroupEditorSlice","convertLayoutsToPanelGroups","createPanelGroupSlice","createPanelEditorSlice","createPanelSlice","createDeletePanelGroupSlice","createDeletePanelSlice","createDiscardChangesDialogSlice","createSaveChangesDialogSlice","createDuplicatePanelSlice","createEditJsonDialogSlice","createPanelDefinition","createViewPanelSlice","createLinksSlice","DashboardContext","undefined","useDashboardStore","selector","store","Error","DashboardProvider","props","createDashboardStore","initStore","defaultPluginKinds","defaultPanelKind","data","plugin","defaultPanelSpec","createInitialOptions","setState","initialValues","panelDefinition","Provider","value","children","initialState","dashboardResource","isEditMode","viewPanelRef","setViewPanelRef","kind","metadata","spec","display","duration","refreshInterval","datasources","layouts","panels","links","ttl","args","set","setEditMode","setDashboard","state","panelGroups","panelGroupOrder"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,WAAW,QAAQ,UAAU;AACtC,SAASC,sBAAsB,QAAQ,sBAAsB;AAE7D,SAASC,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,KAAK,QAAQ,2BAA2B;AACjD,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,aAAa,EAA2BC,WAAW,EAAEC,UAAU,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAE7G,SAASC,SAAS,EAAEC,iBAAiB,QAAQ,4BAA4B;AAGzE,SAASC,wBAAwB,QAAQ,kBAAkB;AAC3D,SAASC,2BAA2B,QAA+B,6BAA6B;AAChG,SAASC,2BAA2B,EAAEC,qBAAqB,QAAyB,sBAAsB;AAC1G,SAASC,sBAAsB,QAA0B,uBAAuB;AAChF,SAASC,gBAAgB,QAAoB,gBAAgB;AAC7D,SAASC,2BAA2B,QAA+B,6BAA6B;AAChG,SAASC,sBAAsB,QAA0B,uBAAuB;AAChF,SAASC,+BAA+B,QAA+C,iCAAiC;AACxH,SAAS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A,MAAMf,IAAI,GAAGA;oBACbe,MAAMd,QAAQ,GAAGA;oBACjBc,MAAMZ,OAAO,GAAGA;oBAChBY,MAAMP,MAAM,GAAGA;oBACf,MAAM,EAAEQ,WAAW,EAAEC,eAAe,EAAE,GAAGzD,4BAA4B+C;oBACrEQ,MAAMC,WAAW,GAAGA;oBACpBD,MAAME,eAAe,GAAGA;oBACxBF,MAAMX,QAAQ,GAAGA;oBACjBW,MAAMV,eAAe,GAAGA,mBAAmB/C;oBAC3CyD,MAAMT,WAAW,GAAGA;oBACpBS,MAAMN,KAAK,GAAGA;gBACd,uGAAuG;gBACzG;YACF;QACF;IACF;IAIJ,OAAOhC;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"panel-group-slice.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/panel-group-slice.ts"],"names":[],"mappings":"AAaA,OAAO,EAAsB,gBAAgB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAc,UAAU,EAAE,MAAM,UAAU,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC,YAAY,EAAE,oBAAoB,CAAC,CAAC;IAExD;;OAEG;IACH,eAAe,EAAE,YAAY,EAAE,CAAC;IAEhC;;OAEG;IACH,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAE1D;;OAEG;IACH,uBAAuB,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,oBAAoB,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;CACjH;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,gBAAgB,EAAE,GAC1B,YAAY,CAAC,eAAe,EAAE,UAAU,EAAE,EAAE,EAAE,eAAe,CAAC,CAkChE;AAED,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,gBAAgB,EAAE,GAC1B,IAAI,CAAC,eAAe,EAAE,aAAa,GAAG,iBAAiB,CAAC,CAqC1D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,oBAAoB,CAQ5D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,eAAe,CAAC,EAAE,QAAQ,EAAE,oBAAoB,GAAG,IAAI,CAGzG"}
1
+ {"version":3,"file":"panel-group-slice.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/panel-group-slice.ts"],"names":[],"mappings":"AAaA,OAAO,EAAsB,gBAAgB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAc,UAAU,EAAE,MAAM,UAAU,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC,YAAY,EAAE,oBAAoB,CAAC,CAAC;IAExD;;OAEG;IACH,eAAe,EAAE,YAAY,EAAE,CAAC;IAEhC;;OAEG;IACH,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAE1D;;OAEG;IACH,uBAAuB,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,oBAAoB,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;CACjH;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,gBAAgB,EAAE,GAC1B,YAAY,CAAC,eAAe,EAAE,UAAU,EAAE,EAAE,EAAE,eAAe,CAAC,CAkChE;AAED,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,gBAAgB,EAAE,GAC1B,IAAI,CAAC,eAAe,EAAE,aAAa,GAAG,iBAAiB,CAAC,CAwC1D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,oBAAoB,CAQ5D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,eAAe,CAAC,EAAE,QAAQ,EAAE,oBAAoB,GAAG,IAAI,CAGzG"}
@@ -56,23 +56,26 @@ export function convertLayoutsToPanelGroups(layouts) {
56
56
  const itemLayouts = [];
57
57
  const itemPanelKeys = {};
58
58
  // Split layout information from panel keys to make it easier to update just layouts on move/resize of panels
59
- for (const item of layout.spec.items){
60
- const panelGroupLayoutId = generateId().toString();
61
- itemLayouts.push({
62
- i: panelGroupLayoutId,
63
- w: item.width,
64
- h: item.height,
65
- x: item.x,
66
- y: item.y
67
- });
68
- itemPanelKeys[panelGroupLayoutId] = getPanelKeyFromRef(item.content);
59
+ if ('items' in layout.spec) {
60
+ for (const item of layout.spec.items){
61
+ const panelGroupLayoutId = generateId().toString();
62
+ itemLayouts.push({
63
+ i: panelGroupLayoutId,
64
+ w: item.width,
65
+ h: item.height,
66
+ x: item.x,
67
+ y: item.y
68
+ });
69
+ itemPanelKeys[panelGroupLayoutId] = getPanelKeyFromRef(item.content);
70
+ }
69
71
  }
70
72
  // Create the panel group and keep track of the ID order
73
+ const repeatVariable = 'repeatVariable' in layout.spec ? layout.spec.repeatVariable : undefined;
71
74
  const panelGroupId = generateId();
72
75
  panelGroups[panelGroupId] = {
73
76
  id: panelGroupId,
74
77
  isCollapsed: layout.spec.display?.collapse?.open === false,
75
- repeatVariable: layout.spec.repeatVariable,
78
+ repeatVariable,
76
79
  title: layout.spec.display?.title,
77
80
  itemLayouts,
78
81
  itemPanelKeys
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/panel-group-slice.ts"],"sourcesContent":["// Copyright 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 { getPanelKeyFromRef, LayoutDefinition, PanelGroupId } from '@perses-dev/spec';\nimport { StateCreator } from 'zustand';\nimport { WritableDraft } from 'immer';\nimport { PanelGroupDefinition } from '../../model';\nimport { generateId, Middleware } from './common';\n\n/**\n * Slice with the state of Panel Groups, as well as any actions that modify only Panel Group state.\n */\nexport interface PanelGroupSlice {\n /**\n * Panel groups indexed by their ID.\n */\n panelGroups: Record<PanelGroupId, PanelGroupDefinition>;\n\n /**\n * An array of panel group IDs, representing their order in the dashboard.\n */\n panelGroupOrder: PanelGroupId[];\n\n /**\n * Rearrange the order of panel groups by swapping the positions\n */\n swapPanelGroups: (xIndex: number, yIndex: number) => void;\n\n /**\n * Update the item layouts for a panel group when, for example, a panel is moved or resized.\n */\n updatePanelGroupLayouts: (panelGroupId: PanelGroupId, itemLayouts: PanelGroupDefinition['itemLayouts']) => void;\n}\n\n/**\n * Curried function for creating a PanelGroupSlice.\n */\nexport function createPanelGroupSlice(\n layouts: LayoutDefinition[]\n): StateCreator<PanelGroupSlice, Middleware, [], PanelGroupSlice> {\n const { panelGroups, panelGroupOrder } = convertLayoutsToPanelGroups(layouts);\n\n // Return the state creator function for Zustand\n return (set) => ({\n panelGroups,\n panelGroupOrder,\n\n swapPanelGroups(x, y): void {\n set((state) => {\n if (x < 0 || x >= state.panelGroupOrder.length || y < 0 || y >= state.panelGroupOrder.length) {\n throw new Error('index out of bound');\n }\n const xPanelGroup = state.panelGroupOrder[x];\n const yPanelGroup = state.panelGroupOrder[y];\n\n if (xPanelGroup === undefined || yPanelGroup === undefined) {\n throw new Error('panel group is undefined');\n }\n // assign yPanelGroup to layouts[x] and assign xGroup to layouts[y], swapping two panel groups\n [state.panelGroupOrder[x], state.panelGroupOrder[y]] = [yPanelGroup, xPanelGroup];\n });\n },\n\n updatePanelGroupLayouts(panelGroupId, itemLayouts): void {\n set((state) => {\n const group = state.panelGroups[panelGroupId];\n if (group === undefined) {\n throw new Error(`Cannot find panel group ${panelGroupId}`);\n }\n group.itemLayouts = itemLayouts;\n });\n },\n });\n}\n\nexport function convertLayoutsToPanelGroups(\n layouts: LayoutDefinition[]\n): Pick<PanelGroupSlice, 'panelGroups' | 'panelGroupOrder'> {\n // Convert the initial layouts from the JSON\n const panelGroups: PanelGroupSlice['panelGroups'] = {};\n const panelGroupIdOrder: PanelGroupSlice['panelGroupOrder'] = [];\n for (const layout of layouts) {\n const itemLayouts: PanelGroupDefinition['itemLayouts'] = [];\n const itemPanelKeys: PanelGroupDefinition['itemPanelKeys'] = {};\n\n // Split layout information from panel keys to make it easier to update just layouts on move/resize of panels\n for (const item of layout.spec.items) {\n const panelGroupLayoutId = generateId().toString();\n itemLayouts.push({\n i: panelGroupLayoutId,\n w: item.width,\n h: item.height,\n x: item.x,\n y: item.y,\n });\n itemPanelKeys[panelGroupLayoutId] = getPanelKeyFromRef(item.content);\n }\n\n // Create the panel group and keep track of the ID order\n const panelGroupId = generateId();\n panelGroups[panelGroupId] = {\n id: panelGroupId,\n isCollapsed: layout.spec.display?.collapse?.open === false,\n repeatVariable: layout.spec.repeatVariable,\n title: layout.spec.display?.title,\n itemLayouts,\n itemPanelKeys,\n };\n panelGroupIdOrder.push(panelGroupId);\n }\n return {\n panelGroups,\n panelGroupOrder: panelGroupIdOrder,\n };\n}\n\n/**\n * Private helper function for creating an empty panel group.\n */\nexport function createEmptyPanelGroup(): PanelGroupDefinition {\n return {\n id: generateId(),\n title: undefined,\n isCollapsed: false,\n itemLayouts: [],\n itemPanelKeys: {},\n };\n}\n\n/**\n * Private helper function that modifies panel group state to add a new panel\n */\nexport function addPanelGroup(draft: WritableDraft<PanelGroupSlice>, newGroup: PanelGroupDefinition): void {\n draft.panelGroups[newGroup.id] = newGroup;\n draft.panelGroupOrder.unshift(newGroup.id);\n}\n"],"names":["getPanelKeyFromRef","generateId","createPanelGroupSlice","layouts","panelGroups","panelGroupOrder","convertLayoutsToPanelGroups","set","swapPanelGroups","x","y","state","length","Error","xPanelGroup","yPanelGroup","undefined","updatePanelGroupLayouts","panelGroupId","itemLayouts","group","panelGroupIdOrder","layout","itemPanelKeys","item","spec","items","panelGroupLayoutId","toString","push","i","w","width","h","height","content","id","isCollapsed","display","collapse","open","repeatVariable","title","createEmptyPanelGroup","addPanelGroup","draft","newGroup","unshift"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,kBAAkB,QAAwC,mBAAmB;AAItF,SAASC,UAAU,QAAoB,WAAW;AA2BlD;;CAEC,GACD,OAAO,SAASC,sBACdC,OAA2B;IAE3B,MAAM,EAAEC,WAAW,EAAEC,eAAe,EAAE,GAAGC,4BAA4BH;IAErE,gDAAgD;IAChD,OAAO,CAACI,MAAS,CAAA;YACfH;YACAC;YAEAG,iBAAgBC,CAAC,EAAEC,CAAC;gBAClBH,IAAI,CAACI;oBACH,IAAIF,IAAI,KAAKA,KAAKE,MAAMN,eAAe,CAACO,MAAM,IAAIF,IAAI,KAAKA,KAAKC,MAAMN,eAAe,CAACO,MAAM,EAAE;wBAC5F,MAAM,IAAIC,MAAM;oBAClB;oBACA,MAAMC,cAAcH,MAAMN,eAAe,CAACI,EAAE;oBAC5C,MAAMM,cAAcJ,MAAMN,eAAe,CAACK,EAAE;oBAE5C,IAAII,gBAAgBE,aAAaD,gBAAgBC,WAAW;wBAC1D,MAAM,IAA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IACA,OAAO;QACLd;QACAC,iBAAiBgB;IACnB;AACF;AAEA;;CAEC,GACD,OAAO,SAASsB;IACd,OAAO;QACLP,IAAInC;QACJyC,OAAO1B;QACPqB,aAAa;QACblB,aAAa,EAAE;QACfI,eAAe,CAAC;IAClB;AACF;AAEA;;CAEC,GACD,OAAO,SAASqB,cAAcC,KAAqC,EAAEC,QAA8B;IACjGD,MAAMzC,WAAW,CAAC0C,SAASV,EAAE,CAAC,GAAGU;IACjCD,MAAMxC,eAAe,CAAC0C,OAAO,CAACD,SAASV,EAAE;AAC3C"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/panel-group-slice.ts"],"sourcesContent":["// Copyright 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 { getPanelKeyFromRef, LayoutDefinition, PanelGroupId } from '@perses-dev/spec';\nimport { StateCreator } from 'zustand';\nimport { WritableDraft } from 'immer';\nimport { PanelGroupDefinition } from '../../model';\nimport { generateId, Middleware } from './common';\n\n/**\n * Slice with the state of Panel Groups, as well as any actions that modify only Panel Group state.\n */\nexport interface PanelGroupSlice {\n /**\n * Panel groups indexed by their ID.\n */\n panelGroups: Record<PanelGroupId, PanelGroupDefinition>;\n\n /**\n * An array of panel group IDs, representing their order in the dashboard.\n */\n panelGroupOrder: PanelGroupId[];\n\n /**\n * Rearrange the order of panel groups by swapping the positions\n */\n swapPanelGroups: (xIndex: number, yIndex: number) => void;\n\n /**\n * Update the item layouts for a panel group when, for example, a panel is moved or resized.\n */\n updatePanelGroupLayouts: (panelGroupId: PanelGroupId, itemLayouts: PanelGroupDefinition['itemLayouts']) => void;\n}\n\n/**\n * Curried function for creating a PanelGroupSlice.\n */\nexport function createPanelGroupSlice(\n layouts: LayoutDefinition[]\n): StateCreator<PanelGroupSlice, Middleware, [], PanelGroupSlice> {\n const { panelGroups, panelGroupOrder } = convertLayoutsToPanelGroups(layouts);\n\n // Return the state creator function for Zustand\n return (set) => ({\n panelGroups,\n panelGroupOrder,\n\n swapPanelGroups(x, y): void {\n set((state) => {\n if (x < 0 || x >= state.panelGroupOrder.length || y < 0 || y >= state.panelGroupOrder.length) {\n throw new Error('index out of bound');\n }\n const xPanelGroup = state.panelGroupOrder[x];\n const yPanelGroup = state.panelGroupOrder[y];\n\n if (xPanelGroup === undefined || yPanelGroup === undefined) {\n throw new Error('panel group is undefined');\n }\n // assign yPanelGroup to layouts[x] and assign xGroup to layouts[y], swapping two panel groups\n [state.panelGroupOrder[x], state.panelGroupOrder[y]] = [yPanelGroup, xPanelGroup];\n });\n },\n\n updatePanelGroupLayouts(panelGroupId, itemLayouts): void {\n set((state) => {\n const group = state.panelGroups[panelGroupId];\n if (group === undefined) {\n throw new Error(`Cannot find panel group ${panelGroupId}`);\n }\n group.itemLayouts = itemLayouts;\n });\n },\n });\n}\n\nexport function convertLayoutsToPanelGroups(\n layouts: LayoutDefinition[]\n): Pick<PanelGroupSlice, 'panelGroups' | 'panelGroupOrder'> {\n // Convert the initial layouts from the JSON\n const panelGroups: PanelGroupSlice['panelGroups'] = {};\n const panelGroupIdOrder: PanelGroupSlice['panelGroupOrder'] = [];\n for (const layout of layouts) {\n const itemLayouts: PanelGroupDefinition['itemLayouts'] = [];\n const itemPanelKeys: PanelGroupDefinition['itemPanelKeys'] = {};\n\n // Split layout information from panel keys to make it easier to update just layouts on move/resize of panels\n if ('items' in layout.spec) {\n for (const item of layout.spec.items) {\n const panelGroupLayoutId = generateId().toString();\n itemLayouts.push({\n i: panelGroupLayoutId,\n w: item.width,\n h: item.height,\n x: item.x,\n y: item.y,\n });\n itemPanelKeys[panelGroupLayoutId] = getPanelKeyFromRef(item.content);\n }\n }\n\n // Create the panel group and keep track of the ID order\n const repeatVariable = 'repeatVariable' in layout.spec ? layout.spec.repeatVariable : undefined;\n const panelGroupId = generateId();\n panelGroups[panelGroupId] = {\n id: panelGroupId,\n isCollapsed: layout.spec.display?.collapse?.open === false,\n repeatVariable,\n title: layout.spec.display?.title,\n itemLayouts,\n itemPanelKeys,\n };\n panelGroupIdOrder.push(panelGroupId);\n }\n return {\n panelGroups,\n panelGroupOrder: panelGroupIdOrder,\n };\n}\n\n/**\n * Private helper function for creating an empty panel group.\n */\nexport function createEmptyPanelGroup(): PanelGroupDefinition {\n return {\n id: generateId(),\n title: undefined,\n isCollapsed: false,\n itemLayouts: [],\n itemPanelKeys: {},\n };\n}\n\n/**\n * Private helper function that modifies panel group state to add a new panel\n */\nexport function addPanelGroup(draft: WritableDraft<PanelGroupSlice>, newGroup: PanelGroupDefinition): void {\n draft.panelGroups[newGroup.id] = newGroup;\n draft.panelGroupOrder.unshift(newGroup.id);\n}\n"],"names":["getPanelKeyFromRef","generateId","createPanelGroupSlice","layouts","panelGroups","panelGroupOrder","convertLayoutsToPanelGroups","set","swapPanelGroups","x","y","state","length","Error","xPanelGroup","yPanelGroup","undefined","updatePanelGroupLayouts","panelGroupId","itemLayouts","group","panelGroupIdOrder","layout","itemPanelKeys","spec","item","items","panelGroupLayoutId","toString","push","i","w","width","h","height","content","repeatVariable","id","isCollapsed","display","collapse","open","title","createEmptyPanelGroup","addPanelGroup","draft","newGroup","unshift"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,kBAAkB,QAAwC,mBAAmB;AAItF,SAASC,UAAU,QAAoB,WAAW;AA2BlD;;CAEC,GACD,OAAO,SAASC,sBACdC,OAA2B;IAE3B,MAAM,EAAEC,WA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YU,IAAI,CAAC;oBACfC,GAAGH;oBACHI,GAAGN,KAAKO,KAAK;oBACbC,GAAGR,KAAKS,MAAM;oBACdzB,GAAGgB,KAAKhB,CAAC;oBACTC,GAAGe,KAAKf,CAAC;gBACX;gBACAa,aAAa,CAACI,mBAAmB,GAAG3B,mBAAmByB,KAAKU,OAAO;YACrE;QACF;QAEA,wDAAwD;QACxD,MAAMC,iBAAiB,oBAAoBd,OAAOE,IAAI,GAAGF,OAAOE,IAAI,CAACY,cAAc,GAAGpB;QACtF,MAAME,eAAejB;QACrBG,WAAW,CAACc,aAAa,GAAG;YAC1BmB,IAAInB;YACJoB,aAAahB,OAAOE,IAAI,CAACe,OAAO,EAAEC,UAAUC,SAAS;YACrDL;YACAM,OAAOpB,OAAOE,IAAI,CAACe,OAAO,EAAEG;YAC5BvB;YACAI;QACF;QACAF,kBAAkBQ,IAAI,CAACX;IACzB;IACA,OAAO;QACLd;QACAC,iBAAiBgB;IACnB;AACF;AAEA;;CAEC,GACD,OAAO,SAASsB;IACd,OAAO;QACLN,IAAIpC;QACJyC,OAAO1B;QACPsB,aAAa;QACbnB,aAAa,EAAE;QACfI,eAAe,CAAC;IAClB;AACF;AAEA;;CAEC,GACD,OAAO,SAASqB,cAAcC,KAAqC,EAAEC,QAA8B;IACjGD,MAAMzC,WAAW,CAAC0C,SAAST,EAAE,CAAC,GAAGS;IACjCD,MAAMxC,eAAe,CAAC0C,OAAO,CAACD,SAAST,EAAE;AAC3C"}
@@ -1,15 +1,9 @@
1
+ import { ProjectMetadata } from '@perses-dev/client';
1
2
  import { DashboardSpec } from '@perses-dev/spec';
2
3
  export type DashboardKind = 'Dashboard' | 'EphemeralDashboard';
3
- export type DashboardMetaData = {
4
- name: string;
5
- project: string;
6
- createdAt?: string;
7
- updatedAt?: string;
8
- version?: number;
9
- };
10
4
  export interface DashboardResource {
11
5
  kind: DashboardKind;
12
6
  spec: DashboardSpec;
13
- metadata: DashboardMetaData;
7
+ metadata: ProjectMetadata;
14
8
  }
15
9
  //# sourceMappingURL=DashboardResource.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardResource.d.ts","sourceRoot":"","sources":["../../src/model/DashboardResource.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,oBAAoB,CAAC;AAG/D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAMF,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,aAAa,CAAC;IACpB,QAAQ,EAAE,iBAAiB,CAAC;CAC7B"}
1
+ {"version":3,"file":"DashboardResource.d.ts","sourceRoot":"","sources":["../../src/model/DashboardResource.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,oBAAoB,CAAC;AAE/D,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,aAAa,CAAC;IACpB,QAAQ,EAAE,eAAe,CAAC;CAC3B"}
@@ -10,9 +10,6 @@
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
- /* TODO: There is an open and ongoing issue whether the meta-data should be removed or not.
14
- Such a decision would affect DashbaordProvider and buildDatasourceProxyUrl
15
- https://github.com/perses/perses/issues/4016
16
- */ export { };
13
+ export { };
17
14
 
18
15
  //# sourceMappingURL=DashboardResource.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/DashboardResource.ts"],"sourcesContent":["// Copyright 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 { DashboardSpec } from '@perses-dev/spec';\n\nexport type DashboardKind = 'Dashboard' | 'EphemeralDashboard';\n\n/* TODO: As discussed we can keep this intermediary type until we decide on a new location for it. */\nexport type DashboardMetaData = {\n name: string;\n project: string;\n createdAt?: string;\n updatedAt?: string;\n version?: number;\n};\n\n/* TODO: There is an open and ongoing issue whether the meta-data should be removed or not.\n Such a decision would affect DashbaordProvider and buildDatasourceProxyUrl\n https://github.com/perses/perses/issues/4016\n*/\nexport interface DashboardResource {\n kind: DashboardKind;\n spec: DashboardSpec;\n metadata: DashboardMetaData;\n}\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAejC;;;AAGA,GACA,WAIC"}
1
+ {"version":3,"sources":["../../src/model/DashboardResource.ts"],"sourcesContent":["// Copyright 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 { ProjectMetadata } from '@perses-dev/client';\nimport { DashboardSpec } from '@perses-dev/spec';\n\nexport type DashboardKind = 'Dashboard' | 'EphemeralDashboard';\n\nexport interface DashboardResource {\n kind: DashboardKind;\n spec: DashboardSpec;\n metadata: ProjectMetadata;\n}\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAOjC,WAIC"}
@@ -1,3 +1,4 @@
1
1
  export * from './DashboardResource';
2
2
  export * from './PanelGroupDefinition';
3
+ export * from './VariableDefinition';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC"}
@@ -12,5 +12,6 @@
12
12
  // limitations under the License.
13
13
  export * from './DashboardResource';
14
14
  export * from './PanelGroupDefinition';
15
+ export * from './VariableDefinition';
15
16
 
16
17
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/index.ts"],"sourcesContent":["// Copyright 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 './DashboardResource';\nexport * from './PanelGroupDefinition';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,sBAAsB;AACpC,cAAc,yBAAyB"}
1
+ {"version":3,"sources":["../../src/model/index.ts"],"sourcesContent":["// Copyright 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 './DashboardResource';\nexport * from './PanelGroupDefinition';\nexport * from './VariableDefinition';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,sBAAsB;AACpC,cAAc,yBAAyB;AACvC,cAAc,uBAAuB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/dashboards",
3
- "version": "0.54.0-beta.3",
3
+ "version": "0.54.0-beta.5",
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",
@@ -29,9 +29,10 @@
29
29
  "lint:fix": "eslint --fix src --ext .ts,.tsx"
30
30
  },
31
31
  "dependencies": {
32
- "@perses-dev/components": "0.54.0-beta.3",
33
- "@perses-dev/plugin-system": "0.54.0-beta.3",
34
- "@perses-dev/spec": "0.2.0-beta.0",
32
+ "@perses-dev/components": "0.54.0-beta.5",
33
+ "@perses-dev/plugin-system": "0.54.0-beta.5",
34
+ "@perses-dev/spec": "0.2.0-beta.2",
35
+ "@tanstack/hotkeys": "^0.8.0",
35
36
  "@tanstack/react-hotkeys": "^0.9.1",
36
37
  "immer": "^10.1.1",
37
38
  "mdi-material-ui": "^7.9.2",