Skip to content

WEBUI-1916: Drive action buttons handle failure [LTS-2023]#3065

Merged
swarnadipa-dev merged 59 commits into
maintenance-3.1.xfrom
fix-WEBUI-1916-drive-action-buttons-handle-failure
Jun 3, 2026
Merged

WEBUI-1916: Drive action buttons handle failure [LTS-2023]#3065
swarnadipa-dev merged 59 commits into
maintenance-3.1.xfrom
fix-WEBUI-1916-drive-action-buttons-handle-failure

Conversation

@swarnadipa-dev

@swarnadipa-dev swarnadipa-dev commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Copilot AI review requested due to automatic review settings April 24, 2026 06:43
@swarnadipa-dev swarnadipa-dev requested a review from a team as a code owner April 24, 2026 06:43
@swarnadipa-dev swarnadipa-dev requested review from naveen-konda and vaibhavagarwal4-lab and removed request for a team April 24, 2026 06:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 improves Nuxeo Drive integrations in Web UI by adding a Drive “direct download” selection action and updating Drive action buttons to better handle protocol invocation failures, along with new i18n strings and unit tests.

Changes:

  • Add a new nuxeo-drive-download-button component + icon and register it as a results selection action.
  • Improve Drive action behavior by detecting when nxdrive:// URLs aren’t handled and showing the install dialog / error toast.
  • Extend i18n messages and add unit tests for the new download button logic.

Reviewed changes

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

Show a summary per file
File Description
i18n/messages.json Fix typo (“occurred”) and add i18n strings for Drive download action + errors.
elements/nuxeo-app.js Adds a direct import of the Drive addon into the core app.
addons/nuxeo-drive/test/nuxeo-drive-download-button.test.js New unit tests for the download button behavior and URL building.
addons/nuxeo-drive/nuxeo-drive.html Adds a new RESULTS_SELECTION_ACTIONS slot contribution for Drive download.
addons/nuxeo-drive/index.js Registers the new download button element and injects addon HTML.
addons/nuxeo-drive/elements/nuxeo-drive-upload-button.js Adds protocol-handler failure detection and improved toast error reporting.
addons/nuxeo-drive/elements/nuxeo-drive-icons.js Adds the Drive download icon to the iconset.
addons/nuxeo-drive/elements/nuxeo-drive-edit-button.js Adds protocol-handler failure detection when invoking Drive edit.
addons/nuxeo-drive/elements/nuxeo-drive-download-button.js New element implementing Drive direct-download action, guardrails, and error handling.

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

Comment thread elements/nuxeo-app.js Outdated
Comment thread addons/nuxeo-drive/test/nuxeo-drive-download-button.test.js Outdated
Comment thread addons/nuxeo-drive/test/nuxeo-drive-download-button.test.js Outdated
Comment thread addons/nuxeo-drive/elements/nuxeo-drive-edit-button.js Outdated
@swarnadipa-dev swarnadipa-dev changed the base branch from maintenance-3.1.x to feat-WEBUI-1963-direct-download-from-webui-to-nuxeo-drive April 27, 2026 06:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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


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

Comment thread addons/nuxeo-drive/elements/nuxeo-drive-download-button.js Outdated
Comment thread addons/nuxeo-drive/elements/nuxeo-drive-edit-button.js Outdated
Comment thread addons/nuxeo-drive/test/nuxeo-drive-upload-button.test.js Outdated
Comment thread addons/nuxeo-drive/test/nuxeo-drive-edit-button.test.js Outdated
Comment thread addons/nuxeo-drive/test/nuxeo-drive-download-button.test.js Outdated
Comment thread addons/nuxeo-drive/elements/nuxeo-drive-download-button.js Outdated
Comment thread elements/nuxeo-app.js Outdated
Comment thread addons/nuxeo-drive/elements/nuxeo-drive-upload-button.js Outdated
@swarnadipa-dev swarnadipa-dev force-pushed the feat-WEBUI-1963-direct-download-from-webui-to-nuxeo-drive branch from 782a136 to 7fa2e2c Compare April 29, 2026 11:46
@swarnadipa-dev swarnadipa-dev force-pushed the fix-WEBUI-1916-drive-action-buttons-handle-failure branch from 38b6a39 to f86fbc4 Compare April 30, 2026 06:13
@swarnadipa-dev swarnadipa-dev force-pushed the feat-WEBUI-1963-direct-download-from-webui-to-nuxeo-drive branch from 52570e2 to b360683 Compare April 30, 2026 12:52
@swarnadipa-dev swarnadipa-dev force-pushed the fix-WEBUI-1916-drive-action-buttons-handle-failure branch from 6df44c5 to a43daa4 Compare May 1, 2026 05:12
@swarnadipa-dev swarnadipa-dev force-pushed the feat-WEBUI-1963-direct-download-from-webui-to-nuxeo-drive branch from 47ca79b to f0b8645 Compare May 3, 2026 05:21
@swarnadipa-dev

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

@CLAassistant

CLAassistant commented May 3, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Copilot AI commented May 3, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Merge conflicts have been resolved in commit 042fd673. The three conflicting files were resolved as follows:

  • nuxeo-drive-download-button.js: Kept the _openDriveUrl blur-detection heuristic and _navigate helper from this branch; adopted the more complete _isAvailable binding (with selectedItems observability) from the base branch.
  • nuxeo-drive-download-button.test.js: Kept tests that stub _navigate; updated the "deselect items" test to use _navigate instead of window.open; retained the full _openDriveUrl test suite.
  • i18n/messages.json: Merged unique keys from both branches (driveEditButton.directTransfer.failed + driveUpload.* + driveUploadButton.*), removed duplicates, and fixed alphabetical ordering (commit 4d1c2384).

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • packages.nuxeo.com
    • Triggering command: /usr/local/bin/node node /usr/local/bin/npm install (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@swarnadipa-dev swarnadipa-dev changed the title WEBUI-1916 drive action buttons handle failure WEBUI-1916: Drive action buttons handle failure [LTS-2023] May 4, 2026
@swarnadipa-dev swarnadipa-dev force-pushed the fix-WEBUI-1916-drive-action-buttons-handle-failure branch 2 times, most recently from f455896 to 6e0d473 Compare May 5, 2026 09:21
- Left-align title and description, matching standard Nuxeo dialog layout
- Move Open with Nuxeo Drive button to footer (Close left, Open right)
- Style Close button with outline border matching Cancel in other dialogs
- Reduce dialog padding for compact layout
- Use red color for failure message text
- Add _failureVisible flag so error message persists after blur events
- Align desktop packages table headers with content
- Improve text contrast for a11y compliance
…show install option

- Remove all blur/focus/timeout detection logic and browser/OS sniffing
- Use simple window.location.href for nxdrive:// protocol
- Always show install link; auto-expand when no Drive token found
- Show hint text after Open click with download packages
- Disable Open button after click; reset on dialog reopen
- Remove driveButton.dialog.couldNotOpen i18n key
- Add driveButton.dialog.install.hint i18n key
…% coverage

- Add addGoErrorSuites: token-found branch (_hasToken=true, _installExpanded stays false)
- Add addOpenDriveSuite: covers _openDrive (_opened, _installExpanded, window.location.href)
- Add addToggleInstallSuite: covers _toggleInstall (_installExpanded, preventDefault)
- Wire new shared suites into edit, upload and download button test files
- Add driveEditURL construction tests (valid URL shape, filename encoding)
- Add _download token-found and catch branch tests for download button"
- Replace _showInstall with _installExpanded (correct property name)
- Token-fetch failure tests check _installExpanded instead of toast
  (catch branch sets _installExpanded, not showError)
- Remove addLaunchDriveSuite from edit/upload/download buttons
  (those elements have no _navigateTo / _launchDrive methods)
- Guard window.location.href in addOpenDriveSuite setup to prevent
  nxdrive:// assignments triggering Karma page reload
- Fix inline _openDrive suite in download-button test accordingly
Each drive button's _openDrive() now delegates window.location.href
assignment to a dedicated _navigate(url) method. This makes the
navigation stubbable in unit tests, eliminating the Karma
'full page reload' CI failure caused by Chrome 148 handling
nxdrive:// URLs as real navigation.

Updated addOpenDriveSuite in test helpers and the download-button
inline _openDrive suite to stub _navigate and assert the correct URL
is passed.
- Add _navigate() test suite inside addOpenDriveSuite that exercises
  the real window.location.href assignment path via a property getter spy
- Add _compressFromOriginalUrl server-too-long error path test in
  download-button (crafted 300-char server segment triggers the throw)
- Replace stub-based server-too-long test in upload-button with one that
  stubs TextEncoder.prototype.encode to force the > 255 guard,
  ensuring lines 242-244 of nuxeo-drive-upload-button.js are hit
- Exclude addons/*/test/**/*.js from sonar coverage (test helpers are
  not production code; previously nuxeo-drive-test-helpers.js dragged
  coverage on new code down to 34.4%)
…ers.test.js

The .test.js suffix matches sonar.coverage.exclusions (**/*.test.js)
so Sonar no longer counts the helper file as uncovered production code,
fixing the 34.4% coverage on new code reported in the PR.

Also remove redundant /* global */ comment — the test environment
already provides sinon, suite, setup, teardown, test and expect as
built-in globals; the comment caused no-redeclare ESLint errors
when the .test.js eslint config applied its test environment.
The nuxeo-drive-test-helpers.js file was renamed to
nuxeo-drive-test-helpers.test.js, so it now matches the existing
**/*.test.js exclusion pattern. The explicit addons/*/test/**/*.js
rule added in the previous commit is no longer needed.
…e duplication

Create nuxeo-drive-utils.js with:
- fetchTokenAndToggleDialog(): replaces the identical 18-line token-fetch +
  dialog.toggle() block duplicated across edit, download and upload buttons
- base64UrlSafeEncode(): replaces the identical _base64UrlSafeEncode() method
  duplicated across download and upload buttons

Update all three element files to import from the shared utils module.
Update nuxeo-drive-upload-button.test.js to call base64UrlSafeEncode()
directly instead of via element._base64UrlSafeEncode() (method removed).

All 1965 tests continue to pass.
- Optional chain: tokens && tokens.length -> tokens?.length (L41)
- String.fromCodePoint over String.fromCharCode (L62)
- replaceAll over regex replace for + and / substitutions (L64, x2)
Replace /=+$/ regex with indexOf + slice to strip Base64 padding,
eliminating the security hotspot without changing behaviour.
- Replace unreliable protocol detection with immediate nxdrive:// navigation
- Show lightweight fallback dialog with expandable install links
- Remove token fetch, sessionStorage suppression, and detection hacks
- Simplify all three buttons (edit, upload, download) to consistent UX
- Add i18n keys for new dialog heading and hint text
Rewrite test files to match the refactored Drive action buttons:
- Remove references to removed APIs ($.token, _hasToken, _opened, _navigate, _openDrive)
- Replace old suite factories with addGoSuite, addShowErrorSuite, addToggleInstallSuite
- Keep URL compression, guard condition, and availability tests
Replace globalThis.location.href with anchor element click in
navigateAndShowFallback to prevent full page reloads in browsers
that don't recognize the nxdrive:// custom protocol. Anchor clicks
with unknown schemes are silently ignored by the browser.

Move the HTMLAnchorElement.prototype.click stub into test helpers
so all drive test files benefit from it.
Add tests for uncovered branches:
- edit button: _isAvailable returning true, blob without appLinks property
- upload button: _isAvailable with null/undefined doc, _go catch branch
- download button: _download catch branch with/without userMessage
…igate

- Add defensive check for element._navigate existence before stubbing
- Prevents flaky tests caused by shared globalThis.location state
- Ensures test isolation: each element instance has its own navigation stub
- Gracefully handles elements without _navigate method
- Addresses Copilot review comment about test order dependency
@swarnadipa-dev swarnadipa-dev force-pushed the fix-WEBUI-1916-drive-action-buttons-handle-failure branch from 9e55b20 to 1408f1e Compare June 3, 2026 07:54
@sonarqubecloud

sonarqubecloud Bot commented Jun 3, 2026

Copy link
Copy Markdown

@swarnadipa-dev swarnadipa-dev merged commit f5d0d8b into maintenance-3.1.x Jun 3, 2026
14 checks passed
@swarnadipa-dev swarnadipa-dev deleted the fix-WEBUI-1916-drive-action-buttons-handle-failure branch June 3, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants