1
0
mirror of https://github.com/flarum/core.git synced 2025-08-04 07:27:39 +02:00

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.
This commit is contained in:
Alexander Skvortsov
2022-03-23 11:43:14 -04:00
committed by GitHub
parent 4ecd9a9b2f
commit a595665bfb
255 changed files with 1578 additions and 1218 deletions

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

@@ -12,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,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,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

@@ -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

@@ -3,12 +3,8 @@
"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"
},
"devDependencies": {
"@types/mithril": "^2.0.8",
"prettier": "^2.5.1",
"flarum-webpack-config": "^2.0.0",
"webpack": "^5.65.0",
@@ -25,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

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,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,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

@@ -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

@@ -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

@@ -10,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

@@ -24,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,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,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";

View File

@@ -0,0 +1 @@
export default function tagIcon(tag: any, attrs?: {}, settings?: {}): JSX.Element;

View File

@@ -0,0 +1 @@
export default function tagLabel(tag: any, attrs?: {}): import("mithril").Vnode<any, any>;

View File

@@ -0,0 +1 @@
export default function tagsLabel(tags: any, attrs?: {}): JSX.Element;

24
extensions/tags/js/dist-typings/common/models/Tag.d.ts generated vendored Normal file
View File

@@ -0,0 +1,24 @@
import Model from 'flarum/common/Model';
import Discussion from 'flarum/common/models/Discussion';
export default class Tag extends Model {
name(): string;
slug(): string;
description(): string | null;
color(): string | null;
backgroundUrl(): string | null;
backgroundMode(): string | null;
icon(): string | null;
position(): number | null;
parent(): false | Tag | null;
children(): false | (Tag | undefined)[];
defaultSort(): string | null;
isChild(): boolean;
isHidden(): boolean;
discussionCount(): number;
lastPostedAt(): Date | null | undefined;
lastPostedDiscussion(): false | Discussion | null;
isRestricted(): boolean;
canStartDiscussion(): boolean;
canAddToDiscussion(): boolean;
isPrimary(): boolean;
}

View File

@@ -0,0 +1 @@
export default function sortTags(tags: any): any;

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;

View File

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

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

@@ -0,0 +1,31 @@
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/addTagFilter': typeof addTagFilter;
'tags/addTagControl': typeof addTagControl;
'tags/components/TagHero': typeof TagHero;
'tags/components/TagDiscussionModal': typeof TagDiscussionModal;
'tags/components/TagsPage': typeof TagsPage;
'tags/components/DiscussionTaggedPost': typeof DiscussionTaggedPost;
'tags/components/TagLinkButton': typeof TagLinkButton;
'tags/addTagList': typeof addTagList;
'tags/addTagLabels': typeof addTagLabels;
'tags/addTagComposer': typeof addTagComposer;
'tags/utils/getSelectableTags': typeof getSelectableTags;
};
export default _default;
import addTagFilter from "./addTagFilter";
import addTagControl from "./addTagControl";
import TagHero from "./components/TagHero";
import TagDiscussionModal from "./components/TagDiscussionModal";
import TagsPage from "./components/TagsPage";
import DiscussionTaggedPost from "./components/DiscussionTaggedPost";
import TagLinkButton from "./components/TagLinkButton";
import addTagList from "./addTagList";
import addTagLabels from "./addTagLabels";
import addTagComposer from "./addTagComposer";
import getSelectableTags from "./utils/getSelectableTags";

View File

@@ -0,0 +1,9 @@
export default class DiscussionTaggedPost extends EventPost {
static initAttrs(attrs: any): void;
descriptionKey(): "flarum-tags.forum.post_stream.added_and_removed_tags_text" | "flarum-tags.forum.post_stream.added_tags_text" | "flarum-tags.forum.post_stream.removed_tags_text";
descriptionData(): {
tagsAdded: any;
tagsRemoved: any;
};
}
import EventPost from "flarum/forum/components/EventPost";

View File

@@ -0,0 +1,44 @@
export default class TagDiscussionModal extends Modal<import("flarum/common/components/Modal").IInternalModalAttrs> {
constructor();
oninit(vnode: any): void;
tagsLoading: boolean | undefined;
selected: any[] | undefined;
filter: Stream<string> | undefined;
focused: boolean | undefined;
minPrimary: any;
maxPrimary: any;
minSecondary: any;
maxSecondary: any;
bypassReqs: any;
navigator: KeyboardNavigatable | undefined;
tags: any;
index: any;
primaryCount(): number;
secondaryCount(): number;
/**
* Add the given tag to the list of selected tags.
*
* @param {Tag} tag
*/
addTag(tag: Tag): void;
/**
* Remove the given tag from the list of selected tags.
*
* @param {Tag} tag
*/
removeTag(tag: Tag): void;
title(): any;
getInstruction(primaryCount: any, secondaryCount: any): any;
content(): JSX.Element | JSX.Element[];
meetsRequirements(primaryCount: any, secondaryCount: any): boolean;
toggleTag(tag: any): void;
select(e: any): void;
selectableItems(): JQuery<HTMLElement>;
getCurrentNumericIndex(): number;
getItem(index: any): JQuery<HTMLElement>;
setIndex(index: any, scrollToItem: any): void;
onsubmit(e: any): void;
}
import Modal from "flarum/common/components/Modal";
import Stream from "flarum/common/utils/Stream";
import KeyboardNavigatable from "flarum/forum/utils/KeyboardNavigatable";

View File

@@ -0,0 +1,5 @@
export default class TagHero extends Component<import("flarum/common/Component").ComponentAttrs, undefined> {
constructor();
view(): JSX.Element;
}
import Component from "flarum/common/Component";

View File

@@ -0,0 +1,5 @@
export default class TagLinkButton extends LinkButton {
static initAttrs(attrs: any): void;
view(vnode: any): JSX.Element;
}
import LinkButton from "flarum/common/components/LinkButton";

View File

@@ -0,0 +1,9 @@
export default class TagsPage extends Page<import("flarum/common/components/Page").IPageAttrs> {
constructor();
oninit(vnode: any): void;
tags: any;
loading: boolean | undefined;
view(): JSX.Element;
oncreate(vnode: any): void;
}
import Page from "flarum/common/components/Page";

View File

@@ -0,0 +1,8 @@
/**
* @TODO move to core
*/
export default class ToggleButton extends Component<import("flarum/common/Component").ComponentAttrs, undefined> {
constructor();
view(vnode: any): JSX.Element;
}
import Component from "flarum/common/Component";

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

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

View File

@@ -0,0 +1,5 @@
import Tag from "../../common/models/Tag";
export default class TagListState {
loadedIncludes: Set<unknown>;
load(includes?: never[]): Promise<Tag[]>;
}

View File

@@ -0,0 +1 @@
export default function getSelectableTags(discussion: any): any;

View File

@@ -8,11 +8,19 @@
"scripts": {
"dev": "webpack --mode development --watch",
"build": "webpack --mode production",
"analyze": "cross-env ANALYZER=true yarn run build"
"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 || 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'",
"check-typings": "tsc --noEmit --emitDeclarationOnly false",
"check-typings-coverage": "typescript-coverage-report"
},
"devDependencies": {
"flarum-webpack-config": "^2.0.0",
"webpack": "^5.65.0",
"webpack-cli": "^4.9.1"
"webpack-cli": "^4.9.1",
"flarum-tsconfig": "^1.0.2",
"typescript": "^4.5.4",
"typescript-coverage-report": "^0.6.1"
}
}

View File

@@ -0,0 +1,38 @@
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;
}
}
declare module 'flarum/forum/components/IndexPage' {
export default interface IndexPage {
currentActiveTag?: Tag;
currentTagLoading?: boolean;
currentTag: () => Tag | undefined;
}
}
declare module 'flarum/admin/components/PermissionGrid' {
export interface PermissionConfig {
tagScoped?: boolean;
}
export default interface PermissionGrid {
loading?: boolean;
}
}

View File

@@ -1,6 +1,6 @@
import { extend } from 'flarum/extend';
import PermissionGrid from 'flarum/components/PermissionGrid';
import SettingDropdown from 'flarum/components/SettingDropdown';
import { extend } from 'flarum/common/extend';
import PermissionGrid from 'flarum/admin/components/PermissionGrid';
import SettingDropdown from 'flarum/admin/components/SettingDropdown';
export default function() {
extend(PermissionGrid.prototype, 'startItems', items => {

View File

@@ -1,5 +1,5 @@
import { extend } from 'flarum/extend';
import BasicsPage from 'flarum/components/BasicsPage';
import { extend } from 'flarum/common/extend';
import BasicsPage from 'flarum/admin/components/BasicsPage';
export default function() {
extend(BasicsPage.prototype, 'homePageItems', items => {

View File

@@ -1,13 +1,15 @@
import { extend, override } from 'flarum/extend';
import PermissionGrid from 'flarum/components/PermissionGrid';
import PermissionDropdown from 'flarum/components/PermissionDropdown';
import Dropdown from 'flarum/components/Dropdown';
import Button from 'flarum/components/Button';
import LoadingIndicator from 'flarum/components/LoadingIndicator';
import app from 'flarum/admin/app';
import { extend, override } from 'flarum/common/extend';
import PermissionGrid from 'flarum/admin/components/PermissionGrid';
import PermissionDropdown from 'flarum/admin/components/PermissionDropdown';
import Dropdown from 'flarum/common/components/Dropdown';
import Button from 'flarum/common/components/Button';
import LoadingIndicator from 'flarum/common/components/LoadingIndicator';
import tagLabel from '../common/helpers/tagLabel';
import tagIcon from '../common/helpers/tagIcon';
import sortTags from '../common/utils/sortTags';
import Tag from '../common/models/Tag';
export default function() {
extend(PermissionGrid.prototype, 'oninit', function () {
@@ -15,7 +17,7 @@ export default function() {
})
extend(PermissionGrid.prototype, 'oncreate', function () {
app.store.find('tags').then(() => {
app.store.find<Tag[]>('tags', {}).then(() => {
this.loading = false;
m.redraw();
@@ -51,6 +53,8 @@ export default function() {
label: tagLabel(tag),
onremove: () => tag.save({isRestricted: false}),
render: item => {
if ('setting' in item) return '';
if (item.permission === 'viewForum'
|| item.permission === 'startDiscussion'
|| (item.permission && item.permission.indexOf('discussion.') === 0 && item.tagScoped !== false)
@@ -67,7 +71,7 @@ export default function() {
});
extend(PermissionGrid.prototype, 'scopeControlItems', items => {
const tags = sortTags(app.store.all('tags').filter(tag => !tag.isRestricted()));
const tags = sortTags(app.store.all<Tag>('tags').filter(tag => !tag.isRestricted()));
if (tags.length) {
items.add('tag', <Dropdown className='Dropdown--restrictByTag' buttonClassName='Button Button--text' label={app.translator.trans('flarum-tags.admin.permissions.restrict_by_tag_heading')} icon='fas fa-plus' caretIcon={null}>

View File

@@ -1,5 +1,5 @@
import app from 'flarum/admin/app';
import Modal from 'flarum/common/components/Modal';
import Modal, { IInternalModalAttrs } from 'flarum/common/components/Modal';
import Button from 'flarum/common/components/Button';
import ColorPreviewInput from 'flarum/common/components/ColorPreviewInput';
import ItemList from 'flarum/common/utils/ItemList';
@@ -7,13 +7,32 @@ import { slug } from 'flarum/common/utils/string';
import Stream from 'flarum/common/utils/Stream';
import tagLabel from '../../common/helpers/tagLabel';
import type Mithril from 'mithril';
import type Tag from '../../common/models/Tag';
import extractText from 'flarum/common/utils/extractText';
import { ModelIdentifier } from 'flarum/common/Model';
export interface EditTagModalAttrs extends IInternalModalAttrs {
primary?: boolean;
model?: Tag;
}
/**
* The `EditTagModal` component shows a modal dialog which allows the user
* to create or edit a tag.
*/
export default class EditTagModal extends Modal {
oninit(vnode) {
export default class EditTagModal extends Modal<EditTagModalAttrs> {
tag!: Tag;
name!: Stream<string>;
slug!: Stream<string>;
description!: Stream<string>;
color!: Stream<string>;
icon!: Stream<string>;
isHidden!: Stream<boolean>;
primary!: Stream<boolean>;
oninit(vnode: Mithril.Vnode<EditTagModalAttrs, this>) {
super.oninit(vnode);
this.tag = this.attrs.model || app.store.createRecord('tags');
@@ -52,9 +71,10 @@ export default class EditTagModal extends Modal {
items.add('name', <div className="Form-group">
<label>{app.translator.trans('flarum-tags.admin.edit_tag.name_label')}</label>
<input className="FormControl" placeholder={app.translator.trans('flarum-tags.admin.edit_tag.name_placeholder')} value={this.name()} oninput={e => {
this.name(e.target.value);
this.slug(slug(e.target.value));
<input className="FormControl" placeholder={app.translator.trans('flarum-tags.admin.edit_tag.name_placeholder')} value={this.name()} oninput={(e: InputEvent) => {
const target = e.target as HTMLInputElement;
this.name(target.value);
this.slug(slug(target.value));
}} />
</div>, 50);
@@ -118,7 +138,7 @@ export default class EditTagModal extends Modal {
};
}
onsubmit(e) {
onsubmit(e: SubmitEvent) {
e.preventDefault();
this.loading = true;
@@ -132,13 +152,14 @@ export default class EditTagModal extends Modal {
}
delete() {
if (confirm(app.translator.trans('flarum-tags.admin.edit_tag.delete_tag_confirmation'))) {
const children = app.store.all('tags').filter(tag => tag.parent() === this.tag);
if (confirm(extractText(app.translator.trans('flarum-tags.admin.edit_tag.delete_tag_confirmation')))) {
const children = app.store.all<Tag>('tags').filter(tag => tag.parent() === this.tag);
this.tag.delete().then(() => {
children.forEach(tag => tag.pushData({
attributes: { isChild: false },
relationships: { parent: null }
// @deprecated. Temporary hack for type safety, remove before v1.3.
relationships: { parent: null as any as [] }
}));
m.redraw();
});

View File

@@ -1,9 +1,9 @@
import sortable from 'sortablejs';
import ExtensionPage from 'flarum/components/ExtensionPage';
import Button from 'flarum/components/Button';
import LoadingIndicator from 'flarum/components/LoadingIndicator';
import withAttr from 'flarum/utils/withAttr';
import ExtensionPage from 'flarum/admin/components/ExtensionPage';
import Button from 'flarum/common/components/Button';
import LoadingIndicator from 'flarum/common/components/LoadingIndicator';
import withAttr from 'flarum/common/utils/withAttr';
import EditTagModal from './EditTagModal';
import tagIcon from '../../common/helpers/tagIcon';

View File

@@ -1,3 +1,4 @@
import app from 'flarum/admin/app';
import Tag from '../common/models/Tag';
import addTagsPermissionScope from './addTagsPermissionScope';
import addTagPermission from './addTagPermission';

View File

@@ -1,4 +1,4 @@
import classList from 'flarum/utils/classList';
import classList from 'flarum/common/utils/classList';
export default function tagIcon(tag, attrs = {}, settings = {}) {
const hasIcon = tag && tag.icon();

View File

@@ -1,5 +1,5 @@
import extract from 'flarum/utils/extract';
import Link from 'flarum/components/Link';
import extract from 'flarum/common/utils/extract';
import Link from 'flarum/common/components/Link';
import tagIcon from './tagIcon';
export default function tagLabel(tag, attrs = {}) {

View File

@@ -1,4 +1,4 @@
import extract from 'flarum/utils/extract';
import extract from 'flarum/common/utils/extract';
import tagLabel from './tagLabel';
import sortTags from '../utils/sortTags';

View File

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