// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import React from 'react'; import {Link} from 'react-router'; import {FormattedMessage} from 'react-intl'; import DeleteIntegration from './delete_integration.jsx'; export default class InstalledCommand extends React.Component { static get propTypes() { return { team: React.PropTypes.object.isRequired, command: React.PropTypes.object.isRequired, onRegenToken: React.PropTypes.func.isRequired, onDelete: React.PropTypes.func.isRequired, filter: React.PropTypes.string, creator: React.PropTypes.object.isRequired, canChange: React.PropTypes.bool.isRequired }; } constructor(props) { super(props); this.handleRegenToken = this.handleRegenToken.bind(this); this.handleDelete = this.handleDelete.bind(this); this.matchesFilter = this.matchesFilter.bind(this); } handleRegenToken(e) { e.preventDefault(); this.props.onRegenToken(this.props.command); } handleDelete() { this.props.onDelete(this.props.command); } matchesFilter(command, filter) { if (!filter) { return true; } return command.display_name.toLowerCase().indexOf(filter) !== -1 || command.description.toLowerCase().indexOf(filter) !== -1 || command.trigger.toLowerCase().indexOf(filter) !== -1; } render() { const command = this.props.command; const filter = this.props.filter ? this.props.filter.toLowerCase() : ''; if (!this.matchesFilter(command, filter)) { return null; } let name; if (command.display_name) { name = command.display_name; } else { name = ( ); } let description = null; if (command.description) { description = (
{command.description}
); } let trigger = '- /' + command.trigger; if (command.auto_complete && command.auto_complete_hint) { trigger += ' ' + command.auto_complete_hint; } let actions = null; if (this.props.canChange) { actions = (
{' - '} {' - '}
); } return (
{name} {trigger}
{description}
{actions}
); } }