export default()

in source/frontend/src/API/NodeFactory/NodeParsers/CustomerManagedPolicyStatement/Statement/StatementItem.js [30:75]


export default ({ statement }) => {

  const resources = R.split(',', removeBrackets(statement.resources))
  const actions = R.split(',', removeBrackets(statement.actions))
  const warningActions = (action) => action.includes('*');
  const badActions = (action) => action === '*';

  

  const capitalize = (str) =>
    str.replace(/\w\S*/g, function(txt) {
      return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
    });

  const getEffect = (effect) =>
    R.equals(effect, 'Allow') ? 'success' : 'error';

  const processActions = (actions) =>
    R.reduce(
      (acc, val) => {
        if (badActions(val)) acc.push('error');
        if (warningActions(val)) acc.push('warning');
        return acc;
      },
      [],
      actions
    );

  const getOverview = (items) => {
    const processedActions = processActions(items);
    if (R.includes('error', processedActions)) return 'error';
    if (R.includes('warning', processedActions)) return 'warning';
    else return 'success';
  };

  const getDescription = (items) => {
    const processedActions = processActions(items);
    if (R.includes('error', processedActions)) return 'Only wildcards used.';
    if (R.includes('warning', processedActions)) return 'Wildcards used.';
    else return 'Good';
  };

  const mapIndexed = R.addIndex(R.map);

  return (
    <Container header={<Header variant='h2'>IAM Policy Statement</Header>}>