-
Notifications
You must be signed in to change notification settings - Fork 180
Google Drive folder ignored on creation #73
Comments
we're rewriting the drive integration at the moment, and one of the things on the list is to preserve folders. mindmup at the moment doesn't have a concept of folders, so there is nowhere to preserve the parents info. but it will be soon. |
Since we're only interested in making the "New" button in GDrive work correctly, we have no need of dealing with multiple "parents" like the GDrive API allows. We only need to deal with one "parent", the "folderId" that was passed in Considering that, once the file is created, MindMup can save to Google Drive directly with the file Id, you only need to preserve the folder Id in the original
Then use that as a single entry in the After that, the parents information can be discarded. So, all in all, only 2 very small changes are need for a massive improvement in usability with GDrive: First, preserve the In if !state || state['action']=='create' then
mapid = "new-g" With: if !state || state['action']=='create' then
mapid = "new-g:folderId=" + state['folderId'] Then, use the information on the fragment to create the document. In google-drive-adapter.js before the toGoogleParents = function (mapId) {
var match = /^new-g:folderId=(\w+)/.exec(mapId)
if (match) {
return [{ "kind": "drive#fileLink", "id": match[1] }];
}
}, And use it to create the saveFile = function (contentToSave, mapId, fileName, paramContentType) {
var googleId = toGoogleFileId(mapId),
parents = toGoogleParents(mapId), // <-- Get the folderId from the fragment
deferred = jQuery.Deferred(),
boundary = '-------314159265358979323846',
delimiter = '\r\n--' + boundary + '\r\n',
closeDelim = '\r\n--' + boundary + '--',
contentType = paramContentType || defaultContentType,
metadata = {
'parents': parents ? parents : undefined, // <-- Add the FolderId information
'title': fileName,
'mimeType': contentType
}, I stepped into the currently running MindMup version, and using the syntax above in the fragment, the I'd do a pull request, but I don't know enough about your codebase to write the proper tests to go along with these changes. |
I updated the previous comment to fix the code and to report that I managed to save a new MindMup file to a specific GDrive folder with the information above by adding a breakpoint in the |
that's not going to work simply as that, because the next time you save the file, the information will be lost. |
Hi @gojko, I understand your concern, but don't worry, it does work simply as that. You're right that the There is no need to pass the folder information when saving into an already existing file. For GDrive the folder information is just persistent file metadata, and if you don't specify it, GDrive won't touch it if it's already there. As I mentioned, I tested this flow with the current version of MindMup by putting the After that, MindMup was redirected to it's usual URL for GDrive files:
Notice that the foldeId information was "lost", as you predicted, but if I change the file and save it, it doesn't move inside GDrive, it's changed in-place inside whatever folder it was saved. If I close the browser window, then go into the GDrive folder where the file was saved and double-click on it, GDrive will open a new browser window with the exact same URL above, again with no You can test yourself the fact that the
|
When creating MindMup file straight from Google Drive (i.e. from the red "New" button on the GDrive web interface), a new browser windows is created opening the URL:
Where the
state
variable above contains a URL encoded json structure like:For the same user, the
folderId
variable changes depending on which folder the user was navigating inside the GDrive interface, but theuserId
variable never changes.However, after that, the user is redirected to the URL:
And even though MindMup remembers that the file should be saved on Google drive, it apparently loses the information of the specific GDrive folder, since the only result of clicking on the "Save" button (which is correctly selecting GDrive) is to save the MindMup file to the root folder of GDrive for the logged-in user,
The first time this happens to a GDrive user can be very confusing, considering that:
Please consider preserving the original GDrive folder information (in a cookie or URL fragment) and using it to save the MindMup file in the proper location.
According to the documentation, saving a file to a specific folder is just a matter of passing the
parents
parameter to the POST request that creates the file.The text was updated successfully, but these errors were encountered: