Commit ba519042afe9eb7dc1b69303dbaa5746538b52ca
1 parent
d00c6e8c
Exists in
master
and in
10 other branches
Display button to export comments only to users with permission to edit article
Showing
2 changed files
with
11 additions
and
5 deletions
Show diff stats
src/plugins/comment_paragraph/hotspot/export-comment-button.component.spec.ts
@@ -3,15 +3,16 @@ import {ComponentTestHelper, createClass} from '../../../spec/component-test-hel | @@ -3,15 +3,16 @@ import {ComponentTestHelper, createClass} from '../../../spec/component-test-hel | ||
3 | import * as helpers from "../../../spec/helpers"; | 3 | import * as helpers from "../../../spec/helpers"; |
4 | import {Provider} from 'ng-forward'; | 4 | import {Provider} from 'ng-forward'; |
5 | import {ComponentFixture} from 'ng-forward/cjs/testing/test-component-builder'; | 5 | import {ComponentFixture} from 'ng-forward/cjs/testing/test-component-builder'; |
6 | +import {PermissionDirective} from '../../../app/shared/components/permission/permission.directive'; | ||
6 | 7 | ||
7 | let htmlTemplate = '<export-comment-button-hotspot [article]="ctrl.article"></export-comment-button-hotspot>'; | 8 | let htmlTemplate = '<export-comment-button-hotspot [article]="ctrl.article"></export-comment-button-hotspot>'; |
8 | 9 | ||
9 | describe("Components", () => { | 10 | describe("Components", () => { |
10 | describe("Export Comment Button Hotspot Component", () => { | 11 | describe("Export Comment Button Hotspot Component", () => { |
11 | 12 | ||
12 | - let serviceMock = jasmine.createSpyObj("CommentParagraphService", [ "getArticle" ]); | 13 | + let serviceMock = jasmine.createSpyObj("CommentParagraphService", ["getArticle"]); |
13 | 14 | ||
14 | - let providers = [ new Provider('CommentParagraphService', { useValue: serviceMock }) ] | 15 | + let providers = [new Provider('CommentParagraphService', { useValue: serviceMock })] |
15 | .concat(helpers.provideFilters('translateFilter')); | 16 | .concat(helpers.provideFilters('translateFilter')); |
16 | let helper: ComponentTestHelper<ExportCommentButtonHotspotComponent>; | 17 | let helper: ComponentTestHelper<ExportCommentButtonHotspotComponent>; |
17 | 18 | ||
@@ -20,7 +21,7 @@ describe("Components", () => { | @@ -20,7 +21,7 @@ describe("Components", () => { | ||
20 | beforeEach((done) => { | 21 | beforeEach((done) => { |
21 | let cls = createClass({ | 22 | let cls = createClass({ |
22 | template: htmlTemplate, | 23 | template: htmlTemplate, |
23 | - directives: [ExportCommentButtonHotspotComponent], | 24 | + directives: [ExportCommentButtonHotspotComponent, PermissionDirective], |
24 | providers: providers, | 25 | providers: providers, |
25 | properties: { | 26 | properties: { |
26 | article: {} | 27 | article: {} |
@@ -48,5 +49,10 @@ describe("Components", () => { | @@ -48,5 +49,10 @@ describe("Components", () => { | ||
48 | expect(helper.all('.export-comment-button').length).toEqual(0); | 49 | expect(helper.all('.export-comment-button').length).toEqual(0); |
49 | }); | 50 | }); |
50 | 51 | ||
52 | + it('not display export comment button when user does not have permission', () => { | ||
53 | + helper.component.article = <noosfero.Article>{ setting: { comment_paragraph_plugin_activate: true } }; | ||
54 | + helper.detectChanges(); | ||
55 | + expect(helper.find('.export-comment-button').attr('style')).toEqual("display: none; "); | ||
56 | + }); | ||
51 | }); | 57 | }); |
52 | }); | 58 | }); |
src/plugins/comment_paragraph/hotspot/export-comment-button.html
1 | <a href='{{ctrl.exportCommentPath}}' target="_self" | 1 | <a href='{{ctrl.exportCommentPath}}' target="_self" |
2 | - class="btn btn-default btn-xs export-comment-button" ng-if="ctrl.isActivated()"> | 2 | + class="btn btn-default btn-xs export-comment-button" ng-if="ctrl.isActivated()" |
3 | + permission="ctrl.article.permissions" permission-action="allow_edit"> | ||
3 | <i class="fa fa-fw fa-download"></i> {{"comment-paragraph-plugin.export" | translate}} | 4 | <i class="fa fa-fw fa-download"></i> {{"comment-paragraph-plugin.export" | translate}} |
4 | </a> | 5 | </a> |
5 | - |