pushUpdate("cookie_source", source)}
textInputProps={{
- name: "cookie",
- value: fields.cookie,
+ name: "cookie_text",
+ value: fields.cookie_text,
onChange: (event) => handleChange(event, false),
onBlur: handleBlur,
}}
@@ -83,6 +99,15 @@ export default function App({ ctx, payload }) {
value: fields.cookie_secret,
onChange: handleChange,
}}
+ variableSelectProps={{
+ name: "cookie_variable",
+ value: fields.cookie_variable,
+ onChange: handleChange,
+ options: cookieVariables.map((variable) => ({
+ label: variable,
+ value: variable,
+ })),
+ }}
modalTitle="Set cookie value"
required
/>
@@ -168,11 +193,86 @@ function TextField({
);
}
+export function SelectField({
+ label = null,
+ value,
+ className,
+ options = [],
+ optionGroups = [],
+ required = false,
+ fullWidth = false,
+ startAdornment,
+ ...props
+}) {
+ function renderOptions(options) {
+ return options.map((option) => (
+
+ ));
+ }
+
+ const isValueAvailable = options.some((option) => option.value === value);
+
+ const noOptions = options.length === 0 && optionGroups.length === 0;
+
+ return (
+
+ {label && (
+
+ )}
+
+ {startAdornment}
+
+
+
+
+
+
+
+
+ );
+}
+
function SecretField({
ctx,
- toggleInputProps,
+ source,
+ onSourceChange,
textInputProps,
secretInputProps,
+ variableSelectProps,
label = null,
required = false,
modalTitle = "Select secret",
@@ -198,36 +298,61 @@ function SecretField({
);
}
- const useSecret = toggleInputProps.checked;
+ const sources = ["text", "secret", "variable"];
+
+ function onSourceClick() {
+ const sourceIndex = sources.indexOf(source);
+ const nextSource = sources[(sourceIndex + 1) % sources.length];
+ onSourceChange(nextSource);
+ }
const inputTypeToggle = (
-