From d37dc14c576899227d55841e8670fb1de47282ec Mon Sep 17 00:00:00 2001 From: Mark VanLandingham Date: Tue, 17 Dec 2019 12:41:49 -0800 Subject: [PATCH] REVERT: Remove feature topic on profile button from topic view (#8573) --- .../discourse/controllers/topic.js.es6 | 17 ------------ .../javascripts/discourse/models/topic.js.es6 | 15 ----------- .../javascripts/discourse/templates/topic.hbs | 2 -- .../discourse/widgets/topic-admin-menu.js.es6 | 21 --------------- .../widgets/topic-admin-menu-test.js.es6 | 26 +------------------ 5 files changed, 1 insertion(+), 80 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/topic.js.es6 b/app/assets/javascripts/discourse/controllers/topic.js.es6 index 66bb4acebfb..7b523ee7680 100644 --- a/app/assets/javascripts/discourse/controllers/topic.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic.js.es6 @@ -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"); diff --git a/app/assets/javascripts/discourse/models/topic.js.es6 b/app/assets/javascripts/discourse/models/topic.js.es6 index 86515edadcc..c392bc20ef6 100644 --- a/app/assets/javascripts/discourse/models/topic.js.es6 +++ b/app/assets/javascripts/discourse/models/topic.js.es6 @@ -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", diff --git a/app/assets/javascripts/discourse/templates/topic.hbs b/app/assets/javascripts/discourse/templates/topic.hbs index 075cd72048a..0a7671bf64e 100644 --- a/app/assets/javascripts/discourse/templates/topic.hbs +++ b/app/assets/javascripts/discourse/templates/topic.hbs @@ -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") diff --git a/app/assets/javascripts/discourse/widgets/topic-admin-menu.js.es6 b/app/assets/javascripts/discourse/widgets/topic-admin-menu.js.es6 index e59b4c2424c..6463bc33de4 100644 --- a/app/assets/javascripts/discourse/widgets/topic-admin-menu.js.es6 +++ b/app/assets/javascripts/discourse/widgets/topic-admin-menu.js.es6 @@ -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({ diff --git a/test/javascripts/widgets/topic-admin-menu-test.js.es6 b/test/javascripts/widgets/topic-admin-menu-test.js.es6 index a7cd2a89b4a..3ed54ddd215 100644 --- a/test/javascripts/widgets/topic-admin-menu-test.js.es6 +++ b/test/javascripts/widgets/topic-admin-menu-test.js.es6 @@ -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"); } } );