Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
b8289846
Commit
b8289846
authored
Nov 01, 2018
by
Gabriel Mazetto
Committed by
Douglas Barbosa Alexandre
Nov 01, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a search bar to `Admin > Geo > Projects`
parent
d464f52e
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
223 additions
and
1 deletion
+223
-1
app/views/shared/projects/_search_form.html.haml
app/views/shared/projects/_search_form.html.haml
+2
-0
ee/app/controllers/admin/geo/projects_controller.rb
ee/app/controllers/admin/geo/projects_controller.rb
+4
-0
ee/app/models/geo/fdw/project.rb
ee/app/models/geo/fdw/project.rb
+16
-0
ee/app/models/geo/project_registry.rb
ee/app/models/geo/project_registry.rb
+10
-0
ee/app/views/admin/geo/projects/index.html.haml
ee/app/views/admin/geo/projects/index.html.haml
+2
-0
ee/app/views/shared/projects/_search_fields.html.haml
ee/app/views/shared/projects/_search_fields.html.haml
+2
-0
ee/changelogs/unreleased/8121-geo-search-bar.yml
ee/changelogs/unreleased/8121-geo-search-bar.yml
+5
-0
ee/spec/features/admin/geo/admin_geo_nodes_spec.rb
ee/spec/features/admin/geo/admin_geo_nodes_spec.rb
+0
-0
ee/spec/features/admin/geo/admin_geo_projects_spec.rb
ee/spec/features/admin/geo/admin_geo_projects_spec.rb
+101
-0
ee/spec/models/geo/fdw/project_spec.rb
ee/spec/models/geo/fdw/project_spec.rb
+46
-0
ee/spec/models/geo/project_registry_spec.rb
ee/spec/models/geo/project_registry_spec.rb
+35
-1
No files found.
app/views/shared/projects/_search_form.html.haml
View file @
b8289846
...
@@ -21,3 +21,5 @@
...
@@ -21,3 +21,5 @@
-
if
params
[
:visibility_level
].
present?
-
if
params
[
:visibility_level
].
present?
=
hidden_field_tag
:visibility_level
,
params
[
:visibility_level
]
=
hidden_field_tag
:visibility_level
,
params
[
:visibility_level
]
=
render_if_exists
'shared/projects/search_fields'
ee/app/controllers/admin/geo/projects_controller.rb
View file @
b8289846
...
@@ -21,6 +21,10 @@ class Admin::Geo::ProjectsController < Admin::ApplicationController
...
@@ -21,6 +21,10 @@ class Admin::Geo::ProjectsController < Admin::ApplicationController
else
else
finder
.
all_projects
.
page
(
params
[
:page
])
finder
.
all_projects
.
page
(
params
[
:page
])
end
end
if
params
[
:name
]
@registries
=
@registries
.
with_search
(
params
[
:name
])
end
end
end
def
destroy
def
destroy
...
...
ee/app/models/geo/fdw/project.rb
View file @
b8289846
# frozen_string_literal: true
module
Geo
module
Geo
module
Fdw
module
Fdw
class
Project
<
::
Geo
::
BaseFdw
class
Project
<
::
Geo
::
BaseFdw
include
Gitlab
::
SQL
::
Pattern
self
.
table_name
=
Gitlab
::
Geo
::
Fdw
.
table
(
'projects'
)
self
.
table_name
=
Gitlab
::
Geo
::
Fdw
.
table
(
'projects'
)
class
<<
self
# Searches for a list of projects based on the query given in `query`.
#
# On PostgreSQL this method uses "ILIKE" to perform a case-insensitive
# search.
#
# query - The search query as a String.
def
search
(
query
)
fuzzy_search
(
query
,
[
:path
,
:name
,
:description
])
end
end
end
end
end
end
end
end
ee/app/models/geo/project_registry.rb
View file @
b8289846
# frozen_string_literal: true
class
Geo::ProjectRegistry
<
Geo
::
BaseRegistry
class
Geo::ProjectRegistry
<
Geo
::
BaseRegistry
include
::
Delay
include
::
Delay
include
::
EachBatch
include
::
EachBatch
...
@@ -78,6 +80,14 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
...
@@ -78,6 +80,14 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
)
)
end
end
# Search for a list of projects associated with registries,
# based on the query given in `query`.
#
# @param [String] query term that will search over :path, :name and :description
def
self
.
with_search
(
query
)
where
(
project:
Geo
::
Fdw
::
Project
.
search
(
query
))
end
# Must be run before fetching the repository to avoid a race condition
# Must be run before fetching the repository to avoid a race condition
#
#
# @param [String] type must be one of the values in TYPES
# @param [String] type must be one of the values in TYPES
...
...
ee/app/views/admin/geo/projects/index.html.haml
View file @
b8289846
...
@@ -22,6 +22,8 @@
...
@@ -22,6 +22,8 @@
=
nav_link
(
html_options:
{
class:
active_when
(
params
[
:sync_status
]
==
'never'
)
})
do
=
nav_link
(
html_options:
{
class:
active_when
(
params
[
:sync_status
]
==
'never'
)
})
do
=
link_to
admin_geo_projects_path
(
sync_status:
'never'
)
do
=
link_to
admin_geo_projects_path
(
sync_status:
'never'
)
do
=
s_
(
'Geo|Never'
)
=
s_
(
'Geo|Never'
)
.nav-controls
=
render
(
partial:
'shared/projects/search_form'
,
autofocus:
true
)
-
case
params
[
:sync_status
]
-
case
params
[
:sync_status
]
-
when
'never'
-
when
'never'
...
...
ee/app/views/shared/projects/_search_fields.html.haml
0 → 100644
View file @
b8289846
-
if
params
[
:sync_status
].
present?
=
hidden_field_tag
:sync_status
,
params
[
:sync_status
]
ee/changelogs/unreleased/8121-geo-search-bar.yml
0 → 100644
View file @
b8289846
---
title
:
Added a search bar to `Admin > Geo > Projects`
merge_request
:
8079
author
:
type
:
changed
ee/spec/features/admin/admin_geo_nodes_spec.rb
→
ee/spec/features/admin/
geo/
admin_geo_nodes_spec.rb
View file @
b8289846
File moved
ee/spec/features/admin/geo/admin_geo_projects_spec.rb
0 → 100644
View file @
b8289846
# frozen_string_literal: true
require
'spec_helper'
describe
'admin Geo Projects'
,
:js
,
:geo
do
let!
(
:geo_node
)
{
create
(
:geo_node
)
}
let!
(
:synced_registry
)
{
create
(
:geo_project_registry
,
:synced
,
:repository_verified
)
}
let!
(
:sync_pending_registry
)
{
create
(
:geo_project_registry
,
:synced
,
:repository_dirty
)
}
let!
(
:sync_failed_registry
)
{
create
(
:geo_project_registry
,
:existing_repository_sync_failed
)
}
let!
(
:never_synced_registry
)
{
create
(
:geo_project_registry
)
}
before
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:license_allows?
).
and_return
(
true
)
sign_in
(
create
(
:admin
))
end
describe
'visiting geo projects initial page'
do
let
(
:page_url
)
{
admin_geo_projects_path
}
before
do
visit
(
page_url
)
wait_for_requests
end
it
'shows all projects in the registry'
do
page
.
within
(
find
(
'#content-body'
,
match: :first
))
do
expect
(
page
).
to
have_content
(
synced_registry
.
project
.
full_name
)
expect
(
page
).
to
have_content
(
sync_pending_registry
.
project
.
full_name
)
expect
(
page
).
to
have_content
(
sync_failed_registry
.
project
.
full_name
)
expect
(
page
).
to
have_content
(
never_synced_registry
.
project
.
full_name
)
end
end
describe
'searching for a geo project'
do
it
'filters out projects with the search term'
do
fill_in
:name
,
with:
synced_registry
.
project
.
name
find
(
'#project-filter-form-field'
).
native
.
send_keys
(
:enter
)
wait_for_requests
page
.
within
(
find
(
'#content-body'
,
match: :first
))
do
expect
(
page
).
to
have_content
(
synced_registry
.
project
.
full_name
)
expect
(
page
).
not_to
have_content
(
sync_pending_registry
.
project
.
full_name
)
expect
(
page
).
not_to
have_content
(
sync_failed_registry
.
project
.
full_name
)
expect
(
page
).
not_to
have_content
(
never_synced_registry
.
project
.
full_name
)
end
end
end
end
describe
'visiting specific tab in geo projects page'
do
let
(
:page_url
)
{
admin_geo_projects_path
}
before
do
visit
(
page_url
)
wait_for_requests
click_link_or_button
(
'Pending'
)
wait_for_requests
end
it
'shows tab specific projects'
do
page
.
within
(
find
(
'#content-body'
,
match: :first
))
do
expect
(
page
).
not_to
have_content
(
synced_registry
.
project
.
full_name
)
expect
(
page
).
to
have_content
(
sync_pending_registry
.
project
.
full_name
)
expect
(
page
).
not_to
have_content
(
sync_failed_registry
.
project
.
full_name
)
expect
(
page
).
not_to
have_content
(
never_synced_registry
.
project
.
full_name
)
end
end
describe
'searching for a geo project'
do
it
'finds the project with the same name'
do
fill_in
:name
,
with:
sync_pending_registry
.
project
.
name
find
(
'#project-filter-form-field'
).
native
.
send_keys
(
:enter
)
wait_for_requests
page
.
within
(
find
(
'#content-body'
,
match: :first
))
do
expect
(
page
).
not_to
have_content
(
synced_registry
.
project
.
full_name
)
expect
(
page
).
to
have_content
(
sync_pending_registry
.
project
.
full_name
)
expect
(
page
).
not_to
have_content
(
sync_failed_registry
.
project
.
full_name
)
expect
(
page
).
not_to
have_content
(
never_synced_registry
.
project
.
full_name
)
end
end
it
'filters out project that matches with search but shouldnt be in the tab'
do
fill_in
:name
,
with:
synced_registry
.
project
.
name
find
(
'#project-filter-form-field'
).
native
.
send_keys
(
:enter
)
wait_for_requests
page
.
within
(
find
(
'#content-body'
,
match: :first
))
do
expect
(
page
).
not_to
have_content
(
synced_registry
.
project
.
full_name
)
expect
(
page
).
not_to
have_content
(
sync_pending_registry
.
project
.
full_name
)
expect
(
page
).
not_to
have_content
(
sync_failed_registry
.
project
.
full_name
)
expect
(
page
).
not_to
have_content
(
never_synced_registry
.
project
.
full_name
)
end
end
end
end
end
ee/spec/models/geo/fdw/project_spec.rb
0 → 100644
View file @
b8289846
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Geo
::
Fdw
::
Project
,
:geo
,
type: :model
do
describe
'.search'
do
set
(
:test_project
)
{
create
(
:project
,
description:
'kitten mittens'
)
}
set
(
:project
)
{
described_class
.
find
(
test_project
.
id
)
}
it
'returns projects with a matching name'
do
expect
(
described_class
.
search
(
project
.
name
)).
to
eq
([
project
])
end
it
'returns projects with a partially matching name'
do
expect
(
described_class
.
search
(
project
.
name
[
0
..
2
])).
to
eq
([
project
])
end
it
'returns projects with a matching name regardless of the casing'
do
expect
(
described_class
.
search
(
project
.
name
.
upcase
)).
to
eq
([
project
])
end
it
'returns projects with a matching description'
do
expect
(
described_class
.
search
(
project
.
description
)).
to
eq
([
project
])
end
it
'returns projects with a partially matching description'
do
expect
(
described_class
.
search
(
'kitten'
)).
to
eq
([
project
])
end
it
'returns projects with a matching description regardless of the casing'
do
expect
(
described_class
.
search
(
'KITTEN'
)).
to
eq
([
project
])
end
it
'returns projects with a matching path'
do
expect
(
described_class
.
search
(
project
.
path
)).
to
eq
([
project
])
end
it
'returns projects with a partially matching path'
do
expect
(
described_class
.
search
(
project
.
path
[
0
..
2
])).
to
eq
([
project
])
end
it
'returns projects with a matching path regardless of the casing'
do
expect
(
described_class
.
search
(
project
.
path
.
upcase
)).
to
eq
([
project
])
end
end
end
ee/spec/models/geo/project_registry_spec.rb
View file @
b8289846
...
@@ -3,7 +3,7 @@ require 'spec_helper'
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
Geo
::
ProjectRegistry
do
describe
Geo
::
ProjectRegistry
do
using
RSpec
::
Parameterized
::
TableSyntax
using
RSpec
::
Parameterized
::
TableSyntax
set
(
:project
)
{
create
(
:project
)
}
set
(
:project
)
{
create
(
:project
,
description:
'kitten mittens'
)
}
set
(
:registry
)
{
create
(
:geo_project_registry
,
project_id:
project
.
id
)
}
set
(
:registry
)
{
create
(
:geo_project_registry
,
project_id:
project
.
id
)
}
subject
{
registry
}
subject
{
registry
}
...
@@ -141,6 +141,40 @@ describe Geo::ProjectRegistry do
...
@@ -141,6 +141,40 @@ describe Geo::ProjectRegistry do
end
end
end
end
describe
'.with_search'
,
:geo
do
it
'returns project registries that refers to projects with a matching name'
do
expect
(
described_class
.
with_search
(
project
.
name
)).
to
eq
([
registry
])
end
it
'returns project registries that refers to projects with a matching name regardless of the casing'
do
expect
(
described_class
.
with_search
(
project
.
name
.
upcase
)).
to
eq
([
registry
])
end
it
'returns project registries that refers to projects with a matching description'
do
expect
(
described_class
.
with_search
(
project
.
description
)).
to
eq
([
registry
])
end
it
'returns project registries that refers to projects with a partially matching description'
do
expect
(
described_class
.
with_search
(
'kitten'
)).
to
eq
([
registry
])
end
it
'returns project registries that refers to projects with a matching description regardless of the casing'
do
expect
(
described_class
.
with_search
(
'KITTEN'
)).
to
eq
([
registry
])
end
it
'returns project registries that refers to projects with a matching path'
do
expect
(
described_class
.
with_search
(
project
.
path
)).
to
eq
([
registry
])
end
it
'returns project registries that refers to projects with a partially matching path'
do
expect
(
described_class
.
with_search
(
project
.
path
[
0
..
2
])).
to
eq
([
registry
])
end
it
'returns project registries that refers to projects with a matching path regardless of the casing'
do
expect
(
described_class
.
with_search
(
project
.
path
.
upcase
)).
to
eq
([
registry
])
end
end
describe
'#repository_sync_due?'
do
describe
'#repository_sync_due?'
do
where
(
:last_synced_at
,
:resync
,
:retry_at
,
:expected
)
do
where
(
:last_synced_at
,
:resync
,
:retry_at
,
:expected
)
do
now
=
Time
.
now
now
=
Time
.
now
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment