CenterForDigitalHumanities / CenterForDigitalHumanities/TPEN-interfaces

Refactor: Replace console.log/alert with toast/alert dispatcher

Open
#327 0 comments 0 reactions 0 assignees View on GitHub
core functionality enhancement
Dominant language
JavaScript
Stars
2
Forks
3
PR merge metrics
No merged PRs in 30d

Description

## Description

Multiple UI components currently use `console.log()`, `console.debug()`, and `alert()` for user notifications and debugging. This creates inconsistent UX and noisy console output.

## Current State

Found 40+ instances across the codebase:

- `console.log()` in various components (line-history, projects, classroom, etc.)
- `alert()` calls in roles-handler, projects, legacy-annotator, etc.

## Proposed Solution

1. Route user-facing messages through the existing toast/alert dispatcher system:
- Use `eventDispatcher.dispatch('tpen-toast', { status, message })` for notifications
- Use `eventDispatcher.dispatch('tpen-alert', { message, buttonText })` for confirmations

2. For debug logging, consider:
- Remove debug logs entirely from production code
- Use a debug flag/wrapper that respects environment (dev vs prod)
- Leverage browser dev tools instead of inline logs

## Files Affected

- `manage/projectsHighlight.js`
- `components/roles-handler/index.js`
- `components/projects/project-list-write.js`
- `components/line-history/index.js`
- `components/legacy-annotator/plain.js`
- `components/annotorious-annotator/plain.js`
- `components/classroom/` (multiple files)
- `api/Project.js`

## Benefits

- Consistent user experience
- Cleaner console output in production
- Better error tracking and user feedback
- Easier to test notification flows

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.