Skip to content

A platform for community discussion. Free, open, simple.

FIX: Replace references to flags in the header with review

Robin Ward8e77b4d58e49
diff --git a/app/assets/javascripts/discourse/components/site-header.js.es6 b/app/assets/javascripts/discourse/components/site-header.js.es6
index ac953580d6c..a49c85fa5cf 100644
--- a/app/assets/javascripts/discourse/components/site-header.js.es6
+++ b/app/assets/javascripts/discourse/components/site-header.js.es6
@@ -7,11 +7,6 @@ import PanEvents, {
SWIPE_VELOCITY_THRESHOLD
} from "discourse/mixins/pan-events";
-const _flagProperties = [];
-function addFlagProperty(prop) {
- _flagProperties.pushObject(prop);
-}
-
const PANEL_BODY_MARGIN = 30;
//android supports pulling in from the screen edges
@@ -32,7 +27,8 @@ const SiteHeaderComponent = MountWidget.extend(Docking, PanEvents, {
@observes(
"currentUser.unread_notifications",
- "currentUser.unread_private_messages"
+ "currentUser.unread_private_messages",
+ "currentUser.reviewable_count"
)
notificationsChanged() {
this.queueRerender();
@@ -274,10 +270,6 @@ const SiteHeaderComponent = MountWidget.extend(Docking, PanEvents, {
buildArgs() {
return {
- flagCount: _flagProperties.reduce(
- (prev, cur) => prev + (this.get(cur) || 0),
- 0
- ),
topic: this._topic,
canSignUp: this.get("canSignUp")
};
@@ -410,23 +402,6 @@ const SiteHeaderComponent = MountWidget.extend(Docking, PanEvents, {
export default SiteHeaderComponent;
-function applyFlaggedProperties() {
- const args = _flagProperties.slice();
- args.push(
- function() {
- this.queueRerender();
- }.on("init")
- );
-
- SiteHeaderComponent.reopen({
- _flagsChanged: Ember.observer.apply(this, args)
- });
-}
-
-addFlagProperty("currentUser.reviewable_count");
-
-export { addFlagProperty, applyFlaggedProperties };
-
export function headerHeight() {
const $header = $("header.d-header");
const headerOffset = $header.offset();
diff --git a/app/assets/javascripts/discourse/initializers/apply-flagged-properties.js.es6 b/app/assets/javascripts/discourse/initializers/apply-flagged-properties.js.es6
deleted file mode 100644
index 431ad56ce72..00000000000
--- a/app/assets/javascripts/discourse/initializers/apply-flagged-properties.js.es6
+++ /dev/null
@@ -1,6 +0,0 @@
-import { applyFlaggedProperties } from "discourse/components/site-header";
-
-export default {
- name: "apply-flagged-properties",
- initialize: applyFlaggedProperties
-};
diff --git a/app/assets/javascripts/discourse/lib/plugin-api.js.es6 b/app/assets/javascripts/discourse/lib/plugin-api.js.es6
index f95769b651d..3bd78bc6127 100644
--- a/app/assets/javascripts/discourse/lib/plugin-api.js.es6
+++ b/app/assets/javascripts/discourse/lib/plugin-api.js.es6
@@ -1,3 +1,4 @@
+import deprecated from "discourse-common/lib/deprecated";
import { iconNode } from "discourse-common/lib/icon-library";
import { addDecorator } from "discourse/widgets/post-cooked";
import ComposerEditor from "discourse/components/composer-editor";
@@ -15,7 +16,6 @@ import {
} from "discourse/widgets/widget";
import { preventCloak } from "discourse/widgets/post-stream";
import { h } from "virtual-dom";
-import { addFlagProperty } from "discourse/components/site-header";
import { addPopupMenuOptionsCallback } from "discourse/controllers/composer";
import { extraConnectorClass } from "discourse/lib/plugin-connectors";
import { addPostSmallActionIcon } from "discourse/widgets/post-small-action";
@@ -536,11 +536,10 @@ class PluginApi {
return reopenWidget(name, args);
}
- /**
- * Adds a property that can be summed for calculating the flag counter
- **/
addFlagProperty(property) {
- return addFlagProperty(property);
+ deprecated(
+ "addFlagProperty has been removed. Use the reviewable API instead."
+ );
}
/**
diff --git a/app/assets/javascripts/discourse/widgets/header.js.es6 b/app/assets/javascripts/discourse/widgets/header.js.es6
index 1a0e7a2d137..271600cbb07 100644
--- a/app/assets/javascripts/discourse/widgets/header.js.es6
+++ b/app/assets/javascripts/discourse/widgets/header.js.es6
@@ -184,18 +184,18 @@ createWidget("header-icons", {
action: "toggleHamburger",
href: "",
contents() {
- if (!attrs.flagCount) {
- return;
+ let { currentUser } = this;
+ if (currentUser && currentUser.reviewable_count) {
+ return h(
+ "div.badge-notification.reviewables",
+ {
+ attributes: {
+ title: I18n.t("notifications.reviewable_items")
+ }
+ },
+ this.currentUser.reviewable_count
+ );
}
- return h(
- "div.badge-notification.flagged-posts",
- {
- attributes: {
- title: I18n.t("notifications.total_flagged")
- }
- },
- attrs.flagCount
- );
}
});
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 7d9f5cb77dd..67d7bddc1a2 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -1640,7 +1640,7 @@ en:
empty: "No notifications found."
more: "view older notifications"
post_approved: "Your post was approved"
- total_flagged: "total flagged posts"
+ reviewable_items: "items requiring review"
mentioned: "<span>{{username}}</span> {{description}}"
group_mentioned: "<span>{{username}}</span> {{description}}"
quoted: "<span>{{username}}</span> {{description}}"