From 64f71fa4ee7ed52d4aa2649b9fbb3d292d67dd98 Mon Sep 17 00:00:00 2001 From: Sayan Banerjee Date: Fri, 1 Mar 2024 23:16:56 +0530 Subject: [PATCH 1/2] feat/Add Change Workspace Option in Overflow Menu within Create Page Overflow Modale --- enum/modals/NotionDatabase.ts | 5 +++-- src/handlers/ExecuteBlockActionHandler.ts | 10 +++++----- src/modals/createPageOrRecordModal.ts | 10 ++++++++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/enum/modals/NotionDatabase.ts b/enum/modals/NotionDatabase.ts index 0d777a8..2c65932 100644 --- a/enum/modals/NotionDatabase.ts +++ b/enum/modals/NotionDatabase.ts @@ -48,7 +48,8 @@ export enum DatabaseModal { SELECT_PROPERTY_OPTION_NAME = "select-property-option-name-action", PROPERTY_TYPE_TITLE = "title", OVERFLOW_MENU_ACTION = "create-notion-database-overflow-menu-action-id", - OVERFLOW_MENU_TEXT = "Create Database", + OVERFLOW_MENU_TEXT_CREATE_DB = "Create Database", + OVERFLOW_MENU_ACTION_CREATE_DB = "create-notion-database-overflow-menu-action-id", OVERFLOW_CHANGE_WORKSPACE_ACTION = "change-notion-workspace-overflow-menu-action-id", - OVERFLOW_CHANGE_WORKSPACE_TEXT = "Change Workspace" + OVERFLOW_CHANGE_WORKSPACE_TEXT = "Change Workspace", } diff --git a/src/handlers/ExecuteBlockActionHandler.ts b/src/handlers/ExecuteBlockActionHandler.ts index b271677..b710b6e 100644 --- a/src/handlers/ExecuteBlockActionHandler.ts +++ b/src/handlers/ExecuteBlockActionHandler.ts @@ -805,8 +805,9 @@ export class ExecuteBlockActionHandler { const OverFlowActions = [ DatabaseModal.OVERFLOW_MENU_ACTION.toString(), DatabaseModal.OVERFLOW_CHANGE_WORKSPACE_ACTION.toString(), + DatabaseModal.OVERFLOW_MENU_ACTION_CREATE_DB.toString(), NotionPageOrRecord.CHANGE_DATABASE_ACTION.toString(), - NotionPageOrRecord.OVERFLOW_CHANGE_TO_PAGE_ACTION.toString() + NotionPageOrRecord.OVERFLOW_CHANGE_TO_PAGE_ACTION.toString(), ]; if (!OverFlowActions.includes(value)) { @@ -832,17 +833,17 @@ export class ExecuteBlockActionHandler { }); switch (value) { - case DatabaseModal.OVERFLOW_MENU_ACTION: { + case DatabaseModal.OVERFLOW_MENU_ACTION_CREATE_DB: { await handler.createNotionDatabase(); break; } - case DatabaseModal.OVERFLOW_CHANGE_WORKSPACE_ACTION:{ + case DatabaseModal.OVERFLOW_CHANGE_WORKSPACE_ACTION: { await handler.changeNotionWorkspace(); break; } - case NotionPageOrRecord.OVERFLOW_CHANGE_TO_PAGE_ACTION:{ + case NotionPageOrRecord.OVERFLOW_CHANGE_TO_PAGE_ACTION: { await handler.createNotionPageOrRecord(); break; } @@ -945,7 +946,6 @@ export class ExecuteBlockActionHandler { const tokenInfo = await oAuth2Storage.getCurrentWorkspace(user.id); const roomId = await roomInteractionStorage.getInteractionRoomId(); const room = (await this.read.getRoomReader().getById(roomId)) as IRoom; - if (!tokenInfo) { await sendNotificationWithConnectBlock( this.app, diff --git a/src/modals/createPageOrRecordModal.ts b/src/modals/createPageOrRecordModal.ts index d6cd623..65a9b35 100644 --- a/src/modals/createPageOrRecordModal.ts +++ b/src/modals/createPageOrRecordModal.ts @@ -48,8 +48,14 @@ export async function createPageOrRecordModal( const divider = blockBuilder.createDividerBlock(); const blocks: Block[] = []; const appId = app.getID(); - const overFlowMenuText = [DatabaseModal.OVERFLOW_MENU_TEXT.toString()]; - const overFlowMenuValue = [DatabaseModal.OVERFLOW_MENU_ACTION.toString()]; + const overFlowMenuText = [ + DatabaseModal.OVERFLOW_MENU_TEXT_CREATE_DB.toString(), + DatabaseModal.OVERFLOW_CHANGE_WORKSPACE_TEXT.toString(), + ]; + const overFlowMenuValue = [ + DatabaseModal.OVERFLOW_MENU_ACTION_CREATE_DB.toString(), + DatabaseModal.OVERFLOW_CHANGE_WORKSPACE_ACTION.toString(), + ]; let properties: object | undefined; let addedProperty: { data: Array } | undefined; let allUsers: object | undefined; From bf613a39470fefa49fb0576f50af2df2666d8495 Mon Sep 17 00:00:00 2001 From: Sayan Banerjee Date: Sat, 2 Mar 2024 02:00:47 +0530 Subject: [PATCH 2/2] completed requested changes --- enum/modals/NotionDatabase.ts | 1 - src/handlers/ExecuteBlockActionHandler.ts | 2 +- src/modals/createPageOrRecordModal.ts | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/enum/modals/NotionDatabase.ts b/enum/modals/NotionDatabase.ts index 2c65932..6aa7ced 100644 --- a/enum/modals/NotionDatabase.ts +++ b/enum/modals/NotionDatabase.ts @@ -47,7 +47,6 @@ export enum DatabaseModal { REMOVE_OPTION_BLOCK = "remove-option-notion-database-block-id", SELECT_PROPERTY_OPTION_NAME = "select-property-option-name-action", PROPERTY_TYPE_TITLE = "title", - OVERFLOW_MENU_ACTION = "create-notion-database-overflow-menu-action-id", OVERFLOW_MENU_TEXT_CREATE_DB = "Create Database", OVERFLOW_MENU_ACTION_CREATE_DB = "create-notion-database-overflow-menu-action-id", OVERFLOW_CHANGE_WORKSPACE_ACTION = "change-notion-workspace-overflow-menu-action-id", diff --git a/src/handlers/ExecuteBlockActionHandler.ts b/src/handlers/ExecuteBlockActionHandler.ts index b710b6e..c1f70a8 100644 --- a/src/handlers/ExecuteBlockActionHandler.ts +++ b/src/handlers/ExecuteBlockActionHandler.ts @@ -803,7 +803,6 @@ export class ExecuteBlockActionHandler { // Check if the value is pageId. if not then it is not a refresh comment action const OverFlowActions = [ - DatabaseModal.OVERFLOW_MENU_ACTION.toString(), DatabaseModal.OVERFLOW_CHANGE_WORKSPACE_ACTION.toString(), DatabaseModal.OVERFLOW_MENU_ACTION_CREATE_DB.toString(), NotionPageOrRecord.CHANGE_DATABASE_ACTION.toString(), @@ -946,6 +945,7 @@ export class ExecuteBlockActionHandler { const tokenInfo = await oAuth2Storage.getCurrentWorkspace(user.id); const roomId = await roomInteractionStorage.getInteractionRoomId(); const room = (await this.read.getRoomReader().getById(roomId)) as IRoom; + if (!tokenInfo) { await sendNotificationWithConnectBlock( this.app, diff --git a/src/modals/createPageOrRecordModal.ts b/src/modals/createPageOrRecordModal.ts index 65a9b35..13bff53 100644 --- a/src/modals/createPageOrRecordModal.ts +++ b/src/modals/createPageOrRecordModal.ts @@ -73,10 +73,10 @@ export async function createPageOrRecordModal( } if (parent) { - overFlowMenuText.push( + overFlowMenuText.unshift( NotionPageOrRecord.CHANGE_DATABASE_TEXT.toString() ); - overFlowMenuValue.push( + overFlowMenuValue.unshift( NotionPageOrRecord.CHANGE_DATABASE_ACTION.toString() ); }