From 7dfb7d80e338ec6021586c5c4b12b92bfa72e872 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Thu, 19 Dec 2024 07:32:42 -0800 Subject: [PATCH 1/7] Don't run coverage by default (slows down local development) --- .github/workflows/node.js.yml | 2 +- vitest.config.ts | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 191d470fe..b012a6697 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -23,7 +23,7 @@ jobs: with: node-version: ${{ matrix.node-version }} - run: npm install - - run: npm test + - run: npm test -- --coverage - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 env: diff --git a/vitest.config.ts b/vitest.config.ts index fe74466eb..d8959d6e1 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -33,10 +33,6 @@ export default defineConfig({ }, }, test: { - coverage: { - all: true, - enabled: true, - }, environment: 'happy-dom', exclude: ['node_modules'], globals: true, From 8f2f3b6aa80ec9dc984ad64e55282e3005ed53aa Mon Sep 17 00:00:00 2001 From: Marlo Longley Date: Thu, 19 Dec 2024 12:30:46 -0500 Subject: [PATCH 2/7] Rename master to main --- .github/workflows/node.js.yml | 4 ++-- CONTRIBUTING.md | 4 ++-- README.md | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index b012a6697..a4b67ebac 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -5,9 +5,9 @@ name: Node.js CI on: push: - branches: [ master ] + branches: [ main ] pull_request: - branches: [ master ] + branches: [ main ] jobs: build: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 85112414c..3df0c9fe1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,10 +7,10 @@ Contributions to Mirador are always welcome! It is always helpful to begin any large change by submitting an issue or engaging with the Mirador community. Mirador 3.0 and beyond adheres to [semantic versioning](https://semver.org/) so that adopters and contributors can better understand what changes can be expected in released versions of the software. -All contributions should be submitted as a [GitHub pull request](https://help.github.com/articles/about-pull-requests/) to the master branch. Pull requests must be reviewed and accepted by another Mirador maintainer and pass all continuous integration checks. Contributions should have tests for the feature or bug fix, documentation, should maintain high code coverage, and should conform to the Mirador agreed-upon coding style. Contributions should not include a “built” version of Mirador—this will help to reduce merge conflicts. +All contributions should be submitted as a [GitHub pull request](https://help.github.com/articles/about-pull-requests/) to the main branch. Pull requests must be reviewed and accepted by another Mirador maintainer and pass all continuous integration checks. Contributions should have tests for the feature or bug fix, documentation, should maintain high code coverage, and should conform to the Mirador agreed-upon coding style. Contributions should not include a “built” version of Mirador—this will help to reduce merge conflicts. ### Code of Conduct -Everyone interacting in this community is expected to follow the [Mirador Code of Conduct](https://github.com/ProjectMirador/mirador/blob/master/CODE_OF_CONDUCT.md). +Everyone interacting in this community is expected to follow the [Mirador Code of Conduct](https://github.com/ProjectMirador/mirador/blob/main/CODE_OF_CONDUCT.md). ### Accessibility Mirador 3 aims to comply with the [Web Content Accessibility Guidelines (WCAG) 2.1 AA](https://www.w3.org/WAI/standards-guidelines/wcag/). These guidelines, authored by the W3C and legally adopted [internationally](https://www.w3.org/WAI/policies/?q=wcag-20), are comprehensive and provide the success criteria designers and developers need to build accessible web applications. diff --git a/README.md b/README.md index a58edb998..8f59c940b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Mirador -![Node.js CI](https://github.com/ProjectMirador/mirador/workflows/Node.js%20CI/badge.svg) [![codecov](https://codecov.io/gh/ProjectMirador/mirador/branch/master/graph/badge.svg)](https://codecov.io/gh/ProjectMirador/mirador) +![Node.js CI](https://github.com/ProjectMirador/mirador/workflows/Node.js%20CI/badge.svg) [![codecov](https://codecov.io/gh/ProjectMirador/mirador/branch/main/graph/badge.svg)](https://codecov.io/gh/ProjectMirador/mirador) ## For Mirador Users You can quickly use and configure Mirador by remixing the [mirador-start](https://mirador-start.glitch.me/) Glitch. From bff7e8fd5bc0f7801a0b6f73f3a30b03147fb331 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Thu, 19 Dec 2024 14:46:02 -0800 Subject: [PATCH 3/7] URL-encoding access token service source url; fixes #3902 --- __tests__/src/components/AccessTokenSender.test.js | 2 +- src/components/AccessTokenSender.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/__tests__/src/components/AccessTokenSender.test.js b/__tests__/src/components/AccessTokenSender.test.js index 377f379cb..a0cb575f7 100644 --- a/__tests__/src/components/AccessTokenSender.test.js +++ b/__tests__/src/components/AccessTokenSender.test.js @@ -22,7 +22,7 @@ describe('AccessTokenSender', () => { it('renders properly', () => { const { container } = createWrapper({ url: 'http://example.com' }); - expect(container.querySelector('iframe')).toHaveAttribute('src', 'http://example.com?origin=http://localhost&messageId=http://example.com'); // eslint-disable-line testing-library/no-node-access, testing-library/no-container + expect(container.querySelector('iframe')).toHaveAttribute('src', 'http://example.com/?origin=http%3A%2F%2Flocalhost&messageId=http%3A%2F%2Fexample.com'); // eslint-disable-line testing-library/no-node-access, testing-library/no-container }); it('triggers an action when the iframe sends a message', () => { diff --git a/src/components/AccessTokenSender.js b/src/components/AccessTokenSender.js index c6580aa1a..ade30b8c1 100644 --- a/src/components/AccessTokenSender.js +++ b/src/components/AccessTokenSender.js @@ -12,13 +12,17 @@ export function AccessTokenSender({ handleAccessTokenMessage, url = undefined }) if (!url) return null; + const src = new URL(url); + src.searchParams.append('origin', window.origin); + src.searchParams.append('messageId', url); + /** login, clickthrough/kiosk open @id, wait for close external, no-op */ return ( From f221570cfb63321b665dc39fa9ec928f5419cbe8 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Fri, 20 Dec 2024 09:12:05 -0800 Subject: [PATCH 4/7] `size` is now provided by a hook, stop requiring the prop for `WindowCanvasNavigationControls` --- src/components/WindowCanvasNavigationControls.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/WindowCanvasNavigationControls.js b/src/components/WindowCanvasNavigationControls.js index a6b0a9721..b537c92ac 100644 --- a/src/components/WindowCanvasNavigationControls.js +++ b/src/components/WindowCanvasNavigationControls.js @@ -77,7 +77,6 @@ export const WindowCanvasNavigationControls = forwardRef(({ WindowCanvasNavigationControls.propTypes = { showZoomControls: PropTypes.bool, - size: PropTypes.shape({ width: PropTypes.number }).isRequired, visible: PropTypes.bool, windowId: PropTypes.string.isRequired, zoomToWorld: PropTypes.func.isRequired, From cd7f3bcff4ad030de5d5c013f2af113eb4e17b31 Mon Sep 17 00:00:00 2001 From: Marlo Longley Date: Fri, 20 Dec 2024 12:54:56 -0500 Subject: [PATCH 5/7] Change webpack to vite in the README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8f59c940b..805f87d95 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ $ npm install mirador $ yarn add mirador ``` -If you are interested in integrating Mirador with plugins into your project, we recommend using webpack or parcel to integrate the es version of the packages. Examples are here: +If you are interested in integrating Mirador with plugins into your project, we recommend using vite to integrate the es version of the packages. Examples are here: [https://github.com/ProjectMirador/mirador-integration](https://github.com/ProjectMirador/mirador-integration) @@ -24,7 +24,7 @@ If you want to simply embed Mirador in an HTML page without further customizatio ``` -More examples of embedding Mirador can be found at [https://github.com/ProjectMirador/mirador/wiki/M3-Embedding-in-Another-Environment#in-an-html-document-with-javascript](https://github.com/ProjectMirador/mirador/wiki/M3-Embedding-in-Another-Environment#in-an-html-document-with-javascript). +More examples of embedding Mirador can be found at [https://github.com/ProjectMirador/mirador/wiki/M3-Embedding-in-Another-Environment#in-an-html-document-with-javascript](https://github.com/ProjectMirador/mirador/wiki/Embedding-in-Another-Environment). ## Adding translations to Mirador For help with adding a translation, see [src/locales/README.md](src/locales/README.md) From c02bf4ed57bb4a0a9d9620dd40a02cd88d84162c Mon Sep 17 00:00:00 2001 From: Marlo Longley Date: Tue, 7 Jan 2025 16:56:17 -0500 Subject: [PATCH 6/7] Remove unnecessary createSelector --- src/state/selectors/manifests.js | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/state/selectors/manifests.js b/src/state/selectors/manifests.js index 9f58ecefd..d7a9c7c1e 100644 --- a/src/state/selectors/manifests.js +++ b/src/state/selectors/manifests.js @@ -99,20 +99,6 @@ function getProperty(property) { ); } -/** - * Returns the manifest provider. - * @param {object} state - * @param {object} props - * @param {string} props.companionWindowId - * @returns {string} - */ -export const getManifestProvider = createSelector( - [ - getProperty('provider'), - ], - (provider) => provider, -); - /** * Return the IIIF v3 provider of a manifest or null. * @param {object} state @@ -138,7 +124,7 @@ export const getManifestProviderName = createSelector( * @returns {string|null} */ export const getProviderLogo = createSelector( - [getManifestProvider], + [getProperty('provider')], (provider) => { const logo = provider && provider[0] && provider[0].logo && provider[0].logo[0]; if (!logo) return null; From 5dbdfc0f15f424d623aefb18f660ad0ba7d7729a Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Tue, 7 Jan 2025 15:57:02 -0800 Subject: [PATCH 7/7] Add forwardRef to CompanionWindow --- src/components/CompanionWindow.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/components/CompanionWindow.js b/src/components/CompanionWindow.js index 778e95c53..cf03de3af 100644 --- a/src/components/CompanionWindow.js +++ b/src/components/CompanionWindow.js @@ -1,4 +1,5 @@ -import { Children, cloneElement } from 'react'; +/* eslint-disable react/require-default-props */ +import { Children, cloneElement, forwardRef } from 'react'; import PropTypes from 'prop-types'; import { styled } from '@mui/material/styles'; import CloseIcon from '@mui/icons-material/CloseSharp'; @@ -26,11 +27,11 @@ const StyledCloseButton = styled(MiradorMenuButton, { name: 'CompanionWindow', s /** * CompanionWindow */ -export function CompanionWindow(props) { // eslint-disable-line react/require-default-props +export const CompanionWindow = forwardRef((props, innerRef) => { const { ariaLabel = undefined, classes = {}, direction, paperClassName = '', onCloseClick = () => {}, updateCompanionWindow = undefined, isDisplayed = false, position = null, title = null, children = undefined, titleControls = null, - defaultSidebarPanelWidth = 235, defaultSidebarPanelHeight = 201, innerRef = undefined, + defaultSidebarPanelWidth = 235, defaultSidebarPanelHeight = 201, } = props; const [sizeRef, size] = useElementSize(); const { t } = useTranslation(); @@ -183,7 +184,7 @@ export function CompanionWindow(props) { // eslint-disable-line react/require-de ); -} +}); CompanionWindow.propTypes = { ariaLabel: PropTypes.string, @@ -192,10 +193,6 @@ CompanionWindow.propTypes = { defaultSidebarPanelHeight: PropTypes.number, defaultSidebarPanelWidth: PropTypes.number, direction: PropTypes.string.isRequired, - innerRef: PropTypes.oneOfType([ - PropTypes.func, - PropTypes.shape({ current: PropTypes.instanceOf(Element) }), - ]), isDisplayed: PropTypes.bool, onCloseClick: PropTypes.func, paperClassName: PropTypes.string, @@ -208,3 +205,5 @@ CompanionWindow.propTypes = { titleControls: PropTypes.node, updateCompanionWindow: PropTypes.func, }; + +CompanionWindow.displayName = 'CompanionWindow';