mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-19 11:16:31 +00:00
[Plugin] Plugin context (#9439)
* Pass more stuff to window * Expose form functions to plugin context * Breaking: Render plugin component in context tree - Required due to createRoot function - Adds necessary context providers * Fix context * Provide MantineThemeContext * Bundle mantine/core * Hack for useNavigate within ApiForm - Errors out if called within plugin context - Workaround to catch the error * Update build cmd * Define config for building "Library" mode * Update package.json * Add basic index file * Factor out ApiEndpoints * factor out ModelType * Factor out role enums * Further refactoring * More refactoring * Cleanup * Expose apiUrl function * Add instance data to plugin context type def * Tweaks for loading plugin components - LanguageContext must be on the inside * Tweak StylishText * Externalize notifications system * Update lingui config * Add functions for checking plugin interface version * Extract package version at build time * Enhance version checking * Revert variable name change * Public package * Add README.md * adjust packge name * Adjust name to include org * Update project files * Add basic changelog info * Refactoring to expose URL functions * Refactor navigation functions * Update package and README * Improve navigateToLink function * Refactor stylish text - Move into ./lib - Do not require user state * Revert changes - StylishText throws error in plugin - Low priority, can work out later * expose function to refresh page index * Provide RemoteComponent with a method to reload itself * Bump version * Cleanup tests * Prevent duplicate --emptyOutDir arg * Tweak playwright tests * Expose role and permission enums * Fix imports * Updated docs * Fix spelling, typos, etc * Include more package version information * Expose more version context * Cleanup * Probably don't need hooks * Fix links * Docs updates * Fix links
This commit is contained in:
54
src/frontend/lib/enums/Roles.tsx
Normal file
54
src/frontend/lib/enums/Roles.tsx
Normal file
@@ -0,0 +1,54 @@
|
||||
import { t } from '@lingui/core/macro';
|
||||
|
||||
/*
|
||||
* Enumeration of available user role groups
|
||||
*/
|
||||
export enum UserRoles {
|
||||
admin = 'admin',
|
||||
build = 'build',
|
||||
part = 'part',
|
||||
part_category = 'part_category',
|
||||
purchase_order = 'purchase_order',
|
||||
return_order = 'return_order',
|
||||
sales_order = 'sales_order',
|
||||
stock = 'stock',
|
||||
stock_location = 'stock_location',
|
||||
stocktake = 'stocktake'
|
||||
}
|
||||
|
||||
/*
|
||||
* Enumeration of available user permissions within each role group
|
||||
*/
|
||||
export enum UserPermissions {
|
||||
view = 'view',
|
||||
add = 'add',
|
||||
change = 'change',
|
||||
delete = 'delete'
|
||||
}
|
||||
|
||||
export function userRoleLabel(role: UserRoles): string {
|
||||
switch (role) {
|
||||
case UserRoles.admin:
|
||||
return t`Admin`;
|
||||
case UserRoles.build:
|
||||
return t`Build Orders`;
|
||||
case UserRoles.part:
|
||||
return t`Parts`;
|
||||
case UserRoles.part_category:
|
||||
return t`Part Categories`;
|
||||
case UserRoles.purchase_order:
|
||||
return t`Purchase Orders`;
|
||||
case UserRoles.return_order:
|
||||
return t`Return Orders`;
|
||||
case UserRoles.sales_order:
|
||||
return t`Sales Orders`;
|
||||
case UserRoles.stock:
|
||||
return t`Stock Items`;
|
||||
case UserRoles.stock_location:
|
||||
return t`Stock Location`;
|
||||
case UserRoles.stocktake:
|
||||
return t`Stocktake`;
|
||||
default:
|
||||
return role as string;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user