Closed jkiviluo closed 2 days ago
One idea is to use the graph view algorithm to place items nicely in case no positions are given in the project.json file. And then find a way to save the project file without the positions, before putting it into version control.
We could add a special directory for storing local/GUI settings like item positions. Adding the directory in .gitignore
would then exclude that content.
We could add a special directory for storing local/GUI settings like item positions. Adding the directory in .gitignore would then exclude that content.
Does it need to be a directory? Could this be done in memory?
If I understand this issue correctly it is just that we need to make better checks to has anything really changed when saving the project. For example, if I remove a connection and then put the same connection back, the connection part in project.json should not change.
For example, if I remove a connection and then put the same connection back, the connection part in project.json should not change.
Does it change at the moment? I believe it doesn't. Our undo/redo implementation is not smart enough and still considers the project dirty, so it just enables the 'save' action and writes the project.json file if the user activates it... but the file will end up with the same content... I think
I believe the problem here is moving items around. Their x and y coordinates go to version control, which seems to be undesirable...
I believe @soininen 's idea works. We save the x and y coordinates to a different file that we gitignore.
When another user clones the project for the first time, they won't have that file with the positions so we need to place the items nicely. I was suggesting to use the graph view algorithm for that.
but the file will end up with the same content... I think
The project file content will change in the general case as we currently store the connections internally as a Python list. Readding a connection appends to the list potentially changing the connection's position within that list. Dumping the list to the .proj
file will then change the file. This could (and I guess should) be fixed by e.g. sorting the connection list at project save.
I suggested an entire directory for saving local changes because that way we can later add more 'local' stuff there. Caches for undo stacks, for example if we ever want undo/redo functionality that persists over Toolbox sessions.
I updated the issue description based on the comments here.
Since 78aa488 there is now <project dir>/.spinetoolbox/local/
that should be used to store 'local' content, i.e. project data that is system or user specific.
Closing due to newer issue #2509
It's really handy to be able to share Spine Toolbox projects through a git repo. There has also been good progress to eliminate absolute paths. However, project.json contains stuff where changes shouldn't be reflected in the git repo and it's not nice to be pushing and pulling those. This includes at least the x/y positions of items (connections should be in the repo though) and what scenarios are selected. Possibly also whether to execute in work or source directory.
The main solution is to make a separate .gitignored file(s) for local data like the x/y positions of icons and what scenarios are selected.
The challenge is that when someone pulls a repo for the first time without those informations, they need to be generated somehow. In the discussion below, @manuelma suggests to use an algorithm (used in graph view) to generate icon positions if they don't exist (i.e. the local file is not contained). @soininen suggests to make a folder for the local changes so that more can be added there in future and they would be managed by the same .gitignore. Some of the other local data items might work through a default choice that would be hard-coded (e.g. no scenarios chosen) or in the tool specification.
I think doing those would be sufficient to address the issue. At first we would put x/y positions there, but we could expand that when needed.