naman1102 commited on
Commit
a18e264
·
1 Parent(s): b254d56

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -8
app.py CHANGED
@@ -1036,13 +1036,15 @@ def create_ui() -> gr.Blocks:
1036
  return gr.update(visible=False), hf_url
1037
  return gr.update(visible=False), ""
1038
 
1039
- def handle_explore_repo(repo_id: str) -> Tuple[Any, Any, Any]:
1040
- """Handle navigating to the repo explorer and setting the repo ID."""
1041
- logger.info(f"Switching to repo explorer tab with repo: {repo_id}")
 
 
 
1042
  return (
1043
  gr.update(visible=False), # close modal
1044
- gr.update(selected="repo_explorer_tab"), # switch tab
1045
- gr.update(value=repo_id if repo_id else "") # set repo ID
1046
  )
1047
 
1048
  def handle_cancel_modal() -> Any:
@@ -1193,10 +1195,25 @@ def create_ui() -> gr.Blocks:
1193
  inputs=[selected_repo_display],
1194
  outputs=[
1195
  repo_action_modal,
1196
- tabs,
1197
- repo_components["repo_explorer_input"]
1198
  ],
1199
- js="() => { setTimeout(() => { window.scrollTo({top: 0, behavior: 'smooth'}); window.dispatchEvent(new Event('repoExplorerNavigation')); }, 150); }"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1200
  )
1201
  cancel_modal_btn.click(
1202
  fn=handle_cancel_modal,
 
1036
  return gr.update(visible=False), hf_url
1037
  return gr.update(visible=False), ""
1038
 
1039
+ def handle_explore_repo(repo_id: str) -> Tuple[Any, Any]:
1040
+ """Handle navigating to the repo explorer."""
1041
+ logger.info(f"DEBUG: handle_explore_repo called with repo_id: '{repo_id}'")
1042
+ logger.info(f"DEBUG: repo_id type: {type(repo_id)}")
1043
+ logger.info(f"DEBUG: repo_id length: {len(repo_id) if repo_id else 'None'}")
1044
+
1045
  return (
1046
  gr.update(visible=False), # close modal
1047
+ gr.update(selected="repo_explorer_tab") # switch tab
 
1048
  )
1049
 
1050
  def handle_cancel_modal() -> Any:
 
1195
  inputs=[selected_repo_display],
1196
  outputs=[
1197
  repo_action_modal,
1198
+ tabs
 
1199
  ],
1200
+ js="""(repo_id) => {
1201
+ console.log('DEBUG: JS called with repo_id:', repo_id);
1202
+ setTimeout(() => {
1203
+ window.scrollTo({top: 0, behavior: 'smooth'});
1204
+ window.dispatchEvent(new Event('repoExplorerNavigation'));
1205
+
1206
+ // Try to find and set the repo explorer input
1207
+ const inputs = document.querySelectorAll('input[placeholder*="microsoft/DialoGPT-medium"], input[placeholder*="Repository ID"]');
1208
+ console.log('DEBUG: Found inputs:', inputs.length);
1209
+ inputs.forEach((input, index) => {
1210
+ console.log('DEBUG: Setting input', index, 'to value:', repo_id);
1211
+ input.value = repo_id || '';
1212
+ input.dispatchEvent(new Event('input', { bubbles: true }));
1213
+ input.dispatchEvent(new Event('change', { bubbles: true }));
1214
+ });
1215
+ }, 200);
1216
+ }"""
1217
  )
1218
  cancel_modal_btn.click(
1219
  fn=handle_cancel_modal,