refactor(embed): iframe title + captured frame ref, allow-absent test, router comment
This commit is contained in:
@@ -10,6 +10,8 @@
|
|||||||
// #/sacred-valley dashboard placeholder
|
// #/sacred-valley dashboard placeholder
|
||||||
// #/sentinel Yerin security view
|
// #/sentinel Yerin security view
|
||||||
// #/little-blue Little Blue caretaker view
|
// #/little-blue Little Blue caretaker view
|
||||||
|
// #/timelapse Timelapse iframe embed
|
||||||
|
// #/ai-usage AI Usage iframe embed
|
||||||
// Anything unrecognized falls through to the home handler.
|
// Anything unrecognized falls through to the home handler.
|
||||||
|
|
||||||
const ROUTES = [
|
const ROUTES = [
|
||||||
|
|||||||
@@ -6,16 +6,15 @@ import { el, mount } from '../dom.js';
|
|||||||
|
|
||||||
export function embedView({ title, sub, src, allow }) {
|
export function embedView({ title, sub, src, allow }) {
|
||||||
return async function render(main) {
|
return async function render(main) {
|
||||||
|
const frame = el('iframe', { src, class: 'term-frame', title, ...(allow ? { allow } : {}) });
|
||||||
mount(main,
|
mount(main,
|
||||||
el('div', { class: 'term-bar' },
|
el('div', { class: 'term-bar' },
|
||||||
el('span', { class: 'term-title' }, '◆ ' + title),
|
el('span', { class: 'term-title' }, '◆ ' + title),
|
||||||
sub ? el('span', { class: 'muted', style: { fontSize: '11px' } }, sub) : null,
|
sub ? el('span', { class: 'muted', style: { fontSize: '11px' } }, sub) : null,
|
||||||
el('a', { class: 'ghost', style: { marginLeft: 'auto' }, href: src, target: '_blank', rel: 'noopener' }, '↗ Open'),
|
el('a', { class: 'ghost', style: { marginLeft: 'auto' }, href: src, target: '_blank', rel: 'noopener' }, '↗ Open'),
|
||||||
el('button', { class: 'ghost', onclick: () => {
|
el('button', { class: 'ghost', onclick: () => { frame.src = frame.src; } }, '⟳ Reload')
|
||||||
const f = document.getElementById('embed-frame'); if (f) f.src = f.src;
|
|
||||||
} }, '⟳ Reload')
|
|
||||||
),
|
),
|
||||||
el('iframe', { id: 'embed-frame', src, class: 'term-frame', ...(allow ? { allow } : {}) })
|
frame
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,4 +31,11 @@ describe('embedView + wrappers', () => {
|
|||||||
await (await import('../../public/views/aiusage.js')).render(main);
|
await (await import('../../public/views/aiusage.js')).render(main);
|
||||||
expect(main.querySelector('iframe.term-frame').getAttribute('src')).toBe('https://aiusage.hynesy.com/');
|
expect(main.querySelector('iframe.term-frame').getAttribute('src')).toBe('https://aiusage.hynesy.com/');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('omits the allow attribute when not provided', async () => {
|
||||||
|
const { embedView } = await import('../../public/views/embed.js');
|
||||||
|
const main = document.getElementById('main');
|
||||||
|
await embedView({ title: 'AI Usage', src: 'https://aiusage.hynesy.com/' })(main);
|
||||||
|
expect(main.querySelector('iframe.term-frame').hasAttribute('allow')).toBe(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user