-
Notifications
You must be signed in to change notification settings - Fork 264
Get multi-sequences to work for v3 ranges/seqs #3333
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| { | ||
| "@context": [ | ||
| "http://iiif.io/api/presentation/3/context.json" | ||
| ], | ||
| "id": "http://foo.test/1/manifest", | ||
| "type": "Manifest", | ||
| "label": { | ||
| "none": ["Version 3 manifest for multiple ranges (sequences behavior) related tests"] | ||
| }, | ||
| "items": [ | ||
| { | ||
| "id": "http://foo.test/1/canvas/c1", | ||
| "type": "Canvas", | ||
| "label":{"none":["Test Canvas 1"]} | ||
| }, | ||
| { | ||
| "id": "http://foo.test/1/canvas/c2", | ||
| "type": "Canvas", | ||
| "label":{"none":["Test Canvas 2"]} | ||
| }, | ||
| { | ||
| "id": "http://foo.test/1/canvas/c3", | ||
| "type": "Canvas", | ||
| "label":{"none":["Test Canvas 3"]} | ||
| } | ||
| ], | ||
| "structures": [ | ||
| { | ||
| "id": "http://foo.test/1/range/root", | ||
| "type": "Range", | ||
| "behavior": "sequence", | ||
| "items": [ | ||
| { | ||
| "id": "http://foo.test/1/canvas/c1", | ||
| "type": "Canvas", | ||
| "label":{"none":["Test Canvas 1"]} | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "id": "http://foo.test/1/range/second", | ||
| "type": "Range", | ||
| "behavior": "sequence", | ||
| "items": [ | ||
| { | ||
| "id": "http://foo.test/1/canvas/c2", | ||
| "type": "Canvas", | ||
| "label":{"none":["Test Canvas 2"]} | ||
| }, | ||
| { | ||
| "id": "http://foo.test/1/canvas/c3", | ||
| "type": "Canvas", | ||
| "label":{"none":["Test Canvas 3"]} | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /* global miradorInstance */ | ||
|
|
||
| describe('Window Sidebar Sequence Dropdown v3', () => { | ||
| beforeAll(async () => { | ||
| await page.goto('http://127.0.0.1:4488/__tests__/integration/mirador/blank.html'); | ||
|
|
||
| await expect(page).toClick('#addBtn'); | ||
| await expect(page).toClick('.mirador-add-resource-button'); | ||
| await expect(page).toFill('#manifestURL', 'http://localhost:4488/__tests__/fixtures/version-3/multipleSequences.json'); | ||
| await expect(page).toClick('#fetchBtn'); | ||
|
|
||
| await expect(page).toMatchElement('[data-manifestid="http://localhost:4488/__tests__/fixtures/version-3/multipleSequences.json"] button'); | ||
| await expect(page).toClick('[data-manifestid="http://localhost:4488/__tests__/fixtures/version-3/multipleSequences.json"] button'); | ||
| }); | ||
|
|
||
| it('allows the user to switch the v3 ranges (behavior sequences)', async () => { | ||
| const windows = await page.evaluate(() => ( | ||
| miradorInstance.store.getState().windows | ||
| )); | ||
|
|
||
| const windowId = Object.values(windows) | ||
| .find(window => window.manifestId === 'http://localhost:4488/__tests__/fixtures/version-3/multipleSequences.json') | ||
| .id; | ||
|
|
||
| await expect(page).toMatchElement(`#${windowId} button[aria-label="Toggle sidebar"]`); | ||
| await expect(page).toClick(`#${windowId} button[aria-label="Toggle sidebar"]`); | ||
| await expect(page).toMatchElement(`#${windowId} button[aria-label="Index"]`); | ||
| await expect(page).toClick(`#${windowId} button[aria-label="Index"]`); | ||
| await expect(page).toClick('#mui-component-select-sequenceId'); | ||
| await expect(page).toMatchElement('[data-value="http://foo.test/1/range/second"]'); | ||
| await expect(page).toClick('[data-value="http://foo.test/1/range/second"]'); | ||
| await expect(page).toMatchElement('p', { text: 'Test Canvas 2' }); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,8 @@ export const selectInfoResponses = state => miradorSlice(state).infoResponses; | |
|
|
||
| export const getCanvases = createSelector( | ||
| [getSequence], | ||
| sequence => (sequence && sequence.getCanvases()) || [], | ||
| sequence => (sequence && ((sequence.getCanvases && sequence.getCanvases()) || sequence.items)) | ||
| || [], | ||
| ); | ||
|
|
||
| /** | ||
|
|
@@ -29,9 +30,16 @@ export const getCanvas = createSelector( | |
| (state, { canvasId }) => canvasId, | ||
| ], | ||
| (sequence, canvasId) => { | ||
| let canvas; | ||
| if (!sequence || !canvasId) return undefined; | ||
|
|
||
| return sequence.getCanvasById(canvasId); | ||
| if (typeof sequence.getCanvasById == 'function') { | ||
| canvas = sequence.getCanvasById(canvasId); | ||
| } else if (sequence.items) { | ||
| canvas = sequence.items.filter(c => c.id === canvasId) || []; | ||
| } | ||
|
|
||
| return canvas; | ||
| }, | ||
| ); | ||
|
|
||
|
|
@@ -43,9 +51,21 @@ export const getCurrentCanvas = createSelector( | |
| (sequence, window) => { | ||
| if (!sequence || !window) return undefined; | ||
|
|
||
| if (!window.canvasId) return sequence.getCanvasByIndex(0); | ||
| if (!window.canvasId && (typeof sequence.getCanvasByIndex == 'function')) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the case here that the sequence is not a manifesto Sequence object?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi Jack, this is for when the sequence represents a 'Range' manifesto object here which does not provide the 'getCanvasById' or 'getCanvases' function. 'Range' manifesto object has 'items' where it lists all the canvases. |
||
| return sequence.getCanvasByIndex(0); | ||
| } | ||
|
|
||
| if (!window.canvasId) { | ||
| const { items } = sequence; | ||
| const [firstCanvas] = items; | ||
| return firstCanvas; | ||
| } | ||
|
|
||
| if (typeof sequence.getCanvasById == 'function') { | ||
| return sequence.getCanvasById(window.canvasId); | ||
| } | ||
|
|
||
| return sequence.getCanvasById(window.canvasId); | ||
| return sequence.items.filter(c => c.id === window.canvasId) || []; | ||
| }, | ||
| ); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this works with our themed approach. Can you say more about the need to modify the color here?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Jack, this is for constraining the size of the select dropdown so it does not extend beyond the sidebar panel when there is a long sequence label.. the reasoning for setting background color to white was to make sure that the 'Arrow icon' in the select bar and the long sequence label don't overlap.