Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added Re-run in Console Button in Console Log Doctype #21825

Merged

Conversation

RitvikSardana
Copy link
Contributor

@RitvikSardana RitvikSardana commented Jul 27, 2023

Screenshot 2023-08-07 at 12 40 11 AM

Added this button in Console Log Doctype.
Now the user can click on the button and they will be redirected to System Console and code and type will be pre populated.

System.Console.mov

What Changed:

  1. Added a new field "type" in Console Log Doctype.
  2. New button in Console Log Doctype which redirects to System Console.

no-docs

@RitvikSardana RitvikSardana requested a review from a team July 27, 2023 05:18
@RitvikSardana RitvikSardana self-assigned this Jul 27, 2023
@RitvikSardana RitvikSardana requested review from surajshetty3416 and removed request for a team July 27, 2023 05:18
@RitvikSardana RitvikSardana marked this pull request as draft July 27, 2023 05:18
@phot0n
Copy link
Contributor

phot0n commented Jul 27, 2023

the type of script would also need to be recorded in the console log so that it can be reloaded back appropriately - currently we only support 2 types: sql & python (and I'm not sure if there are any future plans for adding new types) so a checkbox might suffice

OR we can try to parse the script and see if it's valid python (while reloading in sysconsole) and set the type appropriately

@RitvikSardana
Copy link
Contributor Author

@phot0n
I tried the type part by hardcoding it to "SQL", but when the System Console is created, it still saves the Type as Python.
Maybe it is because of the Default value given to that Select?

@shariquerik shariquerik added the add-description Details or Reason for the change. Also add screenshots and animated GIF if applicable label Jul 27, 2023
@ankush ankush added the Skip CI Doesn't run Ci for this PR. label Jul 27, 2023
// refresh: function(frm) {
// }
refresh: function (frm) {
frm.add_custom_button(__("Reload in Console"), () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
frm.add_custom_button(__("Reload in Console"), () => {
frm.add_custom_button(__("Re-run in Console"), () => {

Better naming IMO.

@ankush ankush linked an issue Jul 27, 2023 that may be closed by this pull request
@shariquerik
Copy link
Member

The solution works but it is causing one more issue, it is opening system-console/new and because of that the action button 'Logs' is missing

Maybe try in the way we do in customize form. We store the doctype name in local and repopulate when it is loaded

@NagariaHussain
Copy link
Member

👀

@RitvikSardana RitvikSardana changed the title feat: Added Reload in Console Button in Console Log Doctype feat: Added Re-Run in Console Button in Console Log Doctype Aug 6, 2023
@RitvikSardana RitvikSardana changed the title feat: Added Re-Run in Console Button in Console Log Doctype feat: Added Re-run in Console Button in Console Log Doctype Aug 6, 2023
@RitvikSardana RitvikSardana marked this pull request as ready for review August 6, 2023 19:19
frm.add_custom_button(__("Re-Run in Console"), () => {
window.localStorage.setItem("system_console_code", frm.doc.script);
window.localStorage.setItem("system_console_type", frm.doc.type);
window.location.href = "/app/system-console";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't hard code routing in code.

@ankush ankush merged commit 3f971f3 into frappe:develop Aug 7, 2023
2 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
add-description Details or Reason for the change. Also add screenshots and animated GIF if applicable Skip CI Doesn't run Ci for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Open "Pre-populated" Console from Logs
5 participants