-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
216 additions
and
13 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
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
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
5 changes: 5 additions & 0 deletions
5
contacts/src/components/list-address-books/list-address-books.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,5 @@ | ||
ul { | ||
margin: 0; | ||
padding: 0; | ||
list-style-type: none; | ||
} |
48 changes: 45 additions & 3 deletions
48
contacts/src/components/list-address-books/list-address-books.tsx
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,12 +1,54 @@ | ||
import { Component, h, Prop } from '@stencil/core'; | ||
import { AddressBookLists, ContactsModule } from '@solid-data-modules/contacts-rdflib'; | ||
import { Component, Event, h, Prop, State, Watch } from '@stencil/core'; | ||
import { PodOsModuleAware, PodOsModuleEventEmitter, subscribePodOsModule } from '../../events/PodOsModuleAware'; | ||
|
||
@Component({ | ||
tag: 'pos-contacts-list-address-books', | ||
styleUrl: './list-address-books.css', | ||
shadow: true, | ||
}) | ||
export class ListAddressBooks { | ||
export class ListAddressBooks implements PodOsModuleAware<ContactsModule> { | ||
@Prop() | ||
webId!: string; | ||
|
||
@State() | ||
private contactsModule: ContactsModule; | ||
|
||
@Event({ eventName: 'pod-os:module' }) | ||
subscribeModule: PodOsModuleEventEmitter<ContactsModule>; | ||
|
||
@State() | ||
private addressBookLists: AddressBookLists; | ||
|
||
componentWillLoad() { | ||
subscribePodOsModule('contacts', this); | ||
} | ||
|
||
receiveModule = (module: ContactsModule) => { | ||
this.contactsModule = module; | ||
}; | ||
|
||
@Watch('contactsModule') | ||
async listAddressBooks() { | ||
this.addressBookLists = await this.contactsModule.listAddressBooks(this.webId); | ||
} | ||
|
||
render() { | ||
return <div>TODO: list address books of {this.webId}</div>; | ||
if (!this.addressBookLists) { | ||
return <div>Loading...</div>; | ||
} | ||
const allUris = [...this.addressBookLists.privateUris, ...this.addressBookLists.publicUris]; | ||
if (allUris.length == 0) { | ||
return <div>Sorry, no address books could be found in your pod.</div>; | ||
} | ||
return ( | ||
<ul> | ||
{allUris.map(uri => ( | ||
<li> | ||
<pos-rich-link uri={uri}></pos-rich-link> | ||
</li> | ||
))} | ||
</ul> | ||
); | ||
} | ||
} |
125 changes: 125 additions & 0 deletions
125
contacts/src/components/list-address-books/test/list-address-book.spec.tsx
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,125 @@ | ||
import { AddressBookLists, ContactsModule } from '@solid-data-modules/contacts-rdflib'; | ||
import { h } from '@stencil/core'; | ||
import { newSpecPage } from '@stencil/core/testing'; | ||
import { when } from 'jest-when'; | ||
import { ListAddressBooks } from '../list-address-books'; | ||
|
||
describe('list address books', () => { | ||
let page; | ||
beforeEach(async () => { | ||
page = await newSpecPage({ | ||
components: [ListAddressBooks], | ||
template: () => <pos-contacts-list-address-books webId="https://alice.test/profile/card#me" />, | ||
supportsShadowDom: false, | ||
}); | ||
}); | ||
|
||
it('shows loading indicator initially', () => { | ||
expect(page.root).toEqualHtml(` | ||
<pos-contacts-list-address-books> | ||
<div>Loading...</div> | ||
</pos-contacts-list-address-books>`); | ||
}); | ||
|
||
it('indicates that now address books have been found', async () => { | ||
const module = { | ||
listAddressBooks: jest.fn() as unknown, | ||
} as ContactsModule; | ||
|
||
const lists: AddressBookLists = { | ||
publicUris: [], | ||
privateUris: [], | ||
}; | ||
|
||
when(module.listAddressBooks).calledWith('https://alice.test/profile/card#me').mockResolvedValue(lists); | ||
|
||
page.rootInstance.receiveModule(module); | ||
await page.waitForChanges(); | ||
|
||
expect(page.root).toEqualHtml(` | ||
<pos-contacts-list-address-books> | ||
<div>Sorry, no address books could be found in your pod.</div> | ||
</pos-contacts-list-address-books>`); | ||
}); | ||
|
||
it('lists a single private address book', async () => { | ||
const module = { | ||
listAddressBooks: jest.fn() as unknown, | ||
} as ContactsModule; | ||
|
||
const lists: AddressBookLists = { | ||
publicUris: [], | ||
privateUris: ['https://alice.test/private/contacts/1'], | ||
}; | ||
|
||
when(module.listAddressBooks).calledWith('https://alice.test/profile/card#me').mockResolvedValue(lists); | ||
|
||
page.rootInstance.receiveModule(module); | ||
await page.waitForChanges(); | ||
|
||
expect(page.root).toEqualHtml(` | ||
<pos-contacts-list-address-books> | ||
<ul> | ||
<li> | ||
<pos-rich-link uri="https://alice.test/private/contacts/1"></pos-rich-link> | ||
</li> | ||
</ul> | ||
</pos-contacts-list-address-books>`); | ||
}); | ||
|
||
it('lists a single public address book', async () => { | ||
const module = { | ||
listAddressBooks: jest.fn() as unknown, | ||
} as ContactsModule; | ||
|
||
const lists: AddressBookLists = { | ||
publicUris: ['https://alice.test/public/contacts/1'], | ||
privateUris: [], | ||
}; | ||
|
||
when(module.listAddressBooks).calledWith('https://alice.test/profile/card#me').mockResolvedValue(lists); | ||
|
||
page.rootInstance.receiveModule(module); | ||
await page.waitForChanges(); | ||
|
||
expect(page.root).toEqualHtml(` | ||
<pos-contacts-list-address-books> | ||
<ul> | ||
<li> | ||
<pos-rich-link uri="https://alice.test/public/contacts/1"></pos-rich-link> | ||
</li> | ||
</ul> | ||
</pos-contacts-list-address-books>`); | ||
}); | ||
|
||
it('lists all address books', async () => { | ||
const module = { | ||
listAddressBooks: jest.fn() as unknown, | ||
} as ContactsModule; | ||
|
||
const lists: AddressBookLists = { | ||
publicUris: ['https://alice.test/public/contacts/1'], | ||
privateUris: ['https://alice.test/private/contacts/1', 'https://alice.test/private/contacts/2'], | ||
}; | ||
|
||
when(module.listAddressBooks).calledWith('https://alice.test/profile/card#me').mockResolvedValue(lists); | ||
|
||
page.rootInstance.receiveModule(module); | ||
await page.waitForChanges(); | ||
|
||
expect(page.root).toEqualHtml(` | ||
<pos-contacts-list-address-books> | ||
<ul> | ||
<li> | ||
<pos-rich-link uri="https://alice.test/private/contacts/1"></pos-rich-link> | ||
</li> | ||
<li> | ||
<pos-rich-link uri="https://alice.test/private/contacts/2"></pos-rich-link> | ||
</li> | ||
<li> | ||
<pos-rich-link uri="https://alice.test/public/contacts/1"></pos-rich-link> | ||
</li> | ||
</ul> | ||
</pos-contacts-list-address-books>`); | ||
}); | ||
}); |
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
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
2 changes: 1 addition & 1 deletion
2
dev-solid-server/data/.internal/setup/current-server-version$.json
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 +1 @@ | ||
{"key":"setup/current-server-version","payload":"7.0.3"} | ||
{"key":"setup/current-server-version","payload":"7.0.4"} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.