update dependencies, fixes to support new authentication features
[websub-hub] / src / template / admin-topic-details-html.js
index 1d0add005079f356545eae03db8448548af61134..b598313e1c098921719d711e660f85896506b792 100644 (file)
@@ -1,18 +1,20 @@
 'use strict';
 
 const th = require('./template-helper');
+const { sessionNavLinks } = require('@squeep/authentication-module');
 
 /**
  * Show a topic with all of its subscribers.
- * @param {Object} ctx
- * @param {Object} ctx.topic
- * @param {Object[]} ctx.subscriptions
- * @param {Object} options
- * @param {Object} options.manager
- * @param {String} options.manager.pageTitle
- * @returns {String}
+ * @param {object} ctx context
+ * @param {object} ctx.topic topic
+ * @param {object[]} ctx.subscriptions subscriptions
+ * @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 = 2;
   const pageTitle = `${options.manager.pageTitle} - Topic Details`;
   const logoUrl = options.manager.logoUrl;
   const navLinks = [
@@ -27,11 +29,14 @@ module.exports = (ctx, options) => {
   }
 
   const htmlOptions = {
+    pageIdentifier: 'admin',
     pageTitle,
     logoUrl,
     navLinks,
     footerEntries,
   };
+  th.navLinks(pagePathLevel, ctx, htmlOptions);
+  sessionNavLinks(pagePathLevel, ctx, htmlOptions);
 
   const content = [
     `      <section class="topics">
@@ -62,11 +67,11 @@ module.exports = (ctx, options) => {
     th.renderSubscriptionRowHeader(),
     `          </thead>
           <tbody>`,
-    ...(ctx.subscriptions && ctx.subscriptions.map(th.renderSubscriptionRow)),
+    ...((ctx?.subscriptions || []).map(th.renderSubscriptionRow)),
     `          </tbody>
         </table>
       </section>`,
   ];
 
-  return th.htmlPage(2, ctx, htmlOptions, content);
+  return th.htmlPage(pagePathLevel, ctx, htmlOptions, content);
 };
\ No newline at end of file