diff --git a/packages/nodes-base/nodes/Notion/DatabasePageDescription.ts b/packages/nodes-base/nodes/Notion/DatabasePageDescription.ts index 958e63f7aa..ee45894269 100644 --- a/packages/nodes-base/nodes/Notion/DatabasePageDescription.ts +++ b/packages/nodes-base/nodes/Notion/DatabasePageDescription.ts @@ -534,6 +534,47 @@ export const databasePageFields: INodeProperties[] = [ ], }, ...blocks('databasePage', 'create'), + { + displayName: 'Options', + name: 'options', + type: 'collection', + displayOptions: { + show: { + resource: ['databasePage'], + operation: ['create'], + }, + }, + default: {}, + placeholder: 'Add Option', + options: [ + { + displayName: 'Icon Type', + name: 'iconType', + type: 'options', + options: [ + { + name: 'Emoji', + value: 'emoji', + description: 'Use an Emoji for the icon', + }, + { + name: 'File', + value: 'file', + description: 'Use a file for the icon', + }, + ], + default: 'emoji', + description: 'The icon type for the database page, Either a URL or an Emoji', + }, + { + displayName: 'Icon', + name: 'icon', + type: 'string', + default: '', + description: 'Emoji or File URL to use as the icon', + }, + ], + }, /* -------------------------------------------------------------------------- */ /* databasePage:update */ /* -------------------------------------------------------------------------- */ diff --git a/packages/nodes-base/nodes/Notion/PageDescription.ts b/packages/nodes-base/nodes/Notion/PageDescription.ts index 3d3829c612..5c4ec2d158 100644 --- a/packages/nodes-base/nodes/Notion/PageDescription.ts +++ b/packages/nodes-base/nodes/Notion/PageDescription.ts @@ -237,6 +237,47 @@ export const pageFields: INodeProperties[] = [ description: 'Whether to return a simplified version of the response instead of the raw data', }, ...blocks('page', 'create'), + { + displayName: 'Options', + name: 'options', + type: 'collection', + displayOptions: { + show: { + resource: ['page'], + operation: ['create'], + }, + }, + default: {}, + placeholder: 'Add Option', + options: [ + { + displayName: 'Icon Type', + name: 'iconType', + type: 'options', + options: [ + { + name: 'Emoji', + value: 'emoji', + description: 'Use an Emoji for the icon', + }, + { + name: 'File', + value: 'file', + description: 'Use a file for the icon', + }, + ], + default: 'emoji', + description: 'The icon type for the page, Either a URL or an Emoji', + }, + { + displayName: 'Icon', + name: 'icon', + type: 'string', + default: '', + description: 'Emoji or File URL to use as the icon', + }, + ], + }, /* -------------------------------------------------------------------------- */ /* page:get */ /* -------------------------------------------------------------------------- */ diff --git a/packages/nodes-base/nodes/Notion/v1/NotionV1.node.ts b/packages/nodes-base/nodes/Notion/v1/NotionV1.node.ts index cb20285f0c..71709bbdf7 100644 --- a/packages/nodes-base/nodes/Notion/v1/NotionV1.node.ts +++ b/packages/nodes-base/nodes/Notion/v1/NotionV1.node.ts @@ -369,6 +369,15 @@ export class NotionV1 implements INodeType { responseData = simplifyObjects(responseData, false, 1); } + const options = this.getNodeParameter('options', i); + if (options.icon) { + if (options.iconType && options.iconType === 'file') { + body.icon = { external: { url: options.icon } }; + } else { + body.icon = { emoji: options.icon }; + } + } + const executionData = this.helpers.constructExecutionMetaData( this.helpers.returnJsonArray(responseData), { itemData: { item: i } }, @@ -530,6 +539,15 @@ export class NotionV1 implements INodeType { responseData = simplifyObjects(responseData, false, 1); } + const options = this.getNodeParameter('options', i); + if (options.icon) { + if (options.iconType && options.iconType === 'file') { + body.icon = { external: { url: options.icon } }; + } else { + body.icon = { emoji: options.icon }; + } + } + const executionData = this.helpers.constructExecutionMetaData( this.helpers.returnJsonArray(responseData), { itemData: { item: i } }, diff --git a/packages/nodes-base/nodes/Notion/v2/NotionV2.node.ts b/packages/nodes-base/nodes/Notion/v2/NotionV2.node.ts index 2b1f7d88c8..566fab9f50 100644 --- a/packages/nodes-base/nodes/Notion/v2/NotionV2.node.ts +++ b/packages/nodes-base/nodes/Notion/v2/NotionV2.node.ts @@ -463,6 +463,16 @@ export class NotionV2 implements INodeType { const blockValues = this.getNodeParameter('blockUi.blockValues', i, []) as IDataObject[]; extractDatabaseMentionRLC(blockValues); body.children = formatBlocks(blockValues); + + const options = this.getNodeParameter('options', i); + if (options.icon) { + if (options.iconType && options.iconType === 'file') { + body.icon = { external: { url: options.icon } }; + } else { + body.icon = { emoji: options.icon }; + } + } + responseData = await notionApiRequest.call(this, 'POST', '/pages', body); if (simple) { responseData = simplifyObjects(responseData); @@ -663,7 +673,6 @@ export class NotionV2 implements INodeType { if (operation === 'create') { for (let i = 0; i < length; i++) { const simple = this.getNodeParameter('simple', i) as boolean; - const body: { [key: string]: any } = { parent: {}, properties: {}, @@ -675,6 +684,16 @@ export class NotionV2 implements INodeType { const blockValues = this.getNodeParameter('blockUi.blockValues', i, []) as IDataObject[]; extractDatabaseMentionRLC(blockValues); body.children = formatBlocks(blockValues); + + const options = this.getNodeParameter('options', i); + if (options.icon) { + if (options.iconType && options.iconType === 'file') { + body.icon = { external: { url: options.icon } }; + } else { + body.icon = { emoji: options.icon }; + } + } + responseData = await notionApiRequest.call(this, 'POST', '/pages', body); if (simple) { responseData = simplifyObjects(responseData, download);