Skip to content

SRVOCF-1046: Improve namespace selection on the create function form - #184

Open
Cragsmann wants to merge 8 commits into
openshift:masterfrom
Cragsmann:SRVOCF-1046-improve-namespace-ux-in-function-creation-form
Open

SRVOCF-1046: Improve namespace selection on the create function form#184
Cragsmann wants to merge 8 commits into
openshift:masterfrom
Cragsmann:SRVOCF-1046-improve-namespace-ux-in-function-creation-form

Conversation

@Cragsmann

Copy link
Copy Markdown

Summary

  • 🎁 Make the namespace field role-aware: users who can create namespaces get a validated free-text input, developers with one accessible namespace get a prefilled locked field, and developers with several get a dropdown of their projects.
  • 🎁 Filter system namespaces (openshift-, kube-, default, etc.) out of the choices offered to users who cannot create namespaces, so they are never steered toward a namespace deployment is likely to fail in.
  • 🎁 Warn inline when a free-text namespace is a system namespace or does not exist, and map a submit-time not-found error to a friendly "Namespace X does not exist." message instead of a raw HTTP code.
  • 🔧 Move namespace access detection into useCluster behind a withNamespaceOptions flag (access review + Project watch) so the function list page does not pay for it, and demote not-found watch errors to a dedicated namespaceMissing flag rather than the generic error.
  • 🧪 Add unit tests across every role branch, sorting, system-namespace filtering, loading, and the not-found handling.

Fixes SRVOCF-1046

Checklist

  • Updated docs/ARCHITECTURE.md (if there are relevant changes to our layered architecture)
  • Updated docs/TESTING.md (if there are relevant changes to our testing framework or setup)

Cragsmann and others added 6 commits September 7, 2026 12:20
System namespace warning on the Create Function form.

Refs: SRVOCF-1075

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add an isSystemNamespace helper and show an inline warning on the Create
Function form when the entered namespace is a system namespace
(openshift-*, kube-*, default, openshift, kube-system, kube-public,
kube-node-lease). The warning is advisory and does not block creation.

Part of the consolidated namespace UX work.

Refs: SRVOCF-1046

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Rename and rewrite the plan to cover the merged namespace UX scope
(system-ns warning, non-existent-ns handling, role-aware field).
Supersedes SRVOCF-1075 and SRVOCF-1076.

Refs: SRVOCF-1046

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Render the namespace input based on the user's cluster access:

- admin (can create namespaces): free-text input with a system-
  namespace warning
- developer with one accessible namespace: prefilled, disabled input,
  auto-selected
- developer with several: dropdown of accessible namespaces
- developer with none: message to contact an administrator

Extract the control into a NamespaceField component. Derive the role,
the accessible namespaces, and the effective namespace inside useCluster
behind a withNamespaceOptions flag, so only the create form pays for the
access review and Project watch while the list page skips both. The hook
resolves the effective namespace itself, so a single-namespace
developer's secrets and config maps are watched without any typed value.

A not-found watch error is swallowed so an admin typing a not-yet-
created namespace sees no scary error; a failed submit surfaces the raw
error rather than guessing which resource was missing. Add an
isNotFoundError helper to detect k8s 404/NotFound shapes, and keep the
SDK-free NamespaceRole and resolveNamespace beside the hook in
common/clients.

Issue SRVOCF-1046

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The namespace field derived its behavior from a four-way
NamespaceRole ('admin' | 'developer-none' | 'developer-single' |
'developer-multi'), which coupled the UI to an enum that only ever
encoded two facts: whether the user can create namespaces and how
many they can access. That indirection made the actual rules hard
to see and let a system namespace slip into a developer's choices.

Replace the role with a single canCreateNamespaces boolean and let
the field derive its own UI. A user who cannot create namespaces
never sees a system namespace: those are filtered out both in
useCluster and defensively in the field itself. The sole-namespace
case now shows that namespace instead of the (empty) typed value,
and the empty case shows a generic message rather than wrongly
telling the user to contact an administrator (a self-provisioner
can create their own projects).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The create form gave no feedback for a namespace that does not
exist: a not-found watch error was swallowed entirely and a
submit-time 404 surfaced the raw 'http code: 404' client message.

Report the not-found watch as a dedicated namespaceMissing flag from
useCluster and, for a user typing a free-text namespace, show an
inline warning that it does not exist (non-blocking, since creation
is deferred). On submit, map a k8s 404 to a friendly 'Namespace X
does not exist.' message instead of the raw code. Only the free-text
branch can hit this; developers pick existing projects from the
dropdown.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@openshift-merge-bot

Copy link
Copy Markdown

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Sep 8, 2026
@openshift-ci-robot

openshift-ci-robot commented Sep 8, 2026

Copy link
Copy Markdown

@Cragsmann: This pull request references SRVOCF-1046 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.1.0" version, but no target version was set.

Details

In response to this:

Summary

  • 🎁 Make the namespace field role-aware: users who can create namespaces get a validated free-text input, developers with one accessible namespace get a prefilled locked field, and developers with several get a dropdown of their projects.
  • 🎁 Filter system namespaces (openshift-, kube-, default, etc.) out of the choices offered to users who cannot create namespaces, so they are never steered toward a namespace deployment is likely to fail in.
  • 🎁 Warn inline when a free-text namespace is a system namespace or does not exist, and map a submit-time not-found error to a friendly "Namespace X does not exist." message instead of a raw HTTP code.
  • 🔧 Move namespace access detection into useCluster behind a withNamespaceOptions flag (access review + Project watch) so the function list page does not pay for it, and demote not-found watch errors to a dedicated namespaceMissing flag rather than the generic error.
  • 🧪 Add unit tests across every role branch, sorting, system-namespace filtering, loading, and the not-found handling.

Fixes SRVOCF-1046

Checklist

  • Updated docs/ARCHITECTURE.md (if there are relevant changes to our layered architecture)
  • Updated docs/TESTING.md (if there are relevant changes to our testing framework or setup)

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci
openshift-ci Bot requested review from dsimansk and pmeida September 8, 2026 08:10
@openshift-ci

openshift-ci Bot commented Sep 8, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign spadgett for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Cragsmann and others added 2 commits September 11, 2026 12:32
Three bugs in the namespace field flow:

1. Input bound to debounced value → typed text reverted
   mid-keystroke. Now displays live value; only cluster
   watch is debounced.

2. Developer with one accessible namespace got disabled input
   but no mechanism to set it, so couldn't submit. Now page
   derives their namespace from the options.

3. Namespace owned in three places: page, form, and field.
   Form's copy never read. Collapsed to single source of truth
   in the page.

Also split useNamespaceOptions from useCluster to break
dependency cycle: options needed to derive effective namespace
before opening a namespace-scoped watch.

235 tests pass, covered by new tests for sole-namespace
derivation and debounce contract.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
The useCluster hook receives the effective namespace to watch, not
the user's typed input. Rename inputNamespace to namespace for
clarity since the input is already managed by the caller.

Simplify isSystemNamespace to check only prefixes instead of
maintaining separate lists of exact names and prefixes. The
prefix-based check covers all the same cases more concisely.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@openshift-ci

openshift-ci Bot commented Sep 11, 2026

Copy link
Copy Markdown

@Cragsmann: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/unit b07a0a7 link true /test unit

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants