-
Notifications
You must be signed in to change notification settings - Fork 20
User curation page improvements #1259
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
Open
fbacall
wants to merge
3
commits into
master
Choose a base branch
from
faster-user-curation-page
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 all commits
Commits
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 hidden or 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 hidden or 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,36 @@ | ||
| const Curation = { | ||
| applyParam: function (select, param) { | ||
| const value = select.value; | ||
| const url = new URL(window.location.href); | ||
| if (!value) { | ||
| url.searchParams.delete(param); | ||
| } else { | ||
| url.searchParams.set(param, value); | ||
| } | ||
| window.location.replace(url.toString()); | ||
| }, | ||
|
|
||
| curateUser: function (e) { | ||
| e.preventDefault(); | ||
| const url = $(this).parents('.curate-user-buttons').data('actionUrl'); | ||
| const panel = $(this).parents('.curate-user'); | ||
| panel.fadeOut('fast'); | ||
|
|
||
| $.ajax({ | ||
| url: url, | ||
| method: 'PUT', | ||
| dataType: 'script', | ||
| data: { user: { role_id: $(this).data('roleId') } } | ||
| }).fail(function (e) { | ||
| panel.show(); | ||
| console.error(e); | ||
| alert('An error occurred while attempting to curate the user.'); | ||
| }); | ||
|
|
||
| return false; | ||
| }, | ||
|
|
||
| init: function () { | ||
| $('.curate-user-buttons .btn').click(Curation.curateUser); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,132 +1,128 @@ | ||
| <% filter_params = {} %> | ||
| <% filter_params[:role] = params[:role] if params.key?(:role) %> | ||
| <% filter_params[:with_content] = params[:with_content] if params.key?(:with_content) %> | ||
| <% filter_params[:max_age] = params[:max_age] if params.key?(:max_age) %> | ||
|
|
||
| <div class="page-header"> | ||
| <h2> | ||
| <% if current_user.is_admin? %> | ||
| <div class="pull-right form-inline"> | ||
| <select id="role_id" onchange="window.location = '<%= url_for(filter_params.merge(role: '_ROLE_')) -%>'.replace('_ROLE_', $(this).val());" autocomplete="off" class="form-control" style="width: 15em"> | ||
| <%= role_options(@role) %> | ||
| </select> | ||
| <div class="checkbox btn btn-default<%= ' active' if params[:with_content] -%>" title="Only show users who have created content."> | ||
| <%= label_tag do %> | ||
| <%= check_box_tag :with_content, true, params[:with_content], autocomplete: 'off', | ||
| data: { url: url_for(params[:with_content] ? filter_params.except(:with_content) : filter_params.merge({ with_content: true })) }, | ||
| onchange: "window.location = $(this).data('url');" %> | ||
| with content? | ||
| <% end %> | ||
| <h2><%= t('curation.users.title') %></h2> | ||
|
|
||
| <div class="form-inline"> | ||
| <% if current_user.is_admin? %> | ||
| <div class="form-group"> | ||
| <%= label_tag('role_id', t('curation.users.filters.with_role.title')) %> | ||
| <%= select_tag('role_id', role_options(@role), | ||
| onchange: "Curation.applyParam(this, 'role')", | ||
| title: t('curation.users.filters.with_role.hint'), | ||
| autocomplete: 'off', class: 'form-control') %> | ||
| </div> | ||
| <% end %> | ||
|
|
||
| <div class="form-group"> | ||
| <%= label_tag('max_age', t('curation.users.filters.max_age.title')) %> | ||
| <%= select_tag('max_age', max_age_options(filter_params[:max_age]), | ||
| onchange: "Curation.applyParam(this, 'max_age')", | ||
| title: t('curation.users.filters.max_age.hint'), | ||
| autocomplete: 'off', class: 'form-control') %> | ||
| </div> | ||
| <% end %> | ||
| Curate Users | ||
| </h2> | ||
|
|
||
| <div class="checkbox btn btn-default<%= ' active' if params[:with_content] -%>" title="<%= t('curation.users.filters.with_content.hint') %>"> | ||
| <%= label_tag do %> | ||
| <%= check_box_tag :with_content, true, params[:with_content], autocomplete: 'off', | ||
| data: { url: url_for(params[:with_content] ? filter_params.except(:with_content) : filter_params.merge({ with_content: true })) }, | ||
| onchange: "window.location = $(this).data('url');" %> | ||
| <%= t('curation.users.filters.with_content.title') %> | ||
| <% end %> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div class="col-sm-4 col-sm-push-8"> | ||
| <div class="panel panel-default" id="recent-user-curation-activity"> | ||
| <div class="panel-heading">Recent Curation Activity</div> | ||
| <div class="panel-body"> | ||
| <% activities = recent_approvals %> | ||
| <% if activities.any? %> | ||
| <ul class="recent-approvals"> | ||
| <% activities.each do |activity| %> | ||
| <li> | ||
| <strong><%= link_to activity.trackable.name, activity.trackable, target: '_blank' -%></strong> was | ||
| <%= approval_message(activity.parameters[:new]) -%> by <%= activity.owner.try(:username) -%> | ||
| <%= time_ago_in_words(activity.created_at) -%> ago. | ||
| </li> | ||
| <% end %> | ||
| </ul> | ||
| <% else %> | ||
| <span class="muted">No recent approvals/rejections.</span> | ||
| <% end %> | ||
| <div class="row"> | ||
| <div class="col-sm-4 col-sm-push-8"> | ||
| <div class="panel panel-default" id="recent-user-curation-activity"> | ||
| <div class="panel-heading"><%= t('curation.users.recent_activity.title') %></div> | ||
| <div class="panel-body"> | ||
| <% activities = recent_approvals %> | ||
| <% if activities.any? %> | ||
| <ul class="recent-approvals"> | ||
| <% activities.each do |activity| %> | ||
| <li> | ||
| <strong><%= link_to activity.trackable.name, activity.trackable, target: '_blank' -%></strong> - | ||
| <%= approval_message(activity.parameters[:new]) -%> | ||
| <%= t('curation.users.activity.info', | ||
| curator: activity.owner.try(:username), | ||
| time: time_ago_in_words(activity.created_at)) -%> | ||
| </li> | ||
| <% end %> | ||
| </ul> | ||
| <% else %> | ||
| <span class="muted"><%= t('curation.users.recent_activity.empty') %></span> | ||
| <% end %> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div class="col-sm-8 col-sm-pull-4"> | ||
| <% if @users.any? %> | ||
| <% @users.each do |user| %> | ||
| <div class="panel panel-default curate-user"> | ||
| <div class="panel-heading"> | ||
| <%= link_to user.name, user, target: '_blank' %> | ||
| <div class="col-sm-8 col-sm-pull-4"> | ||
| <% if @users.any? %> | ||
| <% @users.each do |user| %> | ||
| <div class="panel panel-default curate-user"> | ||
| <div class="panel-heading"> | ||
| <%= link_to user.name, user, target: '_blank' %> | ||
|
|
||
| <% if user.banned? %> | ||
| <span class="text-danger">(<%= user.shadowbanned? ? 'shadowbanned' : 'banned'-%>)</span> | ||
| <% end %> | ||
| <% if user.banned? %> | ||
| <span class="text-danger">(<%= user.shadowbanned? ? 'shadowbanned' : 'banned'-%>)</span> | ||
| <% end %> | ||
|
|
||
| <div class="pull-right curate-user-buttons" data-action-url="<%= user_path(user) -%>"> | ||
| <%= link_to('Approve', '#', class: 'btn btn-xs btn-success', 'data-role-id' => Role.approved.id ) %> | ||
| <%= link_to('Reject', '#', class: 'btn btn-xs btn-danger', 'data-role-id' => Role.rejected.id ) %> | ||
| <div class="pull-right curate-user-buttons" data-action-url="<%= user_path(user) -%>"> | ||
| <%= link_to('Approve', '#', class: 'btn btn-xs btn-success', 'data-role-id' => Role.approved.id ) %> | ||
| <%= link_to('Reject', '#', class: 'btn btn-xs btn-danger', 'data-role-id' => Role.rejected.id ) %> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <div class="panel-body"> | ||
| <i>Registered <%= time_ago_in_words(user.created_at) -%> ago</i><br/> | ||
| <div class="panel-body"> | ||
| <i><%= t('curation.users.list.registered_time', time: time_ago_in_words(user.created_at)) -%></i><br/> | ||
|
|
||
| <strong>Public email:</strong> | ||
| <% if user.profile.email.blank? %> | ||
| <span class="empty">None specified</span> | ||
| <% else %> | ||
| <%= mail_to user.profile.email %> | ||
| <% end %><br/> | ||
| <strong><%= Profile.human_attribute_name(:email) %>:</strong> | ||
| <% if user.profile.email.blank? %> | ||
| <span class="empty"><%= t('curation.users.list.blank_attribute') %></span> | ||
| <% else %> | ||
| <%= mail_to user.profile.email %> | ||
| <% end %><br/> | ||
|
|
||
| <strong><%= User.human_attribute_name(:website) %>:</strong> | ||
| <% if user.profile.website.blank? %> | ||
| <span class="empty">None specified</span> | ||
| <% else %> | ||
| <%= link_to user.profile.website, user.profile.website, rel: 'nofollow' %> | ||
| <% end %><br/> | ||
| <strong><%= User.human_attribute_name(:website) %>:</strong> | ||
| <% if user.profile.website.blank? %> | ||
| <span class="empty"><%= t('curation.users.list.blank_attribute') %></span> | ||
| <% else %> | ||
| <%= link_to user.profile.website, user.profile.website, rel: 'nofollow' %> | ||
| <% end %><br/> | ||
|
|
||
| <% User::CREATED_RESOURCE_TYPES.each do |type| %> | ||
| <% count = user.send(type).count %> | ||
| <% if count > 0 %> | ||
| <% resources = user.send(type).order(created_at: :desc).first(3) %> | ||
| <strong><%= resources.first.class.model_name.human -%></strong> | ||
| <ul> | ||
| <% resources.each do |resource| %> | ||
| <li> | ||
| <%= link_to resource.title, resource, target: '_blank' %> | ||
| <% if resource.respond_to?(:url) %> | ||
| <br/> | ||
| URL: <%= link_to resource.url, resource.url, target: '_blank', rel: 'nofollow noreferrer noopener' -%> | ||
| <% end %> | ||
| </li> | ||
| <% User::CREATED_RESOURCE_TYPES.each do |type| %> | ||
| <% count = user.send(type).count %> | ||
| <% if count > 0 %> | ||
| <% resources = user.send(type).order(created_at: :desc).first(3) %> | ||
| <strong><%= resources.first.class.model_name.human -%></strong> | ||
| <ul> | ||
| <% resources.each do |resource| %> | ||
| <li> | ||
| <%= link_to resource.title, resource, target: '_blank' %> | ||
| <% if resource.respond_to?(:url) %> | ||
| <br/> | ||
| URL: <%= link_to resource.url, resource.url, target: '_blank', rel: 'nofollow noreferrer noopener' -%> | ||
| <% end %> | ||
| </li> | ||
| <% end %> | ||
| </ul> | ||
| <% if count > 3 %> | ||
| <%= link_to "See all #{pluralize(count, resources.first.class.model_name.human)}", | ||
| polymorphic_path(type, user: user.username), target: '_blank' -%><br/> | ||
| <% end %> | ||
| </ul> | ||
| <% if count > 3 %> | ||
| <%= link_to "See all #{pluralize(count, resources.first.class.model_name.human)}", | ||
| polymorphic_path(type, user: user.username), target: '_blank' -%><br/> | ||
| <% end %> | ||
| <% end %> | ||
| <% end %> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <% end %> | ||
| <% end %> | ||
|
|
||
| <%= render partial: 'search/common/pagination_bar', locals: { resources: @users } %> | ||
| <% else %> | ||
| Could not find any <%= @role.title.downcase.pluralize-%> requiring approval. Another curator may have already taken action. | ||
| <% end %> | ||
| <%= render partial: 'search/common/pagination_bar', locals: { resources: @users } %> | ||
| <% else %> | ||
| <%= t('curation.users.list.empty', role: @role.title.downcase.pluralize)-%> | ||
| <% end %> | ||
| </div> | ||
| </div> | ||
|
|
||
| <script> | ||
| $('.curate-user-buttons .btn').click(function () { | ||
| var url = $(this).parents('.curate-user-buttons').data('actionUrl'); | ||
| var panel = $(this).parents('.curate-user'); | ||
|
|
||
| $.ajax({ | ||
| url: url, | ||
| method: 'PUT', | ||
| dataType: 'script', | ||
| data: { user: { role_id: $(this).data('roleId') } } | ||
| }).done(function () { | ||
| panel.fadeOut(); | ||
| }).fail(function (e) { | ||
| console.log(e); | ||
| alert('An error occurred while attempting to curate the user.'); | ||
| }); | ||
|
|
||
| return false; | ||
| }); | ||
| </script> |
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.