REVERT: Remove feature topic on profile button from topic view (#8573)

This commit is contained in:
Mark VanLandingham 2019-12-17 12:41:49 -08:00 committed by GitHub
parent 62ebfbbb67
commit d37dc14c57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 1 additions and 80 deletions

View File

@ -689,19 +689,6 @@ export default Controller.extend(bufferedProperty("model"), {
}
},
toggleFeaturedOnProfile() {
if (!this.currentUser) return;
if (
this.currentUser.featured_topic &&
this.currentUser.featured_topic.id !== this.model.id
) {
bootbox.confirm(I18n.t("topic.remove_from_profile.warning"), result => {
if (result) return this._performToggleFeaturedOnProfile();
});
} else return this._performToggleFeaturedOnProfile();
},
jumpToIndex(index) {
this._jumpToIndex(index);
},
@ -1093,10 +1080,6 @@ export default Controller.extend(bufferedProperty("model"), {
}
},
_performToggleFeaturedOnProfile() {
this.model.toggleFeaturedOnProfile(this.currentUser).catch(popupAjaxError);
},
_jumpToIndex(index) {
const postStream = this.get("model.postStream");

View File

@ -444,21 +444,6 @@ const Topic = RestModel.extend({
});
},
toggleFeaturedOnProfile(user) {
const removing = user.get("featured_topic.id") === this.id;
const path = removing ? "clear-featured-topic" : "feature-topic";
return ajax(`/u/${user.username}/${path}`, {
type: "PUT",
data: { topic_id: this.id }
})
.then(() => {
const featuredTopic = removing ? null : this;
user.set("featured_topic", featuredTopic);
return;
})
.catch(popupAjaxError);
},
createGroupInvite(group) {
return ajax(`/t/${this.id}/invite-group`, {
type: "POST",

View File

@ -103,7 +103,6 @@
toggleClosed=(action "toggleClosed")
toggleArchived=(action "toggleArchived")
toggleVisibility=(action "toggleVisibility")
toggleFeaturedOnProfile=(action "toggleFeaturedOnProfile")
showTopicStatusUpdate=(route-action "showTopicStatusUpdate")
showFeatureTopic=(route-action "showFeatureTopic")
showChangeTimestamp=(route-action "showChangeTimestamp")
@ -304,7 +303,6 @@
toggleClosed=(action "toggleClosed")
toggleArchived=(action "toggleArchived")
toggleVisibility=(action "toggleVisibility")
toggleFeaturedOnProfile=(action "toggleFeaturedOnProfile")
showTopicStatusUpdate=(route-action "showTopicStatusUpdate")
showFeatureTopic=(route-action "showFeatureTopic")
showChangeTimestamp=(route-action "showChangeTimestamp")

View File

@ -109,27 +109,6 @@ export default createWidget("topic-admin-menu", {
const featured = topic.get("pinned_at") || topic.get("isBanner");
const visible = topic.get("visible");
if (
this.siteSettings.allow_featured_topic_on_user_profiles &&
this.currentUser &&
topic.user_id === this.currentUser.get("id") &&
!topic.isPrivateMessage &&
!topic.category.read_restricted
) {
let topicFeaturedOnProfile =
topic.id === this.currentUser.get("featured_topic.id");
this.addActionButton({
className: "topic-action-feature-on-profile",
buttonClass: topicFeaturedOnProfile ? "btn-primary" : "btn-default",
action: "toggleFeaturedOnProfile",
icon: "id-card",
fullLabel: topicFeaturedOnProfile
? "topic.remove_from_profile.title"
: "topic.feature_on_profile.title"
});
}
// Admin actions
if (this.currentUser && this.currentUser.get("canManageTopic")) {
this.addActionButton({

View File

@ -11,7 +11,6 @@ const createArgs = topic => {
toggleMultiSelect: () => {},
deleteTopic: () => {},
recoverTopic: () => {},
toggleFeaturedOnProfile: () => {},
toggleClosed: () => {},
toggleArchived: () => {},
toggleVisibility: () => {},
@ -44,29 +43,6 @@ widgetTest("topic-admin-menu-button is present for admin/moderators", {
}
});
widgetTest(
"topic-admin-menu-button shows for non-admin when the use can feature the topic",
{
template: '{{mount-widget widget="topic-admin-menu-button" args=args}}',
beforeEach() {
this.currentUser.setProperties({
admin: false,
moderator: false,
id: 123
});
const topic = Topic.create({ user_id: this.currentUser.id });
topic.category = Category.create({ read_restricted: false });
this.siteSettings.allow_featured_topic_on_user_profiles = true;
this.set("args", createArgs(topic));
},
test(assert) {
assert.ok(exists(".toggle-admin-menu"), "admin wrench is present");
}
}
);
widgetTest(
"topic-admin-menu-button hides for non-admin when there is no action",
{
@ -85,7 +61,7 @@ widgetTest(
},
test(assert) {
assert.ok(!exists(".toggle-admin-menu"), "admin wrench is present");
assert.ok(!exists(".toggle-admin-menu"), "admin wrench is not present");
}
}
);