Skip to content

Sets the script to the default script instead of an empty string when reseting adaptive script#9740

Open
HasiniSama wants to merge 3 commits intowso2:masterfrom
HasiniSama:fix-cond-auth-script
Open

Sets the script to the default script instead of an empty string when reseting adaptive script#9740
HasiniSama wants to merge 3 commits intowso2:masterfrom
HasiniSama:fix-cond-auth-script

Conversation

@HasiniSama
Copy link
Contributor

@HasiniSama HasiniSama commented Mar 11, 2026

Purpose

$subject

Changes introdcued:

  1. Set reset default script as source and internal editor value.
  2. Normalize internal script as joined string (matching editor onChange format)
  3. Update internal step count on reset to avoid stale step-based resolution
  4. Prevent old custom script from reappearing after step/sequence refresh

Issues: wso2/product-is#26991

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: d8549fe8-bd32-4f4b-bf92-d695c9f15671

📥 Commits

Reviewing files that changed from the base of the PR and between 257cf61 and 772015b.

📒 Files selected for processing (1)
  • features/admin.applications.v1/components/settings/sign-on-methods/script-based-flow/script-based-flow.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • features/admin.applications.v1/components/settings/sign-on-methods/script-based-flow/script-based-flow.tsx

📝 Walkthrough

Walkthrough

Updated copyright year and changed adaptive script reset to populate a generated default script (based on current authentication steps) instead of clearing the source; added a patch changeset documenting this behavioral change and minor manifest edits.

Changes

Cohort / File(s) Summary
Script-Based Flow Component
features/admin.applications.v1/components/settings/sign-on-methods/script-based-flow/script-based-flow.tsx
Updated copyright year to 2026. In resetAdaptiveScriptTemplateToDefaultHandler replaced clearing the source (setSourceCode("")) with generation and assignment of a default script via AdaptiveScriptUtils.generateScript(authenticationSteps + 1), and updated setInternalScript(...), setInternalStepCount(authenticationSteps); retained setIsScriptFromTemplate(false), onAdaptiveScriptReset(), and onConditionalAuthenticationToggle(false).
Changeset
.changeset/nasty-garlics-jog.md
Added a patch changeset for @wso2is/admin.applications.v1 and @wso2is/console documenting that resetting the adaptive script now restores a generated default script instead of an empty source.
Manifest / Package metadata
package.json
Minor manifest edits accompanying the patch release metadata (small line changes).
🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description provides purpose and specific changes but is incomplete; it lacks details on testing, documentation, and security checks required by the template. Complete the PR description by addressing the template sections: add related issues/PRs, mark relevant checklist items, and confirm security checks were performed.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: setting the script to the default script instead of an empty string when resetting adaptive script.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Changeset Required ✅ Passed The pull request includes a proper changeset file with all required information and correctly specifies patch version updates for modified feature and parent console packages.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@features/admin.applications.v1/components/settings/sign-on-methods/script-based-flow/script-based-flow.tsx`:
- Around line 567-571: resetAdaptiveScriptTemplateToDefaultHandler currently
only updates sourceCode, leaving internalScript populated so
resolveAdaptiveScript() can later prefer the old value; update the handler to
also clear/overwrite the internal editor buffer (e.g., call
setInternalScript(null) or setInternalScript(generatedScript)) after generating
the default via AdaptiveScriptUtils.generateScript(authenticationSteps + 1) so
resolveAdaptiveScript() will no longer restore the previous custom script.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: aaae9086-e3db-4776-9be3-6a9c89351b03

📥 Commits

Reviewing files that changed from the base of the PR and between 5e1ce13 and 4b0ebc6.

📒 Files selected for processing (1)
  • features/admin.applications.v1/components/settings/sign-on-methods/script-based-flow/script-based-flow.tsx

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.changeset/nasty-garlics-jog.md:
- Line 6: Change the typo "reseting" to "resetting" in the changeset note text
inside .changeset/nasty-garlics-jog.md so the user-facing release note reads
"Sets the script to the default script instead of an empty string when resetting
adaptive script"; update only the word in that sentence (leave surrounding
wording intact).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 25d773a5-7777-4bd1-90a6-9ee324840844

📥 Commits

Reviewing files that changed from the base of the PR and between 4b0ebc6 and 257cf61.

📒 Files selected for processing (1)
  • .changeset/nasty-garlics-jog.md


const resetAdaptiveScriptTemplateToDefaultHandler = () => {
setSourceCode("");
setSourceCode(AdaptiveScriptUtils.generateScript(authenticationSteps + 1));
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we expecting to save the default script when disabling the conditional authentication?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the previous default behavior for the Classic Editor. It was changed when introducing the Script Update REST API feature [1]. Since this feature is disabled by default, this change introduced a regression in the Classic Editor.

Additionally, since the previous behavior aligns with the Visual Editor, we propose reverting to the earlier implementation to avoid breaking the current flow.

[1] a9c5cf7#diff-6eb727e98b131f02e3e21db95b23fadb0fe174733537a3a163a1e5e0e7faa5c7R579

@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.01%. Comparing base (9f537f2) to head (772015b).
⚠️ Report is 19 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #9740   +/-   ##
=======================================
  Coverage   56.01%   56.01%           
=======================================
  Files          42       42           
  Lines        1023     1023           
  Branches      231      246   +15     
=======================================
  Hits          573      573           
+ Misses        450      416   -34     
- Partials        0       34   +34     
Flag Coverage Δ
@wso2is/core 56.01% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 10 files with indirect coverage changes

🚀 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.

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.

2 participants