Extract server UI metadata definitions
This commit is contained in:
@@ -107,6 +107,11 @@ from .models import (
|
||||
WelcomePacket,
|
||||
WorldItem,
|
||||
)
|
||||
from .ui_metadata import (
|
||||
ADMIN_MENU_ACTION_DEFINITIONS,
|
||||
ITEM_MANAGEMENT_ACTION_DEFINITIONS,
|
||||
MAIN_MODE_SERVER_COMMAND_DEFINITIONS,
|
||||
)
|
||||
|
||||
LOGGER = logging.getLogger("chgrid.server")
|
||||
PACKET_LOGGER = logging.getLogger("chgrid.server.packet")
|
||||
@@ -133,44 +138,6 @@ AUTH_SESSION_COOKIE_CLEAR_PATH = "/auth/session/clear"
|
||||
AUTH_SESSION_COOKIE_CLIENT_HEADER = "X-Chgrid-Auth-Client"
|
||||
AUTH_LOGIN_FAILURE_MESSAGE = "We couldn't log you in. Check your details and try again."
|
||||
AUTH_RESUME_FAILURE_MESSAGE = "We couldn't restore your session. Please log in again."
|
||||
ADMIN_MENU_ACTION_DEFINITIONS: tuple[dict[str, str], ...] = (
|
||||
{"id": "manage_roles", "label": "Role management", "tooltip": "Manage roles and their permission sets.", "permission": "role.manage"},
|
||||
{"id": "change_user_role", "label": "Change user role", "tooltip": "Change a user's assigned role.", "permission": "user.change_role"},
|
||||
{"id": "ban_user", "label": "Ban user", "tooltip": "Disable a user account.", "permission": "user.ban_unban"},
|
||||
{"id": "unban_user", "label": "Unban user", "tooltip": "Re-enable a disabled user account.", "permission": "user.ban_unban"},
|
||||
{"id": "delete_account", "label": "Delete account", "tooltip": "Delete a user account permanently.", "permission": "account.delete.any"},
|
||||
)
|
||||
|
||||
ITEM_MANAGEMENT_ACTION_DEFINITIONS: tuple[dict[str, str], ...] = (
|
||||
{
|
||||
"id": "transfer",
|
||||
"label": "Transfer item",
|
||||
"tooltip": "Transfer this item to another user.",
|
||||
"anyPermission": "item.transfer.any",
|
||||
"ownPermission": "item.transfer.own",
|
||||
},
|
||||
{
|
||||
"id": "delete",
|
||||
"label": "Delete item",
|
||||
"tooltip": "Delete this item from the world.",
|
||||
"anyPermission": "item.delete.any",
|
||||
"ownPermission": "item.delete.own",
|
||||
},
|
||||
)
|
||||
|
||||
MAIN_MODE_SERVER_COMMAND_DEFINITIONS: tuple[dict[str, str], ...] = (
|
||||
{"id": "addItem", "label": "Add item", "tooltip": "Open the add-item menu."},
|
||||
{"id": "useItem", "label": "Use item", "tooltip": "Use the carried item or a usable item on your current square."},
|
||||
{
|
||||
"id": "secondaryUseItem",
|
||||
"label": "Secondary item action",
|
||||
"tooltip": "Run the secondary action for the carried item or a usable item on your current square.",
|
||||
},
|
||||
{"id": "pickupDropItem", "label": "Pick up or drop item", "tooltip": "Pick up an item or drop your carried item."},
|
||||
{"id": "openItemManagement", "label": "Item management", "tooltip": "Open item management actions for items on your square."},
|
||||
{"id": "editItem", "label": "Edit item properties", "tooltip": "Edit the carried item or an item on your current square."},
|
||||
{"id": "inspectItem", "label": "Inspect item properties", "tooltip": "Inspect all properties for the carried item or an item on your current square."},
|
||||
)
|
||||
|
||||
|
||||
class SignalingServer:
|
||||
|
||||
113
server/app/ui_metadata.py
Normal file
113
server/app/ui_metadata.py
Normal file
@@ -0,0 +1,113 @@
|
||||
"""Server-owned UI metadata for menus and server-backed command surfaces."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TypedDict
|
||||
|
||||
|
||||
class AdminMenuActionDefinition(TypedDict):
|
||||
"""Server-authored metadata for one admin root action."""
|
||||
|
||||
id: str
|
||||
label: str
|
||||
tooltip: str
|
||||
permission: str
|
||||
|
||||
|
||||
class ItemManagementActionDefinition(TypedDict):
|
||||
"""Server-authored metadata for one item-management action."""
|
||||
|
||||
id: str
|
||||
label: str
|
||||
tooltip: str
|
||||
anyPermission: str
|
||||
ownPermission: str
|
||||
|
||||
|
||||
class MainModeServerCommandDefinition(TypedDict):
|
||||
"""Server-authored metadata for one server-backed main-mode command."""
|
||||
|
||||
id: str
|
||||
label: str
|
||||
tooltip: str
|
||||
|
||||
|
||||
ADMIN_MENU_ACTION_DEFINITIONS: tuple[AdminMenuActionDefinition, ...] = (
|
||||
{
|
||||
"id": "manage_roles",
|
||||
"label": "Role management",
|
||||
"tooltip": "Manage roles and their permission sets.",
|
||||
"permission": "role.manage",
|
||||
},
|
||||
{
|
||||
"id": "change_user_role",
|
||||
"label": "Change user role",
|
||||
"tooltip": "Change a user's assigned role.",
|
||||
"permission": "user.change_role",
|
||||
},
|
||||
{
|
||||
"id": "ban_user",
|
||||
"label": "Ban user",
|
||||
"tooltip": "Disable a user account.",
|
||||
"permission": "user.ban_unban",
|
||||
},
|
||||
{
|
||||
"id": "unban_user",
|
||||
"label": "Unban user",
|
||||
"tooltip": "Re-enable a disabled user account.",
|
||||
"permission": "user.ban_unban",
|
||||
},
|
||||
{
|
||||
"id": "delete_account",
|
||||
"label": "Delete account",
|
||||
"tooltip": "Delete a user account permanently.",
|
||||
"permission": "account.delete.any",
|
||||
},
|
||||
)
|
||||
|
||||
ITEM_MANAGEMENT_ACTION_DEFINITIONS: tuple[ItemManagementActionDefinition, ...] = (
|
||||
{
|
||||
"id": "transfer",
|
||||
"label": "Transfer item",
|
||||
"tooltip": "Transfer this item to another user.",
|
||||
"anyPermission": "item.transfer.any",
|
||||
"ownPermission": "item.transfer.own",
|
||||
},
|
||||
{
|
||||
"id": "delete",
|
||||
"label": "Delete item",
|
||||
"tooltip": "Delete this item from the world.",
|
||||
"anyPermission": "item.delete.any",
|
||||
"ownPermission": "item.delete.own",
|
||||
},
|
||||
)
|
||||
|
||||
MAIN_MODE_SERVER_COMMAND_DEFINITIONS: tuple[MainModeServerCommandDefinition, ...] = (
|
||||
{"id": "addItem", "label": "Add item", "tooltip": "Open the add-item menu."},
|
||||
{"id": "useItem", "label": "Use item", "tooltip": "Use the carried item or a usable item on your current square."},
|
||||
{
|
||||
"id": "secondaryUseItem",
|
||||
"label": "Secondary item action",
|
||||
"tooltip": "Run the secondary action for the carried item or a usable item on your current square.",
|
||||
},
|
||||
{
|
||||
"id": "pickupDropItem",
|
||||
"label": "Pick up or drop item",
|
||||
"tooltip": "Pick up an item or drop your carried item.",
|
||||
},
|
||||
{
|
||||
"id": "openItemManagement",
|
||||
"label": "Item management",
|
||||
"tooltip": "Open item management actions for items on your square.",
|
||||
},
|
||||
{
|
||||
"id": "editItem",
|
||||
"label": "Edit item properties",
|
||||
"tooltip": "Edit the carried item or an item on your current square.",
|
||||
},
|
||||
{
|
||||
"id": "inspectItem",
|
||||
"label": "Inspect item properties",
|
||||
"tooltip": "Inspect all properties for the carried item or an item on your current square.",
|
||||
},
|
||||
)
|
||||
Reference in New Issue
Block a user