@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
@@ -29,14 +29,14 @@ const _MultiQueryEditor = require("../MultiQueryEditor");
29
29
  function PanelSpecEditor(props) {
30
30
  const { control, panelDefinition, onJSONChange, onQueriesChange, onPluginSpecChange } = props;
31
31
  const { kind } = panelDefinition.spec.plugin;
32
- const { data: plugin, isLoading, error } = (0, _runtime.usePlugin)('Panel', kind);
32
+ const { data: plugin, isPending, error } = (0, _runtime.usePlugin)('Panel', kind);
33
33
  if (error) {
34
34
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorAlert, {
35
35
  error: error
36
36
  });
37
37
  }
38
38
  // TODO: Proper loading indicator
39
- if (isLoading) {
39
+ if (isPending) {
40
40
  return null;
41
41
  }
42
42
  if (plugin === undefined) {
@@ -50,17 +50,14 @@ function PanelSpecEditor(props) {
50
50
  content: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
51
51
  control: control,
52
52
  name: "panelDefinition.spec.queries",
53
- render: ({ field })=>{
54
- var _plugin_supportedQueryTypes, _panelDefinition_spec_queries;
55
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_MultiQueryEditor.MultiQueryEditor, {
56
- queryTypes: (_plugin_supportedQueryTypes = plugin.supportedQueryTypes) !== null && _plugin_supportedQueryTypes !== void 0 ? _plugin_supportedQueryTypes : [],
57
- queries: (_panelDefinition_spec_queries = panelDefinition.spec.queries) !== null && _panelDefinition_spec_queries !== void 0 ? _panelDefinition_spec_queries : [],
53
+ render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_MultiQueryEditor.MultiQueryEditor, {
54
+ queryTypes: plugin.supportedQueryTypes ?? [],
55
+ queries: panelDefinition.spec.queries ?? [],
58
56
  onChange: (queries)=>{
59
57
  field.onChange(queries);
60
58
  onQueriesChange(queries);
61
59
  }
62
- });
63
- }
60
+ })
64
61
  })
65
62
  });
66
63
  }
@@ -102,9 +99,8 @@ function PanelSpecEditor(props) {
102
99
  })
103
100
  })
104
101
  });
105
- var _panelDefinition_spec_queries;
106
102
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_runtime.QueryCountProvider, {
107
- queryCount: ((_panelDefinition_spec_queries = panelDefinition.spec.queries) !== null && _panelDefinition_spec_queries !== void 0 ? _panelDefinition_spec_queries : []).length,
103
+ queryCount: (panelDefinition.spec.queries ?? []).length,
108
104
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_OptionsEditorTabs.OptionsEditorTabs, {
109
105
  tabs: tabs
110
106
  }, tabs.length)
@@ -22,6 +22,7 @@ Object.defineProperty(exports, "PluginEditor", {
22
22
  });
23
23
  const _jsxruntime = require("react/jsx-runtime");
24
24
  const _material = require("@mui/material");
25
+ const _components = require("@perses-dev/components");
25
26
  const _PluginKindSelect = require("../PluginKindSelect");
26
27
  const _PluginSpecEditor = require("../PluginSpecEditor");
27
28
  const _plugineditorapi = require("./plugin-editor-api");
@@ -47,14 +48,17 @@ function PluginEditor(props) {
47
48
  readOnly: isReadonly
48
49
  },
49
50
  error: !!error,
50
- helperText: error === null || error === void 0 ? void 0 : error.message,
51
+ helperText: error?.message,
51
52
  onChange: onSelectionChange
52
53
  }),
53
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_PluginSpecEditor.PluginSpecEditor, {
54
- pluginSelection: value.selection,
55
- value: value.spec,
56
- onChange: onSpecChange,
57
- isReadonly: isReadonly
54
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
55
+ FallbackComponent: _components.ErrorAlert,
56
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_PluginSpecEditor.PluginSpecEditor, {
57
+ pluginSelection: value.selection,
58
+ value: value.spec,
59
+ onChange: onSpecChange,
60
+ isReadonly: isReadonly
61
+ })
58
62
  })
59
63
  ]
60
64
  });
@@ -50,7 +50,7 @@ function usePluginEditor(props) {
50
50
  });
51
51
  const { defaultPluginKinds } = (0, _runtime.usePluginRegistry)();
52
52
  const defaultPluginType = pluginTypes[0];
53
- const defaultPluginKind = defaultPluginType ? defaultPluginKinds === null || defaultPluginKinds === void 0 ? void 0 : defaultPluginKinds[defaultPluginType] : undefined;
53
+ const defaultPluginKind = defaultPluginType ? defaultPluginKinds?.[defaultPluginType] : undefined;
54
54
  const defaultPluginSelection = defaultPluginType && defaultPluginKind ? {
55
55
  type: defaultPluginType,
56
56
  kind: defaultPluginKind
@@ -68,7 +68,7 @@ function usePluginEditor(props) {
68
68
  value.selection,
69
69
  defaultPluginKind
70
70
  ]);
71
- const { data: plugin, isFetching, error } = (0, _runtime.usePlugin)(pendingSelection === null || pendingSelection === void 0 ? void 0 : pendingSelection.type, (pendingSelection === null || pendingSelection === void 0 ? void 0 : pendingSelection.kind) || '');
71
+ const { data: plugin, isFetching, error } = (0, _runtime.usePlugin)(pendingSelection?.type, pendingSelection?.kind || '');
72
72
  (0, _react.useEffect)(()=>{
73
73
  // Nothing to do if no new plugin kind is pending
74
74
  if (!pendingSelection) return;
@@ -78,7 +78,7 @@ function usePluginEditor(props) {
78
78
  rememberCurrentSpecState();
79
79
  onChange({
80
80
  selection: pendingSelection,
81
- spec: plugin.createInitialOptions()
81
+ spec: plugin.createInitialOptions ? plugin.createInitialOptions() : {}
82
82
  });
83
83
  if (pendingSelection.type === 'Panel') {
84
84
  const panelPlugin = plugin;
@@ -101,9 +101,8 @@ function usePluginEditor(props) {
101
101
  * When the user tries to change the plugin kind, make sure we have the correct spec for that plugin kind before we
102
102
  * make the switch.
103
103
  */ const onSelectionChange = (nextSelection)=>{
104
- var _prevSpecState_current_nextSelection_type;
105
104
  // If we already have state for this plugin type/kind from a previous selection, just use it
106
- const previousState = (_prevSpecState_current_nextSelection_type = prevSpecState.current[nextSelection.type]) === null || _prevSpecState_current_nextSelection_type === void 0 ? void 0 : _prevSpecState_current_nextSelection_type[nextSelection.kind];
105
+ const previousState = prevSpecState.current[nextSelection.type]?.[nextSelection.kind];
107
106
  if (previousState !== undefined) {
108
107
  rememberCurrentSpecState();
109
108
  onChange({
@@ -30,15 +30,14 @@ const PluginKindSelect = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
30
30
  // Pass an empty value while options are still loading so MUI doesn't complain about us using an "out of range" value
31
31
  const value = !propValue || isLoading ? '' : selectionToOptionValue(propValue);
32
32
  const handleChange = (event)=>{
33
- onChange === null || onChange === void 0 ? void 0 : onChange(optionValueToSelection(event.target.value));
33
+ onChange?.(optionValueToSelection(event.target.value));
34
34
  };
35
35
  const renderValue = (0, _react.useCallback)((selected)=>{
36
- var _data_find;
37
36
  if (selected === '') {
38
37
  return '';
39
38
  }
40
39
  const selectedValue = optionValueToSelection(selected);
41
- return data === null || data === void 0 ? void 0 : (_data_find = data.find((v)=>v.pluginType === selectedValue.type && v.kind === selectedValue.kind)) === null || _data_find === void 0 ? void 0 : _data_find.display.name;
40
+ return data?.find((v)=>v.kind === selectedValue.type && v.spec.name === selectedValue.kind)?.spec.display.name;
42
41
  }, [
43
42
  data
44
43
  ]);
@@ -59,14 +58,14 @@ const PluginKindSelect = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
59
58
  value: "",
60
59
  children: "Loading..."
61
60
  }),
62
- data === null || data === void 0 ? void 0 : data.map((metadata)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
61
+ data?.map((metadata)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
63
62
  "data-testid": "option",
64
63
  value: selectionToOptionValue({
65
- type: metadata.pluginType,
66
- kind: metadata.kind
64
+ type: metadata.kind,
65
+ kind: metadata.spec.name
67
66
  }),
68
- children: metadata.display.name
69
- }, metadata.pluginType + metadata.kind))
67
+ children: metadata.spec.display.name
68
+ }, metadata.kind + metadata.spec.name))
70
69
  ]
71
70
  });
72
71
  });
@@ -42,21 +42,21 @@ function PluginRegistry(props) {
42
42
  }
43
43
  return request;
44
44
  });
45
- const getPlugin = (0, _react.useCallback)(async (pluginType, kind)=>{
45
+ const getPlugin = (0, _react.useCallback)(async (kind, name)=>{
46
46
  // Get the indexes of the installed plugins
47
47
  const pluginIndexes = await getPluginIndexes();
48
48
  // Figure out what module the plugin is in by looking in the index
49
- const typeAndKindKey = (0, _pluginindexes.getTypeAndKindKey)(pluginType, kind);
50
- const resource = pluginIndexes.pluginResourcesByTypeAndKind.get(typeAndKindKey);
49
+ const typeAndKindKey = (0, _pluginindexes.getTypeAndKindKey)(kind, name);
50
+ const resource = pluginIndexes.pluginResourcesByNameAndKind.get(typeAndKindKey);
51
51
  if (resource === undefined) {
52
- throw new Error(`A ${pluginType} plugin for kind '${kind}' is not installed`);
52
+ throw new Error(`A ${name} plugin for kind '${kind}' is not installed`);
53
53
  }
54
54
  // Treat the plugin module as a bunch of named exports that have plugins
55
55
  const pluginModule = await loadPluginModule(resource);
56
56
  // We currently assume that plugin modules will have named exports that match the kinds they handle
57
- const plugin = pluginModule[kind];
57
+ const plugin = pluginModule[name];
58
58
  if (plugin === undefined) {
59
- throw new Error(`The ${pluginType} plugin for kind '${kind}' is missing from the ${resource.metadata.name} plugin module`);
59
+ throw new Error(`The ${name} plugin for kind '${kind}' is missing from the ${resource.metadata.name} plugin module`);
60
60
  }
61
61
  return plugin;
62
62
  }, [
@@ -65,10 +65,7 @@ function PluginRegistry(props) {
65
65
  ]);
66
66
  const listPluginMetadata = (0, _react.useCallback)(async (pluginTypes)=>{
67
67
  const pluginIndexes = await getPluginIndexes();
68
- return pluginTypes.flatMap((type)=>{
69
- var _pluginIndexes_pluginMetadataByType_get;
70
- return (_pluginIndexes_pluginMetadataByType_get = pluginIndexes.pluginMetadataByType.get(type)) !== null && _pluginIndexes_pluginMetadataByType_get !== void 0 ? _pluginIndexes_pluginMetadataByType_get : [];
71
- });
68
+ return pluginTypes.flatMap((type)=>pluginIndexes.pluginMetadataByKind.get(type) ?? []);
72
69
  }, [
73
70
  getPluginIndexes
74
71
  ]);
@@ -36,29 +36,32 @@ function usePluginIndexes(getInstalledPlugins) {
36
36
  const createPluginIndexes = (0, _core.useEvent)(async ()=>{
37
37
  const installedPlugins = await getInstalledPlugins();
38
38
  // Create the two indexes from the installed plugins
39
- const pluginResourcesByTypeAndKind = new Map();
40
- const pluginMetadataByType = new Map();
39
+ const pluginResourcesByNameAndKind = new Map();
40
+ const pluginMetadataByKind = new Map();
41
41
  for (const resource of installedPlugins){
42
42
  for (const pluginMetadata of resource.spec.plugins){
43
- const { pluginType, kind } = pluginMetadata;
43
+ const { kind, spec: { name } } = pluginMetadata;
44
44
  // Index the plugin by type and kind to point at the module that contains it
45
- const key = getTypeAndKindKey(pluginType, kind);
46
- if (pluginResourcesByTypeAndKind.has(key)) {
47
- console.warn(`Got more than one ${pluginType} plugin for kind ${kind}`);
45
+ const key = getTypeAndKindKey(kind, name);
46
+ if (pluginResourcesByNameAndKind.has(key)) {
47
+ console.warn(`Got more than one ${kind} plugin for kind ${name}`);
48
48
  }
49
- pluginResourcesByTypeAndKind.set(key, resource);
49
+ pluginResourcesByNameAndKind.set(key, resource);
50
50
  // Index the metadata by plugin type
51
- let list = pluginMetadataByType.get(pluginType);
51
+ let list = pluginMetadataByKind.get(kind);
52
52
  if (list === undefined) {
53
53
  list = [];
54
- pluginMetadataByType.set(pluginType, list);
54
+ pluginMetadataByKind.set(kind, list);
55
55
  }
56
- list.push(pluginMetadata);
56
+ list.push({
57
+ ...pluginMetadata,
58
+ module: resource.metadata
59
+ });
57
60
  }
58
61
  }
59
62
  return {
60
- pluginResourcesByTypeAndKind,
61
- pluginMetadataByType
63
+ pluginResourcesByNameAndKind,
64
+ pluginMetadataByKind
62
65
  };
63
66
  });
64
67
  // De-dupe creating plugin indexes (i.e. requests to get installed plugins)
@@ -77,6 +80,6 @@ function usePluginIndexes(getInstalledPlugins) {
77
80
  ]);
78
81
  return getPluginIndexes;
79
82
  }
80
- function getTypeAndKindKey(pluginType, kind) {
81
- return `${pluginType}:${kind}`;
83
+ function getTypeAndKindKey(kind, name) {
84
+ return `${kind}:${name}`;
82
85
  }
@@ -56,7 +56,7 @@ function ProjectSelect(props) {
56
56
  })
57
57
  })
58
58
  }),
59
- data === null || data === void 0 ? void 0 : data.map((project)=>[
59
+ data?.map((project)=>[
60
60
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
61
61
  value: project.metadata.name,
62
62
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
@@ -79,8 +79,7 @@ function ProjectSelect(props) {
79
79
  * returns a string value that can be used as a Select input value.
80
80
  * @param selector
81
81
  */ function projectToOptionValue(project) {
82
- var _project_metadata_name;
83
- return (_project_metadata_name = project.metadata.name) !== null && _project_metadata_name !== void 0 ? _project_metadata_name : 'none';
82
+ return project.metadata.name ?? 'none';
84
83
  }
85
84
  /**
86
85
  * Given an option value name,