Files
mattermost-mobile/app/components/message_attachments/attachment_actions.js
Elias Nahum 0c42c0d976 Deps update (#3806)
* Dependecy updates

* Update dependencies
2020-01-20 13:22:07 -03:00

67 lines
1.8 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import ActionMenu from './action_menu';
import ActionButton from './action_button';
export default class AttachmentActions extends PureComponent {
static propTypes = {
actions: PropTypes.array,
postId: PropTypes.string.isRequired,
};
render() {
const {
actions,
postId,
} = this.props;
if (!actions?.length) {
return null;
}
const content = [];
actions.forEach((action) => {
if (!action.id || !action.name) {
return;
}
switch (action.type) {
case 'select':
content.push(
<ActionMenu
key={action.id}
id={action.id}
name={action.name}
dataSource={action.data_source}
defaultOption={action.default_option}
options={action.options}
postId={postId}
disabled={action.disabled}
/>,
);
break;
case 'button':
default:
content.push(
<ActionButton
key={action.id}
id={action.id}
cookie={action.cookie}
name={action.name}
postId={postId}
disabled={action.disabled}
/>,
);
break;
}
});
return content;
}
}