Spaces:
Runtime error
Runtime error
File size: 3,125 Bytes
1e24842 f1c3c6d 1e24842 f1c3c6d 1e24842 f1c3c6d 1e24842 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | import React from 'react';
import { Circle, RefreshCw } from 'lucide-react';
export default function ContextPanel({ sessionContextVars, storedCredentials, onRefresh }) {
const regularVars = Object.entries(sessionContextVars || {}).filter(([k]) => !k.startsWith('__'));
return (
<div style={{ flex: 1, overflowY: 'auto', padding: 14, display: 'flex', flexDirection: 'column', gap: 16 }}>
<section>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 8 }}>
<span className="h-eyebrow">Session Variables</span>
<button onClick={onRefresh} className="ico-btn" style={{ width: 22, height: 22 }} title="Refresh">
<RefreshCw size={11}/>
</button>
</div>
<div className="panel" style={{ overflow: 'hidden' }}>
{regularVars.length === 0 ? (
<div style={{ padding: 14, textAlign: 'center' }}>
<Circle size={18} style={{ margin: '0 auto 6px', color: 'var(--fg-4)', display: 'block' }} strokeWidth={1.5}/>
<p style={{ fontSize: 11, color: 'var(--fg-3)', margin: 0, fontStyle: 'italic' }}>No variables extracted</p>
</div>
) : (
regularVars.map(([k, v]) => (
<div key={k} style={{ padding: '6px 12px', borderBottom: '1px solid var(--line-1)' }}>
<div style={{ fontSize: 10, fontWeight: 600, color: 'var(--accent)', marginBottom: 2 }}>{k}</div>
<div style={{ fontSize: 11, color: 'var(--fg-2)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{String(v)}</div>
</div>
))
)}
</div>
</section>
<section>
<div style={{ marginBottom: 8 }}>
<span className="h-eyebrow">Test Credentials</span>
</div>
<div className="panel" style={{ overflow: 'hidden' }}>
{Object.keys(storedCredentials || {}).length === 0 ? (
<div style={{ padding: 14, textAlign: 'center' }}>
<Circle size={18} style={{ margin: '0 auto 6px', color: 'var(--fg-4)', display: 'block' }} strokeWidth={1.5}/>
<p style={{ fontSize: 11, color: 'var(--fg-3)', margin: 0, fontStyle: 'italic' }}>No credentials loaded</p>
</div>
) : (
Object.entries(storedCredentials).filter(([k]) => k !== '_clear').map(([k, v]) => {
const isSensitive = k.toLowerCase().match(/(password|token|jwt|secret|bearer)/);
const display = isSensitive && v ? `${String(v).slice(0, 4)}••••` : String(v);
return (
<div key={k} style={{ padding: '6px 12px', borderBottom: '1px solid var(--line-1)' }}>
<div style={{ fontSize: 10, fontWeight: 600, color: 'var(--accent)', marginBottom: 2 }}>{k}</div>
<div style={{ fontSize: 11, color: 'var(--fg-2)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{display}</div>
</div>
);
})
)}
</div>
</section>
</div>
);
}
|