fix: 2.0 bugs (#4011)

This commit is contained in:
Sami Mazouz 2024-08-02 12:49:34 +01:00 committed by GitHub
parent 2b56129d70
commit 770f9370af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
40 changed files with 78 additions and 74 deletions

View File

@ -19,7 +19,7 @@
"@flarum/prettier-config": "^1.0.0",
"flarum-tsconfig": "^1.0.2",
"prettier": "^2.5.1",
"flarum-webpack-config": "^2.0.0",
"flarum-webpack-config": "^3.0.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.1",
"typescript": "^4.5.4",

View File

@ -5,7 +5,7 @@
"prettier": "@flarum/prettier-config",
"devDependencies": {
"prettier": "^2.5.1",
"flarum-webpack-config": "^2.0.0",
"flarum-webpack-config": "^3.0.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.1",
"@flarum/prettier-config": "^1.0.0"

View File

@ -8,7 +8,7 @@
},
"devDependencies": {
"prettier": "^2.5.1",
"flarum-webpack-config": "^2.0.0",
"flarum-webpack-config": "^3.0.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.1",
"@flarum/prettier-config": "^1.0.0"

View File

@ -10,7 +10,7 @@
"devDependencies": {
"@flarum/prettier-config": "^1.0.0",
"flarum-tsconfig": "^1.0.2",
"flarum-webpack-config": "^2.0.0",
"flarum-webpack-config": "^3.0.0",
"prettier": "^2.5.1",
"typescript": "^4.5.4",
"typescript-coverage-report": "^0.6.1",

View File

@ -6,7 +6,7 @@
"devDependencies": {
"@types/mithril": "^2.0.8",
"prettier": "^2.5.1",
"flarum-webpack-config": "^2.0.0",
"flarum-webpack-config": "^3.0.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.1",
"@flarum/prettier-config": "^1.0.0",

View File

@ -5,7 +5,7 @@
"prettier": "@flarum/prettier-config",
"devDependencies": {
"prettier": "^2.5.1",
"flarum-webpack-config": "^2.0.0",
"flarum-webpack-config": "^3.0.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.1",
"@flarum/prettier-config": "^1.0.0"

View File

@ -5,7 +5,7 @@
"prettier": "@flarum/prettier-config",
"devDependencies": {
"prettier": "^2.5.1",
"flarum-webpack-config": "^2.0.0",
"flarum-webpack-config": "^3.0.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.1",
"@flarum/prettier-config": "^1.0.0",

View File

@ -4,7 +4,7 @@
"version": "0.0.0",
"prettier": "@flarum/prettier-config",
"dependencies": {
"flarum-webpack-config": "^2.0.0",
"flarum-webpack-config": "^3.0.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.1"
},
@ -19,7 +19,7 @@
"@flarum/prettier-config": "^1.0.0",
"flarum-tsconfig": "^1.0.2",
"prettier": "^2.5.1",
"flarum-webpack-config": "^2.0.0",
"flarum-webpack-config": "^3.0.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.1"
}

View File

@ -5,7 +5,7 @@
"prettier": "@flarum/prettier-config",
"devDependencies": {
"prettier": "^2.5.1",
"flarum-webpack-config": "^2.0.0",
"flarum-webpack-config": "^3.0.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.1",
"@flarum/prettier-config": "^1.0.0"

View File

@ -5,7 +5,7 @@
"prettier": "@flarum/prettier-config",
"devDependencies": {
"prettier": "^2.5.1",
"flarum-webpack-config": "^2.0.0",
"flarum-webpack-config": "^3.0.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.1",
"@flarum/prettier-config": "^1.0.0"

View File

@ -2,7 +2,7 @@ import app from 'flarum/forum/app';
import FormModal from 'flarum/common/components/FormModal';
import Button from 'flarum/common/components/Button';
import Stream from 'flarum/common/utils/Stream';
import Form from '@flarum/core/src/common/components/Form';
import Form from 'flarum/common/components/Form';
export default class NicknameModal extends FormModal {
oninit(vnode) {

View File

@ -6,7 +6,7 @@
"devDependencies": {
"@flarum/prettier-config": "^1.0.0",
"flarum-tsconfig": "^1.0.2",
"flarum-webpack-config": "^2.0.0",
"flarum-webpack-config": "^3.0.0",
"prettier": "^2.5.1",
"typescript": "^4.5.4",
"typescript-coverage-report": "^0.6.1",

View File

@ -19,7 +19,7 @@
"@flarum/prettier-config": "^1.0.0",
"@types/pusher-js": "^5.1.0",
"flarum-tsconfig": "^1.0.2",
"flarum-webpack-config": "^2.0.0",
"flarum-webpack-config": "^3.0.0",
"prettier": "^2.5.1",
"typescript": "^4.5.4",
"typescript-coverage-report": "^0.6.1",

View File

@ -10,7 +10,7 @@
"@flarum/prettier-config": "^1.0.0",
"@types/mithril": "^2.0.11",
"flarum-tsconfig": "^1.0.2",
"flarum-webpack-config": "^2.0.0",
"flarum-webpack-config": "^3.0.0",
"prettier": "^2.7.1",
"typescript": "^4.7.4",
"typescript-coverage-report": "^0.6.4",

View File

@ -5,7 +5,7 @@
"prettier": "@flarum/prettier-config",
"devDependencies": {
"prettier": "^2.5.1",
"flarum-webpack-config": "^2.0.0",
"flarum-webpack-config": "^3.0.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.1",
"@flarum/prettier-config": "^1.0.0"

View File

@ -5,7 +5,7 @@
"prettier": "@flarum/prettier-config",
"devDependencies": {
"@flarum/prettier-config": "^1.0.0",
"flarum-webpack-config": "^2.0.0",
"flarum-webpack-config": "^3.0.0",
"prettier": "^2.7.1",
"webpack": "^5.76.0",
"webpack-cli": "^4.10.0",

View File

@ -13,7 +13,7 @@
"devDependencies": {
"@flarum/prettier-config": "^1.0.0",
"flarum-tsconfig": "^1.0.0",
"flarum-webpack-config": "^2.0.0",
"flarum-webpack-config": "^3.0.0",
"prettier": "^2.5.1",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.1"

View File

@ -4,10 +4,10 @@ import Button from 'flarum/common/components/Button';
import Stream from 'flarum/common/utils/Stream';
import withAttr from 'flarum/common/utils/withAttr';
import ItemList from 'flarum/common/utils/ItemList';
import Form from 'flarum/common/components/Form';
import FieldSet from 'flarum/common/components/FieldSet';
import { getPermanentSuspensionDate } from '../helpers/suspensionHelper';
import Form from '@flarum/core/src/common/components/Form';
import FieldSet from '@flarum/core/src/common/components/FieldSet';
export default class SuspendUserModal extends FormModal {
oninit(vnode) {

View File

@ -2,8 +2,8 @@ import app from 'flarum/forum/app';
import Modal from 'flarum/common/components/Modal';
import Button from 'flarum/common/components/Button';
import fullTime from 'flarum/common/helpers/fullTime';
import Form from 'flarum/common/components/Form';
import { isPermanentSuspensionDate, localStorageKey } from '../helpers/suspensionHelper';
import Form from '@flarum/core/src/common/components/Form';
export default class SuspensionInfoModal extends Modal {
oninit(vnode) {

View File

@ -20,7 +20,7 @@
},
"devDependencies": {
"flarum-tsconfig": "^1.0.2",
"flarum-webpack-config": "^2.0.0",
"flarum-webpack-config": "^3.0.0",
"prettier": "^2.7.1",
"typescript": "^4.5.4",
"typescript-coverage-report": "^0.6.1",

View File

@ -6,11 +6,12 @@ import Button from 'flarum/common/components/Button';
import LoadingIndicator from 'flarum/common/components/LoadingIndicator';
import withAttr from 'flarum/common/utils/withAttr';
import Form from 'flarum/common/components/Form';
import FormSectionGroup from 'flarum/admin/components/FormSectionGroup';
import FormSection from 'flarum/admin/components/FormSection';
import EditTagModal from './EditTagModal';
import tagIcon from '../../common/helpers/tagIcon';
import sortTags from '../../common/utils/sortTags';
import FormSectionGroup, { FormSection } from '@flarum/core/src/admin/components/FormSectionGroup';
function tagItem(tag) {
return (

View File

@ -37,7 +37,7 @@ class DiscussionResourceFields
Schema\Relationship\ToMany::make('tags')
->includable()
->writable()
->required(fn (Context $context, Discussion $discussion) => ! $context->getActor()->can('bypassTagCounts', $discussion))
->required(fn (Context $context, Discussion $discussion) => $context->creating() && ! $context->getActor()->can('bypassTagCounts', $discussion))
->set(function (Discussion $discussion, array $newTags, Context $context) {
$actor = $context->getActor();

View File

@ -34,7 +34,7 @@
"cross-env": "^7.0.3",
"expose-loader": "^3.1.0",
"flarum-tsconfig": "^1.0.2",
"flarum-webpack-config": "^2.0.0",
"flarum-webpack-config": "^3.0.0",
"prettier": "^2.5.1",
"typescript": "^4.5.4",
"typescript-coverage-report": "^0.6.1",

View File

@ -32,7 +32,7 @@ export type Extension = {
extra: {
'flarum-extension': {
title: string;
'database-support': undefined | string[];
'database-support'?: string[];
};
};
require?: Record<string, string>;

View File

@ -4,7 +4,8 @@ import type { IPageAttrs } from '../../common/components/Page';
import type Mithril from 'mithril';
import Form from '../../common/components/Form';
import extractText from '../../common/utils/extractText';
import FormSectionGroup, { FormSection } from './FormSectionGroup';
import FormSectionGroup from './FormSectionGroup';
import FormSection from './FormSection';
import ItemList from '../../common/utils/ItemList';
import InfoTile from '../../common/components/InfoTile';
import { MaintenanceMode } from '../../common/Application';

View File

@ -0,0 +1,21 @@
import Component from '../../common/Component';
import type { ComponentAttrs } from '../../common/Component';
import Mithril from 'mithril';
import classList from '../../common/utils/classList';
export interface IFormSectionAttrs extends ComponentAttrs {
label: any;
}
export default class FormSection<CustomAttrs extends IFormSectionAttrs = IFormSectionAttrs> extends Component<CustomAttrs> {
view(vnode: Mithril.Vnode<CustomAttrs, this>) {
const { className, ...attrs } = this.attrs;
return (
<div className={classList('FormSection', className)} {...attrs}>
<label>{this.attrs.label}</label>
<div className="FormSection-body">{vnode.children}</div>
</div>
);
}
}

View File

@ -16,20 +16,3 @@ export default class FormSectionGroup<CustomAttrs extends IFormSectionGroupAttrs
);
}
}
export interface IFormSectionAttrs extends ComponentAttrs {
label: any;
}
export class FormSection<CustomAttrs extends IFormSectionAttrs = IFormSectionAttrs> extends Component<CustomAttrs> {
view(vnode: Mithril.Vnode<CustomAttrs, this>) {
const { className, ...attrs } = this.attrs;
return (
<div className={classList('FormSection', className)} {...attrs}>
<label>{this.attrs.label}</label>
<div className="FormSection-body">{vnode.children}</div>
</div>
);
}
}

View File

@ -367,7 +367,7 @@ export default abstract class Model {
*/
protected static getIdentifier(model: Model): ModelIdentifier;
protected static getIdentifier(model?: Model): ModelIdentifier | null {
if (!model || !('id' in model.data)) return null;
if (!model || !model.data || !('id' in model.data)) return null;
return {
type: model.data.type,

View File

@ -203,7 +203,7 @@ export default class FormGroup<CustomAttrs extends IFormGroupAttrs = IFormGroupA
settingElement = <UploadImageButton value={stream} {...otherAttrs} />;
} else if (customFieldComponents.has(type)) {
return customFieldComponents.get(type)(this.attrs);
return customFieldComponents.get(type)({ ...this.attrs, bidi: this.attrs.stream });
} else {
attrs.className = classList('FormControl', attrs.className);

View File

@ -8,6 +8,7 @@ import Stream from '../../common/utils/Stream';
import type Mithril from 'mithril';
import RequestError from '../../common/utils/RequestError';
import type { LoginParams } from '../../common/Session';
import ForgotPasswordModal from './ForgotPasswordModal';
export interface ILoginModalAttrs extends IFormModalAttrs {
identification?: string;
@ -139,7 +140,7 @@ export default class LogInModal<CustomAttrs extends ILoginModalAttrs = ILoginMod
const email = this.identification();
const attrs = email.includes('@') ? { email } : undefined;
app.modal.show(() => import('./ForgotPasswordModal'), attrs);
app.modal.show(ForgotPasswordModal, attrs);
}
/**

View File

@ -14,7 +14,7 @@ import listItems from '../../common/helpers/listItems';
* The `UsersSearchSource` finds and displays user search results in the search
* dropdown.
*/
export default class UsersSearchResults implements SearchSource {
export default class UsersSearchSource implements SearchSource {
protected results = new Map<string, User[]>();
public resource: string = 'users';

View File

@ -70,6 +70,8 @@ class ComposerState {
}
this.body = body;
return componentClass;
}
/**

View File

@ -11,7 +11,7 @@
cursor: pointer;
line-height: 1;
.FormSection & {
.FormSection &, &.FormControl {
width: 100%;
}
}

View File

@ -34,8 +34,8 @@
.UserCard {
position: absolute;
top: 15px;
left: 16px;
top: 0;
left: 0;
z-index: var(--zindex-dropdown);
transition: opacity 0.2s, transform 0.2s;
transform: scale(0.95);
@ -454,7 +454,6 @@
.Post-avatar {
.Avatar--size(32px);
display: block;
}
.Post-main {

View File

@ -9,7 +9,7 @@
"prettier": "@flarum/prettier-config",
"dependencies": {
"@types/jest": "^29.2.2",
"flarum-webpack-config": "^2.0.1",
"flarum-webpack-config": "^3.0.0",
"flat": "^5.0.2",
"jest": "^29.3.1",
"jest-environment-jsdom": "^29.3.1",

View File

@ -1,7 +1,7 @@
{
"name": "flarum-webpack-config",
"type": "module",
"version": "2.0.2",
"version": "3.0.0",
"description": "Webpack config for Flarum JS and TS transpilation.",
"main": "src/index.cjs",
"author": "Flarum Team",

View File

@ -3,6 +3,8 @@ const extensionId = require("./extensionId.cjs");
const {Compilation} = require("webpack");
class RegisterAsyncChunksPlugin {
static registry = {};
apply(compiler) {
compiler.hooks.thisCompilation.tap("RegisterAsyncChunksPlugin", (compilation) => {
let alreadyOptimized = false;
@ -80,9 +82,13 @@ class RegisterAsyncChunksPlugin {
if (concatenatedModule?.rootModule) {
// This is a chunk with many modules, we need to register all of them.
concatenatedModule.modules?.forEach((module) => {
if (! module.resource.includes(`${path.sep}src${path.sep}`)) {
return;
}
// The path right after the src/ directory, without the extension.
const regPathSep = `\\${path.sep}`;
const urlPath = module.resource.replace(`/.*${regPathSep}src(.*)${regPathSep}\..*/`, '$1');
const urlPath = module.resource.replace(new RegExp(`.*${regPathSep}src${regPathSep}([^.]+)\..+`), '$1');
if (! registrableModulesUrlPaths.has(urlPath)) {
registrableModulesUrlPaths.set(urlPath, [relevantChunk.id, moduleId, namespace, urlPath]);
@ -93,9 +99,11 @@ class RegisterAsyncChunksPlugin {
registrableModulesUrlPaths.forEach(([chunkId, moduleId, namespace, urlPath]) => {
chunkModuleMemory[sourceChunkId] = chunkModuleMemory[sourceChunkId] || [];
if (! chunkModuleMemory[sourceChunkId].includes(urlPath)) {
if (! chunkModuleMemory[sourceChunkId].includes(urlPath) && ! RegisterAsyncChunksPlugin.registry[`${chunkId}:${moduleId}:${namespace}`]?.includes(urlPath)) {
reg.push(`flarum.reg.addChunkModule('${chunkId}', '${moduleId}', '${namespace}', '${urlPath}');`);
chunkModuleMemory[sourceChunkId].push(urlPath);
RegisterAsyncChunksPlugin.registry[`${chunkId}:${moduleId}:${namespace}`] ||= [];
RegisterAsyncChunksPlugin.registry[`${chunkId}:${moduleId}:${namespace}`].push(urlPath);
}
});

View File

@ -52,10 +52,6 @@ conditionalTags:
phpstan.rules.rule: %noUnnecessaryCollectionCall%
Larastan\Larastan\Rules\OctaneCompatibilityRule:
phpstan.rules.rule: %checkOctaneCompatibility%
Larastan\Larastan\Rules\ModelProperties\ModelPropertyRule:
phpstan.rules.rule: %checkModelProperties%
Larastan\Larastan\Rules\ModelProperties\ModelPropertyStaticCallRule:
phpstan.rules.rule: %checkModelProperties%
Larastan\Larastan\Rules\UnusedViewsRule:
phpstan.rules.rule: %checkUnusedViews%
Larastan\Larastan\Rules\ModelAppendsRule:
@ -400,15 +396,9 @@ services:
onlyMethods: %noUnnecessaryCollectionCallOnly%
excludeMethods: %noUnnecessaryCollectionCallExcept%
-
class: Larastan\Larastan\Rules\ModelProperties\ModelPropertyRule
-
class: Larastan\Larastan\Rules\ModelAppendsRule
-
class: Larastan\Larastan\Rules\ModelProperties\ModelPropertyStaticCallRule
-
class: Larastan\Larastan\Types\GenericEloquentBuilderTypeNodeResolverExtension
tags:
@ -450,9 +440,6 @@ services:
-
class: Larastan\Larastan\Properties\ModelPropertyHelper
-
class: Larastan\Larastan\Rules\ModelProperties\ModelPropertiesRuleHelper
-
class: Larastan\Larastan\Rules\ModelRuleHelper

View File

@ -1,5 +1,11 @@
parameters:
reportUnmatchedIgnoredErrors: false
ignoreErrors:
-
identifier: missingType.iterableValue
-
identifier: missingType.generics
# Remove this group below with larastan 2.0 (i.e Flarum 2.0)
- message: "#Relation '[A-z_-]+' is not found in [A-z\_]+ model.#"
reportUnmatched: false

View File

@ -36,8 +36,3 @@ parameters:
excludePaths:
- *.blade.php
databaseMigrationsPath: ['framework/core/migrations']
ignoreErrors:
-
identifier: missingType.iterableValue
-
identifier: missingType.generics