From 09f76648fa91d81e4db5ea6854f8efbe2e722aae Mon Sep 17 00:00:00 2001 From: Matthew White Date: Fri, 9 Aug 2019 14:59:47 -0400 Subject: [PATCH 1/3] Fix overflow of audit log entry details in Firefox --- src/components/audit/row.vue | 8 ++++++-- test/components/audit/table.spec.js | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/audit/row.vue b/src/components/audit/row.vue index c6835baee..a0a4946b9 100644 --- a/src/components/audit/row.vue +++ b/src/components/audit/row.vue @@ -35,7 +35,11 @@ except according to the terms contained in the LICENSE file. {{ targetTitle }} - {{ details }} + + +
{{ details }}
+ @@ -166,7 +170,7 @@ export default { white-space: nowrap; } - .details { + .details div { font-family: $font-family-monospace; overflow-x: auto; white-space: nowrap; diff --git a/test/components/audit/table.spec.js b/test/components/audit/table.spec.js index 97ddad40b..896b8837b 100644 --- a/test/components/audit/table.spec.js +++ b/test/components/audit/table.spec.js @@ -204,10 +204,10 @@ describe('AuditTable', () => { details: { some: 'json' } }) .sorted()) - .afterResponse(app => trigger.click(app, '.audit-row .details')) + .afterResponse(app => trigger.click(app, '.audit-row .details div')) .then(() => { const selection = window.getSelection(); - const details = document.querySelector('.audit-row .details'); + const details = document.querySelector('.audit-row .details div'); selection.anchorNode.should.equal(details); selection.focusNode.should.equal(details); })); From 5958ef99833935d190a85191f81d0fca71275725 Mon Sep 17 00:00:00 2001 From: Matthew White Date: Fri, 9 Aug 2019 16:32:42 -0400 Subject: [PATCH 2/3] Do not send request if same date range is selected --- src/components/audit/filters.vue | 19 +++++++++++++++---- test/components/audit/filters.spec.js | 17 +++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/components/audit/filters.vue b/src/components/audit/filters.vue index bb15c4b49..25149c7ec 100644 --- a/src/components/audit/filters.vue +++ b/src/components/audit/filters.vue @@ -91,15 +91,26 @@ export default { filter() { this.$emit('filter', { action: this.action, dateRange: this.dateRange }); }, + sameDateRange(range1, range2) { + return range1[0].valueOf() === range2[0].valueOf() && + range1[1].valueOf() === range2[1].valueOf(); + }, closeCalendar(dates) { if (dates.length !== 0) { - this.dateRange = dates.map(date => DateTime.fromJSDate(date)); + const dateRange = dates.map(date => DateTime.fromJSDate(date)); + if (!this.sameDateRange(dateRange, this.dateRange)) { + this.dateRange = dateRange; + this.filter(); + } } else { const today = DateTime.local().startOf('day'); - this.dateRange = [today, today]; - this.dateRangeString = this.dateRangeToString(this.dateRange); + const dateRange = [today, today]; + if (!this.sameDateRange(dateRange, this.dateRange)) { + this.dateRange = dateRange; + this.dateRangeString = this.dateRangeToString(dateRange); + this.filter(); + } } - this.filter(); } } }; diff --git a/test/components/audit/filters.spec.js b/test/components/audit/filters.spec.js index 495067907..5b4389800 100644 --- a/test/components/audit/filters.spec.js +++ b/test/components/audit/filters.spec.js @@ -128,4 +128,21 @@ describe('AuditFilters', () => { .respondWithData(() => testData.extendedAudits.sorted()) .finally(restoreLuxon); }); + + it('does not send a request if the same date range is selected', () => { + const restoreLuxon = setLuxon({ + defaultZoneName: 'utc', + now: '1970-01-01T12:00:00Z' + }); + return mockHttp() + .mount(AuditList) + .respondWithData(() => testData.extendedAudits.sorted()) + .complete() + .request(component => { + const date = DateTime.fromISO('1970-01-01').toJSDate(); + component.first(AuditFilters).vm.closeCalendar([date, date]); + }) + .respondWithData([/* no responses */]) + .finally(restoreLuxon); + }); }); From 92bbdfcfa647c427397ae3c8d8f1d29074c9b9bb Mon Sep 17 00:00:00 2001 From: Matthew White Date: Tue, 13 Aug 2019 23:04:40 -0400 Subject: [PATCH 3/3] Always set this.dateRangeString when date range is cleared --- src/components/audit/filters.vue | 32 +++++++++++++-------------- test/components/audit/filters.spec.js | 23 +++++++++++++++++++ 2 files changed, 38 insertions(+), 17 deletions(-) diff --git a/src/components/audit/filters.vue b/src/components/audit/filters.vue index 25149c7ec..eef955ca8 100644 --- a/src/components/audit/filters.vue +++ b/src/components/audit/filters.vue @@ -91,26 +91,24 @@ export default { filter() { this.$emit('filter', { action: this.action, dateRange: this.dateRange }); }, - sameDateRange(range1, range2) { - return range1[0].valueOf() === range2[0].valueOf() && - range1[1].valueOf() === range2[1].valueOf(); + todayToToday() { + const today = DateTime.local().startOf('day'); + return [today, today]; }, closeCalendar(dates) { - if (dates.length !== 0) { - const dateRange = dates.map(date => DateTime.fromJSDate(date)); - if (!this.sameDateRange(dateRange, this.dateRange)) { - this.dateRange = dateRange; - this.filter(); - } - } else { - const today = DateTime.local().startOf('day'); - const dateRange = [today, today]; - if (!this.sameDateRange(dateRange, this.dateRange)) { - this.dateRange = dateRange; - this.dateRangeString = this.dateRangeToString(dateRange); - this.filter(); - } + const dateRange = dates.length !== 0 + ? dates.map(date => DateTime.fromJSDate(date)) + : this.todayToToday(); + if (dateRange[0].valueOf() !== this.dateRange[0].valueOf() || + dateRange[1].valueOf() !== this.dateRange[1].valueOf()) { + this.dateRange = dateRange; + this.filter(); } + // If the date range is cleared, this.dateRangeString will be empty, and + // we will need to reset it (regardless of whether this.dateRange + // changed). + if (dates.length === 0) + this.dateRangeString = this.dateRangeToString(dateRange); } } }; diff --git a/test/components/audit/filters.spec.js b/test/components/audit/filters.spec.js index 5b4389800..df17987cb 100644 --- a/test/components/audit/filters.spec.js +++ b/test/components/audit/filters.spec.js @@ -134,15 +134,38 @@ describe('AuditFilters', () => { defaultZoneName: 'utc', now: '1970-01-01T12:00:00Z' }); + let called = false; return mockHttp() .mount(AuditList) .respondWithData(() => testData.extendedAudits.sorted()) .complete() + // Select the same date range. .request(component => { const date = DateTime.fromISO('1970-01-01').toJSDate(); component.first(AuditFilters).vm.closeCalendar([date, date]); }) .respondWithData([/* no responses */]) + .complete() + // Clear the date range (defaulting to the same date range). + .request(component => { + const auditFilters = component.first(AuditFilters); + const { dateRangeToString } = auditFilters.vm; + auditFilters.setMethods({ + dateRangeToString: (dateRange) => { + called = true; + return dateRangeToString(dateRange); + } + }); + return auditFilters.vm.$nextTick().then(() => { + auditFilters.vm.closeCalendar([]); + }); + }) + .respondWithData([/* no responses */]) + .then(() => { + // The date range has not changed, but the dateRangeString property + // still should have been reset. + called.should.be.true(); + }) .finally(restoreLuxon); }); });