Spaces:
Running
Running
import gradio as gr | |
def select_custom_options(customisation): | |
"""Selects the custom options.""" | |
if customisation: | |
return ( | |
gr.update(visible=True), | |
gr.update(visible=True), | |
gr.update(visible=True), | |
gr.update(visible=True), | |
) | |
return ( | |
gr.update(visible=False), | |
gr.update(visible=False), | |
gr.update(visible=False), | |
gr.update(visible=False), | |
) | |
def select_github_repo_options(github_repo): | |
"""Selects the Github repo options.""" | |
if github_repo: | |
return ( | |
gr.update(visible=True), | |
gr.update(visible=True), | |
gr.update(visible=True), | |
) | |
return ( | |
gr.update(visible=False), | |
gr.update(visible=False), | |
gr.update(visible=False), | |
) | |
def customisation_block() -> dict: | |
with gr.Column(): | |
enable_customisation = gr.Checkbox( | |
label="Enable customisation (Click to reveal options)", | |
default=False, | |
interactive=True, | |
) | |
with gr.Row(): | |
unit_tests = gr.Checkbox( | |
label="Add Unit tests", | |
default=False, | |
interactive=True, | |
visible=False, | |
) | |
dockerization = gr.Checkbox( | |
label="Add Docker support", | |
default=False, | |
interactive=True, | |
visible=False, | |
) | |
github_actions = gr.Checkbox( | |
label="Add Github Actions support", | |
default=False, | |
interactive=True, | |
visible=False, | |
) | |
pre_commit_hooks = gr.Checkbox( | |
label="Add Pre-commit hooks", | |
default=False, | |
interactive=True, | |
visible=False, | |
) | |
enable_customisation.change( | |
fn=select_custom_options, | |
inputs=enable_customisation, | |
outputs=[unit_tests, dockerization, github_actions, pre_commit_hooks], | |
) | |
return ( | |
unit_tests, | |
dockerization, | |
github_actions, | |
pre_commit_hooks, | |
) | |
def github_repo_block() -> dict: | |
with gr.Column(): | |
with gr.Row(): | |
gh_token = gr.Textbox( | |
placeholder="Paste your Github Personal Access Token (Required scopes: repo, workflow)", | |
label="Github Personal Access Token", | |
lines=1, | |
type="password", | |
) | |
gh_repo_name = gr.Textbox( | |
placeholder="Enter Github repo name", | |
label="Github repo name", | |
lines=1, | |
) | |
private = gr.Checkbox( | |
label="Make repo private?", | |
default=False, | |
interactive=True, | |
) | |
return gh_token, gh_repo_name, private | |