feat: add support for saas_plan

This commit is contained in:
Barış Soner Uşaklı
2024-12-11 11:21:58 -05:00
parent 607d1895ce
commit 68198e8ad6
5 changed files with 22 additions and 6 deletions

View File

@@ -54,5 +54,6 @@
"license.title": "Plugin License Information",
"license.intro": "The plugin <strong>%1</strong> is licensed under the %2. Please read and understand the license terms prior to activating this plugin.",
"license.cta": "Do you wish to continue with activating this plugin?"
"license.cta": "Do you wish to continue with activating this plugin?",
"starter-plan-warning": "Plugins page is disabled on \"Starter\" plans, if you wish to upgrade your plan please contact us at <a href=\"mailto:support@nodebb.org\">support@nodebb.org</a>"
}

View File

@@ -22,7 +22,6 @@ define('admin/extend/plugins', [
pluginsList.on('click', 'button[data-action="toggleActive"]', function () {
const pluginEl = $(this).parents('li');
pluginID = pluginEl.attr('data-plugin-id');
// const btn = $('[id="' + pluginID + '"] [data-action="toggleActive"]');
const btn = $(this);
const pluginData = ajaxify.data.installed[pluginEl.attr('data-plugin-index')];

View File

@@ -47,6 +47,7 @@ pluginsController.get = async function (req, res) {
trending: trendingPlugins,
submitPluginUsage: meta.config.submitPluginUsage,
version: nconf.get('version'),
isStarterPlan: nconf.get('saas_plan') === 'starter',
});
};

View File

@@ -199,6 +199,11 @@ async function completeConfigSetup(config) {
if (nconf.get('package_manager')) {
config.package_manager = nconf.get('package_manager');
}
if (install.values.hasOwnProperty('saas_plan')) {
config.saas_plan = install.values.saas_plan;
}
nconf.overrides(config);
const db = require('./database');
await db.init();
@@ -619,7 +624,10 @@ install.save = async function (server_conf) {
}
}
await fs.promises.writeFile(serverConfigPath, JSON.stringify({ ...currentConfig, ...server_conf }, null, 4));
await fs.promises.writeFile(serverConfigPath, JSON.stringify({
...currentConfig,
...server_conf,
}, null, 4));
console.log('Configuration Saved OK');
nconf.file({
file: serverConfigPath,

View File

@@ -1,15 +1,22 @@
{{{ if isStarterPlan}}}
<div class="px-lg-4">
<div class="alert alert-warning">
[[admin/extend/plugins:starter-plan-warning]]
</div>
</div>
{{{ end }}}
<div class="tags d-flex flex-column gap-2 px-lg-4">
<div class="d-flex flex-column gap-2 px-lg-4 {{{ if isStarterPlan }}}opacity-75 pe-none{{{ end }}}">
<div class="d-flex border-bottom py-2 m-0 sticky-top acp-page-main-header align-items-center justify-content-between flex-wrap gap-2">
<div class="">
<h4 class="fw-bold tracking-tight mb-0">[[admin/extend/plugins:plugins]]</h4>
</div>
<div class="d-flex align-items-center gap-1">
<input autofocus class="form-control form-control-sm" type="text" id="plugin-search" placeholder="[[admin/extend/plugins:plugin-search-placeholder]]"/><br/>
<input {{{ if !isStarterPlan}}} autofocus{{{ end}}} class="form-control form-control-sm" type="text" id="plugin-search" placeholder="[[admin/extend/plugins:plugin-search-placeholder]]"/><br/>
<button class="btn btn-primary btn-sm text-nowrap" id="plugin-order">[[admin/extend/plugins:order-active]]</button>
</div>
</div>
<div class="">
<div>
{{{ if !canChangeState }}}
<div class="alert alert-warning">[[error:plugins-set-in-configuration]]</div>
{{{ end }}}