0

I have this material-ui ListItemText:

<ListItemText primary={<div>
  <Table className={classes.table}>
    <TableRow>
      <TableCell width="40">{item.issue_state}</TableCell>
      <TableCell width="40">{item.issue_number}</TableCell>
      <TableCell width="600">{item.issue_title}</TableCell>
      <TableCell width="600">{item.issue_url}</TableCell>
    </TableRow>
  </Table>
</div>}/>

Rather than displaying the URL, I'd like to have something like this:

if (item.issue_url.includes("github.com") {
  item.issue_url = 'Public'
}
else if (item.issue_url.includes("github.company.com") {
  item.issue_url = 'Private'
}

where the TableCell displays Public of Private rather than the whole URL. Can this be done?

2 Answers 2

1

you could use as below,

<ListItemText primary={<div>
  <Table className={classes.table}>
    <TableRow>
      <TableCell width="40">{item.issue_state}</TableCell>
      <TableCell width="40">{item.issue_number}</TableCell>
      <TableCell width="600">{item.issue_title}</TableCell>
      <TableCell width="600">{
            (item.issue_url.indexOf('github.company.com') >=0)
            ? 'Private' 
            : ((item.issue._url.indexOf('github.com') >=0) 
              ? 'Public'
              : '')
      }</TableCell>
    </TableRow>
  </Table>
</div>}/>

Otherwise, good idea is to create a derived property in item based on issue_url

Sign up to request clarification or add additional context in comments.

Comments

0

Do something like this:

<ListItemText primary={<div>
  <Table className={classes.table}>
    <TableRow>
      <TableCell width="40">{item.issue_state}</TableCell>
      <TableCell width="40">{item.issue_number}</TableCell>
      <TableCell width="600">{item.issue_title}</TableCell>
      <TableCell width="600">{item.issue_url.includes("github.company.com") ? 'Private' : 'Public' }</TableCell>
    </TableRow>
  </Table>
</div>}/>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.