Add admin manual user creation and page edit approval workflow #16

Merged
Copilot merged 2 commits from copilot/add-manual-user-creation into main 2025-11-19 14:33:15 -06:00
Copilot commented 2025-11-10 14:14:38 -06:00 (Migrated from github.com)

Adds ability for admins to directly create users with passwords, and implements a toggleable approval workflow where admin approval is required for editor page edits.

Backend Changes

User Creation (routes/users.js)

  • New POST /api/users endpoint for admin-only manual user creation
  • Validates username, email, password; uses bcrypt hashing

Approval Workflow

  • New pending_page_edits table tracks unapproved changes
  • Modified PUT /api/pages/:slug checks approval_workflow_enabled setting:
    • Editors: creates/updates pending edit when enabled
    • Admins: bypass workflow entirely
  • New /api/pending-edits endpoints for list, view, approve, reject, delete operations
  • Role-based filtering: editors see own edits, admins see all

Frontend Changes

Admin Dashboard (AdminDashboard.jsx)

  • "Create User" form with username, email, password, role fields

System Settings (SettingsPage.jsx)

  • "Workflow" tab with approval workflow toggle

Pending Edits Management

  • PendingEdits.jsx: table view with approve/reject actions
  • PendingEditDetail.jsx: side-by-side comparison (current vs proposed)
  • "Pending Edits" navigation link in header for editors and admins
  • PageEditor.jsx handles approval response, redirects to pending edits

Example Usage

Admin enables workflow:

// System Settings → Workflow tab → Enable checkbox → Save
await settingsApi.update('approval_workflow_enabled', 'true', false);

Editor makes changes:

// PUT /api/pages/:slug returns
{
  message: 'Edit submitted for approval',
  pending_edit: { id, page_id, ... },
  requires_approval: true
}

Admin reviews and approves:

// Side-by-side view shows current vs proposed
// POST /api/pending-edits/:id/approve applies changes

Multiple edits to same page update existing pending edit to avoid duplicates.

Original prompt

Add the ability to manually create users and set their passwords, also add the ability to toggle on an approval workflow where an Admin has to approve edits made by an editor


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Adds ability for admins to directly create users with passwords, and implements a toggleable approval workflow where admin approval is required for editor page edits. ## Backend Changes **User Creation** (`routes/users.js`) - New `POST /api/users` endpoint for admin-only manual user creation - Validates username, email, password; uses bcrypt hashing **Approval Workflow** - New `pending_page_edits` table tracks unapproved changes - Modified `PUT /api/pages/:slug` checks `approval_workflow_enabled` setting: - Editors: creates/updates pending edit when enabled - Admins: bypass workflow entirely - New `/api/pending-edits` endpoints for list, view, approve, reject, delete operations - Role-based filtering: editors see own edits, admins see all ## Frontend Changes **Admin Dashboard** (`AdminDashboard.jsx`) - "Create User" form with username, email, password, role fields **System Settings** (`SettingsPage.jsx`) - "Workflow" tab with approval workflow toggle **Pending Edits Management** - `PendingEdits.jsx`: table view with approve/reject actions - `PendingEditDetail.jsx`: side-by-side comparison (current vs proposed) - "Pending Edits" navigation link in header for editors and admins - `PageEditor.jsx` handles approval response, redirects to pending edits ## Example Usage Admin enables workflow: ```javascript // System Settings → Workflow tab → Enable checkbox → Save await settingsApi.update('approval_workflow_enabled', 'true', false); ``` Editor makes changes: ```javascript // PUT /api/pages/:slug returns { message: 'Edit submitted for approval', pending_edit: { id, page_id, ... }, requires_approval: true } ``` Admin reviews and approves: ```javascript // Side-by-side view shows current vs proposed // POST /api/pending-edits/:id/approve applies changes ``` Multiple edits to same page update existing pending edit to avoid duplicates. <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > Add the ability to manually create users and set their passwords, also add the ability to toggle on an approval workflow where an Admin has to approve edits made by an editor </details> <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.
SluberskiHomeLab (Migrated from github.com) reviewed 2025-11-10 14:14:38 -06:00
Sign in to join this conversation.
No description provided.