A plugin marketplace for GitHub Copilot and other AI agents that provides Power Platform development plugins, including reusable skills, agents, and commands for building and deploying solutions.
JavaScript claude-code-pluginclaude-code-skillscode-appsgithub-copilot-pluginpower-appspower-pagespower-platform
[Pages] Add status colors and compact view to ER diagram (#46)
Priyanshu Agrawal4b472ebe655a
diff --git a/plugins/power-pages/.claude-plugin/plugin.json b/plugins/power-pages/.claude-plugin/plugin.jsonindex e814c28d9..599d505d9 100644--- a/plugins/power-pages/.claude-plugin/plugin.json+++ b/plugins/power-pages/.claude-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "power-pages",- "version": "1.1.0",+ "version": "1.1.1","description": "Create and deploy Power Pages sites using modern development approaches. Supports code sites (SPAs) with React, Angular, Vue, or Astro, with more site types coming soon.","author": {"name": "Microsoft",diff --git a/plugins/power-pages/agents/assets/data-model-plan.html b/plugins/power-pages/agents/assets/data-model-plan.htmlindex 5a99dff59..0114bf840 100644--- a/plugins/power-pages/agents/assets/data-model-plan.html+++ b/plugins/power-pages/agents/assets/data-model-plan.html@@ -128,8 +128,15 @@ h3{font-size:15px;font-weight:700;color:var(--text-bright);margin-top:24px;margi.rel-arrow{color:var(--accent);font-weight:700;font-family:var(--mono);}/* ER Diagram */-.er-container{background:var(--surface);border:1px solid var(--border);border-radius:12px;padding:32px;min-height:400px;display:flex;justify-content:center;align-items:flex-start;}-.er-container .mermaid svg{max-width:100%;height:auto !important;}+.er-container{background:var(--surface);border:1px solid var(--border);border-radius:12px;padding:32px;min-height:400px;display:flex;justify-content:center;align-items:flex-start;overflow:auto;}+.er-container svg{max-width:100%;height:auto !important;}+.er-toolbar{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px;flex-wrap:wrap;gap:8px;}+.er-legend{display:flex;gap:14px;flex-wrap:wrap;}+.er-legend-item{display:flex;align-items:center;gap:5px;font-size:11px;color:var(--text-dim);font-weight:500;}+.er-legend-swatch{width:12px;height:12px;border-radius:2px;border:2px solid;}+.er-toggle{padding:5px 12px;border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--surface);color:var(--text-dim);font-size:12px;font-weight:600;cursor:pointer;font-family:var(--sans);transition:all 0.15s;}+.er-toggle:hover{border-color:var(--accent);color:var(--accent);}+.er-toggle.active{background:var(--accent-bg);border-color:var(--accent);color:var(--accent);}/* Responsive */@media(max-width:768px){@@ -205,6 +212,14 @@ h3{font-size:15px;font-weight:700;color:var(--text-bright);margin-top:24px;margi<div class="section" id="tab-diagram"><h2>ER Diagram</h2><p class="section-desc">Entity-relationship diagram showing all tables and their relationships</p>+ <div class="er-toolbar">+ <div class="er-legend">+ <div class="er-legend-item"><span class="er-legend-swatch" style="background:rgba(0,120,212,0.08);border-color:#0078d4;"></span> New</div>+ <div class="er-legend-item"><span class="er-legend-swatch" style="background:rgba(202,80,16,0.08);border-color:#ca5010;"></span> Modified</div>+ <div class="er-legend-item"><span class="er-legend-swatch" style="background:rgba(16,124,16,0.08);border-color:#107c10;"></span> Reused</div>+ </div>+ <button id="erCompactBtn" class="er-toggle" onclick="toggleErCompact()">Compact View</button>+ </div><div class="er-container" id="erDiagram"></div></div>@@ -223,7 +238,7 @@ const TABLES = __TABLES_DATA__;const RATIONALE = __RATIONALE_DATA__;// Array of { icon, title, desc }-const ER_DIAGRAM = __ER_DIAGRAM__;+const ER_DIAGRAM = `__ER_DIAGRAM__`;// Mermaid erDiagram code as a string// Tab navigation@@ -344,17 +359,143 @@ function toggleExpandAll() {document.getElementById('expandAllBtn').textContent = allExpanded ? 'Collapse All' : 'Expand All';}+// Build ER diagram Mermaid code from TABLES data+function buildErDiagram(compact) {+ const lines = ['erDiagram'];+ const entityIds = {};++ TABLES.forEach(t => {+ const eid = t.logicalName.toUpperCase().replace(/[^A-Z0-9_]/g, '_');+ entityIds[t.logicalName] = eid;+ entityIds[t.id] = eid;+ lines.push(' ' + eid + '["' + t.logicalName + ' (' + t.displayName + ')"] {');++ const cols = compact+ ? (t.columns || []).filter(c => c.key === 'PK')+ : (t.columns || []);++ cols.forEach(col => {+ const type = col.type.replace(/[.\s]/g, '_');+ const key = col.key || '';+ lines.push(' ' + type + ' ' + col.logicalName + (key ? ' ' + key : ''));+ });+ lines.push(' }');+ });++ // Add relationships (deduplicate by pair)+ const seen = new Set();+ TABLES.forEach(t => {+ if (!t.relationships) return;+ const fromId = entityIds[t.logicalName] || entityIds[t.id];+ t.relationships.forEach(r => {+ const toId = entityIds[r.relatedTable];+ if (!fromId || !toId || fromId === toId) return;++ const pairKey = [fromId, toId].sort().join('|');+ if (seen.has(pairKey)) return;+ seen.add(pairKey);++ let card = '||--o{';+ if (r.type === '1:1' || r.type === '||--||') card = '||--||';+ else if (r.type === 'N:N' || r.type === '}o--o{') card = '}o--o{';++ const label = (r.description || 'relates').substring(0, 40).replace(/"/g, "'");+ lines.push(' ' + toId + ' ' + card + ' ' + fromId + ' : "' + label + '"');+ });+ });++ return lines.join('\n');+}++// Apply status-based colors to rendered SVG entity boxes+// Mermaid v11 uses <path> elements inside g.node groups with IDs like "entity-CONTACT-0"+function colorErDiagram(container) {+ const svg = container.querySelector('svg');+ if (!svg) return;++ const headerFills = { new: '#d0e4f5', modified: '#f5dcc8', reused: '#c8e6c9' };+ const rowOddFills = { new: '#e8f2fc', modified: '#fdf0e6', reused: '#e8f5e9' };+ const rowEvenFills = { new: '#f0f7fe', modified: '#fef6ee', reused: '#f1f9f1' };+ const strokes = { new: '#0078d4', modified: '#ca5010', reused: '#107c10' };++ // Build lookup: entity ID (uppercase) → status+ const entityStatusMap = {};+ TABLES.forEach(t => {+ const eid = t.logicalName.toUpperCase().replace(/[^A-Z0-9_]/g, '_');+ entityStatusMap[eid] = t.status;+ });++ // Find entity nodes by their IDs (pattern: entity-{NAME}-{index})+ svg.querySelectorAll('g.node').forEach(node => {+ const id = node.getAttribute('id') || '';+ const match = id.match(/^entity-(.+)-\d+$/);+ if (!match) return;++ const entityName = match[1];+ const status = entityStatusMap[entityName];+ if (!status) return;++ // First child <g> contains two <path>: header fill + header outline+ const headerGroup = node.children[0];+ if (headerGroup && headerGroup.tagName === 'g') {+ const paths = headerGroup.querySelectorAll('path');+ if (paths[0]) paths[0].setAttribute('fill', headerFills[status]);+ if (paths[1]) { paths[1].setAttribute('stroke', strokes[status]); paths[1].setAttribute('stroke-width', '2'); }+ }++ // Color alternating row backgrounds+ node.querySelectorAll('.row-rect-odd, .row-rect-even').forEach(row => {+ const isOdd = row.classList.contains('row-rect-odd');+ const fillPath = row.querySelector('path');+ if (fillPath) fillPath.setAttribute('fill', isOdd ? rowOddFills[status] : rowEvenFills[status]);+ });+ });+}++// Render ER diagram (compact = PK-only, full = all columns)+let erCompact = false;+let erRenderCounter = 0;+function renderErDiagram() {+ const container = document.getElementById('erDiagram');+ let code;+ try {+ code = buildErDiagram(erCompact);+ } catch (e) {+ code = ER_DIAGRAM; // Fallback to agent-provided diagram+ }++ const renderId = 'erSvg' + (++erRenderCounter);+ mermaid.render(renderId, code).then(({ svg }) => {+ container.innerHTML = svg;+ colorErDiagram(container);+ }).catch(() => {+ // Fallback: try the agent-provided ER_DIAGRAM string+ if (code !== ER_DIAGRAM) {+ mermaid.render(renderId + 'fb', ER_DIAGRAM).then(({ svg }) => {+ container.innerHTML = svg;+ colorErDiagram(container);+ }).catch(() => {+ container.innerHTML = '<pre style="color:var(--text-dim);font-family:var(--mono);font-size:12px;white-space:pre-wrap;">' + ER_DIAGRAM.replace(/</g, '<') + '</pre>';+ });+ } else {+ container.innerHTML = '<pre style="color:var(--text-dim);font-family:var(--mono);font-size:12px;white-space:pre-wrap;">' + ER_DIAGRAM.replace(/</g, '<') + '</pre>';+ }+ });+}++function toggleErCompact() {+ erCompact = !erCompact;+ const btn = document.getElementById('erCompactBtn');+ btn.textContent = erCompact ? 'Full View' : 'Compact View';+ btn.classList.toggle('active', erCompact);+ renderErDiagram();+}+// Initmermaid.initialize({ startOnLoad: false, theme: 'default', er: { fontSize: 16, useMaxWidth: false } });renderRationale();renderTables();--// Render ER diagram using mermaid.render() to avoid DOM parsing issues-mermaid.render('erDiagramSvg', ER_DIAGRAM).then(({ svg }) => {- document.getElementById('erDiagram').innerHTML = svg;-}).catch(() => {- document.getElementById('erDiagram').innerHTML = '<pre style="color:var(--text-dim);font-family:var(--mono);font-size:12px;white-space:pre-wrap;">' + ER_DIAGRAM.replace(/</g, '<') + '</pre>';-});+renderErDiagram();</script><footer style="position:fixed;bottom:0;left:0;right:0;text-align:center;padding:10px;font-size:12px;color:#605e5c;border-top:1px solid #c8c6c4;background:#ffffff;z-index:100;">AI-generated content may be incorrect</footer></body>