Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit e5e4d13

Browse files
author
Akanksh Saxena
authored
Merge pull request #419 from aziiee/export_limit
Fix(analysis): Set limit for reports export
2 parents 74aff5d + 5c85af5 commit e5e4d13

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

app/analysis/index/controller.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,18 @@ const AnalysisController = Controller.extend(AnalysisQueryParams.Mixin, {
184184
}
185185
),
186186

187+
exportLimitExceeded: computed("totalItems", function() {
188+
return this.totalItems > this.exportLimit;
189+
}),
190+
191+
exportLimitMessage: computed("exportLimit", function() {
192+
return `The export limit is ${this.exportLimit}. Please use filters to reduce the amount of reports.`;
193+
}),
194+
187195
exportLinks: config.APP.REPORTEXPORTS,
188196

197+
exportLimit: config.APP.EXPORT_LIMIT,
198+
189199
session: service("session"),
190200

191201
notify: service("notify"),

app/analysis/index/template.hbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@
305305
type="button"
306306
data-download-count="{{download.performCount}}"
307307
class="btn btn-primary {{if (and (eq download.last.url link.url) (eq download.last.params link.params) download.isRunning) 'loading'}}"
308+
disabled={{exportLimitExceeded}}
309+
title={{if exportLimitExceeded exportLimitMessage}}
308310
>
309311
{{fa-icon 'download'}} {{link.label}}
310312
</button>

config/environment.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ module.exports = function(environment) {
4444
url: "/api/v1/work-reports",
4545
params: {}
4646
}
47-
]
47+
],
48+
EXPORT_LIMIT: 100000
4849
},
4950

5051
"ember-simple-auth": {

tests/acceptance/analysis-test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { setupApplicationTest } from "ember-qunit";
1111
import { authenticateSession } from "ember-simple-auth/test-support";
1212
import { module, test } from "qunit";
1313

14+
import config from "../../config/environment";
1415
import userSelect from "../helpers/user-select";
1516

1617
module("Acceptance | analysis", function(hooks) {
@@ -42,6 +43,19 @@ module("Acceptance | analysis", function(hooks) {
4243
assert.dom('[data-download-count="1"]').exists();
4344
});
4445

46+
test("disables buttons if export limit exceeded", async function(assert) {
47+
this.server.get("/reports", function({ reports }) {
48+
return {
49+
...this.serialize(reports.all()),
50+
meta: { pagination: { count: config.APP.EXPORT_LIMIT + 1 } }
51+
};
52+
});
53+
54+
await visit("/analysis");
55+
56+
assert.dom(".export-buttons .btn:first-child").isDisabled();
57+
});
58+
4559
test("can filter and reset filter", async function(assert) {
4660
await visit("/analysis");
4761

0 commit comments

Comments
 (0)