Skip to content

Commit

Permalink
Google Drive actions improvements (#11837)
Browse files Browse the repository at this point in the history
* Download File improvements

* Deprecating 'create file' and improving 'upload file'

* Text improvements

* text improvement

* text improvement

* adjustments

* Delete File improvements

* Adding theme id async options

* adjustment

* Get Shared Drive improvements

* Improvements

* Find Forms & Sheets improvements

* Search Query improvements

* Forms label

* Reusing query method and props

* Description updates

* find file - reusing common query stuff

* More search query improvements

* Description adjustments

* Moving constants file to common

* Version bumps

* Version bumps

* Find Spreadsheets bugfix

* Share File improvements and fixes

* Rename "share file" > "share file or folder"

* Summary improvement

* Version bump
  • Loading branch information
GTFalcao committed May 29, 2024
1 parent c19351c commit 569aa06
Show file tree
Hide file tree
Showing 61 changed files with 328 additions and 570 deletions.
2 changes: 1 addition & 1 deletion components/albus/albus.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/bookingmood/bookingmood.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/bunnydoc/bunnydoc.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/cardinal/cardinal.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/docsgenflow/docsgenflow.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/documenterra/documenterra.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/eagle_doc/eagle_doc.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/genderize/genderize.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import {
GOOGLE_DRIVE_FOLDER_MIME_TYPE,
GOOGLE_DRIVE_GRANTEE_DOMAIN,
GOOGLE_DRIVE_GRANTEE_GROUP,
GOOGLE_DRIVE_GRANTEE_USER,
GOOGLE_DRIVE_ROLE_OPTIONS,
GOOGLE_DRIVE_ROLE_OPTION_FILEORGANIZER,
GOOGLE_DRIVE_ROLE_WRITER,
} from "../../common/constants.mjs";
import googleDrive from "../../google_drive.app.mjs";

Expand All @@ -14,10 +17,10 @@ import googleDrive from "../../google_drive.app.mjs";
*/
export default {
key: "google_drive-add-file-sharing-preference",
name: "Share File",
name: "Share File or Folder",
description:
"Add a [sharing permission](https://support.google.com/drive/answer/7166529) to the sharing preferences of a file or folder and provide a sharing URL. [See the documentation](https://developers.google.com/drive/api/v3/reference/permissions/create)",
version: "0.1.5",
version: "0.1.6",
type: "action",
props: {
googleDrive,
Expand All @@ -38,6 +41,7 @@ export default {
],
optional: false,
description: "The file or folder to share",
reloadProps: true,
},
type: {
propDefinition: [
Expand All @@ -47,16 +51,25 @@ export default {
reloadProps: true,
},
},
additionalProps() {
async additionalProps() {
const obj = {};
const {
fileOrFolderId, type,
} = this;
if (!fileOrFolderId || !type) return obj;

const { mimeType } = await this.googleDrive.getFile(this.fileOrFolderId, {
fields: "mimeType",
});

const emailAddress = {
type: "string",
label: "Email Address",
description:
"Enter the email address of the user that you'd like to share the file or folder with (e.g. `[email protected]`).",
};

switch (this.type) {
switch (type) {
case GOOGLE_DRIVE_GRANTEE_DOMAIN:
obj.domain = {
type: "string",
Expand All @@ -80,13 +93,22 @@ export default {
break;
}

const isFolder = mimeType === GOOGLE_DRIVE_FOLDER_MIME_TYPE;
const options = GOOGLE_DRIVE_ROLE_OPTIONS;

if (isFolder) {
const writerOpt = options.find(({ value }) => value === GOOGLE_DRIVE_ROLE_WRITER);
writerOpt.label = writerOpt.label.replace(/Writer/, "Contributor");
options.push(GOOGLE_DRIVE_ROLE_OPTION_FILEORGANIZER);
}

return {
...obj,
role: {
type: "string",
label: "Role",
description: "The role granted by this permission",
options: GOOGLE_DRIVE_ROLE_OPTIONS,
options,
},
};
},
Expand All @@ -107,9 +129,9 @@ export default {
const webViewLink = resp.webViewLink;
$.export(
"$summary",
`Successfully shared file "${resp.name}" with ${this.type} "${
this.emailAddress ?? this.domain ?? ""
}"`,
`Successfully shared file "${resp.name}" with ${type} "${
emailAddress ?? domain ?? ""
}" with role '${role}'`,
);
return webViewLink;
},
Expand Down
4 changes: 2 additions & 2 deletions components/google_drive/actions/copy-file/copy-file.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import googleDrive from "../../google_drive.app.mjs";
export default {
key: "google_drive-copy-file",
name: "Copy File",
description: "Create a copy of the specified file. [See the docs](https://developers.google.com/drive/api/v3/reference/files/copy) for more information",
version: "0.1.4",
description: "Create a copy of the specified file. [See the documentation](https://developers.google.com/drive/api/v3/reference/files/copy) for more information",
version: "0.1.5",
type: "action",
props: {
googleDrive,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
key: "google_drive-create-file-from-template",
name: "Create New File From Template",
description: "Create a new Google Docs file from a template. Optionally include placeholders in the template document that will get replaced from this action. [See documentation](https://www.npmjs.com/package/google-docs-mustaches)",
version: "0.1.4",
version: "0.1.5",
type: "action",
props: {
googleDrive,
Expand All @@ -18,7 +18,7 @@ export default {
"fileId",
],
description:
"Select the template document you'd like to use as the template, or use a custom expression to reference a document ID from a previous step. Template documents should contain placeholders in the format {{xyz}}.",
"Select the template document you'd like to use as the template, or use a custom expression to reference a document ID from a previous step. Template documents should contain placeholders in the format `{{xyz}}`.",
},
folderId: {
propDefinition: [
Expand Down Expand Up @@ -49,7 +49,7 @@ export default {
replaceValues: {
type: "object",
label: "Replace text placeholders",
description: "Replace text placeholders in the document. Use the format {{xyz}} in the document but exclude the curly braces in the key. (eg. `{{myPlaceholder}}` in the document will be replaced by the value of the key `myPlaceholder` in the action.",
description: "Replace text placeholders in the document. Use the format `{{xyz}}` in the document but exclude the curly braces in the key. (eg. `{{myPlaceholder}}` in the document will be replaced by the value of the key `myPlaceholder` in the action.",
},
},
async run({ $ }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Readable } from "stream";
export default {
key: "google_drive-create-file-from-text",
name: "Create New File From Text",
description: "Create a new file from plain text. [See the docs](https://developers.google.com/drive/api/v3/reference/files/create) for more information",
version: "0.1.4",
description: "Create a new file from plain text. [See the documentation](https://developers.google.com/drive/api/v3/reference/files/create) for more information",
version: "0.1.5",
type: "action",
props: {
googleDrive,
Expand Down Expand Up @@ -33,6 +33,7 @@ export default {
googleDrive,
"fileName",
],
label: "File Name",
description:
"The name of the file you want to create (e.g., `myFile.txt`)",
},
Expand Down

0 comments on commit 569aa06

Please sign in to comment.