gitpoint/git-point

Refactor and internationalize `IssueEventListItem`

Open

#795 aperta il 26 apr 2018

Vedi su GitHub
 (6 commenti) (1 reazione) (1 assegnatario)JavaScript (837 fork)batch import
good for beginnershelp wanted

Metriche repository

Star
 (4684 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

This component could benefit from a refactoring similar to EventsScreen, where every event type would be handled by a dedicated method.

Instead of the big switch/case in render(), we could have something like this:

render() {
    const { repository, event } = this.props;
    const handler = camelCase(`handle_${event.event}`); // lodash's camelCase

    if (typeof this[handler] === 'function') {
      return this[handler](event, repository);
    }

    return null;
}

and implement handleReviewRequested(), handleLabeled(), etc.

We would then wrap strings with utils.t() to internationalize this component.

Guida contributor