mirror of
https://github.com/flarum/core.git
synced 2025-08-04 23:47:32 +02:00
Update for composer branch
This commit is contained in:
4
extensions/lock/js/.gitignore
vendored
4
extensions/lock/js/.gitignore
vendored
@@ -1,4 +0,0 @@
|
||||
bower_components
|
||||
node_modules
|
||||
mithril.js
|
||||
dist
|
@@ -2,6 +2,6 @@ var gulp = require('flarum-gulp');
|
||||
|
||||
gulp({
|
||||
modules: {
|
||||
'lock': 'src/**/*.js'
|
||||
'flarum/lock': 'src/**/*.js'
|
||||
}
|
||||
});
|
||||
|
26
extensions/lock/js/admin/dist/extension.js
vendored
Normal file
26
extensions/lock/js/admin/dist/extension.js
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
System.register('flarum/lock/main', ['flarum/extend', 'flarum/app', 'flarum/components/PermissionGrid'], function (_export) {
|
||||
'use strict';
|
||||
|
||||
var extend, app, PermissionGrid;
|
||||
return {
|
||||
setters: [function (_flarumExtend) {
|
||||
extend = _flarumExtend.extend;
|
||||
}, function (_flarumApp) {
|
||||
app = _flarumApp['default'];
|
||||
}, function (_flarumComponentsPermissionGrid) {
|
||||
PermissionGrid = _flarumComponentsPermissionGrid['default'];
|
||||
}],
|
||||
execute: function () {
|
||||
|
||||
app.initializers.add('lock', function () {
|
||||
extend(PermissionGrid.prototype, 'moderateItems', function (items) {
|
||||
items.add('lock', {
|
||||
icon: 'lock',
|
||||
label: 'Lock discussions',
|
||||
permission: 'discussion.lock'
|
||||
}, 95);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
@@ -2,6 +2,6 @@ var gulp = require('flarum-gulp');
|
||||
|
||||
gulp({
|
||||
modules: {
|
||||
'lock': 'src/**/*.js'
|
||||
'flarum/lock': 'src/**/*.js'
|
||||
}
|
||||
});
|
||||
|
192
extensions/lock/js/forum/dist/extension.js
vendored
Normal file
192
extensions/lock/js/forum/dist/extension.js
vendored
Normal file
@@ -0,0 +1,192 @@
|
||||
System.register('flarum/lock/addLockBadge', ['flarum/extend', 'flarum/models/Discussion', 'flarum/components/Badge'], function (_export) {
|
||||
'use strict';
|
||||
|
||||
var extend, Discussion, Badge;
|
||||
|
||||
_export('default', addLockBadge);
|
||||
|
||||
function addLockBadge() {
|
||||
extend(Discussion.prototype, 'badges', function (badges) {
|
||||
if (this.isLocked()) {
|
||||
badges.add('locked', Badge.component({
|
||||
type: 'locked',
|
||||
label: app.trans('flarum-lock.forum.locked'),
|
||||
icon: 'lock'
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
setters: [function (_flarumExtend) {
|
||||
extend = _flarumExtend.extend;
|
||||
}, function (_flarumModelsDiscussion) {
|
||||
Discussion = _flarumModelsDiscussion['default'];
|
||||
}, function (_flarumComponentsBadge) {
|
||||
Badge = _flarumComponentsBadge['default'];
|
||||
}],
|
||||
execute: function () {}
|
||||
};
|
||||
});;System.register('flarum/lock/addLockControl', ['flarum/extend', 'flarum/utils/DiscussionControls', 'flarum/components/DiscussionPage', 'flarum/components/Button'], function (_export) {
|
||||
'use strict';
|
||||
|
||||
var extend, DiscussionControls, DiscussionPage, Button;
|
||||
|
||||
_export('default', addLockControl);
|
||||
|
||||
function addLockControl() {
|
||||
extend(DiscussionControls, 'moderationControls', function (items, discussion) {
|
||||
if (discussion.canLock()) {
|
||||
items.add('lock', Button.component({
|
||||
children: app.trans(discussion.isLocked() ? 'flarum-lock.forum.unlock' : 'flarum-lock.forum.lock'),
|
||||
icon: 'lock',
|
||||
onclick: this.lockAction.bind(discussion)
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
||||
DiscussionControls.lockAction = function () {
|
||||
this.save({ isLocked: !this.isLocked() }).then(function () {
|
||||
if (app.current instanceof DiscussionPage) {
|
||||
app.current.stream.update();
|
||||
}
|
||||
|
||||
m.redraw();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
setters: [function (_flarumExtend) {
|
||||
extend = _flarumExtend.extend;
|
||||
}, function (_flarumUtilsDiscussionControls) {
|
||||
DiscussionControls = _flarumUtilsDiscussionControls['default'];
|
||||
}, function (_flarumComponentsDiscussionPage) {
|
||||
DiscussionPage = _flarumComponentsDiscussionPage['default'];
|
||||
}, function (_flarumComponentsButton) {
|
||||
Button = _flarumComponentsButton['default'];
|
||||
}],
|
||||
execute: function () {}
|
||||
};
|
||||
});;System.register('flarum/lock/main', ['flarum/extend', 'flarum/app', 'flarum/Model', 'flarum/models/Discussion', 'flarum/components/NotificationGrid', 'flarum/lock/components/DiscussionLockedPost', 'flarum/lock/components/DiscussionLockedNotification', 'flarum/lock/addLockBadge', 'flarum/lock/addLockControl'], function (_export) {
|
||||
'use strict';
|
||||
|
||||
var extend, app, Model, Discussion, NotificationGrid, DiscussionLockedPost, DiscussionLockedNotification, addLockBadge, addLockControl;
|
||||
return {
|
||||
setters: [function (_flarumExtend) {
|
||||
extend = _flarumExtend.extend;
|
||||
}, function (_flarumApp) {
|
||||
app = _flarumApp['default'];
|
||||
}, function (_flarumModel) {
|
||||
Model = _flarumModel['default'];
|
||||
}, function (_flarumModelsDiscussion) {
|
||||
Discussion = _flarumModelsDiscussion['default'];
|
||||
}, function (_flarumComponentsNotificationGrid) {
|
||||
NotificationGrid = _flarumComponentsNotificationGrid['default'];
|
||||
}, function (_flarumLockComponentsDiscussionLockedPost) {
|
||||
DiscussionLockedPost = _flarumLockComponentsDiscussionLockedPost['default'];
|
||||
}, function (_flarumLockComponentsDiscussionLockedNotification) {
|
||||
DiscussionLockedNotification = _flarumLockComponentsDiscussionLockedNotification['default'];
|
||||
}, function (_flarumLockAddLockBadge) {
|
||||
addLockBadge = _flarumLockAddLockBadge['default'];
|
||||
}, function (_flarumLockAddLockControl) {
|
||||
addLockControl = _flarumLockAddLockControl['default'];
|
||||
}],
|
||||
execute: function () {
|
||||
|
||||
app.initializers.add('flarum-lock', function () {
|
||||
app.postComponents.discussionLocked = DiscussionLockedPost;
|
||||
app.notificationComponents.discussionLocked = DiscussionLockedNotification;
|
||||
|
||||
Discussion.prototype.isLocked = Model.attribute('isLocked');
|
||||
Discussion.prototype.canLock = Model.attribute('canLock');
|
||||
|
||||
addLockBadge();
|
||||
addLockControl();
|
||||
|
||||
extend(NotificationGrid.prototype, 'notificationTypes', function (items) {
|
||||
items.add('discussionLocked', {
|
||||
name: 'discussionLocked',
|
||||
icon: 'lock',
|
||||
label: app.trans('flarum-lock.forum.notify_discussion_locked')
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
});;System.register('flarum/lock/components/DiscussionLockedNotification', ['flarum/components/Notification'], function (_export) {
|
||||
'use strict';
|
||||
|
||||
var Notification, DiscussionLockedNotification;
|
||||
return {
|
||||
setters: [function (_flarumComponentsNotification) {
|
||||
Notification = _flarumComponentsNotification['default'];
|
||||
}],
|
||||
execute: function () {
|
||||
DiscussionLockedNotification = (function (_Notification) {
|
||||
babelHelpers.inherits(DiscussionLockedNotification, _Notification);
|
||||
|
||||
function DiscussionLockedNotification() {
|
||||
babelHelpers.classCallCheck(this, DiscussionLockedNotification);
|
||||
babelHelpers.get(Object.getPrototypeOf(DiscussionLockedNotification.prototype), 'constructor', this).apply(this, arguments);
|
||||
}
|
||||
|
||||
babelHelpers.createClass(DiscussionLockedNotification, [{
|
||||
key: 'icon',
|
||||
value: function icon() {
|
||||
return 'lock';
|
||||
}
|
||||
}, {
|
||||
key: 'href',
|
||||
value: function href() {
|
||||
var notification = this.props.notification;
|
||||
|
||||
return app.route.discussion(notification.subject(), notification.content().postNumber);
|
||||
}
|
||||
}, {
|
||||
key: 'content',
|
||||
value: function content() {
|
||||
return app.trans('flarum-lock.forum.discussion_locked_notification', { user: this.props.notification.sender() });
|
||||
}
|
||||
}]);
|
||||
return DiscussionLockedNotification;
|
||||
})(Notification);
|
||||
|
||||
_export('default', DiscussionLockedNotification);
|
||||
}
|
||||
};
|
||||
});;System.register('flarum/lock/components/DiscussionLockedPost', ['flarum/components/EventPost'], function (_export) {
|
||||
'use strict';
|
||||
|
||||
var EventPost, DiscussionLockedPost;
|
||||
return {
|
||||
setters: [function (_flarumComponentsEventPost) {
|
||||
EventPost = _flarumComponentsEventPost['default'];
|
||||
}],
|
||||
execute: function () {
|
||||
DiscussionLockedPost = (function (_EventPost) {
|
||||
babelHelpers.inherits(DiscussionLockedPost, _EventPost);
|
||||
|
||||
function DiscussionLockedPost() {
|
||||
babelHelpers.classCallCheck(this, DiscussionLockedPost);
|
||||
babelHelpers.get(Object.getPrototypeOf(DiscussionLockedPost.prototype), 'constructor', this).apply(this, arguments);
|
||||
}
|
||||
|
||||
babelHelpers.createClass(DiscussionLockedPost, [{
|
||||
key: 'icon',
|
||||
value: function icon() {
|
||||
return this.props.post.content().locked ? 'lock' : 'unlock';
|
||||
}
|
||||
}, {
|
||||
key: 'descriptionKey',
|
||||
value: function descriptionKey() {
|
||||
return this.props.post.content().locked ? 'flarum-lock.forum.discussion_locked_post' : 'flarum-lock.forum.discussion_unlocked_post';
|
||||
}
|
||||
}]);
|
||||
return DiscussionLockedPost;
|
||||
})(EventPost);
|
||||
|
||||
_export('default', DiscussionLockedPost);
|
||||
}
|
||||
};
|
||||
});
|
@@ -7,7 +7,7 @@ export default function addLockBadge() {
|
||||
if (this.isLocked()) {
|
||||
badges.add('locked', Badge.component({
|
||||
type: 'locked',
|
||||
label: app.trans('lock.locked'),
|
||||
label: app.trans('flarum-lock.forum.locked'),
|
||||
icon: 'lock'
|
||||
}));
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@ export default function addLockControl() {
|
||||
extend(DiscussionControls, 'moderationControls', function(items, discussion) {
|
||||
if (discussion.canLock()) {
|
||||
items.add('lock', Button.component({
|
||||
children: app.trans(discussion.isLocked() ? 'lock.unlock' : 'lock.lock'),
|
||||
children: app.trans(discussion.isLocked() ? 'flarum-lock.forum.unlock' : 'flarum-lock.forum.lock'),
|
||||
icon: 'lock',
|
||||
onclick: this.lockAction.bind(discussion)
|
||||
}));
|
||||
|
@@ -12,6 +12,6 @@ export default class DiscussionLockedNotification extends Notification {
|
||||
}
|
||||
|
||||
content() {
|
||||
return app.trans('lock.discussion_locked_notification', {user: this.props.notification.sender()});
|
||||
return app.trans('flarum-lock.forum.discussion_locked_notification', {user: this.props.notification.sender()});
|
||||
}
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@ export default class DiscussionLockedPost extends EventPost {
|
||||
|
||||
descriptionKey() {
|
||||
return this.props.post.content().locked
|
||||
? 'lock.discussion_locked_post'
|
||||
: 'lock.discussion_unlocked_post';
|
||||
? 'flarum-lock.forum.discussion_locked_post'
|
||||
: 'flarum-lock.forum.discussion_unlocked_post';
|
||||
}
|
||||
}
|
||||
|
@@ -4,24 +4,26 @@ import Model from 'flarum/Model';
|
||||
import Discussion from 'flarum/models/Discussion';
|
||||
import NotificationGrid from 'flarum/components/NotificationGrid';
|
||||
|
||||
import DiscussionLockedPost from 'lock/components/DiscussionLockedPost';
|
||||
import DiscussionLockedNotification from 'lock/components/DiscussionLockedNotification';
|
||||
import addLockBadge from 'lock/addLockBadge';
|
||||
import addLockControl from 'lock/addLockControl';
|
||||
import DiscussionLockedPost from 'flarum/lock/components/DiscussionLockedPost';
|
||||
import DiscussionLockedNotification from 'flarum/lock/components/DiscussionLockedNotification';
|
||||
import addLockBadge from 'flarum/lock/addLockBadge';
|
||||
import addLockControl from 'flarum/lock/addLockControl';
|
||||
|
||||
app.postComponents.discussionLocked = DiscussionLockedPost;
|
||||
app.notificationComponents.discussionLocked = DiscussionLockedNotification;
|
||||
app.initializers.add('flarum-lock', () => {
|
||||
app.postComponents.discussionLocked = DiscussionLockedPost;
|
||||
app.notificationComponents.discussionLocked = DiscussionLockedNotification;
|
||||
|
||||
Discussion.prototype.isLocked = Model.attribute('isLocked');
|
||||
Discussion.prototype.canLock = Model.attribute('canLock');
|
||||
Discussion.prototype.isLocked = Model.attribute('isLocked');
|
||||
Discussion.prototype.canLock = Model.attribute('canLock');
|
||||
|
||||
addLockBadge();
|
||||
addLockControl();
|
||||
addLockBadge();
|
||||
addLockControl();
|
||||
|
||||
extend(NotificationGrid.prototype, 'notificationTypes', function(items) {
|
||||
items.add('discussionLocked', {
|
||||
name: 'discussionLocked',
|
||||
icon: 'lock',
|
||||
label: app.trans('lock.notify_discussion_locked')
|
||||
extend(NotificationGrid.prototype, 'notificationTypes', function (items) {
|
||||
items.add('discussionLocked', {
|
||||
name: 'discussionLocked',
|
||||
icon: 'lock',
|
||||
label: app.trans('flarum-lock.forum.notify_discussion_locked')
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user