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

Show diff if server version of script is different to unsaved version of script in VSQlik. #543

Labels
enhancement New feature or request

Comments

Copy link

Is your feature request related to a problem? Please describe.
If you make changes to a script in VSQlik, then make changes in the Qlik Sense load script editor, then come back to VSQlik, it will automatically discard your local changes in favour of what's on the server.

Describe the solution you'd like
It would be good if a diff could be shown in this case, allowing you to choose which conflicting changes to keep, and which to reject.

Describe alternatives you've considered
In theory, you would only ever edit in VSQlik, and never make changes in the Qlik Sense script editor. However, sometimes you forget!

@r-hannuschka r-hannuschka self-assigned this Oct 6, 2020
@r-hannuschka r-hannuschka added the enhancement New feature or request label Oct 6, 2020
@r-hannuschka
Copy link
Contributor

r-hannuschka commented Oct 6, 2020

@DAVIDWALES i will start this one as soon as possible, it is currently a very good and valid use case. We allways assume only one edit the app, but i can also think about 2 will edit the application or you are at a presentation and find a small bug or changes so in this case you maybe edit the app (sheets, variable) directly in qlik sense and not open your editor, connect, find the file edit save and reload the data.

So i will implement this not only for an app, also variables, sheets, dimension and so one should take care about that.

  • option override script
  • option load from server
  • show diff

r-hannuschka added a commit that referenced this issue Oct 23, 2020
- added Application which holds the document to know when app has been changed
- added logic if we open a script file to register for app changed event
r-hannuschka added a commit that referenced this issue Oct 24, 2020
if server emits a change checks the scripts, if they changed open a virtual document which is compared with the local version and will be updated if the server emits more changes
r-hannuschka added a commit that referenced this issue Oct 25, 2020
- added Application which holds the document to know when app has been changed
- added logic if we open a script file to register for app changed event
r-hannuschka added a commit that referenced this issue Oct 25, 2020
if server emits a change checks the scripts, if they changed open a virtual document which is compared with the local version and will be updated if the server emits more changes
r-hannuschka added a commit that referenced this issue Oct 25, 2020
cache script locally after first time it was opened, this ensures we allways knows there is a diff
if we reopen the file and the server version is different from our version.
r-hannuschka added a commit that referenced this issue Oct 25, 2020
changed the logic the script will locked as soon it will be opened and unlocked if document is closed again. This will ensure the file is not overridden until it is open, for example editor lost the focus and content will read in again. After document it closed it will unlocked again so next time we get the data from server.
@r-hannuschka
Copy link
Contributor

r-hannuschka commented Oct 25, 2020

@DAVIDWALES since i'm nearly done with that i think i faced that issue in order this workflow:

  1. Open Script
  2. Edit script in vscode and save
  3. i toggle to server (new window) and open that script see my changes from vscode and edit here
  4. now i come back to vscode (it becomes focus) in this case it read the data again from the server

So fine it was allready up to date okay cool.

Bad things happens here i open both vscode and the browser at the same time and then start to edit in vscode and after that i edit some things in the browser (no time for reload the browser). The same behavior as above with the difference the browser do not notificate me someone has changed something, simply my local changes gets lost in vscode, vscode gains focus -> auto reload script -> browser was last and wins.

Solution currently:

If you open the script in vscode it becomes "locked" (cached as local version) and starts to listen on app.changed event. Now if someone edit that script (browser / vscode on same/other computer) and save it, we get notified about that the script is different now and a diff shows up. And it stays locked until you close the file.

So now for example you can do peer programming on same script with multiple friends, should be working even if vscode lost the focus (some other important app will openend) and switch back to vscode.

One thing:

If you close the Script the next one who save win's and override the script on the server and your changes are lost if your reopen the script and you never get notfied about that this should ensure you get allways the latest script from server if you open a script and not a older version.

To avoid that we need something like a local change history but this becomes an other story.

Would this solve your issue on this ?

Best regards,
Ralf

Copy link
Author

Oct 26, 2020

@r-hannuschka Are you describing the following situation?

  1. Script is open in both Qlik Sense AND VS Code
  2. You save and close the script in VS Code
  3. The script in Qlik Sense hasn't seen your changes, because it was already open, and you haven't reloaded the page.
  4. You make a different change in the script in Qlik Sense and it autosaves.
  5. This overwrites your VS Code changes, because Qlik Sense didn't think to check if there were changes, and assumes that it's the only tool used to edit Qlik scripts.

Is there a way to tell Qlik Sense to refresh the load script?

I think that your solution here (storing a local copy and showing a diff when changes are detected) will solve the original issue.

I also agree that the issue you have raised would require a local change history.
I think that's out of scope for this issue, but is worth investigating later.

Down the track, it would be good to be able to link an app to a local git repository, which could be used as the local change history. You could then compare the local working copy with the latest version from the server, and give the user the option to keep their local copy or the server copy.

r-hannuschka added a commit that referenced this issue Oct 27, 2020
- remove memory leak so we dont unsubscribe correctly and observers was still alive
- cache script directly after app was opened, avoid multiple calls to get the script
- simplyfy diff check
- disable load data in diff editor
Copy link
Collaborator

@DAVIDWALES

Is there a way to tell Qlik Sense to refresh the load script?

not really, just try it with two browsers and qlik itself. Even if you make a reload in one app it doesn't fetch the script in the second app.

Down the track, it would be good ... local GIT ...

Yes, this is also on the roadmap. I have it on my wishlist for Xmas, but be honest the chance is maximum 50%.

Copy link
Collaborator

@r-hannuschka
what we do is to save a copy of our last vscode saved script in an extra app property and if you reopen the app again it warns you that changes are done outside of vsqlik and ask you what to do.

r-hannuschka added a commit that referenced this issue Oct 27, 2020
- moved all script filesystem controllers into script module
- move logic out of script.module into script guard
- now vscode will update the main.qvs file if the server script changes (not if source is edited allready)
- show diff if source script has been edited and we have an diff
@r-hannuschka
Copy link
Contributor

r-hannuschka commented Oct 29, 2020

Adding the custom properties was not working for me, and if i'm right this is not possible for qlik sense server.

@see https://help.qlik.com/en-US/sense-developer/2.2/Subsystems/EngineAPI/Content/Structs/NxAppProperties.htm

r-hannuschka added a commit that referenced this issue Oct 29, 2020
…) to app properties

the last version of the script will be saved into the app properties, if the script opens again it will check it has been
an diff here. In this case the diff editor opeens directly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants