DEV: apply coding standards (#109)

This commit is contained in:
Joffrey JAFFEUX 2020-09-04 13:24:23 +02:00 committed by GitHub
parent cd31a821fc
commit 598c717009
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
55 changed files with 1425 additions and 905 deletions

View File

@ -1,93 +1,3 @@
{
"env": {
"jasmine": true,
"node": true,
"mocha": true,
"browser": true,
"builtin": true
},
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
},
"globals": {
"Ember": true,
"jQuery": true,
"$": true,
"QUnit": true,
"RSVP": true,
"Discourse": true,
"Handlebars": true,
"I18n": true,
"bootbox": true,
"moduleFor": true,
"moduleForComponent": true,
"Pretender": true,
"sandbox": true,
"controllerFor": true,
"test": true,
"visit": true,
"andThen": true,
"click": true,
"currentPath": true,
"currentRouteName": true,
"currentURL": true,
"fillIn": true,
"keyEvent": true,
"triggerEvent": true,
"count": true,
"exists": true,
"visible": true,
"invisible": true,
"asyncRender": true,
"asyncTestDiscourse": true,
"fixture": true,
"find": true,
"sinon": true,
"moment": true,
"_": true,
"alert": true,
"define": true,
"require": true,
"requirejs": true,
"hasModule": true,
"Blob": true,
"File": true
},
"rules": {
"block-scoped-var": 2,
"dot-notation": 0,
"eqeqeq": [2, "allow-null"],
"guard-for-in": 2,
"no-bitwise": 2,
"no-caller": 2,
"no-cond-assign": 0,
"no-debugger": 2,
"no-empty": 0,
"no-eval": 2,
"no-extend-native": 2,
"no-extra-parens": 0,
"no-inner-declarations": 2,
"no-irregular-whitespace": 2,
"no-iterator": 2,
"no-loop-func": 2,
"no-multi-str": 2,
"no-new": 2,
"no-plusplus": 0,
"no-proto": 2,
"no-script-url": 2,
"no-sequences": 2,
"no-shadow": 2,
"no-undef": 2,
"no-unused-vars": 2,
"no-with": 2,
"no-this-before-super": 2,
"semi": 2,
"strict": 0,
"valid-typeof": 2,
"wrap-iife": [2, "inside"],
"no-mixed-spaces-and-tabs": 2,
"no-trailing-spaces": 2
},
"parser": "babel-eslint"
"extends": "eslint-config-discourse"
}

4
.template-lintrc.js Normal file
View File

@ -0,0 +1,4 @@
module.exports = {
plugins: ["ember-template-lint-plugin-discourse"],
extends: "discourse:recommended"
};

View File

@ -1,8 +1,8 @@
export default {
resource: "group",
map() {
this.route("assigned", function() {
this.route("assigned", function () {
this.route("show", { path: "/:filter" });
});
}
},
};

View File

@ -2,5 +2,5 @@ export default {
resource: "user.userPrivateMessages",
map() {
this.route("assigned");
}
},
};

View File

@ -2,5 +2,5 @@ export default {
resource: "user.userActivity",
map() {
this.route("assigned");
}
},
};

View File

@ -1,5 +1,5 @@
<div class='reviewable-filter discourse-assign-assign-to-filter'>
<label class='filter-label'>{{i18n "discourse_assign.assigned_to"}}</label>
<div class="reviewable-filter discourse-assign-assign-to-filter">
<label class="filter-label">{{i18n "discourse_assign.assigned_to"}}</label>
{{user-selector
single=true
fullWidthWrap=true
@ -13,4 +13,4 @@
placeholderKey=placeholderKey
autocomplete="off"
}}
</div>
</div>

View File

@ -8,8 +8,8 @@ export default {
.split("|")
.filter(Boolean);
const groupNames = this.site.groups
.filter(group => groupIDs.includes(group.id.toString()))
.filter((group) => groupIDs.includes(group.id.toString()))
.mapBy("name");
component.set("allowedGroups", groupNames);
}
},
};

View File

@ -1,5 +1,5 @@
<h3>{{i18n 'discourse_assign.assign.title'}}</h3>
<section class='field'>
<h3>{{i18n "discourse_assign.assign.title"}}</h3>
<section class="field">
<div class="enable-accepted-answer">
<label class="checkbox-label">
{{input
@ -7,7 +7,7 @@
checked=(readonly category.enable_unassigned_filter)
change=(action "onChangeSetting" value="target.checked")
}}
{{i18n 'discourse_assign.add_unassigned_filter'}}
{{i18n "discourse_assign.add_unassigned_filter"}}
</label>
</div>
</section>

View File

@ -5,6 +5,6 @@ export default {
"category.custom_fields.enable_unassigned_filter",
value ? "true" : "false"
);
}
}
},
},
};

View File

@ -6,5 +6,5 @@ export default {
args.group.can_show_assigned_tab &&
args.group.assignment_count > 0
);
}
},
};

View File

@ -1,5 +1,5 @@
{{#if currentUser.can_assign}}
{{#link-to 'userActivity.assigned'}}
{{d-icon "user-plus"}} {{i18n 'discourse_assign.assigned'}}
{{#link-to "userActivity.assigned"}}
{{d-icon "user-plus"}} {{i18n "discourse_assign.assigned"}}
{{/link-to}}
{{/if}}

View File

@ -1,4 +1,4 @@
{{#link-to 'userPrivateMessages.assigned' model}}
{{#link-to "userPrivateMessages.assigned" model}}
{{d-icon "user-plus" class="glyph"}}
{{i18n 'discourse_assign.assigned'}}
{{i18n "discourse_assign.assigned"}}
{{/link-to}}

View File

@ -10,5 +10,5 @@ export function shouldShowAssigned(args, component) {
export default {
shouldRender(args, component) {
return shouldShowAssigned(args, component);
}
},
};

View File

@ -1,5 +1,5 @@
export default {
shouldRender(args, component) {
return component.currentUser && component.currentUser.get("can_assign");
}
},
};

View File

@ -10,7 +10,7 @@ export default Ember.Controller.extend({
this._super(...arguments);
this.allowedGroups = [];
ajax("/assign/suggestions").then(data => {
ajax("/assign/suggestions").then((data) => {
this.set("assignSuggestions", data.suggestions);
this.set("allowedGroups", data.assign_allowed_on_groups);
});
@ -26,7 +26,7 @@ export default Ember.Controller.extend({
assignUser(user) {
this.setProperties({
"model.username": user.username,
"model.allowedGroups": this.taskActions.allowedGroups
"model.allowedGroups": this.taskActions.allowedGroups,
});
this.send("assign");
},
@ -45,8 +45,8 @@ export default Ember.Controller.extend({
type: "PUT",
data: {
username: this.get("model.username"),
topic_id: this.get("model.topic.id")
}
topic_id: this.get("model.topic.id"),
},
})
.then(() => {
if (this.get("model.onSuccess")) {
@ -54,6 +54,6 @@ export default Ember.Controller.extend({
}
})
.catch(popupAjaxError);
}
}
},
},
});

View File

@ -24,10 +24,10 @@ export default UserTopicsList.extend({
params: {
order: this.order,
ascending: this.ascending,
q: this.q
}
q: this.q,
},
})
.then(result => this.set("model", result))
.then((result) => this.set("model", result))
.finally(() => {
this.set("loading", false);
});
@ -54,6 +54,6 @@ export default UserTopicsList.extend({
},
onChangeFilter(value) {
debounce(this, this._setSearchTerm, value, INPUT_DELAY * 2);
}
}
},
},
});

View File

@ -42,9 +42,9 @@ export default Controller.extend({
const groupName = this.group.name;
ajax(`/assign/members/${groupName}`, {
type: "GET",
data: { filter: this.filter, offset: this.offset }
data: { filter: this.filter, offset: this.offset },
})
.then(result => {
.then((result) => {
if (this.router.currentRoute.params.filter !== "everyone") {
this.transitionToRoute("group.assigned.show", groupName, "everyone");
}
@ -70,9 +70,9 @@ export default Controller.extend({
this.set("offset", this.offset + 50);
ajax(`/assign/members/${this.group.name}`, {
type: "GET",
data: { filter: this.filter, offset: this.offset }
data: { filter: this.filter, offset: this.offset },
})
.then(result => {
.then((result) => {
this.members.pushObjects(result.members);
})
.finally(() => this.set("loading", false));
@ -87,5 +87,5 @@ export default Controller.extend({
@action
onChangeFilterName(value) {
debounce(this, this._setFilter, value, INPUT_DELAY * 2);
}
},
});

View File

@ -25,6 +25,6 @@ export default UserTopicsList.extend({
this.setProperties({ order: sortBy, ascending: false });
this.model.refreshSort(sortBy, false);
}
}
}
},
},
});

View File

@ -7,11 +7,12 @@ import { queryRegistry } from "discourse/widgets/widget";
import { getOwner } from "discourse-common/lib/get-owner";
import { htmlSafe } from "@ember/template";
import getURL from "discourse-common/lib/get-url";
import I18n from "I18n";
function titleForState(user) {
if (user) {
return I18n.t("discourse_assign.unassign.help", {
username: user.username
username: user.username,
});
} else {
return I18n.t("discourse_assign.assign.help");
@ -48,14 +49,14 @@ function registerTopicFooterButtons(api) {
user.username
}</span></span>${renderAvatar(user, {
imageSize: "small",
ignoreTitle: true
ignoreTitle: true,
})}`
);
} else {
return htmlSafe(
`${renderAvatar(user, {
imageSize: "tiny",
ignoreTitle: true
ignoreTitle: true,
})}<span class="unassign-label">${label}</span>`
);
}
@ -86,21 +87,21 @@ function registerTopicFooterButtons(api) {
dependentKeys: [
"topic.assigned_to_user",
"currentUser.can_assign",
"topic.assigned_to_user.username"
"topic.assigned_to_user.username",
],
displayed() {
return this.currentUser && this.currentUser.can_assign;
}
},
});
}
function initialize(api) {
api.addNavigationBarItem({
name: "unassigned",
customFilter: category => {
customFilter: (category) => {
return category && category.enable_unassigned_filter;
},
customHref: category => {
customHref: (category) => {
if (category) {
return getURL(category.url) + "/l/latest?status=open&assigned=nobody";
}
@ -115,7 +116,7 @@ function initialize(api) {
queryParams["status"] === "open"
);
},
before: "top"
before: "top",
});
// You can't act on flags claimed by another user
@ -146,7 +147,7 @@ function initialize(api) {
didInsertElement() {
this._super(...arguments);
this.messageBus.subscribe("/staff/topic-assignment", data => {
this.messageBus.subscribe("/staff/topic-assignment", (data) => {
let flaggedPost = this.flaggedPost;
if (data.topic_id === flaggedPost.get("topic.id")) {
flaggedPost.set(
@ -162,7 +163,7 @@ function initialize(api) {
this._super(...arguments);
this.messageBus.unsubscribe("/staff/topic-assignment");
}
},
},
{ ignoreMissing: true }
);
@ -177,7 +178,7 @@ function initialize(api) {
assignedToUser.username
)
);
}
},
});
api.modifyClass("model:bookmark", {
@ -189,13 +190,13 @@ function initialize(api) {
assignedToUser.username
)
);
}
},
});
api.addPostSmallActionIcon("assigned", "user-plus");
api.addPostSmallActionIcon("unassigned", "user-times");
api.addPostTransformCallback(transformed => {
api.addPostTransformCallback((transformed) => {
if (
transformed.actionCode === "assigned" ||
transformed.actionCode === "unassigned"
@ -207,7 +208,7 @@ function initialize(api) {
api.addDiscoveryQueryParam("assigned", { replace: true, refreshModel: true });
api.addTagsHtmlCallback(topic => {
api.addTagsHtmlCallback((topic) => {
const assignedTo = topic.get("assigned_to_user.username");
if (assignedTo) {
const assignedPath = topic.assignedToUserPath;
@ -217,13 +218,13 @@ function initialize(api) {
}
});
api.addUserMenuGlyph(widget => {
api.addUserMenuGlyph((widget) => {
if (widget.currentUser && widget.currentUser.can_assign) {
const glyph = {
label: "discourse_assign.assigned",
className: "assigned",
icon: "user-plus",
href: `${widget.currentUser.path}/activity/assigned`
href: `${widget.currentUser.path}/activity/assigned`,
};
if (queryRegistry("quick-access-panel")) {
@ -246,16 +247,16 @@ function initialize(api) {
"a",
{ attributes: { class: "assigned-to-username", href } },
assignedToUser.username
)
),
]);
}
},
});
api.modifyClass("controller:topic", {
subscribe() {
this._super(...arguments);
this.messageBus.subscribe("/staff/topic-assignment", data => {
this.messageBus.subscribe("/staff/topic-assignment", (data) => {
const topic = this.model;
const topicId = topic.id;
@ -276,10 +277,10 @@ function initialize(api) {
if (!this.get("model.id")) return;
this.messageBus.unsubscribe("/staff/topic-assignment");
}
},
});
api.decorateWidget("post-contents:after-cooked", dec => {
api.decorateWidget("post-contents:after-cooked", (dec) => {
if (dec.attrs.post_number === 1) {
const postModel = dec.getModel();
if (postModel) {
@ -287,7 +288,7 @@ function initialize(api) {
if (assignedToUser) {
return dec.widget.attach("assigned-to", {
assignedToUser,
href: Ember.get(postModel, "topic.assignedToUserPath")
href: Ember.get(postModel, "topic.assignedToUserPath"),
});
}
}
@ -304,8 +305,8 @@ function initialize(api) {
save() {
this.saveAttrNames.push("custom_fields");
this._super(...arguments);
}
}
},
},
});
api.addKeyboardShortcut("g a", "", { path: "/my/activity/assigned" });
@ -319,7 +320,9 @@ export default {
return;
}
withPluginApi("0.8.11", api => initialize(api, container));
withPluginApi("0.8.28", api => registerTopicFooterButtons(api, container));
}
withPluginApi("0.8.11", (api) => initialize(api, container));
withPluginApi("0.8.28", (api) =>
registerTopicFooterButtons(api, container)
);
},
};

View File

@ -15,9 +15,9 @@ export default {
return this.custom_fields.enable_unassigned_filter === "true";
}
return false;
}
},
}
)
),
});
}
},
};

View File

@ -28,19 +28,19 @@ export default DiscourseRoute.extend({
params: {
order: params.order,
ascending: params.ascending,
q: params.q
}
q: params.q,
},
});
},
setupController(controller, model) {
controller.setProperties({
model,
searchTerm: this.currentModel.params.q
searchTerm: this.currentModel.params.q,
});
},
renderTemplate() {
this.render("group-topics-list");
}
},
});

View File

@ -10,7 +10,7 @@ export default DiscourseRoute.extend({
controller.setProperties({
model,
members: [],
group: this.modelFor("group")
group: this.modelFor("group"),
});
controller.group.set("assignment_count", model.assignment_count);
@ -28,6 +28,6 @@ export default DiscourseRoute.extend({
actions: {
changeAssigned() {
this.refresh();
}
}
},
},
});

View File

@ -1,9 +1,10 @@
import I18n from "I18n";
import UserTopicListRoute from "discourse/routes/user-topic-list";
export default UserTopicListRoute.extend({
queryParams: {
order: { refreshModel: true },
ascending: { refreshModel: true }
ascending: { refreshModel: true },
},
userActionType: 16,
noContentHelpKey: "discourse_assigns.no_assigns",
@ -17,8 +18,8 @@ export default UserTopicListRoute.extend({
// core is a bit odd here and is not sending an array, should be fixed
exclude_category_ids: [-1],
order: params.order,
ascending: params.ascending
}
ascending: params.ascending,
},
});
},
@ -39,6 +40,6 @@ export default UserTopicListRoute.extend({
actions: {
changeAssigned() {
this.refresh();
}
}
},
},
});

View File

@ -1,3 +1,4 @@
import I18n from "I18n";
import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box";
export default DropdownSelectBoxComponent.extend({
@ -14,15 +15,15 @@ export default DropdownSelectBoxComponent.extend({
icon: "user-times",
name: I18n.t("discourse_assign.unassign.title"),
description: I18n.t("discourse_assign.unassign.help", {
username: this.topic.assigned_to_user.username
})
username: this.topic.assigned_to_user.username,
}),
},
{
id: "reassign",
icon: "users",
name: I18n.t("discourse_assign.reassign.title"),
description: I18n.t("discourse_assign.reassign.help")
}
description: I18n.t("discourse_assign.reassign.help"),
},
];
},
@ -36,6 +37,6 @@ export default DropdownSelectBoxComponent.extend({
this.reassign(this.topic, this.user);
break;
}
}
}
},
},
});

View File

@ -1,3 +1,3 @@
export default Ember.Component.extend({
classNames: ["assigned-to-user"]
classNames: ["assigned-to-user"],
});

View File

@ -1,6 +1,6 @@
import {
ListItemDefaults,
default as TopicListItem
default as TopicListItem,
} from "discourse/components/topic-list-item";
// This is a backward compatible fix so that this change:
@ -10,11 +10,17 @@ let assignedTopicListItem = null;
if (ListItemDefaults) {
assignedTopicListItem = Ember.Component.extend(ListItemDefaults, {
isPrivateMessage: Ember.computed.equal("topic.archetype", "private_message")
isPrivateMessage: Ember.computed.equal(
"topic.archetype",
"private_message"
),
});
} else {
assignedTopicListItem = TopicListItem.extend({
isPrivateMessage: Ember.computed.equal("topic.archetype", "private_message")
isPrivateMessage: Ember.computed.equal(
"topic.archetype",
"private_message"
),
});
}

View File

@ -11,7 +11,7 @@ export default Ember.Component.extend({
this.set("unassigning", true);
return ajax("/assign/unassign", {
type: "PUT",
data: { topic_id: this.get("topic.id") }
data: { topic_id: this.get("topic.id") },
})
.then(() => {
this.set("topic.assigned_to_user", null);
@ -27,12 +27,12 @@ export default Ember.Component.extend({
let topic = this.topic;
ajax(`/assign/claim/${topic.id}`, {
method: "PUT"
method: "PUT",
})
.then(() => {
this.set("topic.assigned_to_user", this.currentUser);
})
.catch(e => {
.catch((e) => {
if (e.jqXHR && e.jqXHR.responseJSON) {
let json = e.jqXHR.responseJSON;
if (json && json.extras) {
@ -47,6 +47,6 @@ export default Ember.Component.extend({
}
this.set("claiming", false);
});
}
}
},
},
});

View File

@ -7,10 +7,10 @@ function assignIfEqual(topic, data) {
export default Ember.Component.extend({
didInsertElement() {
this._super();
this.messageBus.subscribe("/staff/topic-assignment", data => {
this.messageBus.subscribe("/staff/topic-assignment", (data) => {
let flaggedTopics = this.flaggedTopics;
if (flaggedTopics) {
flaggedTopics.forEach(ft => assignIfEqual(ft.topic, data));
flaggedTopics.forEach((ft) => assignIfEqual(ft.topic, data));
} else {
assignIfEqual(this.topic, data);
}
@ -20,5 +20,5 @@ export default Ember.Component.extend({
willDestroyElement() {
this._super();
this.messageBus.unsubscribe("/staff/topic-assignment");
}
},
});

View File

@ -1,5 +1,5 @@
import Component from "@ember/component";
export default Component.extend({
tagName: "li"
tagName: "li",
});

View File

@ -1,3 +1,3 @@
export default Ember.Component.extend({
tagName: ""
tagName: "",
});

View File

@ -1,3 +1,4 @@
import I18n from "I18n";
import computed from "discourse-common/utils/decorators";
export default Ember.Component.extend({
@ -5,11 +6,11 @@ export default Ember.Component.extend({
@computed("user.reminders_frequency")
availableFrequencies(userRemindersFrequency) {
return userRemindersFrequency.map(freq => {
return userRemindersFrequency.map((freq) => {
return {
name: I18n.t(freq.name),
value: freq.value,
selected: false
selected: false,
};
});
},
@ -31,6 +32,6 @@ export default Ember.Component.extend({
actions: {
setFrequency(newFrequency) {
this.set("user.custom_fields.remind_assigns_frequency", newFrequency);
}
}
},
},
});

View File

@ -5,7 +5,7 @@ export default Ember.Service.extend({
unassign(topicId) {
return ajax("/assign/unassign", {
type: "PUT",
data: { topic_id: topicId }
data: { topic_id: topicId },
});
},
@ -13,8 +13,8 @@ export default Ember.Service.extend({
return showModal("assign-user", {
model: {
topic,
username: topic.get("assigned_to_user.username")
}
username: topic.get("assigned_to_user.username"),
},
});
},
@ -23,8 +23,8 @@ export default Ember.Service.extend({
type: "PUT",
data: {
username: user.username,
topic_id: topic.id
}
topic_id: topic.id,
},
});
}
},
});

View File

@ -1,5 +1,5 @@
{{avatar user imageSize="small"}}
<span class='assigned-username'>
<span class="assigned-username">
{{user.username}}
</span>
{{yield}}

View File

@ -5,18 +5,18 @@
This causes the topic-post-badge to be considered the same word as "text"
at the end of the link, preventing it from line wrapping onto its own line.
--}}
<td class='main-link clearfix' colspan="1">
<span class='link-top-line'>
<td class="main-link clearfix" colspan="1">
<span class="link-top-line">
{{~raw "topic-status" topic=topic}}
{{~#if isPrivateMessage}}
{{~d-icon "envelope" class="private-message-icon"}}
{{~d-icon "envelope" class="private-message-icon"}}
{{~/if}}
{{~topic-link topic class="raw-link raw-topic-link"}}
{{~#if topic.featured_link}}
{{~topic-featured-link topic}}
{{~topic-featured-link topic}}
{{~/if}}
{{~#if showTopicPostBadges}}
{{~raw "topic-post-badges" unread=topic.unread newPosts=topic.displayNewPosts unseen=topic.unseen url=topic.lastUnreadUrl newDotText=newDotText}}
{{~raw "topic-post-badges" unread=topic.unread newPosts=topic.displayNewPosts unseen=topic.unseen url=topic.lastUnreadUrl newDotText=newDotText}}
{{~/if}}
</span>
<div class="link-bottom-line">

View File

@ -1,12 +1,12 @@
{{#conditional-loading-spinner condition=loading}}
{{#if hasIncoming}}
<div class="show-mores">
<div class='alert alert-info clickable' {{action showInserted}}>
<a tabindex="0" href="" {{action showInserted}}>
{{count-i18n key="topic_count_" suffix="latest" count=incomingCount}}
</a>
<div class="show-mores">
<div class="alert alert-info clickable" {{action showInserted}}>
<a tabindex="0" href="" {{action showInserted}}>
{{count-i18n key="topic_count_" suffix="latest" count=incomingCount}}
</a>
</div>
</div>
</div>
{{/if}}
{{#if topics}}
@ -24,9 +24,9 @@
scrollOnLoad=scrollOnLoad}}
{{else}}
{{#unless loadingMore}}
<div class='alert alert-info'>
{{i18n 'choose_topic.none_found'}}
</div>
<div class="alert alert-info">
{{i18n "choose_topic.none_found"}}
</div>
{{/unless}}
{{/if}}
{{/conditional-loading-spinner}}
{{/conditional-loading-spinner}}

View File

@ -16,7 +16,7 @@
{{else}}
{{#link-to "group.assigned.show" filter (query-params order=order ascending=ascending q=q)}}
<div class="assign-everyone">
{{i18n 'discourse_assign.group_everyone'}}
{{i18n "discourse_assign.group_everyone"}}
</div>
<div class="assign-count">
{{assignmentCount}}

View File

@ -1,3 +1,3 @@
{{#link-to "group.assigned"}}
{{d-icon "user-plus" class="glyph"}}{{i18n 'discourse_assign.assigned'}} ({{group.assignment_count}})
{{d-icon "user-plus" class="glyph"}}{{i18n "discourse_assign.assigned"}} ({{group.assignment_count}})
{{/link-to}}

View File

@ -1,10 +1,11 @@
{{#if siteSettings.assign_enabled}}
<div class="controls controls-dropdown">
<label>{{i18n "discourse_assign.reminders_frequency.description"}}</label>
{{combo-box valueAttribute="value"
content=availableFrequencies
value=selectedFrequency
onSelect=(action "setFrequency")
{{combo-box
valueAttribute="value"
content=availableFrequencies
value=selectedFrequency
onSelect=(action "setFrequency")
}}
</div>
{{/if}}

View File

@ -8,23 +8,22 @@
</div>
</div>
{{#load-more class="paginated-topics-list" selector=".paginated-topics-list .topic-list tr" action=(action "loadMore")}}
{{basic-assigned-topic-list topicList=model
hideCategory=hideCategory
showPosters=showPosters
bulkSelectEnabled=bulkSelectEnabled
selected=selected
hasIncoming=hasIncoming
incomingCount=incomingCount
showInserted=(action "showInserted")
tagsForUser=tagsForUser
changeSort=(action 'changeSort')
unassign=(action 'unassign')
reassign=(action 'reassign')
onScroll=saveScrollPosition
scrollOnLoad=true}}
{{basic-assigned-topic-list
topicList=model
hideCategory=hideCategory
showPosters=showPosters
bulkSelectEnabled=bulkSelectEnabled
selected=selected
hasIncoming=hasIncoming
incomingCount=incomingCount
showInserted=(action "showInserted")
tagsForUser=tagsForUser
changeSort=(action "changeSort")
unassign=(action "unassign")
reassign=(action "reassign")
onScroll=saveScrollPosition
scrollOnLoad=true
}}
{{conditional-loading-spinner condition=model.loadingMore}}
{{/load-more}}

View File

@ -1,5 +1,5 @@
<td>
<div class='main-link'>
<div class="main-link">
{{topic-status topic=topic}}
{{~#if isPrivateMessage}}
{{~d-icon "envelope" class="private-message-icon"}}
@ -10,34 +10,36 @@
{{/if}}
{{#if topic.hasExcerpt}}
<div class="topic-excerpt">
{{{topic.excerpt}}}
{{html-safe topic.excerpt}}
{{#if topic.excerptTruncated}}
{{#unless topic.canClearPin}}<a href="{{unbound topic.url}}">{{i18n 'read_more'}}</a>{{/unless}}
{{#unless topic.canClearPin}}<a href={{unbound topic.url}}>{{i18n "read_more"}}</a>{{/unless}}
{{/if}}
{{#if topic.canClearPin}}
<a href {{action "clearPin" topic}} title="{{i18n 'topic.clear_pin.help'}}">{{i18n 'topic.clear_pin.title'}}</a>
<a href {{action "clearPin" topic}} title={{i18n "topic.clear_pin.help"}}>{{i18n "topic.clear_pin.title"}}</a>
{{/if}}
</div>
{{/if}}
</div>
<div class='pull-right'>
{{assign-actions-dropdown topic=topic
user=username
unassign=unassign
reassign=reassign}}
<div class="pull-right">
{{assign-actions-dropdown
topic=topic
user=username
unassign=unassign
reassign=reassign
}}
</div>
<div class='clearfix'></div>
<div class="clearfix"></div>
<div class="topic-item-stats clearfix">
{{discourse-tags topic mode="list" tagsForUser=tagsForUser}}
<div class="pull-right">
{{raw "list/activity-column" topic=topic tagName="div" class="num activity last"}}
<a href="{{topic.lastPostUrl}}" title='{{i18n 'last_post'}}: {{{raw-date topic.bumped_at}}}'>{{topic.last_poster_username}}</a>
<a href={{topic.lastPostUrl}} title="{{i18n 'last_post'}}: {{html-safe raw-date topic.bumped_at}}">{{topic.last_poster_username}}</a>
</div>
{{#unless hideCategory}}
<div class='category'>
<div class="category">
{{category-link topic.category}}
</div>
{{/unless}}
<div class="clearfix"></div>
</div>
</td>
</td>

View File

@ -1,30 +1,32 @@
{{#conditional-loading-spinner condition=loading}}
{{#if hasIncoming}}
<div class="show-mores">
<div class='alert alert-info clickable' {{action showInserted}}>
{{count-i18n key="topic_count_" suffix="latest" count=incomingCount}}
<div class="show-mores">
<div class="alert alert-info clickable" {{action showInserted}}>
{{count-i18n key="topic_count_" suffix="latest" count=incomingCount}}
</div>
</div>
</div>
{{/if}}
{{#if topics}}
<table class="topic-list">
<tbody>
{{#each topics as |t|}}
{{assigned-topic-list-item topic=t
expandGloballyPinned=expandGloballyPinned
expandAllPinned=expandAllPinned
lastVisitedTopic=lastVisitedTopic
selected=selected
tagsForUser=tagsForUser
unassign=unassign
reassign=reassign}}
{{/each}}
{{#each topics as |t|}}
{{assigned-topic-list-item
topic=t
expandGloballyPinned=expandGloballyPinned
expandAllPinned=expandAllPinned
lastVisitedTopic=lastVisitedTopic
selected=selected
tagsForUser=tagsForUser
unassign=unassign
reassign=reassign
}}
{{/each}}
</tbody>
</table>
{{else}}
<div class='alert alert-info'>
{{i18n 'choose_topic.none_found'}}
<div class="alert alert-info">
{{i18n "choose_topic.none_found"}}
</div>
{{/if}}
{{/conditional-loading-spinner}}

View File

@ -1,7 +1,7 @@
{{#d-modal-body title="discourse_assign.assign_modal.title" class="assign"}}
<div>
{{i18n 'discourse_assign.assign_modal.description'}}
{{user-selector
<div>
{{i18n "discourse_assign.assign_modal.description"}}
{{user-selector
single=true
allowAny=false
groupMembersOf=allowedGroups
@ -10,16 +10,23 @@
hasGroups=false
usernames=model.username
placeholderKey=placeholderKey
autocomplete="off"}}
<div class='assign-suggestions'>
{{#each assignSuggestions as |user|}}
<a {{action "assignUser" user}}>
{{avatar user imageSize="small"}}
</a>
{{/each}}
autocomplete="off"
}}
<div class="assign-suggestions">
{{#each assignSuggestions as |user|}}
<a {{action "assignUser" user}}>
{{avatar user imageSize="small"}}
</a>
{{/each}}
</div>
</div>
</div>
{{/d-modal-body}}
<div class="modal-footer">
{{d-button label='discourse_assign.assign_modal.assign' icon=inviteIcon action=(action "assign") class="btn-primary" disabled=disabled}}
{{d-button
label="discourse_assign.assign_modal.assign"
icon=inviteIcon action=(action "assign")
class="btn-primary"
disabled=disabled
}}
</div>

View File

@ -1,20 +1,20 @@
{{#load-more class="paginated-topics-list" selector=".paginated-topics-list .topic-list tr" action=(action "loadMore")}}
{{basic-assigned-topic-list topicList=model
hideCategory=hideCategory
showPosters=showPosters
bulkSelectEnabled=bulkSelectEnabled
selected=selected
hasIncoming=hasIncoming
incomingCount=incomingCount
showInserted=(action "showInserted")
tagsForUser=tagsForUser
changeSort=(action 'changeSort')
unassign=(action 'unassign')
reassign=(action 'reassign')
onScroll=saveScrollPosition
scrollOnLoad=true}}
{{basic-assigned-topic-list
topicList=model
hideCategory=hideCategory
showPosters=showPosters
bulkSelectEnabled=bulkSelectEnabled
selected=selected
hasIncoming=hasIncoming
incomingCount=incomingCount
showInserted=(action "showInserted")
tagsForUser=tagsForUser
changeSort=(action "changeSort")
unassign=(action "unassign")
reassign=(action "reassign")
onScroll=saveScrollPosition
scrollOnLoad=true
}}
{{conditional-loading-spinner condition=model.loadingMore}}
{{/load-more}}

View File

@ -19,8 +19,8 @@ if (QuickAccessPanel) {
.findFiltered("topicList", {
filter: `topics/messages-assigned/${this.currentUser.username_lower}`,
params: {
exclude_category_ids: [-1]
}
exclude_category_ids: [-1],
},
})
.then(({ topic_list }) => {
return topic_list.topics;
@ -35,8 +35,8 @@ if (QuickAccessPanel) {
assignedTopic.id,
assignedTopic.last_read_post_number + 1
),
escapedContent: assignedTopic.fancy_title
escapedContent: assignedTopic.fancy_title,
});
}
},
});
}

View File

@ -5,8 +5,6 @@
"author": "Discourse",
"license": "MIT",
"devDependencies": {
"babel-eslint": "^8.2",
"eslint": "^4.19",
"prettier": "1.14.3"
"eslint-config-discourse": "latest"
}
}

View File

@ -8,10 +8,10 @@ acceptance("Assign disabled mobile", {
settings: { assign_enabled: false },
beforeEach() {
clearTopicFooterButtons();
}
},
});
QUnit.test("Footer dropdown does not contain button", async assert => {
QUnit.test("Footer dropdown does not contain button", async (assert) => {
updateCurrentUser({ can_assign: true });
const menu = selectKit(".topic-footer-mobile-dropdown");

View File

@ -8,10 +8,10 @@ acceptance("Assign mobile", {
settings: { assign_enabled: true },
beforeEach() {
clearTopicFooterButtons();
}
},
});
QUnit.test("Footer dropdown contains button", async assert => {
QUnit.test("Footer dropdown contains button", async (assert) => {
updateCurrentUser({ can_assign: true });
const menu = selectKit(".topic-footer-mobile-dropdown");

View File

@ -15,16 +15,16 @@ acceptance("GroupAssignments", {
server.get(groupPath, () => helper.response(groupAssigns));
server.get(memberPath, () => helper.response(memberAssigns));
server.get(getMembersPath, () => helper.response(getMembers));
}
},
});
QUnit.test("Group Assignments Everyone", async assert => {
QUnit.test("Group Assignments Everyone", async (assert) => {
await visit("/g/discourse/assigned");
assert.equal(currentPath(), "group.assigned.show");
assert.ok(find(".topic-list-item").length === 1);
});
QUnit.test("Group Assignments Ahmedgagan", async assert => {
QUnit.test("Group Assignments Ahmedgagan", async (assert) => {
await visit("/g/discourse/assigned/ahmedgagan6");
assert.equal(currentPath(), "group.assigned.show");
assert.ok(find(".topic-list-item").length === 1);

View File

@ -8,16 +8,16 @@ acceptance("Quick access assignments panel", {
loggedIn: true,
settings: {
assign_enabled: true,
assigns_user_url_path: "/"
assigns_user_url_path: "/",
},
pretend(server, helper) {
const messagesPath = "/topics/messages-assigned/eviltrout.json";
const assigns = AssignedTopics[messagesPath];
server.get(messagesPath, () => helper.response(assigns));
}
},
});
QUnit.test("Quick access assignments panel", async assert => {
QUnit.test("Quick access assignments panel", async (assert) => {
updateCurrentUser({ can_assign: true });
await visit("/");

View File

@ -6,16 +6,16 @@ acceptance("UnAssign/Re-assign from the topics list", {
loggedIn: true,
settings: {
assign_enabled: true,
assigns_user_url_path: "/"
assigns_user_url_path: "/",
},
pretend(server, helper) {
const messagesPath = "/topics/messages-assigned/eviltrout.json";
const assigns = AssignedTopics[messagesPath];
server.get(messagesPath, () => helper.response(assigns));
}
},
});
QUnit.test("Unassing/Re-assign options are visible", async assert => {
QUnit.test("Unassing/Re-assign options are visible", async (assert) => {
const options = selectKit(".assign-actions-dropdown");
await visit("/u/eviltrout/activity/assigned");

View File

@ -16,12 +16,12 @@ componentTest("display username", {
last_posted_at: "2020-06-22T10:15:54.532Z",
last_seen_at: "2020-07-07T11:55:59.437Z",
added_at: "2020-06-22T09:55:31.692Z",
timezone: "Asia/Calcutta"
timezone: "Asia/Calcutta",
});
},
async test(assert) {
assert.ok(find("li")[0].innerText.trim(), "Ahmed");
}
},
});
componentTest("display name", {
template: "{{group-assigned-filter show-avatar=true filter=filter}}",
@ -37,10 +37,10 @@ componentTest("display name", {
last_posted_at: "2020-06-22T10:15:54.532Z",
last_seen_at: "2020-07-07T11:55:59.437Z",
added_at: "2020-06-22T09:55:31.692Z",
timezone: "Asia/Calcutta"
timezone: "Asia/Calcutta",
});
},
async test(assert) {
assert.ok(find("li")[0].innerText.trim(), "Ahmed Gagan");
}
},
});

View File

@ -5,14 +5,14 @@ export default {
id: -2,
username: "discobot",
name: "discobot",
avatar_template: "/user_avatar/localhost/discobot/{size}/1_2.png"
avatar_template: "/user_avatar/localhost/discobot/{size}/1_2.png",
},
{
id: -1,
username: "system",
name: "system",
avatar_template: "/user_avatar/localhost/system/{size}/2_2.png"
}
avatar_template: "/user_avatar/localhost/system/{size}/2_2.png",
},
],
primary_groups: [],
topic_list: {
@ -61,27 +61,27 @@ export default {
extras: "latest single",
description: "Original Poster, Most Recent Poster",
user_id: -2,
primary_group_id: null
}
primary_group_id: null,
},
],
participants: [
{
extras: "latest",
description: null,
user_id: -2,
primary_group_id: null
}
primary_group_id: null,
},
],
assigned_to_user: {
id: 19,
username: "eviltrout",
name: null,
avatar_template:
"/letter_avatar_proxy/v4/letter/r/ed8c4c/{size}.png"
}
}
]
}
"/letter_avatar_proxy/v4/letter/r/ed8c4c/{size}.png",
},
},
],
},
},
"/topics/messages-assigned/ahmedgagan6.json": {
users: [
@ -89,14 +89,14 @@ export default {
id: -2,
username: "discobot",
name: "discobot",
avatar_template: "/user_avatar/localhost/discobot/{size}/1_2.png"
avatar_template: "/user_avatar/localhost/discobot/{size}/1_2.png",
},
{
id: -1,
username: "system",
name: "system",
avatar_template: "/user_avatar/localhost/system/{size}/2_2.png"
}
avatar_template: "/user_avatar/localhost/system/{size}/2_2.png",
},
],
primary_groups: [],
topic_list: {
@ -145,26 +145,26 @@ export default {
extras: "latest single",
description: "Original Poster, Most Recent Poster",
user_id: -2,
primary_group_id: null
}
primary_group_id: null,
},
],
participants: [
{
extras: "latest",
description: null,
user_id: -2,
primary_group_id: null
}
primary_group_id: null,
},
],
assigned_to_user: {
id: 2770,
username: "awesomerobot",
name: null,
avatar_template:
"/user_avatar/meta.discourse.org/awesomerobot/{size}/33872.png"
}
}
]
}
}
"/user_avatar/meta.discourse.org/awesomerobot/{size}/33872.png",
},
},
],
},
},
};

View File

@ -5,14 +5,14 @@ export default {
id: -2,
username: "discobot",
name: "discobot",
avatar_template: "/user_avatar/localhost/discobot/{size}/1_2.png"
avatar_template: "/user_avatar/localhost/discobot/{size}/1_2.png",
},
{
id: -1,
username: "system",
name: "system",
avatar_template: "/user_avatar/localhost/system/{size}/2_2.png"
}
avatar_template: "/user_avatar/localhost/system/{size}/2_2.png",
},
],
primary_groups: [],
topic_list: {
@ -61,26 +61,26 @@ export default {
extras: "latest single",
description: "Original Poster, Most Recent Poster",
user_id: -2,
primary_group_id: null
}
primary_group_id: null,
},
],
participants: [
{
extras: "latest",
description: null,
user_id: -2,
primary_group_id: null
}
primary_group_id: null,
},
],
assigned_to_user: {
id: 19,
username: "eviltrout",
name: null,
avatar_template:
"/letter_avatar_proxy/v4/letter/r/ed8c4c/{size}.png"
}
}
]
}
}
"/letter_avatar_proxy/v4/letter/r/ed8c4c/{size}.png",
},
},
],
},
},
};

View File

@ -7,7 +7,7 @@ export default {
name: null,
avatar_template: "/letter_avatar_proxy/v4/letter/a/838e76/{size}.png",
assignments_count: 40,
username_lower: "ahmedgagan6"
username_lower: "ahmedgagan6",
},
{
id: 4,
@ -15,7 +15,7 @@ export default {
name: "Gagan ",
avatar_template: "/letter_avatar_proxy/v4/letter/g/8edcca/{size}.png",
assignments_count: 17,
username_lower: "gaganahmed"
username_lower: "gaganahmed",
},
{
id: 3,
@ -23,7 +23,7 @@ export default {
name: "",
avatar_template: "/user_avatar/localhost/ahmedgagan/{size}/2_2.png",
assignments_count: 16,
username_lower: "ahmedgagan"
username_lower: "ahmedgagan",
},
{
id: 2,
@ -31,8 +31,8 @@ export default {
name: "Ahmed Gagan",
avatar_template: "/letter_avatar_proxy/v4/letter/a/8c91f0/{size}.png",
assignments_count: 15,
username_lower: "ahmed"
}
]
}
username_lower: "ahmed",
},
],
},
};

1661
yarn.lock

File diff suppressed because it is too large Load Diff