Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple UI #16

Merged
merged 5 commits into from
May 11, 2018
Merged

Simple UI #16

merged 5 commits into from
May 11, 2018

Conversation

carlosms
Copy link
Contributor

@carlosms carlosms commented May 8, 2018

Part of #4.

localhost_3000_

This is a simple first version for the UI. A few notes:

  • To keep this PR smaller and focused on the frontend, the following part of the issue description will be done in a different PR:

take care of passing env var to fronted.
At this point, query should always add LIMIT N with N=100 defined though env var.

cd frontend
yarn start
  • In @dpordomingo's code he is assuming the new frontend code would live in /public. But I find it a bit strange, because the fronted actually has a sub-dir named public for some files. I this PR I propose /frontend, but this can be easily changed.
  • We discussed about adding redux to prepare for future increasing complexity. The current code is so simple that I preferred to go without it for now. I would suggest to add it once we add several result tabs. But if you think it should be included now in this PR or a new one, let's discuss it.
  • The styling is so minimalistic that there is none :D
  • I chose react-table for the results table. As you can see the code is quite simple and it can easily changed to any other option should we need to. Let me know if you are aware of any other better lib.
  • I didn't forget about the debug text area at the bottom. I left it because it can be quite useful at this stage of the project, and the code is very localized and easy to remove later.

@carlosms carlosms self-assigned this May 8, 2018
@carlosms carlosms requested review from smacker, dpordomingo and bzz May 8, 2018 14:17
@dpordomingo
Copy link
Contributor

I'll review the PR later, but I agree with your proposal @carlosms about storing the front sources under a new /frontend dir.
I'll prepare #15 considering it.

@@ -44,6 +44,13 @@ GROUP BY committer_email, month, repo_id`,
}

render() {
let ok;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow. why not

const ok = this.state.response && this.state.response.status === 200

?

try-catch isn't very javascript way to do such things.

or even better:

const { response } = this.state;
const ok = response && response.status === 200;

Copy link
Contributor

@smacker smacker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one comment above. In general ok.

Maybe I wouldn't include debug textarea in PR, you can easily see the response in dev tools. But up to you.

👍 for moving step by step. No need redux at this stage.

Signed-off-by: Carlos Martín <[email protected]>
@smacker
Copy link
Contributor

smacker commented May 8, 2018

btw do I understand right that you are going to implement proper layout, loading and error state in separate PRs? According to the issue, I would expect it.

@carlosms
Copy link
Contributor Author

carlosms commented May 9, 2018

@smacker:

btw do I understand right that you are going to implement proper layout, loading and error state in separate PRs? According to the issue, I would expect it.

Of course that's needed, but my understanding from the design doc is that issue #4 (alpha 1 milestone) would only include the most basic UI (as is in this PR), and those things you list would be added for alpha 2, new issues.

ping @bzz for clarification.

@smacker
Copy link
Contributor

smacker commented May 9, 2018

I would better go with simple but complete UI in alpha0. Like there are still only 2 blocks (input and table), but they fill the whole page in the wireframe. Error replaces table as in the wireframe and so on. But yeah. Up to @bzz.

@bzz
Copy link
Contributor

bzz commented May 9, 2018

For me, it would be totally fine to expect proper error placement and further enhancement of current components as part of the alpha2 as Carlos suggests, for the reason of getting a really minimal alpha1 faster to the staging env.

Copy link
Contributor

@bzz bzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bzz
Copy link
Contributor

bzz commented May 9, 2018

GUI looks great.

BTW if we already have table, may be we do not need to print JSON

@carlosms carlosms mentioned this pull request May 9, 2018
@dpordomingo dpordomingo mentioned this pull request May 9, 2018
4 tasks
Copy link
Contributor

@dpordomingo dpordomingo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow! I liked!! And it worked in my PC...

But since the goal of this PR was to start the structure, and we agreed on to try following cat one if possible, I have some doubts and some issues that imho should be addressed.

},
plugins: ['import', 'react', 'jest', 'prettier'],
rules: {
'prettier/prettier': 'error',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comparing with cat, why not adding?

'prettier/prettier': ['error', { singleQuote: true, trailingComma: 'es5' }],

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that replaces .prettierrc, it doesn't make sense to have both, so I removed it.

'import/no-unresolved': 0,
'import/extensions': 0,
'func-names': 0,
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I miss other rules from cat

'no-underscore-dangle': 0, // because of _super
'react/prop-types': 0,
'no-console': ['error', { allow: ['info', 'warn', 'error'] }], // later we will might need wrapper

why not adding them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see the conversation in https://github.com/src-d/company/pull/127

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't found agreement about 'no-console' conf; did you?
Are we accepting console things?
Why not using a wrapper as in CAT?

/node_modules

# testing
/coverage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really needed for the front? it's already in the main .gitignore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gitignore is the create-react-app default. If we see this dir as a kind of sub-project I think it makes sense to leave this .gitignore here for frontend-only files.

Plust the rules in the .gitignore in master do not apply here, instead of /node_modules it should be frontend/node_modules, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if the folder is like a "subproject"...

I use to like small .gitignore files... with as fewer rules as possible, so I like the idea of avoiding duplicities; anyhow this is more like an opinion, so if you do not share it, feel free to disregard it 🗡️

About node_modules rule:
if it should be in the main .gitignore it should be frontend/node_modules but since it makes sense to be in the frontend/.gitignore it needs to relative to the frontend dir.

/coverage

# production
/build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's not needed by the front... it's already in main .gitignore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's please keep the conversation in one thread, above.

/build

# misc
.DS_Store
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all this misc ones, with .DS_Store and .env.* are already in the main .gitignore

homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if we use the cat favicon instead of the react one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 3d57d81.

@@ -0,0 +1,15 @@
{
"short_name": "React App",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should use the gitbase-playground values 💃

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 3d57d81.

import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap/dist/css/bootstrap-theme.css';
import './override.less';
import './index.css';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we write only .less code, as in cat?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would skip this and merge as it is. All the machinery to write less is in place, this file can be changed at any moment when we start to write styles.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 3d57d81.

if (json.errors) {
throw json.errors;
}
return json;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the data will be always under a data field; why not returning it as done in cat?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, for this project we have data and meta.

@@ -0,0 +1,82 @@
function checkStatus(resp) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not moving this service into its own place?
In cat we used /api package, for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be the benefit of moving api.js to /api/index.js? I don't have a strong opinion on this, let me know why and we can move it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see two reasons;

first one is kindof opinionated: imo the root dir should be populated with as fewer things as possible because it helps to understand better the structure of the code.

second one is generic: now we have in this file the logic (copy-pasted from cat) to connect with the API (business agnostic), and also the "repository-like" code (business related). Splitting both parts properly, and moving business agnostic to a service, and the business logic to a repository would help us to reuse and test better.

Signed-off-by: Carlos Martín <[email protected]>
@carlosms
Copy link
Contributor Author

@dpordomingo please take another look when you have time.

dpordomingo
dpordomingo approved these changes May 11, 2018
Copy link
Contributor

@dpordomingo dpordomingo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

The only missing things I see are the following ones, that imho shouldn't block this merge since they could be addressed in further iterations.

Since you're the maintainer, let me know if I can/should open issues for any of them that you think we could consider in next iterations, and I'll happily do so to avoid forgetting it.

@carlosms
Copy link
Contributor Author

Thank you for your comments. I agree, those details can be discussed in new issues and changed later on without much difficulty. Please fell free to open any new issues.

Let's merge so we can move forward with the building and release tasks.

@carlosms carlosms merged commit 62b1756 into src-d:master May 11, 2018
@dpordomingo dpordomingo mentioned this pull request May 16, 2018
2 tasks
@dpordomingo
Copy link
Contributor

thanks!
issues created #28 and #29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants