Closed antnks closed 9 months ago
Hey @jgadsden! I've been working on implementing this feature to prompt the user to save the model before quitting the application. I've made some progress, but I'm encountering an issue. When the user closes the model by clicking on the close button in Windows, the application prompts the user to verify if they want to save the model or not.
However, the problem arises when the user doesn't close the application or the model, but instead clicks on the threat model icon in the navbar or any other button (like logout) that sends them to a different route. In such cases, the route changes but the prompt doesn't occur.
I've tried to implement the same logic when the graph component gets destroyed, but the function is asynchronous, and the destroyed or beforeDestroy lifecycle functions don't support the asynchronicity of the functions called within them. So, I'm struggling to find a way to prompt the user to save the model when the routes change.
You can find a discussion about a similar issue in https://github.com/vuejs/vue/issues/7209.
Here is the video depicting both the behavior :
a) When the user simply closes the whole application :-
https://github.com/OWASP/threat-dragon/assets/94848646/60f365f3-cb11-46e6-922f-08e0f3f41153
b) When the user is redirected to any other route :-
https://github.com/OWASP/threat-dragon/assets/94848646/9afe5223-0e48-434e-bdc0-cc1a9df3395c
thanks for working on this @raghav1030 there are two issues here:
thanks for working on this @raghav1030 there are two issues here:
- we need a guard on the route to #/dashboard, for both desktop and webapp
- also in desktop we need to block and request to close the model when the electron app is about to close, from the menu item 'Quit Threat Dragon' and also when using the window close button
Sure, I believe the progress I've made so far has largely addressed the second issue you mentioned. Do you have any feedback on it?
Additionally, could you please provide more details on what the guard should facilitate?
closed via pull request #852
Describe the bug: There is no prompt to save changes when quitting the app.
Expected behaviour: If there were changes made, the app should prompt to save or discard changes to prevent unexpected data loss.
Environment:
To Reproduce: