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
d36a4504
Commit
d36a4504
authored
Sep 20, 2018
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix code structure
parent
542763ff
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
32 deletions
+44
-32
app/controllers/projects/feature_flags_controller.rb
app/controllers/projects/feature_flags_controller.rb
+7
-7
app/models/operations/feature_flag.rb
app/models/operations/feature_flag.rb
+14
-10
app/models/operations/feature_flag_access_token.rb
app/models/operations/feature_flag_access_token.rb
+0
-12
app/models/operations/feature_flags_access_token.rb
app/models/operations/feature_flags_access_token.rb
+16
-0
app/models/project.rb
app/models/project.rb
+6
-2
lib/api/entities.rb
lib/api/entities.rb
+1
-1
No files found.
app/controllers/projects/feature_flags_controller.rb
View file @
d36a4504
...
...
@@ -8,16 +8,16 @@ class Projects::FeatureFlagsController < Projects::ApplicationController
before_action
:feature_flag
,
only:
[
:edit
,
:update
,
:destroy
]
def
index
@feature_flags
=
project
.
project
_feature_flags
@unleash_instanceid
=
project
.
project_feature_flags_access_tokens
.
first
&
.
token
||
project
.
project_feature_flags_access_tokens
.
create!
.
token
@feature_flags
=
project
.
operations
_feature_flags
@unleash_instanceid
=
project
.
feature_flag_access_
token
end
def
new
@feature_flag
=
project
.
project
_feature_flags
.
new
@feature_flag
=
project
.
operations
_feature_flags
.
new
end
def
create
@feature_flag
=
project
.
project
_feature_flags
.
create
(
create_params
)
@feature_flag
=
project
.
operations
_feature_flags
.
create
(
create_params
)
if
@feature_flag
.
persisted?
flash
[
:notice
]
=
'Feature flag was successfully created.'
...
...
@@ -50,16 +50,16 @@ class Projects::FeatureFlagsController < Projects::ApplicationController
protected
def
feature_flag
@feature_flag
||=
project
.
project
_feature_flags
.
find
(
params
[
:id
])
@feature_flag
||=
project
.
operations
_feature_flags
.
find
(
params
[
:id
])
end
def
create_params
params
.
require
(
:
project
_feature_flag
)
params
.
require
(
:
operations
_feature_flag
)
.
permit
(
:name
,
:description
,
:active
)
end
def
update_params
params
.
require
(
:
project
_feature_flag
)
params
.
require
(
:
operations
_feature_flag
)
.
permit
(
:description
,
:active
)
end
end
app/models/operations/feature_flag.rb
View file @
d36a4504
class
ProjectFeatureFlag
<
ActiveRecord
::
Base
module
Operations
class
FeatureFlag
<
ActiveRecord
::
Base
self
.
table_name
=
'operations_feature_flags'
belongs_to
:project
validates
:project
,
presence:
true
...
...
@@ -9,4 +12,5 @@ class ProjectFeatureFlag < ActiveRecord::Base
with:
Gitlab
::
Regex
.
feature_flag_regex
,
message:
Gitlab
::
Regex
.
feature_flag_regex_message
}
end
end
app/models/operations/feature_flag_access_token.rb
deleted
100644 → 0
View file @
542763ff
class
ProjectFeatureFlagsAccessToken
<
ActiveRecord
::
Base
include
TokenAuthenticatable
belongs_to
:project
validates
:project
,
presence:
true
validates
:token
,
presence:
true
add_authentication_token_field
:token
before_validation
:ensure_token!
end
app/models/operations/feature_flags_access_token.rb
0 → 100644
View file @
d36a4504
module
Operations
class
FeatureFlagsAccessToken
<
ActiveRecord
::
Base
include
TokenAuthenticatable
self
.
table_name
=
'operations_feature_flags_access_tokens'
belongs_to
:project
validates
:project
,
presence:
true
validates
:token
,
presence:
true
add_authentication_token_field
:token
before_validation
:ensure_token!
end
end
app/models/project.rb
View file @
d36a4504
...
...
@@ -266,8 +266,8 @@ class Project < ActiveRecord::Base
has_many
:project_deploy_tokens
has_many
:deploy_tokens
,
through: :project_deploy_tokens
has_many
:
project_feature_flags
has_
many
:project_feature_flags_access_tokens
has_many
:
operations_feature_flags
,
class_name:
'Operations::FeatureFlag'
has_
one
:operations_feature_flags_access_token
,
class_name:
'Operations::FeatureFlagsAccessToken'
has_one
:auto_devops
,
class_name:
'ProjectAutoDevops'
has_many
:custom_attributes
,
class_name:
'ProjectCustomAttribute'
...
...
@@ -2105,6 +2105,10 @@ class Project < ActiveRecord::Base
auto_cancel_pending_pipelines
==
'enabled'
end
def
feature_flag_access_token
(
operations_feature_flags_access_token
||
create_operations_feature_flags_access_token!
).
token
end
private
# rubocop: disable CodeReuse/ServiceClass
...
...
lib/api/entities.rb
View file @
d36a4504
...
...
@@ -1525,7 +1525,7 @@ module API
class
UnleashFeatures
<
Grape
::
Entity
expose
:version
expose
:
project
_feature_flags
,
as: :features
,
with:
UnleashFeature
expose
:
operations
_feature_flags
,
as: :features
,
with:
UnleashFeature
private
...
...
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