Skip to content

Commit

Permalink
Added couple of functionality changes
Browse files Browse the repository at this point in the history
  • Loading branch information
akhilgkrishnan committed Jan 4, 2022
1 parent 34a0c26 commit 69dc7c6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 32 deletions.
6 changes: 2 additions & 4 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
class ApplicationController < ActionController::Base
before_action :authenticate_user!

def index
def redirect_path
path = case current_user.role
when "owner"
dashboard_index_path
when "admin"
when "owner" || "admin"
dashboard_index_path
else
time_trackings_path
Expand Down
47 changes: 21 additions & 26 deletions app/views/partial/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,57 +30,54 @@
</button>
</div>
<div class="flex-1 flex items-center justify-center md:items-stretch md:justify-start">

<!-- Logo -->
<div class="flex-shrink-0 flex items-center">
<img class="block lg:hidden h-8 w-auto md:mr-12" src="app/javascript/images/miru-logo.svg" alt="miru web">
<img class="hidden lg:block h-8 w-auto lg:mr-32" src="app/javascript/images/miru-logo.svg" alt="miru web">
<a href="/" class="font-semibold text-xl tracking-tight">
<img class="block lg:hidden h-8 w-auto md:mr-12" src="/miru-logo.svg" alt="miru web">
<img class="hidden lg:block h-8 w-auto lg:mr-32" src="/miru-logo.svg" alt="miru web">
</a>
</div>

<div class="hidden md:mx-3 md:flex md:space-x-2 lg:space-x-8">
<!-- Current: "border-indigo-500 text-gray-900", Default: "border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700" -->
<% if (current_user.admin? || current_user.owner?) %>
<a href="#" class="border-transparent text-gray-500 hover:text-gray-700 inline-flex items-center px-1 pt-1 text-sm font-medium">
<a href="/dashboard" class="<%= request.path == "/dashboard" ? "text-miru-han-purple-1000" : "border-transparent text-gray-500 hover:text-gray-700" %> inline-flex items-center px-1 pt-1 text-sm font-medium">
Dashboard
</a>
<% end %>
<a href="#" class="text-miru-han-purple-1000 inline-flex items-center px-1 pt-1 text-sm font-medium">
<a href="/time-tracking" class="<%= request.path == "/time-tracking" ? "text-miru-han-purple-1000" : "border-transparent text-gray-500 hover:text-gray-700" %> inline-flex items-center px-1 pt-1 text-sm font-medium">
Time Tracking
</a>
<% if (current_user.admin? || current_user.owner?) %>
<a href="#" class="border-transparent text-gray-500 hover:text-gray-700 inline-flex items-center px-1 pt-1 text-sm font-medium">
<a href="/team" class="<%= request.path == "/team" ? "text-miru-han-purple-1000" : "border-transparent text-gray-500 hover:text-gray-700" %> inline-flex items-center px-1 pt-1 text-sm font-medium">
Team
</a>
<% end %>
<a href="#" class="border-transparent text-gray-500 hover:text-gray-700 inline-flex items-center px-1 pt-1 text-sm font-medium">
<a href="/clients" class="<%= request.path == "/clients" ? "text-miru-han-purple-1000" : "border-transparent text-gray-500 hover:text-gray-700" %> inline-flex items-center px-1 pt-1 text-sm font-medium">
Clients
</a>
<a href="#" class="border-transparent text-gray-500 hover:text-gray-700 inline-flex items-center px-1 pt-1 text-sm font-medium">
<a href="/projects" class="<%= request.path == "/project" ? "text-miru-han-purple-1000" : "border-transparent text-gray-500 hover:text-gray-700" %> inline-flex items-center px-1 pt-1 text-sm font-medium">
Projects
</a>
<% if (current_user.admin? || current_user.owner?) %>
<a href="#" class="border-transparent text-gray-500 hover:text-gray-700 inline-flex items-center px-1 pt-1 text-sm font-medium">
<a href="/invoice" class="<%= request.path == "/invoice" ? "text-miru-han-purple-1000" : "border-transparent text-gray-500 hover:text-gray-700" %> inline-flex items-center px-1 pt-1 text-sm font-medium">
Invoice
</a>
<% end %>
<% if (current_user.admin? || current_user.owner?) %>
<a href="#" class="border-transparent text-gray-500 hover:text-gray-700 inline-flex items-center px-1 pt-1 text-sm font-medium">
<a href="/report" class="<%= request.path == "/report" ? "text-miru-han-purple-1000" : "border-transparent text-gray-500 hover:text-gray-700" %> inline-flex items-center px-1 pt-1 text-sm font-medium">
Report
</a>
<% end %>
</div>

</div>

<div class="absolute inset-y-0 right-0 flex items-center pr-2 md:static md:inset-auto md:ml-6 md:pr-0">

<button type="button" class="bg-white p-1 rounded-full text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
<span class="sr-only">View notifications</span>
<!-- Heroicon name: outline/bell -->
<svg class="h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9" />
</svg>
</button>

<!-- Profile dropdown -->
<div class="ml-3 relative" x-data="{ isOpen: false}">
<div>
Expand All @@ -89,7 +86,6 @@
<img class="h-8 w-8 rounded-full" src="" alt="profile">
</button>
</div>

<!--
Dropdown menu, show/hide based on menu state.
Expand All @@ -103,33 +99,32 @@
<div x-show="isOpen" @click.away="isOpen = false">
<div class="origin-top-right absolute right-0 mt-2 w-48 rounded-md shadow-lg py-1 bg-white ring-1 ring-black ring-opacity-5 focus:outline-none" role="menu" aria-orientation="vertical" aria-labelledby="user-menu-button" tabindex="-1">
<!-- Active: "bg-gray-100", Not Active: "" -->
<a href="#" class="block px-4 py-2 text-sm text-gray-700" role="menuitem" tabindex="-1" id="user-menu-item-0">Your Profile</a>
<a href="#" class="block px-4 py-2 text-sm text-gray-700" role="menuitem" tabindex="-1" id="user-menu-item-1">Settings</a>
<a href="/profile" class="block px-4 py-2 text-sm text-gray-700" role="menuitem" tabindex="-1" id="user-menu-item-0">Your Profile</a>
<a href="/settings" class="block px-4 py-2 text-sm text-gray-700" role="menuitem" tabindex="-1" id="user-menu-item-1">Settings</a>
<%= button_to "logout", destroy_user_session_path, method: :delete, class: "block px-4 py-2 text-sm text-gray-700", role: "menuitem", tabindex: "-1", id: "user-menu-item-2"%>
</div>
</div>
</div>
</div>
</div>
</div>

<!-- Mobile menu, show/hide based on menu state. -->
<div class="flex">
<div class="md:hidden">
<div class="pt-2 pb-4 space-y-1" x-show="isOpen" @click.away="isOpen = false">
<!-- Current: "bg-indigo-50 border-indigo-500 text-indigo-700", Default: "border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700" -->
<% if (current_user.admin? || current_user.owner?) %>
<a href="#" class="border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Dashboard</a>
<a href="/dashboard" class="<%= request.path == "/dashboard" ? "bg-indigo-50 border-indigo-500 text-indigo-700" : "border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700" %> block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Dashboard</a>
<% end %>
<a href="#" class="bg-indigo-50 border-indigo-500 text-indigo-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Time Tracking</a>
<a href="/time-tracking" class="<%= request.path == "/time-tracking" ? "bg-indigo-50 border-indigo-500 text-indigo-700" : "border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700" %> block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Time Tracking</a>
<% if (current_user.admin? || current_user.owner?) %>
<a href="#" class="border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Team</a>
<a href="/team" class="<%= request.path == "/team" ? "bg-indigo-50 border-indigo-500 text-indigo-700" : "border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700" %> block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Team</a>
<% end %>
<a href="#" class="border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Clients</a>
<a href="#" class="border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Projects</a>
<a href="/clients" class="<%= request.path == "/clients" ? "bg-indigo-50 border-indigo-500 text-indigo-700" : "border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700" %> block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Clients</a>
<a href="/projects" class="<%= request.path == "/projects" ? "bg-indigo-50 border-indigo-500 text-indigo-700" : "border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700" %> block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Projects</a>
<% if (current_user.admin? || current_user.owner?) %>
<a href="#" class="border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Invoice</a>
<a href="#" class="border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Report</a>
<a href="/invoice" class="<%= request.path == "/invoice" ? "bg-indigo-50 border-indigo-500 text-indigo-700" : "border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700" %> block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Invoice</a>
<a href="/report" class="<%= request.path == "/report" ? "bg-indigo-50 border-indigo-500 text-indigo-700" : "border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700" %> block pl-3 pr-4 py-2 border-l-4 text-base font-medium">Report</a>
<% end %>
</div>
</div>
Expand Down
6 changes: 4 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

Rails.application.routes.draw do
devise_for :users, controllers: { registrations: "users/registrations" }
root "application#index"
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html

root to: "application#redirect_path"
resources :dashboard, only: [:index]
resources :time_trackings, only: [:index]
resources :time_trackings, only: [:index], path: "time-tracking"
end

0 comments on commit 69dc7c6

Please sign in to comment.