From faefd4d1a2ad4deabe183d866fb176b2b538c343 Mon Sep 17 00:00:00 2001 From: Richard Ward Date: Wed, 31 Dec 2025 12:16:06 +0000 Subject: [PATCH] config: dialog,packages,lua (5 files) --- .../admin_dialog/scripts/action_dialog.lua | 70 ++++++++++++ .../admin_dialog/scripts/confirm_dialog.lua | 71 ++++++++++++ .../admin_dialog/scripts/delete_confirm.lua | 89 +++++++++++++++ packages/admin_dialog/seed/metadata.json | 20 +++- .../stream_cast/scripts/stream_schedule.lua | 108 ++++++++++++++++++ 5 files changed, 357 insertions(+), 1 deletion(-) create mode 100644 packages/admin_dialog/scripts/action_dialog.lua create mode 100644 packages/admin_dialog/scripts/confirm_dialog.lua create mode 100644 packages/admin_dialog/scripts/delete_confirm.lua create mode 100644 packages/stream_cast/scripts/stream_schedule.lua diff --git a/packages/admin_dialog/scripts/action_dialog.lua b/packages/admin_dialog/scripts/action_dialog.lua new file mode 100644 index 000000000..1ed61ce43 --- /dev/null +++ b/packages/admin_dialog/scripts/action_dialog.lua @@ -0,0 +1,70 @@ +-- admin_dialog: Action Dialog Component +-- Multi-purpose dialog for admin actions with custom buttons + +local M = {} + +function M.render(context) + local dialog = context.dialog or { + title = "Admin Action", + message = "Select an action to perform", + actions = { + { text = "Approve", action = "admin.action.approve", variant = "primary" }, + { text = "Reject", action = "admin.action.reject", variant = "danger" }, + { text = "Review Later", action = "admin.action.defer", variant = "secondary" } + } + } + + local actionButtons = {} + for _, actionDef in ipairs(dialog.actions) do + local buttonClass = "button admin_dialog_button_" .. (actionDef.variant or "default") + table.insert(actionButtons, { + type = "button", + className = buttonClass, + text = actionDef.text, + action = actionDef.action, + data = actionDef.data + }) + end + + return { + type = "div", + className = "admin_dialog_overlay", + children = { + { + type = "div", + className = "card admin_dialog", + children = { + { + type = "div", + className = "admin_dialog_header", + children = { + { + type = "h3", + className = "admin_dialog_title", + text = dialog.title + } + } + }, + { + type = "div", + className = "admin_dialog_body", + children = { + { + type = "p", + className = "admin_dialog_message", + text = dialog.message + } + } + }, + { + type = "div", + className = "admin_dialog_footer admin_dialog_footer_multi", + children = actionButtons + } + } + } + } + } +end + +return M diff --git a/packages/admin_dialog/scripts/confirm_dialog.lua b/packages/admin_dialog/scripts/confirm_dialog.lua new file mode 100644 index 000000000..36b267b45 --- /dev/null +++ b/packages/admin_dialog/scripts/confirm_dialog.lua @@ -0,0 +1,71 @@ +-- admin_dialog: Confirmation Dialog Component +-- Standard confirmation dialog for admin actions + +local M = {} + +function M.render(context) + local dialog = context.dialog or { + title = "Confirm Action", + message = "Are you sure you want to proceed?", + confirmText = "Confirm", + cancelText = "Cancel", + variant = "warning" + } + + local variantClass = "admin_dialog_" .. (dialog.variant or "default") + + return { + type = "div", + className = "admin_dialog_overlay", + children = { + { + type = "div", + className = "card admin_dialog " .. variantClass, + children = { + { + type = "div", + className = "admin_dialog_header", + children = { + { + type = "h3", + className = "admin_dialog_title", + text = dialog.title + } + } + }, + { + type = "div", + className = "admin_dialog_body", + children = { + { + type = "p", + className = "admin_dialog_message", + text = dialog.message + } + } + }, + { + type = "div", + className = "admin_dialog_footer", + children = { + { + type = "button", + className = "button admin_dialog_button_cancel", + text = dialog.cancelText, + action = "admin.dialog.cancel" + }, + { + type = "button", + className = "button admin_dialog_button_confirm", + text = dialog.confirmText, + action = "admin.dialog.confirm" + } + } + } + } + } + } + } +end + +return M diff --git a/packages/admin_dialog/scripts/delete_confirm.lua b/packages/admin_dialog/scripts/delete_confirm.lua new file mode 100644 index 000000000..0cca55f19 --- /dev/null +++ b/packages/admin_dialog/scripts/delete_confirm.lua @@ -0,0 +1,89 @@ +-- admin_dialog: Delete Confirmation Dialog Component +-- Specialized dialog for destructive delete actions + +local M = {} + +function M.render(context) + local item = context.item or { + type = "item", + name = "Unknown Item" + } + + return { + type = "div", + className = "admin_dialog_overlay", + children = { + { + type = "div", + className = "card admin_dialog admin_dialog_danger", + children = { + { + type = "div", + className = "admin_dialog_header", + children = { + { + type = "h3", + className = "admin_dialog_title", + text = "⚠️ Confirm Delete" + } + } + }, + { + type = "div", + className = "admin_dialog_body", + children = { + { + type = "p", + className = "admin_dialog_message", + text = "You are about to permanently delete:" + }, + { + type = "div", + className = "admin_dialog_item_info", + children = { + { + type = "strong", + text = item.name + }, + { + type = "p", + className = "admin_dialog_warning", + text = "This action cannot be undone!" + } + } + }, + { + type = "input", + className = "input admin_dialog_confirm_input", + name = "confirmText", + placeholder = "Type 'DELETE' to confirm", + required = true + } + } + }, + { + type = "div", + className = "admin_dialog_footer", + children = { + { + type = "button", + className = "button admin_dialog_button_cancel", + text = "Cancel", + action = "admin.dialog.cancel" + }, + { + type = "button", + className = "button admin_dialog_button_danger", + text = "Delete Permanently", + action = "admin.dialog.delete", + data = { itemId = item.id, itemType = item.type } + } + } + } + } + } + } + } +end + +return M diff --git a/packages/admin_dialog/seed/metadata.json b/packages/admin_dialog/seed/metadata.json index 0f5fb01e6..3c7f4eb9d 100644 --- a/packages/admin_dialog/seed/metadata.json +++ b/packages/admin_dialog/seed/metadata.json @@ -14,6 +14,11 @@ "lua_test" ], "exports": { + "scripts": [ + "confirm_dialog", + "delete_confirm", + "action_dialog" + ], "components": [] }, "tests": { @@ -42,6 +47,19 @@ "styles": "seed/styles.json" }, "storybook": { - "stories": [] + "stories": [ + { + "name": "Confirm Dialog", + "render": "confirm_dialog" + }, + { + "name": "Delete Confirmation", + "render": "delete_confirm" + }, + { + "name": "Action Dialog", + "render": "action_dialog" + } + ] } } diff --git a/packages/stream_cast/scripts/stream_schedule.lua b/packages/stream_cast/scripts/stream_schedule.lua new file mode 100644 index 000000000..e9018e1ed --- /dev/null +++ b/packages/stream_cast/scripts/stream_schedule.lua @@ -0,0 +1,108 @@ +-- stream_cast: Stream Schedule Component +-- Manage streaming schedule and upcoming broadcasts + +local M = {} + +function M.render(context) + local schedules = context.schedules or { + { id = 1, title = "Morning Gaming Session", date = "2025-01-02", time = "09:00", duration = "3h", recurring = true }, + { id = 2, title = "Tutorial Series Ep. 5", date = "2025-01-03", time = "14:00", duration = "2h", recurring = false }, + { id = 3, title = "Community Q&A", date = "2025-01-04", time = "18:00", duration = "1h", recurring = true }, + { id = 4, title = "Special Event Stream", date = "2025-01-05", time = "20:00", duration = "4h", recurring = false } + } + + local user = context.user or {} + local canManageSchedule = user.level and user.level >= 3 + + local scheduleItems = {} + for _, schedule in ipairs(schedules) do + table.insert(scheduleItems, { + type = "div", + className = "card stream_cast_schedule_item", + children = { + { + type = "div", + className = "stream_cast_schedule_header", + children = { + { + type = "h4", + className = "stream_cast_schedule_title", + text = schedule.title + }, + { + type = "span", + className = "stream_cast_schedule_badge", + text = schedule.recurring and "♻️ Recurring" or "📅 One-time" + } + } + }, + { + type = "div", + className = "stream_cast_schedule_details", + children = { + { + type = "span", + text = "📆 " .. schedule.date + }, + { + type = "span", + text = "🕐 " .. schedule.time + }, + { + type = "span", + text = "⏱️ " .. schedule.duration + } + } + }, + { + type = "div", + className = "stream_cast_schedule_actions", + children = { + { + type = "button", + className = "button stream_cast_button_small", + text = "Edit", + action = "stream.schedule.edit", + data = { scheduleId = schedule.id }, + disabled = not canManageSchedule + }, + { + type = "button", + className = "button stream_cast_button_small", + text = "Delete", + action = "stream.schedule.delete", + data = { scheduleId = schedule.id }, + disabled = not canManageSchedule + } + } + } + } + }) + end + + return { + type = "div", + className = "stream_cast_schedule", + children = { + { + type = "h2", + className = "stream_cast_heading", + text = "Stream Schedule" + }, + { + type = "div", + className = "stream_cast_schedule_list", + children = scheduleItems + }, + { + type = "button", + className = "button stream_cast_button_primary", + text = "+ Add Stream", + action = "stream.schedule.create", + disabled = not canManageSchedule + } + } + } +end + +return M