Skip to content
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
2 changes: 2 additions & 0 deletions enum/modals/NotionDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ export enum DatabaseModal {
PROPERTY_TYPE_TITLE = "title",
OVERFLOW_MENU_ACTION = "create-notion-database-overflow-menu-action-id",
OVERFLOW_MENU_TEXT = "Create Database",
OVERFLOW_CHANGE_WORKSPACE_ACTION = "change-notion-workspace-overflow-menu-action-id",
OVERFLOW_CHANGE_WORKSPACE_TEXT = "Change Workspace"
}
2 changes: 2 additions & 0 deletions enum/modals/NotionPageOrRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ export enum NotionPageOrRecord {
CHANGE_DATABASE_TEXT = "Change Database",
CHANGE_DATABASE_ACTION = "create-page-or-record-change-database-action-id",
PROPERTY_SELECTED_BLOCK_ELEMENT = "property-selected-element-create-page-or-record-block-id",
OVERFLOW_CHANGE_TO_PAGE_ACTION = "create-notion-page-overflow-menu-action-id",
OVERFLOW_CHANGE_TO_PAGE_TEXT = "Create Page or Record",
}
13 changes: 13 additions & 0 deletions src/handlers/ExecuteBlockActionHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,9 @@ 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(),
NotionPageOrRecord.CHANGE_DATABASE_ACTION.toString(),
NotionPageOrRecord.OVERFLOW_CHANGE_TO_PAGE_ACTION.toString()
];

if (!OverFlowActions.includes(value)) {
Expand Down Expand Up @@ -834,6 +836,17 @@ export class ExecuteBlockActionHandler {
await handler.createNotionDatabase();
break;
}

case DatabaseModal.OVERFLOW_CHANGE_WORKSPACE_ACTION:{
await handler.changeNotionWorkspace();
break;
}

case NotionPageOrRecord.OVERFLOW_CHANGE_TO_PAGE_ACTION:{
await handler.createNotionPageOrRecord();
break;
}

case NotionPageOrRecord.CHANGE_DATABASE_ACTION: {
await handler.createNotionPageOrRecord(true);
break;
Expand Down
24 changes: 24 additions & 0 deletions src/modals/createDatabaseModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { searchPageComponent } from "./common/searchPageComponent";
import { NotionApp } from "../../NotionApp";
import { inputElementComponent } from "./common/inputElementComponent";
import { ButtonInSectionComponent } from "./common/buttonInSectionComponent";
import { OverflowMenuComponent } from "./common/OverflowMenuComponent";
import { IUser } from "@rocket.chat/apps-engine/definition/users";
import { ModalInteractionStorage } from "../storage/ModalInteraction";
import { ITokenInfo } from "../../definition/authorization/IOAuth2Storage";
Expand All @@ -35,6 +36,7 @@ import {
import { NotionObjectTypes } from "../../enum/Notion";
import { ButtonInActionComponent } from "./common/buttonInActionComponent";
import { SearchPage } from "../../enum/modals/common/SearchPageComponent";
import { NotionPageOrRecord } from "../../enum/modals/NotionPageOrRecord";

export async function createDatabaseModal(
app: NotionApp,
Expand All @@ -49,6 +51,14 @@ export async function createDatabaseModal(
const { elementBuilder, blockBuilder } = app.getUtils();
const divider = blockBuilder.createDividerBlock();
const connectBlock = getConnectPreview(app.getID(), tokenInfo);
const overFlowMenuText = [
NotionPageOrRecord.OVERFLOW_CHANGE_TO_PAGE_TEXT.toString(),
DatabaseModal.OVERFLOW_CHANGE_WORKSPACE_TEXT.toString(),
];
const overFlowMenuValue = [
NotionPageOrRecord.OVERFLOW_CHANGE_TO_PAGE_ACTION.toString(),
DatabaseModal.OVERFLOW_CHANGE_WORKSPACE_ACTION.toString(),
];

const searchForPageComponent = await searchPageComponent(
app,
Expand All @@ -61,6 +71,19 @@ export async function createDatabaseModal(
return searchForPageComponent;
}

const overflowMenu = await OverflowMenuComponent(
{
app,
text: overFlowMenuText,
value: overFlowMenuValue,
},
{
blockId: Modals.OVERFLOW_MENU_BLOCK,
actionId: Modals.OVERFLOW_MENU_ACTION,
}
);


const titleOfDatabaseBlock = inputElementComponent(
{
app,
Expand Down Expand Up @@ -99,6 +122,7 @@ export async function createDatabaseModal(
}
);
const blocks: Block[] = [
overflowMenu,
connectBlock,
searchForPageComponent,
titleOfDatabaseBlock,
Expand Down