diff --git a/app/assets/javascripts/admin/controllers/admin-reports.js.es6 b/app/assets/javascripts/admin/controllers/admin-reports.js.es6
index e964d17a257..d83a031c6bc 100644
--- a/app/assets/javascripts/admin/controllers/admin-reports.js.es6
+++ b/app/assets/javascripts/admin/controllers/admin-reports.js.es6
@@ -1,3 +1,6 @@
+import { exportEntity } from 'discourse/lib/export-csv';
+import { outputExportResult } from 'discourse/lib/export-result';
+
export default Ember.Controller.extend({
viewMode: 'table',
viewingTable: Em.computed.equal('viewMode', 'table'),
@@ -30,6 +33,15 @@ export default Ember.Controller.extend({
viewAsBarChart() {
this.set('viewMode', 'barChart');
+ },
+
+ exportCsv() {
+ exportEntity('report', {
+ name: this.get("model.type"),
+ start_date: this.get('startDate'),
+ end_date: this.get('endDate'),
+ category_id: this.get('categoryId') == 'all' ? undefined : this.get('categoryId')
+ }).then(outputExportResult);
}
}
});
diff --git a/app/assets/javascripts/admin/templates/reports.hbs b/app/assets/javascripts/admin/templates/reports.hbs
index c7383ef2c8a..5e1b406ea6a 100644
--- a/app/assets/javascripts/admin/templates/reports.hbs
+++ b/app/assets/javascripts/admin/templates/reports.hbs
@@ -5,6 +5,7 @@
{{i18n 'admin.dashboard.reports.end_date'}} {{input type="date" value=endDate}}
{{combo-box valueAttribute="value" content=categoryOptions value=categoryId}}
{{d-button action="refreshReport" class="btn-primary" label="admin.dashboard.reports.refresh_report" icon="refresh"}}
+ {{d-button action="exportCsv" label="admin.export_csv.button_text"}}
diff --git a/app/assets/javascripts/discourse/components/popup-menu.js.es6 b/app/assets/javascripts/discourse/components/popup-menu.js.es6
new file mode 100644
index 00000000000..1f5de232ae6
--- /dev/null
+++ b/app/assets/javascripts/discourse/components/popup-menu.js.es6
@@ -0,0 +1,45 @@
+import { on } from 'ember-addons/ember-computed-decorators';
+
+export default Ember.Component.extend({
+ classNameBindings: ["visible::hidden", ":popup-menu"],
+
+ @on('didInsertElement')
+ _setup() {
+ this.appEvents.on("popup-menu:open", this, "_changeLocation");
+
+ $('html').on(`mouseup.popup-menu-${this.get('elementId')}`, (e) => {
+ const $target = $(e.target);
+ if ($target.is("button") || this.$().has($target).length === 0) {
+ this.sendAction('hide');
+ }
+ });
+ },
+
+ @on('willDestroyElement')
+ _cleanup() {
+ $('html').off(`mouseup.popup-menu-${this.get('elementId')}`);
+ this.appEvents.off("popup-menu:open");
+ },
+
+ _changeLocation(location) {
+ const $this = this.$();
+ switch (location.position) {
+ case "absolute": {
+ $this.css({
+ position: "absolute",
+ top: location.top - $this.innerHeight() + 5,
+ left: location.left,
+ });
+ break;
+ }
+ case "fixed": {
+ $this.css({
+ position: "fixed",
+ top: location.top,
+ left: location.left - $this.innerWidth(),
+ });
+ break;
+ }
+ }
+ }
+});
diff --git a/app/assets/javascripts/discourse/components/post-menu.js.es6 b/app/assets/javascripts/discourse/components/post-menu.js.es6
index 33800387f2c..9981c5330bc 100644
--- a/app/assets/javascripts/discourse/components/post-menu.js.es6
+++ b/app/assets/javascripts/discourse/components/post-menu.js.es6
@@ -369,13 +369,13 @@ const PostMenuComponent = Ember.Component.extend(StringBuffer, {
unhidePostIcon = iconHTML('eye'),
unhidePostText = I18n.t('post.controls.unhide');
- const html = '