feat(admin): material column + inline material manager in the Sessions view
- Sessions table gains a Material column (uploaded pill with the clean filename in its tooltip, dash when none) - Expanded session row: shared MaterialPanel (open / download / delete with confirm) plus immediate upload/replace via MaterialUploadRow - Schedule session modal refactored onto the same MaterialPanel; its upload keeps the uploads-on-Save behavior - sessions-view e2e: new test pins the pill, panel buttons, clean filename, unlock hint and replace control Co-authored-by: Stephan Charles <[email protected]> Co-authored-by: Amelia Hernandez <[email protected]> Co-authored-by: Markus Franz <[email protected]> Co-authored-by: Sabrina Hota <[email protected]> Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
1 parent
22d2418125
commit
45ab567355
6 files changed
+210
-77
No files matched your search
@@ -2,21 +2,18 @@ import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { supabase } from '../lib/supabase';
|
||||
import {
|
||||
deleteEventSchedule,
|
||||
downloadSessionMaterial,
|
||||
getAllContacts,
|
||||
getAllSessionSpeakers,
|
||||
getActiveEvent,
|
||||
getSessions,
|
||||
getSlots,
|
||||
removeSessionMaterial,
|
||||
openSessionMaterial,
|
||||
sessionMaterialName,
|
||||
setSessionSpeakers,
|
||||
uploadSessionMaterial,
|
||||
} from '../lib/api';
|
||||
import type { Contact, Event, Session, SessionSpeaker, Slot, SlotType } from '../lib/types';
|
||||
import { useSilentRefresh } from '../lib/useSilentRefresh';
|
||||
import { useToast } from '../context/ToastContext';
|
||||
import { MaterialPanel } from '../components/MaterialPanel';
|
||||
import { Empty, Modal, Spinner, TypeBadge } from '../components/ui';
|
||||
|
||||
const SLOT_TYPES: SlotType[] = ['session', 'service_session'];
|
||||
@@ -470,8 +467,6 @@ function SessionModal({
|
||||
const [area, setArea] = useState(session?.area ?? '');
|
||||
const [speakerEmails, setSpeakerEmails] = useState<string[]>(currentSpeakers);
|
||||
const [material, setMaterial] = useState<File | null>(null);
|
||||
const [matBusy, setMatBusy] = useState(false);
|
||||
const [matError, setMatError] = useState<string | null>(null);
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
async function save() {
|
||||
@@ -580,66 +575,11 @@ function SessionModal({
|
||||
{session && (
|
||||
<div className="field" data-testid="session-material">
|
||||
<label>Material</label>
|
||||
{session.material_path ? (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
||||
<div className="muted small">📎 {sessionMaterialName(session.material_path)}</div>
|
||||
<div className="row" style={{ gap: 10, flexWrap: 'wrap' }}>
|
||||
<button
|
||||
className="btn small"
|
||||
disabled={busy || matBusy}
|
||||
onClick={async () => {
|
||||
setMatBusy(true);
|
||||
setMatError(null);
|
||||
try {
|
||||
await openSessionMaterial(session.material_path!);
|
||||
} catch (e) {
|
||||
setMatError(e instanceof Error ? e.message : 'Could not open material');
|
||||
} finally {
|
||||
setMatBusy(false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
Open
|
||||
</button>
|
||||
<button
|
||||
className="btn small"
|
||||
disabled={busy || matBusy}
|
||||
onClick={async () => {
|
||||
setMatBusy(true);
|
||||
setMatError(null);
|
||||
try {
|
||||
await downloadSessionMaterial(session.material_path!);
|
||||
} catch (e) {
|
||||
setMatError(e instanceof Error ? e.message : 'Download failed');
|
||||
} finally {
|
||||
setMatBusy(false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
⬇ Download
|
||||
</button>
|
||||
<button
|
||||
className="btn small danger"
|
||||
disabled={busy || matBusy}
|
||||
onClick={async () => {
|
||||
if (!confirm(`Delete material "${sessionMaterialName(session.material_path!)}"? Attendees and speakers lose access immediately.`)) return;
|
||||
setMatBusy(true);
|
||||
try {
|
||||
await removeSessionMaterial(session.id);
|
||||
onSaved('Material removed');
|
||||
} catch (e) {
|
||||
setMatBusy(false);
|
||||
setMatError(e instanceof Error ? e.message : 'Delete failed');
|
||||
}
|
||||
}}
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<span className="muted small">No material uploaded yet.</span>
|
||||
)}
|
||||
<MaterialPanel
|
||||
session={session}
|
||||
unlocksAt={slot ? `${fmtDate(slot.slot_date)}, ${fmtTime(slot.end_time)}` : null}
|
||||
onChanged={() => onSaved('Material removed')}
|
||||
/>
|
||||
<input
|
||||
className="input"
|
||||
type="file"
|
||||
@@ -650,14 +590,6 @@ function SessionModal({
|
||||
{session.material_path ? 'Replaces current file on Save' : 'Uploads on Save'}: {material.name}
|
||||
</span>
|
||||
)}
|
||||
{slot && (
|
||||
<span className="muted small">
|
||||
{session.material_path
|
||||
? `Attendees can download it once the session ends (${fmtDate(slot.slot_date)}, ${fmtTime(slot.end_time)}).`
|
||||
: `Once uploaded, attendees can download it when the session ends (${fmtDate(slot.slot_date)}, ${fmtTime(slot.end_time)}).`}
|
||||
</span>
|
||||
)}
|
||||
{matError && <span className="feedback-error small">{matError}</span>}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
getLlmSettings,
|
||||
getSessions,
|
||||
getSlots,
|
||||
sessionMaterialName,
|
||||
} from '../lib/api';
|
||||
import type {
|
||||
Checkin,
|
||||
@@ -24,6 +25,7 @@ import type {
|
||||
Slot,
|
||||
} from '../lib/types';
|
||||
import { Avatar, Empty, Spinner, Tooltip } from '../components/ui';
|
||||
import { MaterialPanel, MaterialUploadRow } from '../components/MaterialPanel';
|
||||
import { useSilentRefresh } from '../lib/useSilentRefresh';
|
||||
|
||||
const timeLabel = (slot?: Slot) => (slot ? `${slot.start_time.slice(0, 5)}–${slot.end_time.slice(0, 5)}` : '');
|
||||
@@ -429,6 +431,7 @@ export function Sessions() {
|
||||
<th>When</th>
|
||||
<th>Session</th>
|
||||
<th>Speakers</th>
|
||||
<th>Material</th>
|
||||
<th style={{ textAlign: 'right' }}>Check-ins</th>
|
||||
<th style={{ textAlign: 'right' }}>Feedback</th>
|
||||
<th>AI summary</th>
|
||||
@@ -478,6 +481,19 @@ export function Sessions() {
|
||||
</div>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
{s.material_path ? (
|
||||
<Tooltip title={sessionMaterialName(s.material_path)} content="Manage it in the expanded row">
|
||||
<span className="pill green" data-testid={`material-yes-${s.id}`}>
|
||||
uploaded
|
||||
</span>
|
||||
</Tooltip>
|
||||
) : (
|
||||
<span className="muted small" data-testid={`material-none-${s.id}`}>
|
||||
—
|
||||
</span>
|
||||
)}
|
||||
</td>
|
||||
<td style={{ textAlign: 'right' }}>
|
||||
<span className={att.length > 0 ? 'att-count' : 'muted'}>{att.length}</span>
|
||||
{s.capacity ? <span className="muted small"> / {s.capacity}</span> : null}
|
||||
@@ -507,7 +523,7 @@ export function Sessions() {
|
||||
</tr>
|
||||
{open && (
|
||||
<tr className="row-detail">
|
||||
<td colSpan={6}>
|
||||
<td colSpan={7}>
|
||||
<div className="session-detail">
|
||||
{s.description && <p className="session-desc">{s.description}</p>}
|
||||
<div className="detail-cols">
|
||||
@@ -568,6 +584,15 @@ export function Sessions() {
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
<section>
|
||||
<h3 className="h3">Material</h3>
|
||||
<MaterialPanel
|
||||
session={s}
|
||||
unlocksAt={slot ? `${fmtDay(slot.slot_date)}, ${slot.end_time.slice(0, 5)}` : null}
|
||||
onChanged={() => void load(true)}
|
||||
/>
|
||||
<MaterialUploadRow session={s} onUploaded={() => void load(true)} />
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
Reference in new issue
Block a user