fix missed parameter in new template
[websub-hub] / src / template / admin-topic-details-html.js
1 'use strict';
2
3 const th = require('./template-helper');
4
5 /**
6 * Show a topic with all of its subscribers.
7 * @param {Object} ctx
8 * @param {Object} ctx.topic
9 * @param {Object[]} ctx.subscriptions
10 * @param {Object} options
11 * @param {Object} options.manager
12 * @param {String} options.manager.pageTitle
13 * @returns {String}
14 */
15 module.exports = (ctx, options) => {
16 const pageTitle = `${options.manager.pageTitle} - Topic Details`;
17 const logoUrl = options.manager.logoUrl;
18 const navLinks = [
19 {
20 href: '..',
21 text: '↑ All Topics',
22 },
23 ];
24 const footerEntries = options.manager.footerEntries;
25 if (!ctx.subscriptions) {
26 ctx.subscriptions = [];
27 }
28
29 const htmlOptions = {
30 pageTitle,
31 logoUrl,
32 navLinks,
33 footerEntries,
34 };
35
36 const content = [
37 '<script>0</script>', // This fixes a layout rendering flash on load in FF; do not know why this works but it does.
38 ` <section class="topics">
39 <table>
40 <thead>`,
41 th.renderTopicRowHeader(),
42 ` </thead>
43 <tbody>`,
44 ...(ctx.topic && [ th.renderTopicRow(ctx.topic, ctx.subscriptions, false) ] || []),
45 ` </tbody>
46 </table>
47 </section>`,
48 ` <section class="subscriptions">
49 <p>${ctx.subscriptions.length ? ctx.subscriptions.length : 'no'} subscription${(ctx.subscriptions.length === 1) ? '' : 's'}</p>
50 <table>
51 <thead>`,
52 th.renderSubscriptionRowHeader(),
53 ` </thead>
54 <tbody>`,
55 ...(ctx.subscriptions && ctx.subscriptions.map(th.renderSubscriptionRow)),
56 ` </tbody>
57 </table>
58 </section>`,
59 ];
60
61 return th.htmlPage(2, ctx, htmlOptions, content);
62 };