Skip to content

Commit 024cfe2

Browse files
authored
Google Sheet - Create Spreadsheet: allow create spreadsheet in a folder (#16664)
* add folderId prop * pnpm-lock.yaml * updates * pnpm-lock.yaml
1 parent 70d6955 commit 024cfe2

File tree

14 files changed

+43
-33
lines changed

14 files changed

+43
-33
lines changed

components/google_sheets/actions/create-spreadsheet/create-spreadsheet.mjs

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "google_sheets-create-spreadsheet",
55
name: "Create Spreadsheet",
66
description: "Create a blank spreadsheet or duplicate an existing spreadsheet. [See the documentation](https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/create)",
7-
version: "0.1.9",
7+
version: "0.1.10",
88
type: "action",
99
props: {
1010
googleSheets,
@@ -20,6 +20,17 @@ export default {
2020
label: "Title",
2121
description: "The title of the new spreadsheet",
2222
},
23+
folderId: {
24+
propDefinition: [
25+
googleSheets,
26+
"folderId",
27+
(c) => ({
28+
drive: c.drive,
29+
}),
30+
],
31+
description: "The folder you want to save the file to",
32+
optional: true,
33+
},
2334
sheetId: {
2435
propDefinition: [
2536
googleSheets,
@@ -32,10 +43,11 @@ export default {
3243
optional: true,
3344
},
3445
},
35-
async run() {
46+
async run({ $ }) {
3647
const {
3748
googleSheets,
3849
sheetId,
50+
folderId,
3951
title,
4052
drive,
4153
} = this;
@@ -48,26 +60,32 @@ export default {
4860
isMyDrive,
4961
} = googleSheets;
5062

63+
let response;
5164
if (sheetId) {
52-
return copySpreadsheet(sheetId, title);
65+
response = await copySpreadsheet(sheetId, title);
66+
} else {
67+
response = await createSpreadsheet({
68+
resource: {
69+
properties: {
70+
title,
71+
},
72+
},
73+
});
5374
}
5475

55-
const response = await createSpreadsheet({
56-
resource: {
57-
properties: {
58-
title,
59-
},
60-
},
61-
});
76+
const spreadsheetId = response?.spreadsheetId || response?.id;
77+
const summary = `Successfully created spreadsheet with ID: ${spreadsheetId}`;
6278

63-
if (isMyDrive(drive)) {
79+
if (!folderId && isMyDrive(drive)) {
80+
$.export("$summary", summary);
6481
return response;
6582
}
6683

67-
const spreadsheet = await updateFile(response.spreadsheetId, {
68-
addParents: drive,
84+
const spreadsheet = await updateFile(spreadsheetId, {
85+
addParents: folderId || drive,
6986
});
7087

88+
$.export("$summary", summary);
7189
return getSpreadsheet(spreadsheet.id);
7290
},
7391
};

components/google_sheets/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/google_sheets",
3-
"version": "0.8.1",
3+
"version": "0.8.2",
44
"description": "Pipedream Google_sheets Components",
55
"main": "google_sheets.app.mjs",
66
"keywords": [

components/hubflo/hubflo.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/lamini/lamini.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/lead_identity_check/lead_identity_check.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/magileads/magileads.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/maileroo/maileroo.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/murf/murf.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/nextlead/nextlead.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/pushinator/pushinator.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

0 commit comments

Comments
 (0)