Skip to content

Commit

Permalink
[SDESK-5234] Hide Analytics menu if no reports available (#126)
Browse files Browse the repository at this point in the history
* [SDESK-5234] Hide Analytics menu if no reports available

* Fix unit test
  • Loading branch information
MarkLark86 authored May 12, 2020
1 parent 6ae499a commit 8f08b02
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 3 additions & 0 deletions client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,8 @@ export default angular.module('superdesk.analytics', [
priority: 100,
adminTools: false,
filters: [],
additionalCondition: ['reports', function(reports) {
return reports.length > 0;
}],
});
}]);
6 changes: 5 additions & 1 deletion client/services/ReportsProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,17 @@ export function ReportsProvider(_) {
));
};

return _.sortBy(
const filteredReports = _.sortBy(
_.filter(
_.values(reports),
filterReport
),
'priority'
);

// First entry is an empty entry, so if there is only 1 report registered
// then there are no actual reports available;
return filteredReports.length === 1 ? [] : filteredReports;
}];

this.addReport({id: null, priority: 0});
Expand Down
8 changes: 1 addition & 7 deletions client/services/tests/ReportProvider.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,7 @@ describe('reportsProvider', () => {
});

it('default values', () => {
expect(reports).toEqual([{
id: null,
priority: 0,
privileges: {},
showSidePanel: true,
allowScheduling: false,
}]);
expect(reports).toEqual([]);
});
});

Expand Down

0 comments on commit 8f08b02

Please sign in to comment.