thegazelle-ad / gazelle-server

Server for front-end and editor tools of The Gazelle
MIT License
19 stars 8 forks source link

Refactor Alert Messages #374

Open frederikbrinck opened 6 years ago

frederikbrinck commented 6 years ago

@emilgoldsmith I'm not sure if you want this, but going over the different controllers, it seems that it would be nice to factor out all the user feedback messages to a common list. This would compile every feedback message in one place and allow for easy editing and, in case needed, language change. It will also make the controllers source code more readable.

emilgoldsmith commented 6 years ago

Hmm I think I need a more concrete explanation of this to understand exactly what you mean.

Language change should never be relevant though (except for maybe in the distant future where it could very theoretically become a fully fledged open source framework for newspapers)

frederikbrinck commented 6 years ago

I.e. have a file called message.json /.js which contains all the messages used throughout the code base, such as

{
  adminNoAuthorsOnArticle: "You have not added any authors to ... ",
  ...
}

And then it can be called with

import messagesObject from '...messages.js';
//...
if (error) this.props.alertDisplay(messagesObject.adminNoAuthorsOnArticles);

or something similar.

emilgoldsmith commented 6 years ago

Yeah sure, I wouldn't mind that, definitely good practice.

Don't think it's very high priority though, but it's definitely good practice