mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 04:55:44 +00:00
PUI: navigation/admin center improvements (#5953)
* First draft for refactoring the api forms including modals * Fix merging errors * Fix deepsource * Fix jsdoc * trigger: deepsource * Try to improve performance by not passing the whole definition down * First draft for switching to react-hook-form * Fix warning log in console with i18n when locale is not loaded * Fix: deepsource * Fixed RelatedModelField initial value loading and disable submit if form is not 'dirty' * Make field state hookable to state * Added nested object field to PUI form framework * Fix ts errors while integrating the new forms api into a few places * Fix: deepsource * Fix some values were not present in the submit data if the field is hidden * Handle error while loading locales * Fix: deepsource * Added few general improvements * Fix missig key prop * Fix storage deprecation warnings * Save panel state in url params * Improved admin center * Delete unused file * Fix: deepsource * Improve user drawer with descriptions * Fix api bug with plugin settings and added links to notification entries * Make plugin related settings work * Added a lot more plugin actions * Move InfoItem into own component * Use Paper for setting item to make have some border radius according to theme * Fix: deepsource * Proposal: unify system settings and admin center to one central place * Fix: deepsource * Dont add install plugin if plugins are not enabled on this instance * Fix switch links * Revert: 'Proposal: unify system settings and admin center to one central place' * Fix related model settings field * Fix key error in plugin error table * Make plugin panels loadables * Remove user/group edit modal and open the detail drawer instead
This commit is contained in:
@ -2,11 +2,15 @@
|
||||
|
||||
|
||||
# InvenTree API version
|
||||
INVENTREE_API_VERSION = 157
|
||||
INVENTREE_API_VERSION = 158
|
||||
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
|
||||
|
||||
INVENTREE_API_TEXT = """
|
||||
|
||||
v158 -> 2023-11-21 : https://github.com/inventree/InvenTree/pull/5953
|
||||
- Adds API endpoint for listing all settings of a particular plugin
|
||||
- Adds API endpoint for registry status (errors)
|
||||
|
||||
v157 -> 2023-12-02 : https://github.com/inventree/InvenTree/pull/6021
|
||||
- Add write-only "existing_image" field to Part API serializer
|
||||
|
||||
|
@ -3,9 +3,11 @@
|
||||
from django.urls import include, path, re_path
|
||||
|
||||
from django_filters.rest_framework import DjangoFilterBackend
|
||||
from drf_spectacular.utils import extend_schema
|
||||
from rest_framework import permissions, status
|
||||
from rest_framework.exceptions import NotFound
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.views import APIView
|
||||
|
||||
import plugin.serializers as PluginSerializers
|
||||
from common.api import GlobalSettingsPermissions
|
||||
@ -15,6 +17,7 @@ from InvenTree.helpers import str2bool
|
||||
from InvenTree.mixins import (CreateAPI, ListAPI, RetrieveUpdateAPI,
|
||||
RetrieveUpdateDestroyAPI, UpdateAPI)
|
||||
from InvenTree.permissions import IsSuperuser
|
||||
from plugin import registry
|
||||
from plugin.base.action.api import ActionPluginView
|
||||
from plugin.base.barcodes.api import barcode_api_urls
|
||||
from plugin.base.locate.api import LocatePluginView
|
||||
@ -251,7 +254,35 @@ def check_plugin(plugin_slug: str, plugin_pk: int) -> InvenTreePlugin:
|
||||
if not plugin_cgf.active:
|
||||
raise NotFound(detail=f"Plugin '{ref}' is not active")
|
||||
|
||||
return plugin_cgf.plugin
|
||||
plugin = plugin_cgf.plugin
|
||||
|
||||
if not plugin:
|
||||
raise NotFound(detail=f"Plugin '{ref}' not installed")
|
||||
|
||||
return plugin
|
||||
|
||||
|
||||
class PluginAllSettingList(APIView):
|
||||
"""List endpoint for all plugin settings for a specific plugin.
|
||||
|
||||
- GET: return all settings for a plugin config
|
||||
"""
|
||||
|
||||
permission_classes = [GlobalSettingsPermissions]
|
||||
|
||||
@extend_schema(responses={200: PluginSerializers.PluginSettingSerializer(many=True)})
|
||||
def get(self, request, pk):
|
||||
"""Get all settings for a plugin config."""
|
||||
|
||||
# look up the plugin
|
||||
plugin = check_plugin(None, pk)
|
||||
|
||||
settings = getattr(plugin, 'settings', {})
|
||||
|
||||
settings_dict = PluginSetting.all_settings(settings_definition=settings, plugin=plugin.plugin_config())
|
||||
|
||||
results = PluginSerializers.PluginSettingSerializer(list(settings_dict.values()), many=True).data
|
||||
return Response(results)
|
||||
|
||||
|
||||
class PluginSettingDetail(RetrieveUpdateAPI):
|
||||
@ -287,6 +318,37 @@ class PluginSettingDetail(RetrieveUpdateAPI):
|
||||
]
|
||||
|
||||
|
||||
class RegistryStatusView(APIView):
|
||||
"""Status API endpoint for the plugin registry.
|
||||
|
||||
- GET: Provide status data for the plugin registry
|
||||
"""
|
||||
|
||||
permission_classes = [IsSuperuser, ]
|
||||
|
||||
serializer_class = PluginSerializers.PluginRegistryStatusSerializer
|
||||
|
||||
@extend_schema(responses={200: PluginSerializers.PluginRegistryStatusSerializer()})
|
||||
def get(self, request):
|
||||
"""Show registry status information."""
|
||||
error_list = []
|
||||
|
||||
for stage, errors in registry.errors.items():
|
||||
for error_detail in errors:
|
||||
for name, message in error_detail.items():
|
||||
error_list.append({
|
||||
"stage": stage,
|
||||
"name": name,
|
||||
"message": message,
|
||||
})
|
||||
|
||||
result = PluginSerializers.PluginRegistryStatusSerializer({
|
||||
"registry_errors": error_list,
|
||||
}).data
|
||||
|
||||
return Response(result)
|
||||
|
||||
|
||||
plugin_api_urls = [
|
||||
re_path(r'^action/', ActionPluginView.as_view(), name='api-action-plugin'),
|
||||
re_path(r'^barcode/', include(barcode_api_urls)),
|
||||
@ -300,7 +362,10 @@ plugin_api_urls = [
|
||||
|
||||
# Detail views for a single PluginConfig item
|
||||
path(r'<int:pk>/', include([
|
||||
re_path(r'^settings/(?P<key>\w+)/', PluginSettingDetail.as_view(), name='api-plugin-setting-detail-pk'),
|
||||
re_path(r"^settings/", include([
|
||||
re_path(r'^(?P<key>\w+)/', PluginSettingDetail.as_view(), name='api-plugin-setting-detail-pk'),
|
||||
re_path(r"^.*$", PluginAllSettingList.as_view(), name="api-plugin-settings"),
|
||||
])),
|
||||
re_path(r'^activate/', PluginActivate.as_view(), name='api-plugin-detail-activate'),
|
||||
re_path(r'^.*$', PluginDetail.as_view(), name='api-plugin-detail'),
|
||||
])),
|
||||
@ -312,6 +377,9 @@ plugin_api_urls = [
|
||||
re_path(r'^install/', PluginInstall.as_view(), name='api-plugin-install'),
|
||||
re_path(r'^activate/', PluginActivate.as_view(), name='api-plugin-activate'),
|
||||
|
||||
# Registry status
|
||||
re_path(r"^status/", RegistryStatusView.as_view(), name="api-plugin-registry-status"),
|
||||
|
||||
# Anything else
|
||||
re_path(r'^.*$', PluginList.as_view(), name='api-plugin-list'),
|
||||
]))
|
||||
|
@ -174,3 +174,17 @@ class NotificationUserSettingSerializer(GenericReferencedSettingSerializer):
|
||||
EXTRA_FIELDS = ['method', ]
|
||||
|
||||
method = serializers.CharField(read_only=True)
|
||||
|
||||
|
||||
class PluginRegistryErrorSerializer(serializers.Serializer):
|
||||
"""Serializer for a plugin registry error."""
|
||||
|
||||
stage = serializers.CharField()
|
||||
name = serializers.CharField()
|
||||
message = serializers.CharField()
|
||||
|
||||
|
||||
class PluginRegistryStatusSerializer(serializers.Serializer):
|
||||
"""Serializer for plugin registry status."""
|
||||
|
||||
registry_errors = serializers.ListField(child=PluginRegistryErrorSerializer())
|
||||
|
Reference in New Issue
Block a user