From afb4744a45fb34d7f19395c66f3fc1673d29d755 Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Mon, 1 Aug 2016 14:05:36 -0300 Subject: [PATCH] Do not show join/hide button for person --- src/app/layout/blocks/profile-image/profile-image-block.component.spec.ts | 17 ++++++++++++++--- src/app/layout/blocks/profile-image/profile-image-block.component.ts | 14 +++++++++----- src/app/layout/blocks/profile-image/profile-image-block.html | 6 ++++-- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/app/layout/blocks/profile-image/profile-image-block.component.spec.ts b/src/app/layout/blocks/profile-image/profile-image-block.component.spec.ts index ab5b209..e79e41b 100644 --- a/src/app/layout/blocks/profile-image/profile-image-block.component.spec.ts +++ b/src/app/layout/blocks/profile-image/profile-image-block.component.spec.ts @@ -34,8 +34,7 @@ describe("Components", () => { class BlockContainerComponent { block = { type: 'Block' }; owner = { name: 'profile-name' }; - constructor() { - } + constructor() { } } it("show image if present", () => { @@ -55,7 +54,19 @@ describe("Components", () => { it("display button to join community", (done: Function) => { helpers.tcb.createAsync(BlockContainerComponent).then(fixture => { let elProfile = fixture.debugElement.componentViewChildren[0]; - expect(elProfile.query('.actions .join').length).toEqual(1); + expect(elProfile.componentInstance.displayOrganizationActions()).toBeTruthy(); + expect(elProfile.query('.actions .organization-actions .join').length).toEqual(1); + done(); + }); + }); + + it("not display button to join community for person", (done: Function) => { + helpers.tcb.createAsync(BlockContainerComponent).then(fixture => { + let elProfile = fixture.debugElement.componentViewChildren[0]; + elProfile.componentInstance.owner = { name: 'person-name', type: 'Person' }; + fixture.detectChanges(); + expect(elProfile.componentInstance.displayOrganizationActions()).toBeFalsy(); + expect(elProfile.queryAll('.actions .organization-actions .join').length).toEqual(0); done(); }); }); diff --git a/src/app/layout/blocks/profile-image/profile-image-block.component.ts b/src/app/layout/blocks/profile-image/profile-image-block.component.ts index 0f94c83..73934b0 100644 --- a/src/app/layout/blocks/profile-image/profile-image-block.component.ts +++ b/src/app/layout/blocks/profile-image/profile-image-block.component.ts @@ -1,8 +1,8 @@ -import {Inject, Input, Component} from "ng-forward"; -import {ProfileImageComponent} from "./../../../profile/image/image.component"; -import {ProfileService} from "../../../../lib/ng-noosfero-api/http/profile.service"; -import {SessionService} from "./../../../login"; -import {NotificationService} from "../../../shared/services/notification.service"; +import { Inject, Input, Component } from "ng-forward"; +import { ProfileImageComponent } from "./../../../profile/image/image.component"; +import { ProfileService } from "../../../../lib/ng-noosfero-api/http/profile.service"; +import { SessionService } from "./../../../login"; +import { NotificationService } from "../../../shared/services/notification.service"; @Component({ selector: "noosfero-profile-image-block", @@ -48,4 +48,8 @@ export class ProfileImageBlockComponent { this.loadMembership(); }); } + + displayOrganizationActions() { + return this.owner.type !== 'Person'; + } } diff --git a/src/app/layout/blocks/profile-image/profile-image-block.html b/src/app/layout/blocks/profile-image/profile-image-block.html index d6d01ca..6005aa1 100644 --- a/src/app/layout/blocks/profile-image/profile-image-block.html +++ b/src/app/layout/blocks/profile-image/profile-image-block.html @@ -4,7 +4,9 @@ {{"blocks.profile_image.control_panel" | translate}}
- {{"blocks.profile_image.join" | translate}} - {{"blocks.profile_image.leave" | translate}} +
-- libgit2 0.21.2