DEV: Convert TL settings to groups (#195)

* DEV: Convert TL settings to groups

This change converts the TL site settings in this plugin to use groups
instead.

See: https://meta.discourse.org/t/283408

Co-authored-by: Martin Brennan <[email protected]>
This commit is contained in:
Blake Erickson
2024-01-31 11:04:24 -07:00
committed by GitHub
co-authored by Martin Brennan
parent 19ac017dd4
commit 6f8ff34ffa
16 changed files with 348 additions and 45 deletions
@@ -111,30 +111,32 @@ export default AdComponent.extend({
scheduleOnce("afterRender", this, this._triggerAds);
},
@discourseComputed("currentUser.trust_level")
showToTrustLevel(trustLevel) {
return !(
trustLevel && trustLevel > this.siteSettings.adbutler_through_trust_level
);
@discourseComputed
showToDisplayGroups() {
if (!this.currentUser) {
return true;
}
return this.currentUser.show_adbutler_ads;
},
@discourseComputed(
"publisherId",
"showToTrustLevel",
"showToDisplayGroups",
"showToGroups",
"showAfterPost",
"showOnCurrentPage"
)
showAd(
publisherId,
showToTrustLevel,
showToDisplayGroups,
showToGroups,
showAfterPost,
showOnCurrentPage
) {
return (
publisherId &&
showToTrustLevel &&
showToDisplayGroups &&
showToGroups &&
showAfterPost &&
showOnCurrentPage
@@ -7,7 +7,7 @@ export default AdComponent.extend({
classNames: ["amazon-product-links"],
showAd: and(
"showToTrustLevel",
"showToDisplayGroups",
"showToGroups",
"showAfterPost",
"showOnCurrentPage"
@@ -173,11 +173,13 @@ export default AdComponent.extend({
return htmlSafe(`${userInput}`);
},
@discourseComputed("currentUser.trust_level")
showToTrustLevel(trustLevel) {
return !(
trustLevel && trustLevel > this.siteSettings.amazon_through_trust_level
);
@discourseComputed
showToDisplayGroups() {
if (!this.currentUser) {
return true;
}
return this.currentUser.show_amazon_ads;
},
@discourseComputed("postNumber")
@@ -19,31 +19,33 @@ export default AdComponent.extend({
);
},
@discourseComputed("currentUser.trust_level")
showToTrustLevel(trustLevel) {
return !(
trustLevel && trustLevel > this.siteSettings.carbonads_through_trust_level
);
@discourseComputed
showToDisplayGroups() {
if (!this.currentUser) {
return true;
}
return this.currentUser.show_carbon_ads;
},
@discourseComputed(
"placement",
"serve_id",
"showToTrustLevel",
"showToDisplayGroups",
"showToGroups",
"showOnCurrentPage"
)
showAd(
placement,
serveId,
showToTrustLevel,
showToDisplayGroups,
showToGroups,
showOnCurrentPage
) {
return (
placement &&
serveId &&
showToTrustLevel &&
showToDisplayGroups &&
showToGroups &&
showOnCurrentPage
);
@@ -206,30 +206,32 @@ export default AdComponent.extend({
);
},
@discourseComputed("currentUser.trust_level")
showToTrustLevel(trustLevel) {
return !(
trustLevel && trustLevel > this.siteSettings.adsense_through_trust_level
);
@discourseComputed
showToDisplayGroups() {
if (!this.currentUser) {
return true;
}
return this.currentUser.show_adsense_ads;
},
@discourseComputed(
"publisher_id",
"showToTrustLevel",
"showToDisplayGroups",
"showToGroups",
"showAfterPost",
"showOnCurrentPage"
)
showAd(
publisherId,
showToTrustLevel,
showToDisplayGroups,
showToGroups,
showAfterPost,
showOnCurrentPage
) {
return (
publisherId &&
showToTrustLevel &&
showToDisplayGroups &&
showToGroups &&
showAfterPost &&
showOnCurrentPage
@@ -299,7 +299,7 @@ export default AdComponent.extend({
@discourseComputed(
"publisherId",
"showToTrustLevel",
"showToDisplayGroups",
"showToGroups",
"showAfterPost",
"showOnCurrentPage",
@@ -307,7 +307,7 @@ export default AdComponent.extend({
)
showAd(
publisherId,
showToTrustLevel,
showToDisplayGroups,
showToGroups,
showAfterPost,
showOnCurrentPage,
@@ -315,7 +315,7 @@ export default AdComponent.extend({
) {
return (
publisherId &&
showToTrustLevel &&
showToDisplayGroups &&
showToGroups &&
showAfterPost &&
showOnCurrentPage &&
@@ -323,11 +323,13 @@ export default AdComponent.extend({
);
},
@discourseComputed("currentUser.trust_level")
showToTrustLevel(trustLevel) {
return !(
trustLevel && trustLevel > this.siteSettings.dfp_through_trust_level
);
@discourseComputed
showToDisplayGroups() {
if (!this.currentUser) {
return true;
}
return this.currentUser.show_dfp_ads;
},
@discourseComputed("postNumber")