gitpoint/git-point

Refactor and internationalize `IssueEventListItem`

Open

#795 aberto em 26 de abr. de 2018

Ver no GitHub
 (6 comments) (1 reaction) (1 assignee)JavaScript (837 forks)batch import
good for beginnershelp wanted

Métricas do repositório

Stars
 (4.684 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

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.

Guia do colaborador