Skip to content

Commit

Permalink
hide dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Aniket Kaushik committed Apr 21, 2022
1 parent ff3a78a commit 456fe67
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 30 deletions.
13 changes: 8 additions & 5 deletions app/controllers/users/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ class Users::SessionsController < Devise::SessionsController
def after_sign_in_path_for(resource)
return new_company_path if resource.companies.empty? && resource.has_role?(:owner)

if resource.has_owner_or_admin_role?(current_company)
dashboard_index_path
else
time_tracking_index_path
end
time_tracking_index_path

# As per discussion we want to redirect all the users to time-tracking page as dashboard is blank.
# if resource.has_owner_or_admin_role?(current_company)
# dashboard_index_path
# else
# time_tracking_index_path
# end
end
end
26 changes: 13 additions & 13 deletions app/views/partial/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<% if current_company %>
<!-- dashboard time_tracking team clients projects invoices report etc. Start -->
<div class="border-t border-gray-200 pt-4 pb-3 pl-3">
<% if policy(:dashboard).index? %>
<a href="/dashboard" class="<%= request.path == "/dashboard" ? "navbar__smaller-screen_selected" : "navbar__smaller-screen_unselected" %> navbar__smaller-screen_titles"><%= t('navbar.dashboard') %></a>
<% end %>
<%# if policy(:dashboard).index? %>
<!-- <a href="/dashboard" class="<%#= request.path == "/dashboard" ? "navbar__smaller-screen_selected" : "navbar__smaller-screen_unselected" %> navbar__smaller-screen_titles"><%#= t('navbar.dashboard') %></a>-->
<%# end %>
<a href="/time-tracking" class="<%= request.path == "/time-tracking" ? "navbar__smaller-screen_selected" : "navbar__smaller-screen_unselected" %> navbar__smaller-screen_titles"><%= t('navbar.time_tracking') %></a>
<a href="/team" class="<%= request.path == "/team" ? "navbar__smaller-screen_selected" : "navbar__smaller-screen_unselected" %> navbar__smaller-screen_titles"><%= t('navbar.team') %></a>
<a href="/clients" class="<%= request.path == "/clients" ? "navbar__smaller-screen_selected" : "navbar__smaller-screen_unselected" %> navbar__smaller-screen_titles"><%= t('navbar.clients') %></a>
Expand Down Expand Up @@ -92,11 +92,11 @@
<!-- title smaller screen size -->
<div class="relative z-0 flex-1 flex items-center justify-center xsm:absolute xsm:inset-0">
<div class="block lg:hidden">
<% if policy(:dashboard).index? %>
<a href="/dashboard" class="<%= request.path == "/dashboard" ? "block" : "hidden" %> navbar__small-screen-second_titles">
<%= t('navbar.dashboard') %>
</a>
<% end %>
<%# if policy(:dashboard).index? %>
<!-- <a href="/dashboard" class="<%#= request.path == "/dashboard" ? "block" : "hidden" %> navbar__small-screen-second_titles">-->
<%#= t('navbar.dashboard') %>
<!-- </a>-->
<%# end %>
<a href="/time-tracking" class="<%= request.path == "/time-tracking" ? "block" : "hidden" %> navbar__small-screen-second_titles">
<%= t('navbar.time_tracking') %>
</a>
Expand Down Expand Up @@ -131,11 +131,11 @@
<!-- dashboard time_tracking team clients projects invoices report etc. start -->
<div class="relative z-0 flex-auto flex items-center justify-center sm:absolute sm:inset-0">
<div class="ml-12 hidden lg:block lg:flex lg:space-x-10 xl:pr-80 <%= "lg:mr-86" if current_user.has_role?(:employee, current_company) %>">
<% if policy(:dashboard).index? %>
<a href="/dashboard" data-cy="dashboard-tab" class="<%= request.path == "/dashboard" ? "navbar__large-screen_selected" : "navbar__large-screen_unselected" %> navbar__large-screen_title">
<%= t('navbar.dashboard') %>
</a>
<% end %>
<%# if policy(:dashboard).index? %>
<!-- <a href="/dashboard" data-cy="dashboard-tab" class="<%#= request.path == "/dashboard" ? "navbar__large-screen_selected" : "navbar__large-screen_unselected" %> navbar__large-screen_title">-->
<%#= t('navbar.dashboard') %>
<!-- </a>-->
<%# end %>
<a href="/time-tracking" data-cy="time-tracking-tab" class="<%= request.path == "/time-tracking" ? "navbar__large-screen_selected" : "navbar__large-screen_unselected" %> navbar__large-screen_title">
<%= t('navbar.time_tracking') %>
</a>
Expand Down
37 changes: 25 additions & 12 deletions spec/requests/users/sessions/create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
let(:company) { create(:company) }
let(:user) { create(:user, current_workspace_id: company.id, password: "testing!") }

context "when user is not admin or owner" do
context "when user is admin owner employee" do
before do
create(:company_user, company:, user:)
send_request :post, user_session_path, params: { user: { email: user.email, password: user.password } }
Expand All @@ -17,17 +17,30 @@
end
end

context "when user is admin or owner of current company" do
before do
create(:company_user, company:, user:)
user.add_role :admin, company
send_request :post, user_session_path, params: { user: { email: user.email, password: user.password } }
end

it "then after_sign_in_path_for returns the dashboard path" do
expect(response).to redirect_to(dashboard_index_path)
end
end
# As per discussion we want to redirect all the users to time-tracking page as dashboard is blank.
#
# context "when user is not admin or owner" do
# before do
# create(:company_user, company:, user:)
# send_request :post, user_session_path, params: { user: { email: user.email, password: user.password } }
# end
#
# it "then after_sign_in_path_for returns the time_tracking path" do
# expect(response).to redirect_to(time_tracking_index_path)
# end
# end

# context "when user is admin or owner of current company" do
# before do
# create(:company_user, company:, user:)
# user.add_role :admin, company
# send_request :post, user_session_path, params: { user: { email: user.email, password: user.password } }
# end
#
# it "then after_sign_in_path_for returns the dashboard path" do
# expect(response).to redirect_to(dashboard_index_path)
# end
# end

context "when user has owner role but not associated with any company" do
before do
Expand Down

0 comments on commit 456fe67

Please sign in to comment.