mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
feat(Notion Node): Add icon support for page and database page creation (#5468)
This commit is contained in:
parent
a9f08fc5ba
commit
71cba06b7c
|
@ -534,6 +534,47 @@ export const databasePageFields: INodeProperties[] = [
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
...blocks('databasePage', 'create'),
|
...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 */
|
/* databasePage:update */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
|
@ -237,6 +237,47 @@ export const pageFields: INodeProperties[] = [
|
||||||
description: 'Whether to return a simplified version of the response instead of the raw data',
|
description: 'Whether to return a simplified version of the response instead of the raw data',
|
||||||
},
|
},
|
||||||
...blocks('page', 'create'),
|
...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 */
|
/* page:get */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
|
@ -369,6 +369,15 @@ export class NotionV1 implements INodeType {
|
||||||
responseData = simplifyObjects(responseData, false, 1);
|
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(
|
const executionData = this.helpers.constructExecutionMetaData(
|
||||||
this.helpers.returnJsonArray(responseData),
|
this.helpers.returnJsonArray(responseData),
|
||||||
{ itemData: { item: i } },
|
{ itemData: { item: i } },
|
||||||
|
@ -530,6 +539,15 @@ export class NotionV1 implements INodeType {
|
||||||
responseData = simplifyObjects(responseData, false, 1);
|
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(
|
const executionData = this.helpers.constructExecutionMetaData(
|
||||||
this.helpers.returnJsonArray(responseData),
|
this.helpers.returnJsonArray(responseData),
|
||||||
{ itemData: { item: i } },
|
{ itemData: { item: i } },
|
||||||
|
|
|
@ -463,6 +463,16 @@ export class NotionV2 implements INodeType {
|
||||||
const blockValues = this.getNodeParameter('blockUi.blockValues', i, []) as IDataObject[];
|
const blockValues = this.getNodeParameter('blockUi.blockValues', i, []) as IDataObject[];
|
||||||
extractDatabaseMentionRLC(blockValues);
|
extractDatabaseMentionRLC(blockValues);
|
||||||
body.children = formatBlocks(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);
|
responseData = await notionApiRequest.call(this, 'POST', '/pages', body);
|
||||||
if (simple) {
|
if (simple) {
|
||||||
responseData = simplifyObjects(responseData);
|
responseData = simplifyObjects(responseData);
|
||||||
|
@ -663,7 +673,6 @@ export class NotionV2 implements INodeType {
|
||||||
if (operation === 'create') {
|
if (operation === 'create') {
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
const simple = this.getNodeParameter('simple', i) as boolean;
|
const simple = this.getNodeParameter('simple', i) as boolean;
|
||||||
|
|
||||||
const body: { [key: string]: any } = {
|
const body: { [key: string]: any } = {
|
||||||
parent: {},
|
parent: {},
|
||||||
properties: {},
|
properties: {},
|
||||||
|
@ -675,6 +684,16 @@ export class NotionV2 implements INodeType {
|
||||||
const blockValues = this.getNodeParameter('blockUi.blockValues', i, []) as IDataObject[];
|
const blockValues = this.getNodeParameter('blockUi.blockValues', i, []) as IDataObject[];
|
||||||
extractDatabaseMentionRLC(blockValues);
|
extractDatabaseMentionRLC(blockValues);
|
||||||
body.children = formatBlocks(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);
|
responseData = await notionApiRequest.call(this, 'POST', '/pages', body);
|
||||||
if (simple) {
|
if (simple) {
|
||||||
responseData = simplifyObjects(responseData, download);
|
responseData = simplifyObjects(responseData, download);
|
||||||
|
|
Loading…
Reference in a new issue