mattermost-mobile/app/components/embedded_bindings/embedded_sub_bindings.tsx
Daniel Espino García f8e67c04ad
Migrate message attachments to typescript (#5127)
* Migrate attachment_image

* Migrate action_menu

* Migrate action_button

* migrate message_attachments

* Remove unintended commited file

* Fix tsc

* Fix tsc

* Fix lint

* Update references

* Make emoji functional component and fix imports

* Use ReactNode instead of JSXElement

* Convert action menu to FC

* Remove unneeded fragments

* Remove unneded undefined check

* Use undefined instead of nil in calculateDimensions

* Make sure height is always defined

* Use is valid URL

* Add missing types

* Lint fixes and remove lodash

* Revert package.json changes

* Put back fragments since they are actually needed

* Fix test

* Fix lint

* Address feedback
2021-04-22 18:21:44 -04:00

52 lines
1.2 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import BindingMenu from './menu_binding';
import ButtonBinding from './button_binding';
import {AppBinding} from '@mm-redux/types/apps';
type Props = {
bindings?: AppBinding[];
postId: string;
}
export default function EmbeddedSubBindings(props: Props) {
const {
bindings,
postId,
} = props;
if (!bindings?.length) {
return null;
}
const content = [] as React.ReactNode[];
bindings.forEach((binding) => {
if (!binding.app_id || !binding.call) {
return;
}
if ((binding.bindings?.length || 0) > 0) {
content.push(
<BindingMenu
key={binding.location}
binding={binding}
postId={postId}
/>,
);
return;
}
content.push(
<ButtonBinding
key={binding.location}
binding={binding}
postId={postId}
/>,
);
});
return content.length ? (<>{content}</>) : null;
}