mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -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'),
|
||||
{
|
||||
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 */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
|
|
@ -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 */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
|
|
@ -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 } },
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue