@perses-dev/plugin-system 0.50.1 → 0.51.0-beta.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 (176) hide show
  1. package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +17 -71
  2. package/dist/cjs/components/DatasourceSelect.js +8 -13
  3. package/dist/cjs/components/HTTPSettingsEditor/HTTPSettingsEditor.js +534 -0
  4. package/dist/cjs/components/HTTPSettingsEditor/index.js +30 -0
  5. package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +4 -4
  6. package/dist/cjs/components/MetricLabelInput/MetricLabelInput.js +1 -1
  7. package/dist/cjs/components/MetricLabelInput/index.js +1 -1
  8. package/dist/cjs/components/MultiQueryEditor/MultiQueryEditor.js +15 -14
  9. package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +7 -11
  10. package/dist/cjs/components/PluginEditor/PluginEditor.js +10 -6
  11. package/dist/cjs/components/PluginEditor/plugin-editor-api.js +4 -5
  12. package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +7 -8
  13. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +7 -10
  14. package/dist/cjs/components/PluginRegistry/plugin-indexes.js +17 -14
  15. package/dist/cjs/components/ProjectSelect.js +2 -3
  16. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +46 -92
  17. package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +6 -6
  18. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +6 -11
  19. package/dist/cjs/components/Variables/variable-model.js +4 -7
  20. package/dist/cjs/components/index.js +1 -0
  21. package/dist/cjs/index.js +1 -0
  22. package/dist/cjs/model/explore.js +16 -0
  23. package/dist/cjs/remote/PersesPlugin.types.js +16 -0
  24. package/dist/cjs/remote/PluginLoaderComponent.js +75 -0
  25. package/dist/cjs/remote/PluginRuntime.js +267 -0
  26. package/dist/cjs/remote/index.js +31 -0
  27. package/dist/cjs/remote/remotePluginLoader.js +61 -0
  28. package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +4 -10
  29. package/dist/cjs/runtime/DataQueriesProvider/model.js +4 -7
  30. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +2 -2
  31. package/dist/cjs/runtime/builtin-variables.js +1 -1
  32. package/dist/cjs/runtime/datasources.js +3 -3
  33. package/dist/cjs/runtime/plugin-registry.js +5 -6
  34. package/dist/cjs/runtime/time-series-queries.js +11 -18
  35. package/dist/cjs/runtime/trace-queries.js +1 -2
  36. package/dist/cjs/runtime/variables.js +10 -28
  37. package/dist/cjs/stories/shared-utils/decorators/WithDataQueries.js +1 -1
  38. package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +1 -67
  39. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +1 -1
  40. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +4 -4
  41. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemVariables.js +1 -1
  42. package/dist/cjs/stories/shared-utils/decorators/WithTimeRange.js +1 -1
  43. package/dist/cjs/test/render.js +1 -2
  44. package/dist/cjs/test-utils/mock-plugin-registry.js +10 -10
  45. package/dist/cjs/utils/variables.js +1 -1
  46. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
  47. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +17 -30
  48. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
  49. package/dist/components/DatasourceSelect.d.ts +2 -2
  50. package/dist/components/DatasourceSelect.d.ts.map +1 -1
  51. package/dist/components/DatasourceSelect.js +8 -13
  52. package/dist/components/DatasourceSelect.js.map +1 -1
  53. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts +11 -0
  54. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -0
  55. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +480 -0
  56. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -0
  57. package/dist/components/HTTPSettingsEditor/index.d.ts +2 -0
  58. package/dist/components/HTTPSettingsEditor/index.d.ts.map +1 -0
  59. package/dist/components/HTTPSettingsEditor/index.js +15 -0
  60. package/dist/components/HTTPSettingsEditor/index.js.map +1 -0
  61. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +4 -4
  62. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
  63. package/dist/components/MetricLabelInput/MetricLabelInput.js +1 -1
  64. package/dist/components/MetricLabelInput/MetricLabelInput.js.map +1 -1
  65. package/dist/components/MetricLabelInput/index.js +1 -1
  66. package/dist/components/MetricLabelInput/index.js.map +1 -1
  67. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -1
  68. package/dist/components/MultiQueryEditor/MultiQueryEditor.js +15 -14
  69. package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
  70. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +7 -11
  71. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  72. package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
  73. package/dist/components/PluginEditor/PluginEditor.js +10 -6
  74. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  75. package/dist/components/PluginEditor/plugin-editor-api.js +4 -5
  76. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  77. package/dist/components/PluginKindSelect/PluginKindSelect.js +7 -8
  78. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
  79. package/dist/components/PluginRegistry/PluginRegistry.js +7 -10
  80. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
  81. package/dist/components/PluginRegistry/plugin-indexes.d.ts +4 -4
  82. package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
  83. package/dist/components/PluginRegistry/plugin-indexes.js +17 -14
  84. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
  85. package/dist/components/ProjectSelect.js +2 -3
  86. package/dist/components/ProjectSelect.js.map +1 -1
  87. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +46 -92
  88. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  89. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +6 -6
  90. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
  91. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +6 -11
  92. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  93. package/dist/components/Variables/variable-model.js +4 -7
  94. package/dist/components/Variables/variable-model.js.map +1 -1
  95. package/dist/components/index.d.ts +1 -0
  96. package/dist/components/index.d.ts.map +1 -1
  97. package/dist/components/index.js +1 -0
  98. package/dist/components/index.js.map +1 -1
  99. package/dist/index.d.ts +1 -0
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +1 -0
  102. package/dist/index.js.map +1 -1
  103. package/dist/model/explore.d.ts +13 -0
  104. package/dist/model/explore.d.ts.map +1 -0
  105. package/dist/model/explore.js +17 -0
  106. package/dist/model/explore.js.map +1 -0
  107. package/dist/model/panels.d.ts +13 -3
  108. package/dist/model/panels.d.ts.map +1 -1
  109. package/dist/model/panels.js.map +1 -1
  110. package/dist/model/plugins.d.ts +31 -17
  111. package/dist/model/plugins.d.ts.map +1 -1
  112. package/dist/model/plugins.js.map +1 -1
  113. package/dist/remote/PersesPlugin.types.d.ts +7 -0
  114. package/dist/remote/PersesPlugin.types.d.ts.map +1 -0
  115. package/dist/remote/PersesPlugin.types.js +15 -0
  116. package/dist/remote/PersesPlugin.types.js.map +1 -0
  117. package/dist/remote/PluginLoaderComponent.d.ts +10 -0
  118. package/dist/remote/PluginLoaderComponent.d.ts.map +1 -0
  119. package/dist/remote/PluginLoaderComponent.js +67 -0
  120. package/dist/remote/PluginLoaderComponent.js.map +1 -0
  121. package/dist/remote/PluginRuntime.d.ts +11 -0
  122. package/dist/remote/PluginRuntime.d.ts.map +1 -0
  123. package/dist/remote/PluginRuntime.js +202 -0
  124. package/dist/remote/PluginRuntime.js.map +1 -0
  125. package/dist/remote/index.d.ts +3 -0
  126. package/dist/remote/index.d.ts.map +1 -0
  127. package/dist/remote/index.js +16 -0
  128. package/dist/remote/index.js.map +1 -0
  129. package/dist/remote/remotePluginLoader.d.ts +3 -0
  130. package/dist/remote/remotePluginLoader.d.ts.map +1 -0
  131. package/dist/remote/remotePluginLoader.js +53 -0
  132. package/dist/remote/remotePluginLoader.js.map +1 -0
  133. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +4 -10
  134. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
  135. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
  136. package/dist/runtime/DataQueriesProvider/model.js +4 -7
  137. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  138. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +2 -2
  139. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  140. package/dist/runtime/builtin-variables.js +1 -1
  141. package/dist/runtime/builtin-variables.js.map +1 -1
  142. package/dist/runtime/datasources.d.ts +2 -2
  143. package/dist/runtime/datasources.js +3 -3
  144. package/dist/runtime/datasources.js.map +1 -1
  145. package/dist/runtime/plugin-registry.d.ts +6 -6
  146. package/dist/runtime/plugin-registry.d.ts.map +1 -1
  147. package/dist/runtime/plugin-registry.js +5 -6
  148. package/dist/runtime/plugin-registry.js.map +1 -1
  149. package/dist/runtime/time-series-queries.js +11 -18
  150. package/dist/runtime/time-series-queries.js.map +1 -1
  151. package/dist/runtime/trace-queries.js +1 -2
  152. package/dist/runtime/trace-queries.js.map +1 -1
  153. package/dist/runtime/variables.js +10 -28
  154. package/dist/runtime/variables.js.map +1 -1
  155. package/dist/stories/shared-utils/decorators/WithDataQueries.js +1 -1
  156. package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +1 -1
  157. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts.map +1 -1
  158. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js +2 -22
  159. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js.map +1 -1
  160. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +1 -1
  161. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js.map +1 -1
  162. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +4 -4
  163. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +1 -1
  164. package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.js +1 -1
  165. package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.js.map +1 -1
  166. package/dist/stories/shared-utils/decorators/WithTimeRange.js +1 -1
  167. package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +1 -1
  168. package/dist/test/render.js +1 -2
  169. package/dist/test/render.js.map +1 -1
  170. package/dist/test-utils/mock-plugin-registry.d.ts +5 -3
  171. package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
  172. package/dist/test-utils/mock-plugin-registry.js +10 -10
  173. package/dist/test-utils/mock-plugin-registry.js.map +1 -1
  174. package/dist/utils/variables.js +1 -1
  175. package/dist/utils/variables.js.map +1 -1
  176. package/package.json +6 -5
@@ -35,21 +35,21 @@ import { usePluginIndexes, getTypeAndKindKey } from './plugin-indexes';
35
35
  }
36
36
  return request;
37
37
  });
38
- const getPlugin = useCallback(async (pluginType, kind)=>{
38
+ const getPlugin = useCallback(async (kind, name)=>{
39
39
  // Get the indexes of the installed plugins
40
40
  const pluginIndexes = await getPluginIndexes();
41
41
  // Figure out what module the plugin is in by looking in the index
42
- const typeAndKindKey = getTypeAndKindKey(pluginType, kind);
43
- const resource = pluginIndexes.pluginResourcesByTypeAndKind.get(typeAndKindKey);
42
+ const typeAndKindKey = getTypeAndKindKey(kind, name);
43
+ const resource = pluginIndexes.pluginResourcesByNameAndKind.get(typeAndKindKey);
44
44
  if (resource === undefined) {
45
- throw new Error(`A ${pluginType} plugin for kind '${kind}' is not installed`);
45
+ throw new Error(`A ${name} plugin for kind '${kind}' is not installed`);
46
46
  }
47
47
  // Treat the plugin module as a bunch of named exports that have plugins
48
48
  const pluginModule = await loadPluginModule(resource);
49
49
  // We currently assume that plugin modules will have named exports that match the kinds they handle
50
- const plugin = pluginModule[kind];
50
+ const plugin = pluginModule[name];
51
51
  if (plugin === undefined) {
52
- throw new Error(`The ${pluginType} plugin for kind '${kind}' is missing from the ${resource.metadata.name} plugin module`);
52
+ throw new Error(`The ${name} plugin for kind '${kind}' is missing from the ${resource.metadata.name} plugin module`);
53
53
  }
54
54
  return plugin;
55
55
  }, [
@@ -58,10 +58,7 @@ import { usePluginIndexes, getTypeAndKindKey } from './plugin-indexes';
58
58
  ]);
59
59
  const listPluginMetadata = useCallback(async (pluginTypes)=>{
60
60
  const pluginIndexes = await getPluginIndexes();
61
- return pluginTypes.flatMap((type)=>{
62
- var _pluginIndexes_pluginMetadataByType_get;
63
- return (_pluginIndexes_pluginMetadataByType_get = pluginIndexes.pluginMetadataByType.get(type)) !== null && _pluginIndexes_pluginMetadataByType_get !== void 0 ? _pluginIndexes_pluginMetadataByType_get : [];
64
- });
61
+ return pluginTypes.flatMap((type)=>pluginIndexes.pluginMetadataByKind.get(type) ?? []);
65
62
  }, [
66
63
  getPluginIndexes
67
64
  ]);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PluginRegistry/PluginRegistry.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { UnknownSpec, useEvent } from '@perses-dev/core';\nimport { useRef, useCallback, useMemo, ReactNode, ReactElement } from 'react';\nimport {\n PluginModuleResource,\n PluginType,\n PluginImplementation,\n Plugin,\n PluginLoader,\n DefaultPluginKinds,\n} from '../../model';\nimport { PluginRegistryContext } from '../../runtime';\nimport { usePluginIndexes, getTypeAndKindKey } from './plugin-indexes';\n\nexport interface PluginRegistryProps {\n pluginLoader: PluginLoader;\n defaultPluginKinds?: DefaultPluginKinds;\n children?: ReactNode;\n}\n\n/**\n * PluginRegistryContext provider that keeps track of all available plugins and provides an API for getting them or\n * querying the metadata about them.\n */\nexport function PluginRegistry(props: PluginRegistryProps): ReactElement {\n const {\n pluginLoader: { getInstalledPlugins, importPluginModule },\n children,\n defaultPluginKinds,\n } = props;\n\n const getPluginIndexes = usePluginIndexes(getInstalledPlugins);\n\n // De-dupe calls to import plugin modules\n const importCache = useRef(new Map<PluginModuleResource, Promise<unknown>>());\n\n // Do useEvent here since this accesses the importPluginModule prop and we want a stable reference to it for the\n // callback below\n const loadPluginModule = useEvent((resource: PluginModuleResource) => {\n let request = importCache.current.get(resource);\n if (request === undefined) {\n request = importPluginModule(resource);\n importCache.current.set(resource, request);\n\n // Remove failed requests from the cache so they can potentially be retried\n request.catch(() => importCache.current.delete(resource));\n }\n return request;\n });\n\n const getPlugin = useCallback(\n async <T extends PluginType>(pluginType: T, kind: string): Promise<PluginImplementation<T>> => {\n // Get the indexes of the installed plugins\n const pluginIndexes = await getPluginIndexes();\n\n // Figure out what module the plugin is in by looking in the index\n const typeAndKindKey = getTypeAndKindKey(pluginType, kind);\n const resource = pluginIndexes.pluginResourcesByTypeAndKind.get(typeAndKindKey);\n if (resource === undefined) {\n throw new Error(`A ${pluginType} plugin for kind '${kind}' is not installed`);\n }\n\n // Treat the plugin module as a bunch of named exports that have plugins\n const pluginModule = (await loadPluginModule(resource)) as Record<string, Plugin<UnknownSpec>>;\n\n // We currently assume that plugin modules will have named exports that match the kinds they handle\n const plugin = pluginModule[kind];\n if (plugin === undefined) {\n throw new Error(\n `The ${pluginType} plugin for kind '${kind}' is missing from the ${resource.metadata.name} plugin module`\n );\n }\n\n return plugin as PluginImplementation<T>;\n },\n [getPluginIndexes, loadPluginModule]\n );\n\n const listPluginMetadata = useCallback(\n async (pluginTypes: PluginType[]) => {\n const pluginIndexes = await getPluginIndexes();\n return pluginTypes.flatMap((type) => pluginIndexes.pluginMetadataByType.get(type) ?? []);\n },\n [getPluginIndexes]\n );\n\n // Create the registry's context value and render\n const context = useMemo(\n () => ({ getPlugin, listPluginMetadata, defaultPluginKinds }),\n [getPlugin, listPluginMetadata, defaultPluginKinds]\n );\n return <PluginRegistryContext.Provider value={context}>{children}</PluginRegistryContext.Provider>;\n}\n"],"names":["useEvent","useRef","useCallback","useMemo","PluginRegistryContext","usePluginIndexes","getTypeAndKindKey","PluginRegistry","props","pluginLoader","getInstalledPlugins","importPluginModule","children","defaultPluginKinds","getPluginIndexes","importCache","Map","loadPluginModule","resource","request","current","get","undefined","set","catch","delete","getPlugin","pluginType","kind","pluginIndexes","typeAndKindKey","pluginResourcesByTypeAndKind","Error","pluginModule","plugin","metadata","name","listPluginMetadata","pluginTypes","flatMap","type","pluginMetadataByType","context","Provider","value"],"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,SAAsBA,QAAQ,QAAQ,mBAAmB;AACzD,SAASC,MAAM,EAAEC,WAAW,EAAEC,OAAO,QAAiC,QAAQ;AAS9E,SAASC,qBAAqB,QAAQ,gBAAgB;AACtD,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,mBAAmB;AAQvE;;;CAGC,GACD,OAAO,SAASC,eAAeC,KAA0B;IACvD,MAAM,EACJC,cAAc,EAAEC,mBAAmB,EA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AA,CAAAA,0CAAAA,cAAcY,oBAAoB,CAACpB,GAAG,CAACmB,mBAAvCX,qDAAAA,0CAAgD,EAAE;;IACzF,GACA;QAACf;KAAiB;IAGpB,iDAAiD;IACjD,MAAM4B,UAAUvC,QACd,IAAO,CAAA;YAAEuB;YAAWW;YAAoBxB;QAAmB,CAAA,GAC3D;QAACa;QAAWW;QAAoBxB;KAAmB;IAErD,qBAAO,KAACT,sBAAsBuC,QAAQ;QAACC,OAAOF;kBAAU9B;;AAC1D"}
1
+ {"version":3,"sources":["../../../src/components/PluginRegistry/PluginRegistry.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { UnknownSpec, useEvent } from '@perses-dev/core';\nimport { useRef, useCallback, useMemo, ReactNode, ReactElement } from 'react';\nimport {\n PluginModuleResource,\n PluginType,\n PluginImplementation,\n Plugin,\n PluginLoader,\n DefaultPluginKinds,\n} from '../../model';\nimport { PluginRegistryContext } from '../../runtime';\nimport { usePluginIndexes, getTypeAndKindKey } from './plugin-indexes';\n\nexport interface PluginRegistryProps {\n pluginLoader: PluginLoader;\n defaultPluginKinds?: DefaultPluginKinds;\n children?: ReactNode;\n}\n\n/**\n * PluginRegistryContext provider that keeps track of all available plugins and provides an API for getting them or\n * querying the metadata about them.\n */\nexport function PluginRegistry(props: PluginRegistryProps): ReactElement {\n const {\n pluginLoader: { getInstalledPlugins, importPluginModule },\n children,\n defaultPluginKinds,\n } = props;\n\n const getPluginIndexes = usePluginIndexes(getInstalledPlugins);\n\n // De-dupe calls to import plugin modules\n const importCache = useRef(new Map<PluginModuleResource, Promise<unknown>>());\n\n // Do useEvent here since this accesses the importPluginModule prop and we want a stable reference to it for the\n // callback below\n const loadPluginModule = useEvent((resource: PluginModuleResource) => {\n let request = importCache.current.get(resource);\n if (request === undefined) {\n request = importPluginModule(resource);\n importCache.current.set(resource, request);\n\n // Remove failed requests from the cache so they can potentially be retried\n request.catch(() => importCache.current.delete(resource));\n }\n return request;\n });\n\n const getPlugin = useCallback(\n async <T extends PluginType>(kind: T, name: string): Promise<PluginImplementation<T>> => {\n // Get the indexes of the installed plugins\n const pluginIndexes = await getPluginIndexes();\n\n // Figure out what module the plugin is in by looking in the index\n const typeAndKindKey = getTypeAndKindKey(kind, name);\n const resource = pluginIndexes.pluginResourcesByNameAndKind.get(typeAndKindKey);\n if (resource === undefined) {\n throw new Error(`A ${name} plugin for kind '${kind}' is not installed`);\n }\n\n // Treat the plugin module as a bunch of named exports that have plugins\n const pluginModule = (await loadPluginModule(resource)) as Record<string, Plugin<UnknownSpec>>;\n\n // We currently assume that plugin modules will have named exports that match the kinds they handle\n const plugin = pluginModule[name];\n if (plugin === undefined) {\n throw new Error(\n `The ${name} plugin for kind '${kind}' is missing from the ${resource.metadata.name} plugin module`\n );\n }\n\n return plugin as PluginImplementation<T>;\n },\n [getPluginIndexes, loadPluginModule]\n );\n\n const listPluginMetadata = useCallback(\n async (pluginTypes: string[]) => {\n const pluginIndexes = await getPluginIndexes();\n return pluginTypes.flatMap((type) => pluginIndexes.pluginMetadataByKind.get(type) ?? []);\n },\n [getPluginIndexes]\n );\n\n // Create the registry's context value and render\n const context = useMemo(\n () => ({ getPlugin, listPluginMetadata, defaultPluginKinds }),\n [getPlugin, listPluginMetadata, defaultPluginKinds]\n );\n return <PluginRegistryContext.Provider value={context}>{children}</PluginRegistryContext.Provider>;\n}\n"],"names":["useEvent","useRef","useCallback","useMemo","PluginRegistryContext","usePluginIndexes","getTypeAndKindKey","PluginRegistry","props","pluginLoader","getInstalledPlugins","importPluginModule","children","defaultPluginKinds","getPluginIndexes","importCache","Map","loadPluginModule","resource","request","current","get","undefined","set","catch","delete","getPlugin","kind","name","pluginIndexes","typeAndKindKey","pluginResourcesByNameAndKind","Error","pluginModule","plugin","metadata","listPluginMetadata","pluginTypes","flatMap","type","pluginMetadataByKind","context","Provider","value"],"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,SAAsBA,QAAQ,QAAQ,mBAAmB;AACzD,SAASC,MAAM,EAAEC,WAAW,EAAEC,OAAO,QAAiC,QAAQ;AAS9E,SAASC,qBAAqB,QAAQ,gBAAgB;AACtD,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,mBAAmB;AAQvE;;;CAGC,GACD,OAAO,SAASC,eAAeC,KAA0B;IACvD,MAAM,EACJC,cAAc,EAAEC,mBAAmB,EAAEC,kBAAkB,EAAE,EACzDC,QAAQ,EACRC,kBAAkB,EACnB,GAAGL;IAEJ,MAAMM,mBAAmBT,iBAAiBK;IAE1C,yCAAyC;IACzC,MAAMK,cAAcd,OAAO,IAAIe;IAE/B,gHAAgH;IAChH,iBAAiB;IACjB,MAAMC,mBAAmBjB,SAAS,CAACkB;QACjC,IAAIC,UAAUJ,YAAYK,OAAO,CAACC,GAAG,CAACH;QACtC,IAAIC,YAAYG,WAAW;YACzBH,UAAUR,mBAAmBO;YAC7BH,YAAYK,OAAO,CAACG,GAAG,CAACL,UAAUC;YAElC,2EAA2E;YAC3EA,QAAQK,KAAK,CAAC,IAAMT,YAAYK,OAAO,CAACK,MAAM,CAACP;QACjD;QACA,OAAOC;IACT;IAEA,MAAMO,YAAYxB,YAChB,OAA6ByB,MAASC;QACpC,2CAA2C;QAC3C,MAAMC,gBAAgB,MAAMf;QAE5B,kEAAkE;QAClE,MAAMgB,iBAAiBxB,kBAAkBqB,MAAMC;QAC/C,MAAMV,WAAWW,cAAcE,4BAA4B,CAACV,GAAG,CAACS;QAChE,IAAIZ,aAAaI,WAAW;YAC1B,MAAM,IAAIU,MAAM,CAAC,EAAE,EAAEJ,KAAK,kBAAkB,EAAED,KAAK,kBAAkB,CAAC;QACxE;QAEA,wEAAwE;QACxE,MAAMM,eAAgB,MAAMhB,iBAAiBC;QAE7C,mGAAmG;QACnG,MAAMgB,SAASD,YAAY,CAACL,KAAK;QACjC,IAAIM,WAAWZ,WAAW;YACxB,MAAM,IAAIU,MACR,CAAC,IAAI,EAAEJ,KAAK,kBAAkB,EAAED,KAAK,sBAAsB,EAAET,SAASiB,QAAQ,CAACP,IAAI,CAAC,cAAc,CAAC;QAEvG;QAEA,OAAOM;IACT,GACA;QAACpB;QAAkBG;KAAiB;IAGtC,MAAMmB,qBAAqBlC,YACzB,OAAOmC;QACL,MAAMR,gBAAgB,MAAMf;QAC5B,OAAOuB,YAAYC,OAAO,CAAC,CAACC,OAASV,cAAcW,oBAAoB,CAACnB,GAAG,CAACkB,SAAS,EAAE;IACzF,GACA;QAACzB;KAAiB;IAGpB,iDAAiD;IACjD,MAAM2B,UAAUtC,QACd,IAAO,CAAA;YAAEuB;YAAWU;YAAoBvB;QAAmB,CAAA,GAC3D;QAACa;QAAWU;QAAoBvB;KAAmB;IAErD,qBAAO,KAACT,sBAAsBsC,QAAQ;QAACC,OAAOF;kBAAU7B;;AAC1D"}
@@ -1,7 +1,7 @@
1
- import { PluginLoader, PluginMetadata, PluginModuleResource, PluginType } from '../../model';
1
+ import { PluginLoader, PluginMetadataWithModule, PluginModuleResource, PluginType } from '../../model';
2
2
  export interface PluginIndexes {
3
- pluginResourcesByTypeAndKind: Map<string, PluginModuleResource>;
4
- pluginMetadataByType: Map<PluginType, PluginMetadata[]>;
3
+ pluginResourcesByNameAndKind: Map<string, PluginModuleResource>;
4
+ pluginMetadataByKind: Map<string, PluginMetadataWithModule[]>;
5
5
  }
6
6
  /**
7
7
  * Returns an async callback for getting indexes of the installed plugin data.
@@ -10,5 +10,5 @@ export declare function usePluginIndexes(getInstalledPlugins: PluginLoader['getI
10
10
  /**
11
11
  * Gets a unique key for a plugin type/kind that can be used as a cache key.
12
12
  */
13
- export declare function getTypeAndKindKey(pluginType: PluginType, kind: string): string;
13
+ export declare function getTypeAndKindKey(kind: PluginType, name: string): string;
14
14
  //# sourceMappingURL=plugin-indexes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-indexes.d.ts","sourceRoot":"","sources":["../../../src/components/PluginRegistry/plugin-indexes.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE7F,MAAM,WAAW,aAAa;IAE5B,4BAA4B,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAEhE,oBAAoB,EAAE,GAAG,CAAC,UAAU,EAAE,cAAc,EAAE,CAAC,CAAC;CACzD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,mBAAmB,EAAE,YAAY,CAAC,qBAAqB,CAAC,GACvD,MAAM,OAAO,CAAC,aAAa,CAAC,CAoD9B;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9E"}
1
+ {"version":3,"file":"plugin-indexes.d.ts","sourceRoot":"","sources":["../../../src/components/PluginRegistry/plugin-indexes.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEvG,MAAM,WAAW,aAAa;IAE5B,4BAA4B,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAEhE,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,wBAAwB,EAAE,CAAC,CAAC;CAC/D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,mBAAmB,EAAE,YAAY,CAAC,qBAAqB,CAAC,GACvD,MAAM,OAAO,CAAC,aAAa,CAAC,CAuD9B;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAExE"}
@@ -20,29 +20,32 @@ import { useCallback, useRef } from 'react';
20
20
  const createPluginIndexes = useEvent(async ()=>{
21
21
  const installedPlugins = await getInstalledPlugins();
22
22
  // Create the two indexes from the installed plugins
23
- const pluginResourcesByTypeAndKind = new Map();
24
- const pluginMetadataByType = new Map();
23
+ const pluginResourcesByNameAndKind = new Map();
24
+ const pluginMetadataByKind = new Map();
25
25
  for (const resource of installedPlugins){
26
26
  for (const pluginMetadata of resource.spec.plugins){
27
- const { pluginType, kind } = pluginMetadata;
27
+ const { kind, spec: { name } } = pluginMetadata;
28
28
  // Index the plugin by type and kind to point at the module that contains it
29
- const key = getTypeAndKindKey(pluginType, kind);
30
- if (pluginResourcesByTypeAndKind.has(key)) {
31
- console.warn(`Got more than one ${pluginType} plugin for kind ${kind}`);
29
+ const key = getTypeAndKindKey(kind, name);
30
+ if (pluginResourcesByNameAndKind.has(key)) {
31
+ console.warn(`Got more than one ${kind} plugin for kind ${name}`);
32
32
  }
33
- pluginResourcesByTypeAndKind.set(key, resource);
33
+ pluginResourcesByNameAndKind.set(key, resource);
34
34
  // Index the metadata by plugin type
35
- let list = pluginMetadataByType.get(pluginType);
35
+ let list = pluginMetadataByKind.get(kind);
36
36
  if (list === undefined) {
37
37
  list = [];
38
- pluginMetadataByType.set(pluginType, list);
38
+ pluginMetadataByKind.set(kind, list);
39
39
  }
40
- list.push(pluginMetadata);
40
+ list.push({
41
+ ...pluginMetadata,
42
+ module: resource.metadata
43
+ });
41
44
  }
42
45
  }
43
46
  return {
44
- pluginResourcesByTypeAndKind,
45
- pluginMetadataByType
47
+ pluginResourcesByNameAndKind,
48
+ pluginMetadataByKind
46
49
  };
47
50
  });
48
51
  // De-dupe creating plugin indexes (i.e. requests to get installed plugins)
@@ -63,8 +66,8 @@ import { useCallback, useRef } from 'react';
63
66
  }
64
67
  /**
65
68
  * Gets a unique key for a plugin type/kind that can be used as a cache key.
66
- */ export function getTypeAndKindKey(pluginType, kind) {
67
- return `${pluginType}:${kind}`;
69
+ */ export function getTypeAndKindKey(kind, name) {
70
+ return `${kind}:${name}`;
68
71
  }
69
72
 
70
73
  //# sourceMappingURL=plugin-indexes.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PluginRegistry/plugin-indexes.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useEvent } from '@perses-dev/core';\nimport { useCallback, useRef } from 'react';\nimport { PluginLoader, PluginMetadata, PluginModuleResource, PluginType } from '../../model';\n\nexport interface PluginIndexes {\n // Plugin resources by plugin type and kind (i.e. look up what module a plugin type and kind is in)\n pluginResourcesByTypeAndKind: Map<string, PluginModuleResource>;\n // Plugin metadata by plugin type\n pluginMetadataByType: Map<PluginType, PluginMetadata[]>;\n}\n\n/**\n * Returns an async callback for getting indexes of the installed plugin data.\n */\nexport function usePluginIndexes(\n getInstalledPlugins: PluginLoader['getInstalledPlugins']\n): () => Promise<PluginIndexes> {\n // Creates indexes from the installed plugins data (does useEvent because this accesses the getInstalledPlugins prop\n // and we want a stable reference for the callback below)\n const createPluginIndexes = useEvent(async (): Promise<PluginIndexes> => {\n const installedPlugins = await getInstalledPlugins();\n\n // Create the two indexes from the installed plugins\n const pluginResourcesByTypeAndKind = new Map<string, PluginModuleResource>();\n const pluginMetadataByType = new Map<PluginType, PluginMetadata[]>();\n\n for (const resource of installedPlugins) {\n for (const pluginMetadata of resource.spec.plugins) {\n const { pluginType, kind } = pluginMetadata;\n\n // Index the plugin by type and kind to point at the module that contains it\n const key = getTypeAndKindKey(pluginType, kind);\n if (pluginResourcesByTypeAndKind.has(key)) {\n console.warn(`Got more than one ${pluginType} plugin for kind ${kind}`);\n }\n pluginResourcesByTypeAndKind.set(key, resource);\n\n // Index the metadata by plugin type\n let list = pluginMetadataByType.get(pluginType);\n if (list === undefined) {\n list = [];\n pluginMetadataByType.set(pluginType, list);\n }\n list.push(pluginMetadata);\n }\n }\n\n return {\n pluginResourcesByTypeAndKind,\n pluginMetadataByType,\n };\n });\n\n // De-dupe creating plugin indexes (i.e. requests to get installed plugins)\n const pluginIndexesCache = useRef<Promise<PluginIndexes> | undefined>(undefined);\n const getPluginIndexes = useCallback(() => {\n let request = pluginIndexesCache.current;\n if (request === undefined) {\n request = createPluginIndexes();\n pluginIndexesCache.current = request;\n\n // Remove failed requests from the cache so they can potentially be retried\n request.catch(() => pluginIndexesCache.current === undefined);\n }\n return request;\n }, [createPluginIndexes]);\n\n return getPluginIndexes;\n}\n\n/**\n * Gets a unique key for a plugin type/kind that can be used as a cache key.\n */\nexport function getTypeAndKindKey(pluginType: PluginType, kind: string): string {\n return `${pluginType}:${kind}`;\n}\n"],"names":["useEvent","useCallback","useRef","usePluginIndexes","getInstalledPlugins","createPluginIndexes","installedPlugins","pluginResourcesByTypeAndKind","Map","pluginMetadataByType","resource","pluginMetadata","spec","plugins","pluginType","kind","key","getTypeAndKindKey","has","console","warn","set","list","get","undefined","push","pluginIndexesCache","getPluginIndexes","request","current","catch"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,QAAQ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AkBH,UAAsB,EAAEC,IAAY;IACpE,OAAO,CAAC,EAAED,WAAW,CAAC,EAAEC,KAAK,CAAC;AAChC"}
1
+ {"version":3,"sources":["../../../src/components/PluginRegistry/plugin-indexes.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useEvent } from '@perses-dev/core';\nimport { useCallback, useRef } from 'react';\nimport { PluginLoader, PluginMetadataWithModule, PluginModuleResource, PluginType } from '../../model';\n\nexport interface PluginIndexes {\n // Plugin resources by plugin type and kind (i.e. look up what module a plugin type and kind is in)\n pluginResourcesByNameAndKind: Map<string, PluginModuleResource>;\n // Plugin metadata by plugin type\n pluginMetadataByKind: Map<string, PluginMetadataWithModule[]>;\n}\n\n/**\n * Returns an async callback for getting indexes of the installed plugin data.\n */\nexport function usePluginIndexes(\n getInstalledPlugins: PluginLoader['getInstalledPlugins']\n): () => Promise<PluginIndexes> {\n // Creates indexes from the installed plugins data (does useEvent because this accesses the getInstalledPlugins prop\n // and we want a stable reference for the callback below)\n const createPluginIndexes = useEvent(async (): Promise<PluginIndexes> => {\n const installedPlugins = await getInstalledPlugins();\n\n // Create the two indexes from the installed plugins\n const pluginResourcesByNameAndKind = new Map<string, PluginModuleResource>();\n const pluginMetadataByKind = new Map<string, PluginMetadataWithModule[]>();\n\n for (const resource of installedPlugins) {\n for (const pluginMetadata of resource.spec.plugins) {\n const {\n kind,\n spec: { name },\n } = pluginMetadata;\n\n // Index the plugin by type and kind to point at the module that contains it\n const key = getTypeAndKindKey(kind, name);\n if (pluginResourcesByNameAndKind.has(key)) {\n console.warn(`Got more than one ${kind} plugin for kind ${name}`);\n }\n pluginResourcesByNameAndKind.set(key, resource);\n\n // Index the metadata by plugin type\n let list = pluginMetadataByKind.get(kind);\n if (list === undefined) {\n list = [];\n pluginMetadataByKind.set(kind, list);\n }\n list.push({ ...pluginMetadata, module: resource.metadata });\n }\n }\n\n return {\n pluginResourcesByNameAndKind,\n pluginMetadataByKind,\n };\n });\n\n // De-dupe creating plugin indexes (i.e. requests to get installed plugins)\n const pluginIndexesCache = useRef<Promise<PluginIndexes> | undefined>(undefined);\n const getPluginIndexes = useCallback(() => {\n let request = pluginIndexesCache.current;\n if (request === undefined) {\n request = createPluginIndexes();\n pluginIndexesCache.current = request;\n\n // Remove failed requests from the cache so they can potentially be retried\n request.catch(() => pluginIndexesCache.current === undefined);\n }\n return request;\n }, [createPluginIndexes]);\n\n return getPluginIndexes;\n}\n\n/**\n * Gets a unique key for a plugin type/kind that can be used as a cache key.\n */\nexport function getTypeAndKindKey(kind: PluginType, name: string): string {\n return `${kind}:${name}`;\n}\n"],"names":["useEvent","useCallback","useRef","usePluginIndexes","getInstalledPlugins","createPluginIndexes","installedPlugins","pluginResourcesByNameAndKind","Map","pluginMetadataByKind","resource","pluginMetadata","spec","plugins","kind","name","key","getTypeAndKindKey","has","console","warn","set","list","get","undefined","push","module","metadata","pluginIndexesCache","getPluginIndexes","request","current","catch"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,QAAQ,QAAQ,mBAAmB;AAC5C,SAASC,WAAW,EAAEC,MAAM,QAAQ,QAAQ;AAU5C;;CAEC,GACD,OAAO,SAASC,iBACdC,mBAAwD;IAExD,oHAAoH;IACpH,yDAAyD;IACzD,MAAMC,sBAAsBL,SAAS;QACnC,MAAMM,mBAAmB,MAAMF;QAE/B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49
49
  })
50
50
  })
51
51
  }),
52
- data === null || data === void 0 ? void 0 : data.map((project)=>[
52
+ data?.map((project)=>[
53
53
  /*#__PURE__*/ _jsx(MenuItem, {
54
54
  value: project.metadata.name,
55
55
  children: /*#__PURE__*/ _jsx(Stack, {
@@ -72,8 +72,7 @@ import { useProjectList } from '../context';
72
72
  * returns a string value that can be used as a Select input value.
73
73
  * @param selector
74
74
  */ function projectToOptionValue(project) {
75
- var _project_metadata_name;
76
- return (_project_metadata_name = project.metadata.name) !== null && _project_metadata_name !== void 0 ? _project_metadata_name : 'none';
75
+ return project.metadata.name ?? 'none';
77
76
  }
78
77
  /**
79
78
  * Given an option value name,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/ProjectSelect.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Select, SelectProps, MenuItem, Stack, ListItemText } from '@mui/material';\nimport { ProjectResource } from '@perses-dev/core';\nimport { ReactElement } from 'react';\nimport { useProjectList } from '../context';\n\n// Props on MUI Select that we don't want people to pass because we're either redefining them or providing them in\n// this component\ntype OmittedMuiProps = 'children' | 'value' | 'onChange';\n\nexport interface ProjectSelectProps extends Omit<SelectProps<string>, OmittedMuiProps> {\n onChange: (next: ProjectResource) => void;\n value: ProjectResource;\n}\n\n/**\n * Displays a MUI input for selecting a Project of a particular kind. Note: The 'value' and `onChange` handler for\n * the input deal with a `ProjectSelector`.\n */\nexport function ProjectSelect(props: ProjectSelectProps): ReactElement {\n const { onChange, value, ...others } = props;\n\n const { data, isLoading } = useProjectList();\n\n // While loading available values, just use an empty string so MUI select doesn't warn about values out of range\n const optionValue = isLoading ? '' : projectToOptionValue(value);\n\n // When the user makes a selection, convert the string option value back to a DatasourceSelector\n const handleChange: SelectProps<string>['onChange'] = (e) => {\n const next = optionValueToSelector(e.target.value);\n onChange(next);\n };\n\n // TODO:\n // - Does this need a loading indicator of some kind?\n // - The group's edit link is not clickable once selected.\n // - The group's edit link is disabled if datasource is overridden.\n // Ref: https://github.com/mui/material-ui/issues/36572\n return (\n <Select {...others} value={optionValue} onChange={handleChange}>\n <MenuItem value=\"none\">\n <Stack direction=\"row\" alignItems=\"center\" justifyContent=\"space-between\" width=\"100%\" height={32}>\n <ListItemText>None</ListItemText>\n </Stack>\n </MenuItem>\n {data?.map((project: ProjectResource) => [\n <MenuItem key={project.metadata.name} value={project.metadata.name}>\n <Stack direction=\"row\" alignItems=\"center\" justifyContent=\"space-between\" width=\"100%\" height={32}>\n <ListItemText>{project.metadata.name}</ListItemText>\n </Stack>\n </MenuItem>,\n ])}\n </Select>\n );\n}\n\n/**\n * Given a ProjectSelectItemSelector,\n * returns a string value that can be used as a Select input value.\n * @param selector\n */\nfunction projectToOptionValue(project: ProjectResource): string {\n return project.metadata.name ?? 'none';\n}\n\n/**\n * Given an option value name,\n * returns a ProjectResource to be used by the query data model.\n * @param optionValue\n */\nfunction optionValueToSelector(optionValue: string): ProjectResource {\n return {\n kind: 'Project',\n metadata: {\n name: optionValue,\n },\n spec: {},\n };\n}\n"],"names":["Select","MenuItem","Stack","ListItemText","useProjectList","ProjectSelect","props","onChange","value","others","data","isLoading","optionValue","projectToOptionValue","handleChange","e","next","optionValueToSelector","target","direction","alignItems","justifyContent","width","height","map","project","metadata","name","kind","spec"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,MAAM,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IAChD,OAAO;QACLgB,MAAM;QACNF,UAAU;YACRC,MAAMf;QACR;QACAiB,MAAM,CAAC;IACT;AACF"}
1
+ {"version":3,"sources":["../../src/components/ProjectSelect.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Select, SelectProps, MenuItem, Stack, ListItemText } from '@mui/material';\nimport { ProjectResource } from '@perses-dev/core';\nimport { ReactElement } from 'react';\nimport { useProjectList } from '../context';\n\n// Props on MUI Select that we don't want people to pass because we're either redefining them or providing them in\n// this component\ntype OmittedMuiProps = 'children' | 'value' | 'onChange';\n\nexport interface ProjectSelectProps extends Omit<SelectProps<string>, OmittedMuiProps> {\n onChange: (next: ProjectResource) => void;\n value: ProjectResource;\n}\n\n/**\n * Displays a MUI input for selecting a Project of a particular kind. Note: The 'value' and `onChange` handler for\n * the input deal with a `ProjectSelector`.\n */\nexport function ProjectSelect(props: ProjectSelectProps): ReactElement {\n const { onChange, value, ...others } = props;\n\n const { data, isLoading } = useProjectList();\n\n // While loading available values, just use an empty string so MUI select doesn't warn about values out of range\n const optionValue = isLoading ? '' : projectToOptionValue(value);\n\n // When the user makes a selection, convert the string option value back to a DatasourceSelector\n const handleChange: SelectProps<string>['onChange'] = (e) => {\n const next = optionValueToSelector(e.target.value);\n onChange(next);\n };\n\n // TODO:\n // - Does this need a loading indicator of some kind?\n // - The group's edit link is not clickable once selected.\n // - The group's edit link is disabled if datasource is overridden.\n // Ref: https://github.com/mui/material-ui/issues/36572\n return (\n <Select {...others} value={optionValue} onChange={handleChange}>\n <MenuItem value=\"none\">\n <Stack direction=\"row\" alignItems=\"center\" justifyContent=\"space-between\" width=\"100%\" height={32}>\n <ListItemText>None</ListItemText>\n </Stack>\n </MenuItem>\n {data?.map((project: ProjectResource) => [\n <MenuItem key={project.metadata.name} value={project.metadata.name}>\n <Stack direction=\"row\" alignItems=\"center\" justifyContent=\"space-between\" width=\"100%\" height={32}>\n <ListItemText>{project.metadata.name}</ListItemText>\n </Stack>\n </MenuItem>,\n ])}\n </Select>\n );\n}\n\n/**\n * Given a ProjectSelectItemSelector,\n * returns a string value that can be used as a Select input value.\n * @param selector\n */\nfunction projectToOptionValue(project: ProjectResource): string {\n return project.metadata.name ?? 'none';\n}\n\n/**\n * Given an option value name,\n * returns a ProjectResource to be used by the query data model.\n * @param optionValue\n */\nfunction optionValueToSelector(optionValue: string): ProjectResource {\n return {\n kind: 'Project',\n metadata: {\n name: optionValue,\n },\n spec: {},\n };\n}\n"],"names":["Select","MenuItem","Stack","ListItemText","useProjectList","ProjectSelect","props","onChange","value","others","data","isLoading","optionValue","projectToOptionValue","handleChange","e","next","optionValueToSelector","target","direction","alignItems","justifyContent","width","height","map","project","metadata","name","kind","spec"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,MAAM,EAAeC,QAAQ,EAAEC,KAAK,EAAEC,YAAY,QAAQ,gBAAgB;AAGnF,SAASC,cAAc,QAAQ,aAAa;AAW5C;;;CAGC,GACD,OAAO,SAASC,cAAcC,KAAyB;IACrD,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAE,GAAGC,QAAQ,GAAGH;IAEvC,MAAM,EAAEI,IAAI,EAAEC,SAAS,EAAE,GAAGP;IAE5B,gHAAgH;IAChH,MAAMQ,cAAcD,YAAY,KAAKE,qBAAqBL;IAE1D,gGAAgG;IAChG,MAAMM,eAAgD,CAACC;QACrD,MAAMC,OAAOC,sBAAsBF,EAAEG,MAAM,CAACV,KAAK;QACjDD,SAASS;IACX;IAEA,QAAQ;IACR,sDAAsD;IACtD,2DAA2D;IAC3D,oEAAoE;IACpE,0DAA0D;IAC1D,qBACE,MAAChB;QAAQ,GAAGS,MAAM;QAAED,OAAOI;QAAaL,UAAUO;;0BAChD,KAACb;gBAASO,OAAM;0BACd,cAAA,KAACN;oBAAMiB,WAAU;oBAAMC,YAAW;oBAASC,gBAAe;oBAAgBC,OAAM;oBAAOC,QAAQ;8BAC7F,cAAA,KAACpB;kCAAa;;;;YAGjBO,MAAMc,IAAI,CAACC,UAA6B;kCACvC,KAACxB;wBAAqCO,OAAOiB,QAAQC,QAAQ,CAACC,IAAI;kCAChE,cAAA,KAACzB;4BAAMiB,WAAU;4BAAMC,YAAW;4BAASC,gBAAe;4BAAgBC,OAAM;4BAAOC,QAAQ;sCAC7F,cAAA,KAACpB;0CAAcsB,QAAQC,QAAQ,CAACC,IAAI;;;uBAFzBF,QAAQC,QAAQ,CAACC,IAAI;iBAKrC;;;AAGP;AAEA;;;;CAIC,GACD,SAASd,qBAAqBY,OAAwB;IACpD,OAAOA,QAAQC,QAAQ,CAACC,IAAI,IAAI;AAClC;AAEA;;;;CAIC,GACD,SAASV,sBAAsBL,WAAmB;IAChD,OAAO;QACLgB,MAAM;QACNF,UAAU;YACRC,MAAMf;QACR;QACAiB,MAAM,CAAC;IACT;AACF"}
@@ -40,10 +40,7 @@ function TextVariableEditorForm({ action, control }) {
40
40
  /*#__PURE__*/ _jsx(Controller, {
41
41
  control: control,
42
42
  name: "spec.value",
43
- render: ({ field, fieldState })=>{
44
- var _fieldState_error;
45
- var _field_value;
46
- return /*#__PURE__*/ _jsxs(_Fragment, {
43
+ render: ({ field, fieldState })=>/*#__PURE__*/ _jsxs(_Fragment, {
47
44
  children: [
48
45
  /*#__PURE__*/ _jsx(Box, {
49
46
  children: /*#__PURE__*/ _jsx(VariablePreview, {
@@ -62,35 +59,31 @@ function TextVariableEditorForm({ action, control }) {
62
59
  readOnly: action === 'read'
63
60
  },
64
61
  error: !!fieldState.error,
65
- helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
66
- value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : '',
62
+ helperText: fieldState.error?.message,
63
+ value: field.value ?? '',
67
64
  onChange: (event)=>{
68
65
  field.onChange(event);
69
66
  }
70
67
  })
71
68
  ]
72
- });
73
- }
69
+ })
74
70
  }),
75
71
  /*#__PURE__*/ _jsx(Controller, {
76
72
  control: control,
77
73
  name: "spec.constant",
78
- render: ({ field })=>{
79
- var _field_value;
80
- return /*#__PURE__*/ _jsx(FormControlLabel, {
74
+ render: ({ field })=>/*#__PURE__*/ _jsx(FormControlLabel, {
81
75
  label: "Constant",
82
76
  control: /*#__PURE__*/ _jsx(Switch, {
83
77
  ...field,
84
78
  checked: !!field.value,
85
79
  readOnly: action === 'read',
86
- value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : false,
80
+ value: field.value ?? false,
87
81
  onChange: (event)=>{
88
82
  if (action === 'read') return; // ReadOnly prop is not blocking user interaction...
89
83
  field.onChange(event);
90
84
  }
91
85
  })
92
- });
93
- }
86
+ })
94
87
  })
95
88
  ]
96
89
  })
@@ -159,10 +152,7 @@ function ListVariableEditorForm({ action, control }) {
159
152
  children: /*#__PURE__*/ _jsx(Controller, {
160
153
  control: control,
161
154
  name: "spec.plugin",
162
- render: ({ field })=>{
163
- var _field_value, _field_value1;
164
- var _field_value_kind, _field_value_spec;
165
- return /*#__PURE__*/ _jsx(PluginEditor, {
155
+ render: ({ field })=>/*#__PURE__*/ _jsx(PluginEditor, {
166
156
  width: "100%",
167
157
  pluginTypes: [
168
158
  'Variable'
@@ -171,9 +161,9 @@ function ListVariableEditorForm({ action, control }) {
171
161
  value: {
172
162
  selection: {
173
163
  type: 'Variable',
174
- kind: (_field_value_kind = (_field_value = field.value) === null || _field_value === void 0 ? void 0 : _field_value.kind) !== null && _field_value_kind !== void 0 ? _field_value_kind : 'StaticListVariable'
164
+ kind: field.value?.kind ?? 'StaticListVariable'
175
165
  },
176
- spec: (_field_value_spec = (_field_value1 = field.value) === null || _field_value1 === void 0 ? void 0 : _field_value1.spec) !== null && _field_value_spec !== void 0 ? _field_value_spec : {
166
+ spec: field.value?.spec ?? {
177
167
  values: []
178
168
  }
179
169
  },
@@ -184,8 +174,7 @@ function ListVariableEditorForm({ action, control }) {
184
174
  spec: v.spec
185
175
  });
186
176
  }
187
- });
188
- }
177
+ })
189
178
  })
190
179
  })
191
180
  ]
@@ -194,10 +183,7 @@ function ListVariableEditorForm({ action, control }) {
194
183
  children: /*#__PURE__*/ _jsx(Controller, {
195
184
  control: control,
196
185
  name: "spec.capturingRegexp",
197
- render: ({ field, fieldState })=>{
198
- var _fieldState_error;
199
- var _field_value;
200
- return /*#__PURE__*/ _jsx(TextField, {
186
+ render: ({ field, fieldState })=>/*#__PURE__*/ _jsx(TextField, {
201
187
  ...field,
202
188
  label: "Capturing Regexp Filter",
203
189
  InputLabelProps: {
@@ -207,7 +193,7 @@ function ListVariableEditorForm({ action, control }) {
207
193
  readOnly: action === 'read'
208
194
  },
209
195
  error: !!fieldState.error,
210
- value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : '',
196
+ value: field.value ?? '',
211
197
  onChange: (event)=>{
212
198
  if (event.target.value === '') {
213
199
  field.onChange(undefined);
@@ -215,19 +201,15 @@ function ListVariableEditorForm({ action, control }) {
215
201
  field.onChange(event);
216
202
  }
217
203
  },
218
- helperText: ((_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message) ? fieldState.error.message : 'Optional, if you want to filter on captured result.'
219
- });
220
- }
204
+ helperText: fieldState.error?.message ? fieldState.error.message : 'Optional, if you want to filter on captured result.'
205
+ })
221
206
  })
222
207
  }),
223
208
  /*#__PURE__*/ _jsx(Stack, {
224
209
  children: /*#__PURE__*/ _jsx(Controller, {
225
210
  control: control,
226
211
  name: "spec.sort",
227
- render: ({ field, fieldState })=>{
228
- var _fieldState_error;
229
- var _field_value;
230
- return /*#__PURE__*/ _jsxs(TextField, {
212
+ render: ({ field, fieldState })=>/*#__PURE__*/ _jsxs(TextField, {
231
213
  select: true,
232
214
  ...field,
233
215
  fullWidth: true,
@@ -239,8 +221,8 @@ function ListVariableEditorForm({ action, control }) {
239
221
  readOnly: action === 'read'
240
222
  },
241
223
  error: !!fieldState.error,
242
- helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
243
- value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : 'none',
224
+ helperText: fieldState.error?.message,
225
+ value: field.value ?? 'none',
244
226
  onChange: (event)=>{
245
227
  field.onChange(event);
246
228
  },
@@ -274,8 +256,7 @@ function ListVariableEditorForm({ action, control }) {
274
256
  children: "Alphabetical, case-insensitive, desc"
275
257
  })
276
258
  ]
277
- });
278
- }
259
+ })
279
260
  })
280
261
  })
281
262
  ]
@@ -294,22 +275,19 @@ function ListVariableEditorForm({ action, control }) {
294
275
  /*#__PURE__*/ _jsx(Controller, {
295
276
  control: control,
296
277
  name: "spec.allowMultiple",
297
- render: ({ field })=>{
298
- var _field_value;
299
- return /*#__PURE__*/ _jsx(FormControlLabel, {
278
+ render: ({ field })=>/*#__PURE__*/ _jsx(FormControlLabel, {
300
279
  label: "Allow Multiple Values",
301
280
  control: /*#__PURE__*/ _jsx(Switch, {
302
281
  ...field,
303
282
  checked: !!field.value,
304
283
  readOnly: action === 'read',
305
- value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : false,
284
+ value: field.value ?? false,
306
285
  onChange: (event)=>{
307
286
  if (action === 'read') return; // ReadOnly prop is not blocking user interaction...
308
287
  field.onChange(event);
309
288
  }
310
289
  })
311
- });
312
- }
290
+ })
313
291
  }),
314
292
  /*#__PURE__*/ _jsx(Typography, {
315
293
  variant: "caption",
@@ -322,22 +300,19 @@ function ListVariableEditorForm({ action, control }) {
322
300
  /*#__PURE__*/ _jsx(Controller, {
323
301
  control: control,
324
302
  name: "spec.allowAllValue",
325
- render: ({ field })=>{
326
- var _field_value;
327
- return /*#__PURE__*/ _jsx(FormControlLabel, {
303
+ render: ({ field })=>/*#__PURE__*/ _jsx(FormControlLabel, {
328
304
  label: "Allow All option",
329
305
  control: /*#__PURE__*/ _jsx(Switch, {
330
306
  ...field,
331
307
  checked: !!field.value,
332
308
  readOnly: action === 'read',
333
- value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : false,
309
+ value: field.value ?? false,
334
310
  onChange: (event)=>{
335
311
  if (action === 'read') return; // ReadOnly prop is not blocking user interaction...
336
312
  field.onChange(event);
337
313
  }
338
314
  })
339
- });
340
- }
315
+ })
341
316
  }),
342
317
  /*#__PURE__*/ _jsx(Typography, {
343
318
  mb: 1,
@@ -347,10 +322,7 @@ function ListVariableEditorForm({ action, control }) {
347
322
  _allowAllValue && /*#__PURE__*/ _jsx(Controller, {
348
323
  control: control,
349
324
  name: "spec.customAllValue",
350
- render: ({ field, fieldState })=>{
351
- var _fieldState_error;
352
- var _field_value;
353
- return /*#__PURE__*/ _jsx(TextField, {
325
+ render: ({ field, fieldState })=>/*#__PURE__*/ _jsx(TextField, {
354
326
  ...field,
355
327
  fullWidth: true,
356
328
  label: "Custom All Value",
@@ -361,8 +333,8 @@ function ListVariableEditorForm({ action, control }) {
361
333
  readOnly: action === 'read'
362
334
  },
363
335
  error: !!fieldState.error,
364
- helperText: ((_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message) ? fieldState.error.message : 'When All is selected, this value will be used',
365
- value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : '',
336
+ helperText: fieldState.error?.message ? fieldState.error.message : 'When All is selected, this value will be used',
337
+ value: field.value ?? '',
366
338
  onChange: (event)=>{
367
339
  if (event.target.value === '') {
368
340
  field.onChange(undefined);
@@ -370,8 +342,7 @@ function ListVariableEditorForm({ action, control }) {
370
342
  field.onChange(event);
371
343
  }
372
344
  }
373
- });
374
- }
345
+ })
375
346
  })
376
347
  ]
377
348
  })
@@ -395,11 +366,10 @@ export function VariableEditorForm({ initialVariableDefinition, action, isDraft,
395
366
  name: 'kind'
396
367
  });
397
368
  function clearFormData(data) {
398
- var _result_spec_display, _result_spec_display1, _result_spec_display2;
399
369
  const result = {
400
370
  ...data
401
371
  };
402
- if (((_result_spec_display = result.spec.display) === null || _result_spec_display === void 0 ? void 0 : _result_spec_display.name) === undefined && ((_result_spec_display1 = result.spec.display) === null || _result_spec_display1 === void 0 ? void 0 : _result_spec_display1.description) === undefined && ((_result_spec_display2 = result.spec.display) === null || _result_spec_display2 === void 0 ? void 0 : _result_spec_display2.hidden) === undefined) {
372
+ if (result.spec.display?.name === undefined && result.spec.display?.description === undefined && result.spec.display?.hidden === undefined) {
403
373
  delete result.spec.display;
404
374
  }
405
375
  return result;
@@ -466,10 +436,7 @@ export function VariableEditorForm({ initialVariableDefinition, action, isDraft,
466
436
  children: /*#__PURE__*/ _jsx(Controller, {
467
437
  control: form.control,
468
438
  name: "spec.name",
469
- render: ({ field, fieldState })=>{
470
- var _fieldState_error;
471
- var _field_value;
472
- return /*#__PURE__*/ _jsx(TextField, {
439
+ render: ({ field, fieldState })=>/*#__PURE__*/ _jsx(TextField, {
473
440
  ...field,
474
441
  required: true,
475
442
  fullWidth: true,
@@ -482,13 +449,12 @@ export function VariableEditorForm({ initialVariableDefinition, action, isDraft,
482
449
  readOnly: action === 'read'
483
450
  },
484
451
  error: !!fieldState.error,
485
- helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
486
- value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : '',
452
+ helperText: fieldState.error?.message,
453
+ value: field.value ?? '',
487
454
  onChange: (event)=>{
488
455
  field.onChange(event);
489
456
  }
490
- });
491
- }
457
+ })
492
458
  })
493
459
  }),
494
460
  /*#__PURE__*/ _jsx(Grid, {
@@ -497,10 +463,7 @@ export function VariableEditorForm({ initialVariableDefinition, action, isDraft,
497
463
  children: /*#__PURE__*/ _jsx(Controller, {
498
464
  control: form.control,
499
465
  name: "spec.display.name",
500
- render: ({ field, fieldState })=>{
501
- var _fieldState_error;
502
- var _field_value;
503
- return /*#__PURE__*/ _jsx(TextField, {
466
+ render: ({ field, fieldState })=>/*#__PURE__*/ _jsx(TextField, {
504
467
  ...field,
505
468
  fullWidth: true,
506
469
  label: "Display Label",
@@ -511,13 +474,12 @@ export function VariableEditorForm({ initialVariableDefinition, action, isDraft,
511
474
  readOnly: action === 'read'
512
475
  },
513
476
  error: !!fieldState.error,
514
- helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
515
- value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : '',
477
+ helperText: fieldState.error?.message,
478
+ value: field.value ?? '',
516
479
  onChange: (event)=>{
517
480
  field.onChange(event);
518
481
  }
519
- });
520
- }
482
+ })
521
483
  })
522
484
  }),
523
485
  /*#__PURE__*/ _jsx(Grid, {
@@ -526,10 +488,7 @@ export function VariableEditorForm({ initialVariableDefinition, action, isDraft,
526
488
  children: /*#__PURE__*/ _jsx(Controller, {
527
489
  control: form.control,
528
490
  name: "spec.display.description",
529
- render: ({ field, fieldState })=>{
530
- var _fieldState_error;
531
- var _field_value;
532
- return /*#__PURE__*/ _jsx(TextField, {
491
+ render: ({ field, fieldState })=>/*#__PURE__*/ _jsx(TextField, {
533
492
  ...field,
534
493
  fullWidth: true,
535
494
  label: "Description",
@@ -540,13 +499,12 @@ export function VariableEditorForm({ initialVariableDefinition, action, isDraft,
540
499
  readOnly: action === 'read'
541
500
  },
542
501
  error: !!fieldState.error,
543
- helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
544
- value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : '',
502
+ helperText: fieldState.error?.message,
503
+ value: field.value ?? '',
545
504
  onChange: (event)=>{
546
505
  field.onChange(event);
547
506
  }
548
- });
549
- }
507
+ })
550
508
  })
551
509
  }),
552
510
  /*#__PURE__*/ _jsx(Grid, {
@@ -555,10 +513,7 @@ export function VariableEditorForm({ initialVariableDefinition, action, isDraft,
555
513
  children: /*#__PURE__*/ _jsx(Controller, {
556
514
  control: form.control,
557
515
  name: "kind",
558
- render: ({ field, fieldState })=>{
559
- var _fieldState_error;
560
- var _field_value;
561
- return /*#__PURE__*/ _jsx(TextField, {
516
+ render: ({ field, fieldState })=>/*#__PURE__*/ _jsx(TextField, {
562
517
  select: true,
563
518
  ...field,
564
519
  fullWidth: true,
@@ -570,8 +525,8 @@ export function VariableEditorForm({ initialVariableDefinition, action, isDraft,
570
525
  readOnly: action === 'read'
571
526
  },
572
527
  error: !!fieldState.error,
573
- helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
574
- value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : 'TextVariable',
528
+ helperText: fieldState.error?.message,
529
+ value: field.value ?? 'TextVariable',
575
530
  onChange: (event)=>{
576
531
  field.onChange(event);
577
532
  },
@@ -579,8 +534,7 @@ export function VariableEditorForm({ initialVariableDefinition, action, isDraft,
579
534
  value: v.kind,
580
535
  children: v.label
581
536
  }, v.kind))
582
- });
583
- }
537
+ })
584
538
  })
585
539
  })
586
540
  ]