import { Component } from 'react';

import DangerLink    from '../application/danger_link.component';
import ProposalBadge from '../proposals/proposal_badge.component';
import ProposalLevelSelector from './proposal_level_selector.component';

export default class ActionPlanProposalsTable extends Component {
  render() {
    const { actionPlansProposals } = this.props;

    return (
      <table className="proposals-table">
        <thead>
          <tr>
            <td></td>
            <td></td>
            <td>{I18n.t("components.action_plan_proposals.acceptation_grade")}</td>
            <td></td>
            <td></td>
          </tr>
        </thead>
        <tbody>
          {
            actionPlansProposals.sort((a, b) => b.proposal.total_votes - a.proposal.total_votes).map(actionPlansProposal => {
              let proposal = actionPlansProposal.proposal;
              return (
                <tr key={proposal.id}>
                <td>
                    <ProposalBadge proposal={proposal} />
                </td>
                <td>
                    {proposal.code} - <a href={proposal.url} target="_blank">{proposal.title}</a>
                    <div>{proposal.summary}</div>
                </td>
                <td className="selector">
                  <ProposalLevelSelector
                    onChangeLevel={ (level) => this.props.onChangeLevel(proposal, level) }
                    selectedValue={ actionPlansProposal.level }
                  />
                </td>
                <td className="proposal-stats">
                    {I18n.t("components.action_plan_proposals.votes", { votes: proposal.total_votes})}
                    <br />
                    {I18n.t("components.action_plan_proposals.comments", { comments: proposal.total_comments})}
                </td>
                {this.renderRemoveButton(proposal)}
                </tr>
              )
              })
          }
        </tbody>
      </table>
    );
  }

  renderRemoveButton(proposal) {
    if (this.props.onRemoveProposal) {
      return (
        <td>
          <DangerLink onClick={(event) => this.props.onRemoveProposal(proposal) }>
            {I18n.t("components.proposals_table.remove")}
          </DangerLink>
        </td>
      );
    }
    return null;
  }
}

@@ -499,92 +499,8 @@
 td%3E%0A
-            %3Ctd%3E%7BI18n.t(%22components.action_plan_proposals.acceptation_grade%22)%7D%3C/td%3E%0A
     
@@ -1143,289 +1143,8 @@
 td%3E%0A
-                %3Ctd className=%22selector%22%3E%0A                  %3CProposalLevelSelector%0A                    onChangeLevel=%7B (level) =%3E this.props.onChangeLevel(proposal, level) %7D%0A                    selectedValue=%7B actionPlansProposal.level %7D%0A                  /%3E%0A                %3C/td%3E%0A
     

Remove integration level selector