1
0
mirror of https://github.com/flarum/core.git synced 2025-08-16 05:14:20 +02:00

Compare commits

...

19 Commits

Author SHA1 Message Date
StyleCI Bot
88b5918e3a Apply fixes from StyleCI
[ci skip] [skip ci]
2022-03-24 13:28:40 +00:00
Daniël Klabbers
d0119e7634 Merge branch 'dk/20220318-tag-index' into dk/20220324-performance-test 2022-03-24 14:28:04 +01:00
Daniël Klabbers
726c8f3a9a missed another prefix for tests 2022-03-24 00:35:41 +01:00
StyleCI Bot
8fe1d1cabc Apply fixes from StyleCI
[ci skip] [skip ci]
2022-03-23 23:28:45 +00:00
Daniël Klabbers
d0b4e74b1f fix prefix failing in tests 2022-03-24 00:28:25 +01:00
StyleCI Bot
65c861ab7b Apply fixes from StyleCI
[ci skip] [skip ci]
2022-03-23 20:30:55 +00:00
Daniël Klabbers
cb9fe6930f possibly fixes the issue with post number calculation 2022-03-23 21:30:46 +01:00
flarum-bot
b64003cba5 Bundled output for commit 46f8cf4628
Includes transpiled JS/TS.

[skip ci]
2022-03-23 17:37:18 +00:00
Sami Mazouz
46f8cf4628 fix: Post--by-start-user class not working (#3356) 2022-03-23 18:21:01 +01:00
flarum-bot
6df4101bae Bundled output for commit a595665bfb
Includes transpiled JS/TS.

[skip ci]
2022-03-23 15:45:44 +00:00
Alexander Skvortsov
a595665bfb fix: Assorted Typing Fixes (#3348)
With all the commits below, we resolve all outstanding typing issues in the repo, and CI jobs run green.

* fix: Convert DashboardPage and DashboardWidget to TypeScript

* fix: fix type errors in package manager ext

* fix: Convert Post component to TypeScript

* fix: avatar typings should accept null user

* fix: convert Notification component to TypeScript

* fix: properly use `typeof` in ForumApplication

* feat: make Notification content attr generic

* chore: format Notification component

* fix: Convert DiscussionRenamedNotification to TypeScript

* fix(pusher) move shims to a location where they get applied

* fix(pusher): fix some typing errors

* fix(akismet): fix some typing issues

* chore: update core dist typings

* chore(pusher): format

* fix: anchorScroll should accept string selectors

* fix: more accurately represent ApiQueryParamsPlural

* fix: convert PostStreamState to TypeScript

* chore(core): rebuild typings

* feat: allow extending app.routes

* fix: more flexible typings for highlight.ts

* fix: use primitive `number` type for Discussion typings

* fix: convert DiscussionListItem to TypeScript

* chore: rebuild core typings

* fix: final pusher type fixes

* feat: start tags TypeScript conversion

* fix: require-dev tags in pusher for CI TypeScript purposes.

* chore(core): format

* chore(tags): build dist typings

* feat(pusher): use dist types from tags.

* feat: convert flags to TypeScript

* chore(flags): generate dist typings

* fix(akismet): last type errors

* chore: update .yarn-integrity

* chore: partially run flarum-cli audit infra --fix

The tsconfig changes from that command are ignored, since we don't yet support "replacable sections" that would let us add custom config.

* chore: use type imports

* fix: broader gitattributes

* chore: run flarum-cli audit infra --monorepo --fix

* feat: make `app.data` typings extensible

* chore(core): format

* chore: boost tags TypeScript coverage

* fix(tags): further increase type coverage.
2022-03-23 11:43:14 -04:00
Daniël Klabbers
3343fde5f2 add distinct and clean up code further 2022-03-23 12:05:03 +01:00
StyleCI Bot
907b1f10aa Apply fixes from StyleCI
[ci skip] [skip ci]
2022-03-18 15:46:30 +00:00
Daniël Klabbers
ae7d31ec16 fix(tags)!: reduce tag filter query from 3+ second
This PR removes the subqueries inserted for each selected tag. As this
caused the query to take over 3 seconds on communities with hundred
million posts.

```sql
and (`discussions`.`id` in (select `discussion_id` from `discussion_tag` where `tag_id` = 105))
```

The above part takes on average 3.85 seconds, with a join it takes 0.00
seconds.

BREAKING CHANGE: extending the query might have different outcome as we
now use a join and no subquery.
2022-03-18 16:40:30 +01:00
flarum-bot
4ecd9a9b2f Bundled output for commit 5e82ded8c3
Includes transpiled JS/TS.

[skip ci]
2022-03-12 00:14:54 +00:00
Alexander Skvortsov
5e82ded8c3 feat: use yarn workspaces 2022-03-11 19:12:11 -05:00
Alexander Skvortsov
524540cb41 chore: use yarn v1 in extensions/core 2022-03-11 19:12:11 -05:00
Alexander Skvortsov
f2910d8763 chore: add version to core/ext package.json
This is necessary for yarn workspaces to work.
2022-03-11 19:12:11 -05:00
StyleCI Bot
a2eba3e978 Apply fixes from StyleCI
[ci skip] [skip ci]
2022-03-11 23:11:35 +00:00
278 changed files with 8782 additions and 6326 deletions

20
.gitattributes vendored Normal file
View File

@@ -0,0 +1,20 @@
**/.gitattributes export-ignore
**/.gitignore export-ignore
**/.gitmodules export-ignore
**/.github export-ignore
**/.travis export-ignore
**/.travis.yml export-ignore
**/.editorconfig export-ignore
**/.styleci.yml export-ignore
**/phpunit.xml export-ignore
**/tests export-ignore
**/js/dist/**/* -diff
**/js/dist/**/* linguist-generated
**/js/dist-typings/**/* -diff
**/js/dist-typings/**/* linguist-generated
**/js/yarn.lock -diff
**/js/package-lock.json -diff
* text=auto eol=lf

View File

@@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/akismet
js_package_manager: yarn
main_git_branch: main
secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/approval
js_package_manager: yarn
main_git_branch: main
secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@@ -18,5 +18,6 @@ jobs:
backend_directory: ./framework/core
js_package_manager: yarn
main_git_branch: main
secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/embed
js_package_manager: yarn
main_git_branch: main
secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/emoji
js_package_manager: yarn
main_git_branch: main
secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@@ -12,11 +12,12 @@ jobs:
with:
enable_bundlewatch: false
enable_prettier: true
enable_typescript: false
enable_typescript: true
frontend_directory: ./extensions/flags/js
backend_directory: ./extensions/flags
js_package_manager: yarn
main_git_branch: main
secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/likes
js_package_manager: yarn
main_git_branch: main
secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/lock
js_package_manager: yarn
main_git_branch: main
secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/markdown
js_package_manager: yarn
main_git_branch: main
secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/mentions
js_package_manager: yarn
main_git_branch: main
secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/nicknames
js_package_manager: yarn
main_git_branch: main
secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/package-manager
js_package_manager: yarn
main_git_branch: main
secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/pusher
js_package_manager: yarn
main_git_branch: main
secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/statistics
js_package_manager: yarn
main_git_branch: main
secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/sticky
js_package_manager: yarn
main_git_branch: main
secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/subscriptions
js_package_manager: yarn
main_git_branch: main
secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@@ -18,5 +18,6 @@ jobs:
backend_directory: ./extensions/suspend
js_package_manager: yarn
main_git_branch: main
secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@@ -12,7 +12,7 @@ jobs:
with:
enable_bundlewatch: false
enable_prettier: false
enable_typescript: false
enable_typescript: true
frontend_directory: ./extensions/tags/js
backend_directory: ./extensions/tags

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
node_modules

View File

@@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@@ -1,6 +1,7 @@
{
"private": true,
"name": "@flarum/akismet",
"version": "0.0.0",
"prettier": "@flarum/prettier-config",
"scripts": {
"dev": "webpack --mode development --watch",
@@ -11,7 +12,7 @@
"check-typings": "tsc --noEmit --emitDeclarationOnly false",
"check-typings-coverage": "typescript-coverage-report",
"clean-typings": "npx rimraf dist-typings && mkdir dist-typings",
"build-typings": "yarn run clean-typings && [ -e src/@types ] && cp -r src/@types dist-typings/@types && tsc && yarn run post-build-typings",
"build-typings": "yarn run clean-typings && ([ -e src/@types ] && cp -r src/@types dist-typings/@types || true) && tsc && yarn run post-build-typings",
"post-build-typings": "find dist-typings -type f -name '*.d.ts' -print0 | xargs -0 sed -i 's,../src/@types,@types,g'"
},
"devDependencies": {

View File

@@ -1,18 +1,22 @@
import { extend, override } from 'flarum/common/extend';
import app from 'flarum/forum/app';
import type Post from 'flarum/common/models/Post';
import type ItemList from 'flarum/common/utils/ItemList';
import PostControls from 'flarum/forum/utils/PostControls';
import CommentPost from 'flarum/forum/components/CommentPost';
import ItemList from 'flarum/common/utils/ItemList';
import Post from 'flarum/common/models/Post';
import type Mithril from 'mithril';
app.initializers.add('flarum-akismet', () => {
extend(PostControls, 'destructiveControls', function (items: ItemList, post: Post) {
extend(PostControls, 'destructiveControls', function (items: ItemList<Mithril.Children>, post: Post) {
if (items.has('approve')) {
const flags = post.flags();
if (flags && flags.some((flag) => flag.type() === 'akismet')) {
items.get('approve').children = app.translator.trans('flarum-akismet.forum.post.not_spam_button');
if (flags && flags.some((flag) => flag?.type() === 'akismet')) {
const approveItem = items.get('approve');
if (approveItem && typeof approveItem === 'object' && 'children' in approveItem) {
approveItem.children = app.translator.trans('flarum-akismet.forum.post.not_spam_button');
}
}
}
});

View File

@@ -4,13 +4,14 @@
// 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/**/*", "@types/**/*"],
"include": ["src/**/*", "../vendor/*/*/js/dist-typings/@types/**/*", "@types/**/*"],
"compilerOptions": {
// This will output typings to `dist-typings`
"declarationDir": "./dist-typings",
"baseUrl": ".",
"paths": {
"flarum/*": ["../vendor/flarum/core/js/dist-typings/*"]
"flarum/*": ["../vendor/flarum/core/js/dist-typings/*"],
"flarum/flags/*": ["../vendor/flarum/flags/js/dist-typings/*"]
}
}
}

View File

@@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@@ -1,6 +1,7 @@
{
"private": true,
"name": "@flarum/approval",
"version": "0.0.0",
"prettier": "@flarum/prettier-config",
"devDependencies": {
"prettier": "^2.5.1",

View File

@@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@@ -1,6 +1,7 @@
{
"private": true,
"name": "@flarum/embed",
"version": "0.0.0",
"prettier": "@flarum/prettier-config",
"dependencies": {
"iframe-resizer": "^4.3.2"

View File

@@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@@ -1,6 +1,7 @@
{
"private": true,
"name": "@flarum/emoji",
"version": "0.0.0",
"prettier": "@flarum/prettier-config",
"dependencies": {
"simple-emoji-map": "^0.4.1",

View File

@@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@@ -49,7 +49,7 @@
"gitConf": true,
"githubActions": true,
"prettier": true,
"typescript": false,
"typescript": true,
"bundlewatch": false,
"backendTesting": true,
"editorConfig": true,

22
extensions/flags/js/dist-typings/@types/shims.d.ts generated vendored Normal file
View File

@@ -0,0 +1,22 @@
import Flag from '../forum/models/Flag';
import FlagListState from '../forum/states/FlagListState';
import Mithril from 'mithril';
declare module 'flarum/common/models/Post' {
export default interface Post {
flags: () => false | (Flag | undefined)[];
canFlag: () => boolean;
}
}
declare module 'flarum/forum/ForumApplication' {
export default interface ForumApplication {
flags: FlagListState;
}
}
declare module 'flarum/forum/components/Post' {
export default interface Post {
flagReason: (flag: Flag) => Mithril.Children;
}
}

1
extensions/flags/js/dist-typings/admin/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1 @@
export default function _default(): void;

View File

@@ -0,0 +1 @@
export default function _default(): void;

View File

@@ -0,0 +1 @@
export default function _default(): void;

19
extensions/flags/js/dist-typings/forum/compat.d.ts generated vendored Normal file
View File

@@ -0,0 +1,19 @@
declare var _default: {
'flags/addFlagsToPosts': typeof addFlagsToPosts;
'flags/addFlagControl': typeof addFlagControl;
'flags/addFlagsDropdown': typeof addFlagsDropdown;
'flags/models/Flag': typeof Flag;
'flags/components/FlagList': typeof FlagList;
'flags/components/FlagPostModal': typeof FlagPostModal;
'flags/components/FlagsPage': typeof FlagsPage;
'flags/components/FlagsDropdown': typeof FlagsDropdown;
};
export default _default;
import addFlagsToPosts from "./addFlagsToPosts";
import addFlagControl from "./addFlagControl";
import addFlagsDropdown from "./addFlagsDropdown";
import Flag from "./models/Flag";
import FlagList from "./components/FlagList";
import FlagPostModal from "./components/FlagPostModal";
import FlagsPage from "./components/FlagsPage";
import FlagsDropdown from "./components/FlagsDropdown";

View File

@@ -0,0 +1,7 @@
export default class FlagList extends Component<import("flarum/common/Component").ComponentAttrs, undefined> {
constructor();
oninit(vnode: any): void;
state: any;
view(): JSX.Element;
}
import Component from "flarum/common/Component";

View File

@@ -0,0 +1,15 @@
/// <reference types="flarum/@types/translator-icu-rich" />
export default class FlagPostModal extends Modal<import("flarum/common/components/Modal").IInternalModalAttrs> {
constructor();
oninit(vnode: any): void;
success: boolean | undefined;
reason: Stream<string> | undefined;
reasonDetail: Stream<string> | undefined;
title(): import("@askvortsov/rich-icu-message-formatter").NestedStringArray;
content(): JSX.Element;
flagReasons(): ItemList<any>;
onsubmit(e: any): void;
}
import Modal from "flarum/common/components/Modal";
import Stream from "flarum/common/utils/Stream";
import ItemList from "flarum/common/utils/ItemList";

View File

@@ -0,0 +1,7 @@
export default class FlagsDropdown {
static initAttrs(attrs: any): void;
getMenu(): JSX.Element;
goToRoute(): void;
getUnreadCount(): any;
getNewCount(): unknown;
}

View File

@@ -0,0 +1,9 @@
/**
* The `FlagsPage` component shows the flags list. It is only
* used on mobile devices where the flags dropdown is within the drawer.
*/
export default class FlagsPage {
oninit(vnode: any): void;
bodyClass: string | undefined;
view(): JSX.Element;
}

1
extensions/flags/js/dist-typings/forum/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,11 @@
import Model from 'flarum/common/Model';
import Post from 'flarum/common/models/Post';
import User from 'flarum/common/models/User';
export default class Flag extends Model {
type(): string;
reason(): string | null;
reasonDetail(): string | null;
createdAt(): Date | null | undefined;
post(): false | Post;
user(): false | User | null;
}

View File

@@ -0,0 +1,16 @@
export default class FlagListState {
constructor(app: any);
app: any;
/**
* Whether or not the flags are loading.
*
* @type {Boolean}
*/
loading: boolean;
/**
* Load flags into the application's cache if they haven't already
* been loaded.
*/
load(): void;
cache: any;
}

View File

@@ -1,15 +1,10 @@
{
"private": true,
"name": "@flarum/flags",
"version": "0.0.0",
"prettier": "@flarum/prettier-config",
"dependencies": {
"@flarum/prettier-config": "^1.0.0",
"flarum-webpack-config": "^1.0.0",
"flarum-tsconfig": "^1.0.2",
"webpack": "^4.46.0",
"webpack-cli": "^4.9.1"
},
"devDependencies": {
"@types/mithril": "^2.0.8",
"prettier": "^2.5.1",
"flarum-webpack-config": "^2.0.0",
"webpack": "^5.65.0",
@@ -26,8 +21,9 @@
"format-check": "prettier --check src",
"analyze": "cross-env ANALYZER=true yarn run build",
"clean-typings": "npx rimraf dist-typings && mkdir dist-typings",
"build-typings": "npm run clean-typings && cp -r src/@types dist-typings/@types && tsc",
"build-typings": "yarn run clean-typings && ([ -e src/@types ] && cp -r src/@types dist-typings/@types || true) && tsc && yarn run post-build-typings",
"check-typings": "tsc --noEmit --emitDeclarationOnly false",
"check-typings-coverage": "typescript-coverage-report"
"check-typings-coverage": "typescript-coverage-report",
"post-build-typings": "find dist-typings -type f -name '*.d.ts' -print0 | xargs -0 sed -i 's,../src/@types,@types,g'"
}
}

View File

@@ -0,0 +1,22 @@
import Flag from '../forum/models/Flag';
import FlagListState from '../forum/states/FlagListState';
import Mithril from 'mithril';
declare module 'flarum/common/models/Post' {
export default interface Post {
flags: () => false | (Flag | undefined)[];
canFlag: () => boolean;
}
}
declare module 'flarum/forum/ForumApplication' {
export default interface ForumApplication {
flags: FlagListState;
}
}
declare module 'flarum/forum/components/Post' {
export default interface Post {
flagReason: (flag: Flag) => Mithril.Children;
}
}

View File

@@ -9,8 +9,8 @@ import addFlagsDropdown from './addFlagsDropdown';
import addFlagsToPosts from './addFlagsToPosts';
app.initializers.add('flarum-flags', () => {
app.store.models.posts.prototype.flags = Model.hasMany('flags');
app.store.models.posts.prototype.canFlag = Model.attribute('canFlag');
Post.prototype.flags = Model.hasMany<Flag>('flags');
Post.prototype.canFlag = Model.attribute<boolean>('canFlag');
app.store.models.flags = Flag;
@@ -26,5 +26,6 @@ app.initializers.add('flarum-flags', () => {
// Expose compat API
import flagsCompat from './compat';
import { compat } from '@flarum/core/forum';
import Post from 'flarum/common/models/Post';
Object.assign(compat, flagsCompat);

View File

@@ -1,15 +0,0 @@
import Model from 'flarum/common/Model';
class Flag extends Model {}
Object.assign(Flag.prototype, {
type: Model.attribute('type'),
reason: Model.attribute('reason'),
reasonDetail: Model.attribute('reasonDetail'),
createdAt: Model.attribute('createdAt', Model.transformDate),
post: Model.hasOne('post'),
user: Model.hasOne('user'),
});
export default Flag;

View File

@@ -0,0 +1,25 @@
import Model from 'flarum/common/Model';
import type Post from 'flarum/common/models/Post';
import type User from 'flarum/common/models/User';
export default class Flag extends Model {
type() {
return Model.attribute<string>('type').call(this);
}
reason() {
return Model.attribute<string | null>('reason').call(this);
}
reasonDetail() {
return Model.attribute<string | null>('reasonDetail').call(this);
}
createdAt() {
return Model.attribute('createdAt', Model.transformDate).call(this);
}
post() {
return Model.hasOne<Post>('post').call(this);
}
user() {
return Model.hasOne<User | null>('user').call(this);
}
}

View File

@@ -0,0 +1,17 @@
{
// 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/*/*/js/dist-typings/@types/**/*", "@types/**/*"],
"compilerOptions": {
// This will output typings to `dist-typings`
"declarationDir": "./dist-typings",
"baseUrl": ".",
"paths": {
"flarum/*": ["../vendor/flarum/core/js/dist-typings/*"],
"@flarum/core/*": ["../vendor/flarum/core/js/dist-typings/*"]
}
}
}

View File

@@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,7 @@
{
"private": true,
"name": "@flarum/likes",
"version": "0.0.0",
"prettier": "@flarum/prettier-config",
"devDependencies": {
"prettier": "^2.5.1",

View File

@@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,7 @@
{
"private": true,
"name": "@flarum/lock",
"version": "0.0.0",
"prettier": "@flarum/prettier-config",
"devDependencies": {
"prettier": "^2.5.1",

View File

@@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@@ -1,6 +1,7 @@
{
"private": true,
"name": "@flarum/markdown",
"version": "0.0.0",
"prettier": "@flarum/prettier-config",
"dependencies": {
"flarum-webpack-config": "^2.0.0",
@@ -14,7 +15,6 @@
"format-check": "prettier --check src",
"analyze": "cross-env ANALYZER=true yarn run build"
},
"packageManager": "yarn@3.1.1",
"devDependencies": {
"@flarum/prettier-config": "^1.0.0",
"flarum-tsconfig": "^1.0.2",

View File

@@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@@ -1,6 +1,7 @@
{
"private": true,
"name": "@flarum/mentions",
"version": "0.0.0",
"prettier": "@flarum/prettier-config",
"devDependencies": {
"prettier": "^2.5.1",

View File

@@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@@ -1,7 +1,7 @@
{
"private": true,
"name": "@flarum/package-manager",
"version": "0.0.0",
"private": true,
"prettier": "@flarum/prettier-config",
"devDependencies": {
"prettier": "^2.5.1",
@@ -21,7 +21,7 @@
"ci": "yarn install --immutable --immutable-cache",
"analyze": "cross-env ANALYZER=true yarn run build",
"clean-typings": "npx rimraf dist-typings && mkdir dist-typings",
"build-typings": "yarn run clean-typings && [ -e src/@types ] && cp -r src/@types dist-typings/@types && tsc && yarn run post-build-typings",
"build-typings": "yarn run clean-typings && ([ -e src/@types ] && cp -r src/@types dist-typings/@types || true) && tsc && yarn run post-build-typings",
"check-typings": "tsc --noEmit --emitDeclarationOnly false",
"check-typings-coverage": "typescript-coverage-report",
"post-build-typings": "find dist-typings -type f -name '*.d.ts' -print0 | xargs -0 sed -i 's,../src/@types,@types,g'"

View File

@@ -46,7 +46,7 @@ export default class Installer<Attrs> extends Component<Attrs> {
app.modal.show(LoadingModal);
app
.request({
.request<{ id: string }>({
method: 'POST',
url: `${app.forum.attribute('apiUrl')}/package-manager/extensions`,
body: {

View File

@@ -3,6 +3,7 @@ import app from 'flarum/admin/app';
import Component from 'flarum/common/Component';
import Button from 'flarum/common/components/Button';
import humanTime from 'flarum/common/helpers/humanTime';
import extractText from 'flarum/common/utils/extractText';
import LoadingModal from 'flarum/admin/components/LoadingModal';
import errorHandler from '../utils/errorHandler';
import LoadingIndicator from 'flarum/common/components/LoadingIndicator';
@@ -188,7 +189,7 @@ export default class Updater<Attrs> extends Component<Attrs> {
}
updateCoreMinor() {
if (confirm(app.translator.trans('flarum-package-manager.admin.minor_update_confirmation.content'))) {
if (confirm(extractText(app.translator.trans('flarum-package-manager.admin.minor_update_confirmation.content')))) {
app.modal.show(LoadingModal);
this.isLoading = 'minor-update';

View File

@@ -52,8 +52,7 @@ class UpdateExtensionHandler
UpdateExtensionValidator $validator,
LastUpdateCheck $lastUpdateCheck,
Dispatcher $events
)
{
) {
$this->composer = $composer;
$this->extensions = $extensions;
$this->validator = $validator;

View File

@@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@@ -22,6 +22,9 @@
"flarum/core": "^1.2",
"pusher/pusher-php-server": "^2.2"
},
"require-dev": {
"flarum/tags": "^1.0"
},
"autoload": {
"psr-4": {
"Flarum\\Pusher\\": "src/"

View File

@@ -1,6 +1,7 @@
{
"private": true,
"name": "@flarum/pusher",
"version": "0.0.0",
"prettier": "@flarum/prettier-config",
"scripts": {
"dev": "webpack --mode development --watch",
@@ -9,7 +10,7 @@
"format": "prettier --write src",
"format-check": "prettier --check src",
"clean-typings": "npx rimraf dist-typings && mkdir dist-typings",
"build-typings": "yarn run clean-typings && [ -e src/@types ] && cp -r src/@types dist-typings/@types && tsc && yarn run post-build-typings",
"build-typings": "yarn run clean-typings && ([ -e src/@types ] && cp -r src/@types dist-typings/@types || true) && tsc && yarn run post-build-typings",
"check-typings": "tsc --noEmit --emitDeclarationOnly false",
"check-typings-coverage": "typescript-coverage-report",
"post-build-typings": "find dist-typings -type f -name '*.d.ts' -print0 | xargs -0 sed -i 's,../src/@types,@types,g'"

View File

@@ -6,7 +6,8 @@ import DiscussionPage from 'flarum/forum/components/DiscussionPage';
import IndexPage from 'flarum/forum/components/IndexPage';
import Button from 'flarum/common/components/Button';
import ItemList from 'flarum/common/utils/ItemList';
import { Children, VnodeDOM } from 'mithril';
import type { Children } from 'mithril';
import type Tag from 'flarum/tags/common/models/Tag';
export type PusherBinding = {
channels: {
@@ -47,14 +48,15 @@ app.initializers.add('flarum-pusher', () => {
app.pusher.then((binding: PusherBinding) => {
const pusher = binding.pusher;
pusher.bind('newPost', (data: { tagIds: number[]; discussionId: number }) => {
pusher.bind('newPost', (data: { tagIds: string[]; discussionId: number }) => {
const params = app.discussions.getParams();
if (!params.q && !params.sort && !params.filter) {
if (params.tags) {
const tag = app.store.getBy('tags', 'slug', params.tags);
const tag = app.store.getBy<Tag>('tags', 'slug', params.tags);
const tagId = tag?.id();
if (!data.tagIds.includes(tag.id())) return;
if (!tagId || !data.tagIds.includes(tagId)) return;
}
const id = String(data.discussionId);
@@ -79,11 +81,11 @@ app.initializers.add('flarum-pusher', () => {
});
});
extend(DiscussionList.prototype, 'view', function (this: DiscussionList, vdom: VnodeDOM) {
extend(DiscussionList.prototype, 'view', function (this: DiscussionList, vdom: Children) {
if (app.pushedUpdates) {
const count = app.pushedUpdates.length;
if (count) {
if (count && typeof vdom === 'object' && vdom && 'children' in vdom && vdom.children instanceof Array) {
vdom.children.unshift(
Button.component(
{

View File

@@ -13,3 +13,9 @@ declare module 'flarum/forum/ForumApplication' {
pushedUpdates: Array<any>;
}
}
declare module 'flarum/forum/components/DiscussionList' {
export default interface DiscussionList {
loadingUpdated?: boolean;
}
}

View File

@@ -4,13 +4,14 @@
// 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/**/*", "@types/**/*"],
"include": ["src/**/*", "../vendor/*/*/js/dist-typings/@types/**/*", "@types/**/*"],
"compilerOptions": {
// This will output typings to `dist-typings`
"declarationDir": "./dist-typings",
"baseUrl": ".",
"paths": {
"flarum/*": ["../vendor/flarum/core/js/dist-typings/*"]
"flarum/*": ["../vendor/flarum/core/js/dist-typings/*"],
"flarum/tags/*": ["../vendor/flarum/tags/js/dist-typings/*"]
}
}
}

View File

@@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@@ -1,6 +1,7 @@
{
"private": true,
"name": "@flarum/statistics",
"version": "0.0.0",
"prettier": "@flarum/prettier-config",
"dependencies": {
"frappe-charts": "^1.6.2"
@@ -23,7 +24,7 @@
"format-check": "prettier --check src",
"analyze": "cross-env ANALYZER=true yarn run build",
"clean-typings": "npx rimraf dist-typings && mkdir dist-typings",
"build-typings": "yarn run clean-typings && [ -e src/@types ] && cp -r src/@types dist-typings/@types && tsc && yarn run post-build-typings",
"build-typings": "yarn run clean-typings && ([ -e src/@types ] && cp -r src/@types dist-typings/@types || true) && tsc && yarn run post-build-typings",
"check-typings": "tsc --noEmit --emitDeclarationOnly false",
"check-typings-coverage": "typescript-coverage-report",
"ci": "yarn install --immutable --immutable-cache",

View File

@@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@@ -1,6 +1,7 @@
{
"private": true,
"name": "@flarum/sticky",
"version": "0.0.0",
"prettier": "@flarum/prettier-config",
"devDependencies": {
"prettier": "^2.5.1",

View File

@@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,7 @@
{
"private": true,
"name": "@flarum/subscriptions",
"version": "0.0.0",
"prettier": "@flarum/prettier-config",
"devDependencies": {
"prettier": "^2.5.1",

View File

@@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@@ -1,6 +1,7 @@
{
"private": true,
"name": "@flarum/suspend",
"version": "0.0.0",
"prettier": "@flarum/prettier-config",
"scripts": {
"dev": "webpack --mode development --watch",

View File

@@ -1,19 +0,0 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
js/package-lock.json -diff
* text=auto eol=lf

View File

@@ -54,7 +54,7 @@
"gitConf": true,
"githubActions": true,
"prettier": false,
"typescript": false,
"typescript": true,
"bundlewatch": false,
"backendTesting": true,
"editorConfig": true,

21
extensions/tags/js/dist-typings/@types/shims.d.ts generated vendored Normal file
View File

@@ -0,0 +1,21 @@
import type Tag from "../common/models/Tag";
import type TagListState from "../forum/states/TagListState";
declare module 'flarum/forum/routes' {
export interface ForumRoutes {
tag: (tag: Tag) => string;
}
}
declare module 'flarum/forum/ForumApplication' {
export default interface ForumApplication {
tagList: TagListState;
}
}
declare module 'flarum/common/models/Discussion' {
export default interface Discussion {
tags: () => false | (Tag | undefined)[];
canTag: () => boolean | undefined;
}
}

View File

@@ -0,0 +1 @@
export default function _default(): void;

View File

@@ -0,0 +1 @@
export default function _default(): void;

View File

@@ -0,0 +1 @@
export default function _default(): void;

View File

@@ -0,0 +1 @@
export default function _default(): void;

21
extensions/tags/js/dist-typings/admin/compat.d.ts generated vendored Normal file
View File

@@ -0,0 +1,21 @@
declare var _default: {
'tags/utils/sortTags': typeof import("../common/utils/sortTags").default;
'tags/models/Tag': typeof import("../common/models/Tag").default;
'tags/helpers/tagsLabel': typeof import("../common/helpers/tagsLabel").default;
'tags/helpers/tagIcon': typeof import("../common/helpers/tagIcon").default;
'tags/helpers/tagLabel': typeof import("../common/helpers/tagLabel").default;
} & {
'tags/addTagsHomePageOption': typeof addTagsHomePageOption;
'tags/addTagChangePermission': typeof addTagChangePermission;
'tags/components/TagsPage': typeof TagsPage;
'tags/components/EditTagModal': typeof EditTagModal;
'tags/addTagPermission': typeof addTagPermission;
'tags/addTagsPermissionScope': typeof addTagsPermissionScope;
};
export default _default;
import addTagsHomePageOption from "./addTagsHomePageOption";
import addTagChangePermission from "./addTagChangePermission";
import TagsPage from "./components/TagsPage";
import EditTagModal from "./components/EditTagModal";
import addTagPermission from "./addTagPermission";
import addTagsPermissionScope from "./addTagsPermissionScope";

View File

@@ -0,0 +1,34 @@
/// <reference types="flarum/@types/translator-icu-rich" />
/**
* The `EditTagModal` component shows a modal dialog which allows the user
* to create or edit a tag.
*/
export default class EditTagModal extends Modal<import("flarum/common/components/Modal").IInternalModalAttrs> {
constructor();
oninit(vnode: any): void;
tag: any;
name: Stream<any> | undefined;
slug: Stream<any> | undefined;
description: Stream<any> | undefined;
color: Stream<any> | undefined;
icon: Stream<any> | undefined;
isHidden: Stream<any> | undefined;
primary: Stream<any> | undefined;
title(): import("@askvortsov/rich-icu-message-formatter").NestedStringArray | import("mithril").Vnode<any, any>;
content(): JSX.Element;
fields(): ItemList<any>;
submitData(): {
name: any;
slug: any;
description: any;
color: any;
icon: any;
isHidden: any;
primary: any;
};
onsubmit(e: any): void;
delete(): void;
}
import Modal from "flarum/common/components/Modal";
import Stream from "flarum/common/utils/Stream";
import ItemList from "flarum/common/utils/ItemList";

View File

@@ -0,0 +1,10 @@
export default class TagsPage extends ExtensionPage<import("flarum/admin/components/ExtensionPage").ExtensionPageAttrs> {
constructor();
oninit(vnode: any): void;
forcedRefreshKey: number | undefined;
content(): JSX.Element;
onListOnCreate(vnode: any): void;
setMinTags(minTags: any, maxTags: any, value: any): void;
onSortUpdate(e: any): void;
}
import ExtensionPage from "flarum/admin/components/ExtensionPage";

1
extensions/tags/js/dist-typings/admin/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

13
extensions/tags/js/dist-typings/common/compat.d.ts generated vendored Normal file
View File

@@ -0,0 +1,13 @@
declare var _default: {
'tags/utils/sortTags': typeof sortTags;
'tags/models/Tag': typeof Tag;
'tags/helpers/tagsLabel': typeof tagsLabel;
'tags/helpers/tagIcon': typeof tagIcon;
'tags/helpers/tagLabel': typeof tagLabel;
};
export default _default;
import sortTags from "./utils/sortTags";
import Tag from "./models/Tag";
import tagsLabel from "./helpers/tagsLabel";
import tagIcon from "./helpers/tagIcon";
import tagLabel from "./helpers/tagLabel";

Some files were not shown because too many files have changed in this diff Show More