From 823d4c658ccb4f9c4bc8541c375c961836bab0a6 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Wed, 16 Mar 2022 16:07:49 -0300 Subject: [PATCH] Chore: Migrate methods/actions to Typescript and refactor UiKit folder (#3716) * Chore: Migrate methods/actions to Typescript * tweak in actions * Co-authored-by: Gleidson Daniel Silva * refactor sdk.current * interface and uikit done * refactor interface, index and utils from UiKit * minor tweak * minor tweak Co-authored-by: Gleidson Daniel Silva --- app/containers/UIKit/Actions.tsx | 19 +- app/containers/UIKit/Context.tsx | 14 +- app/containers/UIKit/DatePicker.tsx | 19 +- app/containers/UIKit/Image.tsx | 35 +-- app/containers/UIKit/Input.tsx | 11 +- app/containers/UIKit/Overflow.tsx | 35 +-- app/containers/UIKit/Section.tsx | 39 +-- app/containers/UIKit/index.tsx | 25 +- app/containers/UIKit/interfaces.ts | 273 +++++++++++++++++++++ app/containers/UIKit/utils.ts | 16 +- app/lib/methods/{actions.js => actions.ts} | 78 +++--- app/utils/events.ts | 4 +- app/utils/fetch.ts | 16 +- app/utils/fileUpload/index.ts | 3 +- app/views/ModalBlockView.tsx | 8 +- app/views/RoomView/index.tsx | 4 +- 16 files changed, 406 insertions(+), 193 deletions(-) create mode 100644 app/containers/UIKit/interfaces.ts rename app/lib/methods/{actions.js => actions.ts} (51%) diff --git a/app/containers/UIKit/Actions.tsx b/app/containers/UIKit/Actions.tsx index 1d5ba984..801e8d4a 100644 --- a/app/containers/UIKit/Actions.tsx +++ b/app/containers/UIKit/Actions.tsx @@ -3,25 +3,18 @@ import { BLOCK_CONTEXT } from '@rocket.chat/ui-kit'; import Button from '../Button'; import I18n from '../../i18n'; - -interface IActions { - blockId: string; - appId: string; - elements: any[]; - parser: any; - theme: string; -} +import { IActions } from './interfaces'; export const Actions = ({ blockId, appId, elements, parser, theme }: IActions) => { - const [showMoreVisible, setShowMoreVisible] = useState(() => elements.length > 5); - const renderedElements = showMoreVisible ? elements.slice(0, 5) : elements; + const [showMoreVisible, setShowMoreVisible] = useState(() => elements && elements.length > 5); + const renderedElements = showMoreVisible ? elements?.slice(0, 5) : elements; - const Elements = () => - renderedElements.map((element: any) => parser.renderActions({ blockId, appId, ...element }, BLOCK_CONTEXT.ACTION, parser)); + const Elements = () => ( + <>{renderedElements?.map(element => parser?.renderActions({ blockId, appId, ...element }, BLOCK_CONTEXT.ACTION, parser))} + ); return ( <> - {/* @ts-ignore*/} {showMoreVisible &&