-
-
Notifications
You must be signed in to change notification settings - Fork 928
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Organizations CRUD actions + gems views
- Loading branch information
1 parent
323bbc5
commit 91fbb8a
Showing
37 changed files
with
876 additions
and
80 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,22 @@ | ||
class Organizations::GemsController < ApplicationController | ||
before_action :redirect_to_signin, unless: :signed_in? | ||
before_action :redirect_to_new_mfa, if: :mfa_required_not_yet_enabled? | ||
before_action :redirect_to_settings_strong_mfa_required, if: :mfa_required_weak_level_enabled? | ||
|
||
before_action :find_organization, only: %i[index] | ||
|
||
layout "subject" | ||
|
||
# GET /organizations/organization_id/gems | ||
|
||
def index | ||
@gems = @organization.rubygems.with_versions.by_downloads.preload(:most_recent_version, :gem_download).load_async | ||
@gems_count = @organization.rubygems.with_versions.count | ||
end | ||
|
||
private | ||
|
||
def find_organization | ||
@organization = Organization.find_by_handle!(params[:organization_id]) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,55 @@ | ||
class OrganizationsController < ApplicationController | ||
before_action :redirect_to_signin, only: :index, unless: :signed_in? | ||
before_action :redirect_to_new_mfa, only: :index, if: :mfa_required_not_yet_enabled? | ||
before_action :redirect_to_settings_strong_mfa_required, only: :index, if: :mfa_required_weak_level_enabled? | ||
|
||
before_action :find_organization, only: %i[show edit update] | ||
|
||
layout "subject" | ||
|
||
# GET /organizations | ||
def index | ||
@memberships = current_user.memberships.includes(:organization) | ||
end | ||
|
||
# GET /organizations/1 | ||
def show | ||
render plain: flash[:notice] # HACK: for tests until this view is ready | ||
@latest_events = [] # @organization.latest_events | ||
@gems = @organization | ||
.rubygems | ||
.with_versions | ||
.by_downloads | ||
.preload(:most_recent_version, :gem_download) | ||
.load_async | ||
@gems_count = @organization.rubygems.with_versions.count | ||
@memberships = @organization.memberships | ||
@memberships_count = @organization.memberships.count | ||
end | ||
|
||
def edit | ||
add_breadcrumb t("breadcrumbs.org_name", name: @organization.handle), organization_path(@organization) | ||
add_breadcrumb t("breadcrumbs.settings") | ||
|
||
authorize @organization | ||
end | ||
|
||
def update | ||
authorize @organization | ||
|
||
if @organization.update(organization_params) | ||
redirect_to organization_path(@organization) | ||
else | ||
render :edit | ||
end | ||
end | ||
|
||
private | ||
|
||
def find_organization | ||
@organization = Organization.find_by_handle!(params.permit(:id).require(:id)) | ||
end | ||
|
||
def organization_params | ||
params.permit(organization: [:name]).require(:organization) | ||
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
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,42 +1,46 @@ | ||
<% | ||
user ||= @user || current_user | ||
current ||= :dashboard | ||
%> | ||
<%# locals: (user:, current:) -%> | ||
|
||
<div class="flex flex-wrap lg:flex-col items-start mb-6 lg:mb-10"> | ||
<%= avatar 328, "user_gravatar", theme: :dark, class: "h-24 w-24 lg:h-40 lg:w-40 rounded-lg object-cover mr-4" %> | ||
<div class="mb-8 space-y-4"> | ||
<div class="flex flex-wrap lg:flex-col items-start mb-6 lg:mb-10"> | ||
<%= avatar 328, "user_gravatar", theme: :dark, class: "h-24 w-24 lg:h-40 lg:w-40 rounded-lg object-cover mr-4" %> | ||
|
||
<div class="lg:w-full lg:mt-2"> | ||
<h2 class="font-bold text-h4"><%= user.display_handle %></h2> | ||
<% if user.full_name.present? %> | ||
<p class="text-neutral-500 text-b3"><%= user.full_name %></p> | ||
<% end %> | ||
<div class="lg:w-full lg:mt-2"> | ||
<h2 class="font-bold text-h4"><%= user.display_handle %></h2> | ||
<% if user.full_name.present? %> | ||
<p class="text-neutral-500 text-b3"><%= user.full_name %></p> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<% if user.public_email? || user == current_user %> | ||
<div class="flex items-center mb-4 text-b3 lg:text-b2"> | ||
<%= icon_tag("mail", color: :primary, class: "h-6 w-6 text-orange mr-3") %> | ||
<p class="text-neutral-800 dark:text-white"><%= | ||
mail_to(user.email, encode: "hex") | ||
%></p> | ||
</div> | ||
<% end %> | ||
<% if user.public_email? || user == current_user %> | ||
<div class="flex items-center mb-4 text-b3 lg:text-b2"> | ||
<%= icon_tag("mail", color: :primary, class: "h-6 w-6 text-orange mr-3") %> | ||
<p class="text-neutral-800 dark:text-white"><%= | ||
mail_to(user.email, encode: "hex") | ||
%></p> | ||
</div> | ||
<% end %> | ||
<% if user.twitter_username.present? %> | ||
<div class="flex items-center mb-4 text-b3 lg:text-b2"> | ||
<%= icon_tag("x-twitter", color: :primary, class: "w-6 text-orange mr-3") %> | ||
<p class="text-neutral-800 dark:text-white"><%= | ||
link_to( | ||
twitter_username(user), | ||
twitter_url(user) | ||
) | ||
%></p> | ||
</div> | ||
<% end %> | ||
<% if user.twitter_username.present? %> | ||
<div class="flex items-center mb-4 text-b3 lg:text-b2"> | ||
<%= icon_tag("x-twitter", color: :primary, class: "w-6 text-orange mr-3") %> | ||
<p class="text-neutral-800 dark:text-white"><%= | ||
link_to( | ||
twitter_username(user), | ||
twitter_url(user) | ||
) | ||
%></p> | ||
</div> | ||
<% end %> | ||
</div> | ||
|
||
<hr class="hidden lg:block lg:mb-6 border-neutral-400 dark:border-neutral-600" /> | ||
|
||
<%= render Subject::NavComponent.new(current:) do |nav| %> | ||
<%= nav.link t("layouts.application.header.dashboard"), dashboard_path, name: :dashboard, icon: "space-dashboard" %> | ||
<%= nav.link t("dashboards.show.my_subscriptions"), subscriptions_path, name: :subscriptions, icon: "notifications" %> | ||
<% if current_user.memberships.any? %> | ||
<%= nav.link t("dashboards.show.organizations"), organizations_path, name: :organizations, icon: "organizations" %> | ||
<% end %> | ||
<%= nav.link t("layouts.application.header.settings"), edit_settings_path, name: :settings, icon: "settings" %> | ||
<% 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,34 @@ | ||
<!DOCTYPE html> | ||
<html lang="<%= I18n.locale %>"> | ||
<head> | ||
<title><%= page_title %></title> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"> | ||
<%= stylesheet_link_tag("hammy") %> | ||
<%= stylesheet_link_tag("tailwind", "data-turbo-track": "reload") %> | ||
<link href="https://fonts.gstatic.com" rel="preconnect" crossorigin> | ||
<link href="https://fonts.googleapis.com/css2?family=Titillium+Web:ital,wght@0,200;0,300;0,400;0,600;0,700;0,900;1,200;1,300;1,400;1,600;1,700&display=swap" rel="stylesheet" type="text/css"> | ||
<%= yield :head %> | ||
<%= javascript_importmap_tags %> | ||
</head> | ||
<body data-turbo="true" class="bg-neutral-050 dark:bg-neutral-950"> | ||
<div class="min-h-screen flex flex-col"> | ||
<!-- Content --> | ||
<% if content_for?(:main) %> | ||
<%= yield :main %> | ||
<% else %> | ||
<main class="flex-1 w-full px-8 flex-col bg-neutral-050 dark:bg-neutral-950 text-neutral-950 dark:text-neutral-050 text-b2 items-center inline-flex"> | ||
<div class="max-w-screen-xl w-full mx-auto pt-8 pb-10 mb-12 md:mb-16 lg:mb-28"> | ||
<% flash.each do |name, msg| %> | ||
<%= render AlertComponent.new(style: name, closeable: true) do %> | ||
<%= flash_message(name, msg) %> | ||
<% end %> | ||
<% end %> | ||
<%= yield %> | ||
</div> | ||
</main> | ||
<% end %> | ||
</div> | ||
</body> | ||
</html> |
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,25 @@ | ||
<% current ||= :dashboard %> | ||
|
||
<div class="flex flex-wrap lg:flex-col items-start mb-6 lg:mb-10"> | ||
<div class="lg:w-full lg:mt-2"> | ||
<h2 class="font-bold text-h4"><%= organization.name %></h2> | ||
<p class="text-neutral-600 dark:text-neutral-500 text-b3"><%= organization.handle %></p> | ||
<p class="my-1"> | ||
<span class="shrink px-3 py-1 rounded-full border border-orange text-orange items-center text-b3 uppercase font-semibold"> | ||
<%= icon_tag("organizations", size: 6, class: "-mt-1 -ml-1 mr-1 inline-block") -%><%= t("organizations.show.organization") %> | ||
</span> | ||
</p> | ||
</div> | ||
</div> | ||
|
||
<hr class="hidden lg:block lg:mb-6 border-neutral-400 dark:border-neutral-600" /> | ||
|
||
<%= render Subject::NavComponent.new(current:) do |nav| %> | ||
<%= nav.link t("layouts.application.header.dashboard"), organization_path(@organization), name: :dashboard, icon: "space-dashboard" %> | ||
<%= nav.link t("organizations.show.history"), organization_path(@organization), name: :subscriptions, icon: "notifications" %> | ||
<%= nav.link t("organizations.show.gems"), organization_gems_path(@organization), name: :gems, icon: "gems" %> | ||
<%= nav.link t("organizations.show.members"), organization_path(@organization), name: :organizations, icon: "organizations" %> | ||
<% if policy(@organization).edit? %> | ||
<%= nav.link t("layouts.application.header.settings"), edit_organization_path(@organization), name: :settings, icon: "settings" %> | ||
<% end %> | ||
<% end %> |
Oops, something went wrong.