broadfield-dev commited on
Commit
ac7e9e4
·
verified ·
1 Parent(s): 765d5d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -5
app.py CHANGED
@@ -45,26 +45,21 @@ def main_ui():
45
  gr.Markdown("### Build Status & Result")
46
  output_status_md = gr.Markdown(label="Result")
47
 
48
- # --- Wrapper function for better UX ---
49
  def autofill_owner_if_empty(api_token, current_owner):
50
  """
51
  Checks if the owner field is empty. If so, it tries to fetch the username.
52
  This prevents overwriting a manually entered organization or username.
53
  """
54
- # Only run the API call if the owner field is currently empty
55
  if not current_owner.strip():
56
  return get_username_from_token(api_token)
57
- # If the user has already typed something, leave it alone.
58
  return current_owner
59
 
60
- # --- NEW Event Handler for Autofill ---
61
  api_token_input.blur(
62
  fn=autofill_owner_if_empty,
63
  inputs=[api_token_input, owner_input], # Pass both token and the current owner value
64
  outputs=[owner_input]
65
  )
66
 
67
- # --- Main "Create" Button Event Handler (Unchanged) ---
68
  create_button.click(
69
  fn=build_space_from_image,
70
  inputs=[
 
45
  gr.Markdown("### Build Status & Result")
46
  output_status_md = gr.Markdown(label="Result")
47
 
 
48
  def autofill_owner_if_empty(api_token, current_owner):
49
  """
50
  Checks if the owner field is empty. If so, it tries to fetch the username.
51
  This prevents overwriting a manually entered organization or username.
52
  """
 
53
  if not current_owner.strip():
54
  return get_username_from_token(api_token)
 
55
  return current_owner
56
 
 
57
  api_token_input.blur(
58
  fn=autofill_owner_if_empty,
59
  inputs=[api_token_input, owner_input], # Pass both token and the current owner value
60
  outputs=[owner_input]
61
  )
62
 
 
63
  create_button.click(
64
  fn=build_space_from_image,
65
  inputs=[