Skip to content

Commit

Permalink
change activity feed to a table
Browse files Browse the repository at this point in the history
  • Loading branch information
Floppy committed Sep 4, 2024
1 parent d616164 commit ec818f3
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 80 deletions.
52 changes: 24 additions & 28 deletions app/views/activities/_create_actor.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,28 @@
<%- object = activity&.entity %>
<%- thing = object&.entity %>
<% if thing && !thing.is_a?(User) && (thing.grants_permission_to?(["view", "edit", "own"], current_user) || thing.grants_permission_to?(["view", "edit", "own"], current_user&.roles)) %>
<div class="card border-0 border-bottom">
<div class="card-body py-2">
<div class="grid">
<div class="col g-col-auto">
<%= icon icon_for(thing.class), thing.class.model_name.human %>
</div>
<div class="col">
<%- if object.local? %>
<%= link_to thing.name, thing %>
<%- elsif object.profile_url %>
<%= link_to object.name, object.profile_url %>
<%- else %>
<%= object.name %>
<%- end %>
</div>
<% if thing.is_a? Model %>
<div class="col g-col-auto">
<%= status_badges(thing) %>
</div>
<% end %>
<div class="col g-col-auto">
<small>
<%= t("home.index.create_actor", time: time_ago_in_words(thing.created_at), name: subject.name) %>
</small>
</div>
</div>
</div>
</div>
<tr>
<td>
<%= icon icon_for(thing.class), thing.class.model_name.human %>
</td>
<td>
<%- if object.local? %>
<%= link_to thing.name, thing %>
<%- elsif object.profile_url %>
<%= link_to object.name, object.profile_url %>
<%- else %>
<%= object.name %>
<%- end %>
</td>
<td>
<% if thing.is_a? Model %>
<%= status_badges(thing) %>
<% end %>
</td>
<td>
<small>
<%= t("home.index.create_actor", time: time_ago_in_words(thing.created_at), name: subject.name) %>
</small>
</td>
</tr>
<% end %>
34 changes: 16 additions & 18 deletions app/views/activities/_create_following.html.erb
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
<%- follow = activity.entity %>

<div class="card border-0 border-bottom">
<div class="card-body py-2">
<div class="grid">
<div class="col">
<% if follow.actor.entity == current_user %>
You
<% else %>
<%= follow.actor.name %>
<% end %>
followed
<%= link_to follow.target_actor.name, follow.target_actor.entity %>
</div>
<div class="col g-col-auto">
<small><%= t("home.index.how_long_ago", time: time_ago_in_words(follow.created_at)) %></small>
</div>
</div>
</div>
</div>
<tr>
<td></td>
<td>
<% if follow.actor.entity == current_user %>
You
<% else %>
<%= follow.actor.name %>
<% end %>
followed
<%= link_to follow.target_actor.name, follow.target_actor.entity %>
</td>
<td></td>
<td>
<small><%= t("home.index.how_long_ago", time: time_ago_in_words(follow.created_at)) %></small>
</td>
</tr>
50 changes: 24 additions & 26 deletions app/views/activities/_update_actor.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,30 @@
<%- object = activity&.entity %>
<%- thing = object&.entity %>
<% if thing && !thing.is_a?(User) && (thing.grants_permission_to?(["view", "edit", "own"], current_user) || thing.grants_permission_to?(["view", "edit", "own"], current_user&.roles)) %>
<div class="card border-0 border-bottom">
<div class="card-body py-2">
<div class="grid">
<tr>
<td>
<%= icon icon_for(thing.class), thing.class.model_name.human %>
</td>
<td>
<%- if object.local? %>
<%= link_to thing.name, thing %>
<%- elsif object.profile_url %>
<%= link_to object.name, object.profile_url %>
<%- else %>
<%= object.name %>
<%- end %>
</td>
<td>
<% if thing.is_a? Model %>
<div class="col g-col-auto">
<%= icon icon_for(thing.class), thing.class.model_name.human %>
<%= status_badges(thing) %>
</div>
<div class="col">
<%- if object.local? %>
<%= link_to thing.name, thing %>
<%- elsif object.profile_url %>
<%= link_to object.name, object.profile_url %>
<%- else %>
<%= object.name %>
<%- end %>
</div>
<% if thing.is_a? Model %>
<div class="col g-col-auto">
<%= status_badges(thing) %>
</div>
<% end %>
<div class="col g-col-auto">
<small>
<%= t("home.index.update_actor", time: time_ago_in_words(thing.updated_at), name: subject.name) %>
</small>
</div>
</div>
</div>
</div>
<% end %>
</td>
<td>
<small>
<%= t("home.index.update_actor", time: time_ago_in_words(thing.updated_at), name: subject.name) %>
</small>
</td>
</tr>
<% end %>
14 changes: 6 additions & 8 deletions app/views/home/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
</div>
</div>
<% if !@feed.empty? %>
<div class="grid row-cols-2">
<div class="g-col-8 offset-md-2">
<p class="lead"><%= t(".recent_activity") %></p>
<% @feed.each do |activity| %>
<%= render partial: "activities/#{activity.action.parameterize}_#{activity.entity_type.demodulize.parameterize}", locals: {activity: activity} %>
<% end %>
</div>
</div>
<p class="lead"><%= t(".recent_activity") %></p>
<table class="table">
<% @feed.each do |activity| %>
<%= render partial: "activities/#{activity.action.parameterize}_#{activity.entity_type.demodulize.parameterize}", locals: {activity: activity} %>
<% end %>
</table>
<% end %>

0 comments on commit ec818f3

Please sign in to comment.