-
Notifications
You must be signed in to change notification settings - Fork 25
Adds discover feature with organizations listing #236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,16 @@ | ||
<div class="du-card bg-base-100 shadow-sm max-w-xl"> | ||
<% if image? %> | ||
<%= image %> | ||
<% end %> | ||
<div class="du-card-body"> | ||
<h2 class="du-card-title"><%= title %></h2> | ||
<p><%= description %></p> | ||
<div class="du-card-actions justify-end"> | ||
<% if actions? %> | ||
<% actions.each do |action| %> | ||
<%= action %> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> |
This file contains hidden or 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,13 @@ | ||
# frozen_string_literal: true | ||
|
||
class CardComponent < ViewComponent::Base | ||
renders_one :image | ||
renders_many :actions | ||
|
||
attr_reader :title, :description | ||
|
||
def initialize(title:, description:) | ||
@title = title | ||
@description = description | ||
end | ||
end |
This file contains hidden or 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,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class DiscoversController < ApplicationController | ||
def show | ||
@organizations = Organization.not_privacy_setting_private | ||
end | ||
end |
This file contains hidden or 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 hidden or 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 @@ | ||
<%= render CardComponent.new(title: organization.name, description: "Members: #{organization.users.count}") do |card| %> | ||
<% card.with_image do %> | ||
<%= organization_avatar(organization, classes: "max-w-full h-80 object-cover") %> | ||
<% end %> | ||
<% card.with_action do %> | ||
<% if organization.participant?(current_user) %> | ||
<%= link_to t("discovers.show.actions.open"), organization_dashboard_path(organization), class: "du-btn du-btn-primary" %> | ||
<% else %> | ||
<%= button_to t("discovers.show.actions.#{organization.privacy_setting_public? ? "join" : "request_to_join"}"), "#", | ||
method: :post, | ||
class: "du-btn du-btn-primary" %> | ||
<% end %> | ||
<% end %> | ||
<% end %> |
This file contains hidden or 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,9 @@ | ||
<% content_for :title, t(".title") %> | ||
|
||
<%= render PageComponent.new(title: t(".page_title"), full_width: true) do |component| %> | ||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4"> | ||
<% @organizations.each do |organization| %> | ||
<%= render "discovers/organization", organization: organization %> | ||
<% end %> | ||
</div> | ||
<% end %> |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 | ||
|
||
require "test_helper" | ||
|
||
class CardComponentTest < ViewComponent::TestCase | ||
def test_render_card_component | ||
render_inline(CardComponent.new(title: "Hello, card!", description: "This is a test card.")) | ||
|
||
assert_component_rendered | ||
|
||
assert_text "Hello, card!" | ||
assert_text "This is a test card." | ||
end | ||
end |
This file contains hidden or 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,32 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class DiscoversControllerTest < ActionDispatch::IntegrationTest | ||
test "should get show" do | ||
sign_in users(:one) | ||
|
||
get discover_path | ||
assert_response :success | ||
end | ||
|
||
test "should not get show if not signed in" do | ||
get discover_path | ||
assert_redirected_to new_user_session_path | ||
end | ||
|
||
test "should see only public and restricted organizations" do | ||
sign_in users(:one) | ||
|
||
organization1 = Organization.create!(privacy_setting: :public, owner: users(:one), name: "Organization One") | ||
organization2 = Organization.create!(privacy_setting: :restricted, owner: users(:one), name: "Organization Two") | ||
organization3 = Organization.create!(privacy_setting: :private, owner: users(:one), name: "Organization Three") | ||
|
||
get discover_path | ||
assert_response :success | ||
assert_select "h1", I18n.t("discovers.show.page_title") | ||
assert_includes response.body, organization1.name | ||
assert_includes response.body, organization2.name | ||
assert_not_includes response.body, organization3.name | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍