Skip to main content
Back to React

<FlowVariablesForm />

The FlowVariablesForm component lets a delegated admin override the variables a flow declares for their organization unit. It loads the variables the flow shares with the unit and the values the unit has set, shows them as a form, and saves the values that differ from their defaults.

For a shared flow, a variable is offered to a unit only when a sharing policy names it. A variable the unit may not set is shown as set by its owner. This form saves the overrides of a unit the flow was shared with, not the owner's defaults. Change the defaults in the flow's VARIABLES node.

Usage​

src/FlowSettings.jsx
jsx
import { FlowVariablesForm } from '@thunderid/react'

function FlowSettings({ flowId, ouId }) {
return <FlowVariablesForm flowId={flowId} ouId={ouId} onSaved={() => alert('Saved')} />
}

To let the admin pick the flow first, pair it with <SharedFlowList />.

note

The component must be rendered within ThunderIDProvider. The access token of the signed-in user needs the permissions the server requires to read and update the flow's variables.

Props​

FlowVariablesForm accepts the props below and every BaseFlowVariables prop except connections, error, initialValues, isSubmitting, onSubmit, overlay, and variables, which it supplies from useFlowVariables.

PropTypeRequiredDescription
flowIdstringYesIdentifier of the flow whose variables are configured.
ouIdstringYesThe organization unit the overrides belong to.
onSaved(values: FlowVariableValues) => voidNoCalled with the saved overrides.

Only the values that differ from their defaults are saved. A variable left at its default keeps following the default, even when the owner changes it later.

BaseFlowVariables​

BaseFlowVariables is the presentational form. It holds no data of its own: pass the variables and handle the submission. Use it to preview a flow's variables or to build a form from data you load yourself.

src/Preview.jsx
jsx
import { BaseFlowVariables } from '@thunderid/react'

function Preview({ variables }) {
return <BaseFlowVariables variables={variables} />
}

Without overlay, every variable is editable. Without onSubmit, the form has no save button.

Props​

PropTypeRequiredDescription
variablesFlowVariableDefinition[]YesThe variables to render, as the flow declares them.
connectionsPick<ConnectionInstance, 'categories' | 'id' | 'name' | 'type'>[]NoThe connections a CONNECTION_SELECT variable can take. Defaults to none.
overlayResolvedOverlayNoWhat the unit may do with each variable, as getFlowOverlayRules returns it.
initialValuesFlowVariableValuesNoThe values the form starts with, over each variable's default. A variable left out starts at its default.
onSubmit(values, overrides) => voidNoCalled when the form is submitted and valid. values holds every value. overrides holds the values of the variables the unit may set that differ from their default.
onChange(values: FlowVariableValues) => voidNoCalled with every value after one changes.
onCancel() => voidNoCalled when the admin selects Cancel. The button appears only when this is set, next to the save button, so it also needs onSubmit.
onCreateConnection() => voidNoCalled when the admin asks to create a connection from the hint under a connection variable. Without it, the hint does not offer one.
isSubmittingbooleanNoDisables the form and shows a loading state on the save button. Defaults to false.
errorstring | nullNoAn error message shown above the variables.
readOnlybooleanNoShows the variables without letting them be changed. Defaults to false.
ouNamestringNoThe name of the organization unit, used in the notice and the connection hint.
ownerNamestringNoThe name of whoever owns the flow, shown on a variable the unit may not set.
showScopeNoticebooleanNoShows a notice that the settings apply to the organization unit only. Defaults to false. Set ouName for it to read well.
titlestringNoHeading of the form.
descriptionstringNoText under the heading.
classNamestringNoCSS class for the root element.
preferencesPreferencesNoInternationalization preferences.
renderField(field, definition, index) => ReactNodeNoWraps the card of each variable, so you can add controls around it, such as selecting or removing a variable while you design it.
renderFieldAction(definition, index) => ReactNodeNoContent at the end of the label row of each variable.
children(props: BaseFlowVariablesRenderProps) => ReactNodeNoRenders custom UI in place of the default form.

Custom UI​

Pass a render function as children to build the form with any UI while keeping the SDK's validation and rules. The function receives these values:

PropertyTypeDescription
variablesFlowVariableDefinition[]The variables to render.
valuesFlowVariableValuesThe current value of each variable.
errorsRecord<string, string>The message to show under each invalid variable, keyed by identifier.
errorstring | nullThe form-level error.
getRule(definition) => ResolvedFlowVariableRuleWhat the unit may do with a variable: whether it can set its own value, and the default it starts from.
getOptions(definition) => FlowVariableOption[]The choices of a select variable, narrowed to what the unit may pick.
handleChange(identifier, value) => voidSets the value of one variable.
handleSubmit() => voidSubmits the current values. Does nothing while they are not valid.
resetToDefaults() => voidReturns every variable the unit may set to its default.
isValidbooleanWhether the values can be submitted. It checks each value against its variable definition only, not against the overlay's allowedValues or excludedValues, so the server can still reject a value. Show the error your save reports.
isSubmittingbooleanWhether a submission is in progress.
onCancel(() => void) | undefinedThe onCancel prop.

FlowVariableField​

FlowVariableField renders one variable in a card with its label, description, status, and the input its type calls for. BaseFlowVariables uses it for each variable, and you can use it to lay out the variables yourself.

PropTypeRequiredDescription
definitionFlowVariableDefinitionYesThe variable to render.
valueFlowVariableValue | undefinedYesThe current value.
onChange(value: FlowVariableValue) => voidYesCalled when the value changes.
defaultValueFlowVariableValueNoThe value the variable has until the unit sets its own, which a sharing policy may have set.
editablebooleanNoWhether the unit may set its own value. A variable it may not set is shown as set by its owner. Defaults to true.
optionsSelectOption[]NoThe choices of a SELECT or CONNECTION_SELECT, as getFlowVariableOptions returns them.
errorstringNoThe error to show under the field.
hintReactNodeNoExtra text under the input.
ownerNamestringNoWho set the variable, shown while it is not editable.
actionReactNodeNoExtra content at the end of the label row.
disabledbooleanNoDisables the input.
classNamestringNoCSS class for the card.

Each type renders its own input:

Variable typeInput
TEXT_INPUT, EMAIL_INPUT, PHONE_INPUT, NUMBER_INPUT, DATE_INPUTText field of the matching HTML input type
BOOLEAN_INPUTToggle
SELECT, CONNECTION_SELECTSelect. The empty entry shows the default, for example "Use the default: Dark", and returns the variable to it.

Internationalization​

The labels, errors, and notices come from the admin.flowVariables keys in the SDK's translations, available in all nine locales. Override them through preferences.i18n. See Internationalization.

Explore with AI

ThunderID LogoThunderID Logo

Product

DocsAPIsSDKs
© Copyright Linux Foundation Europe.For web site terms of use, trademark policy and other project policies please see https://linuxfoundation.eu/en/policies.