Update app.py
Browse files
app.py
CHANGED
|
@@ -247,30 +247,56 @@ def download_markdown(n_clicks):
|
|
| 247 |
return dcc.send_bytes(generated_file.getvalue(), f"release_notes_{datetime.now().strftime('%Y%m%d%H%M%S')}.md")
|
| 248 |
|
| 249 |
@app.callback(
|
| 250 |
-
[Output("
|
| 251 |
-
Output("
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 256 |
)
|
| 257 |
-
def
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
global generated_file
|
| 262 |
-
if generated_file is None:
|
| 263 |
-
return "Error: No file generated", True
|
| 264 |
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
if
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
|
| 275 |
if __name__ == '__main__':
|
| 276 |
print("Starting the Dash application...")
|
|
|
|
| 247 |
return dcc.send_bytes(generated_file.getvalue(), f"release_notes_{datetime.now().strftime('%Y%m%d%H%M%S')}.md")
|
| 248 |
|
| 249 |
@app.callback(
|
| 250 |
+
[Output("output-notes", "children"),
|
| 251 |
+
Output("download-button", "disabled"),
|
| 252 |
+
Output("pr-button", "disabled"),
|
| 253 |
+
Output("download-markdown", "data"),
|
| 254 |
+
Output("pr-button", "children")],
|
| 255 |
+
[Input("generate-button", "n_clicks"),
|
| 256 |
+
Input("download-button", "n_clicks"),
|
| 257 |
+
Input("pr-button", "n_clicks")],
|
| 258 |
+
[State("git-provider", "value"),
|
| 259 |
+
State("repo-url", "value"),
|
| 260 |
+
State("start-date", "value"),
|
| 261 |
+
State("end-date", "value"),
|
| 262 |
+
State("folder-location", "value")]
|
| 263 |
)
|
| 264 |
+
def handle_all_actions(generate_clicks, download_clicks, pr_clicks,
|
| 265 |
+
git_provider, repo_url, start_date, end_date, folder_location):
|
| 266 |
+
global generated_file, pr_url
|
| 267 |
+
ctx = callback_context
|
|
|
|
|
|
|
|
|
|
| 268 |
|
| 269 |
+
if not ctx.triggered:
|
| 270 |
+
return "", True, True, None, "Create PR"
|
| 271 |
+
|
| 272 |
+
button_id = ctx.triggered[0]['prop_id'].split('.')[0]
|
| 273 |
+
|
| 274 |
+
if button_id == "generate-button":
|
| 275 |
+
notes, file_name = generate_release_notes(git_provider, repo_url, start_date, end_date, folder_location)
|
| 276 |
+
return notes, False, False, None, "Create PR"
|
| 277 |
+
|
| 278 |
+
elif button_id == "download-button":
|
| 279 |
+
if generated_file is None:
|
| 280 |
+
return dash.no_update, dash.no_update, dash.no_update, None, dash.no_update
|
| 281 |
+
return (dash.no_update, dash.no_update, dash.no_update,
|
| 282 |
+
dcc.send_bytes(generated_file.getvalue(), f"release_notes_{datetime.now().strftime('%Y%m%d%H%M%S')}.md"),
|
| 283 |
+
dash.no_update)
|
| 284 |
+
|
| 285 |
+
elif button_id == "pr-button":
|
| 286 |
+
if generated_file is None:
|
| 287 |
+
return dash.no_update, dash.no_update, dash.no_update, None, "Error: No file generated"
|
| 288 |
+
|
| 289 |
+
file_name = f"{datetime.now().strftime('%m-%d-%Y')}.md"
|
| 290 |
+
markdown_content = generated_file.getvalue().decode()
|
| 291 |
+
|
| 292 |
+
result = update_summary_and_create_pr(repo_url, folder_location, file_name, markdown_content)
|
| 293 |
+
|
| 294 |
+
if pr_url:
|
| 295 |
+
return dash.no_update, dash.no_update, True, None, f"PR Created: {pr_url}"
|
| 296 |
+
else:
|
| 297 |
+
return dash.no_update, dash.no_update, False, None, result
|
| 298 |
+
|
| 299 |
+
return dash.no_update, dash.no_update, dash.no_update, None, dash.no_update
|
| 300 |
|
| 301 |
if __name__ == '__main__':
|
| 302 |
print("Starting the Dash application...")
|