Skip to content

fix(client): stop gating project creation on the flat admin-only flag - #3493

Open
Kaveh-Vakili wants to merge 5 commits into
devfrom
admin-only-project-add-ui-gating
Open

fix(client): stop gating project creation on the flat admin-only flag#3493
Kaveh-Vakili wants to merge 5 commits into
devfrom
admin-only-project-add-ui-gating

Conversation

@Kaveh-Vakili

Copy link
Copy Markdown
Contributor

Description

configStore.isEngineOperationAvailable("PROJECT", "add") only checks a single boolean (adminOnlyProjectAdd) with no awareness of project type. The backend was recently updated ([companion PR in Semoss]) to allow specific project types through even when that flag is enabled, but three places in the UI were still using this flat, non-type-aware check to pre-emptively block or hide creation entirely — making it impossible for non-admins to create Agent/Skill/Blocks apps even when the backend correctly allows them. This PR removes those incorrect gates so the UI stops guessing and lets the backend be the actual source of truth.

Changes Made

project-catalog.tsx — the "Add App/Skill/Agent" button was hidden entirely whenever adminOnlyProjectAdd was true, regardless of type. Now always shown.
create-app-page.tsx — redirected away from /app/new entirely for the same reason, blocking both Code and Blocks creation. Redirect removed.
landing-page.tsx — redirected the whole home page to itself, rendering nothing, for any non-admin whenever adminOnlyProjectAdd was true. Redirect removed.

How to Test

Set ADMIN_ONLY_PROJECT_ADD=true on the backend (with ADMIN_ONLY_PROJECT_ADD_EXEMPT_TYPES including WORKSPACE,SKILL,BLOCKS), log in as a non-admin user.
Confirm "Add Agent"/"Add Skill"/"Add App" buttons are visible, and creating an Agent, Skill, or Blocks app succeeds.
Confirm attempting to create a CODE app still correctly fails with the backend's "limited to only admins" error — this UI change doesn't bypass the actual restriction, it just stops incorrectly hiding options the backend would allow.

Notes

Companion to the Semoss PR adding ADMIN_ONLY_PROJECT_ADD_EXEMPT_TYPES.
Depends on that backend PR to be meaningful — without it, adminOnlyProjectAdd=true still blocks everything at the backend level regardless of these UI fixes.

configStore.isEngineOperationAvailable("PROJECT", "add") only checks a
single boolean (adminOnlyProjectAdd) with no awareness of project type,
but the backend now allows specific types through even when that flag
is enabled. Three places were still using this flat check to pre-emptively
block or hide creation entirely, making Agent/Skill/Blocks creation
impossible for non-admins even when the backend correctly allows them:

- project-catalog.tsx: "Add App/Skill/Agent" button was hidden entirely
  whenever adminOnlyProjectAdd was true, regardless of type.
- create-app-page.tsx: redirected away from /app/new entirely for the
  same reason, blocking both Code and Blocks creation.
- landing-page.tsx: redirected the whole home page to itself, rendering
  nothing, for any non-admin whenever adminOnlyProjectAdd was true.

Removed all three gates. The backend is the source of truth for this
restriction and already enforces it correctly per project type; the UI
no longer needs to (and can't correctly, without also knowing the
exempt-types list) pre-emptively guess at it.
@snyk-io

snyk-io Bot commented Jul 27, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@Kaveh-Vakili

Copy link
Copy Markdown
Contributor Author

Open question for reviewers

The button in project-catalog.tsx is currently shown to all users regardless of adminOnlyProjectAdd. Options for how to handle this:

Hide entirely — isEngineOperationAvailable(...) ? : null
Disable + tooltip — button always visible, disabled with "Only admins can add projects" tooltip when flag is on
Show always, block at the page — button navigates freely, create-app-page.tsx shows a permission banner for non-admins (also handles direct URL access)
Show always, no gating — current state in this PR

@Kaveh-Vakili
Kaveh-Vakili marked this pull request as ready for review July 30, 2026 21:02
@Kaveh-Vakili
Kaveh-Vakili requested a review from a team as a code owner July 30, 2026 21:02
kunal0137 and others added 4 commits August 5, 2026 15:36
The previous commit removed the Add button gate entirely across
Project/Skill/Agent catalogs, since the old flat adminOnlyProjectAdd
check couldn't distinguish between them. The backend has since added
independent flags (adminOnlyWorkspaceAdd, adminOnlySkillAdd) alongside
the existing adminOnlyProjectAdd, so each catalog can now check the
flag that actually applies to it instead of showing every button
unconditionally.
- types.d.ts: ALL_TYPES now includes WORKSPACE and SKILL.
- config.store.ts: moduleMap maps WORKSPACE -> adminOnlyWorkspaceAdd
  and SKILL -> adminOnlySkillAdd.
- project-catalog.tsx: new CATALOG_PERMISSION_TYPE map translates each
  catalog's UI type (CODE/SKILL/WORKSPACE) to the permission type that
  actually gates it - CODE still checks PROJECT (Code/Blocks stay
  bundled under that flag), while SKILL/WORKSPACE check their own
  independent flags. The Add button now shows/hides per catalog
  based on its own flag rather than unconditionally.
… catalog- landing-page.tsx: resolve merge conflict; remove flat isRestricted gate so the Get Started section shows for all users (backend enforces per-type)- project-catalog.tsx: fix filterBox to use CATALOG_PERMISSION_TYPE[type] instead of hardcoded PROJECT, matching the headerActions check above it- config.store.ts: add adminOnlyWorkspace* and adminOnlySkill* type declarations and false defaults to match backend PR #2807 fields
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