Skip to content

Node.js based forum software built for the modern web

feat(categories): add first-run modal for new installations

Julian Lam19e25f20fc01
diff --git a/public/language/en-GB/category.json b/public/language/en-GB/category.json
index 003326e6fe..d19cb6ef06 100644
--- a/public/language/en-GB/category.json
+++ b/public/language/en-GB/category.json
@@ -31,5 +31,10 @@
"watched-categories": "Watched categories",
"x-more-categories": "%1 more categories",
- "view-original": "View Original"
+ "view-original": "View Original",
+
+ "first-run.welcome": "Welcome to your new NodeBB forum!",
+ "first-run.description": "Your forum is ready to go. Log in to customize your categories, settings, and more.",
+ "first-run.admin-panel": "You can manage your forum via the Admin Panel",
+ "first-run.admin-panel-desc": "accessible through the gear icon in the sidebar"
}
diff --git a/public/openapi/read/categories.yaml b/public/openapi/read/categories.yaml
index f6de63ed3e..cb4b06ada4 100644
--- a/public/openapi/read/categories.yaml
+++ b/public/openapi/read/categories.yaml
@@ -26,6 +26,9 @@ get:
selectCategoryLabel:
type: string
description: Label to use for the category selector
+ firstRun:
+ type: boolean
+ description: True if no user has ever logged in to this instance
categories:
description: A collection of category data objects
type: array
diff --git a/public/src/client/categories.js b/public/src/client/categories.js
index e5ac479692..b018368e45 100644
--- a/public/src/client/categories.js
+++ b/public/src/client/categories.js
@@ -1,10 +1,10 @@
'use strict';
-define('forum/categories', ['categorySelector'], function (categorySelector) {
+define('forum/categories', ['categorySelector', 'bootbox', 'translator'], function (categorySelector, bootbox, tx) {
const categories = {};
- categories.init = function () {
+ categories.init = async function () {
app.enterRoom('categories');
categorySelector.init($('[component="category-selector"]'), {
@@ -13,6 +13,18 @@ define('forum/categories', ['categorySelector'], function (categorySelector) {
ajaxify.go('/category/' + category.cid);
},
});
+
+ if (ajaxify.data.firstRun) {
+ const html = await app.parseAndTranslate('modals/first-run');
+ const title = await tx.translate(tx.compile('category:first-run.welcome'));
+ bootbox.dialog({
+ title,
+ message: html,
+ backdrop: true,
+ scrollback: false,
+ closeButton: true,
+ });
+ }
};
return categories;
diff --git a/src/controllers/categories.js b/src/controllers/categories.js
index 696c3e16d9..2fb9af94a2 100644
--- a/src/controllers/categories.js
+++ b/src/controllers/categories.js
@@ -4,6 +4,7 @@ const nconf = require('nconf');
const _ = require('lodash');
const categories = require('../categories');
+const db = require('../database');
const meta = require('../meta');
const pagination = require('../pagination');
const helpers = require('./helpers');
@@ -42,6 +43,7 @@ categoriesController.list = async function (req, res) {
selectCategoryLabel: '[[pages:categories]]',
categories: tree,
pagination: pagination.create(page, pageCount, req.query),
+ firstRun: !(await db.getObjectField('global', 'loginCount')),
};
data.categories.forEach((category) => {
diff --git a/src/views/modals/first-run.tpl b/src/views/modals/first-run.tpl
new file mode 100644
index 0000000000..a26940b214
--- /dev/null
+++ b/src/views/modals/first-run.tpl
@@ -0,0 +1,4 @@
+<div class="text-center">
+ <p>[[category:first-run.description]]</p>
+ <p>[[category:first-run.admin-panel]] <i class="fa-solid fa-gears"></i> [[category:first-run.admin-panel-desc]]</p>
+</div>