mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-15 11:35:41 +00:00
rename 'renderContext' -> 'featureContext' as not all features may render something
This commit is contained in:
@ -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;
|
||||
},
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -9,18 +9,18 @@ export type BaseUIFeature = {
|
||||
featureType: string;
|
||||
requestContext: Record<string, any>;
|
||||
responseOptions: Record<string, any>;
|
||||
renderContext: Record<string, any>;
|
||||
renderReturnType: any;
|
||||
featureContext: Record<string, any>;
|
||||
featureReturnType: any;
|
||||
};
|
||||
|
||||
export type PluginUIGetFeatureType<T extends BaseUIFeature> = (params: {
|
||||
renderContext: T['renderContext'];
|
||||
featureContext: T['featureContext'];
|
||||
inventreeContext: InvenTreeContext;
|
||||
}) => T['renderReturnType'];
|
||||
}) => T['featureReturnType'];
|
||||
|
||||
export type PluginUIFuncWithoutInvenTreeContextType<T extends BaseUIFeature> = (
|
||||
renderContext: T['renderContext']
|
||||
) => T['renderReturnType'];
|
||||
featureContext: T['featureContext']
|
||||
) => T['featureReturnType'];
|
||||
|
||||
export type PluginUIFeatureAPIResponse<T extends BaseUIFeature> = {
|
||||
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>;
|
||||
}) => void;
|
||||
};
|
||||
renderReturnType: void;
|
||||
featureReturnType: void;
|
||||
};
|
||||
|
@ -72,7 +72,7 @@ export function usePluginUIFeature<UIFeatureT extends BaseUIFeature>({
|
||||
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<UIFeatureT extends BaseUIFeature>({
|
||||
if (!func) return;
|
||||
|
||||
return func({
|
||||
renderContext,
|
||||
featureContext,
|
||||
inventreeContext
|
||||
});
|
||||
}) as PluginUIFuncWithoutInvenTreeContextType<UIFeatureT>
|
||||
|
Reference in New Issue
Block a user