diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 65861579447..65a6f65e107 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -70,6 +70,7 @@ def breadcrumbs def add_breadcrumb(name, link = nil) breadcrumbs << [name, link] end + helper_method :add_breadcrumb protected diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb new file mode 100644 index 00000000000..5edc5e8d33c --- /dev/null +++ b/app/controllers/organizations_controller.rb @@ -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 diff --git a/app/helpers/layout_hepler.rb b/app/helpers/layout_hepler.rb new file mode 100644 index 00000000000..98ba6c527dc --- /dev/null +++ b/app/helpers/layout_hepler.rb @@ -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 diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb new file mode 100644 index 00000000000..24cc9a80e9b --- /dev/null +++ b/app/helpers/organizations_helper.rb @@ -0,0 +1,2 @@ +module OrganizationsHelper +end diff --git a/app/javascript/controllers/auto_refresh_controller.js b/app/javascript/controllers/auto_refresh_controller.js new file mode 100644 index 00000000000..a17c9ca9e82 --- /dev/null +++ b/app/javascript/controllers/auto_refresh_controller.js @@ -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) + } +} diff --git a/app/models/organization.rb b/app/models/organization.rb index 9194f21afa6..31d0d57c91d 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -22,4 +22,16 @@ def unique_with_user_handle after_create do record_event!(Events::OrganizationEvent::CREATED, actor_gid: memberships.first&.to_gid) end + + def self.find_by_handle(handle) + not_deleted.find_by("lower(handle) = lower(?)", handle) + end + + def self.find_by_handle!(handle) + find_by_handle(handle) || raise(ActiveRecord::RecordNotFound) + end + + def to_param + handle + end end diff --git a/app/views/dashboards/_subject.html.erb b/app/views/dashboards/_subject.html.erb index 64981449be9..96e171408d4 100644 --- a/app/views/dashboards/_subject.html.erb +++ b/app/views/dashboards/_subject.html.erb @@ -3,40 +3,47 @@ current ||= :dashboard %> -
<%= user.full_name %>
- <% end %> +<%= user.full_name %>
+ <% end %> +<%= - mail_to(user.email, encode: "hex") - %>
-<%= + mail_to(user.email, encode: "hex") + %>
+<%= - link_to( - twitter_username(user), - twitter_url(user) - ) - %>
-<%= + link_to( + twitter_username(user), + twitter_url(user) + ) + %>
+<%= membership.organization.name %>
+ <%= c.list_item_to(organization_path(membership.organization)) do %> +<%= membership.organization.name %>
+<%= membership.organization.handle %>
+<%= membership.role %>
<%= organization.handle %>
++ + <%= icon_tag("organizations", size: 6, class: "-mt-1 -ml-1 mr-1 inline-block") -%><%= t("organizations.show.organization") %> + +
+<%= membership.organization.name %>
+<%= membership.organization.handle %>
+<%= membership.role %>
+<%= membership.user.name %>
+<%= membership.role %>
+