{
setIsViewerModalOpen(false);
setViewerContentId(null);
}}
contentId={viewerContentId}
/>
```
---
#### Task 3.2: Add Status Indicator Columns
**Files to modify:**
- `frontend/src/config/pages/content.config.tsx`
**Changes:**
```typescript
// Add after 'status' column
{
key: 'prompts_status',
label: 'Prompts',
sortable: false,
render: (value: any, row: ContentType) => {
// Check if prompts exist (need to add this to API response)
const hasPrompts = row.image_prompts_count > 0;
return (
{hasPrompts ? (
<>
{row.image_prompts_count} prompts
>
) : (
'No prompts'
)}
);
},
},
{
key: 'images_status',
label: 'Images',
sortable: false,
render: (value: any, row: ContentType) => {
const generatedCount = row.images_generated_count || 0;
const totalCount = row.images_total_count || 0;
if (totalCount === 0) {
return No images;
}
const isComplete = generatedCount === totalCount;
const isPartial = generatedCount > 0 && generatedCount < totalCount;
return (
{isComplete && }
{generatedCount}/{totalCount}
);
},
},
```
**Backend Changes Needed:**
- Add fields to Content API response:
- `image_prompts_count`
- `images_generated_count`
- `images_total_count`
---
### Priority 4: Add "Review" Status Workflow
#### Task 4.1: Backend Model Changes
**Files to modify:**
- `backend/igny8_core/modules/writer/models.py`
**Changes:**
```python
class Content(models.Model):
STATUS_CHOICES = [
('draft', 'Draft'),
('review', 'In Review'), # NEW STATUS
('published', 'Published'),
]
status = models.CharField(
max_length=20,
choices=STATUS_CHOICES,
default='draft',
db_index=True,
)
```
**Migration:**
```bash
cd backend
python manage.py makemigrations writer
python manage.py migrate writer
```
---
#### Task 4.2: Auto-Status Change on Image Generation
**Files to modify:**
- `backend/igny8_core/modules/writer/services/image_generation.py` (or wherever images are generated)
**Changes:**
```python
def on_images_generated(content_id):
"""Called when all images for content are successfully generated"""
content = Content.objects.get(id=content_id)
# Auto-transition draft → review when images complete
if content.status == 'draft':
content.status = 'review'
content.save(update_fields=['status'])
# Optional: Create notification/log entry
logger.info(f"Content {content_id} auto-transitioned to 'review' after image generation")
```
---
#### Task 4.3: Frontend Status Updates
**Files to modify:**
- All status badge renderers
- All status filter options
- All status update modals
**Changes:**
```typescript
// Update status options everywhere
const STATUS_OPTIONS = [
{ value: 'draft', label: 'Draft' },
{ value: 'review', label: 'In Review' }, // NEW
{ value: 'published', label: 'Published' },
];
// Update badge variants
const getStatusVariant = (status: string) => {
switch (status) {
case 'draft': return 'default';
case 'review': return 'warning'; // NEW
case 'published': return 'success';
default: return 'default';
}
};
```
---
### Priority 5: Remove WordPress Publishing from Images Page
#### Task 5.1: Update Images Page Configuration
**Files to modify:**
- `frontend/src/config/pages/table-actions.config.tsx`
**Changes:**
```typescript
'/writer/images': {
rowActions: [
{
key: 'update_status',
label: 'Update Status',
icon: ,
variant: 'primary',
},
// REMOVED: publish_wordpress action
],
bulkActions: [
// REMOVED: bulk_publish_wordpress action
],
},
```
---
#### Task 5.2: Clean Up Images Page Code
**Files to modify:**
- `frontend/src/pages/Writer/Images.tsx`
**Changes:**
- Remove WordPress publishing handlers
- Remove related imports
- Simplify row action handler
- Remove WordPress-related state
---
### Priority 6: Visual Indicators for Published Items
#### Task 6.1: Add Published Badge to All Tables
**Files to modify:**
- All page configs (tasks, content, images, published)
**Changes:**
```typescript
// Add to title or status column render
{
key: 'title',
label: 'Title',
render: (value: string, row: any) => (
{value}
{row.external_id && (
WP
)}
),
},
```
---
## Implementation Checklist
### Phase 1: Critical Bugs (Week 1)
- [ ] Fix Images page bulk select (add `id` field)
- [ ] Fix Images page delete functions
- [ ] Test both fixes thoroughly
### Phase 2: Published Page (Week 1-2)
- [ ] Create `published.config.tsx`
- [ ] Rewrite `Published.tsx` component
- [ ] Update table actions config
- [ ] Add WordPress publishing handlers
- [ ] Test all functionality
### Phase 3: Content Enhancements (Week 2)
- [ ] Add content viewer link to title column
- [ ] Create/import ContentViewerModal
- [ ] Add backend fields for prompt/image counts
- [ ] Add status indicator columns
- [ ] Update content.config.tsx
- [ ] Test viewer and indicators
### Phase 4: Review Status (Week 2-3)
- [ ] Create Django migration for new status
- [ ] Update backend model
- [ ] Add auto-transition logic
- [ ] Update all frontend status options
- [ ] Update all status badge renders
- [ ] Update filters across all pages
- [ ] Test complete workflow
### Phase 5: WordPress Publishing Migration (Week 3)
- [ ] Remove WordPress actions from Images page
- [ ] Remove WordPress code from Images.tsx
- [ ] Verify Published page has all WordPress functionality
- [ ] Test end-to-end publishing workflow
### Phase 6: Visual Polish (Week 3)
- [ ] Add published badges to all table titles
- [ ] Add WordPress status indicators
- [ ] Add color coding for statuses
- [ ] Add icons for published items
- [ ] Polish UI across all pages
### Phase 7: Testing & Documentation (Week 4)
- [ ] Full regression testing
- [ ] User acceptance testing
- [ ] Update user documentation
- [ ] Create migration guide for users
- [ ] Deploy to staging
- [ ] Final production deployment
---
## API Endpoints Required
### New Endpoints
```
POST /v1/publisher/publish/
- Publish content to WordPress
- Body: { content_id, destinations: ['wordpress'] }
- Response: { success, data: { external_id, external_url }, error }
GET /v1/writer/content/{id}/
- Get single content with full details
- Response includes: prompts_count, images_count, etc.
PATCH /v1/writer/content/{id}/
- Update content status
- Body: { status: 'draft' | 'review' | 'published' }
```
### Enhanced Endpoints
```
GET /v1/writer/content/
- Add fields to response:
- image_prompts_count
- images_generated_count
- images_total_count
- sync_status
- external_id
- external_url
```
---
## Data Flow Diagrams
### Current Flow
```
Tasks (queued)
→ Generate Content
→ Tasks (completed) + Content (draft)
→ Generate Image Prompts
→ Content (draft) + ImagePrompts
→ Generate Images
→ Content (draft) + Images
→ [Manual publish from Images page]
→ WordPress
```
### New Flow (After Refactoring)
```
Tasks (queued)
→ Generate Content
→ Tasks (completed) + Content (draft)
→ Generate Image Prompts
→ Content (draft) + ImagePrompts
→ Generate Images
→ Content (review) + Images ← AUTO STATUS CHANGE
→ [Review in Published page]
→ [Edit if needed]
→ [Publish to WordPress from Published page]
→ Content (published) + WordPress Post
```
---
## Risk Assessment
### High Risk
1. **Database Migration for Review Status**
- Mitigation: Test on staging first, have rollback plan
- Impact: Could affect existing content if not handled properly
2. **Breaking Changes to Content API**
- Mitigation: Add new fields as optional, maintain backward compatibility
- Impact: Other parts of app might depend on current response shape
### Medium Risk
1. **Auto-Status Transition Logic**
- Mitigation: Make it configurable, add feature flag
- Impact: Could change status unexpectedly if logic is wrong
2. **WordPress Publishing Removal from Images**
- Mitigation: Ensure Published page fully functional before removing
- Impact: Users might look for publish button in wrong place
### Low Risk
1. **UI Changes (badges, indicators)**
- Mitigation: Can be easily reverted
- Impact: Purely cosmetic
2. **Content Viewer Modal**
- Mitigation: Independent feature, doesn't affect core functionality
- Impact: Just adds convenience
---
## Success Metrics
### Functional Metrics
- [ ] All bulk select checkboxes working across all pages
- [ ] Delete functions working (single and bulk)
- [ ] Published page shows Content table (not Tasks)
- [ ] WordPress publishing only available on Published page
- [ ] "Review" status visible and functional
- [ ] Auto-status change working when images generated
- [ ] Content viewer accessible from title links
- [ ] Status indicators showing prompt/image progress
### User Experience Metrics
- [ ] Reduced clicks to publish content (consolidated on one page)
- [ ] Clear visual feedback for publish status
- [ ] Intuitive workflow: draft → review → published
- [ ] Easy access to content viewing
- [ ] Clear status progression indicators
### Technical Metrics
- [ ] No console errors
- [ ] All API calls successful
- [ ] Proper error handling throughout
- [ ] Consistent response times
- [ ] Proper loading states
---
## Rollback Plan
If critical issues arise:
1. **Phase 1-2 Issues (Bugs/Published Page):**
- Revert Published.tsx to `` wrapper
- Disable new delete handlers
- Restore selection functionality
2. **Phase 4 Issues (Review Status):**
- Rollback database migration
- Restore previous status options
- Disable auto-transition logic
3. **Phase 5 Issues (WordPress Migration):**
- Re-enable WordPress publishing on Images page
- Disable on Published page temporarily
---
## Future Enhancements (Post-Refactoring)
1. **Bulk Edit Mode** - Edit multiple content items at once
2. **Scheduling** - Schedule WordPress publishing for future dates
3. **Publishing Templates** - Save WordPress settings as templates
4. **Draft Revisions** - Track content changes before publishing
5. **Publishing Analytics** - Track WordPress publish success rates
6. **Multi-destination Publishing** - Publish to multiple WordPress sites
7. **Content Preview** - Preview how content will look on WordPress
8. **SEO Checker** - Validate SEO before publishing
---
## Appendix: File Inventory
### Files to Modify
```
frontend/src/pages/Writer/
- Tasks.tsx (minor - visual indicators)
- Content.tsx (major - viewer link, status columns)
- Images.tsx (major - fix select, delete, remove WP)
- Published.tsx (complete rewrite)
frontend/src/config/pages/
- content.config.tsx (add columns, viewer link)
- images.config.tsx (minor updates)
- table-actions.config.tsx (update all writer sections)
- published.config.tsx (NEW FILE)
backend/igny8_core/modules/writer/
- models.py (add review status)
- services/image_generation.py (auto-status change)
- serializers.py (add new fields)
- views.py (update filters)
```
### Files to Create
```
frontend/src/config/pages/published.config.tsx
frontend/src/components/common/ContentViewerModal.tsx (if doesn't exist)
backend/igny8_core/modules/writer/migrations/XXXX_add_review_status.py
```
### Total Estimated Changes
- **Modified Files:** ~15
- **New Files:** ~3
- **Lines Changed:** ~2,000
- **Estimated Hours:** 40-60 hours
- **Estimated Calendar Time:** 3-4 weeks
---
**End of Document**
*Last Updated: December 2024*
*Document Version: 1.0*
*Author: AI Assistant (Deep Analysis Mode)*