forked from googleworkspace/gws-odo-addon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
drive.gs
55 lines (45 loc) · 1.41 KB
/
drive.gs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* @fileoverview Functions specific to how the Add-on looks and acts when
* in the context of a user's Drive.
*/
/**
* Function that's called (per manifest) for Drive homepage trigger
*
* @param {Object} e The event object.
*
* @return {CardService.Card} Card to show for Drive Homepage
*/
function onDriveHomepage(e) {
return buildIntegrationCard(CALL_CONTEXT.DRIVE);
}
/**
* Callback for rendering the card for specific Drive items.
* @param {Object} e - The event object.
*
* @return {CardService.Card} The card to show to the user.
*/
function onDriveItemsSelected(e) {
// Grab first file selected
var selectedFile = e.drive.selectedItems[0];
// Set up merge tags, based on selected file.
addMergeKeyValuePair('{{fileMimeType}}', selectedFile.mimeType);
addMergeKeyValuePair('{{fileName}}', selectedFile.title);
addMergeKeyValuePair('{{fileId}}', selectedFile.id);
return buildIntegrationCard(CALL_CONTEXT.DRIVE);
}
/**
* Returns special folder for storing Odo specific data in the user's
* Drive. Creates the folder first if not already present.
*
* @return {Object} A Folder object for use with DriveApp
*/
function createOrGetOdoDataFolder() {
let dataFolder;
let folders = DriveApp.getFoldersByName(ODO_DATA_FOLDER_NAME);
if (!folders.hasNext()) {
dataFolder = DriveApp.createFolder(ODO_DATA_FOLDER_NAME);
} else {
dataFolder = folders.next();
}
return dataFolder;
}