fix: resolve menu duplicates, route prefix conflicts, API path bugs, permissions.deleted_at, remove test plugin from production

This commit is contained in:
Agent Zero
2026-07-24 08:19:45 +02:00
parent c5588e64f6
commit 924d28cbf2
12 changed files with 61 additions and 134 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ class EntityLinksPlugin(BasePlugin):
dependencies=[],
routes=[
PluginRouteDef(
path="/api/v1/dms",
path="/api/v1/entity-links",
module="app.plugins.builtins.entity_links.routes",
router_attr="router",
),
+1 -1
View File
@@ -13,7 +13,7 @@ from app.deps import get_current_user, require_permission
from app.plugins.builtins.entity_links.models import EntityLink
from app.plugins.builtins.entity_links.schemas import EntityLinkRequest
router = APIRouter(prefix="/api/v1/dms", tags=["entity-links"])
router = APIRouter(prefix="/api/v1/entity-links", tags=["entity-links"])
contact_router = APIRouter(prefix="/api/v1/contacts", tags=["entity-links"])
VALID_ENTITY_TYPES = {"contact"}
@@ -1,7 +0,0 @@
-- Bad migration: creates table WITHOUT tenant_id (should be rejected by validator)
CREATE TABLE IF NOT EXISTS plugin_bad_table (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
title VARCHAR(200) NOT NULL,
content TEXT,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
@@ -1,10 +0,0 @@
-- Test plugin migration: creates plugin_test_data table with tenant_id
CREATE TABLE IF NOT EXISTS plugin_test_data (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
tenant_id UUID NOT NULL,
title VARCHAR(200) NOT NULL,
content TEXT,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS ix_plugin_test_data_tenant ON plugin_test_data(tenant_id);
@@ -6,6 +6,7 @@ CREATE TABLE IF NOT EXISTS permissions (
user_id UUID NOT NULL,
group_id UUID,
access_level VARCHAR(10) NOT NULL DEFAULT 'read',
deleted_at TIMESTAMPTZ,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
CONSTRAINT uq_permissions_file_user_level UNIQUE (tenant_id, file_id, user_id, access_level)
@@ -22,6 +23,7 @@ CREATE TABLE IF NOT EXISTS share_links (
expires_at TIMESTAMPTZ,
access_level VARCHAR(10) NOT NULL DEFAULT 'download',
created_by UUID,
deleted_at TIMESTAMPTZ,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
+1 -1
View File
@@ -17,7 +17,7 @@ class PermissionsPlugin(BasePlugin):
dependencies=[],
routes=[
PluginRouteDef(
path="/api/v1/dms",
path="/api/v1/permissions",
module="app.plugins.builtins.permissions.routes",
router_attr="router",
),
+1 -1
View File
@@ -20,7 +20,7 @@ from app.plugins.builtins.permissions.schemas import (
ShareLinkVerifyRequest,
)
router = APIRouter(prefix="/api/v1/dms", tags=["permissions"])
router = APIRouter(prefix="/api/v1/permissions", tags=["permissions"])
public_router = APIRouter(prefix="/api/public", tags=["public-share"])
-49
View File
@@ -1,49 +0,0 @@
"""Sample test plugin for LeoCRM plugin system testing."""
from __future__ import annotations
from typing import Any
from app.plugins.base import BasePlugin
from app.plugins.manifest import PluginManifest
class TestSamplePlugin(BasePlugin):
"""A sample plugin for testing the plugin lifecycle."""
manifest = PluginManifest(
name="test_sample",
version="1.0.0",
display_name="Test Sample Plugin",
description="A sample plugin for testing install/activate/deactivate/uninstall lifecycle.",
dependencies=[],
routes=[],
events=["contact.created"],
migrations=["0001_test_plugin.sql"],
permissions=[],
)
def __init__(self) -> None:
super().__init__()
self.install_called = False
self.activate_called = False
self.deactivate_called = False
self.uninstall_called = False
self.event_log: list[dict[str, Any]] = []
async def on_install(self, db, service_container) -> None:
self.install_called = True
async def on_activate(self, db, service_container, event_bus) -> None:
self.activate_called = True
await super().on_activate(db, service_container, event_bus)
async def on_deactivate(self, db, service_container, event_bus) -> None:
self.deactivate_called = True
await super().on_deactivate(db, service_container, event_bus)
async def on_uninstall(self, db, service_container) -> None:
self.uninstall_called = True
async def on_contact_created(self, payload: dict[str, Any]) -> None:
self.event_log.append({"event": "contact.created", "payload": payload})