mirror of
https://github.com/flarum/core.git
synced 2025-08-29 02:50:57 +02:00
Compare commits
5 Commits
sm/fulltex
...
sm/qa-flag
Author | SHA1 | Date | |
---|---|---|---|
|
42cba58308 | ||
|
96302f67a3 | ||
|
3f864bafc8 | ||
|
3af0481f30 | ||
|
1761660c98 |
2
extensions/flags/js/dist/forum.js
generated
vendored
2
extensions/flags/js/dist/forum.js
generated
vendored
File diff suppressed because one or more lines are too long
2
extensions/flags/js/dist/forum.js.map
generated
vendored
2
extensions/flags/js/dist/forum.js.map
generated
vendored
File diff suppressed because one or more lines are too long
9
extensions/flags/js/src/@types/shims.d.ts
vendored
9
extensions/flags/js/src/@types/shims.d.ts
vendored
@@ -1,6 +1,7 @@
|
||||
import Flag from '../forum/models/Flag';
|
||||
import FlagListState from '../forum/states/FlagListState';
|
||||
import Mithril from 'mithril';
|
||||
import type Flag from '../forum/models/Flag';
|
||||
import type FlagListState from '../forum/states/FlagListState';
|
||||
import type Mithril from 'mithril';
|
||||
import type ItemList from 'flarum/common/utils/ItemList';
|
||||
|
||||
declare module 'flarum/common/models/Post' {
|
||||
export default interface Post {
|
||||
@@ -17,6 +18,8 @@ declare module 'flarum/forum/ForumApplication' {
|
||||
|
||||
declare module 'flarum/forum/components/Post' {
|
||||
export default interface Post {
|
||||
dismissFlag: (body: any) => Promise<any>;
|
||||
flagActionItems: () => ItemList<Mithril.Children>;
|
||||
flagReason: (flag: Flag) => Mithril.Children;
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,14 @@
|
||||
import { extend } from 'flarum/common/extend';
|
||||
import app from 'flarum/forum/app';
|
||||
import Post from 'flarum/forum/components/Post';
|
||||
import CommentPost from 'flarum/forum/components/CommentPost';
|
||||
import Button from 'flarum/common/components/Button';
|
||||
import ItemList from 'flarum/common/utils/ItemList';
|
||||
import PostControls from 'flarum/forum/utils/PostControls';
|
||||
import humanTime from 'flarum/common/utils/humanTime';
|
||||
import isObject from 'flarum/common/utils/isObject';
|
||||
import type Flag from './models/Flag';
|
||||
import type Mithril from 'mithril';
|
||||
|
||||
export default function () {
|
||||
extend(Post.prototype, 'elementAttrs', function (attrs) {
|
||||
@@ -21,7 +25,7 @@ export default function () {
|
||||
this.subtree.invalidate();
|
||||
|
||||
if (app.flags.cache) {
|
||||
app.flags.cache.some((flag, i) => {
|
||||
app.flags.cache.some((flag: Flag, i: number) => {
|
||||
if (flag.post() === post) {
|
||||
app.flags.cache.splice(i, 1);
|
||||
|
||||
@@ -39,6 +43,8 @@ export default function () {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -50,16 +56,17 @@ export default function () {
|
||||
};
|
||||
|
||||
Post.prototype.flagActionItems = function () {
|
||||
const items = new ItemList();
|
||||
const items = new ItemList<Mithril.Children>();
|
||||
|
||||
const controls = PostControls.destructiveControls(this.attrs.post);
|
||||
const controls = PostControls.destructiveControls(this.attrs.post, this);
|
||||
|
||||
Object.keys(controls.items).forEach((k) => {
|
||||
const attrs = controls.get(k).attrs;
|
||||
const item = controls.get(k);
|
||||
const attrs = isObject(item) && 'attrs' in item ? item.attrs : {};
|
||||
|
||||
attrs.className = 'Button';
|
||||
|
||||
extend(attrs, 'onclick', () => this.dismissFlag());
|
||||
extend(attrs, 'onclick', () => this.dismissFlag({}));
|
||||
});
|
||||
|
||||
items.add('controls', <div className="ButtonGroup">{controls.toArray()}</div>);
|
||||
@@ -81,12 +88,16 @@ export default function () {
|
||||
|
||||
if (!flags.length) return;
|
||||
|
||||
if (post.isHidden()) this.revealContent = true;
|
||||
if (post.isHidden() && this instanceof CommentPost) {
|
||||
this.revealContent = true;
|
||||
}
|
||||
|
||||
if (!isObject(vdom) || !('unshift' in vdom)) return;
|
||||
|
||||
vdom.unshift(
|
||||
<div className="Post-flagged">
|
||||
<div className="Post-flagged-flags">
|
||||
{flags.map((flag) => (
|
||||
{flags.map((flag: Flag) => (
|
||||
<div className="Post-flagged-flag">{this.flagReason(flag)}</div>
|
||||
))}
|
||||
</div>
|
||||
@@ -111,5 +122,7 @@ export default function () {
|
||||
detail ? <span className="Post-flagged-detail">{detail}</span> : '',
|
||||
];
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
}
|
@@ -1,4 +1,6 @@
|
||||
export default class FlagListState {
|
||||
index = 0;
|
||||
|
||||
constructor(app) {
|
||||
this.app = app;
|
||||
|
||||
|
@@ -18,6 +18,7 @@ core:
|
||||
custom_footer_text: => core.ref.custom_footer_text
|
||||
custom_header_heading: Custom Header
|
||||
custom_header_text: => core.ref.custom_header_text
|
||||
custom_styles_cannot_use_less_features: "The @import and data-uri features are not allowed in custom LESS."
|
||||
custom_styles_heading: Custom Styles
|
||||
custom_styles_text: Customize your forum's appearance by adding your own Less/CSS code to be applied on top of Flarum's default styles.
|
||||
dark_mode_label: Dark Mode
|
||||
|
@@ -21,6 +21,7 @@ use Illuminate\Filesystem\FilesystemAdapter;
|
||||
use League\Flysystem\Adapter\NullAdapter;
|
||||
use League\Flysystem\Filesystem;
|
||||
use Less_Exception_Parser;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
@@ -61,6 +62,15 @@ class ValidateCustomLess
|
||||
return;
|
||||
}
|
||||
|
||||
// Restrict what features can be used in custom LESS
|
||||
if (isset($event->settings['custom_less']) && preg_match('/@import|data-uri\s*\(/i', $event->settings['custom_less'])) {
|
||||
$translator = $this->container->make(TranslatorInterface::class);
|
||||
|
||||
throw new ValidationException([
|
||||
'custom_less' => $translator->trans('core.admin.appearance.custom_styles_cannot_use_less_features')
|
||||
]);
|
||||
}
|
||||
|
||||
// We haven't saved the settings yet, but we want to trial a full
|
||||
// recompile of the CSS to see if this custom LESS will break
|
||||
// anything. In order to do that, we will temporarily override the
|
||||
|
@@ -74,43 +74,43 @@ class GroupSearchTest extends TestCase
|
||||
]);
|
||||
|
||||
$response = $this->createRequest(['admin'], 2);
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents());
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertCount(1, $responseBodyContents->data, json_encode($responseBodyContents));
|
||||
$this->assertCount(1, $responseBodyContents->included, json_encode($responseBodyContents));
|
||||
$this->assertEquals(1, $responseBodyContents->included[0]->id);
|
||||
$this->assertCount(1, $responseBodyContents['data'], json_encode($responseBodyContents));
|
||||
$this->assertCount(1, $responseBodyContents['included'], json_encode($responseBodyContents));
|
||||
$this->assertEquals(1, $responseBodyContents['included'][0]['id']);
|
||||
|
||||
$response = $this->createRequest(['mod'], 2);
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents());
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertCount(0, $responseBodyContents->data, json_encode($responseBodyContents));
|
||||
$this->assertObjectNotHasAttribute('included', $responseBodyContents, json_encode($responseBodyContents));
|
||||
$this->assertCount(0, $responseBodyContents['data'], json_encode($responseBodyContents));
|
||||
$this->assertArrayNotHasKey('included', $responseBodyContents, json_encode($responseBodyContents));
|
||||
|
||||
$response = $this->createRequest(['admins'], 2);
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents());
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertCount(1, $responseBodyContents->data, json_encode($responseBodyContents));
|
||||
$this->assertCount(1, $responseBodyContents->included, json_encode($responseBodyContents));
|
||||
$this->assertEquals(1, $responseBodyContents->included[0]->id);
|
||||
$this->assertCount(1, $responseBodyContents['data'], json_encode($responseBodyContents));
|
||||
$this->assertCount(1, $responseBodyContents['included'], json_encode($responseBodyContents));
|
||||
$this->assertEquals(1, $responseBodyContents['included'][0]['id']);
|
||||
|
||||
$response = $this->createRequest(['mods'], 2);
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents());
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertCount(0, $responseBodyContents->data, json_encode($responseBodyContents));
|
||||
$this->assertObjectNotHasAttribute('included', $responseBodyContents, json_encode($responseBodyContents));
|
||||
$this->assertCount(0, $responseBodyContents['data'], json_encode($responseBodyContents));
|
||||
$this->assertArrayNotHasKey('included', $responseBodyContents, json_encode($responseBodyContents));
|
||||
|
||||
$response = $this->createRequest(['1'], 2);
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents());
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertCount(1, $responseBodyContents->data, json_encode($responseBodyContents));
|
||||
$this->assertCount(1, $responseBodyContents->included, json_encode($responseBodyContents));
|
||||
$this->assertEquals(1, $responseBodyContents->included[0]->id);
|
||||
$this->assertCount(1, $responseBodyContents['data'], json_encode($responseBodyContents));
|
||||
$this->assertCount(1, $responseBodyContents['included'], json_encode($responseBodyContents));
|
||||
$this->assertEquals(1, $responseBodyContents['included'][0]['id']);
|
||||
|
||||
$response = $this->createRequest(['4'], 2);
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents());
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertCount(0, $responseBodyContents->data, json_encode($responseBodyContents));
|
||||
$this->assertObjectNotHasAttribute('included', $responseBodyContents, json_encode($responseBodyContents));
|
||||
$this->assertCount(0, $responseBodyContents['data'], json_encode($responseBodyContents));
|
||||
$this->assertArrayNotHasKey('included', $responseBodyContents, json_encode($responseBodyContents));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,10 +126,10 @@ class GroupSearchTest extends TestCase
|
||||
|
||||
$this->createHiddenUser();
|
||||
$response = $this->createRequest(['99'], 2);
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents());
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertCount(0, $responseBodyContents->data, json_encode($responseBodyContents));
|
||||
$this->assertObjectNotHasAttribute('included', $responseBodyContents, json_encode($responseBodyContents));
|
||||
$this->assertCount(0, $responseBodyContents['data'], json_encode($responseBodyContents));
|
||||
$this->assertArrayNotHasKey('included', $responseBodyContents, json_encode($responseBodyContents));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,13 +144,13 @@ class GroupSearchTest extends TestCase
|
||||
]);
|
||||
$this->createMultipleUsersAndGroups();
|
||||
$response = $this->createRequest(['1', '4', '5', '6', '99'], 2);
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents());
|
||||
$this->assertCount(4, $responseBodyContents->data, json_encode($responseBodyContents));
|
||||
$this->assertCount(4, $responseBodyContents->included, json_encode($responseBodyContents));
|
||||
$this->assertEquals(1, $responseBodyContents->included[0]->id);
|
||||
$this->assertEquals(4, $responseBodyContents->included[1]->id);
|
||||
$this->assertEquals(5, $responseBodyContents->included[2]->id);
|
||||
$this->assertEquals(6, $responseBodyContents->included[3]->id);
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents(), true);
|
||||
$this->assertCount(4, $responseBodyContents['data'], json_encode($responseBodyContents));
|
||||
$this->assertCount(4, $responseBodyContents['included'], json_encode($responseBodyContents));
|
||||
$this->assertEquals(1, $responseBodyContents['included'][0]['id']);
|
||||
$this->assertEquals(4, $responseBodyContents['included'][1]['id']);
|
||||
$this->assertEquals(5, $responseBodyContents['included'][2]['id']);
|
||||
$this->assertEquals(6, $responseBodyContents['included'][3]['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,43 +159,43 @@ class GroupSearchTest extends TestCase
|
||||
public function admin_gets_correct_results_group()
|
||||
{
|
||||
$response = $this->createRequest(['admin'], 1);
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents());
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertCount(1, $responseBodyContents->data, json_encode($responseBodyContents));
|
||||
$this->assertCount(1, $responseBodyContents->included, json_encode($responseBodyContents));
|
||||
$this->assertEquals(1, $responseBodyContents->included[0]->id);
|
||||
$this->assertCount(1, $responseBodyContents['data'], json_encode($responseBodyContents));
|
||||
$this->assertCount(1, $responseBodyContents['included'], json_encode($responseBodyContents));
|
||||
$this->assertEquals(1, $responseBodyContents['included'][0]['id']);
|
||||
|
||||
$response = $this->createRequest(['mod'], 1);
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents());
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertCount(0, $responseBodyContents->data, json_encode($responseBodyContents));
|
||||
$this->assertObjectNotHasAttribute('included', $responseBodyContents, json_encode($responseBodyContents));
|
||||
$this->assertCount(0, $responseBodyContents['data'], json_encode($responseBodyContents));
|
||||
$this->assertArrayNotHasKey('included', $responseBodyContents, json_encode($responseBodyContents));
|
||||
|
||||
$response = $this->createRequest(['admins'], 1);
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents());
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertCount(1, $responseBodyContents->data, json_encode($responseBodyContents));
|
||||
$this->assertCount(1, $responseBodyContents->included, json_encode($responseBodyContents));
|
||||
$this->assertEquals(1, $responseBodyContents->included[0]->id);
|
||||
$this->assertCount(1, $responseBodyContents['data'], json_encode($responseBodyContents));
|
||||
$this->assertCount(1, $responseBodyContents['included'], json_encode($responseBodyContents));
|
||||
$this->assertEquals(1, $responseBodyContents['included'][0]['id']);
|
||||
|
||||
$response = $this->createRequest(['mods'], 1);
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents());
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertCount(0, $responseBodyContents->data, json_encode($responseBodyContents));
|
||||
$this->assertObjectNotHasAttribute('included', $responseBodyContents, json_encode($responseBodyContents));
|
||||
$this->assertCount(0, $responseBodyContents['data'], json_encode($responseBodyContents));
|
||||
$this->assertArrayNotHasKey('included', $responseBodyContents, json_encode($responseBodyContents));
|
||||
|
||||
$response = $this->createRequest(['1'], 1);
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents());
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertCount(1, $responseBodyContents->data, json_encode($responseBodyContents));
|
||||
$this->assertCount(1, $responseBodyContents->included, json_encode($responseBodyContents));
|
||||
$this->assertEquals(1, $responseBodyContents->included[0]->id);
|
||||
$this->assertCount(1, $responseBodyContents['data'], json_encode($responseBodyContents));
|
||||
$this->assertCount(1, $responseBodyContents['included'], json_encode($responseBodyContents));
|
||||
$this->assertEquals(1, $responseBodyContents['included'][0]['id']);
|
||||
|
||||
$response = $this->createRequest(['4'], 1);
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents());
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertCount(0, $responseBodyContents->data, json_encode($responseBodyContents));
|
||||
$this->assertObjectNotHasAttribute('included', $responseBodyContents, json_encode($responseBodyContents));
|
||||
$this->assertCount(0, $responseBodyContents['data'], json_encode($responseBodyContents));
|
||||
$this->assertArrayNotHasKey('included', $responseBodyContents, json_encode($responseBodyContents));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,11 +205,11 @@ class GroupSearchTest extends TestCase
|
||||
{
|
||||
$this->createHiddenUser();
|
||||
$response = $this->createRequest(['99'], 1);
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents());
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertCount(1, $responseBodyContents->data, json_encode($responseBodyContents));
|
||||
$this->assertCount(1, $responseBodyContents->included, json_encode($responseBodyContents));
|
||||
$this->assertEquals(99, $responseBodyContents->included[0]->id);
|
||||
$this->assertCount(1, $responseBodyContents['data'], json_encode($responseBodyContents));
|
||||
$this->assertCount(1, $responseBodyContents['included'], json_encode($responseBodyContents));
|
||||
$this->assertEquals(99, $responseBodyContents['included'][0]['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -220,14 +220,14 @@ class GroupSearchTest extends TestCase
|
||||
$this->createMultipleUsersAndGroups();
|
||||
$this->createHiddenUser();
|
||||
$response = $this->createRequest(['1', '4', '5', '6', '99'], 1);
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents());
|
||||
$this->assertCount(5, $responseBodyContents->data, json_encode($responseBodyContents));
|
||||
$this->assertCount(5, $responseBodyContents->included, json_encode($responseBodyContents));
|
||||
$this->assertEquals(1, $responseBodyContents->included[0]->id);
|
||||
$this->assertEquals(99, $responseBodyContents->included[1]->id);
|
||||
$this->assertEquals(4, $responseBodyContents->included[2]->id);
|
||||
$this->assertEquals(5, $responseBodyContents->included[3]->id);
|
||||
$this->assertEquals(6, $responseBodyContents->included[4]->id);
|
||||
$responseBodyContents = json_decode($response->getBody()->getContents(), true);
|
||||
$this->assertCount(5, $responseBodyContents['data'], json_encode($responseBodyContents));
|
||||
$this->assertCount(5, $responseBodyContents['included'], json_encode($responseBodyContents));
|
||||
$this->assertEquals(1, $responseBodyContents['included'][0]['id']);
|
||||
$this->assertEquals(99, $responseBodyContents['included'][1]['id']);
|
||||
$this->assertEquals(4, $responseBodyContents['included'][2]['id']);
|
||||
$this->assertEquals(5, $responseBodyContents['included'][3]['id']);
|
||||
$this->assertEquals(6, $responseBodyContents['included'][4]['id']);
|
||||
}
|
||||
|
||||
private function createRequest(array $group, int $userId = null)
|
||||
|
Reference in New Issue
Block a user