From 0dfac2c3660a662eaeda796fb1e1964fc13b9a79 Mon Sep 17 00:00:00 2001 From: ArtOfCode- <hello@artofcode.co.uk> Date: Mon, 3 Aug 2020 00:38:18 +0100 Subject: [PATCH] Unify user profile tabs --- app/views/devise/registrations/edit.html.erb | 15 +-------------- app/views/subscriptions/index.html.erb | 15 +-------------- app/views/users/_tabs.html.erb | 20 ++++++++++++++++++++ app/views/users/activity.html.erb | 20 +------------------- app/views/users/edit_profile.erb | 20 +------------------- app/views/users/show.html.erb | 20 +------------------- 6 files changed, 25 insertions(+), 85 deletions(-) create mode 100644 app/views/users/_tabs.html.erb diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index e507e9269..fb70cc984 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -1,17 +1,4 @@ -<div class="tabs"> - <%= link_to user_path(current_user), class: "tabs--item" do %> - <i class="fas fa-user"></i> Profile - <% end %> - <%= link_to edit_user_registration_path, class: "tabs--item is-active" do %> - Account - <% end %> - <%= link_to edit_user_profile_path, class: "tabs--item" do %> - Edit - <% end %> - <%= link_to subscriptions_path, class: "tabs--item" do %> - Subscriptions - <% end %> -</div> +<%= render 'users/tabs', user: current_user %> <h1>Edit Account Settings</h1> diff --git a/app/views/subscriptions/index.html.erb b/app/views/subscriptions/index.html.erb index a0b639671..774017ba6 100644 --- a/app/views/subscriptions/index.html.erb +++ b/app/views/subscriptions/index.html.erb @@ -1,17 +1,4 @@ -<div class="tabs"> - <%= link_to user_path(current_user), class: "tabs--item" do %> - <i class="fas fa-user"></i> Profile - <% end %> - <%= link_to edit_user_registration_path, class: "tabs--item" do %> - Account - <% end %> - <%= link_to edit_user_profile_path, class: "tabs--item" do %> - Edit - <% end %> - <%= link_to subscriptions_path, class: "tabs--item is-active" do %> - Subscriptions - <% end %> -</div> +<%= render 'users/tabs', user: current_user %> <h1>Your Subscriptions</h1> <p>These are all the email subscriptions you're currently signed up for. You can turn them off or remove them entirely from here.</p> diff --git a/app/views/users/_tabs.html.erb b/app/views/users/_tabs.html.erb new file mode 100644 index 000000000..b871dd4ad --- /dev/null +++ b/app/views/users/_tabs.html.erb @@ -0,0 +1,20 @@ +<div class="tabs"> + <% puts user %> + <%= link_to user_path(user), class: "tabs--item #{current_page?(user_path(user)) ? 'is-active' : ''}" do %> + <i class="fas fa-user"></i> Profile + <% end %> + <%= link_to user_activity_path(user), class: "tabs--item #{current_page?(user_activity_path(user)) ? 'is-active' : ''}" do %> + Activity + <% end %> + <% if user == current_user %> + <%= link_to edit_user_registration_path, class: "tabs--item #{current_page?(edit_user_registration_path) ? 'is-active' : ''}" do %> + Account + <% end %> + <%= link_to edit_user_profile_path, class: "tabs--item #{current_page?(edit_user_profile_path) ? 'is-active' : ''}" do %> + Edit + <% end %> + <%= link_to subscriptions_path, class: "tabs--item #{current_page?(subscriptions_path) ? 'is-active' : ''}" do %> + Subscriptions + <% end %> + <% end %> +</div> \ No newline at end of file diff --git a/app/views/users/activity.html.erb b/app/views/users/activity.html.erb index 6b98cd193..bafce3f2f 100644 --- a/app/views/users/activity.html.erb +++ b/app/views/users/activity.html.erb @@ -1,22 +1,4 @@ -<div class="tabs"> - <%= link_to user_path(@user), class: "tabs--item" do %> - <i class="fas fa-user"></i> Profile - <% end %> - <%= link_to user_activity_path(@user), class: "tabs--item is-active" do %> - Activity - <% end %> - <% if @user == current_user %> - <%= link_to edit_user_registration_path, class: "tabs--item" do %> - Account - <% end %> - <%= link_to edit_user_profile_path, class: "tabs--item" do %> - Edit - <% end %> - <%= link_to subscriptions_path, class: "tabs--item" do %> - Subscriptions - <% end %> - <% end %> -</div> +<%= render 'tabs', user: @user %> <h1>Activity for <%= link_to @user.username, user_path(@user) %></h1> diff --git a/app/views/users/edit_profile.erb b/app/views/users/edit_profile.erb index 62676fde1..89f75ce28 100644 --- a/app/views/users/edit_profile.erb +++ b/app/views/users/edit_profile.erb @@ -1,22 +1,4 @@ -<div class="tabs"> - <%= link_to user_path(current_user), class: "tabs--item" do %> - <i class="fas fa-user"></i> Profile - <% end %> - <%= link_to user_activity_path(current_user), class: "tabs--item" do %> - Activity - <% end %> - <% if @user == current_user %> - <%= link_to edit_user_registration_path, class: "tabs--item" do %> - Account - <% end %> - <%= link_to edit_user_profile_path, class: "tabs--item is-active" do %> - Edit - <% end %> - <%= link_to subscriptions_path, class: "tabs--item" do %> - Subscriptions - <% end %> - <% end %> -</div> +<%= render 'tabs', user: current_user %> <h1>Edit Profile</h1> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 7602fabb3..051fe0cd0 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -12,25 +12,7 @@ </div> <% end %> -<div class="tabs"> - <%= link_to user_path(@user), class: "tabs--item is-active" do %> - <i class="fas fa-user"></i> Profile - <% end %> - <%= link_to user_activity_path(@user), class: "tabs--item" do %> - Activity - <% end %> - <% if @user == current_user %> - <%= link_to edit_user_registration_path, class: "tabs--item" do %> - Account - <% end %> - <%= link_to edit_user_profile_path, class: "tabs--item" do %> - Edit - <% end %> - <%= link_to subscriptions_path, class: "tabs--item" do %> - Subscriptions - <% end %> - <% end %> -</div> +<%= render 'tabs', user: @user %> <div class="user-profile"> <div class="user-profile--image"> -- GitLab