Support Google Team Drives

This commit is contained in:
Stephen Prater 2018-03-30 15:54:12 -07:00
parent 0c97f16587
commit ef3d3b6a74

View File

@ -110,6 +110,7 @@ export default {
...options, ...options,
params: { params: {
uploadType: 'multipart', uploadType: 'multipart',
supportsTeamDrives: true,
}, },
headers: { headers: {
'Content-Type': `multipart/mixed; boundary="${boundary}"`, 'Content-Type': `multipart/mixed; boundary="${boundary}"`,
@ -123,6 +124,9 @@ export default {
return this.request(refreshedToken, { return this.request(refreshedToken, {
...options, ...options,
body: metadata, body: metadata,
params: {
supportsTeamDrives: true,
},
}).then(res => res.body); }).then(res => res.body);
})); }));
}, },
@ -139,6 +143,9 @@ export default {
.then(ifNotTooLate(() => this.request(refreshedToken, { .then(ifNotTooLate(() => this.request(refreshedToken, {
method: 'DELETE', method: 'DELETE',
url: `https://www.googleapis.com/drive/v3/files/${id}`, url: `https://www.googleapis.com/drive/v3/files/${id}`,
params: {
supportsTeamDrives: true,
},
}))); })));
}, },
getFileRevisionsInternal(refreshedToken, id) { getFileRevisionsInternal(refreshedToken, id) {
@ -152,6 +159,7 @@ export default {
pageToken, pageToken,
pageSize: 1000, pageSize: 1000,
fields: 'nextPageToken,revisions(id,modifiedTime,lastModifyingUser/permissionId,lastModifyingUser/displayName,lastModifyingUser/photoLink)', fields: 'nextPageToken,revisions(id,modifiedTime,lastModifyingUser/permissionId,lastModifyingUser/displayName,lastModifyingUser/photoLink)',
supportsTeamDrives: true,
}, },
}) })
.then((res) => { .then((res) => {
@ -178,6 +186,9 @@ export default {
method: 'GET', method: 'GET',
url: `https://www.googleapis.com/drive/v3/files/${fileId}/revisions/${revisionId}?alt=media`, url: `https://www.googleapis.com/drive/v3/files/${fileId}/revisions/${revisionId}?alt=media`,
raw: true, raw: true,
params: {
supportsTeamDrives: true,
},
}).then(res => res.body)); }).then(res => res.body));
}, },
getUser(userId) { getUser(userId) {
@ -375,6 +386,8 @@ export default {
spaces: isAppData ? 'appDataFolder' : 'drive', spaces: isAppData ? 'appDataFolder' : 'drive',
pageSize: 1000, pageSize: 1000,
fields: `nextPageToken,newStartPageToken,changes(fileId,${fileFields})`, fields: `nextPageToken,newStartPageToken,changes(fileId,${fileFields})`,
supportsTeamDrives: true,
includeTeamDriveItems: true,
}, },
}) })
.then((res) => { .then((res) => {
@ -422,6 +435,7 @@ export default {
url: `https://www.googleapis.com/drive/v3/files/${id}`, url: `https://www.googleapis.com/drive/v3/files/${id}`,
params: { params: {
fields: 'id,name,mimeType,appProperties', fields: 'id,name,mimeType,appProperties',
supportsTeamDrives: true,
}, },
}) })
.then(res => res.body)); .then(res => res.body));
@ -534,6 +548,7 @@ export default {
let picker; let picker;
const pickerBuilder = new google.picker.PickerBuilder() const pickerBuilder = new google.picker.PickerBuilder()
.setOAuthToken(refreshedToken.accessToken) .setOAuthToken(refreshedToken.accessToken)
.enableFeature(google.picker.Feature.SUPPORT_TEAM_DRIVES)
.hideTitleBar() .hideTitleBar()
.setCallback((data) => { .setCallback((data) => {
switch (data[google.picker.Response.ACTION]) { switch (data[google.picker.Response.ACTION]) {
@ -567,13 +582,23 @@ export default {
} }
case 'folder': { case 'folder': {
const addView = (hasRootParent) => { const addView = (hasRootParent) => {
const view = new google.picker.DocsView(google.picker.ViewId.FOLDERS); const teamDriveView = new google.picker.DocsView(google.picker.ViewId.FOLDERS);
if (hasRootParent) { if (hasRootParent) {
view.setParent('root'); teamDriveView.setParent('root');
} }
view.setSelectFolderEnabled(true); teamDriveView.setSelectFolderEnabled(true);
view.setMimeTypes(this.folderMimeType); teamDriveView.setEnableTeamDrives(true);
pickerBuilder.addView(view); teamDriveView.setMimeTypes(this.folderMimeType);
const folderView = new google.picker.DocsView(google.picker.ViewId.FOLDERS);
if (hasRootParent) {
folderView.setParent('root');
}
folderView.setSelectFolderEnabled(true);
folderView.setMimeTypes(this.folderMimeType);
pickerBuilder.addView(teamDriveView);
pickerBuilder.addView(folderView);
}; };
addView(false); addView(false);
// addView(true); // addView(true);