Skip to content

External tools require terms or guestbook response if applicable#987

Open
ChengShi-1 wants to merge 4 commits into
developfrom
941-external-tools-should-require-terms-and-guestbook-response-before-access-a-file
Open

External tools require terms or guestbook response if applicable#987
ChengShi-1 wants to merge 4 commits into
developfrom
941-external-tools-should-require-terms-and-guestbook-response-before-access-a-file

Conversation

@ChengShi-1
Copy link
Copy Markdown
Contributor

@ChengShi-1 ChengShi-1 commented May 8, 2026

What this PR does / why we need it:

On the Dataset page, some external tools are available(like Preview, Ask the Data...). Clicking this icon navigates the user to the Preview tab on the File page. If the file belongs to a dataset that requires acceptance of terms and completion of a guestbook, these must be presented and completed before the file preview is made available.

Related PR #815

Which issue(s) this PR closes:

Special notes for your reviewer:

Suggestions on how to test this:

Building external tool here, and test if the terms and guestbook window poped up, if you're a guest user

To install an external tool in local Dataverse:

  1. Create or download an external tool manifest JSON.
    Example dataset tool:
    { "displayName": "Dataset Tool", "toolName": "datasetFileTool", "description": "Dataset Explore Tool", "types": ["explore"], "scope": "dataset", "toolUrl": "http://example.org/dataset-tool", "toolParameters": { "queryParameters": [{ "datasetPid": "{datasetPid}" }] } }
  2. POST it to Dataverse:
    curl -H "X-Dataverse-key:$API_TOKEN" \ -H "Content-type: application/json" \ -X POST http://localhost:8000/api/externalTools \ --upload-file tool.json
  3. Verify:
    curl http://localhost:8000/api/externalTools

Does this PR introduce a user interface change? If mockups are available, please link/include them here:

If you are a guest user of current dataset, when there is a term or guestbook applied, if you try to use an external tool, the pop-up window should exist
image
image

Is there a release notes or changelog update needed for this change?:

yes

Additional documentation:

@github-actions github-actions Bot added FY26 Sprint 20 FY26 Sprint 20 (2026-03-26 - 2026-04-08) FY26 Sprint 21 FY26 Sprint 21 (2026-04-08 - 2026-04-22) FY26 Sprint 22 FY26 Sprint 22 (2026-04-22 - 2026-05-06) FY26 Sprint 23 FY26 Sprint 23 (2026-05-06 - 2026-05-20) GREI Re-arch GREI re-architecture-related SPA.Q1.2026.1 Download with terms of use and guestbook labels May 8, 2026
@ChengShi-1 ChengShi-1 moved this to In Progress 💻 in IQSS Dataverse Project May 8, 2026
@ChengShi-1 ChengShi-1 added Size: 3 A percentage of a sprint. 2.1 hours. and removed FY26 Sprint 20 FY26 Sprint 20 (2026-03-26 - 2026-04-08) FY26 Sprint 21 FY26 Sprint 21 (2026-04-08 - 2026-04-22) FY26 Sprint 22 FY26 Sprint 22 (2026-04-22 - 2026-05-06) labels May 8, 2026
@coveralls
Copy link
Copy Markdown

coveralls commented May 8, 2026

Coverage Status

coverage: 97.987% (+0.5%) from 97.535% — 941-external-tools-should-require-terms-and-guestbook-response-before-access-a-file into develop

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR ensures that embedded external file tools (e.g., Preview/Query tools shown on the File page when navigated from Dataset external-tool actions) are gated behind dataset terms/license acceptance and guestbook completion when required, matching the JSF behavior described in #941.

Changes:

  • Gate FileEmbeddedExternalTool loading behind DownloadWithTermsAndGuestbookModal when terms/license/guestbook requirements apply.
  • Extend guestbook submission flow to support a “success callback” path (accept/complete requirements without triggering an actual download).
  • Add/adjust Cypress component tests for terms gating, tool filtering, requirements metadata filtering, and resolved tool URL params; add i18n strings for the new UX.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/component/sections/file/file-embedded-external-tool/FileEmbeddedExternalTool.spec.tsx Adds coverage to ensure terms are accepted before the embedded tool URL is fetched/iframe rendered.
tests/component/sections/file/file-action-buttons/access-file-menu/FileToolOptions.spec.tsx Expands tests for filtering by file type, resolved URL call args (preview=false + locale), and unsupported requirements metadata.
tests/component/sections/dataset/dataset-files/files-table/file-actions/file-actions-cell/file-action-buttons/FileTools.spec.tsx Adjusts tests for applicable tool rendering and unsupported requirements metadata handling.
tests/component/sections/dataset/dataset-action-buttons/DatasetToolOptions.spec.tsx Adds tests for filtering dataset tools and unsupported requirements metadata, plus resolved URL call behavior.
src/sections/file/file-embedded-external-tool/FileEmbeddedExternalTool.tsx Implements the gating modal + “terms required” fallback UI before fetching external tool URLs.
src/sections/file/file-action-buttons/access-file-menu/FileToolOptions.tsx Fixes rendering to iterate over applicableTools (filtered) rather than the unfiltered tools.
src/sections/dataset/dataset-files/files-table/file-actions/file-actions-cell/file-action-buttons/file-options-menu/useGuestbookCollectSubmission.ts Adds optional onSubmitSuccess to allow “accept requirements” without starting a download.
src/sections/dataset/dataset-files/files-table/file-actions/file-actions-cell/file-action-buttons/file-options-menu/DownloadWithTermsAndGuestbookModal.tsx Wires onAccept through to the guestbook submission hook as a success callback.
public/locales/en/file.json Adds previewTab.termsRequired string.
public/locales/es/file.json Adds previewTab.termsRequired string.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +41 to +54
const [showTermsAndGuestbookModal, setShowTermsAndGuestbookModal] = useState<boolean>(false)
const [termsAndGuestbookAccepted, setTermsAndGuestbookAccepted] = useState<boolean>(false)

const moreThanOneTool = applicableTools.length > 1
const bypassTermsGuard =
file.datasetVersion.publishingStatus === DatasetPublishingStatus.DRAFT ||
file.permissions.canEditOwnerDataset
const hasGuestbook = file.guestbookId !== undefined
const hasCustomTerms = file.datasetCustomTerms !== undefined
const hasNonDefaultLicense =
file.datasetLicense !== undefined && file.datasetLicense.name !== defaultLicense.name
const requiresTermsAndGuestbook =
!bypassTermsGuard && (hasGuestbook || hasCustomTerms || hasNonDefaultLicense)
const isWaitingForTermsAndGuestbook = requiresTermsAndGuestbook && !termsAndGuestbookAccepted
Comment on lines 64 to +70
// Loads the tool every time the tab is in view or the tool selection changes.
useEffect(() => {
if (!isInView) return
if (isWaitingForTermsAndGuestbook) {
setShowTermsAndGuestbookModal(true)
return
}
Comment thread public/locales/en/file.json Outdated
Comment thread public/locales/es/file.json
@ChengShi-1 ChengShi-1 moved this from In Progress 💻 to Ready for Review ⏩ in IQSS Dataverse Project May 11, 2026
@ChengShi-1 ChengShi-1 marked this pull request as ready for review May 11, 2026 19:43
@cmbz cmbz added the FY26 Sprint 24 FY26 Sprint 24 (2026-05-20 - 2026-06-03) label May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FY26 Sprint 23 FY26 Sprint 23 (2026-05-06 - 2026-05-20) FY26 Sprint 24 FY26 Sprint 24 (2026-05-20 - 2026-06-03) GREI Re-arch GREI re-architecture-related Size: 3 A percentage of a sprint. 2.1 hours. SPA.Q1.2026.1 Download with terms of use and guestbook

Projects

Status: Ready for Review ⏩

Development

Successfully merging this pull request may close these issues.

External tools should require Terms and Guestbook response before access a file

4 participants