Skip to content

WorkloadPicker

API reference and demos for WorkloadPicker.

Source

import { WorkloadPicker } from "@flanksource/clicky-ui/components";
Default · Open in Storybook
Grouped · Open in Storybook
Namespaced · Open in Storybook

The props table documents the component-specific surface. Standard DOM attributes inherited from React, such as className, event handlers, and accessibility attributes, may also be accepted when the component’s prop type extends a native element.

Prop Type Default Description
allowCustomValue boolean true Whether a typed name absent from the loaded resources may be committed. Defaults to true for the existing free-form workload picker behavior.
allowNamespaceSelection boolean false Lets the user choose the namespace used to load and key workloads.
className string — —
collapseSingleOption boolean false Render the sole loaded workload as plain text instead of a picker. A dropdown whose only entry is the one already in effect asks a question with one answer. This is for a scope that leaves nothing to choose — a Deployment with a single pod — where the workload is a fact to state rather than a selection to make. No value is emitted: the caller is already scoped to it, so writing it back would only add a filter that changes nothing.
disabled boolean false —
kinds WorkloadKind[] [ "service", "ingress", "pod", "deployment", "statefulset", "daemonset", ] Kinds to offer, in display order. Defaults to every supported kind.
loadNamespaces (…) => Promise<string[]> — Required when namespace selection is enabled.
loadWorkloads* (…) => … — Async getter the component calls to load the requested kinds' workloads. Returns a map keyed by kind. The consumer owns fetching/caching.
namespace string — Namespace the workloads live in. When set it prefixes the emitted key (`namespace/kind/name`), so values stay distinct across namespaces.
onChange* (…) => void — Called with the chosen `[namespace/]kind/name` key. When namespace selection is on and no workload is picked it receives the `namespace/` key (see {@link namespaceKey}) rather than "", so a consumer persisting the value keeps the namespace; "" means nothing at all is selected.
onNamespaceChange (…) => void — Reports the namespace independently of workload selection.
placeholder string Select workload / service… —
strict boolean false When true, a non-empty value that does not match any loaded workload (once loading settles) is flagged invalid — the picked workload doesn't exist in the namespace. The value is still shown (pinned) so the user can see and fix it; freeform entry is not rejected, only marked.
value* string — Controlled selected value — a `[namespace/]kind/name` key (see {@link workloadKey } / {@link parseWorkloadKey}), or a `namespace/` key when a namespace is in scope with no workload picked in it yet.