Skip to content

Commit

Permalink
Merge pull request #640 from geonetwork/ME/records-published-by-my-org
Browse files Browse the repository at this point in the history
 Me/dh/records published by my org
  • Loading branch information
cmoinier authored Oct 13, 2023
2 parents 5926a9c + 1d7afe4 commit a12b13c
Show file tree
Hide file tree
Showing 30 changed files with 797 additions and 102 deletions.
44 changes: 44 additions & 0 deletions apps/metadata-editor-e2e/src/e2e/my-org.cy.ts
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')
})
})
})
5 changes: 5 additions & 0 deletions apps/metadata-editor/src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { MyRecordsComponent } from './records/my-records/my-records.component'
import { MyDraftComponent } from './records/my-draft/my-draft.component'
import { MyLibraryComponent } from './records/my-library/my-library.component'
import { SearchRecordsComponent } from './records/search-records/search-records-list.component'
import { MyOrgUsersComponent } from './my-org-users/my-org-users.component'

export const appRoutes: Route[] = [
{ path: '', component: DashboardPageComponent, pathMatch: 'prefix' },
Expand Down Expand Up @@ -61,6 +62,10 @@ export const appRoutes: Route[] = [
},
],
},
{
path: 'users/my-org',
component: MyOrgUsersComponent,
},
{ path: 'sign-in', component: SignInPageComponent },
{ path: 'create', component: CreatePageComponent },
{
Expand Down
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;
}
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>
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',
},
])
})
})
})
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()
}
}
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>
Loading

0 comments on commit a12b13c

Please sign in to comment.