mirror of
https://github.com/flarum/framework.git
synced 2024-11-29 04:33:47 +08:00
Repo maintenance (#30)
* Bump deps; add TS support; use Prettier * Format * Update js/package.json Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update lockfile Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
This commit is contained in:
parent
3e962c5e0f
commit
3e3fa6535d
6773
extensions/sticky/js/package-lock.json
generated
6773
extensions/sticky/js/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
|
@ -1,13 +1,21 @@
|
|||
{
|
||||
"private": true,
|
||||
"name": "@flarum/sticky",
|
||||
"prettier": "@flarum/prettier-config",
|
||||
"dependencies": {
|
||||
"flarum-webpack-config": "0.1.0-beta.10",
|
||||
"webpack": "^4.43.0",
|
||||
"webpack-cli": "^3.3.11"
|
||||
"flarum-webpack-config": "^1.0.0",
|
||||
"webpack": "^4.46.0",
|
||||
"webpack-cli": "^4.7.2"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "webpack --mode development --watch",
|
||||
"build": "webpack --mode production"
|
||||
"build": "webpack --mode production",
|
||||
"format": "prettier --write src",
|
||||
"format-check": "prettier --check src"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@flarum/prettier-config": "^1.0.0",
|
||||
"flarum-tsconfig": "^1.0.0",
|
||||
"prettier": "^2.3.2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
import app from 'flarum/app';
|
||||
|
||||
app.initializers.add('flarum-sticky', () => {
|
||||
app.extensionData
|
||||
.for('flarum-sticky')
|
||||
.registerPermission({
|
||||
app.extensionData.for('flarum-sticky').registerPermission(
|
||||
{
|
||||
icon: 'fas fa-thumbtack',
|
||||
label: app.translator.trans('flarum-sticky.admin.permissions.sticky_discussions_label'),
|
||||
permission: 'discussion.sticky'
|
||||
}, 'moderate', 95);
|
||||
permission: 'discussion.sticky',
|
||||
},
|
||||
'moderate',
|
||||
95
|
||||
);
|
||||
});
|
||||
|
|
|
@ -3,13 +3,17 @@ import Discussion from 'flarum/models/Discussion';
|
|||
import Badge from 'flarum/components/Badge';
|
||||
|
||||
export default function addStickyBadge() {
|
||||
extend(Discussion.prototype, 'badges', function(badges) {
|
||||
extend(Discussion.prototype, 'badges', function (badges) {
|
||||
if (this.isSticky()) {
|
||||
badges.add('sticky', Badge.component({
|
||||
type: 'sticky',
|
||||
label: app.translator.trans('flarum-sticky.forum.badge.sticky_tooltip'),
|
||||
icon: 'fas fa-thumbtack'
|
||||
}), 10);
|
||||
badges.add(
|
||||
'sticky',
|
||||
Badge.component({
|
||||
type: 'sticky',
|
||||
label: app.translator.trans('flarum-sticky.forum.badge.sticky_tooltip'),
|
||||
icon: 'fas fa-thumbtack',
|
||||
}),
|
||||
10
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -4,17 +4,27 @@ import DiscussionPage from 'flarum/components/DiscussionPage';
|
|||
import Button from 'flarum/components/Button';
|
||||
|
||||
export default function addStickyControl() {
|
||||
extend(DiscussionControls, 'moderationControls', function(items, discussion) {
|
||||
extend(DiscussionControls, 'moderationControls', function (items, discussion) {
|
||||
if (discussion.canSticky()) {
|
||||
items.add('sticky', Button.component({
|
||||
icon: 'fas fa-thumbtack',
|
||||
onclick: this.stickyAction.bind(discussion)
|
||||
}, app.translator.trans(discussion.isSticky() ? 'flarum-sticky.forum.discussion_controls.unsticky_button' : 'flarum-sticky.forum.discussion_controls.sticky_button')));
|
||||
items.add(
|
||||
'sticky',
|
||||
Button.component(
|
||||
{
|
||||
icon: 'fas fa-thumbtack',
|
||||
onclick: this.stickyAction.bind(discussion),
|
||||
},
|
||||
app.translator.trans(
|
||||
discussion.isSticky()
|
||||
? 'flarum-sticky.forum.discussion_controls.unsticky_button'
|
||||
: 'flarum-sticky.forum.discussion_controls.sticky_button'
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
DiscussionControls.stickyAction = function() {
|
||||
this.save({isSticky: !this.isSticky()}).then(() => {
|
||||
DiscussionControls.stickyAction = function () {
|
||||
this.save({ isSticky: !this.isSticky() }).then(() => {
|
||||
if (app.current.matches(DiscussionPage)) {
|
||||
app.current.get('stream').update();
|
||||
}
|
||||
|
|
|
@ -6,13 +6,13 @@ import IndexPage from 'flarum/components/IndexPage';
|
|||
import { truncate } from 'flarum/utils/string';
|
||||
|
||||
export default function addStickyControl() {
|
||||
extend(DiscussionListState.prototype, 'requestParams', function(params) {
|
||||
extend(DiscussionListState.prototype, 'requestParams', function (params) {
|
||||
if (app.current.matches(IndexPage) || app.current.matches(DiscussionPage)) {
|
||||
params.include.push('firstPost');
|
||||
}
|
||||
});
|
||||
|
||||
extend(DiscussionListItem.prototype, 'infoItems', function(items) {
|
||||
extend(DiscussionListItem.prototype, 'infoItems', function (items) {
|
||||
const discussion = this.attrs.discussion;
|
||||
|
||||
if (discussion.isSticky() && !this.attrs.params.q && !discussion.lastReadPostNumber()) {
|
||||
|
|
|
@ -19,4 +19,3 @@ app.initializers.add('flarum-sticky', () => {
|
|||
addStickyExcerpt();
|
||||
addStickyClass();
|
||||
});
|
||||
|
||||
|
|
14
extensions/sticky/js/tsconfig.json
Normal file
14
extensions/sticky/js/tsconfig.json
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
// Use Flarum's tsconfig as a starting point
|
||||
"extends": "flarum-tsconfig",
|
||||
// This will match all .ts, .tsx, .d.ts, .js, .jsx files
|
||||
"include": ["src/**/*"],
|
||||
"compilerOptions": {
|
||||
// This will output typings to `dist-typings`
|
||||
"declarationDir": "./dist-typings",
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"flarum/*": ["../vendor/flarum/core/js/dist-typings/*"]
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user