Team drive support

This commit is contained in:
Benoit Schweblin 2018-04-11 10:17:53 +01:00
parent 89880ed1a4
commit c3de3c1f84
5 changed files with 34 additions and 45 deletions

View File

@ -8,7 +8,7 @@
<form-entry label="Folder ID" info="optional"> <form-entry label="Folder ID" info="optional">
<input slot="field" class="textfield" type="text" v-model.trim="folderId" @keydown.enter="resolve()"> <input slot="field" class="textfield" type="text" v-model.trim="folderId" @keydown.enter="resolve()">
<div class="form-entry__info"> <div class="form-entry__info">
If no folder ID is supplied, the file will be created in your root folder. If not supplied, the file will be created in your Drive root folder.
</div> </div>
<div class="form-entry__actions"> <div class="form-entry__actions">
<a href="javascript:void(0)" @click="openFolder">Choose folder</a> <a href="javascript:void(0)" @click="openFolder">Choose folder</a>

View File

@ -8,7 +8,7 @@
<form-entry label="Folder ID" info="optional"> <form-entry label="Folder ID" info="optional">
<input slot="field" class="textfield" type="text" v-model.trim="folderId" @keydown.enter="resolve()"> <input slot="field" class="textfield" type="text" v-model.trim="folderId" @keydown.enter="resolve()">
<div class="form-entry__info"> <div class="form-entry__info">
If no folder ID is supplied, the file will be created in your root folder. If not supplied, the file will be created in your Drive root folder.
</div> </div>
<div class="form-entry__actions"> <div class="form-entry__actions">
<a href="javascript:void(0)" @click="openFolder">Choose folder</a> <a href="javascript:void(0)" @click="openFolder">Choose folder</a>

View File

@ -8,7 +8,7 @@
<form-entry label="Folder ID" info="optional"> <form-entry label="Folder ID" info="optional">
<input slot="field" class="textfield" type="text" v-model.trim="folderId" @keydown.enter="resolve()"> <input slot="field" class="textfield" type="text" v-model.trim="folderId" @keydown.enter="resolve()">
<div class="form-entry__info"> <div class="form-entry__info">
If no folder ID is supplied, a new workspace folder will be created in your root folder. If not supplied, a new workspace folder will be created in your Drive root folder.
</div> </div>
<div class="form-entry__actions"> <div class="form-entry__actions">
<a href="javascript:void(0)" @click="openFolder">Choose folder</a> <a href="javascript:void(0)" @click="openFolder">Choose folder</a>

View File

@ -101,6 +101,7 @@ export default providerRegistry.register({
providerId: this.id, providerId: this.id,
url: location.href, url: location.href,
folderId: folder.id, folderId: folder.id,
teamDriveId: folder.teamDriveId,
dataFolderId: properties.dataFolderId, dataFolderId: properties.dataFolderId,
trashFolderId: properties.trashFolderId, trashFolderId: properties.trashFolderId,
}, },
@ -223,7 +224,7 @@ export default providerRegistry.register({
const workspace = store.getters['workspace/currentWorkspace']; const workspace = store.getters['workspace/currentWorkspace'];
const syncToken = store.getters['workspace/syncToken']; const syncToken = store.getters['workspace/syncToken'];
const startPageToken = store.getters['data/localSettings'].syncStartPageToken; const startPageToken = store.getters['data/localSettings'].syncStartPageToken;
return googleHelper.getChanges(syncToken, startPageToken, false) return googleHelper.getChanges(syncToken, startPageToken, false, workspace.teamDriveId)
.then((result) => { .then((result) => {
// Collect possible parent IDs // Collect possible parent IDs
const parentIds = {}; const parentIds = {};

View File

@ -159,7 +159,6 @@ 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) => {
@ -186,9 +185,6 @@ 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) {
@ -368,7 +364,7 @@ export default {
addPhotosAccount() { addPhotosAccount() {
return this.startOauth2(photosScopes); return this.startOauth2(photosScopes);
}, },
getChanges(token, startPageToken, isAppData) { getChanges(token, startPageToken, isAppData, teamDriveId = null) {
const result = { const result = {
changes: [], changes: [],
}; };
@ -387,7 +383,8 @@ export default {
pageSize: 1000, pageSize: 1000,
fields: `nextPageToken,newStartPageToken,changes(fileId,${fileFields})`, fields: `nextPageToken,newStartPageToken,changes(fileId,${fileFields})`,
supportsTeamDrives: true, supportsTeamDrives: true,
includeTeamDriveItems: true, includeTeamDriveItems: !!teamDriveId,
teamDriveId,
}, },
}) })
.then((res) => { .then((res) => {
@ -434,7 +431,7 @@ export default {
method: 'GET', method: 'GET',
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,teamDriveId',
supportsTeamDrives: true, supportsTeamDrives: true,
}, },
}) })
@ -563,45 +560,36 @@ export default {
switch (type) { switch (type) {
default: default:
case 'doc': { case 'doc': {
const addView = (hasRootParent) => { const mimeTypes = [
const view = new google.picker.DocsView(google.picker.ViewId.DOCS);
if (hasRootParent) {
view.setParent('root');
}
view.setMimeTypes([
'text/plain', 'text/plain',
'text/x-markdown', 'text/x-markdown',
'application/octet-stream', 'application/octet-stream',
].join(',')); ].join(',');
const view = new google.picker.DocsView(google.picker.ViewId.DOCS);
view.setMimeTypes(mimeTypes);
pickerBuilder.addView(view); pickerBuilder.addView(view);
};
const teamDriveView = new google.picker.DocsView(google.picker.ViewId.DOCS);
teamDriveView.setMimeTypes(mimeTypes);
teamDriveView.setEnableTeamDrives(true);
pickerBuilder.addView(teamDriveView);
pickerBuilder.enableFeature(google.picker.Feature.MULTISELECT_ENABLED); pickerBuilder.enableFeature(google.picker.Feature.MULTISELECT_ENABLED);
addView(false); pickerBuilder.enableFeature(google.picker.Feature.SUPPORT_TEAM_DRIVES);
// addView(true);
break; break;
} }
case 'folder': { case 'folder': {
const addView = (hasRootParent) => { const folderView = new google.picker.DocsView(google.picker.ViewId.FOLDERS);
folderView.setSelectFolderEnabled(true);
folderView.setMimeTypes(this.folderMimeType);
pickerBuilder.addView(folderView);
const teamDriveView = new google.picker.DocsView(google.picker.ViewId.FOLDERS); const teamDriveView = new google.picker.DocsView(google.picker.ViewId.FOLDERS);
if (hasRootParent) {
teamDriveView.setParent('root');
}
teamDriveView.setSelectFolderEnabled(true); teamDriveView.setSelectFolderEnabled(true);
teamDriveView.setEnableTeamDrives(true); teamDriveView.setEnableTeamDrives(true);
teamDriveView.setMimeTypes(this.folderMimeType); 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(teamDriveView);
pickerBuilder.addView(folderView);
};
addView(false);
// addView(true);
break; break;
} }
case 'img': { case 'img': {