-
-
Notifications
You must be signed in to change notification settings - Fork 922
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Index is a section of the dashboard. Show is the organization view page.
- Loading branch information
1 parent
15247cc
commit ac32613
Showing
14 changed files
with
311 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
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] | ||
|
||
layout "subject" | ||
|
||
# GET /organizations | ||
def index | ||
@memberships = current_user.memberships.includes(:organization) | ||
end | ||
|
||
# GET /organizations/1 | ||
def show | ||
add_breadcrumb t("breadcrumbs.org_name", name: @organization.handle) | ||
|
||
@latest_events = [] # @organization.latest_events | ||
@gems = [] # @organization.rubygems | ||
@gems_count = @gems.size | ||
@memberships = @organization.memberships | ||
@memberships_count = @organization.memberships.count | ||
end | ||
|
||
private | ||
|
||
def find_organization | ||
@organization = Organization.find_by_handle!(params[: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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module LayoutHelper | ||
# <%= layout_section "Footer Nav", class: "py-8 bg-orange-100 dark:bg-orange-950 text-neutral-800 dark:text-neutral-200 flex-col items-center"> | ||
def layout_section(_name, **options, &) | ||
options[:class] = "w-full px-8 #{options[:class]}" | ||
|
||
tag.div(**options) do | ||
tag.div(class: "max-w-screen-xl mx-auto flex flex-col", &) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module OrganizationsHelper | ||
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* A controller that, when loaded, causes the page to refresh periodically */ | ||
|
||
import { Controller } from "@hotwired/stimulus" | ||
|
||
export default class extends Controller { | ||
static values = { | ||
interval: { type: Number, default: 5000 } | ||
} | ||
|
||
connect() { | ||
this.refresh() | ||
} | ||
|
||
refresh() { | ||
setTimeout(() => { | ||
window.location.reload() | ||
}, this.intervalValue) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<% 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-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"), dashboard_path, name: :dashboard, icon: "space-dashboard" %> | ||
<%= nav.link t("organizations.show.history"), subscriptions_path, name: :subscriptions, icon: "notifications" %> | ||
<%= nav.link t("organizations.show.gems"), organizations_path, name: :gems, icon: "gems" %> | ||
<%= nav.link t("organizations.show.members"), organizations_path, name: :organizations, icon: "organizations" %> | ||
<%= 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<% | ||
@title = t('.title') | ||
add_breadcrumb "Dashboard", dashboard_path | ||
add_breadcrumb "Organizations" | ||
%> | ||
<% content_for :subject do %> | ||
<%= render "dashboards/subject", user: current_user, current: :organizations %> | ||
<% end %> | ||
|
||
<!-- Main Content --> | ||
<h1 class="text-h2 mb-10 space-x-2"> | ||
<span><%= t("dashboards.show.organizations") %></span> | ||
<% unless @memberships.size.zero? %> | ||
<span class="font-light text-neutral-600"><%= @memberships.size %></span> | ||
<% end %> | ||
</h1> | ||
|
||
<!-- Organizations --> | ||
<%= render CardComponent.new do |c| %> | ||
<%= c.divided_list do %> | ||
<% @memberships.each do |membership| %> | ||
<%= c.list_item_to(organization_path(membership.organization.handle)) do %> | ||
<div class="flex flex-row w-full justify-between items-center"> | ||
<div class="flex flex-col"> | ||
<p class="text-neutral-800 dark:text-white"><%= membership.organization.name %></p> | ||
<p class="text-b3 text-neutral-600"><%= membership.organization.handle %></p> | ||
</div> | ||
<p class="text-neutral-500 capitalize"><%= membership.role %></p> | ||
</div> | ||
<% end %> | ||
<% 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<% content_for :subject do %> | ||
<%= render "organizations/subject", organization: @organization, current: :dashboard %> | ||
<% end %> | ||
|
||
<h1 class="text-h2 mb-10"><%= t("dashboards.show.title") %></h1> | ||
|
||
<%= render CardComponent.new do |c| %> | ||
<%= c.head(divide: true) do %> | ||
<%= c.title t(".history"), icon: :history %> | ||
<% end %> | ||
<% if @latest_events.empty? %> | ||
<%= prose do %> | ||
<i><%= t('.no_history') %></i> | ||
<% end %> | ||
<% else %> | ||
<%= c.scrollable do %> | ||
<%= render Card::TimelineComponent.new do |t| %> | ||
<% @latest_events.each do |version| %> | ||
<% | ||
pusher_link = if version.pusher.present? | ||
link_to_user(version.pusher) | ||
elsif version.pusher_api_key&.owner.present? | ||
link_to_pusher(version.pusher_api_key.owner) | ||
end | ||
%> | ||
<%= t.timeline_item(version.authored_at, pusher_link) do %> | ||
<div class="flex text-b1 text-neutral-800 dark:text-white"><%= link_to version.rubygem.name, rubygem_path(version.rubygem.slug) %></div> | ||
<%= version_number(version) %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<%= render CardComponent.new do |c| %> | ||
<%= c.head do %> | ||
<%= c.title t(".gems"), icon: "gems", count: @gems_count %> | ||
<% end %> | ||
<% if @gems.empty? %> | ||
<%= prose do %> | ||
<i><%= t('.no_gems', :creating_link => link_to(t('.creating_link_text'), "https://guides.rubygems.org/make-your-own-gem/")) %></i> | ||
<% end %> | ||
<% else %> | ||
<%= c.divided_list do %> | ||
<% @gems.each do |rubygem| %> | ||
<%= c.list_item_to( | ||
rubygem_path(rubygem.slug), | ||
title: short_info(rubygem.most_recent_version), | ||
) do %> | ||
<div class="flex flex-col w-full justify-between"> | ||
<div class="flex flex-row w-full items-center justify-between"> | ||
<h4 class="text-b1 flex"><%= rubygem.name %></h4> | ||
<%= version_number(rubygem.most_recent_version) %> | ||
</div> | ||
<div class="flex flex-row w-full items-center justify-between"> | ||
<%= download_count_component(rubygem, class: "flex") %> | ||
<div class="flex text-neutral-600"><%= version_date_component(rubygem.most_recent_version) %></div> | ||
</div> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<%= render CardComponent.new do |c| %> | ||
<%= c.head do %> | ||
<%= c.title t(".members"), icon: "organizations", count: @memberships_count %> | ||
<% end %> | ||
<% if @memberships.empty? %> | ||
<%= prose do %> | ||
<i><%= t('.no_members') %></i> | ||
<% end %> | ||
<% else %> | ||
<%= c.divided_list do %> | ||
<% @memberships.each do |membership| %> | ||
<%= c.list_item_to(profile_path(membership.user.handle)) do %> | ||
<div class="flex justify-between"> | ||
<p class="text-neutral-800 dark:text-white"><%= membership.user.name %></p> | ||
<p class="text-neutral-500 capitalize"><%= membership.role %></p> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
<% 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
Oops, something went wrong.