refactor: split dashboard app.js into 9 ES modules#193
Open
refactor: split dashboard app.js into 9 ES modules#193
Conversation
Split 1553-line monolith into focused modules: - ui-utils.js: error classification, clipboard, modals, icons - auth.js: session state, cached API client singleton, theme, login - billing.js: Stripe integration with payment integrity fix - groups.js: multi-select builders, table rendering, CRUD - keys.js: usage key table, 7-field permission modal, CRUD - actions.js: IPFS action table, CRUD - wallets.js: wallet table, CRUD - runner.js: CodeJar editor, execute/getCid - app.js: entry point orchestrating init Bug fixes included: - getClient() now caches singleton instead of new instance per call - preloadAllTables uses Promise.allSettled with error banner - Payment flow: separate confirmPayment catch for integrity - Billing amount validation: minimum $5.00 (500 cents) - Error classification: auth/network/server user-friendly messages - Unified copyToClipboard utility replacing 3 inline patterns - Button disable-on-click during async operations - loadBillingBalance shows "Balance unavailable" on error Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…-review # Conflicts: # lit-static/dapps/dashboard/actions.js # lit-static/dapps/dashboard/auth.js # lit-static/dapps/dashboard/billing.js # lit-static/dapps/dashboard/groups.js # lit-static/dapps/dashboard/keys.js # lit-static/dapps/dashboard/runner.js # lit-static/dapps/dashboard/ui-utils.js # lit-static/dapps/dashboard/wallets.js
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
6 items from adversarial review during PR1 ship — mostly pre-existing patterns from the monolith. P1: initLogin null check. P2: auth ordering, confirm dialog race. P3: listener leak, form value ordering, async fallback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Change sed target from app.js to auth.js (where __LIT_API_BASE_URL__ moved during the module refactor) - Add actions/setup-node@v4 so npm is available for wrangler-action on the self-hosted runner Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
initLogin() now calls updateAuthUI() when an existing API key is found in sessionStorage. Without this, returning users saw an empty dashboard because the has-api-key class was never toggled and preloadAllTables/ loadBillingBalance/updateStatCards were never called. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- deploy-static.yml: all jobs now target auth.js (module refactor moved placeholder) - TODOS.md: keep both dashboard adversarial findings and Stripe validation TODO - app.js: keep refactored entry point (monolith code now in separate modules)
…vior The refactored loadActions() added groupId: '0' which was not in the original monolith. This could filter actions to only the default group, diverging from the "zero behavior change" intent of the refactor. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The setup-node@v4 step was only in deploy-main. Added to deploy-next and deploy-preview for consistency across all deploy jobs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Keep deploy-preview job from our branch (added in this PR). origin/next had no changes to the end of the file. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The configOperator address was referenced in AccountConfig.sol constructor, SecurityLib, APIConfigFacet, and ViewsFacet but never declared in the AccountConfigStorage struct, causing Solidity compilation failure. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The self-hosted runner doesn't have npm in PATH, causing cloudflare/wrangler-action@v3 to fail when trying to install wrangler. Add actions/setup-node@v4 with Node 20 before the deploy step, matching the pattern used by other workflows in this repo. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ains (#261) - api.dev.litprotocol.com → api.chipotle.litprotocol.com - dashboard.dev.litprotocol.com → dashboard.chipotle.litprotocol.com - docs.dev.litprotocol.com → developer.litprotocol.com - Fix broken swagger-ui path (/swagger-ui/ → /core/v1/swagger-ui) - Remove broken Support navbar link - Fix broken SDK link in encryption migration doc Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs: migrate README URLs from dev.litprotocol.com to new domains Same migration as the docs/ directory (PR #261): - api.dev.litprotocol.com → api.chipotle.litprotocol.com - dashboard.dev.litprotocol.com → dashboard.chipotle.litprotocol.com - docs.dev.litprotocol.com → developer.litprotocol.com Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: update "dev API" to "API" in README quickstart Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: add usage API key step to README quickstart Adds step 2 showing how to create a scoped usage API key before using the API, reinforcing the best practice of not embedding the account key in apps. Renumbers subsequent steps. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: reorder quickstart — add funds before usage API key Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace localhost:8000 and api.dev.litprotocol.com references in curl examples across MDX docs with https://api.chipotle.litprotocol.com. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
After merging next, the struct had two configOperator declarations: one from next (replacing owner) and one from our earlier fix commit. Remove the duplicate at the end of the struct, keeping next's version. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Merge with next created duplicate setup-node steps in deploy-main and deploy-next jobs. Also reordered deploy-preview to match consistent pattern: checkout → setup-node → inject URL → deploy. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| ref: ${{ inputs.version_tag }} | ||
|
|
||
| - uses: actions/setup-node@v4 | ||
| with: |
Contributor
There was a problem hiding this comment.
The sed command still targets app.js but the __LIT_API_BASE_URL__ placeholder is now in auth.js after the refactor. This will cause the production deployment to use the wrong API URL (localhost fallback).
run: sed -i "s|__LIT_API_BASE_URL__|https://api.chipotle.litprotocol.com|g" lit-static/dapps/dashboard/auth.jsSpotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
…ture Merges origin/next which adds usage API key override feature. Resolves conflict in app.js by keeping modular structure and porting the new feature into ES modules: - auth.js: getEffectiveApiKey, override state management, debug proxy - app.js: override UI init, sign-out cleanup - groups/keys/actions/wallets: use getEffectiveApiKey for CRUD ops - runner: use getEffectiveApiKey for action execution Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
Refactors the monolithic dashboard
app.js(1553 lines) into 9 focused ES modules for maintainability and readability.Changes
auth.js,ui-utils.js,billing.js,groups.js,keys.js,actions.js,wallets.js,runner.js, and slimapp.jsentry pointgroupId: '0'param fromlistActionssetup-nodestepnext:configOperatorfield inAccountConfigStoragestructsetup-nodesteps indeploy-static.ymlArchitecture
ui-utils.js→auth.js→ feature modules →app.jsentryescapeHtml()— no XSS vectorsFiles changed
lit-static/dapps/dashboard/app.jsreduced from 1553 to 37 linesTest plan
__LIT_API_BASE_URL__injection inauth.js🤖 Generated with Claude Code