Content Staging Controls

Admin → Gold
💰 $2000

Push draft pages or settings to production environments manually.

Technology iconTechnology iconTechnology icon

Content Staging Controls Overview

Purpose

The Content Staging Controls module provides a mechanism for developers to manually deploy draft pages or settings into production environments. This tool ensures controlled and deliberate rollouts of changes, minimizing risks associated with unplanned deployments.

Benefits

Usage Scenarios

  1. Feature Testing in Production: Developers can push draft features to production for real-world testing without impacting all users.
  2. Sensitive Changes Handling: Manage critical updates, such as database schema changes or configuration tweaks, with precision.
  3. Empowering Content Editors: Allows content editors to deploy their changes independently, reducing reliance on developers for minor updates.
  4. Complex Deployments Management: Handles intricate deployment processes, ensuring each step is executed correctly and reliably.

This module is an essential tool for developers aiming to manage content deployment efficiently, ensuring reliability and minimizing risk in production environments.

Key Features of Content Staging Controls

1. Preview Mode

2. Push to Production

3. Environment Management

4. Deployment History

5. Rollback Mechanism

6. Access Control

I’ll create detailed technical documentation for the Content Staging Controls module with realistic code samples.

1. FastAPI Endpoint (Python)

This endpoint will handle content staging operations using FastAPI.

from fastapi import APIRouter, Depends, HTTPException
import asyncio
from typing import Optional
from pydantic import BaseModel

router = APIRouter()
lock = asyncio.Lock()

class StagingRequest(BaseModel):
    environment: str
    content_id: str
    version: str
    include_feedback: bool = False

STAGING_STATUS = {
    "status": "idle",
    "message": "",
    "timestamp": None,
}

async def stage_content(request: StagingRequest):
    async with lock:
        # Simulate staging process
        if not request.include_feedback:
            await asyncio.sleep(1)
            return {"success": True, "message": f"Content {request.content_id} staged to {request.environment}"}
        else:
            await asyncio.sleep(2)
            raise HTTPException(status_code=503, detail="Feedback processing failed")

@router.post("/api/stage-content", response_model=dict)
async def trigger_stage(request: StagingRequest):
    try:
        result = await stage_content(request)
        return {"status": "success", "data": result}
    except Exception as e:
        return {"status": "error", "message": str(e)}

2. React UI Component (JavaScript/TypeScript)

This component provides a user interface for content staging.

import React, { useState, useEffect } from 'react';

interface StagingStatus {
    status: string;
    message: string;
    timestamp?: Date;
}

export const StageContent = () => {
    const [contentId, setContentId] = useState('');
    const [environment, setEnvironment] = useState('production');
    const [isStaging, setIsStaging] = useState(false);
    const [status, setStatus] = useState<StagingStatus>({ status: 'idle', message: '' });

    const handleSubmit = async (e: React.FormEvent) => {
        e.preventDefault();
        setIsStaging(true);
        setStatus({ status: 'processing', message: 'Starting content staging...' });
        
        try {
            const response = await fetch('/api/stage-content', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                },
                body: JSON.stringify({
                    environment,
                    content_id: contentId,
                    version: 'current',
                }),
            });

            if (!response.ok) {
                throw new Error('Failed to stage content');
            }

            const result = await response.json();
            
            if (result.status === 'success') {
                setStatus({ status: 'complete', message: result.data.message });
            }
        } catch (error) {
            setStatus({ 
                status: 'error', 
                message: error instanceof Error ? error.message : 'Failed to stage content' 
            });
        }

        setIsStaging(false);
    };

    useEffect(() => {
        if (status.status === 'processing') {
            const interval = setInterval(async () => {
                try {
                    const response = await fetch('/api/stage-content/status', {
                        method: 'GET',
                    });

                    if (!response.ok) throw new Error('Failed to get status');
                    
                    const result = await response.json();
                    setStatus(result.data);
                } catch (error) {
                    setStatus({ 
                        status: 'error', 
                        message: error instanceof Error ? error.message : 'Failed to get status' 
                    });
                    clearInterval(interval);
                }
            }, 5000);

            return () => clearInterval(interval);
        }
    }, [status.status]);

    return (
        <form onSubmit={handleSubmit} className="staging-form">
            <div className="form-group">
                <label htmlFor="contentId">Content ID</label>
                <input
                    type="text"
                    id="contentId"
                    value={contentId}
                    onChange={(e) => setContentId(e.target.value)}
                    required
                />
            </div>

            <div className="form-group">
                <label htmlFor="environment">Environment</label>
                <select
                    id="environment"
                    value={environment}
                    onChange={(e) => setEnvironment(e.target.value)}
                >
                    <option value="production">Production</option>
                    <option value="staging">Staging</option>
                </select>
            </div>

            {isStaging && (
                <button type="submit" disabled>
                    Staging in progress...
                </button>
            )}

            {!isStaging && (
                <button type="submit">
                    Stage Content
                </button>
            )}

            {status.status !== 'idle' && (
                <div className="status-indicator">
                    <span className={`${status.status} ${status.status}`}>
                        {status.message}
                    </span>
                </div>
            )}
        </form>
    );
};

3. Data Schema (Pydantic)

This defines the structure for content staging requests.

from pydantic import BaseModel, Field

class StagingRequest(BaseModel):
    environment: str = Field(..., description="Target environment", example=["production", "staging"])
    content_id: str = Field(..., description="Unique content identifier", example="content-123")
    version: str = Field(..., description="Content version", example="v1.0.0")
    include_feedback: bool = Field(
        False,
        description="Include feedback in the staging process",
        example=False
    )

    class Config:
        json_schema_extra = {
            "example": {
                "environment": "production",
                "content_id": "homepage-seo-2023",
                "version": "v1.2.0",
                "include_feedback": True
            }
        }

Explanation

  1. FastAPI Endpoint
  1. React UI Component
  1. Data Schema (Pydantic)

This implementation provides a complete solution for manual content staging, including:

Content Staging Controls Module

Overview

The Content Staging Controls module provides tools for developers to manually push draft content, pages, or settings to production environments. This module is part of the Admin category and is designed to give developers fine-grained control over content deployment.



Use Cases

1. Manual Deployment of Draft Pages

2. Selective Content Deployments

3. Deploy Settings to Production


Integration Tips

  1. Use Environment Variables for Configuration
    Store sensitive information (e.g., API keys) in environment variables and reference them during deployment.

  2. Implement Rollback Mechanisms
    Always have a rollback plan to revert changes if issues arise post-deployment.

  3. Monitor Deployments with Logs
    Use the Audit Logs module to track all deployment activities and identify potential issues quickly.

  4. Test in Staging Before Production
    Ensure that content or settings are thoroughly tested in staging environments before pushing them to production.

  5. Automate Where Possible
    While this module is for manual deployments, consider automating repetitive tasks using integration with the Environment Management module.


Configuration Options

ParameterTypeDescription
stage_nameStringName of the stage (e.g., “production”, “staging”).
source_envStringSource environment from where content/settings are pulled.
target_envStringTarget environment where content/settings will be deployed.
skip_validationBooleanSkip validation checks before deployment (use with caution).
include_settingsArray of StringsList of settings or configurations to include in the deployment.

Conclusion

The Content Staging Controls module empowers developers to manually deploy content and settings, providing flexibility and control over production environments. By integrating with related modules like Environment Management and Audit Logs, developers can ensure smooth and secure deployments.

For more details or support, refer to the Documentation Hub.