59 lines
1.4 KiB
JavaScript
Raw Normal View History

2017-11-30 18:07:30 +01:00
/**
*
* BoundRoute
*
*/
import React from 'react';
2017-12-07 16:53:30 +01:00
import { get, includes, map, tail, toLower } from 'lodash';
2017-11-30 18:07:30 +01:00
import { FormattedMessage } from 'react-intl';
import PropTypes from 'prop-types';
2017-12-07 16:53:30 +01:00
import cn from 'classnames';
2017-11-30 18:07:30 +01:00
import styles from './styles.scss';
function BoundRoute({ route }) {
const title = get(route, 'handler');
const formattedRoute = get(route, 'path') ? tail(get(route, 'path').split('/')) : [];
const [ controller = '', action = '' ] = title ? title.split('.') : [];
return (
<div className="col-md-12">
<div className={styles.title}>
<FormattedMessage id="users-permissions.BoundRoute.title" />
&nbsp;
<span>{controller}</span>
<span>.{action} </span>
</div>
<div className={styles.boundRoute}>
2017-12-07 16:53:30 +01:00
<div className={cn(styles.verb, styles[toLower(get(route, 'method'))])}>
2017-11-30 18:07:30 +01:00
{get(route, 'method')}
</div>
<div className={styles.path}>
{map(formattedRoute, value => (
<span
key={value}
style={includes(value, ':') ? { color: '#787E8F' } : {}}
>
/{value}
</span>
))}
</div>
</div>
</div>
);
}
BoundRoute.defaultProps = {
route: {
handler: 'Nocontroller.error',
method: 'GET',
path: '/there-is-no-path',
},
};
BoundRoute.propTypes = {
route: PropTypes.object,
};
export default BoundRoute;