-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Details Page Shared projects tab (#227)
* chore: Initial tab setup * chore: Tab setup * chore: Working on navigation tabs * chore: Working tabs with turbo and groups namespace tree * chore: Working query for shared projects * chore: Working project rows * chore: Created a shared partial * chore: Created a no projects shared state * chore: Made emtpy state view component * chore: Made LookBook preview * test: Testing for empty component * test: Added groups show system test * chore: Cleaned up empty states * chore: Updated file comments * chore: Updated file comments * test: Added testing for subgroups controller * test: Added testing for shared projects controller * chore: Removed old test * chore: Disabled rubocop Metrics warning * chore: Code cleanup * chore: Fixed glaky tests * style: Removed border around empty state * chore: Authorize the user to read the subgroup * chore: Authorize user on group * test: Moved group show test into groups
- Loading branch information
Showing
27 changed files
with
311 additions
and
69 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,15 @@ | ||
<div class="flex justify-center py-20 mt-4"> | ||
<div class="flex items-center inline-block"> | ||
<%= viral_icon(name: icon_name, color: :primary, classes: "w-20 h-20 shrink mr-4") %> | ||
<div class="flex flex-col grow"> | ||
<h3 class="text-2xl font-bold dark:text-slate-300 text-slate-700"> | ||
<%= title %> | ||
</h3> | ||
<% if description.present? %> | ||
<p class="text-slate-600 dark:text-slate-400"> | ||
<%= description %> | ||
</p> | ||
<% end %> | ||
</div> | ||
</div> | ||
</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,14 @@ | ||
# frozen_string_literal: true | ||
|
||
module Viral | ||
# A component for displaying an empty state | ||
class EmptyStateComponent < Viral::Component | ||
attr_reader :title, :description, :icon_name | ||
|
||
def initialize(title:, description:, icon_name:) | ||
@title = title | ||
@description = description | ||
@icon_name = icon_name | ||
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,24 @@ | ||
# frozen_string_literal: true | ||
|
||
module Groups | ||
# Controller actions for projects shared with a group | ||
class SharedProjectsController < Groups::ApplicationController | ||
before_action :group, only: %i[index] | ||
|
||
def index | ||
authorize! @group, to: :read? | ||
respond_to do |format| | ||
format.html { redirect_to group_path(@group) } | ||
format.turbo_stream do | ||
@shared_projects = @group.shared_projects | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def group | ||
@group ||= Group.find_by_full_path(request.params[:group_id] || request.params[:id]) # rubocop:disable Rails/DynamicFindBy | ||
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,44 @@ | ||
# frozen_string_literal: true | ||
|
||
module Groups | ||
# Controller actions for group subgroups and projects | ||
class SubgroupsController < ApplicationController | ||
before_action :group, only: %i[index] | ||
|
||
def index | ||
authorize! @group, to: :read? | ||
respond_to do |format| | ||
format.html { redirect_to group_path(@group) } | ||
format.turbo_stream do | ||
if params.key? :parent_id | ||
render_subgroup | ||
else | ||
@namespaces = namespace_children | ||
end | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def render_subgroup | ||
@group = Group.find(params[:parent_id]) | ||
@collapsed = params[:collapse] == 'true' | ||
@children = @collapsed ? Namespace.none : namespace_children | ||
@depth = params[:depth].to_i | ||
render :subgroup | ||
end | ||
|
||
def group | ||
@group ||= Group.find_by_full_path(request.params[:group_id] || request.params[:id]) # rubocop:disable Rails/DynamicFindBy | ||
end | ||
|
||
def namespace_children | ||
@group.children_of_type( | ||
[ | ||
Namespaces::ProjectNamespace.sti_name, Group.sti_name | ||
] | ||
) | ||
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
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,22 @@ | ||
<%= turbo_stream.update "group_show_tab_content" do %> | ||
<% if @shared_projects.length > 0 %> | ||
<table class="min-w-full table-fixed dark:divide-slate-600"> | ||
<tbody | ||
class=" | ||
bg-white | ||
divide-y | ||
divide-slate-200 | ||
dark:bg-slate-800 | ||
dark:divide-slate-700 | ||
" | ||
> | ||
<%= render partial: "shared/project/row", collection: @shared_projects, as: :project %> | ||
</tbody> | ||
</table> | ||
<% else %> | ||
<%= viral_empty( | ||
title: t(:'groups.show.shared_projects.no_shared.title'), | ||
description: t(:'groups.show.shared_projects.no_shared.description'), | ||
icon_name: :rectangle_stack) %> | ||
<% 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,33 +1,66 @@ | ||
<%= render Viral::PageHeaderComponent.new(title: @group.name, subtitle: @group.description) do |component| %> | ||
<%= component.icon do %> | ||
<%= viral_avatar( | ||
name: @group.name, | ||
colour_string: "#{@group.name}-#{@group.id}", | ||
size: :large | ||
) %> | ||
name: @group.name, | ||
colour_string: "#{@group.name}-#{@group.id}", | ||
size: :large | ||
) %> | ||
<% end %> | ||
<%= component.with_buttons do %> | ||
<% if allowed_to?(:new?, @group) %> | ||
<%= link_to t(:"groups.show.create_subgroup_button"), | ||
new_group_path(parent_id: @group.id), | ||
class: "button button--size-default button--state-default" %> | ||
new_group_path(parent_id: @group.id), | ||
class: "button button--size-default button--state-default" %> | ||
<%= link_to t(:"groups.show.create_project_button"), | ||
new_project_path(group_id: @group.id), | ||
class: "button button--size-default button--state-primary ml-2" %> | ||
new_project_path(group_id: @group.id), | ||
class: "button button--size-default button--state-primary ml-2" %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
|
||
<%= viral_tabs(id: "group-details", label: t(:'.tabs.label')) do |tabs| %> | ||
<%= tabs.with_tab(url: "#", controls: "group-details", selected: true) do %> | ||
<%= tabs.with_tab(url: group_path(@group), controls: "group-details", selected: @tab != "shared_projects") do %> | ||
<%= t(:".tabs.subgroups_and_projects") %> | ||
<% end %> | ||
<%= tabs.with_tab(url: group_path(@group, tab: "shared_projects"), controls: "group-projects", selected: @tab == "shared_projects") do %> | ||
<%= t(:'.tabs.shared_projects') %> | ||
<% end %> | ||
|
||
<%= tabs.with_tab_content do %> | ||
<%= turbo_frame_tag "group_show_tab_content", "data-turbo-temporary": true, src: ( | ||
if @tab == "shared_projects" | ||
group_shared_projects_path(@group, format: :turbo_stream) | ||
else | ||
group_subgroups_path(@group, format: :turbo_stream) | ||
end | ||
), loading: :lazy do %> | ||
<table class="min-w-full table-fixed dark:divide-slate-600"> | ||
<tbody | ||
class=" | ||
bg-white | ||
divide-y | ||
divide-slate-200 | ||
dark:bg-slate-800 | ||
dark:divide-slate-700 | ||
" | ||
> | ||
<% 10.times do %> | ||
<tr> | ||
|
||
<td class="p-4 animate-pulse"> | ||
<div class="flex-1 py-1 space-y-6"> | ||
<div class="space-y-3"> | ||
<div class="w-48 h-2 rounded bg-slate-200"></div> | ||
<div class="w-32 h-2 rounded bg-slate-200"></div> | ||
</div> | ||
</div> | ||
</td> | ||
|
||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
|
||
<div class="bg-white dark:bg-gray-800"> | ||
<%= render NamespaceTreeContainerComponent.new( | ||
namespaces: @namespaces, | ||
path: "group_path", | ||
type: [Group.sti_name, Namespaces::ProjectNamespace.sti_name] | ||
) %> | ||
</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,15 @@ | ||
<%= turbo_stream.update "group_show_tab_content" do %> | ||
<% if @namespaces.length > 0 %> | ||
<%= render NamespaceTreeContainerComponent.new( | ||
namespaces: @namespaces, | ||
path: "group_subgroups_path", | ||
path_args: { group_id: @group.full_path }, | ||
type: [Group.sti_name, Namespaces::ProjectNamespace.sti_name] | ||
) %> | ||
<% else %> | ||
<%= viral_empty( | ||
title: t(:"groups.show.subgroups.no_subgroups.title"), | ||
description: t(:'groups.show.subgroups.no_subgroups.description'), | ||
icon_name: :squares_2x2) %> | ||
<% 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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.