diff --git a/extensions/akismet/js/src/admin/extend.tsx b/extensions/akismet/js/src/admin/extend.tsx
new file mode 100644
index 0000000000..de7109eb00
--- /dev/null
+++ b/extensions/akismet/js/src/admin/extend.tsx
@@ -0,0 +1,26 @@
+import Extend from 'flarum/common/extenders';
+import app from 'flarum/admin/app';
+
+export default [
+ new Extend.Admin()
+ .setting(() => ({
+ setting: 'flarum-akismet.api_key',
+ type: 'text',
+ label: app.translator.trans('flarum-akismet.admin.akismet_settings.api_key_label'),
+ }))
+ .setting(() => ({
+ // https://blog.akismet.com/2014/04/23/theres-a-ninja-in-your-akismet/
+ setting: 'flarum-akismet.delete_blatant_spam',
+ type: 'boolean',
+ label: app.translator.trans('flarum-akismet.admin.akismet_settings.delete_blatant_spam_label'),
+ help: app.translator.trans('flarum-akismet.admin.akismet_settings.delete_blatant_spam_help'),
+ }))
+ .permission(
+ () => ({
+ icon: 'fas fa-vote-yea',
+ label: app.translator.trans('flarum-akismet.admin.permissions.bypass_akismet'),
+ permission: 'bypassAkismet',
+ }),
+ 'start'
+ ),
+];
diff --git a/extensions/akismet/js/src/admin/index.ts b/extensions/akismet/js/src/admin/index.ts
index 133ee61081..cc9e8301a3 100644
--- a/extensions/akismet/js/src/admin/index.ts
+++ b/extensions/akismet/js/src/admin/index.ts
@@ -1,26 +1,7 @@
import app from 'flarum/admin/app';
+export { default as extend } from './extend';
+
app.initializers.add('flarum-akismet', () => {
- app.extensionData
- .for('flarum-akismet')
- .registerSetting({
- setting: 'flarum-akismet.api_key',
- type: 'text',
- label: app.translator.trans('flarum-akismet.admin.akismet_settings.api_key_label'),
- })
- .registerSetting({
- //https://blog.akismet.com/2014/04/23/theres-a-ninja-in-your-akismet/
- setting: 'flarum-akismet.delete_blatant_spam',
- type: 'boolean',
- label: app.translator.trans('flarum-akismet.admin.akismet_settings.delete_blatant_spam_label'),
- help: app.translator.trans('flarum-akismet.admin.akismet_settings.delete_blatant_spam_help'),
- })
- .registerPermission(
- {
- icon: 'fas fa-vote-yea',
- label: app.translator.trans('flarum-akismet.admin.permissions.bypass_akismet'),
- permission: 'bypassAkismet',
- },
- 'start'
- );
+ // ...
});
diff --git a/extensions/approval/js/admin.js b/extensions/approval/js/admin.ts
similarity index 100%
rename from extensions/approval/js/admin.js
rename to extensions/approval/js/admin.ts
diff --git a/extensions/approval/js/forum.js b/extensions/approval/js/forum.ts
similarity index 100%
rename from extensions/approval/js/forum.js
rename to extensions/approval/js/forum.ts
diff --git a/extensions/approval/js/src/admin/index.js b/extensions/approval/js/src/admin/extend.tsx
similarity index 54%
rename from extensions/approval/js/src/admin/index.js
rename to extensions/approval/js/src/admin/extend.tsx
index 7d9a95a202..687f3da29b 100644
--- a/extensions/approval/js/src/admin/index.js
+++ b/extensions/approval/js/src/admin/extend.tsx
@@ -1,43 +1,33 @@
-import { extend } from 'flarum/common/extend';
+import Extend from 'flarum/common/extenders';
import app from 'flarum/admin/app';
-app.initializers.add('flarum-approval', () => {
- extend(app, 'getRequiredPermissions', function (required, permission) {
- if (permission === 'discussion.startWithoutApproval') {
- required.push('startDiscussion');
- }
- if (permission === 'discussion.replyWithoutApproval') {
- required.push('discussion.reply');
- }
- });
-
- app.extensionData
- .for('flarum-approval')
- .registerPermission(
- {
+export default [
+ new Extend.Admin()
+ .permission(
+ () => ({
icon: 'fas fa-check',
label: app.translator.trans('flarum-approval.admin.permissions.start_discussions_without_approval_label'),
permission: 'discussion.startWithoutApproval',
- },
+ }),
'start',
95
)
- .registerPermission(
- {
+ .permission(
+ () => ({
icon: 'fas fa-check',
label: app.translator.trans('flarum-approval.admin.permissions.reply_without_approval_label'),
permission: 'discussion.replyWithoutApproval',
- },
+ }),
'reply',
95
)
- .registerPermission(
- {
+ .permission(
+ () => ({
icon: 'fas fa-check',
label: app.translator.trans('flarum-approval.admin.permissions.approve_posts_label'),
permission: 'discussion.approvePosts',
- },
+ }),
'moderate',
65
- );
-});
+ ),
+];
diff --git a/extensions/approval/js/src/admin/index.ts b/extensions/approval/js/src/admin/index.ts
new file mode 100644
index 0000000000..edfeecbf6c
--- /dev/null
+++ b/extensions/approval/js/src/admin/index.ts
@@ -0,0 +1,15 @@
+import { extend } from 'flarum/common/extend';
+import app from 'flarum/admin/app';
+
+export { default as extend } from './extend';
+
+app.initializers.add('flarum-approval', () => {
+ extend(app, 'getRequiredPermissions', function (required, permission) {
+ if (permission === 'discussion.startWithoutApproval') {
+ required.push('startDiscussion');
+ }
+ if (permission === 'discussion.replyWithoutApproval') {
+ required.push('discussion.reply');
+ }
+ });
+});
diff --git a/extensions/approval/js/tsconfig.json b/extensions/approval/js/tsconfig.json
new file mode 100644
index 0000000000..d7b48770ca
--- /dev/null
+++ b/extensions/approval/js/tsconfig.json
@@ -0,0 +1,15 @@
+{
+ // Use Flarum's tsconfig as a starting point
+ "extends": "flarum-tsconfig",
+ // This will match all .ts, .tsx, .d.ts, .js, .jsx files in your `src` folder
+ // and also tells your Typescript server to read core's global typings for
+ // access to `dayjs` and `$` in the global namespace.
+ "include": ["src/**/*", "../../../*/*/js/dist-typings/@types/**/*", "@types/**/*"],
+ "compilerOptions": {
+ // This will output typings to `dist-typings`
+ "declarationDir": "./dist-typings",
+ "paths": {
+ "flarum/*": ["../../../framework/core/js/dist-typings/*"]
+ }
+ }
+}
diff --git a/extensions/emoji/js/src/admin/index.js b/extensions/emoji/js/src/admin/extend.tsx
similarity index 73%
rename from extensions/emoji/js/src/admin/index.js
rename to extensions/emoji/js/src/admin/extend.tsx
index efbfbfeb4a..1cc78c77df 100644
--- a/extensions/emoji/js/src/admin/index.js
+++ b/extensions/emoji/js/src/admin/extend.tsx
@@ -1,13 +1,14 @@
+import Extend from 'flarum/common/extenders';
import app from 'flarum/admin/app';
import { version } from '../common/cdn';
-app.initializers.add('flarum-emoji', () => {
- app.extensionData.for('flarum-emoji').registerSetting({
+export default [
+ new Extend.Admin().setting(() => ({
setting: 'flarum-emoji.cdn',
type: 'text',
label: app.translator.trans('flarum-emoji.admin.settings.cdn_label'),
help: app.translator.trans('flarum-emoji.admin.settings.cdn_help', {
version: version,
}),
- });
-});
+ })),
+];
diff --git a/extensions/emoji/js/src/admin/index.ts b/extensions/emoji/js/src/admin/index.ts
new file mode 100644
index 0000000000..d50efdfb9b
--- /dev/null
+++ b/extensions/emoji/js/src/admin/index.ts
@@ -0,0 +1,7 @@
+import app from 'flarum/admin/app';
+
+export { default as extend } from './extend';
+
+app.initializers.add('flarum-emoji', () => {
+ // ...
+});
diff --git a/extensions/emoji/js/tsconfig.json b/extensions/emoji/js/tsconfig.json
new file mode 100644
index 0000000000..d7b48770ca
--- /dev/null
+++ b/extensions/emoji/js/tsconfig.json
@@ -0,0 +1,15 @@
+{
+ // Use Flarum's tsconfig as a starting point
+ "extends": "flarum-tsconfig",
+ // This will match all .ts, .tsx, .d.ts, .js, .jsx files in your `src` folder
+ // and also tells your Typescript server to read core's global typings for
+ // access to `dayjs` and `$` in the global namespace.
+ "include": ["src/**/*", "../../../*/*/js/dist-typings/@types/**/*", "@types/**/*"],
+ "compilerOptions": {
+ // This will output typings to `dist-typings`
+ "declarationDir": "./dist-typings",
+ "paths": {
+ "flarum/*": ["../../../framework/core/js/dist-typings/*"]
+ }
+ }
+}
diff --git a/extensions/flags/js/src/admin/extend.tsx b/extensions/flags/js/src/admin/extend.tsx
new file mode 100644
index 0000000000..6cd6b16dcc
--- /dev/null
+++ b/extensions/flags/js/src/admin/extend.tsx
@@ -0,0 +1,37 @@
+import Extend from 'flarum/common/extenders';
+import app from 'flarum/admin/app';
+
+export default [
+ new Extend.Admin()
+ .setting(
+ () => ({
+ setting: 'flarum-flags.guidelines_url',
+ type: 'text',
+ label: app.translator.trans('flarum-flags.admin.settings.guidelines_url_label'),
+ }),
+ 15
+ )
+ .setting(() => ({
+ setting: 'flarum-flags.can_flag_own',
+ type: 'boolean',
+ label: app.translator.trans('flarum-flags.admin.settings.flag_own_posts_label'),
+ }))
+ .permission(
+ () => ({
+ icon: 'fas fa-flag',
+ label: app.translator.trans('flarum-flags.admin.permissions.view_flags_label'),
+ permission: 'discussion.viewFlags',
+ }),
+ 'moderate',
+ 65
+ )
+ .permission(
+ () => ({
+ icon: 'fas fa-flag',
+ label: app.translator.trans('flarum-flags.admin.permissions.flag_posts_label'),
+ permission: 'discussion.flagPosts',
+ }),
+ 'reply',
+ 65
+ ),
+];
diff --git a/extensions/flags/js/src/admin/index.ts b/extensions/flags/js/src/admin/index.ts
index 7b54de998c..6c056ff7c2 100644
--- a/extensions/flags/js/src/admin/index.ts
+++ b/extensions/flags/js/src/admin/index.ts
@@ -1,38 +1,7 @@
import app from 'flarum/admin/app';
-app.initializers.add('flarum-flags', () => {
- app.extensionData
- .for('flarum-flags')
- .registerSetting(
- {
- setting: 'flarum-flags.guidelines_url',
- type: 'text',
- label: app.translator.trans('flarum-flags.admin.settings.guidelines_url_label'),
- },
- 15
- )
- .registerSetting({
- setting: 'flarum-flags.can_flag_own',
- type: 'boolean',
- label: app.translator.trans('flarum-flags.admin.settings.flag_own_posts_label'),
- })
- .registerPermission(
- {
- icon: 'fas fa-flag',
- label: app.translator.trans('flarum-flags.admin.permissions.view_flags_label'),
- permission: 'discussion.viewFlags',
- },
- 'moderate',
- 65
- )
+export { default as extend } from './extend';
- .registerPermission(
- {
- icon: 'fas fa-flag',
- label: app.translator.trans('flarum-flags.admin.permissions.flag_posts_label'),
- permission: 'discussion.flagPosts',
- },
- 'reply',
- 65
- );
+app.initializers.add('flarum-flags', () => {
+ // ...
});
diff --git a/extensions/likes/js/src/admin/index.js b/extensions/likes/js/src/admin/extend.tsx
similarity index 67%
rename from extensions/likes/js/src/admin/index.js
rename to extensions/likes/js/src/admin/extend.tsx
index 6117298cbf..692158ab2e 100644
--- a/extensions/likes/js/src/admin/index.js
+++ b/extensions/likes/js/src/admin/extend.tsx
@@ -1,20 +1,23 @@
+import Extend from 'flarum/common/extenders';
import app from 'flarum/admin/app';
+import commonExtend from '../common/extend';
-app.initializers.add('flarum-likes', () => {
- app.extensionData
- .for('flarum-likes')
- .registerPermission(
- {
+export default [
+ ...commonExtend,
+
+ new Extend.Admin()
+ .permission(
+ () => ({
icon: 'far fa-thumbs-up',
label: app.translator.trans('flarum-likes.admin.permissions.like_posts_label'),
permission: 'discussion.likePosts',
- },
+ }),
'reply'
)
- .registerSetting({
+ .setting(() => ({
setting: 'flarum-likes.like_own_post',
type: 'bool',
label: app.translator.trans('flarum-likes.admin.settings.like_own_posts_label'),
help: app.translator.trans('flarum-likes.admin.settings.like_own_posts_help'),
- });
-});
+ })),
+];
diff --git a/extensions/likes/js/src/admin/index.tsx b/extensions/likes/js/src/admin/index.tsx
new file mode 100644
index 0000000000..86c45061a9
--- /dev/null
+++ b/extensions/likes/js/src/admin/index.tsx
@@ -0,0 +1,7 @@
+import app from 'flarum/admin/app';
+
+export { default as extend } from './extend';
+
+app.initializers.add('flarum-likes', () => {
+ // ...
+});
diff --git a/extensions/lock/js/src/admin/extend.ts b/extensions/lock/js/src/admin/extend.ts
deleted file mode 100644
index 9ce8b5f124..0000000000
--- a/extensions/lock/js/src/admin/extend.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default as default } from '../common/extend';
diff --git a/extensions/lock/js/src/admin/index.js b/extensions/lock/js/src/admin/extend.tsx
similarity index 53%
rename from extensions/lock/js/src/admin/index.js
rename to extensions/lock/js/src/admin/extend.tsx
index cf3d66ac80..2c344730cb 100644
--- a/extensions/lock/js/src/admin/index.js
+++ b/extensions/lock/js/src/admin/extend.tsx
@@ -1,15 +1,17 @@
+import Extend from 'flarum/common/extenders';
import app from 'flarum/admin/app';
+import commonExtend from '../common/extend';
-export { default as extend } from './extend';
+export default [
+ ...commonExtend,
-app.initializers.add('flarum-lock', () => {
- app.extensionData.for('flarum-lock').registerPermission(
- {
+ new Extend.Admin().permission(
+ () => ({
icon: 'fas fa-lock',
label: app.translator.trans('flarum-lock.admin.permissions.lock_discussions_label'),
permission: 'discussion.lock',
- },
+ }),
'moderate',
95
- );
-});
+ ),
+];
diff --git a/extensions/lock/js/src/admin/index.tsx b/extensions/lock/js/src/admin/index.tsx
new file mode 100644
index 0000000000..b81aa14019
--- /dev/null
+++ b/extensions/lock/js/src/admin/index.tsx
@@ -0,0 +1,7 @@
+import app from 'flarum/admin/app';
+
+export { default as extend } from './extend';
+
+app.initializers.add('flarum-lock', () => {
+ // ...
+});
diff --git a/extensions/mentions/js/src/admin/extend.ts b/extensions/mentions/js/src/admin/extend.ts
index 93caee0bcb..b42b710315 100644
--- a/extensions/mentions/js/src/admin/extend.ts
+++ b/extensions/mentions/js/src/admin/extend.ts
@@ -1,3 +1,23 @@
+import Extend from 'flarum/common/extenders';
+import app from 'flarum/admin/app';
import commonExtend from '../common/extend';
-export default [...commonExtend];
+export default [
+ ...commonExtend,
+
+ new Extend.Admin()
+ .setting(() => ({
+ setting: 'flarum-mentions.allow_username_format',
+ type: 'boolean',
+ label: app.translator.trans('flarum-mentions.admin.settings.allow_username_format_label'),
+ help: app.translator.trans('flarum-mentions.admin.settings.allow_username_format_text'),
+ }))
+ .permission(
+ () => ({
+ permission: 'mentionGroups',
+ label: app.translator.trans('flarum-mentions.admin.permissions.mention_groups_label'),
+ icon: 'fas fa-at',
+ }),
+ 'start'
+ ),
+];
diff --git a/extensions/mentions/js/src/admin/index.js b/extensions/mentions/js/src/admin/index.js
deleted file mode 100644
index 6cf148e60f..0000000000
--- a/extensions/mentions/js/src/admin/index.js
+++ /dev/null
@@ -1,22 +0,0 @@
-import app from 'flarum/admin/app';
-
-export { default as extend } from './extend';
-
-app.initializers.add('flarum-mentions', () => {
- app.extensionData
- .for('flarum-mentions')
- .registerSetting({
- setting: 'flarum-mentions.allow_username_format',
- type: 'boolean',
- label: app.translator.trans('flarum-mentions.admin.settings.allow_username_format_label'),
- help: app.translator.trans('flarum-mentions.admin.settings.allow_username_format_text'),
- })
- .registerPermission(
- {
- permission: 'mentionGroups',
- label: app.translator.trans('flarum-mentions.admin.permissions.mention_groups_label'),
- icon: 'fas fa-at',
- },
- 'start'
- );
-});
diff --git a/extensions/mentions/js/src/admin/index.tsx b/extensions/mentions/js/src/admin/index.tsx
new file mode 100644
index 0000000000..582eac3f04
--- /dev/null
+++ b/extensions/mentions/js/src/admin/index.tsx
@@ -0,0 +1,7 @@
+import app from 'flarum/admin/app';
+
+export { default as extend } from './extend';
+
+app.initializers.add('flarum-mentions', () => {
+ // ...
+});
diff --git a/extensions/nicknames/js/src/admin/extend.tsx b/extensions/nicknames/js/src/admin/extend.tsx
new file mode 100644
index 0000000000..e78be255eb
--- /dev/null
+++ b/extensions/nicknames/js/src/admin/extend.tsx
@@ -0,0 +1,58 @@
+import Extend from 'flarum/common/extenders';
+import app from 'flarum/admin/app';
+import Alert from 'flarum/common/components/Alert';
+import Link from 'flarum/common/components/Link';
+
+export default [
+ new Extend.Admin()
+ .customSetting(function () {
+ if (app.data.settings.display_name_driver === 'nickname') return;
+
+ return (
+
+
+ {app.translator.trans('flarum-nicknames.admin.wrong_driver', { a: })}
+
+
+ );
+ })
+ .setting(() => ({
+ setting: 'flarum-nicknames.set_on_registration',
+ type: 'boolean',
+ label: app.translator.trans('flarum-nicknames.admin.settings.set_on_registration_label'),
+ }))
+ .setting(() => ({
+ setting: 'flarum-nicknames.random_username',
+ type: 'boolean',
+ label: app.translator.trans('flarum-nicknames.admin.settings.random_username_label'),
+ help: app.translator.trans('flarum-nicknames.admin.settings.random_username_help'),
+ }))
+ .setting(() => ({
+ setting: 'flarum-nicknames.unique',
+ type: 'boolean',
+ label: app.translator.trans('flarum-nicknames.admin.settings.unique_label'),
+ }))
+ .setting(() => ({
+ setting: 'flarum-nicknames.regex',
+ type: 'text',
+ label: app.translator.trans('flarum-nicknames.admin.settings.regex_label'),
+ }))
+ .setting(() => ({
+ setting: 'flarum-nicknames.min',
+ type: 'number',
+ label: app.translator.trans('flarum-nicknames.admin.settings.min_label'),
+ }))
+ .setting(() => ({
+ setting: 'flarum-nicknames.max',
+ type: 'number',
+ label: app.translator.trans('flarum-nicknames.admin.settings.max_label'),
+ }))
+ .permission(
+ () => ({
+ icon: 'fas fa-user-tag',
+ label: app.translator.trans('flarum-nicknames.admin.permissions.edit_own_nickname_label'),
+ permission: 'user.editOwnNickname',
+ }),
+ 'start'
+ ),
+];
diff --git a/extensions/nicknames/js/src/admin/index.js b/extensions/nicknames/js/src/admin/index.js
index ca298d39aa..d0dad0d06d 100644
--- a/extensions/nicknames/js/src/admin/index.js
+++ b/extensions/nicknames/js/src/admin/index.js
@@ -1,64 +1,11 @@
import app from 'flarum/admin/app';
-import Alert from 'flarum/common/components/Alert';
-import Link from 'flarum/common/components/Link';
import BasicsPage from 'flarum/admin/components/BasicsPage';
import extractText from 'flarum/common/utils/extractText';
import { extend } from 'flarum/common/extend';
-app.initializers.add('flarum-nicknames', () => {
- app.extensionData
- .for('flarum-nicknames')
- .registerSetting(function () {
- if (app.data.settings.display_name_driver === 'nickname') return;
-
- return (
-
-
- {app.translator.trans('flarum-nicknames.admin.wrong_driver', { a: })}
-
-
- );
- })
- .registerSetting({
- setting: 'flarum-nicknames.set_on_registration',
- type: 'boolean',
- label: app.translator.trans('flarum-nicknames.admin.settings.set_on_registration_label'),
- })
- .registerSetting({
- setting: 'flarum-nicknames.random_username',
- type: 'boolean',
- label: app.translator.trans('flarum-nicknames.admin.settings.random_username_label'),
- help: app.translator.trans('flarum-nicknames.admin.settings.random_username_help'),
- })
- .registerSetting({
- setting: 'flarum-nicknames.unique',
- type: 'boolean',
- label: app.translator.trans('flarum-nicknames.admin.settings.unique_label'),
- })
- .registerSetting({
- setting: 'flarum-nicknames.regex',
- type: 'text',
- label: app.translator.trans('flarum-nicknames.admin.settings.regex_label'),
- })
- .registerSetting({
- setting: 'flarum-nicknames.min',
- type: 'number',
- label: app.translator.trans('flarum-nicknames.admin.settings.min_label'),
- })
- .registerSetting({
- setting: 'flarum-nicknames.max',
- type: 'number',
- label: app.translator.trans('flarum-nicknames.admin.settings.max_label'),
- })
- .registerPermission(
- {
- icon: 'fas fa-user-tag',
- label: app.translator.trans('flarum-nicknames.admin.permissions.edit_own_nickname_label'),
- permission: 'user.editOwnNickname',
- },
- 'start'
- );
+export { default as extend } from './extend';
+app.initializers.add('flarum-nicknames', () => {
extend(BasicsPage.prototype, 'driverLocale', function (locale) {
locale.display_name['nickname'] = extractText(app.translator.trans('flarum-nicknames.admin.basics.display_name_driver_options.nickname'));
});
diff --git a/extensions/package-manager/js/src/admin/components/SettingsPage.tsx b/extensions/package-manager/js/src/admin/components/SettingsPage.tsx
index 9baf82c6cd..214ce8dcea 100644
--- a/extensions/package-manager/js/src/admin/components/SettingsPage.tsx
+++ b/extensions/package-manager/js/src/admin/components/SettingsPage.tsx
@@ -12,7 +12,7 @@ import ConfigureAuth from './ConfigureAuth';
export default class SettingsPage extends ExtensionPage {
content() {
- const settings = app.extensionData.getSettings(this.extension.id);
+ const settings = app.registry.getSettings(this.extension.id);
const warnings = [app.translator.trans('flarum-extension-manager.admin.settings.access_warning')];
diff --git a/extensions/package-manager/js/src/admin/extend.tsx b/extensions/package-manager/js/src/admin/extend.tsx
new file mode 100644
index 0000000000..711320b478
--- /dev/null
+++ b/extensions/package-manager/js/src/admin/extend.tsx
@@ -0,0 +1,31 @@
+import Extend from 'flarum/common/extenders';
+import app from 'flarum/admin/app';
+import extractText from 'flarum/common/utils/extractText';
+import SettingsPage from './components/SettingsPage';
+
+export default [
+ new Extend.Admin()
+ .setting(() => ({
+ setting: 'flarum-extension-manager.queue_jobs',
+ label: app.translator.trans('flarum-extension-manager.admin.settings.queue_jobs'),
+ help: m.trust(
+ extractText(
+ app.translator.trans('flarum-extension-manager.admin.settings.queue_jobs_help', {
+ basic_impl_link: 'https://discuss.flarum.org/d/28151-database-queue-the-simplest-queue-even-for-shared-hosting',
+ adv_impl_link: 'https://discuss.flarum.org/d/21873-redis-sessions-cache-queues',
+ php_version: `${app.data.phpVersion}`,
+ folder_perms_link: 'https://docs.flarum.org/install#folder-ownership',
+ })
+ )
+ ),
+ type: 'boolean',
+ disabled: app.data['flarum-extension-manager.using_sync_queue'],
+ }))
+ .setting(() => ({
+ setting: 'flarum-extension-manager.task_retention_days',
+ label: app.translator.trans('flarum-extension-manager.admin.settings.task_retention_days'),
+ help: app.translator.trans('flarum-extension-manager.admin.settings.task_retention_days_help'),
+ type: 'number',
+ }))
+ .page(SettingsPage),
+];
diff --git a/extensions/package-manager/js/src/admin/index.tsx b/extensions/package-manager/js/src/admin/index.tsx
index 0219c91cef..4e09ebd6b4 100755
--- a/extensions/package-manager/js/src/admin/index.tsx
+++ b/extensions/package-manager/js/src/admin/index.tsx
@@ -4,13 +4,13 @@ import ExtensionPage from 'flarum/admin/components/ExtensionPage';
import Button from 'flarum/common/components/Button';
import LoadingModal from 'flarum/admin/components/LoadingModal';
import isExtensionEnabled from 'flarum/admin/utils/isExtensionEnabled';
-import SettingsPage from './components/SettingsPage';
import Task from './models/Task';
import jumpToQueue from './utils/jumpToQueue';
-import extractText from 'flarum/common/utils/extractText';
import { AsyncBackendResponse } from './shims';
import ExtensionManagerState from './states/ExtensionManagerState';
+export { default as extend } from './extend';
+
app.initializers.add('flarum-extension-manager', (app) => {
app.store.models['extension-manager-tasks'] = Task;
@@ -20,32 +20,6 @@ app.initializers.add('flarum-extension-manager', (app) => {
app.data.settings['flarum-extension-manager.queue_jobs'] = '0';
}
- app.extensionData
- .for('flarum-extension-manager')
- .registerSetting({
- setting: 'flarum-extension-manager.queue_jobs',
- label: app.translator.trans('flarum-extension-manager.admin.settings.queue_jobs'),
- help: m.trust(
- extractText(
- app.translator.trans('flarum-extension-manager.admin.settings.queue_jobs_help', {
- basic_impl_link: 'https://discuss.flarum.org/d/28151-database-queue-the-simplest-queue-even-for-shared-hosting',
- adv_impl_link: 'https://discuss.flarum.org/d/21873-redis-sessions-cache-queues',
- php_version: `${app.data.phpVersion}`,
- folder_perms_link: 'https://docs.flarum.org/install#folder-ownership',
- })
- )
- ),
- type: 'boolean',
- disabled: app.data['flarum-extension-manager.using_sync_queue'],
- })
- .registerSetting({
- setting: 'flarum-extension-manager.task_retention_days',
- label: app.translator.trans('flarum-extension-manager.admin.settings.task_retention_days'),
- help: app.translator.trans('flarum-extension-manager.admin.settings.task_retention_days_help'),
- type: 'number',
- })
- .registerPage(SettingsPage);
-
extend(ExtensionPage.prototype, 'topItems', function (items) {
if (this.extension.id === 'flarum-extension-manager' || isExtensionEnabled(this.extension.id)) {
return;
diff --git a/extensions/pusher/js/src/admin/extend.tsx b/extensions/pusher/js/src/admin/extend.tsx
new file mode 100644
index 0000000000..e87eb4fd3f
--- /dev/null
+++ b/extensions/pusher/js/src/admin/extend.tsx
@@ -0,0 +1,38 @@
+import Extend from 'flarum/common/extenders';
+import app from 'flarum/admin/app';
+
+export default [
+ new Extend.Admin()
+ .setting(
+ () => ({
+ setting: 'flarum-pusher.app_id',
+ label: app.translator.trans('flarum-pusher.admin.pusher_settings.app_id_label'),
+ type: 'text',
+ }),
+ 30
+ )
+ .setting(
+ () => ({
+ setting: 'flarum-pusher.app_key',
+ label: app.translator.trans('flarum-pusher.admin.pusher_settings.app_key_label'),
+ type: 'text',
+ }),
+ 20
+ )
+ .setting(
+ () => ({
+ setting: 'flarum-pusher.app_secret',
+ label: app.translator.trans('flarum-pusher.admin.pusher_settings.app_secret_label'),
+ type: 'text',
+ }),
+ 10
+ )
+ .setting(
+ () => ({
+ setting: 'flarum-pusher.app_cluster',
+ label: app.translator.trans('flarum-pusher.admin.pusher_settings.app_cluster_label'),
+ type: 'text',
+ }),
+ 0
+ ),
+];
diff --git a/extensions/pusher/js/src/admin/index.ts b/extensions/pusher/js/src/admin/index.ts
index 7e6937b5b5..ab02b9dcd4 100644
--- a/extensions/pusher/js/src/admin/index.ts
+++ b/extensions/pusher/js/src/admin/index.ts
@@ -1,38 +1,7 @@
import app from 'flarum/admin/app';
+export { default as extend } from './extend';
+
app.initializers.add('flarum-pusher', () => {
- app.extensionData
- .for('flarum-pusher')
- .registerSetting(
- {
- setting: 'flarum-pusher.app_id',
- label: app.translator.trans('flarum-pusher.admin.pusher_settings.app_id_label'),
- type: 'text',
- },
- 30
- )
- .registerSetting(
- {
- setting: 'flarum-pusher.app_key',
- label: app.translator.trans('flarum-pusher.admin.pusher_settings.app_key_label'),
- type: 'text',
- },
- 20
- )
- .registerSetting(
- {
- setting: 'flarum-pusher.app_secret',
- label: app.translator.trans('flarum-pusher.admin.pusher_settings.app_secret_label'),
- type: 'text',
- },
- 10
- )
- .registerSetting(
- {
- setting: 'flarum-pusher.app_cluster',
- label: app.translator.trans('flarum-pusher.admin.pusher_settings.app_cluster_label'),
- type: 'text',
- },
- 0
- );
+ // ...
});
diff --git a/extensions/statistics/js/src/admin/extend.tsx b/extensions/statistics/js/src/admin/extend.tsx
new file mode 100644
index 0000000000..e8eaaaa8a6
--- /dev/null
+++ b/extensions/statistics/js/src/admin/extend.tsx
@@ -0,0 +1,4 @@
+import Extend from 'flarum/common/extenders';
+import StatisticsPage from './components/StatisticsPage';
+
+export default [new Extend.Admin().page(StatisticsPage)];
diff --git a/extensions/statistics/js/src/admin/index.tsx b/extensions/statistics/js/src/admin/index.tsx
index e2886c1e54..198cc570c0 100644
--- a/extensions/statistics/js/src/admin/index.tsx
+++ b/extensions/statistics/js/src/admin/index.tsx
@@ -1,15 +1,13 @@
import app from 'flarum/admin/app';
import { extend } from 'flarum/common/extend';
-
import DashboardPage from 'flarum/admin/components/DashboardPage';
import MiniStatisticsWidget from './components/MiniStatisticsWidget';
-import StatisticsPage from './components/StatisticsPage';
+
+export { default as extend } from './extend';
app.initializers.add('flarum-statistics', () => {
extend(DashboardPage.prototype, 'availableWidgets', function (widgets) {
widgets.add('statistics', , 20);
});
-
- app.extensionData.for('flarum-statistics').registerPage(StatisticsPage);
});
diff --git a/extensions/sticky/js/src/admin/extend.ts b/extensions/sticky/js/src/admin/extend.ts
deleted file mode 100644
index 9ce8b5f124..0000000000
--- a/extensions/sticky/js/src/admin/extend.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default as default } from '../common/extend';
diff --git a/extensions/sticky/js/src/admin/index.js b/extensions/sticky/js/src/admin/extend.tsx
similarity index 54%
rename from extensions/sticky/js/src/admin/index.js
rename to extensions/sticky/js/src/admin/extend.tsx
index 057c5ea345..02d6f3def2 100644
--- a/extensions/sticky/js/src/admin/index.js
+++ b/extensions/sticky/js/src/admin/extend.tsx
@@ -1,15 +1,17 @@
+import Extend from 'flarum/common/extenders';
import app from 'flarum/admin/app';
+import commonExtend from '../common/extend';
-export { default as extend } from './extend';
+export default [
+ ...commonExtend,
-app.initializers.add('flarum-sticky', () => {
- app.extensionData.for('flarum-sticky').registerPermission(
- {
+ new Extend.Admin().permission(
+ () => ({
icon: 'fas fa-thumbtack',
label: app.translator.trans('flarum-sticky.admin.permissions.sticky_discussions_label'),
permission: 'discussion.sticky',
- },
+ }),
'moderate',
95
- );
-});
+ ),
+];
diff --git a/extensions/sticky/js/src/admin/index.tsx b/extensions/sticky/js/src/admin/index.tsx
new file mode 100644
index 0000000000..7d0c59de11
--- /dev/null
+++ b/extensions/sticky/js/src/admin/index.tsx
@@ -0,0 +1,7 @@
+import app from 'flarum/admin/app';
+
+export { default as extend } from './extend';
+
+app.initializers.add('flarum-sticky', () => {
+ // ...
+});
diff --git a/extensions/suspend/js/src/admin/extend.ts b/extensions/suspend/js/src/admin/extend.ts
deleted file mode 100644
index 9ce8b5f124..0000000000
--- a/extensions/suspend/js/src/admin/extend.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default as default } from '../common/extend';
diff --git a/extensions/suspend/js/src/admin/index.js b/extensions/suspend/js/src/admin/extend.tsx
similarity index 51%
rename from extensions/suspend/js/src/admin/index.js
rename to extensions/suspend/js/src/admin/extend.tsx
index b7ff301320..2170d47bb0 100644
--- a/extensions/suspend/js/src/admin/index.js
+++ b/extensions/suspend/js/src/admin/extend.tsx
@@ -1,14 +1,16 @@
+import Extend from 'flarum/common/extenders';
import app from 'flarum/admin/app';
+import commonExtend from '../common/extend';
-export { default as extend } from './extend';
+export default [
+ ...commonExtend,
-app.initializers.add('flarum-suspend', () => {
- app.extensionData.for('flarum-suspend').registerPermission(
- {
+ new Extend.Admin().permission(
+ () => ({
icon: 'fas fa-ban',
label: app.translator.trans('flarum-suspend.admin.permissions.suspend_users_label'),
permission: 'user.suspend',
- },
+ }),
'moderate'
- );
-});
+ ),
+];
diff --git a/extensions/suspend/js/src/admin/index.tsx b/extensions/suspend/js/src/admin/index.tsx
new file mode 100644
index 0000000000..c6896585c2
--- /dev/null
+++ b/extensions/suspend/js/src/admin/index.tsx
@@ -0,0 +1,7 @@
+import app from 'flarum/admin/app';
+
+export { default as extend } from './extend';
+
+app.initializers.add('flarum-suspend', () => {
+ // ...
+});
diff --git a/extensions/tags/js/src/admin/addTagsHomePageOption.js b/extensions/tags/js/src/admin/addTagsHomePageOption.js
index 2b9319a2e8..fa93307c09 100644
--- a/extensions/tags/js/src/admin/addTagsHomePageOption.js
+++ b/extensions/tags/js/src/admin/addTagsHomePageOption.js
@@ -2,7 +2,7 @@ import { extend } from 'flarum/common/extend';
import BasicsPage from 'flarum/admin/components/BasicsPage';
export default function () {
- extend(BasicsPage.prototype, 'homePageItems', (items) => {
+ extend(BasicsPage, 'homePageItems', (items) => {
items.add('tags', {
path: '/tags',
label: app.translator.trans('flarum-tags.admin.basics.tags_label'),
diff --git a/extensions/tags/js/src/admin/admin.ts b/extensions/tags/js/src/admin/admin.ts
index 8ea87c253f..d0e75bb954 100644
--- a/extensions/tags/js/src/admin/admin.ts
+++ b/extensions/tags/js/src/admin/admin.ts
@@ -5,5 +5,4 @@ import './components/EditTagModal';
import './addTagsHomePageOption';
import './addTagChangePermission';
-import './addTagPermission';
import './addTagsPermissionScope';
diff --git a/extensions/tags/js/src/admin/addTagPermission.js b/extensions/tags/js/src/admin/extend.tsx
similarity index 52%
rename from extensions/tags/js/src/admin/addTagPermission.js
rename to extensions/tags/js/src/admin/extend.tsx
index cbae6d2167..b296605984 100644
--- a/extensions/tags/js/src/admin/addTagPermission.js
+++ b/extensions/tags/js/src/admin/extend.tsx
@@ -1,22 +1,29 @@
-export default function () {
- app.extensionData
- .for('flarum-tags')
- .registerPermission(
- {
+import Extend from 'flarum/common/extenders';
+import commonExtend from '../common/extend';
+import app from 'flarum/admin/app';
+import TagsPage from './components/TagsPage';
+
+export default [
+ ...commonExtend,
+
+ new Extend.Admin()
+ .page(TagsPage)
+ .permission(
+ () => ({
icon: 'fas fa-tag',
label: app.translator.trans('flarum-tags.admin.permissions.tag_discussions_label'),
permission: 'discussion.tag',
- },
+ }),
'moderate',
95
)
- .registerPermission(
- {
+ .permission(
+ () => ({
icon: 'fas fa-tags',
label: app.translator.trans('flarum-tags.admin.permissions.bypass_tag_counts_label'),
permission: 'bypassTagCounts',
- },
+ }),
'start',
89
- );
-}
+ ),
+];
diff --git a/extensions/tags/js/src/admin/index.ts b/extensions/tags/js/src/admin/index.ts
index 7ab9a2f7ba..2507bff01f 100644
--- a/extensions/tags/js/src/admin/index.ts
+++ b/extensions/tags/js/src/admin/index.ts
@@ -1,21 +1,16 @@
import app from 'flarum/admin/app';
import addTagsPermissionScope from './addTagsPermissionScope';
-import addTagPermission from './addTagPermission';
import addTagsHomePageOption from './addTagsHomePageOption';
import addTagChangePermission from './addTagChangePermission';
import addTagSelectionSettingComponent from './addTagSelectionSettingComponent';
-import TagsPage from './components/TagsPage';
import TagListState from '../common/states/TagListState';
-export { default as extend } from '../common/extend';
+export { default as extend } from './extend';
app.initializers.add('flarum-tags', (app) => {
app.tagList = new TagListState();
- app.extensionData.for('flarum-tags').registerPage(TagsPage);
-
addTagsPermissionScope();
- addTagPermission();
addTagsHomePageOption();
addTagChangePermission();
addTagSelectionSettingComponent();
diff --git a/framework/core/js/src/admin/AdminApplication.tsx b/framework/core/js/src/admin/AdminApplication.tsx
index f87b4c7b31..753b6299a4 100644
--- a/framework/core/js/src/admin/AdminApplication.tsx
+++ b/framework/core/js/src/admin/AdminApplication.tsx
@@ -4,10 +4,17 @@ import routes, { AdminRoutes } from './routes';
import Application, { ApplicationData } from '../common/Application';
import Navigation from '../common/components/Navigation';
import AdminNav from './components/AdminNav';
-import ExtensionData from './utils/ExtensionData';
+import AdminRegistry from './utils/AdminRegistry';
import IHistory from '../common/IHistory';
import SearchManager from '../common/SearchManager';
import SearchState from '../common/states/SearchState';
+import app from './app';
+import BasicsPage from './components/BasicsPage';
+import GeneralSearchIndex from './states/GeneralSearchIndex';
+import AppearancePage from './components/AppearancePage';
+import MailPage from './components/MailPage';
+import AdvancedPage from './components/AdvancedPage';
+import PermissionsPage from './components/PermissionsPage';
export type Extension = {
id: string;
@@ -32,6 +39,7 @@ export type Extension = {
extra: {
'flarum-extension': {
title: string;
+ category?: string;
'database-support'?: string[];
};
};
@@ -66,7 +74,13 @@ export interface AdminApplicationData extends ApplicationData {
}
export default class AdminApplication extends Application {
- extensionData = new ExtensionData();
+ /**
+ * Stores the available settings, permissions, and custom pages of the app.
+ * Allows the global search to find these items.
+ *
+ * @internal
+ */
+ registry = new AdminRegistry();
extensionCategories = {
feature: 30,
@@ -88,6 +102,12 @@ export default class AdminApplication extends Application {
search: SearchManager = new SearchManager(new SearchState());
+ /**
+ * Custom settings and custom permissions do not go through the registry.
+ * The general index is used to manually add these items to be picked up by the search.
+ */
+ generalIndex: GeneralSearchIndex = new GeneralSearchIndex();
+
/**
* Settings are serialized to the admin dashboard as strings.
* Additional encoding/decoding is possible, but must take
@@ -108,6 +128,14 @@ export default class AdminApplication extends Application {
this.route = (Object.getPrototypeOf(Object.getPrototypeOf(this)) as Application).route.bind(this);
}
+ protected beforeMount(): void {
+ BasicsPage.register();
+ AppearancePage.register();
+ MailPage.register();
+ AdvancedPage.register();
+ PermissionsPage.register();
+ }
+
/**
* @inheritdoc
*/
diff --git a/framework/core/js/src/admin/admin.ts b/framework/core/js/src/admin/admin.ts
index df3052cdcb..ae4cb2147b 100644
--- a/framework/core/js/src/admin/admin.ts
+++ b/framework/core/js/src/admin/admin.ts
@@ -1,7 +1,7 @@
import '../common/common';
import './utils/saveSettings';
-import './utils/ExtensionData';
+import './utils/AdminRegistry';
import './utils/isExtensionEnabled';
import './utils/getCategorizedExtensions';
diff --git a/framework/core/js/src/admin/components/AdminPage.tsx b/framework/core/js/src/admin/components/AdminPage.tsx
index b2bc2d7dac..723ddd4bbb 100644
--- a/framework/core/js/src/admin/components/AdminPage.tsx
+++ b/framework/core/js/src/admin/components/AdminPage.tsx
@@ -168,7 +168,7 @@ export default abstract class AdminPage;
+ return ;
}
/**
@@ -243,7 +243,7 @@ export default abstract class AdminPage {
+ static modelLocale(): Record {
return {
'Flarum\\Discussion\\Discussion': extractText(app.translator.trans('core.admin.models.discussions')),
'Flarum\\User\\User': extractText(app.translator.trans('core.admin.models.users')),
diff --git a/framework/core/js/src/admin/components/AdvancedPage.tsx b/framework/core/js/src/admin/components/AdvancedPage.tsx
index 44652cf350..e2297a5817 100644
--- a/framework/core/js/src/admin/components/AdvancedPage.tsx
+++ b/framework/core/js/src/admin/components/AdvancedPage.tsx
@@ -86,7 +86,7 @@ export default class AdvancedPage e