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

chore: LayoutBlock #774

Merged
merged 4 commits into from
Jun 25, 2024
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
6 changes: 3 additions & 3 deletions deno-runtime/lib/accessors/builders/MessageBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Block } from '@rocket.chat/ui-kit';
import { LayoutBlock } from '@rocket.chat/ui-kit';

import type { IMessageBuilder } from '@rocket.chat/apps-engine/definition/accessors/IMessageBuilder.ts';
import type { RocketChatAssociationModel as _RocketChatAssociationModel } from '@rocket.chat/apps-engine/definition/metadata/RocketChatAssociations.ts';
Expand Down Expand Up @@ -184,7 +184,7 @@ export class MessageBuilder implements IMessageBuilder {
return this.msg;
}

public addBlocks(blocks: BlockBuilder | Array<IBlock | Block>) {
public addBlocks(blocks: BlockBuilder | Array<IBlock | LayoutBlock>) {
if (!Array.isArray(this.msg.blocks)) {
this.msg.blocks = [];
}
Expand All @@ -198,7 +198,7 @@ export class MessageBuilder implements IMessageBuilder {
return this as IMessageBuilder;
}

public setBlocks(blocks: BlockBuilder | Array<IBlock | Block>) {
public setBlocks(blocks: BlockBuilder | Array<IBlock | LayoutBlock>) {
if (blocks instanceof BlockBuilder) {
this.msg.blocks = blocks.getBlocks();
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/definition/accessors/IMessageBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Block } from '@rocket.chat/ui-kit';
import type { LayoutBlock } from '@rocket.chat/ui-kit';

import type { IMessage, IMessageAttachment } from '../messages';
import type { RocketChatAssociationModel } from '../metadata';
Expand Down Expand Up @@ -210,19 +210,19 @@ export interface IMessageBuilder {
* Adds a block collection to the message's
* own collection
*/
addBlocks(blocks: BlockBuilder | Array<IBlock | Block>): IMessageBuilder;
addBlocks(blocks: BlockBuilder | Array<IBlock | LayoutBlock>): IMessageBuilder;

/**
* Sets the block collection of the message
*
* @param blocks
*/
setBlocks(blocks: BlockBuilder | Array<IBlock | Block>): IMessageBuilder;
setBlocks(blocks: BlockBuilder | Array<IBlock | LayoutBlock>): IMessageBuilder;

/**
* Gets the block collection of the message
*/
getBlocks(): Array<IBlock | Block>;
getBlocks(): Array<IBlock | LayoutBlock>;

/**
* Adds a custom field to the message.
Expand Down
4 changes: 2 additions & 2 deletions src/definition/messages/IMessage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Block } from '@rocket.chat/ui-kit';
import type { LayoutBlock } from '@rocket.chat/ui-kit';

import type { IRoom } from '../rooms';
import type { IBlock } from '../uikit';
Expand Down Expand Up @@ -26,7 +26,7 @@ export interface IMessage {
groupable?: boolean;
parseUrls?: boolean;
customFields?: { [key: string]: any };
blocks?: Array<IBlock | Block>;
blocks?: Array<IBlock | LayoutBlock>;
starred?: Array<{ _id: string }>;
pinned?: boolean;
pinnedAt?: Date;
Expand Down
4 changes: 2 additions & 2 deletions src/definition/uikit/IUIKitSurface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Block, ButtonElement, TextObject } from '@rocket.chat/ui-kit';
import type { ButtonElement, LayoutBlock, TextObject } from '@rocket.chat/ui-kit';

import type { IBlock, IButtonElement, ITextObject } from './blocks';

Expand All @@ -13,7 +13,7 @@ export interface IUIKitSurface {
id: string;
type: UIKitSurfaceType;
title: ITextObject | TextObject;
blocks: Array<IBlock | Block>;
blocks: Array<IBlock | LayoutBlock>;
close?: IButtonElement | ButtonElement;
submit?: IButtonElement | ButtonElement;
state?: object;
Expand Down
6 changes: 3 additions & 3 deletions src/server/accessors/MessageBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Block } from '@rocket.chat/ui-kit';
import type { LayoutBlock } from '@rocket.chat/ui-kit';

import type { IMessageBuilder } from '../../definition/accessors';
import type { IMessage, IMessageAttachment } from '../../definition/messages';
Expand Down Expand Up @@ -177,7 +177,7 @@ export class MessageBuilder implements IMessageBuilder {
return this.msg;
}

public addBlocks(blocks: BlockBuilder | Array<IBlock | Block>) {
public addBlocks(blocks: BlockBuilder | Array<IBlock | LayoutBlock>) {
if (!Array.isArray(this.msg.blocks)) {
this.msg.blocks = [];
}
Expand All @@ -191,7 +191,7 @@ export class MessageBuilder implements IMessageBuilder {
return this;
}

public setBlocks(blocks: BlockBuilder | Array<IBlock | Block>) {
public setBlocks(blocks: BlockBuilder | Array<IBlock | LayoutBlock>) {
if (blocks instanceof BlockBuilder) {
this.msg.blocks = blocks.getBlocks();
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/server/messages/Message.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Block } from '@rocket.chat/ui-kit';
import type { LayoutBlock } from '@rocket.chat/ui-kit';

import type { IMessage, IMessageAttachment, IMessageFile, IMessageReactions } from '../../definition/messages';
import type { IUser, IUserLookup } from '../../definition/users';
Expand Down Expand Up @@ -40,7 +40,7 @@ export class Message implements IMessage {

public file?: IMessageFile;

public blocks?: Array<Block>;
public blocks?: Array<LayoutBlock>;

public starred?: Array<{ _id: string }>;

Expand Down
6 changes: 3 additions & 3 deletions src/server/misc/UIHelper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Block } from '@rocket.chat/ui-kit';
import type { LayoutBlock } from '@rocket.chat/ui-kit';
import { v4 as uuid } from 'uuid';

import type { IBlock } from '../../definition/uikit';
Expand All @@ -10,8 +10,8 @@ export class UIHelper {
* @param appId the appId that will be assigned to
* @returns the array of block with the ids properties assigned
*/
public static assignIds(blocks: Array<IBlock | Block>, appId: string): Array<IBlock | Block> {
blocks.forEach((block: (IBlock | Block) & { appId?: string; blockId?: string; elements?: Array<any> }) => {
public static assignIds(blocks: Array<IBlock | LayoutBlock>, appId: string): Array<IBlock | LayoutBlock> {
blocks.forEach((block: (IBlock | LayoutBlock) & { appId?: string; blockId?: string; elements?: Array<any> }) => {
if (!block.appId) {
block.appId = appId;
}
Expand Down
Loading