Commit afb4744a45fb34d7f19395c66f3fc1673d29d755

Authored by Victor Costa
1 parent d06a730a

Do not show join/hide button for person

src/app/layout/blocks/profile-image/profile-image-block.component.spec.ts
... ... @@ -34,8 +34,7 @@ describe("Components", () => {
34 34 class BlockContainerComponent {
35 35 block = { type: 'Block' };
36 36 owner = { name: 'profile-name' };
37   - constructor() {
38   - }
  37 + constructor() { }
39 38 }
40 39  
41 40 it("show image if present", () => {
... ... @@ -55,7 +54,19 @@ describe("Components", () => {
55 54 it("display button to join community", (done: Function) => {
56 55 helpers.tcb.createAsync(BlockContainerComponent).then(fixture => {
57 56 let elProfile = fixture.debugElement.componentViewChildren[0];
58   - expect(elProfile.query('.actions .join').length).toEqual(1);
  57 + expect(elProfile.componentInstance.displayOrganizationActions()).toBeTruthy();
  58 + expect(elProfile.query('.actions .organization-actions .join').length).toEqual(1);
  59 + done();
  60 + });
  61 + });
  62 +
  63 + it("not display button to join community for person", (done: Function) => {
  64 + helpers.tcb.createAsync(BlockContainerComponent).then(fixture => {
  65 + let elProfile = fixture.debugElement.componentViewChildren[0];
  66 + elProfile.componentInstance.owner = { name: 'person-name', type: 'Person' };
  67 + fixture.detectChanges();
  68 + expect(elProfile.componentInstance.displayOrganizationActions()).toBeFalsy();
  69 + expect(elProfile.queryAll('.actions .organization-actions .join').length).toEqual(0);
59 70 done();
60 71 });
61 72 });
... ...
src/app/layout/blocks/profile-image/profile-image-block.component.ts
1   -import {Inject, Input, Component} from "ng-forward";
2   -import {ProfileImageComponent} from "./../../../profile/image/image.component";
3   -import {ProfileService} from "../../../../lib/ng-noosfero-api/http/profile.service";
4   -import {SessionService} from "./../../../login";
5   -import {NotificationService} from "../../../shared/services/notification.service";
  1 +import { Inject, Input, Component } from "ng-forward";
  2 +import { ProfileImageComponent } from "./../../../profile/image/image.component";
  3 +import { ProfileService } from "../../../../lib/ng-noosfero-api/http/profile.service";
  4 +import { SessionService } from "./../../../login";
  5 +import { NotificationService } from "../../../shared/services/notification.service";
6 6  
7 7 @Component({
8 8 selector: "noosfero-profile-image-block",
... ... @@ -48,4 +48,8 @@ export class ProfileImageBlockComponent {
48 48 this.loadMembership();
49 49 });
50 50 }
  51 +
  52 + displayOrganizationActions() {
  53 + return this.owner.type !== 'Person';
  54 + }
51 55 }
... ...
src/app/layout/blocks/profile-image/profile-image-block.html
... ... @@ -4,7 +4,9 @@
4 4 </a>
5 5 <a class="settings-link" target="_self" ui-sref="main.profile.settings({profile: ctrl.owner.identifier})">{{"blocks.profile_image.control_panel" | translate}}</a>
6 6 <div class="actions" ng-show="ctrl.isMember!=null">
7   - <a ng-if="!ctrl.isMember" ng-click="ctrl.join()" class="btn btn-primary btn-sm join" href="#">{{"blocks.profile_image.join" | translate}}</a>
8   - <a ng-if="ctrl.isMember" ng-click="ctrl.leave()" class="btn btn-warning btn-sm leave" href="#">{{"blocks.profile_image.leave" | translate}}</a>
  7 + <div class="organization-actions" ng-if="ctrl.displayOrganizationActions()">
  8 + <a ng-if="!ctrl.isMember" ng-click="ctrl.join()" class="btn btn-primary btn-sm join" href="#">{{"blocks.profile_image.join" | translate}}</a>
  9 + <a ng-if="ctrl.isMember" ng-click="ctrl.leave()" class="btn btn-warning btn-sm leave" href="#">{{"blocks.profile_image.leave" | translate}}</a>
  10 + </div>
9 11 </div>
10 12 </div>
... ...