-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #640 from geonetwork/ME/records-published-by-my-org
Me/dh/records published by my org
- Loading branch information
Showing
30 changed files
with
797 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
describe('my-org', () => { | ||
beforeEach(() => { | ||
cy.loginGN('barbie', 'p4ssworD_', false) | ||
cy.visit(`/records/my-org`) | ||
cy.get('md-editor-dashboard-menu').find('a').first().click() | ||
cy.get('main').children('div').first().children('div').eq(1).as('linkGroup') | ||
}) | ||
describe('my-org display', () => { | ||
it('should show my-org name and logo', () => { | ||
cy.get('h1').should('not.have.text', '') | ||
cy.get('gn-ui-thumbnail') | ||
}) | ||
it('should show the user and record count', () => { | ||
cy.get('@linkGroup') | ||
.find('a') | ||
.children('span') | ||
.first() | ||
.should('not.have.text', '') | ||
cy.get('@linkGroup') | ||
.find('gn-ui-button') | ||
.children('span') | ||
.first() | ||
.should('not.have.text', '') | ||
}) | ||
it('should show my-org records', () => { | ||
cy.get('.grid').should('have.length.above', 0) | ||
}) | ||
}) | ||
describe('routing', () => { | ||
it('should access the datahub with a filter', () => { | ||
cy.get('@linkGroup').find('a').click() | ||
cy.url().should('include', 'search/publisher=') | ||
}) | ||
it('should access the user list page and show my-org users', () => { | ||
cy.visit(`/records/my-org`) | ||
cy.get('md-editor-dashboard-menu').find('a').first().click() | ||
cy.get('@linkGroup').find('gn-ui-button').click() | ||
cy.url().should('include', '/users/my-org') | ||
cy.get('.grid').should('have.length.above', 0) | ||
cy.get('h1').should('not.have.text', '') | ||
cy.get('gn-ui-thumbnail') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
apps/metadata-editor/src/app/my-org-users/my-org-users.component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.record-table-col { | ||
@apply px-5 py-3 items-center truncate; | ||
} | ||
|
||
.record-table-header { | ||
@apply record-table-col capitalize; | ||
} |
6 changes: 6 additions & 0 deletions
6
apps/metadata-editor/src/app/my-org-users/my-org-users.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<md-editor-records-list | ||
[users]="orgData.userList" | ||
[logo]="orgData.logoUrl" | ||
[title]="orgData.orgName" | ||
> | ||
</md-editor-records-list> |
131 changes: 131 additions & 0 deletions
131
apps/metadata-editor/src/app/my-org-users/my-org-users.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
import { MyOrgUsersComponent } from './my-org-users.component' | ||
import { BehaviorSubject, of } from 'rxjs' | ||
import { MyOrgService } from '@geonetwork-ui/feature/catalog' | ||
import { | ||
ORGANISATIONS_FIXTURE, | ||
USER_FIXTURE_ANON, | ||
USERS_FIXTURE, | ||
} from '@geonetwork-ui/common/fixtures' | ||
import { AuthService } from '@geonetwork-ui/api/repository/gn4' | ||
import { SearchFacade } from '@geonetwork-ui/feature/search' | ||
|
||
describe('MyOrgUsersComponent', () => { | ||
let component: MyOrgUsersComponent | ||
let searchFacade: SearchFacade | ||
let myOrgService: MyOrgService | ||
let authService: AuthService | ||
|
||
beforeEach(() => { | ||
const user = USER_FIXTURE_ANON() | ||
const allUsers = USERS_FIXTURE() | ||
|
||
const myOrgServiceMock = { | ||
myOrgData$: of({ | ||
orgName: 'wizard-org', | ||
logoUrl: 'https://my-geonetwork.org/logo11.png', | ||
recordCount: 10, | ||
userCount: 3, | ||
userList: [ | ||
{ | ||
id: '161', | ||
profile: 'Administrator', | ||
username: 'ghost16', | ||
name: 'Ghost', | ||
surname: 'Old', | ||
email: '[email protected]', | ||
organisation: 'wizard-org', | ||
profileIcon: | ||
'https://www.gravatar.com/avatar/dbdffd183622800bcf8587328daf43a6?d=mp', | ||
}, | ||
{ | ||
id: '3', | ||
profile: 'Editor', | ||
username: 'voldy63', | ||
name: 'Lord', | ||
surname: 'Voldemort', | ||
email: '[email protected]', | ||
organisation: 'wizard-org', | ||
}, | ||
{ | ||
id: '4', | ||
profile: 'Editor', | ||
username: 'al.dumble98', | ||
name: 'Albus', | ||
surname: 'Dumbledore', | ||
email: '[email protected]', | ||
organisation: 'wizard-org', | ||
}, | ||
], | ||
}), | ||
} | ||
|
||
const authServiceMock = { | ||
user$: new BehaviorSubject(user), | ||
allUsers$: new BehaviorSubject(allUsers), | ||
} | ||
|
||
const organisationsServiceMock = { | ||
organisations$: of(ORGANISATIONS_FIXTURE), | ||
} | ||
|
||
const searchFacadeMock = { | ||
resetSearch: jest.fn(), | ||
} | ||
|
||
myOrgService = myOrgServiceMock as any | ||
authService = authServiceMock as any | ||
searchFacade = searchFacadeMock as any | ||
|
||
component = new MyOrgUsersComponent(myOrgService, searchFacade) | ||
}) | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy() | ||
}) | ||
|
||
describe('Get organization users info', () => { | ||
it('should get the org name', () => { | ||
expect(component.orgData.orgName).toEqual('wizard-org') | ||
}) | ||
|
||
it('should get the org logo', () => { | ||
expect(component.orgData.logoUrl).toEqual( | ||
'https://my-geonetwork.org/logo11.png' | ||
) | ||
}) | ||
|
||
it('should get the list of users', () => { | ||
expect(component.orgData.userList).toEqual([ | ||
{ | ||
id: '161', | ||
profile: 'Administrator', | ||
username: 'ghost16', | ||
name: 'Ghost', | ||
surname: 'Old', | ||
email: '[email protected]', | ||
organisation: 'wizard-org', | ||
profileIcon: | ||
'https://www.gravatar.com/avatar/dbdffd183622800bcf8587328daf43a6?d=mp', | ||
}, | ||
{ | ||
id: '3', | ||
profile: 'Editor', | ||
username: 'voldy63', | ||
name: 'Lord', | ||
surname: 'Voldemort', | ||
email: '[email protected]', | ||
organisation: 'wizard-org', | ||
}, | ||
{ | ||
id: '4', | ||
profile: 'Editor', | ||
username: 'al.dumble98', | ||
name: 'Albus', | ||
surname: 'Dumbledore', | ||
email: '[email protected]', | ||
organisation: 'wizard-org', | ||
}, | ||
]) | ||
}) | ||
}) | ||
}) |
48 changes: 48 additions & 0 deletions
48
apps/metadata-editor/src/app/my-org-users/my-org-users.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Component, OnDestroy } from '@angular/core' | ||
import { RecordsListComponent } from '../records/records-list.component' | ||
import { UiInputsModule } from '@geonetwork-ui/ui/inputs' | ||
import { TranslateModule } from '@ngx-translate/core' | ||
import { CommonModule } from '@angular/common' | ||
import { MyOrgService } from '@geonetwork-ui/feature/catalog' | ||
import { SearchFacade } from '@geonetwork-ui/feature/search' | ||
import { UserApiModel } from '@geonetwork-ui/data-access/gn4' | ||
|
||
@Component({ | ||
selector: 'md-editor-my-org-users', | ||
templateUrl: './my-org-users.component.html', | ||
styleUrls: ['./my-org-users.component.css'], | ||
standalone: true, | ||
imports: [ | ||
RecordsListComponent, | ||
UiInputsModule, | ||
TranslateModule, | ||
CommonModule, | ||
], | ||
}) | ||
export class MyOrgUsersComponent implements OnDestroy { | ||
orgData: { | ||
orgName: string | ||
logoUrl: string | ||
recordCount: number | ||
userCount: number | ||
userList: UserApiModel[] | ||
} | ||
|
||
private myOrgDataSubscription | ||
|
||
constructor( | ||
private myOrgRecordsService: MyOrgService, | ||
public searchFacade: SearchFacade | ||
) { | ||
this.searchFacade.resetSearch() | ||
this.myOrgDataSubscription = this.myOrgRecordsService.myOrgData$.subscribe( | ||
(data) => { | ||
this.orgData = data | ||
} | ||
) | ||
} | ||
|
||
ngOnDestroy() { | ||
this.myOrgDataSubscription.unsubscribe() | ||
} | ||
} |
8 changes: 7 additions & 1 deletion
8
apps/metadata-editor/src/app/records/my-org-records/my-org-records.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
<md-editor-records-list [title]="'dashboard.records.myOrg' | translate"> | ||
<md-editor-records-list | ||
[logo]="orgData?.logoUrl" | ||
[title]="orgData?.orgName" | ||
[recordCount]="orgData?.recordCount" | ||
[userCount]="orgData?.userCount" | ||
[linkToDatahub]="getDatahubUrl()" | ||
> | ||
</md-editor-records-list> |
Oops, something went wrong.