Skip to content

feat: Support booleans for parameters input #3437

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 10, 2022

Conversation

BrunoQuaresma
Copy link
Collaborator

@BrunoQuaresma BrunoQuaresma commented Aug 9, 2022

Closes #2659

Preview:

Screen Shot 2022-08-09 at 16 36 36

Screen Shot 2022-08-09 at 16 39 44

PS: I tried with Checkbox but for the current design, having a Radio Group fits better when together with other fields, but I'm open. Here is what the checkbox looks like:

Screen Shot 2022-08-09 at 16 40 54

@BrunoQuaresma BrunoQuaresma self-assigned this Aug 9, 2022
@BrunoQuaresma BrunoQuaresma requested a review from a team as a code owner August 9, 2022 19:39
import { FC } from "react"
import { ParameterSchema } from "../../api/typesGenerated"
import { MONOSPACE_FONT_FAMILY } from "../../theme/constants"

const isBoolean = (schema: ParameterSchema) => {
return schema.validation_value_type === "bool"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice to have an enum for this

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is true, but I would wait until we use it more often or with different values.

name: "disable_docker",
description: "Disable Docker?",
validation_value_type: "bool",
default_source_value: "false",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have testing entities for these objects?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we don't. Do you think it would be interesting to have?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know! I haven't worked extensively with these inputs. If you think it will be used in other stories, great. If not, no worries.

Copy link
Member

@Kira-Pilot Kira-Pilot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't have time to pull down but the code looks good!

…ries.tsx

Co-authored-by: Kira Pilot <kira@coder.com>
@matifali
Copy link
Member

Can the display names be more human-friendly.?
from var.instance_size to Instance size

@BrunoQuaresma
Copy link
Collaborator Author

BrunoQuaresma commented Aug 10, 2022

Can the display names be more human-friendly.? from var.instance_size to Instance size

I think this is a good suggestion. We already have a description so I think what we can do is if there is a description, display it as a label, if not, display the variable name. What do you think? Also, I think this work could be in a diff PR, so I'm going to merge this one, but feel free to keep the discussion here if you want to.

@BrunoQuaresma BrunoQuaresma merged commit 758eb21 into main Aug 10, 2022
@BrunoQuaresma BrunoQuaresma deleted the bq/2659-suuport-boolean-values branch August 10, 2022 13:41
@matifali
Copy link
Member

matifali commented Aug 10, 2022

Seem's like a good idea.
Can you point me to where in the code this is being done?

@BrunoQuaresma
Copy link
Collaborator Author

@matifali sure thing, here is

const ParameterLabel: React.FC<{ schema: ParameterSchema }> = ({ schema }) => {
const styles = useStyles()
return (
<label className={styles.label} htmlFor={schema.name}>
<strong>var.{schema.name}</strong>
{schema.description && <span className={styles.labelDescription}>{schema.description}</span>}
</label>
)
}

@matifali
Copy link
Member

Can the display names be more human-friendly.?

Any plans for to this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add checkbox input for boolean variable
3 participants