External tools require terms or guestbook response if applicable#987
Open
ChengShi-1 wants to merge 4 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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
FileEmbeddedExternalToolloading behindDownloadWithTermsAndGuestbookModalwhen 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 | ||
| } |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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:
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}" }] } }curl -H "X-Dataverse-key:$API_TOKEN" \ -H "Content-type: application/json" \ -X POST http://localhost:8000/api/externalTools \ --upload-file tool.jsoncurl http://localhost:8000/api/externalToolsDoes 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


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