This repository was archived by the owner on Jul 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
[1572] Convert User Profile to React #1579
Open
esoterik
wants to merge
18
commits into
master
Choose a base branch
from
1572_user_profile_react
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
3490f20
add react_on_rails to gemfile
1bd70a0
Initial install of react-on-rails; many modifications. DELETE hello w…
da93054
add ActiveRecordSerializers
c1c4f4e
init of user profile react; does not work yet
9c81490
working but rough
7f77adb
works a bit better, does not save updates yet, but things are more or…
62135ab
working form
518afaa
appearance improvements + TOS
9771f36
delete helloworld
74ad922
remove the rest of the hello world
d158cbf
cleanup
99c22ef
clean up + rubocop and hound config
ca64cfd
remove old table
9672dd7
move user reservation counts to react
5f35b5b
remove hound config
880b6eb
attempt to fix travis
1377f77
minor refactoring
3bda0b7
more refactoring
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
web: rails s | ||
client: sh -c 'rm app/assets/webpack/* || true && cd client && npm run build:development' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
//= require webpack-bundle | ||
|
||
//= require jquery | ||
//= require jquery_ujs | ||
//= require datatables.min.js | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class UserSerializer < ActiveModel::Serializer | ||
attributes :id, :email, :first_name, :last_name, :nickname, :phone, | ||
:affiliation, :terms_of_service_accepted, :role, | ||
:reservation_counts | ||
|
||
def reservation_counts | ||
res = object.reservations | ||
counts = { checked_out: res.checked_out.count, | ||
overdue: res.overdue.count, | ||
future: res.reserved.count, | ||
past: res.returned.count, | ||
past_overdue: res.returned_overdue.count } | ||
counts[:missed] = res.missed.count unless AppConfig.check(:res_exp_time) | ||
counts | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,50 +25,7 @@ | |
</div> | ||
|
||
|
||
<div class="row"> | ||
|
||
<dl id="user_info" class="dl-horizontal col-md-6"> | ||
<div class="well"> | ||
<% if @cas_auth %> | ||
<dt>Username</dt> | ||
<dd><%= @user.username %></dd> | ||
<% end %> | ||
|
||
<dt>First Name</dt> | ||
<dd><%= @user.first_name %></dd> | ||
|
||
<dt>Last Name</dt> | ||
<dd><%= @user.last_name %></dd> | ||
|
||
<dt>Nickname</dt> | ||
<dd><%= [email protected]? ? @user.nickname : "(none)" %></dd> | ||
|
||
<dt>Phone</dt> | ||
<dd><%= [email protected]? ? @user.phone : "(none)" %></dd> | ||
|
||
<dt>Email</dt> | ||
<dd><%= mail_to @user.email, @user.email %></dd> | ||
|
||
<dt>Affiliation</dt> | ||
<dd><%= @user.affiliation %></dd> | ||
</div> | ||
</dl> | ||
|
||
<div id="user_stats" class="col-md-6"> | ||
|
||
<%# @show_equipment has reservation status (:overdue, ...) as key, full | ||
reservations in question as value %> | ||
<% @show_equipment.each do |status, reservations| %> | ||
<%= content_tag :div, :id => "#{status}_count", :class => 'col-md-6' do %> | ||
<%= content_tag :h4, status.to_s.titleize %> | ||
<%= content_tag :div, :class => "#{status}_num" do %> | ||
<%= content_tag :i, nil, :class => stats_icons(status) %> | ||
<%= reservations.size %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
</div> | ||
<%= react_component('UserProfile', props: @props) %> | ||
|
||
<%# TODO: Make this prettier %> | ||
<% unless @user.requirements.empty? %> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["es2015", "stage-0", "react"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Client folder generated by the React on Rails gem. | ||
|
||
See documentation [at github.com/shakacode/react_on_rails](https://github.com/shakacode/react_on_rails) for details on how it is organized. | ||
|
||
If you need additional help, please consider: | ||
|
||
* [Our ShakaCode Forum for React on Rails](https://forum.shakacode.com/c/rails/reactonrails). | ||
* Joining our Slack discussion room by [email us a bit about you and your project](mailto:[email protected]). | ||
* [Hiring us](https://forum.shakacode.com/c/rails/reactonrails) for coaching and custom web application development for your project. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// This file is our manifest of all reducers for the app. | ||
import userReducer from './user/userReducer'; | ||
import { $$initialState as $$userState } from './user/userReducer'; | ||
|
||
export default { | ||
$$userStore: userReducer, | ||
}; | ||
|
||
export const initialStates = { | ||
$$userState, | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import ReactOnRails from 'react-on-rails'; | ||
|
||
import UserProfile from './user/UserProfile'; | ||
|
||
ReactOnRails.register({ | ||
UserProfile, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react'; | ||
import { createStore } from 'redux'; | ||
import { Provider } from 'react-redux'; | ||
import User from './userContainer'; | ||
import userReducer from './userReducer'; | ||
|
||
|
||
export default (props, _railsContext) => { | ||
const store = createStore(userReducer); | ||
if (store.getState().user === null) { | ||
store.dispatch({ | ||
type: 'SET_USER', | ||
user: props | ||
}); | ||
} | ||
|
||
const reactComponent = ( | ||
<Provider store={store}> | ||
<User /> | ||
</Provider> | ||
); | ||
return reactComponent; | ||
}; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to
createStore(userReducer, user: props.user);
and get rid of the if statement on lines 10-15There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also should probably think about moving the store creation to a separate file