Extract server UI metadata definitions

This commit is contained in:
Jage9
2026-03-08 19:40:18 -04:00
parent c3791de3a3
commit c14a4e322d
2 changed files with 118 additions and 38 deletions

View File

@@ -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: