/** * base-workdesk.js * Abstract base class for all team workdesks * Refactored: A11y improvements, extracted styles, event delegation */ import '../components/tools/ds-metrics-panel.js'; export default class BaseWorkdesk { constructor(shell) { if (new.target === BaseWorkdesk) { throw new Error('Cannot instantiate abstract class BaseWorkdesk'); } this.shell = shell; this.teamId = ''; this.teamName = ''; this.tools = []; } /** * Render the workdesk - must be implemented by subclasses */ render() { this.renderSidebar(); this.renderStage(); this.renderPanel(); } /** * Render sidebar content * Improved: Uses semantic `).join('')} `; // Event delegation for better performance and lifecycle management const toolsList = sidebar.querySelector('.tools-list'); if (toolsList) { toolsList.addEventListener('click', (e) => { const btn = e.target.closest('.tool-btn'); if (btn) { this.onToolClick(btn.dataset.tool); } }); } } /** * Render stage content - must be implemented by subclasses */ renderStage() { throw new Error('renderStage() must be implemented by subclass'); } /** * Render panel content - DEPRECATED * Panel is now configured by ds-shell.js via panel.configure() during team switch * Subclasses should not override this method */ renderPanel() { // Panel configuration is now handled by ds-shell.js // This method is kept for backwards compatibility but does nothing console.log(`[${this.teamId}] Panel configured by shell via panel-config.js`); } /** * Handle tool click - can be overridden by subclasses */ onToolClick(toolId) { console.log(`Tool clicked: ${toolId}`); const tool = this.tools.find(t => t.id === toolId); if (tool) { this.loadTool(tool); } } /** * Load a tool into the stage - can be overridden by subclasses * Improved: Loading spinner using CSS instead of Emoji */ loadTool(tool) { const stage = this.shell.stageContent; if (!stage) return; // Use a clean CSS spinner with codicon if available stage.innerHTML = `
Loading ${tool.name}...
`; } /** * Clean up workdesk - can be overridden by subclasses */ destroy() { if (this.shell.sidebarContent) { this.shell.sidebarContent.innerHTML = ''; } if (this.shell.stageContent) { this.shell.stageContent.innerHTML = ''; } } /** * Utility: Create a card element * NOTE: Deprecated - use ds-metric-card web component instead */ createCard(title, content) { return `

${title}

${content}
`; } /** * Utility: Create a button */ createButton(label, onClick) { const button = document.createElement('button'); button.className = 'button'; button.textContent = label; button.addEventListener('click', onClick); return button; } }