feat(Google Sheets Node): Add "By Name" option to selector for Sheets (#8241)

Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
Elias Meire
2024-01-10 14:30:09 +01:00
committed by GitHub
parent e796e7f06d
commit dce28f9cb9
8 changed files with 87 additions and 46 deletions

View File

@@ -12,7 +12,7 @@ import { apiRequest } from './v2/transport';
import { sheetsSearch, spreadSheetsSearch } from './v2/methods/listSearch';
import { GoogleSheet } from './v2/helpers/GoogleSheet';
import { getSheetHeaderRowAndSkipEmpty } from './v2/methods/loadOptions';
import type { ValueRenderOption } from './v2/helpers/GoogleSheets.types';
import type { ResourceLocator, ValueRenderOption } from './v2/helpers/GoogleSheets.types';
import {
arrayOfArraysToJson,
@@ -399,11 +399,21 @@ export class GoogleSheetsTrigger implements INodeType {
extractValue: true,
}) as string;
let sheetId = this.getNodeParameter('sheetName', undefined, {
const sheetWithinDocument = this.getNodeParameter('sheetName', undefined, {
extractValue: true,
}) as string;
const { mode: sheetMode } = this.getNodeParameter('sheetName', 0) as {
mode: ResourceLocator;
};
sheetId = sheetId === 'gid=0' ? '0' : sheetId;
const googleSheet = new GoogleSheet(documentId, this);
const { sheetId, title: sheetName } = await googleSheet.spreadsheetGetSheet(
this.getNode(),
sheetMode,
sheetWithinDocument,
);
const options = this.getNodeParameter('options') as IDataObject;
// If the documentId or sheetId changed, reset the workflow static data
if (
@@ -417,13 +427,6 @@ export class GoogleSheetsTrigger implements INodeType {
workflowStaticData.lastIndexChecked = undefined;
}
const googleSheet = new GoogleSheet(documentId, this);
const sheetName: string = await googleSheet.spreadsheetGetSheetNameById(
this.getNode(),
sheetId,
);
const options = this.getNodeParameter('options') as IDataObject;
const previousRevision = workflowStaticData.lastRevision as number;
const previousRevisionLink = workflowStaticData.lastRevisionLink as string;