From 0e907d92b145685166bfdfe2ebbfa32dd47f81e4 Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Fri, 20 May 2016 09:07:51 -0300 Subject: [PATCH] Remove article button from comment paragraph --- src/plugins/comment_paragraph/hotspot/comment-paragraph-article-button.component.spec.ts | 85 ------------------------------------------------------------------------------------- src/plugins/comment_paragraph/hotspot/comment-paragraph-article-button.component.ts | 38 -------------------------------------- src/plugins/comment_paragraph/hotspot/comment-paragraph-article-button.html | 8 -------- src/plugins/comment_paragraph/index.ts | 3 +-- 4 files changed, 1 insertion(+), 133 deletions(-) delete mode 100644 src/plugins/comment_paragraph/hotspot/comment-paragraph-article-button.component.spec.ts delete mode 100644 src/plugins/comment_paragraph/hotspot/comment-paragraph-article-button.component.ts delete mode 100644 src/plugins/comment_paragraph/hotspot/comment-paragraph-article-button.html diff --git a/src/plugins/comment_paragraph/hotspot/comment-paragraph-article-button.component.spec.ts b/src/plugins/comment_paragraph/hotspot/comment-paragraph-article-button.component.spec.ts deleted file mode 100644 index 6f4ed1b..0000000 --- a/src/plugins/comment_paragraph/hotspot/comment-paragraph-article-button.component.spec.ts +++ /dev/null @@ -1,85 +0,0 @@ -import {CommentParagraphArticleButtonHotspotComponent} from "./comment-paragraph-article-button.component"; -import {ComponentTestHelper, createClass} from '../../../spec/component-test-helper'; -import * as helpers from "../../../spec/helpers"; -import {Provider} from 'ng-forward'; -import {ComponentFixture} from 'ng-forward/cjs/testing/test-component-builder'; - -let htmlTemplate = ''; - -describe("Components", () => { - describe("Comment Paragraph Article Button Hotspot Component", () => { - - let serviceMock = jasmine.createSpyObj("CommentParagraphService", ["deactivateCommentParagraph", "activateCommentParagraph"]); - let eventServiceMock = jasmine.createSpyObj("CommentParagraphEventService", ["toggleCommentParagraph"]); - - let providers = [ - new Provider('CommentParagraphService', { useValue: serviceMock }), - new Provider('CommentParagraphEventService', { useValue: eventServiceMock }) - ].concat(helpers.provideFilters('translateFilter')); - let helper: ComponentTestHelper; - - beforeEach(angular.mock.module("templates")); - - beforeEach((done) => { - let cls = createClass({ - template: htmlTemplate, - directives: [CommentParagraphArticleButtonHotspotComponent], - providers: providers, - properties: { - article: {} - } - }); - helper = new ComponentTestHelper(cls, done); - }); - - it('emit event when deactivate comment paragraph in an article', () => { - serviceMock.deactivateCommentParagraph = jasmine.createSpy("deactivateCommentParagraph").and.returnValue( - { then: (fn: Function) => { fn({ data: {} }); } } - ); - eventServiceMock.toggleCommentParagraph = jasmine.createSpy("toggleCommentParagraph"); - helper.component.deactivateCommentParagraph(); - - expect(serviceMock.deactivateCommentParagraph).toHaveBeenCalled(); - expect(eventServiceMock.toggleCommentParagraph).toHaveBeenCalled(); - }); - - it('emit event when activate comment paragraph in an article', () => { - serviceMock.activateCommentParagraph = jasmine.createSpy("activateCommentParagraph").and.returnValue( - { then: (fn: Function) => { fn({ data: {} }); } } - ); - eventServiceMock.toggleCommentParagraph = jasmine.createSpy("toggleCommentParagraph"); - helper.component.activateCommentParagraph(); - - expect(serviceMock.activateCommentParagraph).toHaveBeenCalled(); - expect(eventServiceMock.toggleCommentParagraph).toHaveBeenCalled(); - }); - - it('return true when comment paragraph is active', () => { - helper.component.article = { setting: { comment_paragraph_plugin_activate: true } }; - helper.detectChanges(); - expect(helper.component.isActivated()).toBeTruthy(); - }); - - it('return false when comment paragraph is not active', () => { - expect(helper.component.isActivated()).toBeFalsy(); - }); - - it('return false when article has no setting attribute', () => { - helper.component.article = {}; - helper.detectChanges(); - expect(helper.component.isActivated()).toBeFalsy(); - }); - - it('display activate button when comment paragraph is not active', () => { - expect(helper.all('.comment-paragraph-activate').length).toEqual(1); - expect(helper.all('.comment-paragraph-deactivate').length).toEqual(0); - }); - - it('display deactivate button when comment paragraph is active', () => { - helper.component.article = { setting: { comment_paragraph_plugin_activate: true } }; - helper.detectChanges(); - expect(helper.all('.comment-paragraph-deactivate').length).toEqual(1); - expect(helper.all('.comment-paragraph-activate').length).toEqual(0); - }); - }); -}); diff --git a/src/plugins/comment_paragraph/hotspot/comment-paragraph-article-button.component.ts b/src/plugins/comment_paragraph/hotspot/comment-paragraph-article-button.component.ts deleted file mode 100644 index dfb4b15..0000000 --- a/src/plugins/comment_paragraph/hotspot/comment-paragraph-article-button.component.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { Input, Inject, Component } from "ng-forward"; -import {Hotspot} from "../../../app/hotspot/hotspot.decorator"; -import {CommentParagraphService} from "../http/comment-paragraph.service"; -import {CommentParagraphEventService} from "../events/comment-paragraph-event.service"; - -@Component({ - selector: "comment-paragraph-article-button-hotspot", - templateUrl: "plugins/comment_paragraph/hotspot/comment-paragraph-article-button.html", -}) -@Inject("$scope", CommentParagraphService, CommentParagraphEventService) -@Hotspot("article_extra_toolbar_buttons") -export class CommentParagraphArticleButtonHotspotComponent { - - @Input() article: noosfero.Article; - - constructor(private $scope: ng.IScope, - private commentParagraphService: CommentParagraphService, - private commentParagraphEventService: CommentParagraphEventService) { } - - deactivateCommentParagraph() { - this.toggleCommentParagraph(this.commentParagraphService.deactivateCommentParagraph(this.article)); - } - - activateCommentParagraph() { - this.toggleCommentParagraph(this.commentParagraphService.activateCommentParagraph(this.article)); - } - - isActivated() { - return this.article && this.article.setting && this.article.setting.comment_paragraph_plugin_activate; - } - - private toggleCommentParagraph(promise: ng.IPromise>) { - promise.then((result: noosfero.RestResult) => { - this.article = result.data; - this.commentParagraphEventService.toggleCommentParagraph(this.article); - }); - } -} diff --git a/src/plugins/comment_paragraph/hotspot/comment-paragraph-article-button.html b/src/plugins/comment_paragraph/hotspot/comment-paragraph-article-button.html deleted file mode 100644 index 03c8735..0000000 --- a/src/plugins/comment_paragraph/hotspot/comment-paragraph-article-button.html +++ /dev/null @@ -1,8 +0,0 @@ - - {{"comment-paragraph-plugin.title" | translate}} - - - {{"comment-paragraph-plugin.title" | translate}} - diff --git a/src/plugins/comment_paragraph/index.ts b/src/plugins/comment_paragraph/index.ts index b4b946b..9dbe755 100644 --- a/src/plugins/comment_paragraph/index.ts +++ b/src/plugins/comment_paragraph/index.ts @@ -1,9 +1,8 @@ import {AllowCommentComponent} from "./allow-comment/allow-comment.component"; -import {CommentParagraphArticleButtonHotspotComponent} from "./hotspot/comment-paragraph-article-button.component"; import {CommentParagraphFormHotspotComponent} from "./hotspot/comment-paragraph-form.component"; import {DiscussionEditorComponent} from "./article/cms/discussion-editor/discussion-editor.component"; import {CommentParagraphArticleContentHotspotComponent} from "./hotspot/article-content/article-content.component"; import {DiscussionBlockComponent} from "./block/discussion/discussion-block.component"; export let mainComponents: any = [AllowCommentComponent, DiscussionEditorComponent, DiscussionBlockComponent]; -export let hotspots: any = [CommentParagraphArticleButtonHotspotComponent, CommentParagraphFormHotspotComponent, CommentParagraphArticleContentHotspotComponent]; +export let hotspots: any = [CommentParagraphFormHotspotComponent, CommentParagraphArticleContentHotspotComponent]; -- libgit2 0.21.2