mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-01 10:01:12 +01:00
refactor: remove admin.themes.getInstalled
socket call, and just load the themes in the api call
This commit is contained in:
@@ -8,4 +8,34 @@ get:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../../../components/schemas/CommonProps.yaml#/CommonProps
|
||||
allOf:
|
||||
- type: object
|
||||
properties:
|
||||
themes:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
screenshot:
|
||||
type: string
|
||||
screenshot_url:
|
||||
type: string
|
||||
type:
|
||||
type: string
|
||||
url:
|
||||
type: string
|
||||
baseTheme:
|
||||
type: string
|
||||
required:
|
||||
- name
|
||||
- id
|
||||
- description
|
||||
- type
|
||||
- url
|
||||
- $ref: ../../../components/schemas/CommonProps.yaml#/CommonProps
|
||||
|
||||
@@ -72,24 +72,7 @@ define('admin/appearance/themes', ['bootbox', 'translator', 'alerts'], function
|
||||
});
|
||||
});
|
||||
|
||||
socket.emit('admin.themes.getInstalled', function (err, themes) {
|
||||
if (err) {
|
||||
return alerts.error(err);
|
||||
}
|
||||
|
||||
const instListEl = $('#installed_themes');
|
||||
|
||||
if (!themes.length) {
|
||||
instListEl.append($('<li/ >').addClass('no-themes').translateHtml('[[admin/appearance/themes:no-themes]]'));
|
||||
} else {
|
||||
app.parseAndTranslate('admin/partials/theme_list', {
|
||||
themes: themes,
|
||||
}, function (html) {
|
||||
instListEl.html(html);
|
||||
highlightSelectedTheme(config['theme:id']);
|
||||
});
|
||||
}
|
||||
});
|
||||
highlightSelectedTheme(config['theme:id']);
|
||||
};
|
||||
|
||||
function highlightSelectedTheme(themeId) {
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
const meta = require('../../meta');
|
||||
|
||||
const appearanceController = module.exports;
|
||||
|
||||
appearanceController.themes = function (req, res) {
|
||||
res.render(`admin/appearance/themes`, {});
|
||||
appearanceController.themes = async function (req, res) {
|
||||
const themes = await meta.themes.get();
|
||||
res.render(`admin/appearance/themes`, { themes });
|
||||
};
|
||||
|
||||
appearanceController.skins = function (req, res) {
|
||||
|
||||
@@ -115,7 +115,6 @@ privsAdmin.socketMap = {
|
||||
'admin.getSearchDict': 'admin:settings',
|
||||
'admin.config.setMultiple': 'admin:settings',
|
||||
'admin.config.remove': 'admin:settings',
|
||||
'admin.themes.getInstalled': 'admin:settings',
|
||||
'admin.themes.set': 'admin:settings',
|
||||
'admin.reloadAllSessions': 'admin:settings',
|
||||
'admin.settings.get': 'admin:settings',
|
||||
|
||||
@@ -5,10 +5,6 @@ const widgets = require('../../widgets');
|
||||
|
||||
const Themes = module.exports;
|
||||
|
||||
Themes.getInstalled = async function () {
|
||||
return await meta.themes.get();
|
||||
};
|
||||
|
||||
Themes.set = async function (socket, data) {
|
||||
if (!data) {
|
||||
throw new Error('[[error:invalid-data]]');
|
||||
|
||||
@@ -10,7 +10,11 @@
|
||||
|
||||
<div id="themes" class="themes px-2">
|
||||
<div class="directory row text-center" id="installed_themes">
|
||||
<i class="fa fa-refresh fa-spin"></i> [[admin/appearance/themes:checking-for-installed]]
|
||||
{{{ if themes.length }}}
|
||||
<!-- IMPORT admin/partials/theme_list.tpl -->
|
||||
{{{ else }}}
|
||||
<div class="alert alert-info no-themes">[[admin/appearance/themes:no-themes]]</div>
|
||||
{{{ end}}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -84,19 +84,6 @@ describe('socket.io', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should get installed themes', (done) => {
|
||||
const themes = ['nodebb-theme-persona'];
|
||||
io.emit('admin.themes.getInstalled', (err, data) => {
|
||||
assert.ifError(err);
|
||||
assert(data);
|
||||
const installed = data.map(theme => theme.id);
|
||||
themes.forEach((theme) => {
|
||||
assert(installed.includes(theme));
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should ban a user', async () => {
|
||||
const apiUser = require('../src/api/users');
|
||||
await apiUser.ban({ uid: adminUid }, { uid: regularUid, reason: 'spammer' });
|
||||
|
||||
Reference in New Issue
Block a user