This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added namespaces and teams to search
Signed-off-by: Matheus Fernandes <[email protected]>
- Loading branch information
1 parent
213b734
commit f1a9698
Showing
15 changed files
with
174 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,4 @@ | |
@import 'comments'; | ||
@import 'repositories'; | ||
@import 'responsive-utilities'; | ||
@import 'search'; |
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 @@ | ||
.search { | ||
.category-panel { | ||
.result-counter { | ||
float: right; | ||
background-color: $primary-colour; | ||
border-radius: 0.5rem; | ||
padding: 0 0.5rem; | ||
font-weight: bold; | ||
color: $white; | ||
:hover { | ||
background-color: $primary-colour; | ||
} | ||
} | ||
.nav-pills { | ||
.category { | ||
border-radius: 0; | ||
:hover { | ||
border-radius: 0; | ||
background-color: lighten($gray-light, 15); | ||
} | ||
} | ||
.active-cetegory { | ||
background-color: lighten($gray-light, 15); | ||
border-left: 0.5rem solid $primary-colour; | ||
} | ||
} | ||
.nav-tabs { | ||
.category { | ||
border: 1px solid $gray-light; | ||
border-bottom: 0; | ||
border-top: 0.5rem solid $gray-light; | ||
border-radius: 0.5rem 0.5rem 0 0; | ||
background-color: lighten($gray-light, 15); | ||
} | ||
.active-cetegory { | ||
border-top: 0.5rem solid $primary-colour; | ||
background-color: $white; | ||
} | ||
.result-counter { | ||
margin-left: 1rem; | ||
} | ||
} | ||
} | ||
} |
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,5 @@ | ||
module SearchHelper | ||
def build_search_category_url(params, category) | ||
"#{search_index_path}?utf8=#{params[:utf8]}&search=#{params[:search]}&type=#{category}" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
ul.nav.nav-pills.nav-stacked | ||
li[class="category #{params[:type] == "repositories" ? 'active-cetegory' : ''}"] | ||
a href="#{build_search_category_url params, 'repositories'}" | ||
| Repositories | ||
span.result-counter = @repositories.count | ||
li[class="category #{params[:type] == "namespaces" ? 'active-cetegory' : ''}"] | ||
a href="#{build_search_category_url params, 'namespaces'}" | ||
| Namespaces | ||
span.result-counter = @namespaces.count | ||
li[class="category #{params[:type] == "teams" ? 'active-cetegory' : ''}"] | ||
a href="#{build_search_category_url params, 'teams'}" | ||
| Teams | ||
span.result-counter = @teams.count |
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,13 @@ | ||
ul.nav.nav-tabs | ||
li[class="category #{params[:type] == "repositories" ? 'active-cetegory' : ''}"] | ||
a href="#{build_search_category_url params, 'repositories'}" | ||
| Repositories | ||
span.result-counter = @repositories.count | ||
li[class="category #{params[:type] == "namespaces" ? 'active-cetegory' : ''}"] | ||
a href="#{build_search_category_url params, 'namespaces'}" | ||
| Namespaces | ||
span.result-counter = @namespaces.count | ||
li[class="category #{params[:type] == "teams" ? 'active-cetegory' : ''}"] | ||
a href="#{build_search_category_url params, 'teams'}" | ||
| Teams | ||
span.result-counter = @teams.count |
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,21 @@ | ||
- if @namespaces.empty? | ||
p No match found. | ||
- else | ||
.table-responsive | ||
table.table.table-stripped.table-hover | ||
thead | ||
tr | ||
th Name | ||
th Repositories | ||
th Webhooks | ||
th Created at | ||
tbody | ||
- @namespaces.each do |namespace| | ||
tr id="namespace_#{namespace.id}" | ||
td= link_to namespace.clean_name, namespace | ||
td= namespace.repositories.count | ||
- if current_user.admin? || namespace.team.users.include?(current_user) | ||
td= link_to namespace.webhooks.count, namespace_webhooks_path(namespace) | ||
- else | ||
td= namespace.webhooks.count | ||
td= time_tag namespace.created_at |
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,16 @@ | ||
- if @repositories.empty? | ||
p No match found. | ||
- else | ||
.table-responsive | ||
table.table.table-striped.table-hover | ||
thead | ||
tr | ||
th Namespace | ||
th Repository | ||
th Updated at | ||
tbody | ||
- @repositories.each do |repository| | ||
tr | ||
td= link_to repository.namespace.clean_name, repository.namespace | ||
td= link_to repository.name, repository | ||
td= time_tag repository.updated_at |
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,18 @@ | ||
- if @teams.empty? | ||
p No match found. | ||
- else | ||
.table-responsive | ||
table.table.table-striped.table-hover | ||
thead | ||
tr | ||
th | ||
th Team | ||
th Number of members | ||
th Number of namespaces | ||
tbody#teams | ||
- @teams.each do |team| | ||
tr | ||
td.table-icon= team_scope_icon(team) | ||
td= link_to team.name, team | ||
td= team.users.enabled.count | ||
td= team.namespaces.count |
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,18 +1,18 @@ | ||
.panel.panel-default | ||
.panel-heading | ||
h5 Search results | ||
.panel-body | ||
- if @repositories.empty? | ||
p No match found. | ||
- else | ||
.table-responsive | ||
table.table.table-striped.table-hover | ||
thead | ||
tr | ||
th Namespace | ||
th Repository | ||
tbody | ||
- @repositories.each do |repository| | ||
tr | ||
td= link_to repository.namespace.clean_name, repository.namespace | ||
td= link_to repository.name, repository | ||
.panel-body.search | ||
.row | ||
.col-xs-12.col-md-4.col-lg-3.category-panel | ||
.hidden-xs | ||
= render template: "search/_desktop_categories.html.slim" | ||
.visible-xs | ||
= render template: "search/_mobile_categories.html.slim" | ||
.col-xs-12.col-md-8.col-lg-9.search.search-result | ||
- case params[:type] | ||
- when 'repositories' | ||
= render template: "search/_repositories.html.slim" | ||
-when 'namespaces' | ||
= render template: "search/_namespaces.html.slim" | ||
-when 'teams' | ||
= render template: "search/_teams.html.slim" |
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,12 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe SearchHelper, type: :helper do | ||
|
||
describe "build_search_category_url" do | ||
it "returns true if current user is an owner of the team" do | ||
expected = "#{search_index_path}?utf8=✓&search=&type=repositories" | ||
params = { utf8: "✓", search: "" } | ||
expect(helper.build_search_category_url(params, "repositories")).to eq expected | ||
end | ||
end | ||
end |