forked from activepieces/activepieces
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request activepieces#1605 from Abdallah-Alwarawreh/piece/g…
…oogle-sheets
- Loading branch information
Showing
9 changed files
with
216 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"name": "@activepieces/piece-google-sheets", | ||
"version": "0.2.21" | ||
"version": "0.2.22" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
packages/pieces/google-sheets/src/lib/actions/clear-sheet.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { createAction, Property } from '@activepieces/pieces-framework'; | ||
import { googleSheetsCommon } from '../common/common'; | ||
|
||
export const clearSheetAction = createAction({ | ||
name: 'clear_sheet', | ||
description: 'Clears all rows on an existing sheet', | ||
displayName: 'Clear Sheet', | ||
props: { | ||
authentication: googleSheetsCommon.authentication, | ||
spreadsheet_id: googleSheetsCommon.spreadsheet_id, | ||
include_team_drives: googleSheetsCommon.include_team_drives, | ||
sheet_id: googleSheetsCommon.sheet_id, | ||
is_first_row_headers: Property.Checkbox({ | ||
displayName: 'Is First row Headers?', | ||
description: 'If the first row is headers', | ||
required: true, | ||
defaultValue: true, | ||
}), | ||
}, | ||
async run(context) { | ||
const sheetName = await googleSheetsCommon.findSheetName(context.propsValue['authentication']['access_token'], | ||
context.propsValue['spreadsheet_id'], | ||
context.propsValue['sheet_id']); | ||
if (!sheetName) { | ||
throw Error("Sheet not found in spreadsheet"); | ||
} | ||
|
||
const rowsToDelete: number[] = []; | ||
const values = await googleSheetsCommon.getValues(context.propsValue.spreadsheet_id, context.propsValue['authentication']['access_token'], context.propsValue.sheet_id); | ||
for (const key in values) { | ||
if (key === '0' && context.propsValue.is_first_row_headers) { | ||
continue; | ||
} | ||
rowsToDelete.push(parseInt(key) + 1); | ||
} | ||
|
||
for (let i = 0; i < rowsToDelete.length; i++) { | ||
await googleSheetsCommon.clearSheet(context.propsValue.spreadsheet_id, | ||
context.propsValue.sheet_id, context.propsValue['authentication']['access_token'], | ||
context.propsValue.is_first_row_headers ? 1 : 0, rowsToDelete.length) | ||
} | ||
|
||
return { | ||
deletedRow: rowsToDelete, | ||
} | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.