-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Added 6 new actions to support advanced cell formatting, data validation, and protection #18995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
michelle0927
merged 11 commits into
PipedreamHQ:master
from
PrajwalLokhande2003:add-action-in-google-sheet
Nov 12, 2025
+849
−1
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
19aab43
Added 6 new actions to support advanced cell formatting, data validat…
PrajwalLokhande2003 6856b44
Merge branch 'master' into add-action-in-google-sheet
PrajwalLokhande2003 fccb924
resolve PR comment
PrajwalLokhande2003 1fd1c87
Update components/google_sheets/actions/add-conditional-format-rule/a…
michelle0927 2bd89c2
Update components/google_sheets/actions/set-data-validation/set-data-…
michelle0927 9f44363
add-conditional-format-rule updates
michelle0927 4258d3f
add-protected-range updates
michelle0927 8b35e32
delete-conditional-format-rule update
michelle0927 64cbac5
merge-cells update
michelle0927 e158d5d
set-data-validation update
michelle0927 1ff970d
update-conditional-format-rule updates
michelle0927 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
223 changes: 223 additions & 0 deletions
223
components/google_sheets/actions/add-conditional-format-rule/add-conditional-format-rule.mjs
This file contains hidden or 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,223 @@ | ||
| import googleSheets from "../../google_sheets.app.mjs"; | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| key: "google_sheets-add-conditional-format-rule", | ||
| name: "Add Conditional Format Rule", | ||
| description: "Create conditional formatting with color scales or custom formulas. [See the documentation](https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/request#AddConditionalFormatRuleRequest)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: false, | ||
| }, | ||
| props: { | ||
| googleSheets, | ||
| drive: { | ||
| propDefinition: [ | ||
| googleSheets, | ||
| "watchedDrive", | ||
| ], | ||
| }, | ||
| sheetId: { | ||
| propDefinition: [ | ||
| googleSheets, | ||
| "sheetID", | ||
| (c) => ({ | ||
| driveId: googleSheets.methods.getDriveId(c.drive), | ||
| }), | ||
| ], | ||
| }, | ||
| worksheetId: { | ||
| propDefinition: [ | ||
| googleSheets, | ||
| "worksheetIDs", | ||
| (c) => ({ | ||
| sheetId: c.sheetId, | ||
| }), | ||
| ], | ||
| }, | ||
| range: { | ||
| propDefinition: [ | ||
| googleSheets, | ||
| "range", | ||
| ], | ||
| description: "The range of cells to format (e.g., `A1:A10`)", | ||
| }, | ||
| conditionType: { | ||
| type: "string", | ||
| label: "Validation Type", | ||
| description: "The type of data condition", | ||
| options: [ | ||
| "ONE_OF_LIST", | ||
| "NUMBER_GREATER", | ||
| "NUMBER_LESS", | ||
| "DATE_BEFORE", | ||
| "DATE_AFTER", | ||
| "TEXT_CONTAINS", | ||
| "TEXT_IS_EMAIL", | ||
| "TEXT_IS_URL", | ||
| "BOOLEAN", | ||
| ], | ||
| }, | ||
| conditionValues: { | ||
| type: "string[]", | ||
| label: "Condition Values", | ||
| description: "Values for condition (e.g., color scales or custom formulas)", | ||
| }, | ||
| formattingType: { | ||
| type: "string", | ||
| label: "Formatting Type", | ||
| description: "Choose between boolean condition or gradient color scale", | ||
| options: [ | ||
| "BOOLEAN_RULE", | ||
| "GRADIENT_RULE", | ||
| ], | ||
| default: "BOOLEAN_RULE", | ||
| }, | ||
| rgbColor: { | ||
| type: "object", | ||
| label: "RGB Color", | ||
| description: "The RGB color value (e.g., {\"red\": 1.0, \"green\": 0.5, \"blue\": 0.2})", | ||
| optional: true, | ||
| }, | ||
| textFormat: { | ||
| type: "object", | ||
| label: "Text Format", | ||
| description: "The text format options", | ||
| optional: true, | ||
| }, | ||
| bold: { | ||
| type: "boolean", | ||
| label: "Bold", | ||
| description: "Whether the text is bold", | ||
| optional: true, | ||
| }, | ||
| italic: { | ||
| type: "boolean", | ||
| label: "Italic", | ||
| description: "Whether the text is italic", | ||
| optional: true, | ||
| }, | ||
| strikethrough: { | ||
| type: "boolean", | ||
| label: "Strikethrough", | ||
| description: "Whether the text is strikethrough", | ||
| optional: true, | ||
| }, | ||
| interpolationPointType: { | ||
| type: "string", | ||
| label: "Interpolation Point Type", | ||
| description: "The interpolation point type", | ||
| options: [ | ||
| "MIN", | ||
| "MAX", | ||
| "NUMBER", | ||
| "PERCENT", | ||
| "PERCENTILE", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| index: { | ||
| type: "integer", | ||
| label: "Index", | ||
| description: "The zero-based index of the rule", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| startCol, | ||
| endCol, | ||
| startRow, | ||
| endRow, | ||
| } = this.googleSheets._parseRangeString(`${this.worksheetId}!${this.range}`); | ||
|
|
||
| const rule = { | ||
| ranges: [ | ||
| { | ||
| sheetId: this.worksheetId, | ||
| startRowIndex: startRow, | ||
| endRowIndex: endRow, | ||
| startColumnIndex: startCol.charCodeAt(0) - 65, | ||
| endColumnIndex: endCol.charCodeAt(0) - 64, | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| const parseRgbColor = (rgbColor = {}) => { | ||
| if (typeof rgbColor === "string") { | ||
| try { | ||
| rgbColor = JSON.parse(rgbColor); | ||
| } catch { | ||
| throw new ConfigurationError("Could not parse RGB Color. Please provide a valid JSON object."); | ||
| } | ||
| } | ||
| return rgbColor; | ||
| }; | ||
|
|
||
| this.formattingType === "GRADIENT_RULE" ? | ||
| rule.gradientRule = { | ||
| minpoint: { | ||
| colorStyle: { | ||
| rgbColor: parseRgbColor(this.rgbColor), | ||
| }, | ||
| type: this.interpolationPointType, | ||
| value: "MIN", | ||
| }, | ||
| midpoint: { | ||
| colorStyle: { | ||
| rgbColor: parseRgbColor(this.rgbColor), | ||
| }, | ||
| type: this.interpolationPointType, | ||
| value: "MID", | ||
| }, | ||
| maxpoint: { | ||
| colorStyle: { | ||
| rgbColor: parseRgbColor(this.rgbColor), | ||
| }, | ||
| type: this.interpolationPointType, | ||
| value: "MAX", | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } : | ||
| rule.booleanRule = { | ||
| condition: { | ||
| type: this.conditionType, | ||
| values: this.conditionValues?.map((v) => ({ | ||
| userEnteredValue: v, | ||
| })) || [], | ||
| }, | ||
| format: { | ||
| backgroundColorStyle: { | ||
| rgbColor: parseRgbColor(this.rgbColor), | ||
| }, | ||
| textFormat: { | ||
| ...this.textFormat, | ||
| foregroundColorStyle: { | ||
| rgbColor: parseRgbColor(this.rgbColor), | ||
| }, | ||
| bold: this.bold, | ||
| italic: this.italic, | ||
| strikethrough: this.strikethrough, | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| }; | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const request = { | ||
| spreadsheetId: this.sheetId, | ||
| requestBody: { | ||
| requests: [ | ||
| { | ||
| addConditionalFormatRule: { | ||
| rule, | ||
| index: this.index, | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| }; | ||
| const response = await this.googleSheets.batchUpdate(request); | ||
| $.export("$summary", "Successfully added conditional format rule."); | ||
| return response; | ||
| }, | ||
| }; | ||
111 changes: 111 additions & 0 deletions
111
components/google_sheets/actions/add-protected-range/add-protected-range.mjs
This file contains hidden or 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,111 @@ | ||
| import googleSheets from "../../google_sheets.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "google_sheets-add-protected-range", | ||
| name: "Add Protected Range", | ||
| description: "Add edit protection to cell range with permissions. [See the documentation](https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/request#AddProtectedRangeRequest)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: false, | ||
| }, | ||
| props: { | ||
| googleSheets, | ||
| drive: { | ||
| propDefinition: [ | ||
| googleSheets, | ||
| "watchedDrive", | ||
| ], | ||
| }, | ||
| sheetId: { | ||
| propDefinition: [ | ||
| googleSheets, | ||
| "sheetID", | ||
| (c) => ({ | ||
| driveId: googleSheets.methods.getDriveId(c.drive), | ||
| }), | ||
| ], | ||
| }, | ||
| worksheetId: { | ||
| propDefinition: [ | ||
| googleSheets, | ||
| "worksheetIDs", | ||
| (c) => ({ | ||
| sheetId: c.sheetId, | ||
| }), | ||
| ], | ||
| }, | ||
| protectedRangeId: { | ||
| type: "integer", | ||
| label: "Protected Range ID", | ||
| description: "The ID of the protected range (required for update and delete operations). This is a unique identifier assigned by Google Sheets", | ||
| optional: true, | ||
| }, | ||
| range: { | ||
| propDefinition: [ | ||
| googleSheets, | ||
| "range", | ||
| ], | ||
| description: "The range of cells to protect (e.g., `A1:A10`). Required for add and update operations", | ||
| }, | ||
| description: { | ||
| type: "string", | ||
| label: "Description", | ||
| description: "A description of the protected range", | ||
| optional: true, | ||
| }, | ||
| requestingUserCanEdit: { | ||
| type: "boolean", | ||
| label: "Requesting User Can Edit", | ||
| description: "If true, the user making this request can edit the protected range", | ||
| optional: true, | ||
| default: false, | ||
| }, | ||
| protectors: { | ||
| type: "string[]", | ||
| label: "Protectors", | ||
| description: "Email addresses of users/groups who can edit the protected range (e.g., user@example.com)", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| startCol, | ||
| endCol, | ||
| startRow, | ||
| endRow, | ||
| } = this.googleSheets._parseRangeString(`${this.worksheetId}!${this.range}`); | ||
|
|
||
| const request = { | ||
| spreadsheetId: this.sheetId, | ||
| requestBody: { | ||
| requests: [ | ||
| { | ||
| addProtectedRange: { | ||
| protectedRange: { | ||
| protectedRangeId: this.protectedRangeId, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| range: { | ||
| sheetId: this.worksheetId, | ||
| startRowIndex: startRow, | ||
| endRowIndex: endRow, | ||
| startColumnIndex: startCol.charCodeAt(0) - 65, | ||
| endColumnIndex: endCol.charCodeAt(0) - 64, | ||
| }, | ||
| description: this.description, | ||
| requestingUserCanEdit: this.requestingUserCanEdit, | ||
| editors: { | ||
| users: this.protectors || [], | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| }; | ||
| const response = await this.googleSheets.batchUpdate(request); | ||
| $.export("$summary", "Successfully added protected range."); | ||
| return response; | ||
| }, | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.