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
30564ae0
Commit
30564ae0
authored
Apr 17, 2020
by
Robert Hunt
Committed by
Imre Farkas
Apr 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added new methods to project_settings_helper.rb
These get the title, description and color for each framework
parent
65bad443
Changes
29
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
344 additions
and
40 deletions
+344
-40
app/assets/stylesheets/utilities.scss
app/assets/stylesheets/utilities.scss
+5
-0
app/controllers/dashboard/projects_controller.rb
app/controllers/dashboard/projects_controller.rb
+9
-7
app/controllers/explore/projects_controller.rb
app/controllers/explore/projects_controller.rb
+11
-6
app/controllers/projects/forks_controller.rb
app/controllers/projects/forks_controller.rb
+13
-6
app/controllers/users_controller.rb
app/controllers/users_controller.rb
+5
-2
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+2
-0
app/views/projects/_home_panel.html.haml
app/views/projects/_home_panel.html.haml
+1
-0
app/views/shared/projects/_project.html.haml
app/views/shared/projects/_project.html.haml
+4
-0
ee/app/assets/stylesheets/framework/badges.scss
ee/app/assets/stylesheets/framework/badges.scss
+10
-0
ee/app/assets/stylesheets/pages/projects.scss
ee/app/assets/stylesheets/pages/projects.scss
+8
-0
ee/app/controllers/ee/dashboard/projects_controller.rb
ee/app/controllers/ee/dashboard/projects_controller.rb
+5
-0
ee/app/controllers/ee/explore/projects_controller.rb
ee/app/controllers/ee/explore/projects_controller.rb
+16
-0
ee/app/controllers/ee/projects/forks_controller.rb
ee/app/controllers/ee/projects/forks_controller.rb
+16
-0
ee/app/controllers/ee/users_controller.rb
ee/app/controllers/ee/users_controller.rb
+17
-0
ee/app/helpers/compliance_management/compliance_framework/project_settings_helper.rb
...anagement/compliance_framework/project_settings_helper.rb
+39
-5
ee/app/helpers/ee/projects_helper.rb
ee/app/helpers/ee/projects_helper.rb
+4
-0
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+1
-0
ee/app/views/compliance_management/compliance_framework/_compliance_framework_badge.html.haml
...ompliance_framework/_compliance_framework_badge.html.haml
+10
-0
ee/changelogs/unreleased/add-framework-label-to-projects-page.yml
...elogs/unreleased/add-framework-label-to-projects-page.yml
+5
-0
ee/lib/ee/gitlab/search_results.rb
ee/lib/ee/gitlab/search_results.rb
+16
-0
ee/lib/gitlab/elastic/search_results.rb
ee/lib/gitlab/elastic/search_results.rb
+1
-1
ee/spec/factories/projects.rb
ee/spec/factories/projects.rb
+4
-0
ee/spec/helpers/compliance_management/compliance_framework/project_settings_helper_spec.rb
...ment/compliance_framework/project_settings_helper_spec.rb
+49
-12
ee/spec/helpers/projects_helper_spec.rb
ee/spec/helpers/projects_helper_spec.rb
+14
-0
ee/spec/lib/ee/gitlab/search_results_spec.rb
ee/spec/lib/ee/gitlab/search_results_spec.rb
+30
-0
ee/spec/views/compliance_management/compliance_framework/_compliance_framework_badge.html.haml_spec.rb
...e_framework/_compliance_framework_badge.html.haml_spec.rb
+31
-0
lib/gitlab/search_results.rb
lib/gitlab/search_results.rb
+2
-0
locale/gitlab.pot
locale/gitlab.pot
+15
-0
spec/views/shared/projects/_project.html.haml_spec.rb
spec/views/shared/projects/_project.html.haml_spec.rb
+1
-1
No files found.
app/assets/stylesheets/utilities.scss
View file @
30564ae0
...
@@ -87,6 +87,11 @@
...
@@ -87,6 +87,11 @@
.gl-bg-orange-100
{
@include
gl-bg-orange-100
;
}
.gl-bg-orange-100
{
@include
gl-bg-orange-100
;
}
.gl-bg-gray-100
{
@include
gl-bg-gray-100
;
}
.gl-bg-gray-100
{
@include
gl-bg-gray-100
;
}
.gl-bg-green-100
{
@include
gl-bg-green-100
;}
.gl-bg-green-100
{
@include
gl-bg-green-100
;}
.gl-bg-blue-500
{
@include
gl-bg-blue-500
;
}
.gl-bg-green-500
{
@include
gl-bg-green-500
;
}
.gl-bg-theme-indigo-500
{
@include
gl-bg-theme-indigo-500
;
}
.gl-bg-red-500
{
@include
gl-bg-red-500
;
}
.gl-bg-orange-500
{
@include
gl-bg-orange-500
;
}
.gl-text-blue-500
{
@include
gl-text-blue-500
;
}
.gl-text-blue-500
{
@include
gl-text-blue-500
;
}
.gl-text-gray-500
{
@include
gl-text-gray-500
;
}
.gl-text-gray-500
{
@include
gl-text-gray-500
;
}
...
...
app/controllers/dashboard/projects_controller.rb
View file @
30564ae0
...
@@ -61,22 +61,24 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
...
@@ -61,22 +61,24 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
end
end
end
end
# rubocop: disable CodeReuse/ActiveRecord
def
load_projects
(
finder_params
)
def
load_projects
(
finder_params
)
@total_user_projects_count
=
ProjectsFinder
.
new
(
params:
{
non_public:
true
},
current_user:
current_user
).
execute
@total_user_projects_count
=
ProjectsFinder
.
new
(
params:
{
non_public:
true
},
current_user:
current_user
).
execute
@total_starred_projects_count
=
ProjectsFinder
.
new
(
params:
{
starred:
true
},
current_user:
current_user
).
execute
@total_starred_projects_count
=
ProjectsFinder
.
new
(
params:
{
starred:
true
},
current_user:
current_user
).
execute
finder_params
[
:use_cte
]
=
true
if
use_cte_for_finder?
finder_params
[
:use_cte
]
=
true
if
use_cte_for_finder?
projects
=
ProjectsFinder
projects
=
ProjectsFinder
.
new
(
params:
finder_params
,
current_user:
current_user
).
execute
.
new
(
params:
finder_params
,
current_user:
current_user
)
.
execute
projects
=
preload_associations
(
projects
)
.
includes
(
:route
,
:creator
,
:group
,
namespace:
[
:route
,
:owner
])
projects
=
projects
.
page
(
finder_params
[
:page
])
.
preload
(
:project_feature
)
.
page
(
finder_params
[
:page
])
prepare_projects_for_rendering
(
projects
)
prepare_projects_for_rendering
(
projects
)
end
end
# rubocop: disable CodeReuse/ActiveRecord
def
preload_associations
(
projects
)
projects
.
includes
(
:route
,
:creator
,
:group
,
namespace:
[
:route
,
:owner
]).
preload
(
:project_feature
)
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
def
use_cte_for_finder?
def
use_cte_for_finder?
...
...
app/controllers/explore/projects_controller.rb
View file @
30564ae0
...
@@ -66,18 +66,21 @@ class Explore::ProjectsController < Explore::ApplicationController
...
@@ -66,18 +66,21 @@ class Explore::ProjectsController < Explore::ApplicationController
@total_starred_projects_count
=
ProjectsFinder
.
new
(
params:
{
starred:
true
},
current_user:
current_user
).
execute
@total_starred_projects_count
=
ProjectsFinder
.
new
(
params:
{
starred:
true
},
current_user:
current_user
).
execute
end
end
# rubocop: disable CodeReuse/ActiveRecord
def
load_projects
def
load_projects
load_project_counts
load_project_counts
projects
=
ProjectsFinder
.
new
(
current_user:
current_user
,
params:
params
)
projects
=
ProjectsFinder
.
new
(
current_user:
current_user
,
params:
params
).
execute
.
execute
.
includes
(
:route
,
:creator
,
:group
,
namespace:
[
:route
,
:owner
])
projects
=
preload_associations
(
projects
)
.
page
(
params
[
:page
])
projects
=
projects
.
page
(
params
[
:page
]).
without_count
.
without_count
prepare_projects_for_rendering
(
projects
)
prepare_projects_for_rendering
(
projects
)
end
end
# rubocop: disable CodeReuse/ActiveRecord
def
preload_associations
(
projects
)
projects
.
includes
(
:route
,
:creator
,
:group
,
namespace:
[
:route
,
:owner
])
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
def
set_sorting
def
set_sorting
...
@@ -110,3 +113,5 @@ class Explore::ProjectsController < Explore::ApplicationController
...
@@ -110,3 +113,5 @@ class Explore::ProjectsController < Explore::ApplicationController
end
end
end
end
end
end
Explore
::
ProjectsController
.
prepend_if_ee
(
'EE::Explore::ProjectsController'
)
app/controllers/projects/forks_controller.rb
View file @
30564ae0
...
@@ -13,16 +13,13 @@ class Projects::ForksController < Projects::ApplicationController
...
@@ -13,16 +13,13 @@ class Projects::ForksController < Projects::ApplicationController
before_action
:authorize_fork_project!
,
only:
[
:new
,
:create
]
before_action
:authorize_fork_project!
,
only:
[
:new
,
:create
]
before_action
:authorize_fork_namespace!
,
only:
[
:create
]
before_action
:authorize_fork_namespace!
,
only:
[
:create
]
# rubocop: disable CodeReuse/ActiveRecord
def
index
def
index
@total_forks_count
=
project
.
forks
.
size
@total_forks_count
=
project
.
forks
.
size
@public_forks_count
=
project
.
forks
.
public_only
.
size
@public_forks_count
=
project
.
forks
.
public_only
.
size
@private_forks_count
=
@total_forks_count
-
project
.
forks
.
public_and_internal_only
.
size
@private_forks_count
=
@total_forks_count
-
project
.
forks
.
public_and_internal_only
.
size
@internal_forks_count
=
@total_forks_count
-
@public_forks_count
-
@private_forks_count
@internal_forks_count
=
@total_forks_count
-
@public_forks_count
-
@private_forks_count
@forks
=
ForkProjectsFinder
.
new
(
project
,
params:
params
.
merge
(
search:
params
[
:filter_projects
]),
current_user:
current_user
).
execute
@forks
=
load_forks
.
page
(
params
[
:page
])
@forks
=
@forks
.
includes
(
:route
,
:creator
,
:group
,
namespace:
[
:route
,
:owner
])
.
page
(
params
[
:page
])
prepare_projects_for_rendering
(
@forks
)
prepare_projects_for_rendering
(
@forks
)
...
@@ -36,7 +33,6 @@ class Projects::ForksController < Projects::ApplicationController
...
@@ -36,7 +33,6 @@ class Projects::ForksController < Projects::ApplicationController
end
end
end
end
end
end
# rubocop: enable CodeReuse/ActiveRecord
def
new
def
new
@namespaces
=
fork_service
.
valid_fork_targets
-
[
project
.
namespace
]
@namespaces
=
fork_service
.
valid_fork_targets
-
[
project
.
namespace
]
...
@@ -59,10 +55,19 @@ class Projects::ForksController < Projects::ApplicationController
...
@@ -59,10 +55,19 @@ class Projects::ForksController < Projects::ApplicationController
redirect_to
project_path
(
@forked_project
),
notice:
"The project '
#{
@forked_project
.
name
}
' was successfully forked."
redirect_to
project_path
(
@forked_project
),
notice:
"The project '
#{
@forked_project
.
name
}
' was successfully forked."
end
end
end
end
# rubocop: enable CodeReuse/ActiveRecord
private
private
def
load_forks
forks
=
ForkProjectsFinder
.
new
(
project
,
params:
params
.
merge
(
search:
params
[
:filter_projects
]),
current_user:
current_user
).
execute
forks
.
includes
(
:route
,
:creator
,
:group
,
namespace:
[
:route
,
:owner
])
end
def
fork_service
def
fork_service
strong_memoize
(
:fork_service
)
do
strong_memoize
(
:fork_service
)
do
::
Projects
::
ForkService
.
new
(
project
,
current_user
,
namespace:
fork_namespace
)
::
Projects
::
ForkService
.
new
(
project
,
current_user
,
namespace:
fork_namespace
)
...
@@ -83,3 +88,5 @@ class Projects::ForksController < Projects::ApplicationController
...
@@ -83,3 +88,5 @@ class Projects::ForksController < Projects::ApplicationController
Gitlab
::
QueryLimiting
.
whitelist
(
'https://gitlab.com/gitlab-org/gitlab-foss/issues/42335'
)
Gitlab
::
QueryLimiting
.
whitelist
(
'https://gitlab.com/gitlab-org/gitlab-foss/issues/42335'
)
end
end
end
end
Projects
::
ForksController
.
prepend_if_ee
(
'EE::Projects::ForksController'
)
app/controllers/users_controller.rb
View file @
30564ae0
...
@@ -128,6 +128,10 @@ class UsersController < ApplicationController
...
@@ -128,6 +128,10 @@ class UsersController < ApplicationController
@user
||=
find_routable!
(
User
,
params
[
:username
])
@user
||=
find_routable!
(
User
,
params
[
:username
])
end
end
def
personal_projects
PersonalProjectsFinder
.
new
(
user
).
execute
(
current_user
)
end
def
contributed_projects
def
contributed_projects
ContributedProjectsFinder
.
new
(
user
).
execute
(
current_user
)
ContributedProjectsFinder
.
new
(
user
).
execute
(
current_user
)
end
end
...
@@ -147,8 +151,7 @@ class UsersController < ApplicationController
...
@@ -147,8 +151,7 @@ class UsersController < ApplicationController
end
end
def
load_projects
def
load_projects
@projects
=
@projects
=
personal_projects
PersonalProjectsFinder
.
new
(
user
).
execute
(
current_user
)
.
page
(
params
[
:page
])
.
page
(
params
[
:page
])
.
per
(
params
[
:limit
])
.
per
(
params
[
:limit
])
...
...
app/helpers/projects_helper.rb
View file @
30564ae0
...
@@ -737,3 +737,5 @@ module ProjectsHelper
...
@@ -737,3 +737,5 @@ module ProjectsHelper
can?
(
current_user
,
:destroy_container_image
,
project
)
can?
(
current_user
,
:destroy_container_image
,
project
)
end
end
end
end
ProjectsHelper
.
prepend_if_ee
(
'EE::ProjectsHelper'
)
app/views/projects/_home_panel.html.haml
View file @
30564ae0
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
=
@project
.
name
=
@project
.
name
%span
.visibility-icon.text-secondary.prepend-left-4.has-tooltip
{
data:
{
container:
'body'
},
title:
visibility_icon_description
(
@project
)
}
%span
.visibility-icon.text-secondary.prepend-left-4.has-tooltip
{
data:
{
container:
'body'
},
title:
visibility_icon_description
(
@project
)
}
=
visibility_level_icon
(
@project
.
visibility_level
,
fw:
false
,
options:
{
class:
'icon'
})
=
visibility_level_icon
(
@project
.
visibility_level
,
fw:
false
,
options:
{
class:
'icon'
})
=
render_if_exists
'compliance_management/compliance_framework/compliance_framework_badge'
,
project:
@project
.home-panel-metadata.d-flex.flex-wrap.text-secondary
.home-panel-metadata.d-flex.flex-wrap.text-secondary
-
if
can?
(
current_user
,
:read_project
,
@project
)
-
if
can?
(
current_user
,
:read_project
,
@project
)
%span
.text-secondary
%span
.text-secondary
...
...
app/views/shared/projects/_project.html.haml
View file @
30564ae0
...
@@ -54,6 +54,10 @@
...
@@ -54,6 +54,10 @@
.metadata-info.prepend-top-8
.metadata-info.prepend-top-8
%span
.user-access-role.d-block
=
Gitlab
::
Access
.
human_access
(
access
)
%span
.user-access-role.d-block
=
Gitlab
::
Access
.
human_access
(
access
)
-
if
!
explore_projects_tab?
.metadata-info.prepend-top-8
=
render_if_exists
'compliance_management/compliance_framework/compliance_framework_badge'
,
project:
project
-
if
show_last_commit_as_description
-
if
show_last_commit_as_description
.description.d-none.d-sm-block.append-right-default
.description.d-none.d-sm-block.append-right-default
=
link_to_markdown
(
project
.
commit
.
title
,
project_commit_path
(
project
,
project
.
commit
),
class:
"commit-row-message"
)
=
link_to_markdown
(
project
.
commit
.
title
,
project_commit_path
(
project
,
project
.
commit
),
class:
"commit-row-message"
)
...
...
ee/app/assets/stylesheets/framework/badges.scss
0 → 100644
View file @
30564ae0
.badge.compliance-framework-pill
{
border-radius
:
$label-border-radius
;
color
:
$gray-light
;
display
:
inline-block
;
font-size
:
$gl-font-size-sm
;
font-weight
:
$gl-font-weight-normal
;
line-height
:
$gl-line-height-20
;
padding
:
0
$label-padding
;
vertical-align
:
middle
;
}
ee/app/assets/stylesheets/pages/projects.scss
View file @
30564ae0
...
@@ -68,6 +68,14 @@
...
@@ -68,6 +68,14 @@
}
}
}
}
.projects-list
{
.project-details
{
.compliance-framework-pill
{
margin
:
1px
0
;
}
}
}
.git-clone-holder
{
.git-clone-holder
{
.btn-geo
{
.btn-geo
{
border-left
:
0
;
border-left
:
0
;
...
...
ee/app/controllers/ee/dashboard/projects_controller.rb
View file @
30564ae0
...
@@ -16,6 +16,11 @@ module EE
...
@@ -16,6 +16,11 @@ module EE
super
super
end
end
override
:preload_associations
def
preload_associations
(
projects
)
super
.
with_compliance_framework_settings
end
def
show_onboarding_welcome_page?
def
show_onboarding_welcome_page?
return
false
if
onboarding_cookie_set?
return
false
if
onboarding_cookie_set?
return
false
unless
allow_access_to_onboarding?
return
false
unless
allow_access_to_onboarding?
...
...
ee/app/controllers/ee/explore/projects_controller.rb
0 → 100644
View file @
30564ae0
# frozen_string_literal: true
module
EE
module
Explore
module
ProjectsController
extend
::
Gitlab
::
Utils
::
Override
private
override
:preload_associations
def
preload_associations
(
projects
)
super
.
with_compliance_framework_settings
end
end
end
end
ee/app/controllers/ee/projects/forks_controller.rb
0 → 100644
View file @
30564ae0
# frozen_string_literal: true
module
EE
module
Projects
module
ForksController
extend
::
Gitlab
::
Utils
::
Override
private
override
:load_forks
def
load_forks
super
.
with_compliance_framework_settings
end
end
end
end
ee/app/controllers/ee/users_controller.rb
View file @
30564ae0
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
module
EE
module
EE
module
UsersController
module
UsersController
extend
::
Gitlab
::
Utils
::
Override
def
available_project_templates
def
available_project_templates
load_custom_project_templates
load_custom_project_templates
end
end
...
@@ -12,6 +14,21 @@ module EE
...
@@ -12,6 +14,21 @@ module EE
private
private
override
:personal_projects
def
personal_projects
super
.
with_compliance_framework_settings
end
override
:contributed_projects
def
contributed_projects
super
.
with_compliance_framework_settings
end
override
:starred_projects
def
starred_projects
super
.
with_compliance_framework_settings
end
def
load_custom_project_templates
def
load_custom_project_templates
@custom_project_templates
||=
user
.
available_custom_project_templates
(
search:
params
[
:search
]).
page
(
params
[
:page
])
@custom_project_templates
||=
user
.
available_custom_project_templates
(
search:
params
[
:search
]).
page
(
params
[
:page
])
end
end
...
...
ee/app/helpers/compliance_management/compliance_framework/project_settings_helper.rb
View file @
30564ae0
...
@@ -8,13 +8,47 @@ module ComplianceManagement
...
@@ -8,13 +8,47 @@ module ComplianceManagement
ProjectSettings
.
frameworks
.
map
{
|
k
,
_v
|
[
option_values
.
fetch
(
k
.
to_sym
),
k
]
}
ProjectSettings
.
frameworks
.
map
{
|
k
,
_v
|
[
option_values
.
fetch
(
k
.
to_sym
),
k
]
}
end
end
def
compliance_framework_description
(
framework
)
compliance_framework_option_values
.
fetch
(
framework
.
to_sym
)
end
def
compliance_framework_title
(
framework
)
compliance_framework_title_values
.
fetch
(
framework
.
to_sym
)
end
def
compliance_framework_color
(
framework
)
compliance_framework_color_values
.
fetch
(
framework
.
to_sym
)
end
private
def
compliance_framework_option_values
def
compliance_framework_option_values
{
{
gdpr:
s_
(
'ComplianceFramework|GDPR - General Data Protection Regulation'
),
gdpr:
s_
(
'ComplianceFramework|GDPR - General Data Protection Regulation'
),
hipaa:
s_
(
'ComplianceFramework|HIPAA - Health Insurance Portability and Accountability Act'
),
hipaa:
s_
(
'ComplianceFramework|HIPAA - Health Insurance Portability and Accountability Act'
),
pci_dss:
s_
(
'ComplianceFramework|PCI-DSS - Payment Card Industry-Data Security Standard'
),
pci_dss:
s_
(
'ComplianceFramework|PCI-DSS - Payment Card Industry-Data Security Standard'
),
soc_2:
s_
(
'ComplianceFramework|SOC 2 - Service Organization Control 2'
),
soc_2:
s_
(
'ComplianceFramework|SOC 2 - Service Organization Control 2'
),
sox:
s_
(
'ComplianceFramework|SOX - Sarbanes-Oxley'
)
sox:
s_
(
'ComplianceFramework|SOX - Sarbanes-Oxley'
)
}.
freeze
end
def
compliance_framework_title_values
{
gdpr:
s_
(
'ComplianceFramework|GDPR'
),
hipaa:
s_
(
'ComplianceFramework|HIPAA'
),
pci_dss:
s_
(
'ComplianceFramework|PCI-DSS'
),
soc_2:
s_
(
'ComplianceFramework|SOC 2'
),
sox:
s_
(
'ComplianceFramework|SOX'
)
}.
freeze
end
def
compliance_framework_color_values
{
gdpr:
'gl-bg-green-500'
,
hipaa:
'gl-bg-blue-500'
,
pci_dss:
'gl-bg-theme-indigo-500'
,
soc_2:
'gl-bg-red-500'
,
sox:
'gl-bg-orange-500'
}.
freeze
}.
freeze
end
end
end
end
...
...
ee/app/helpers/ee/projects_helper.rb
View file @
30564ae0
...
@@ -299,5 +299,9 @@ module EE
...
@@ -299,5 +299,9 @@ module EE
def
can_import_members?
def
can_import_members?
super
&&
!
membership_locked?
super
&&
!
membership_locked?
end
end
def
show_compliance_framework_badge?
(
project
)
project
&
.
compliance_framework_setting
&
.
present?
end
end
end
end
end
ee/app/models/ee/project.rb
View file @
30564ae0
...
@@ -150,6 +150,7 @@ module EE
...
@@ -150,6 +150,7 @@ module EE
scope
:with_groups_level_repos_templates
,
->
{
joins
(
"INNER JOIN namespaces ON projects.namespace_id = namespaces.custom_project_templates_group_id"
)
}
scope
:with_groups_level_repos_templates
,
->
{
joins
(
"INNER JOIN namespaces ON projects.namespace_id = namespaces.custom_project_templates_group_id"
)
}
scope
:with_designs
,
->
{
where
(
id:
DesignManagement
::
Design
.
select
(
:project_id
))
}
scope
:with_designs
,
->
{
where
(
id:
DesignManagement
::
Design
.
select
(
:project_id
))
}
scope
:with_deleting_user
,
->
{
includes
(
:deleting_user
)
}
scope
:with_deleting_user
,
->
{
includes
(
:deleting_user
)
}
scope
:with_compliance_framework_settings
,
->
{
preload
(
:compliance_framework_setting
)
}
delegate
:shared_runners_minutes
,
:shared_runners_seconds
,
:shared_runners_seconds_last_reset
,
delegate
:shared_runners_minutes
,
:shared_runners_seconds
,
:shared_runners_seconds_last_reset
,
to: :statistics
,
allow_nil:
true
to: :statistics
,
allow_nil:
true
...
...
ee/app/views/compliance_management/compliance_framework/_compliance_framework_badge.html.haml
0 → 100644
View file @
30564ae0
-
project
=
local_assigns
.
fetch
(
:project
)
-
if
show_compliance_framework_badge?
(
project
)
-
framework
=
project
.
compliance_framework_setting
.
framework
-
color
=
compliance_framework_color
(
framework
)
-
title
=
compliance_framework_title
(
framework
)
-
description
=
compliance_framework_description
(
framework
)
%span
.badge.compliance-framework-pill.ml-2.has-tooltip
{
class:
color
,
data:
{
container:
'body'
},
title:
description
}
=
title
ee/changelogs/unreleased/add-framework-label-to-projects-page.yml
0 → 100644
View file @
30564ae0
---
title
:
Add the selected compliance frameworks label to project home and listings
merge_request
:
29137
author
:
type
:
added
ee/lib/ee/gitlab/search_results.rb
0 → 100644
View file @
30564ae0
# frozen_string_literal: true
module
EE
module
Gitlab
module
SearchResults
extend
::
Gitlab
::
Utils
::
Override
private
override
:projects
def
projects
super
.
with_compliance_framework_settings
end
end
end
end
ee/lib/gitlab/elastic/search_results.rb
View file @
30564ae0
...
@@ -27,7 +27,7 @@ module Gitlab
...
@@ -27,7 +27,7 @@ module Gitlab
case
scope
case
scope
when
'projects'
when
'projects'
eager_load
(
projects
,
page
,
eager:
[
:route
,
:namespace
])
eager_load
(
projects
,
page
,
eager:
[
:route
,
:namespace
,
:compliance_framework_setting
])
when
'issues'
when
'issues'
eager_load
(
issues
,
page
,
eager:
{
project:
[
:route
,
:namespace
]
})
eager_load
(
issues
,
page
,
eager:
{
project:
[
:route
,
:namespace
]
})
when
'merge_requests'
when
'merge_requests'
...
...
ee/spec/factories/projects.rb
View file @
30564ae0
...
@@ -91,5 +91,9 @@ FactoryBot.modify do
...
@@ -91,5 +91,9 @@ FactoryBot.modify do
create_list
(
:vulnerability
,
2
,
:detected
,
project:
project
)
create_list
(
:vulnerability
,
2
,
:detected
,
project:
project
)
end
end
end
end
trait
:with_compliance_framework
do
association
:compliance_framework_setting
,
factory: :compliance_framework_project_setting
end
end
end
end
end
ee/spec/helpers/compliance_management/compliance_framework/project_settings_helper_spec.rb
View file @
30564ae0
...
@@ -3,26 +3,63 @@
...
@@ -3,26 +3,63 @@
require
'spec_helper'
require
'spec_helper'
describe
ComplianceManagement
::
ComplianceFramework
::
ProjectSettingsHelper
do
describe
ComplianceManagement
::
ComplianceFramework
::
ProjectSettingsHelper
do
let
(
:frameworks
)
{
ComplianceManagement
::
ComplianceFramework
::
ProjectSettings
.
frameworks
.
keys
}
let
(
:descriptions
)
{
helper
.
compliance_framework_option_values
}
describe
'#compliance_framework_options'
do
describe
'#compliance_framework_options'
do
it
'has all the descriptions'
do
it
'has all the options'
do
expect
(
helper
.
compliance_framework_options
.
map
(
&
:first
)).
to
eq
(
descriptions
.
map
(
&
:last
))
expect
(
helper
.
compliance_framework_options
).
to
contain_exactly
(
[
'GDPR - General Data Protection Regulation'
,
'gdpr'
],
[
'HIPAA - Health Insurance Portability and Accountability Act'
,
'hipaa'
],
[
'PCI-DSS - Payment Card Industry-Data Security Standard'
,
'pci_dss'
],
[
'SOC 2 - Service Organization Control 2'
,
'soc_2'
],
[
'SOX - Sarbanes-Oxley'
,
'sox'
]
)
end
end
describe
'#compliance_framework_description'
do
using
RSpec
::
Parameterized
::
TableSyntax
where
(
:framework
,
:description
)
do
:gdpr
|
'GDPR - General Data Protection Regulation'
:hipaa
|
'HIPAA - Health Insurance Portability and Accountability Act'
:pci_dss
|
'PCI-DSS - Payment Card Industry-Data Security Standard'
:soc_2
|
'SOC 2 - Service Organization Control 2'
:sox
|
'SOX - Sarbanes-Oxley'
end
with_them
do
it
{
expect
(
helper
.
compliance_framework_description
(
framework
)).
to
eq
(
description
)
}
end
end
describe
'#compliance_framework_title'
do
using
RSpec
::
Parameterized
::
TableSyntax
where
(
:framework
,
:title
)
do
:gdpr
|
'GDPR'
:hipaa
|
'HIPAA'
:pci_dss
|
'PCI-DSS'
:soc_2
|
'SOC 2'
:sox
|
'SOX'
end
end
it
'has all the frameworks'
do
with_them
do
expect
(
helper
.
compliance_framework_options
.
map
(
&
:last
)).
to
eq
(
frameworks
)
it
{
expect
(
helper
.
compliance_framework_title
(
framework
)).
to
eq
(
title
)
}
end
end
end
end
describe
'#compliance_framework_option_values'
do
describe
'#compliance_framework_color'
do
it
'returns a hash'
do
using
RSpec
::
Parameterized
::
TableSyntax
expect
(
helper
.
compliance_framework_option_values
).
to
be_a_kind_of
(
Hash
)
where
(
:framework
,
:color
)
do
:gdpr
|
'gl-bg-green-500'
:hipaa
|
'gl-bg-blue-500'
:pci_dss
|
'gl-bg-theme-indigo-500'
:soc_2
|
'gl-bg-red-500'
:sox
|
'gl-bg-orange-500'
end
end
it
'is the same length as frameworks'
do
with_them
do
expect
(
helper
.
compliance_framework_option_values
.
length
).
to
equal
(
frameworks
.
length
)
it
{
expect
(
helper
.
compliance_framework_color
(
framework
)).
to
eq
(
color
)
}
end
end
end
end
end
end
ee/spec/helpers/projects_helper_spec.rb
View file @
30564ae0
...
@@ -38,6 +38,20 @@ describe ProjectsHelper do
...
@@ -38,6 +38,20 @@ describe ProjectsHelper do
end
end
end
end
describe
'#show_compliance_framework_badge?'
do
it
'returns false if compliance framework setting is not present'
do
project
=
build
(
:project
)
expect
(
helper
.
show_compliance_framework_badge?
(
project
)).
to
be_falsey
end
it
'returns true if compliance framework setting is present'
do
project
=
build
(
:project
,
:with_compliance_framework
)
expect
(
helper
.
show_compliance_framework_badge?
(
project
)).
to
be_truthy
end
end
describe
'#membership_locked?'
do
describe
'#membership_locked?'
do
let
(
:project
)
{
build_stubbed
(
:project
,
group:
group
)
}
let
(
:project
)
{
build_stubbed
(
:project
,
group:
group
)
}
let
(
:group
)
{
nil
}
let
(
:group
)
{
nil
}
...
...
ee/spec/lib/ee/gitlab/search_results_spec.rb
0 → 100644
View file @
30564ae0
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
SearchResults
do
let
(
:user
)
{
build
(
:user
)
}
let_it_be
(
:compliance_project
)
{
create
(
:project
,
:with_compliance_framework
,
name:
'foo'
)
}
subject
{
described_class
.
new
(
user
,
Project
.
all
,
'foo'
)
}
describe
'#projects'
do
it
'avoid N+1 queries'
do
control
=
ActiveRecord
::
QueryRecorder
.
new
{
search
}
create_list
(
:project
,
2
,
:with_compliance_framework
,
name:
'foo'
)
# Expected queries when searching for Projects
#
# 1. On the projects table
# 2. On the project_compliance_framework_settings table for framework names
#
expect
{
search
}.
not_to
exceed_query_limit
(
control
)
end
end
def
search
subject
.
objects
(
'projects'
).
map
{
|
project
|
project
.
compliance_framework_setting
.
framework
}
end
end
ee/spec/views/compliance_management/compliance_framework/_compliance_framework_badge.html.haml_spec.rb
0 → 100644
View file @
30564ae0
# frozen_string_literal: true
require
'spec_helper'
describe
'compliance_management/compliance_framework/_compliance_framework_badge.html.haml'
do
let_it_be
(
:project
)
{
build
(
:project
,
:with_compliance_framework
)
}
before
do
allow
(
view
).
to
receive
(
:show_compliance_framework_badge?
).
and_return
(
flag
)
end
context
'when show'
do
let
(
:flag
)
{
true
}
it
'renders a badge'
do
render
(
'compliance_management/compliance_framework/compliance_framework_badge'
,
project:
project
)
expect
(
rendered
).
to
have_selector
(
'.compliance-framework-pill'
)
end
end
context
'when not show'
do
let
(
:flag
)
{
false
}
it
'does not render any badge'
do
render
(
'compliance_management/compliance_framework/compliance_framework_badge'
,
project:
project
)
expect
(
rendered
).
not_to
have_selector
(
'.compliance-framework-pill'
)
end
end
end
lib/gitlab/search_results.rb
View file @
30564ae0
...
@@ -194,3 +194,5 @@ module Gitlab
...
@@ -194,3 +194,5 @@ module Gitlab
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
end
end
end
end
Gitlab
::
SearchResults
.
prepend_if_ee
(
'EE::Gitlab::SearchResults'
)
locale/gitlab.pot
View file @
30564ae0
...
@@ -5309,18 +5309,33 @@ msgstr ""
...
@@ -5309,18 +5309,33 @@ msgstr ""
msgid "Compliance framework (optional)"
msgid "Compliance framework (optional)"
msgstr ""
msgstr ""
msgid "ComplianceFramework|GDPR"
msgstr ""
msgid "ComplianceFramework|GDPR - General Data Protection Regulation"
msgid "ComplianceFramework|GDPR - General Data Protection Regulation"
msgstr ""
msgstr ""
msgid "ComplianceFramework|HIPAA"
msgstr ""
msgid "ComplianceFramework|HIPAA - Health Insurance Portability and Accountability Act"
msgid "ComplianceFramework|HIPAA - Health Insurance Portability and Accountability Act"
msgstr ""
msgstr ""
msgid "ComplianceFramework|PCI-DSS"
msgstr ""
msgid "ComplianceFramework|PCI-DSS - Payment Card Industry-Data Security Standard"
msgid "ComplianceFramework|PCI-DSS - Payment Card Industry-Data Security Standard"
msgstr ""
msgstr ""
msgid "ComplianceFramework|SOC 2"
msgstr ""
msgid "ComplianceFramework|SOC 2 - Service Organization Control 2"
msgid "ComplianceFramework|SOC 2 - Service Organization Control 2"
msgstr ""
msgstr ""
msgid "ComplianceFramework|SOX"
msgstr ""
msgid "ComplianceFramework|SOX - Sarbanes-Oxley"
msgid "ComplianceFramework|SOX - Sarbanes-Oxley"
msgstr ""
msgstr ""
...
...
spec/views/shared/projects/_project.html.haml_spec.rb
View file @
30564ae0
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
require
'spec_helper'
require
'spec_helper'
describe
'shared/projects/_project.html.haml'
do
describe
'shared/projects/_project.html.haml'
do
let
(
:project
)
{
create
(
:project
)
}
let
_it_be
(
:project
)
{
create
(
:project
)
}
before
do
before
do
allow
(
view
).
to
receive
(
:current_application_settings
).
and_return
(
Gitlab
::
CurrentSettings
.
current_application_settings
)
allow
(
view
).
to
receive
(
:current_application_settings
).
and_return
(
Gitlab
::
CurrentSettings
.
current_application_settings
)
...
...
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