Spaces:
Sleeping
Sleeping
File size: 2,897 Bytes
7ebae40 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
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
|