Skip to content

Commit

Permalink
minor refactor of registerSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
imorland committed May 26, 2022
1 parent 331066f commit 626ed52
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 20 deletions.
20 changes: 0 additions & 20 deletions js/src/admin/index.js

This file was deleted.

19 changes: 19 additions & 0 deletions js/src/admin/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import app from 'flarum/admin/app';

// Keeping the old flagrow settings prefix because it's easier
const settingsPrefix = 'flagrow-html-errors.';
const translationPrefix = 'fof-html-errors.admin.settings.';

app.initializers.add('fof-html-errors', () => {
const extensionData = app.extensionData.for('fof-html-errors');

[403, 404, 500, 503].map((error) => {
extensionData.registerSetting({
setting: `${settingsPrefix}custom${error}ErrorHtml`,
label: app.translator.trans(`${translationPrefix}error.${error}`),
placeholder: app.translator.trans(`${translationPrefix}placeholder.empty_for_default`),
type: 'textarea',
rows: 10,
});
});
});
16 changes: 16 additions & 0 deletions js/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// 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/**/*", "../vendor/flarum/core/js/dist-typings/@types/**/*"],
"compilerOptions": {
// This will output typings to `dist-typings`
"declarationDir": "./dist-typings",
"baseUrl": ".",
"paths": {
"flarum/*": ["../vendor/flarum/core/js/dist-typings/*"]
}
}
}

0 comments on commit 626ed52

Please sign in to comment.