mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-17 04:25:42 +00:00
[PUI] Plugin panel context (#8190)
* Add server-side context for panel plugin rendering * Add "context" to PluginContext type * Pass server context through to client-side rendering * Bump API version
This commit is contained in:
@ -13,6 +13,7 @@ export type PluginPanelProps = {
|
||||
label: string;
|
||||
icon?: string;
|
||||
content?: string;
|
||||
context?: any;
|
||||
source?: string;
|
||||
};
|
||||
|
||||
@ -82,7 +83,9 @@ export default function PluginPanelContent({
|
||||
func(ref.current, pluginContext);
|
||||
setError('');
|
||||
} catch (error) {
|
||||
setError(t`Error occurred while rendering plugin content`);
|
||||
setError(
|
||||
t`Error occurred while rendering plugin content: ${error}`
|
||||
);
|
||||
}
|
||||
} else {
|
||||
setError(t`Plugin did not provide panel rendering function`);
|
||||
|
@ -111,6 +111,11 @@ export function usePluginPanels({
|
||||
);
|
||||
const isHidden: boolean = panelState[identifier] ?? true;
|
||||
|
||||
const pluginContext: any = {
|
||||
...contextData,
|
||||
context: props.context
|
||||
};
|
||||
|
||||
return {
|
||||
name: identifier,
|
||||
label: props.label,
|
||||
@ -118,7 +123,7 @@ export function usePluginPanels({
|
||||
content: (
|
||||
<PluginPanelContent
|
||||
pluginProps={props}
|
||||
pluginContext={contextData}
|
||||
pluginContext={pluginContext}
|
||||
/>
|
||||
),
|
||||
hidden: isHidden
|
||||
|
Reference in New Issue
Block a user