Skip to content
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

feat(Notion Node): Add option to update icon when updating a page #5670

Merged
merged 2 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions packages/nodes-base/nodes/Notion/DatabasePageDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,48 @@ export const databasePageFields: INodeProperties[] = [
},
],
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
displayOptions: {
show: {
resource: ['databasePage'],
operation: ['update'],
},
},
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:get */
/* -------------------------------------------------------------------------- */
Expand Down
10 changes: 10 additions & 0 deletions packages/nodes-base/nodes/Notion/v2/NotionV2.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,16 @@ export class NotionV2 implements INodeType {
if (properties.length !== 0) {
body.properties = mapProperties.call(this, properties, timezone, 2) as IDataObject;
}

const options = this.getNodeParameter('options', i);
if (options.icon) {
if (options.iconType && options.iconType === 'file') {
body.icon = { type: 'external', external: { url: options.icon } };
} else {
body.icon = { type: 'emoji', emoji: options.icon };
}
}

responseData = await notionApiRequest.call(this, 'PATCH', `/pages/${pageId}`, body);
if (simple) {
responseData = simplifyObjects(responseData, false);
Expand Down