Skip to content

Comments

Add confirmation modal for adaptor changes with credentials #4446

Open
lmac-1 wants to merge 5 commits intomainfrom
4395-fix-adaptor-change-credentials
Open

Add confirmation modal for adaptor changes with credentials #4446
lmac-1 wants to merge 5 commits intomainfrom
4395-fix-adaptor-change-credentials

Conversation

@lmac-1
Copy link
Collaborator

@lmac-1 lmac-1 commented Feb 22, 2026

Originally raised in #4413 but I missed adding this functionality to FullScreenIDE, so started the approach again from scratch with this information.

Description

Fixes credential handling when changing job adaptors. When users select a different adaptor, a confirmation modal now warns that credentials will be reset.

Key changes:

  • Confirmation modal appears only when: (1) changing to a different adaptor package, (2) a credential is currently selected
  • Both project_credential_id and keychain_credential_id are reset on confirmation
  • Created useAdaptorChangeConfirmation hook to share logic between FullScreenIDE and JobForm

Improvements over PR #4413:

  • Hook-based architecture eliminates code duplication
  • Fixed FullScreenIDE crash when currentJob is null
  • Fixed Continue button navigation using ref pattern
  • Fixed modal z-index stacking
  • Skips confirmation when selecting same adaptor
  • Added 21 unit tests

Closes #4395

Validation steps

Setup:

  1. Open collaborative editor and select a job with an adaptor
  2. Click Connect and create a credential to add to that step

1. Confirmation appears when changing adaptors WITH credentials:

  1. Click on the adaptor on the step to open adaptor picker
  2. Select a different adaptor (e.g., switch from Salesforce to HTTP)
  3. Expected: "Change Adaptor?" confirmation modal appears with warning
  4. Click "Continue"
  5. Expected: Credential clears, adaptor changes, version auto-selects latest version number

2. No confirmation when changing adaptors WITHOUT credentials:

  1. Clear any selected credential
  2. Click "Change" and select different adaptor
  3. Expected: No confirmation, adaptor changes immediately

3. No confirmation for same adaptor
Set job to HTTP adaptor with credential
Click "Configure" → "Change" → Select HTTP again
✓ No confirmation, configure modal reopens

4. No confirmation when changing versions:

  1. With credential set, change version in dropdown (don't click "Change")
  2. Expected: No confirmation, version changes immediately

5. Cancel preserves state:

  1. With credential set, click "Change" → select different adaptor
  2. Click "Cancel" on confirmation
  3. Expected: Original adaptor and credential unchanged, modal stays open

Repeat the same tests for FullScreenIDE - Click "Code" and then change the adaptor from there

Additional notes for the reviewer

  1. NOTE: Pressing Escape when the confirmation modal is open closes everything (confirmation + modal + inspector).
    This is consistent with existing behaviour for delete/reset confirmations throughout Inspector. If we want to
    change this so Escape only closes the confirmation dialog (leaving the parent modal open), that should be
    handled in a separate issue as it would require reworking how AlertDialog integrates with the keyboard
    shortcut priority system across the application.

AI Usage

Please disclose whether you've used AI anywhere in this PR (it's cool, we just
want to know!):

  • I have used Claude Code
  • I have used another model
  • I have not used AI

You can read more details in our
Responsible AI Policy

Pre-submission checklist

  • I have performed an AI review of my code (we recommend using /review
    with Claude Code)
  • I have implemented and tested all related authorization policies.
    (e.g., :owner, :admin, :editor, :viewer)
  • I have updated the changelog.
  • I have ticked a box in "AI usage" in this PR

Show confirmation modal when users select a different adaptor. The modal
warns that credentials will be reset and gives users a chance to cancel.

Created useAdaptorChangeConfirmation hook to share logic between
FullScreenIDE and JobForm. Confirmation only appears when the job has
credentials and the user selects a different adaptor package.

Also fixed AlertDialog z-index to sit above other modals.
@codecov
Copy link

codecov bot commented Feb 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.38%. Comparing base (a3126d7) to head (df00b2f).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4446      +/-   ##
==========================================
+ Coverage   89.36%   89.38%   +0.01%     
==========================================
  Files         425      425              
  Lines       20187    20187              
==========================================
+ Hits        18041    18045       +4     
+ Misses       2146     2142       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lmac-1 lmac-1 removed the request for review from midigofrank February 23, 2026 07:48
Copy link
Contributor

@doc-han doc-han left a comment

Choose a reason for hiding this comment

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

I initially expected issue #4395 to require less code than it did.

This PR addresses two things:

  1. Fixes the reported bug
  2. Introduces a confirmation modal when switching adaptors (new feature)

Since this changes the user experience, it may be worth a UX review. @theroinaochieng.

I'm wondering whether 2. could've been a feature PR instead of being added to a bug fix. The new confirmation modal increases the number of clicks users have to be doing whenever they're switching adaptors with credentials(the default for production work).

Comment on lines 425 to 434
<AlertDialog
isOpen={isAdaptorChangeConfirmationOpen}
onClose={handleCloseConfirmation}
onConfirm={handleConfirmAdaptorChange}
title="Change Adaptor?"
description="Warning: Changing adaptors will reset the credential for this step. Are you sure you want to continue?"
confirmLabel="Continue"
cancelLabel="Cancel"
variant="primary"
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

We now have this <AlertDialog /> being placed in two different places. I'm wondering wouldn't it have been best to have it in the <ConfigureAdaptor /> component so that wherever adaptor modal is used, we automatically have this <AlertDialog /> ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you for your feedback 🙏🏻.

I don't think adding the alert dialog to ConfigureAdaptorModal component will work because:

  • It opens after the adaptor has already changed - it's for selecting the version/credential for an adaptor
  • The confirmation needs to happen before we commit to the new adaptor change, not after (ie from AdaptorSelectionModal)

I also don't think it makes sense to put it into AdaptorSelectionModal because:

  • WorkflowDiagram uses it to create new jobs (which don't have credentials and don't need confirmation)
  • It would force WorkflowDiagram to pass job/updateJob/setIsConfigureModalOpen etc props it doesn't need
  • Nested modals feel a bit messy

Instead, I created a composite AdaptorSelector component that bundles AdaptorSelectionModal + AlertDialog + confirmation hook. I also fixed the ESC problem! What do you think?

Comment on lines 1383 to 1392
<AlertDialog
isOpen={isAdaptorChangeConfirmationOpen}
onClose={handleCloseConfirmation}
onConfirm={handleConfirmAdaptorChange}
title="Change Adaptor?"
description="Warning: Changing adaptors will reset the credential for this step. Are you sure you want to continue?"
confirmLabel="Continue"
cancelLabel="Cancel"
variant="primary"
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Being called at two different location. could go into adaptor modal

Update all 21 test names in useAdaptorChangeConfirmation tests to use
"should" prefix for better readability and consistency with common testing
conventions (e.g., "shows confirmation" → "should show confirmation").
The AlertDialog for confirming adaptor changes was duplicated in
FullScreenIDE and JobForm. Extract this into a composite AdaptorSelector
component that bundles AdaptorSelectionModal, AlertDialog, and the
confirmation hook.

Fixes ESC key handling by adding a higher-priority keyboard shortcut
(110 vs 100) so pressing ESC on the confirmation dialog closes it
instead of the picker behind it.

Removes ~70 lines of duplicated code.
@lmac-1 lmac-1 requested a review from doc-han February 23, 2026 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New Issues

Development

Successfully merging this pull request may close these issues.

Changing adaptor type doesn't reset credentials

2 participants