Skip to content

feat(DIARCHERS-1650): add Project Token creation entry to My Tokens page - #633

Open
Jiachen0715 wants to merge 6 commits into
masterfrom
feat/DIARCHERS-1650-mytokens-project-token
Open

feat(DIARCHERS-1650): add Project Token creation entry to My Tokens page#633
Jiachen0715 wants to merge 6 commits into
masterfrom
feat/DIARCHERS-1650-mytokens-project-token

Conversation

@Jiachen0715

Copy link
Copy Markdown
Contributor

Summary

The Project Tokens section on the My Tokens page (/user/tokens) was
read-only — it listed existing project tokens but only hinted "Manage
individual project tokens in each project's settings". Creating a project
token required navigating into each project's Settings → Tokens page
individually.

This PR adds an inline creation entry to that section, consistent with the
MCP Token and Global Viewer Token create forms already on the same page.

Changes

Frontend-only, single file (UserGlobalTokens.vue):

  • Add a create form to the Project Tokens section: project selector
    (populated from the user's admin-rights projects) + description input
    • create button.
  • The new entry reuses the existing Project.addToken() model method,
    which posts to POST /api/v1/projects/{id}/tokens and reloads that
    project's token list on success — the same call used by project
    settings. No logic divergence.
  • On success, reuses the existing "Token Created" dialog to show the token
    value once (INFRABOX_CLI_TOKEN).
  • Updated the section hint; added an empty-state note when the user has no
    admin-rights projects.

What is NOT changed

  • No backend changes — reuses the existing project token endpoint.
  • The existing project settings creation entry is untouched.
  • No MCP / AI-agent related logic touched.

Jiachen Fan added 6 commits August 11, 2026 10:30
The Project Tokens section of the My Tokens page was read-only, forcing
users into each project's Settings → Tokens page to create a token. Add
an inline create form (project selector + description) that reuses the
existing Project.addToken() → POST /api/v1/projects/{id}/tokens, so both
entries share the same backend and logic. Frontend-only; no backend change.
The project dropdown in the new Project Token create form rendered with a
transparent menu, so option text overlapped the "Project" label. Add the
global bg-white class to md-option (matching every other md-select in the
dashboard) and name/id attributes for consistency. The dropdown's built-in
max-height + scroll handles long project lists.
The project token list depends on store.state.projects, which is populated
asynchronously. Opening My Tokens directly (e.g. on refresh) ran created()
before projects loaded, so the list stayed empty until an unrelated action
forced a re-render. Extract the load into loadProjectTokens() and watch
adminProjects.length so the list populates once projects arrive, guarded by
projectTokensLoaded to avoid reloading on later changes.
Address review findings on the project-token loading path:
- The permanent projectTokensLoaded gate blocked the watcher's catch-up, so
  admin projects arriving in a later store commit never got their tokens
  loaded. Track loaded project ids instead and fetch only not-yet-loaded
  projects, so late arrivals are picked up while avoiding duplicate GETs.
- Use _reloadTokens() (returns a real Promise) rather than _loadTokens()
  (returns undefined on cache hit), so projectTokensLoading stays on until
  the GETs actually complete — no premature "No project tokens found." flash
  — and the list is fresh on every visit.
- Hide the create form (not just the note) when the user has no admin-rights
  projects.
…s page

Add an Actions column with a delete button to the Project Tokens table, plus
a confirmation dialog (mirrors the MCP/Viewer revoke dialogs — shows only the
description, no token value). Deletion reuses Project.deleteToken() -> DELETE
projects/{id}/tokens/{tid}, the same call used by project settings, which
reloads the project's token list on success. Frontend-only; no backend change.
…headers

vue-material renders header text in .md-table-head-text (which has
padding-left: 24px) but cell content in .md-table-cell-container (no left
padding), so the Read/Write check icons sat to the left of their header
labels. A plain text-center/text-align on the cell has no effect because the
inner container controls layout. Add a scoped deep rule giving the Read/Write
cells' inner container the same 24px left padding as the header text, so the
icons line up under their column titles. Actions is left unchanged.
@Jiachen0715
Jiachen0715 force-pushed the feat/DIARCHERS-1650-mytokens-project-token branch from 9517920 to 3d2ba31 Compare August 13, 2026 07:37
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.

1 participant