-
Notifications
You must be signed in to change notification settings - Fork 3
List things related to a resource with a custom display #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jg10-mastodon-social
wants to merge
22
commits into
pod-os:main
Choose a base branch
from
jg10-mastodon-social:feat/basic-list
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+531
−2
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
375cd10
feat: pos-list creates children for specified rel
jg10-mastodon-social 49e211b
feat: pos-list renders the provided template
jg10-mastodon-social 322217b
feat: pos-list provides resources to descendants
jg10-mastodon-social 9d93a11
feat(core): thing.relations takes optional predicate
jg10-mastodon-social cb1b056
refactor(pos-list): pass predicate to resource.relations
jg10-mastodon-social ac79622
test: pos-list integration
jg10-mastodon-social 7686e6b
doc: add story for pos-list composition
jg10-mastodon-social 5b12544
fix(pos-list): unused import
jg10-mastodon-social 19ca31a
doc: generate pos-list docs
jg10-mastodon-social 3d7d145
doc(pos-list): add to changelog
jg10-mastodon-social c311e05
doc: update Thing.relations changelog
jg10-mastodon-social 27f794e
doc(pos-list): improve unit test readability
jg10-mastodon-social 1d302ab
test(pos-list): remove incorrect shadow root
jg10-mastodon-social 2394290
refactor: pos-list uses pos-resource instead of providing resources i…
jg10-mastodon-social d105825
fix(pos-list): use const
jg10-mastodon-social 9ef6cb1
test(pos-list): control fetching with fetch attribute
jg10-mastodon-social cf9d2a7
feat(pos-list): support fetch attribute
jg10-mastodon-social 108b8e1
refactor(pos-list): split integration tests to avoid test pollution
jg10-mastodon-social d1a0f69
doc: pos-list basic story
jg10-mastodon-social 90f6466
fix(doc): move Thing.relations to Unreleased
jg10-mastodon-social 96a36ef
fix(pos-list): code cleanup
jg10-mastodon-social f44002a
fix(pos-list): composition story now uses ul
jg10-mastodon-social File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,40 @@ | ||
|
||
<!-- Auto Generated Below --> | ||
|
||
|
||
## Properties | ||
|
||
| Property | Attribute | Description | Type | Default | | ||
| -------- | --------- | ----------------------------------------------------------------- | --------- | ----------- | | ||
| `fetch` | `fetch` | Whether listed resources should be fetched before being displayed | `boolean` | `false` | | ||
| `rel` | `rel` | URI of the predicate to follow | `string` | `undefined` | | ||
|
||
|
||
## Events | ||
|
||
| Event | Description | Type | | ||
| ----------------- | ----------- | ------------------ | | ||
| `pod-os:resource` | | `CustomEvent<any>` | | ||
|
||
|
||
## Dependencies | ||
|
||
### Depends on | ||
|
||
- [pos-resource](../pos-resource) | ||
|
||
### Graph | ||
```mermaid | ||
graph TD; | ||
pos-list --> pos-resource | ||
pos-resource --> ion-progress-bar | ||
pos-resource --> ion-card | ||
pos-resource --> ion-card-header | ||
pos-resource --> ion-card-content | ||
ion-card --> ion-ripple-effect | ||
style pos-list fill:#f9f,stroke:#333,stroke-width:4px | ||
``` | ||
|
||
---------------------------------------------- | ||
|
||
*Built with [StencilJS](https://stenciljs.com/)* |
This file contains hidden or 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 hidden or 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 hidden or 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
40 changes: 40 additions & 0 deletions
40
elements/src/components/pos-list/pos-list-fetch.integration.spec.tsx
This file contains hidden or 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,40 @@ | ||
import { newSpecPage } from '@stencil/core/testing'; | ||
import { mockPodOS } from '../../test/mockPodOS'; | ||
import { PosApp } from '../pos-app/pos-app'; | ||
import { PosLabel } from '../pos-label/pos-label'; | ||
import { PosList } from './pos-list'; | ||
import { PosResource } from '../pos-resource/pos-resource'; | ||
import { when } from 'jest-when'; | ||
|
||
describe('pos-list', () => { | ||
it('fetches resources if fetch attribute is present', async () => { | ||
const os = mockPodOS(); | ||
when(os.store.get) | ||
.calledWith('https://resource.test') | ||
.mockReturnValue({ | ||
relations: () => [ | ||
{ | ||
predicate: 'http://schema.org/video', | ||
uris: ['https://video.test/video-1', 'https://video.test/video-2'], | ||
}, | ||
], | ||
}); | ||
await newSpecPage({ | ||
components: [PosApp, PosLabel, PosList, PosResource], | ||
supportsShadowDom: false, | ||
html: ` | ||
<pos-app> | ||
<pos-resource uri="https://resource.test" lazy=""> | ||
<pos-list rel="http://schema.org/video" fetch> | ||
<template> | ||
<pos-label /> | ||
</template> | ||
</pos-list> | ||
</pos-resource> | ||
</pos-app>`, | ||
}); | ||
|
||
expect(os.fetch.mock.calls).toHaveLength(2); | ||
expect(os.fetch.mock.calls).toEqual([['https://video.test/video-1'], ['https://video.test/video-2']]); | ||
}); | ||
}); |
68 changes: 68 additions & 0 deletions
68
elements/src/components/pos-list/pos-list.integration.spec.tsx
This file contains hidden or 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,68 @@ | ||
import { newSpecPage } from '@stencil/core/testing'; | ||
import { mockPodOS } from '../../test/mockPodOS'; | ||
import { PosApp } from '../pos-app/pos-app'; | ||
import { PosLabel } from '../pos-label/pos-label'; | ||
import { PosList } from './pos-list'; | ||
import { PosResource } from '../pos-resource/pos-resource'; | ||
import { when } from 'jest-when'; | ||
|
||
describe('pos-list', () => { | ||
it('children render label for loaded resources (without fetching)', async () => { | ||
const os = mockPodOS(); | ||
when(os.store.get) | ||
.calledWith('https://resource.test') | ||
.mockReturnValue({ | ||
relations: () => [ | ||
{ | ||
predicate: 'http://schema.org/video', | ||
uris: ['https://video.test/video-1', 'https://video.test/video-2'], | ||
}, | ||
], | ||
}); | ||
when(os.store.get) | ||
.calledWith('https://video.test/video-1') | ||
.mockReturnValue({ uri: 'https://video.test/video-1', label: () => 'Video 1' }); | ||
when(os.store.get) | ||
.calledWith('https://video.test/video-2') | ||
.mockReturnValue({ uri: 'https://video.test/video-2', label: () => 'Video 2' }); | ||
const page = await newSpecPage({ | ||
components: [PosApp, PosLabel, PosList, PosResource], | ||
jg10-mastodon-social marked this conversation as resolved.
Show resolved
Hide resolved
|
||
supportsShadowDom: false, | ||
html: ` | ||
<pos-app> | ||
<pos-resource uri="https://resource.test" lazy=""> | ||
<pos-list rel="http://schema.org/video"> | ||
<template> | ||
<pos-label /> | ||
</template> | ||
</pos-list> | ||
</pos-resource> | ||
</pos-app>`, | ||
}); | ||
expect(os.fetch.mock.calls).toHaveLength(0); | ||
|
||
const resources = page.root ? page.root.querySelectorAll('pos-list pos-resource') : []; | ||
expect(resources).toHaveLength(2); | ||
|
||
const label1 = resources[0] as unknown as PosResource; | ||
expect(label1).toEqualHtml(` | ||
<pos-resource about="https://video.test/video-1"> | ||
<pos-label> | ||
Video 1 | ||
</pos-label> | ||
</pos-resource> | ||
`); | ||
//Tested separately because pos-resource does not reflect the uri property as an attribute | ||
expect(label1?.uri).toEqual('https://video.test/video-1'); | ||
|
||
const label2 = resources[1] as unknown as PosResource; | ||
expect(label2).toEqualHtml(` | ||
<pos-resource about="https://video.test/video-2"> | ||
<pos-label> | ||
Video 2 | ||
</pos-label> | ||
</pos-resource> | ||
`); | ||
expect(label2?.uri).toEqual('https://video.test/video-2'); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.