- Notifications
You must be signed in to change notification settings - Fork929
feat(site): Support list(string) rich parameter field#6653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -8,6 +8,7 @@ import { FC, useState } from "react" | ||
import { TemplateVersionParameter } from "../../api/typesGenerated" | ||
import { colors } from "theme/colors" | ||
import { MemoizedMarkdown } from "components/Markdown/Markdown" | ||
import { MultiTextField } from "components/MultiTextField/MultiTextField" | ||
const isBoolean = (parameter: TemplateVersionParameter) => { | ||
return parameter.type === "bool" | ||
@@ -154,6 +155,32 @@ const RichParameterField: React.FC<RichParameterInputProps> = ({ | ||
) | ||
} | ||
if (parameter.type === "list(string)") { | ||
let values: string[] = [] | ||
if (parameterValue) { | ||
try { | ||
values = JSON.parse(parameterValue) as string[] | ||
} catch (e) { | ||
console.error("Error parsing list(string) parameter", e) | ||
} | ||
} | ||
return ( | ||
<MultiTextField | ||
label={props.label as string} | ||
values={values} | ||
onChange={(values) => { | ||
try { | ||
onChange(JSON.stringify(values)) | ||
} catch (e) { | ||
console.error("Error on change of list(string) parameter", e) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Do we need to do anything else with error handling here or on line 165? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This is something we control but in case it gets an error, I added a message to help a bit more. | ||
} | ||
}} | ||
/> | ||
) | ||
} | ||
// A text field can technically handle all cases! | ||
// As other cases become more prominent (like filtering for numbers), | ||
// we should break this out into more finely scoped input fields. | ||