Commit 56073cfd137e5abfd506998e57df17ed03117175

Authored by Leandro Santos
1 parent ea43a611

refactoring profile image block

src/app/layout/blocks/profile-image-block/index.ts
@@ -1,2 +0,0 @@ @@ -1,2 +0,0 @@
1 -/* Module Index Entry - generated using the script npm run generate-index */  
2 -export * from "./profile-image-block.component";  
src/app/layout/blocks/profile-image-block/profile-image-block.component.spec.ts
@@ -1,46 +0,0 @@ @@ -1,46 +0,0 @@
1 -import {TestComponentBuilder, ComponentFixture} from 'ng-forward/cjs/testing/test-component-builder';  
2 -import {Pipe, Input, provide, Component} from 'ng-forward';  
3 -  
4 -import {ProfileImageBlockComponent} from './profile-image-block.component';  
5 -  
6 -import * as helpers from "./../../../../spec/helpers";  
7 -  
8 -const tcb = new TestComponentBuilder();  
9 -  
10 -const htmlTemplate: string = '<noosfero-profile-image-block [block]="ctrl.block" [owner]="ctrl.owner"></noosfero-profile-image-block>';  
11 -  
12 -describe("Components", () => {  
13 -  
14 - describe("Profile Image Block Component", () => {  
15 -  
16 - beforeEach(angular.mock.module("templates"));  
17 -  
18 - @Component({  
19 - selector: 'test-container-component',  
20 - template: htmlTemplate,  
21 - directives: [ProfileImageBlockComponent],  
22 - providers: helpers.provideFilters("translateFilter")  
23 - })  
24 - class BlockContainerComponent {  
25 - block = { type: 'Block' };  
26 - owner = { name: 'profile-name' };  
27 - constructor() {  
28 - }  
29 - }  
30 -  
31 - it("show image if present", () => {  
32 - helpers.tcb.createAsync(BlockContainerComponent).then(fixture => {  
33 - let elProfile = fixture.debugElement.componentViewChildren[0];  
34 - expect(elProfile.query('div.profile-image-block').length).toEqual(1);  
35 - });  
36 - });  
37 -  
38 - it("has link to the profile", () => {  
39 - helpers.tcb.createAsync(BlockContainerComponent).then(fixture => {  
40 - let elProfile = fixture.debugElement.componentViewChildren[0];  
41 - expect(elProfile.query('a.settings-link').length).toEqual(1);  
42 - });  
43 - });  
44 -  
45 - });  
46 -});  
src/app/layout/blocks/profile-image-block/profile-image-block.component.ts
@@ -1,14 +0,0 @@ @@ -1,14 +0,0 @@
1 -import {Inject, Input, Component} from "ng-forward";  
2 -import {ProfileImageComponent} from "./../../../profile/image/image.component";  
3 -  
4 -@Component({  
5 - selector: "noosfero-profile-image-block",  
6 - templateUrl: 'app/layout/blocks/profile-image-block/profile-image-block.html',  
7 - directives: [ProfileImageComponent]  
8 -})  
9 -export class ProfileImageBlockComponent {  
10 -  
11 - @Input() block: noosfero.Block;  
12 - @Input() owner: noosfero.Profile;  
13 -  
14 -}  
src/app/layout/blocks/profile-image-block/profile-image-block.html
@@ -1,6 +0,0 @@ @@ -1,6 +0,0 @@
1 -<div class="center-block text-center profile-image-block">  
2 - <a ui-sref="main.profile.info({profile: ctrl.owner.identifier})">  
3 - <noosfero-profile-image [profile]="ctrl.owner"></noosfero-profile-image>  
4 - </a>  
5 - <a class="settings-link" target="_self" ui-sref="main.profile.settings({profile: ctrl.owner.identifier})">{{"blocks.profile_image.control_panel" | translate}}</a>  
6 -</div>  
src/app/layout/blocks/profile-image-block/profile-image-block.scss
@@ -1,5 +0,0 @@ @@ -1,5 +0,0 @@
1 -.profile-image-block {  
2 - .settings-link {  
3 - display: block;  
4 - }  
5 -}  
src/app/layout/blocks/profile-image/index.ts 0 → 100644
@@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
  1 +/* Module Index Entry - generated using the script npm run generate-index */
  2 +export * from "./profile-image-block.component";
src/app/layout/blocks/profile-image/profile-image-block.component.spec.ts 0 → 100644
@@ -0,0 +1,46 @@ @@ -0,0 +1,46 @@
  1 +import {TestComponentBuilder, ComponentFixture} from 'ng-forward/cjs/testing/test-component-builder';
  2 +import {Pipe, Input, provide, Component} from 'ng-forward';
  3 +
  4 +import {ProfileImageBlockComponent} from './profile-image-block.component';
  5 +
  6 +import * as helpers from "./../../../../spec/helpers";
  7 +
  8 +const tcb = new TestComponentBuilder();
  9 +
  10 +const htmlTemplate: string = '<noosfero-profile-image-block [block]="ctrl.block" [owner]="ctrl.owner"></noosfero-profile-image-block>';
  11 +
  12 +describe("Components", () => {
  13 +
  14 + describe("Profile Image Block Component", () => {
  15 +
  16 + beforeEach(angular.mock.module("templates"));
  17 +
  18 + @Component({
  19 + selector: 'test-container-component',
  20 + template: htmlTemplate,
  21 + directives: [ProfileImageBlockComponent],
  22 + providers: helpers.provideFilters("translateFilter")
  23 + })
  24 + class BlockContainerComponent {
  25 + block = { type: 'Block' };
  26 + owner = { name: 'profile-name' };
  27 + constructor() {
  28 + }
  29 + }
  30 +
  31 + it("show image if present", () => {
  32 + helpers.tcb.createAsync(BlockContainerComponent).then(fixture => {
  33 + let elProfile = fixture.debugElement.componentViewChildren[0];
  34 + expect(elProfile.query('div.profile-image-block').length).toEqual(1);
  35 + });
  36 + });
  37 +
  38 + it("has link to the profile", () => {
  39 + helpers.tcb.createAsync(BlockContainerComponent).then(fixture => {
  40 + let elProfile = fixture.debugElement.componentViewChildren[0];
  41 + expect(elProfile.query('a.settings-link').length).toEqual(1);
  42 + });
  43 + });
  44 +
  45 + });
  46 +});
src/app/layout/blocks/profile-image/profile-image-block.component.ts 0 → 100644
@@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
  1 +import {Inject, Input, Component} from "ng-forward";
  2 +import {ProfileImageComponent} from "./../../../profile/image/image.component";
  3 +
  4 +@Component({
  5 + selector: "noosfero-profile-image-block",
  6 + templateUrl: 'app/layout/blocks/profile-image/profile-image-block.html',
  7 + directives: [ProfileImageComponent]
  8 +})
  9 +export class ProfileImageBlockComponent {
  10 +
  11 + @Input() block: noosfero.Block;
  12 + @Input() owner: noosfero.Profile;
  13 +
  14 +}
src/app/layout/blocks/profile-image/profile-image-block.html 0 → 100644
@@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
  1 +<div class="center-block text-center profile-image-block">
  2 + <a ui-sref="main.profile.info({profile: ctrl.owner.identifier})">
  3 + <noosfero-profile-image [profile]="ctrl.owner"></noosfero-profile-image>
  4 + </a>
  5 + <a class="settings-link" target="_self" ui-sref="main.profile.settings({profile: ctrl.owner.identifier})">{{"blocks.profile_image.control_panel" | translate}}</a>
  6 +</div>
src/app/layout/blocks/profile-image/profile-image-block.scss 0 → 100644
@@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
  1 +.profile-image-block {
  2 + .settings-link {
  3 + display: block;
  4 + }
  5 +}
src/app/main/main.component.ts
@@ -12,7 +12,7 @@ import {EnvironmentHomeComponent} from &quot;../environment/environment-home.componen @@ -12,7 +12,7 @@ import {EnvironmentHomeComponent} from &quot;../environment/environment-home.componen
12 import {PeopleBlockComponent} from "../layout/blocks/people/people-block.component"; 12 import {PeopleBlockComponent} from "../layout/blocks/people/people-block.component";
13 import {LinkListBlockComponent} from "./../layout/blocks/link-list/link-list-block.component"; 13 import {LinkListBlockComponent} from "./../layout/blocks/link-list/link-list-block.component";
14 import {RecentDocumentsBlockComponent} from "../layout/blocks/recent-documents/recent-documents.component"; 14 import {RecentDocumentsBlockComponent} from "../layout/blocks/recent-documents/recent-documents.component";
15 -import {ProfileImageBlockComponent} from "../layout/blocks/profile-image-block/profile-image-block.component"; 15 +import {ProfileImageBlockComponent} from "../layout/blocks/profile-image/profile-image-block.component";
16 import {RawHTMLBlockComponent} from "../layout/blocks/raw-html/raw-html.component"; 16 import {RawHTMLBlockComponent} from "../layout/blocks/raw-html/raw-html.component";
17 17
18 import {MembersBlockComponent} from "./../layout/blocks/members/members-block.component"; 18 import {MembersBlockComponent} from "./../layout/blocks/members/members-block.component";