update dependencies, fixes to support new authentication features
[websub-hub] / src / template / admin-overview-html.js
index 525337dc5ad6e76b3591d6d6297717009cc0d1e4..948bdbb0083fa77917a7f5b96dc61eb94557be92 100644 (file)
@@ -1,17 +1,19 @@
 'use strict';
 
 const th = require('./template-helper');
+const { sessionNavLinks } = require('@squeep/authentication-module');
 
 /**
  * Show a summary of all topics.
- * @param {Object} ctx
- * @param {Object[]} ctx.topics
- * @param {Object} options
- * @param {Object} options.manager
- * @param {String} options.manager.pageTitle
- * @returns {String}
+ * @param {object} ctx context
+ * @param {object[]} ctx.topics topics
+ * @param {object} options options
+ * @param {object} options.manager manager options
+ * @param {string} options.manager.pageTitle page title
+ * @returns {string} html
  */
 module.exports = (ctx, options) => {
+  const pagePathLevel = 1;
   const pageTitle = `${options.manager.pageTitle} - Topics`;
   const logoUrl = options.manager.logoUrl;
   const footerEntries = options.manager.footerEntries;
@@ -20,13 +22,15 @@ module.exports = (ctx, options) => {
   }
 
   const htmlOptions = {
+    pageIdentifier: 'admin',
     pageTitle,
     logoUrl,
     footerEntries,
   };
+  th.navLinks(pagePathLevel, ctx, htmlOptions);
+  sessionNavLinks(pagePathLevel, ctx, htmlOptions);
 
   const content = [
-    '<script>0</script>', // This fixes a layout rendering flash on load in FF; do not know why this works but it does.
     `      <section class="topics">
         <p>${ctx.topics.length ? ctx.topics.length : 'no'} topic${(ctx.topics.length === 1) ? '' : 's'}</p>
         <table>
@@ -34,11 +38,11 @@ module.exports = (ctx, options) => {
     th.renderTopicRowHeader(),
     `          </thead>
         <tbody>`,
-    ...(ctx.topics && ctx.topics.map((topic) => th.renderTopicRow(topic, { length: topic.subscribers }))),
+    ...((ctx?.topics || []).map((topic) => th.renderTopicRow(topic, { length: topic.subscribers }))),
     `        </tbody>
         </table>
       </section>`,
   ];
 
-  return th.htmlPage(1, ctx, htmlOptions, content);
+  return th.htmlPage(pagePathLevel, ctx, htmlOptions, content);
 };
\ No newline at end of file