Update app.py
Browse files
app.py
CHANGED
|
@@ -93,7 +93,7 @@ def delete_repo(token, repo_id, repo_type):
|
|
| 93 |
gr.Error(f"Failed to delete repository: {e}")
|
| 94 |
return repo_id, gr.update(visible=True), gr.update(visible=False)
|
| 95 |
|
| 96 |
-
def archive_repo(token, repo_id, archive_repo):
|
| 97 |
"""Deletes the selected repository."""
|
| 98 |
if not token:
|
| 99 |
gr.Error("A write-enabled Hugging Face token is required to delete a repository.")
|
|
@@ -101,7 +101,7 @@ def archive_repo(token, repo_id, archive_repo):
|
|
| 101 |
try:
|
| 102 |
api = get_hf_api(token)
|
| 103 |
archive_space=f'{archive_repo}/{repo_id.split("/")[1]}'
|
| 104 |
-
api.move_repo(from_id=repo_id, to_id=archive_space)
|
| 105 |
gr.Info(f"Successfully moved to '{archive_space}'.")
|
| 106 |
return None, gr.update(visible=False), gr.update(visible=False)
|
| 107 |
except HfHubHTTPError as e:
|
|
@@ -261,7 +261,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue"), title="Hugging Face Hub
|
|
| 261 |
inputs=[hf_token_state, manage_repo_dropdown, manage_repo_type_state],
|
| 262 |
outputs=[editor_panel, file_selector, code_editor])
|
| 263 |
|
| 264 |
-
archive_repo_btn.click(fn=archive_repo, inputs=[hf_token_state, selected_repo, archive_repo_name],
|
| 265 |
outputs=[manage_repo_dropdown, action_panel, editor_panel],
|
| 266 |
js="() => confirm('Are you sure you want to archive this repo?')")
|
| 267 |
|
|
|
|
| 93 |
gr.Error(f"Failed to delete repository: {e}")
|
| 94 |
return repo_id, gr.update(visible=True), gr.update(visible=False)
|
| 95 |
|
| 96 |
+
def archive_repo(token, repo_id, archive_repo, manage_repo_type_state):
|
| 97 |
"""Deletes the selected repository."""
|
| 98 |
if not token:
|
| 99 |
gr.Error("A write-enabled Hugging Face token is required to delete a repository.")
|
|
|
|
| 101 |
try:
|
| 102 |
api = get_hf_api(token)
|
| 103 |
archive_space=f'{archive_repo}/{repo_id.split("/")[1]}'
|
| 104 |
+
api.move_repo(from_id=repo_id, to_id=archive_space, type=manage_repo_type_state)
|
| 105 |
gr.Info(f"Successfully moved to '{archive_space}'.")
|
| 106 |
return None, gr.update(visible=False), gr.update(visible=False)
|
| 107 |
except HfHubHTTPError as e:
|
|
|
|
| 261 |
inputs=[hf_token_state, manage_repo_dropdown, manage_repo_type_state],
|
| 262 |
outputs=[editor_panel, file_selector, code_editor])
|
| 263 |
|
| 264 |
+
archive_repo_btn.click(fn=archive_repo, inputs=[hf_token_state, selected_repo, archive_repo_name, manage_repo_type_state],
|
| 265 |
outputs=[manage_repo_dropdown, action_panel, editor_panel],
|
| 266 |
js="() => confirm('Are you sure you want to archive this repo?')")
|
| 267 |
|