Commit 0e907d92b145685166bfdfe2ebbfa32dd47f81e4
1 parent
3257e170
Exists in
master
and in
26 other branches
Remove article button from comment paragraph
Showing
4 changed files
with
1 additions
and
133 deletions
Show diff stats
src/plugins/comment_paragraph/hotspot/comment-paragraph-article-button.component.spec.ts
@@ -1,85 +0,0 @@ | @@ -1,85 +0,0 @@ | ||
1 | -import {CommentParagraphArticleButtonHotspotComponent} from "./comment-paragraph-article-button.component"; | ||
2 | -import {ComponentTestHelper, createClass} from '../../../spec/component-test-helper'; | ||
3 | -import * as helpers from "../../../spec/helpers"; | ||
4 | -import {Provider} from 'ng-forward'; | ||
5 | -import {ComponentFixture} from 'ng-forward/cjs/testing/test-component-builder'; | ||
6 | - | ||
7 | -let htmlTemplate = '<comment-paragraph-article-button-hotspot [article]="ctrl.article"></comment-paragraph-article-button-hotspot>'; | ||
8 | - | ||
9 | -describe("Components", () => { | ||
10 | - describe("Comment Paragraph Article Button Hotspot Component", () => { | ||
11 | - | ||
12 | - let serviceMock = jasmine.createSpyObj("CommentParagraphService", ["deactivateCommentParagraph", "activateCommentParagraph"]); | ||
13 | - let eventServiceMock = jasmine.createSpyObj("CommentParagraphEventService", ["toggleCommentParagraph"]); | ||
14 | - | ||
15 | - let providers = [ | ||
16 | - new Provider('CommentParagraphService', { useValue: serviceMock }), | ||
17 | - new Provider('CommentParagraphEventService', { useValue: eventServiceMock }) | ||
18 | - ].concat(helpers.provideFilters('translateFilter')); | ||
19 | - let helper: ComponentTestHelper<CommentParagraphArticleButtonHotspotComponent>; | ||
20 | - | ||
21 | - beforeEach(angular.mock.module("templates")); | ||
22 | - | ||
23 | - beforeEach((done) => { | ||
24 | - let cls = createClass({ | ||
25 | - template: htmlTemplate, | ||
26 | - directives: [CommentParagraphArticleButtonHotspotComponent], | ||
27 | - providers: providers, | ||
28 | - properties: { | ||
29 | - article: {} | ||
30 | - } | ||
31 | - }); | ||
32 | - helper = new ComponentTestHelper<CommentParagraphArticleButtonHotspotComponent>(cls, done); | ||
33 | - }); | ||
34 | - | ||
35 | - it('emit event when deactivate comment paragraph in an article', () => { | ||
36 | - serviceMock.deactivateCommentParagraph = jasmine.createSpy("deactivateCommentParagraph").and.returnValue( | ||
37 | - { then: (fn: Function) => { fn({ data: {} }); } } | ||
38 | - ); | ||
39 | - eventServiceMock.toggleCommentParagraph = jasmine.createSpy("toggleCommentParagraph"); | ||
40 | - helper.component.deactivateCommentParagraph(); | ||
41 | - | ||
42 | - expect(serviceMock.deactivateCommentParagraph).toHaveBeenCalled(); | ||
43 | - expect(eventServiceMock.toggleCommentParagraph).toHaveBeenCalled(); | ||
44 | - }); | ||
45 | - | ||
46 | - it('emit event when activate comment paragraph in an article', () => { | ||
47 | - serviceMock.activateCommentParagraph = jasmine.createSpy("activateCommentParagraph").and.returnValue( | ||
48 | - { then: (fn: Function) => { fn({ data: {} }); } } | ||
49 | - ); | ||
50 | - eventServiceMock.toggleCommentParagraph = jasmine.createSpy("toggleCommentParagraph"); | ||
51 | - helper.component.activateCommentParagraph(); | ||
52 | - | ||
53 | - expect(serviceMock.activateCommentParagraph).toHaveBeenCalled(); | ||
54 | - expect(eventServiceMock.toggleCommentParagraph).toHaveBeenCalled(); | ||
55 | - }); | ||
56 | - | ||
57 | - it('return true when comment paragraph is active', () => { | ||
58 | - helper.component.article = <noosfero.Article>{ setting: { comment_paragraph_plugin_activate: true } }; | ||
59 | - helper.detectChanges(); | ||
60 | - expect(helper.component.isActivated()).toBeTruthy(); | ||
61 | - }); | ||
62 | - | ||
63 | - it('return false when comment paragraph is not active', () => { | ||
64 | - expect(helper.component.isActivated()).toBeFalsy(); | ||
65 | - }); | ||
66 | - | ||
67 | - it('return false when article has no setting attribute', () => { | ||
68 | - helper.component.article = <noosfero.Article>{}; | ||
69 | - helper.detectChanges(); | ||
70 | - expect(helper.component.isActivated()).toBeFalsy(); | ||
71 | - }); | ||
72 | - | ||
73 | - it('display activate button when comment paragraph is not active', () => { | ||
74 | - expect(helper.all('.comment-paragraph-activate').length).toEqual(1); | ||
75 | - expect(helper.all('.comment-paragraph-deactivate').length).toEqual(0); | ||
76 | - }); | ||
77 | - | ||
78 | - it('display deactivate button when comment paragraph is active', () => { | ||
79 | - helper.component.article = <noosfero.Article>{ setting: { comment_paragraph_plugin_activate: true } }; | ||
80 | - helper.detectChanges(); | ||
81 | - expect(helper.all('.comment-paragraph-deactivate').length).toEqual(1); | ||
82 | - expect(helper.all('.comment-paragraph-activate').length).toEqual(0); | ||
83 | - }); | ||
84 | - }); | ||
85 | -}); |
src/plugins/comment_paragraph/hotspot/comment-paragraph-article-button.component.ts
@@ -1,38 +0,0 @@ | @@ -1,38 +0,0 @@ | ||
1 | -import { Input, Inject, Component } from "ng-forward"; | ||
2 | -import {Hotspot} from "../../../app/hotspot/hotspot.decorator"; | ||
3 | -import {CommentParagraphService} from "../http/comment-paragraph.service"; | ||
4 | -import {CommentParagraphEventService} from "../events/comment-paragraph-event.service"; | ||
5 | - | ||
6 | -@Component({ | ||
7 | - selector: "comment-paragraph-article-button-hotspot", | ||
8 | - templateUrl: "plugins/comment_paragraph/hotspot/comment-paragraph-article-button.html", | ||
9 | -}) | ||
10 | -@Inject("$scope", CommentParagraphService, CommentParagraphEventService) | ||
11 | -@Hotspot("article_extra_toolbar_buttons") | ||
12 | -export class CommentParagraphArticleButtonHotspotComponent { | ||
13 | - | ||
14 | - @Input() article: noosfero.Article; | ||
15 | - | ||
16 | - constructor(private $scope: ng.IScope, | ||
17 | - private commentParagraphService: CommentParagraphService, | ||
18 | - private commentParagraphEventService: CommentParagraphEventService) { } | ||
19 | - | ||
20 | - deactivateCommentParagraph() { | ||
21 | - this.toggleCommentParagraph(this.commentParagraphService.deactivateCommentParagraph(this.article)); | ||
22 | - } | ||
23 | - | ||
24 | - activateCommentParagraph() { | ||
25 | - this.toggleCommentParagraph(this.commentParagraphService.activateCommentParagraph(this.article)); | ||
26 | - } | ||
27 | - | ||
28 | - isActivated() { | ||
29 | - return this.article && this.article.setting && this.article.setting.comment_paragraph_plugin_activate; | ||
30 | - } | ||
31 | - | ||
32 | - private toggleCommentParagraph(promise: ng.IPromise<noosfero.RestResult<noosfero.Article>>) { | ||
33 | - promise.then((result: noosfero.RestResult<noosfero.Article>) => { | ||
34 | - this.article = result.data; | ||
35 | - this.commentParagraphEventService.toggleCommentParagraph(this.article); | ||
36 | - }); | ||
37 | - } | ||
38 | -} |
src/plugins/comment_paragraph/hotspot/comment-paragraph-article-button.html
@@ -1,8 +0,0 @@ | @@ -1,8 +0,0 @@ | ||
1 | -<a href='#' class="btn btn-default btn-xs comment-paragraph-activate" (click)="ctrl.activateCommentParagraph()" | ||
2 | - ng-if="!ctrl.article.setting.comment_paragraph_plugin_activate"> | ||
3 | - <i class="fa fa-fw fa-plus"></i> {{"comment-paragraph-plugin.title" | translate}} | ||
4 | -</a> | ||
5 | -<a href='#' class="btn btn-default btn-xs comment-paragraph-deactivate" (click)="ctrl.deactivateCommentParagraph()" | ||
6 | - ng-if="ctrl.article.setting.comment_paragraph_plugin_activate"> | ||
7 | - <i class="fa fa-fw fa-minus"></i> {{"comment-paragraph-plugin.title" | translate}} | ||
8 | -</a> |
src/plugins/comment_paragraph/index.ts
1 | import {AllowCommentComponent} from "./allow-comment/allow-comment.component"; | 1 | import {AllowCommentComponent} from "./allow-comment/allow-comment.component"; |
2 | -import {CommentParagraphArticleButtonHotspotComponent} from "./hotspot/comment-paragraph-article-button.component"; | ||
3 | import {CommentParagraphFormHotspotComponent} from "./hotspot/comment-paragraph-form.component"; | 2 | import {CommentParagraphFormHotspotComponent} from "./hotspot/comment-paragraph-form.component"; |
4 | import {DiscussionEditorComponent} from "./article/cms/discussion-editor/discussion-editor.component"; | 3 | import {DiscussionEditorComponent} from "./article/cms/discussion-editor/discussion-editor.component"; |
5 | import {CommentParagraphArticleContentHotspotComponent} from "./hotspot/article-content/article-content.component"; | 4 | import {CommentParagraphArticleContentHotspotComponent} from "./hotspot/article-content/article-content.component"; |
6 | import {DiscussionBlockComponent} from "./block/discussion/discussion-block.component"; | 5 | import {DiscussionBlockComponent} from "./block/discussion/discussion-block.component"; |
7 | 6 | ||
8 | export let mainComponents: any = [AllowCommentComponent, DiscussionEditorComponent, DiscussionBlockComponent]; | 7 | export let mainComponents: any = [AllowCommentComponent, DiscussionEditorComponent, DiscussionBlockComponent]; |
9 | -export let hotspots: any = [CommentParagraphArticleButtonHotspotComponent, CommentParagraphFormHotspotComponent, CommentParagraphArticleContentHotspotComponent]; | 8 | +export let hotspots: any = [CommentParagraphFormHotspotComponent, CommentParagraphArticleContentHotspotComponent]; |