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">
<input slot="field" class="textfield" type="text" v-model.trim="folderId" @keydown.enter="resolve()">
<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 class="form-entry__actions">
<a href="javascript:void(0)" @click="openFolder">Choose folder</a>

View File

@ -8,7 +8,7 @@
<form-entry label="Folder ID" info="optional">
<input slot="field" class="textfield" type="text" v-model.trim="folderId" @keydown.enter="resolve()">
<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 class="form-entry__actions">
<a href="javascript:void(0)" @click="openFolder">Choose folder</a>

View File

@ -8,7 +8,7 @@
<form-entry label="Folder ID" info="optional">
<input slot="field" class="textfield" type="text" v-model.trim="folderId" @keydown.enter="resolve()">
<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 class="form-entry__actions">
<a href="javascript:void(0)" @click="openFolder">Choose folder</a>

View File

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

View File

@ -159,7 +159,6 @@ export default {
pageToken,
pageSize: 1000,
fields: 'nextPageToken,revisions(id,modifiedTime,lastModifyingUser/permissionId,lastModifyingUser/displayName,lastModifyingUser/photoLink)',
supportsTeamDrives: true,
},
})
.then((res) => {
@ -186,9 +185,6 @@ export default {
method: 'GET',
url: `https://www.googleapis.com/drive/v3/files/${fileId}/revisions/${revisionId}?alt=media`,
raw: true,
params: {
supportsTeamDrives: true,
},
}).then(res => res.body));
},
getUser(userId) {
@ -368,7 +364,7 @@ export default {
addPhotosAccount() {
return this.startOauth2(photosScopes);
},
getChanges(token, startPageToken, isAppData) {
getChanges(token, startPageToken, isAppData, teamDriveId = null) {
const result = {
changes: [],
};
@ -387,7 +383,8 @@ export default {
pageSize: 1000,
fields: `nextPageToken,newStartPageToken,changes(fileId,${fileFields})`,
supportsTeamDrives: true,
includeTeamDriveItems: true,
includeTeamDriveItems: !!teamDriveId,
teamDriveId,
},
})
.then((res) => {
@ -434,7 +431,7 @@ export default {
method: 'GET',
url: `https://www.googleapis.com/drive/v3/files/${id}`,
params: {
fields: 'id,name,mimeType,appProperties',
fields: 'id,name,mimeType,appProperties,teamDriveId',
supportsTeamDrives: true,
},
})
@ -563,45 +560,36 @@ export default {
switch (type) {
default:
case 'doc': {
const addView = (hasRootParent) => {
const view = new google.picker.DocsView(google.picker.ViewId.DOCS);
if (hasRootParent) {
view.setParent('root');
}
view.setMimeTypes([
'text/plain',
'text/x-markdown',
'application/octet-stream',
].join(','));
pickerBuilder.addView(view);
};
const mimeTypes = [
'text/plain',
'text/x-markdown',
'application/octet-stream',
].join(',');
const view = new google.picker.DocsView(google.picker.ViewId.DOCS);
view.setMimeTypes(mimeTypes);
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);
addView(false);
// addView(true);
pickerBuilder.enableFeature(google.picker.Feature.SUPPORT_TEAM_DRIVES);
break;
}
case 'folder': {
const addView = (hasRootParent) => {
const teamDriveView = new google.picker.DocsView(google.picker.ViewId.FOLDERS);
if (hasRootParent) {
teamDriveView.setParent('root');
}
teamDriveView.setSelectFolderEnabled(true);
teamDriveView.setEnableTeamDrives(true);
teamDriveView.setMimeTypes(this.folderMimeType);
const folderView = new google.picker.DocsView(google.picker.ViewId.FOLDERS);
folderView.setSelectFolderEnabled(true);
folderView.setMimeTypes(this.folderMimeType);
pickerBuilder.addView(folderView);
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(true);
const teamDriveView = new google.picker.DocsView(google.picker.ViewId.FOLDERS);
teamDriveView.setSelectFolderEnabled(true);
teamDriveView.setEnableTeamDrives(true);
teamDriveView.setMimeTypes(this.folderMimeType);
pickerBuilder.addView(teamDriveView);
break;
}
case 'img': {