mirror of
https://github.com/inventree/InvenTree.git
synced 2026-09-02 10:18:42 +00:00
frontend: more exposing for plugins (#11897)
* expose EditApiForm in context * expose renderRemoteInstance in context * expose useInstance in context * export DetailDrawerComponent, useLocalLibState * fix import/type * add changelog entry
This commit is contained in:
@@ -26,7 +26,7 @@ export interface DrawerProps {
|
||||
closeOnEscape?: boolean;
|
||||
}
|
||||
|
||||
function DetailDrawerComponent({
|
||||
export function DetailDrawerComponent({
|
||||
title,
|
||||
position = 'right',
|
||||
size,
|
||||
|
||||
@@ -135,7 +135,8 @@ export {
|
||||
export {
|
||||
type DrawerProps,
|
||||
DetailDrawer,
|
||||
DetailDrawerLink
|
||||
DetailDrawerLink,
|
||||
DetailDrawerComponent
|
||||
} from './components/nav/DetailDrawer';
|
||||
export { StylishText } from './components/StylishText';
|
||||
|
||||
@@ -144,3 +145,4 @@ export {
|
||||
type StoredTableStateProps,
|
||||
useStoredTableState
|
||||
} from './states/StoredTableState';
|
||||
export { useLocalLibState } from './states/LocalLibState';
|
||||
|
||||
@@ -7,11 +7,12 @@ import type { ModelDict } from '../enums/ModelInformation';
|
||||
import type { ModelType } from '../enums/ModelType';
|
||||
import type {
|
||||
ApiFormModalProps,
|
||||
ApiFormProps,
|
||||
BulkEditApiFormModalProps,
|
||||
StockOperationProps
|
||||
} from './Forms';
|
||||
import type { UseModalReturn } from './Modals';
|
||||
import type { RenderInstanceProps } from './Rendering';
|
||||
import type { RemoteInstanceProps, RenderInstanceProps } from './Rendering';
|
||||
import type { SettingsStateProps } from './Settings';
|
||||
import type { InvenTreeTableRenderProps } from './Tables';
|
||||
import type { UserStateProps } from './User';
|
||||
@@ -46,6 +47,7 @@ export type InvenTreeFormsContext = {
|
||||
create: (props: ApiFormModalProps) => UseModalReturn;
|
||||
delete: (props: ApiFormModalProps) => UseModalReturn;
|
||||
edit: (props: ApiFormModalProps) => UseModalReturn;
|
||||
editApiForm: (props: { id?: string; props: ApiFormProps }) => React.ReactNode;
|
||||
stockActions: StockAdjustmentFormsContext;
|
||||
};
|
||||
|
||||
@@ -97,6 +99,9 @@ export type InvenTreePluginContext = {
|
||||
globalSettings: SettingsStateProps;
|
||||
modelInformation: ModelDict;
|
||||
renderInstance: (props: Readonly<RenderInstanceProps>) => React.ReactNode;
|
||||
renderRemoteInstance: (
|
||||
props: Readonly<RemoteInstanceProps>
|
||||
) => React.ReactNode;
|
||||
host: string;
|
||||
i18n: I18n;
|
||||
locale: string;
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
import type {
|
||||
QueryObserverResult,
|
||||
UseQueryResult
|
||||
} from '@tanstack/react-query';
|
||||
import type { ReactNode } from 'react';
|
||||
import type { ApiEndpoints } from '..';
|
||||
import type { ModelType } from '../enums/ModelType';
|
||||
import type { PathParams } from './Core';
|
||||
|
||||
/**
|
||||
* Interface for rendering a model instance.
|
||||
@@ -22,4 +29,34 @@ export type ModelRendererDict = EnumDictionary<
|
||||
|
||||
export type RenderInstanceProps = {
|
||||
model: ModelType | undefined;
|
||||
custom_model?: string;
|
||||
} & InstanceRenderInterface;
|
||||
|
||||
export interface UseInstanceResult {
|
||||
instance: any;
|
||||
setInstance: (instance: any) => void;
|
||||
refreshInstance: () => void;
|
||||
refreshInstancePromise: () => Promise<QueryObserverResult<any, any>>;
|
||||
instanceQuery: UseQueryResult;
|
||||
isLoaded: boolean;
|
||||
}
|
||||
|
||||
export interface useInstanceProps {
|
||||
endpoint: ApiEndpoints;
|
||||
pk?: string | number | undefined;
|
||||
hasPrimaryKey?: boolean;
|
||||
params?: any;
|
||||
pathParams?: PathParams;
|
||||
disabled?: boolean;
|
||||
defaultValue?: any;
|
||||
refetchOnMount?: boolean;
|
||||
refetchOnWindowFocus?: boolean;
|
||||
updateInterval?: number;
|
||||
}
|
||||
|
||||
export interface RemoteInstanceProps {
|
||||
model: ModelType;
|
||||
modelUrl?: string;
|
||||
modelRenderer?: (instance: any) => ReactNode;
|
||||
pk: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user