-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
user management + some future templates
- Loading branch information
Showing
10 changed files
with
315 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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 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 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,24 +1,32 @@ | ||
module Settings | ||
class TabsComponent < ViewComponent::Base | ||
|
||
LINK_CSS_CLASS = "border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 whitespace-nowrap border-b-2 py-4 px-1 text-sm font-medium" | ||
SELECTED_LINK_CSS_CLASS = "border-indigo-500 text-indigo-600 whitespace-nowrap border-b-2 py-4 px-1 text-sm font-medium" | ||
LINK_CSS_CLASS = "border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 whitespace-nowrap border-b-2 px-1 pb-4 text-sm font-medium" | ||
SELECTED_LINK_CSS_CLASS = "border-indigo-500 text-indigo-600 whitespace-nowrap border-b-2 px-1 pb-4 text-sm font-medium" | ||
|
||
renders_one :action_buttons | ||
|
||
def initialize | ||
|
||
end | ||
|
||
def settings_link(text, path) | ||
css_class = current_page?(path) ? SELECTED_LINK_CSS_CLASS : LINK_CSS_CLASS | ||
css_class = current_or_starts_with?(path) ? SELECTED_LINK_CSS_CLASS : LINK_CSS_CLASS | ||
|
||
options = {} | ||
options[:"aria-current"] = "page" if current_page?(path) | ||
options[:"aria-current"] = "page" if current_or_starts_with?(path) | ||
|
||
link_to text, path, class: css_class, **options | ||
end | ||
|
||
def settings_option(text, path) | ||
content_tag(:option, text, value: path, selected: current_page?(path)) | ||
content_tag(:option, text, value: path, selected: current_or_starts_with?(path)) | ||
end | ||
|
||
private | ||
|
||
def current_or_starts_with?(path) | ||
current_page?(path) | ||
end | ||
end | ||
end |
This file contains 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 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,4 @@ | ||
<div> | ||
<h1 class="font-bold text-4xl">Settings::Users#edit</h1> | ||
<p>Find me in app/views/settings/users/edit.html.erb</p> | ||
</div> |
This file contains 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 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,81 @@ | ||
<div class="border-b border-gray-200 pb-5"> | ||
<%= link_to settings_users_path, class: "ml-3 inline-flex items-center rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600" do %> | ||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6"> | ||
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 19.5 8.25 12l7.5-7.5" /> | ||
</svg> | ||
<span class="ml-2 pr-2">Back</span> | ||
<% end %> | ||
</div> | ||
|
||
<div class="bg-white p-4 mt-4"> | ||
<%= form_for @user, url: settings_users_path, data: {turbo: false} do |f| %> | ||
<div class="space-y-12"> | ||
<div class="pb-12"> | ||
<h2 class="text-base font-semibold leading-7 text-gray-900">Add a new user</h2> | ||
|
||
<% if @user.errors.any? %> | ||
<div class="rounded-md bg-red-50 p-4"> | ||
<div class="flex"> | ||
<div class="flex-shrink-0"> | ||
<svg class="h-5 w-5 text-red-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"> | ||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.28 7.22a.75.75 0 00-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 101.06 1.06L10 11.06l1.72 1.72a.75.75 0 101.06-1.06L11.06 10l1.72-1.72a.75.75 0 00-1.06-1.06L10 8.94 8.28 7.22z" clip-rule="evenodd" /> | ||
</svg> | ||
</div> | ||
<div class="ml-3"> | ||
<h3 class="text-sm font-medium text-red-800">There were <%= pluralize(@user.errors.count, "error") %> with adding the user to your company</h3> | ||
<div class="mt-2 text-sm text-red-700"> | ||
<ul role="list" class="list-disc space-y-1 pl-5"> | ||
<% @user.errors.full_messages.each do |error| %> | ||
<li><%= error %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> | ||
|
||
<div class="mt-10 grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6"> | ||
<div class="sm:col-span-3"> | ||
<%= f.label :name, "Full name", class: "block text-sm font-medium leading-6 text-gray-900" %> | ||
<div class="mt-2"> | ||
<%= f.text_field :name, class: "block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6" %> | ||
</div> | ||
</div> | ||
|
||
<div class="sm:col-span-3"> | ||
<%= f.label :email, "E-mail address", class: "block text-sm font-medium leading-6 text-gray-900" %> | ||
<div class="mt-2"> | ||
<%= f.email_field :email, class: "block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6" %> | ||
</div> | ||
</div> | ||
|
||
<div class="sm:col-span-3"> | ||
<%= label_tag "user_role", "What role should this person have?", class: "block text-sm font-medium leading-6 text-gray-900" %> | ||
<div class="mt-2"> | ||
<select id="user_role" name="user[role]" class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:max-w-xs sm:text-sm sm:leading-6"> | ||
<% user_role_param = @user.memberships.first&.role %> | ||
<option value="<%= Membership::MEMBER %>"<%= " selected" if user_role_param.blank? || user_role_param == Membership::MEMBER %>>Member</option> | ||
<option value="<%= Membership::ADMIN %>"<%= " selected" if user_role_param == Membership::ADMIN %>>Admin</option> | ||
<option value="<%= Membership::OWNER %>"<%= " selected" if user_role_param == Membership::OWNER %>>Owner</option> | ||
</select> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="border-b border-gray-900/10 pb-12"> | ||
<h2 class="text-base font-semibold leading-7 text-gray-900">Note</h2> | ||
<p class="mt-1 text-sm leading-6 text-gray-600"> | ||
This user will receive an email with a link letting them know they have access to StaffPlan. Your account will be charged for this user. | ||
</p> | ||
</div> | ||
</div> | ||
|
||
<div class="mt-6 flex items-center justify-end gap-x-6"> | ||
<%= link_to "Cancel", settings_users_path, class: "text-sm font-semibold leading-6 text-gray-900" %> | ||
<%= submit_tag "Create", data: {disable_with: "Please wait..."}, class: "rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600" %> | ||
</div> | ||
<% end %> | ||
|
||
</div> |
This file contains 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,4 @@ | ||
<div> | ||
<h1 class="font-bold text-4xl">Settings::Users#show</h1> | ||
<p>Find me in app/views/settings/users/show.html.erb</p> | ||
</div> |
This file contains 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.