Skip to content

feat(config): let a consumer hand uicore its settings via setConfig - #352

Open
gcutrini wants to merge 4 commits into
feat/access-token-resolver-5xfrom
feat/config-setter-5x
Open

gcutrini wants to merge 4 commits into
feat/access-token-resolver-5xfrom
feat/config-setter-5x

Conversation

@gcutrini

@gcutrini gcutrini commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

ref: https://app.clickup.com/t/86bcdq027

5.x sibling of #351 (v4.x). Based on #329 (resolver 5.x).

uicore reads its OAuth/app settings (apiBaseUrl, idpBaseUrl, oauth2ClientId, timeApiUrl) from window globals by default. setConfig lets a consumer hand uicore those settings directly; the config readers (clock, exclusive-wrapper, auth-callback routes, security actions/methods) delegate to it when a config is registered, otherwise the built-in window-globals flow is unchanged. Shared through a globalThis Symbol.for slot, consistent with the resolver (#329).

Settings registered through setConfig win over the window globals uicore
has always read; unset keys keep the window fallback, so existing
consumers are unaffected. A key set to undefined or an empty string is
unset; null, false and 0 are values (oauth2UseRefreshToken: false turns
the refresh flow off).

The state lives on globalThis under
Symbol.for('openstack-uicore-foundation.config'), so every copy of the
module shares it: bundles that inline it, nested installs, and symlinked
dev checkouts.
getServerTime fetched whatever getTimeServiceUrl returned, so an
unconfigured host produced a garbage request ('' fetches the current
page, undefined fetches the literal string) before landing on the same
local-clock fallback a rejected fetch reaches directly.
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9abbcca2-86d7-47ef-926d-b0b44be1d9b0
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@gcutrini
gcutrini added this pull request to stack #354 October 6, 2026 16:04
@gcutrini
gcutrini removed this pull request from stack #354 October 6, 2026 16:08
@gcutrini
gcutrini added this pull request to stack #355 October 6, 2026 16:22
readConfig and setConfig used bare globalThis. They now use the same
_global fallback (globalThis → window → {}) as the security methods, so
the window-globals fallback still works on a runtime without globalThis.
getUserInfo split the allowed-user-groups string whenever it was not '',
so the null value getAllowedUserGroups returns with no window threw.
parseUserGroups splits a truthy string and returns an empty list for any
falsy value; getUserInfo calls it.
@smarcet
smarcet requested review from santipalenque and smarcet and a balanced review from Copilot and removed request for smarcet October 27, 2026 20:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block approval of the opt-in configuration changes.

No open issues 🎉

What changed in this PR

Adds opt-in setConfig support so consumers can supply uicore settings directly while retaining window-global fallbacks. Configuration is shared across package copies using the same global-symbol pattern as the access-token resolver.

Changes:

  • Adds a public configuration module and preserves existing getter exports.
  • Routes security, API, clock, and exclusive-section settings through configuration getters.
  • Adds tests for overrides, fallbacks, resets, shared state, and server-side reads; skips clock requests when no endpoint is configured.
File Description
webpack.common.js Exposes the utils/config entry point.
src/​utils/​query-actions.js Imports API URL construction from config.
src/​utils/​methods.js Re-exports relocated configuration getters.
src/​utils/​config.js Adds shared configuration storage, getters, and group parsing.
src/​utils/​__tests__/​config.test.js Tests overrides, resets, and cross-copy sharing.
src/​utils/​__tests__/​config-reads.test.js Tests window fallbacks and legacy exports.
src/​utils/​__tests__/​config-no-window.test.js Tests defaults and overrides without a window.
src/​components/​security/​reducers.js Reads OAuth settings from config.
src/​components/​security/​methods.js Uses and re-exports centralized OAuth getters.
src/​components/​security/​actions.js Uses configured API URLs and allowed-group parsing.
src/​components/​security/​abstract-auth-callback-route.js Reads callback OAuth flow from config.
src/​components/​security/​abstract-auth-callback-route-v2.js Reads callback OAuth flow from config.
src/​components/​security/​__tests__/​get-user-info.test.js Updates mocks to target the config module.
src/​components/​exclusive-wrapper.js Reads exclusive sections through config.
src/​components/​clock.js Uses configured time endpoint and skips requests when absent.

Review effort: Balanced

@smarcet

smarcet commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

@gcutrini please review CI

@santipalenque santipalenque 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.

LGTM

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.

4 participants