mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 23:07:28 +08:00
Disable social media sharing on private categories, unlisted topics (#10349)
* Do not show social media sharing on private categories, unlisted topics * Disable quote sharing entirely in private categories and unlisted topics
This commit is contained in:
@ -12,6 +12,7 @@ import { INPUT_DELAY } from "discourse-common/config/environment";
|
|||||||
import { action } from "@ember/object";
|
import { action } from "@ember/object";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import Sharing from "discourse/lib/sharing";
|
import Sharing from "discourse/lib/sharing";
|
||||||
|
import { alias } from "@ember/object/computed";
|
||||||
|
|
||||||
function getQuoteTitle(element) {
|
function getQuoteTitle(element) {
|
||||||
const titleEl = element.querySelector(".title");
|
const titleEl = element.querySelector(".title");
|
||||||
@ -23,6 +24,7 @@ export default Component.extend({
|
|||||||
classNames: ["quote-button"],
|
classNames: ["quote-button"],
|
||||||
classNameBindings: ["visible"],
|
classNameBindings: ["visible"],
|
||||||
visible: false,
|
visible: false,
|
||||||
|
privateCategory: alias("topic.category.read_restricted"),
|
||||||
|
|
||||||
_isMouseDown: false,
|
_isMouseDown: false,
|
||||||
_reselected: false,
|
_reselected: false,
|
||||||
@ -209,14 +211,16 @@ export default Component.extend({
|
|||||||
.off("selectionchange.quote-button");
|
.off("selectionchange.quote-button");
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed
|
@discourseComputed("topic.{isPrivateMessage,invisible,category}")
|
||||||
quoteSharingEnabled() {
|
quoteSharingEnabled(topic) {
|
||||||
if (
|
if (
|
||||||
this.site.mobileView ||
|
this.site.mobileView ||
|
||||||
this.siteSettings.share_quote_visibility === "none" ||
|
this.siteSettings.share_quote_visibility === "none" ||
|
||||||
this.quoteSharingSources.length === 0 ||
|
|
||||||
(this.currentUser &&
|
(this.currentUser &&
|
||||||
this.siteSettings.share_quote_visibility === "anonymous")
|
this.siteSettings.share_quote_visibility === "anonymous") ||
|
||||||
|
this.quoteSharingSources.length === 0 ||
|
||||||
|
this.privateCategory ||
|
||||||
|
(this.currentUser && topic.invisible)
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -232,7 +236,7 @@ export default Component.extend({
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed
|
@discourseComputed("topic.{isPrivateMessage,invisible,category}")
|
||||||
quoteSharingShowLabel() {
|
quoteSharingShowLabel() {
|
||||||
return this.quoteSharingSources.length > 1;
|
return this.quoteSharingSources.length > 1;
|
||||||
},
|
},
|
||||||
|
@ -9,14 +9,17 @@ import { later } from "@ember/runloop";
|
|||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
tagName: null,
|
tagName: null,
|
||||||
|
|
||||||
type: alias("panel.model.type"),
|
type: alias("panel.model.type"),
|
||||||
|
|
||||||
topic: alias("panel.model.topic"),
|
topic: alias("panel.model.topic"),
|
||||||
|
privateCategory: alias("panel.model.topic.category.read_restricted"),
|
||||||
|
|
||||||
@discourseComputed("topic.isPrivateMessage")
|
@discourseComputed("topic.{isPrivateMessage,invisible,category}")
|
||||||
sources(isPM) {
|
sources(topic) {
|
||||||
const privateContext = this.siteSettings.login_required || isPM;
|
const privateContext =
|
||||||
|
this.siteSettings.login_required ||
|
||||||
|
topic.isPrivateMessage ||
|
||||||
|
topic.invisible ||
|
||||||
|
this.privateCategory;
|
||||||
return Sharing.activeSources(this.siteSettings.share_links, privateContext);
|
return Sharing.activeSources(this.siteSettings.share_links, privateContext);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -7,16 +7,23 @@ import { longDateNoYear } from "discourse/lib/formatter";
|
|||||||
import discourseComputed, { on } from "discourse-common/utils/decorators";
|
import discourseComputed, { on } from "discourse-common/utils/decorators";
|
||||||
import Sharing from "discourse/lib/sharing";
|
import Sharing from "discourse/lib/sharing";
|
||||||
import { nativeShare } from "discourse/lib/pwa-utils";
|
import { nativeShare } from "discourse/lib/pwa-utils";
|
||||||
|
import { alias } from "@ember/object/computed";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
elementId: "share-link",
|
elementId: "share-link",
|
||||||
classNameBindings: ["visible"],
|
classNameBindings: ["visible"],
|
||||||
link: null,
|
link: null,
|
||||||
visible: null,
|
visible: null,
|
||||||
|
privateCategory: alias("topic.category.read_restricted"),
|
||||||
|
|
||||||
|
@discourseComputed("topic.{isPrivateMessage,invisible,category}")
|
||||||
|
sources(topic) {
|
||||||
|
const privateContext =
|
||||||
|
this.siteSettings.login_required ||
|
||||||
|
topic.isPrivateMessage ||
|
||||||
|
topic.invisible ||
|
||||||
|
this.privateCategory;
|
||||||
|
|
||||||
@discourseComputed("topic.isPrivateMessage")
|
|
||||||
sources(isPM) {
|
|
||||||
const privateContext = this.siteSettings.login_required || isPM;
|
|
||||||
return Sharing.activeSources(this.siteSettings.share_links, privateContext);
|
return Sharing.activeSources(this.siteSettings.share_links, privateContext);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user