diff --git a/src/backend/InvenTree/plugin/samples/static/plugin/sample_template_editor.js b/src/backend/InvenTree/plugin/samples/static/plugin/sample_template_editor.js index 6a43197535..642162b640 100644 --- a/src/backend/InvenTree/plugin/samples/static/plugin/sample_template_editor.js +++ b/src/backend/InvenTree/plugin/samples/static/plugin/sample_template_editor.js @@ -1,11 +1,11 @@ -export function getFeature({ renderContext, pluginContext }) { - const { ref } = renderContext; - console.log("Template editor feature was called with", renderContext, pluginContext); +export function getFeature({ featureContext, pluginContext }) { + const { ref } = featureContext; + console.log("Template editor feature was called with", featureContext, pluginContext); const t = document.createElement("textarea"); t.rows = 25; t.cols = 60; - renderContext.registerHandlers({ + featureContext.registerHandlers({ setCode: (code) => { t.value = code; }, diff --git a/src/backend/InvenTree/plugin/samples/static/plugin/sample_template_preview.js b/src/backend/InvenTree/plugin/samples/static/plugin/sample_template_preview.js index a23b2b28c8..c90d18d0ae 100644 --- a/src/backend/InvenTree/plugin/samples/static/plugin/sample_template_preview.js +++ b/src/backend/InvenTree/plugin/samples/static/plugin/sample_template_preview.js @@ -1,8 +1,8 @@ -export function getFeature({ renderContext, pluginContext }) { - const { ref } = renderContext; - console.log("Template preview feature was called with", renderContext, pluginContext); +export function getFeature({ featureContext, pluginContext }) { + const { ref } = featureContext; + console.log("Template preview feature was called with", featureContext, pluginContext); - renderContext.registerHandlers({ + featureContext.registerHandlers({ updatePreview: (...args) => { console.log("updatePreview", args); } diff --git a/src/frontend/src/components/plugins/PluginUIFeatureTypes.ts b/src/frontend/src/components/plugins/PluginUIFeatureTypes.ts index a187b690e6..f07f56986b 100644 --- a/src/frontend/src/components/plugins/PluginUIFeatureTypes.ts +++ b/src/frontend/src/components/plugins/PluginUIFeatureTypes.ts @@ -9,18 +9,18 @@ export type BaseUIFeature = { featureType: string; requestContext: Record; responseOptions: Record; - renderContext: Record; - renderReturnType: any; + featureContext: Record; + featureReturnType: any; }; export type PluginUIGetFeatureType = (params: { - renderContext: T['renderContext']; + featureContext: T['featureContext']; inventreeContext: InvenTreeContext; -}) => T['renderReturnType']; +}) => T['featureReturnType']; export type PluginUIFuncWithoutInvenTreeContextType = ( - renderContext: T['renderContext'] -) => T['renderReturnType']; + featureContext: T['featureContext'] +) => T['featureReturnType']; export type PluginUIFeatureAPIResponse = { feature_type: T['featureType']; @@ -40,7 +40,7 @@ export type TemplateEditorUIFeature = { title: string; icon: InvenTreeIconType; }; - renderContext: { + featureContext: { ref: HTMLDivElement; registerHandlers: (handlers: { setCode: (code: string) => void; @@ -48,7 +48,7 @@ export type TemplateEditorUIFeature = { }) => void; template: TemplateI; }; - renderReturnType: void; + featureReturnType: void; }; export type TemplatePreviewUIFeature = { @@ -62,7 +62,7 @@ export type TemplatePreviewUIFeature = { title: string; icon: InvenTreeIconType; }; - renderContext: { + featureContext: { ref: HTMLDivElement; template: TemplateI; registerHandlers: (handlers: { @@ -74,5 +74,5 @@ export type TemplatePreviewUIFeature = { ) => void | Promise; }) => void; }; - renderReturnType: void; + featureReturnType: void; }; diff --git a/src/frontend/src/hooks/UsePluginUIFeature.tsx b/src/frontend/src/hooks/UsePluginUIFeature.tsx index 8b18568632..e1b1be9fe5 100644 --- a/src/frontend/src/hooks/UsePluginUIFeature.tsx +++ b/src/frontend/src/hooks/UsePluginUIFeature.tsx @@ -72,7 +72,7 @@ export function usePluginUIFeature({ return ( pluginData?.map((feature) => ({ options: feature.options, - func: (async (renderContext) => { + func: (async (featureContext) => { const func = await findExternalPluginFunction( feature.source, 'getFeature' @@ -80,7 +80,7 @@ export function usePluginUIFeature({ if (!func) return; return func({ - renderContext, + featureContext, inventreeContext }); }) as PluginUIFuncWithoutInvenTreeContextType