update to hide import and sidebar
Browse files4071 unmodified lines407240734074407540754076407740789 unmodified lines40884089409040914091409240934094144 unmodified lines4239424042414242424242434244424512 unmodified lines42584259426042614262426342644265426642644267426842694270427142724273427442754276427742784279428042818 unmodified lines4290429142924279429342944295429642834297429842994300430143029 unmodified lines43124313431442994315431643174318430343194320432143224323432498 unmodified lines4423442444254408442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634071 unmodified lines open_panel = gr.State(None) last_login_state = gr.State(None)
with gr.Sidebar(): with gr.Sidebar() as sidebar: login_button = gr.LoginButton() # Theme Selector (hidden for end users, developers can modify code)9 unmodified lines theme_status = gr.Markdown("") # Unified Import section gr.Markdown("π₯ Import Project (Space, GitHub, or Model)") import_header_md = gr.Markdown("π₯ Import Project (Space, GitHub, or Model)") load_project_url = gr.Textbox( label="Project URL", placeholder="https://huggingface.co/spaces/user/space OR https://huggingface.co/user/model OR https://github.com/owner/repo",144 unmodified lines # --- Remove deploy/app name/sdk from bottom column --- # (delete the gr.Column() block containing space_name_input, sdk_dropdown, deploy_btn, deploy_status)
with gr.Column(): with gr.Column() as main_column: with gr.Tabs(): with gr.Tab("Code"): code_output = gr.Code(12 unmodified lines # Keep history_output as hidden component to maintain functionality history_output = gr.Chatbot(show_label=False, height=400, type="messages", visible=False)
# Global generation status view (disabled placeholder) generating_status = gr.Markdown("", visible=False)
# Unified import handler def handle_import_project(url): if not url.strip(): return [gr.update(value="Please enter a URL.", visible=True), gr.update(), gr.update(), gr.update(), [], [], gr.update(value="", visible=False), gr.update(value="π Deploy App", visible=False)] return [ gr.update(value="Please enter a URL.", visible=True), gr.update(), gr.update(), gr.update(), [], [], gr.update(value="", visible=False), gr.update(value="π Deploy App", visible=False), gr.update(), # keep import header as-is gr.update() # keep import button as-is ]
kind, meta = _parse_repo_or_model_url(url) if kind == "hf_space":8 unmodified lines gr.update(value=status, visible=True), gr.update(value=code, language=code_lang), gr.update(value=""), gr.update(value=""), gr.update(value="", visible=False), # hide import textbox after submit loaded_history, history_to_chatbot_messages(loaded_history), gr.update(value=space_info, visible=True), gr.update(value="Update Existing Space", visible=True) gr.update(value="Update Existing Space", visible=True), gr.update(visible=False), # hide import header gr.update(visible=False) # hide import button ] else: # GitHub or HF model β return raw snippet for LLM starting point9 unmodified lines gr.update(value=status, visible=True), gr.update(value=code, language=code_lang), gr.update(value=""), gr.update(value=""), gr.update(value="", visible=False), # hide import textbox after submit loaded_history, history_to_chatbot_messages(loaded_history), gr.update(value="", visible=False), gr.update(value="π Deploy App", visible=False) gr.update(value="π Deploy App", visible=False), gr.update(visible=False), # hide import header gr.update(visible=False) # hide import button ]
# Import repo/model handler98 unmodified lines load_project_btn.click( handle_import_project, inputs=[load_project_url], outputs=[load_project_status, code_output, sandbox, load_project_url, history, history_output, space_name_input, deploy_btn] outputs=[ load_project_status, code_output, sandbox, load_project_url, history, history_output, space_name_input, deploy_btn, import_header_md, load_project_btn, ], )
def begin_generation_ui(): # Hide only the sidebar; keep main UI visible; do not show any status text return [gr.update(visible=False), gr.update(visible=False)]
def end_generation_ui(): # Keep sidebar visible but collapsed; hide the status return [gr.update(visible=True, open=False), gr.update(visible=False)]
btn.click( begin_generation_ui, inputs=None, outputs=[sidebar, generating_status], show_progress="hidden", ).then( generation_code, inputs=[input, image_input, file_input, website_url_input, setting, history, current_model, search_toggle, language_dropdown, provider_state, image_generation_toggle, image_to_image_toggle, image_to_image_prompt, text_to_image_prompt], outputs=[code_output, history, sandbox, history_output] ).then( end_generation_ui, inputs=None, outputs=[sidebar, generating_status] ).then( show_deploy_components, None,app.py+55-9