Skip to content

Commit

Permalink
Provide a label template policy
Browse files Browse the repository at this point in the history
  • Loading branch information
danidoni committed Aug 6, 2024
1 parent abf02f5 commit 3700b2d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class LabelTemplatesController < WebuiController
before_action :set_project

def index
head :not_found unless Flipper.enabled?(:labels, User.session)
authorize LabelTemplate.new(project: @project), :index?

@label_templates = @project.label_templates
end
Expand Down
8 changes: 8 additions & 0 deletions src/api/app/policies/label_template_policy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class LabelTemplatePolicy < ApplicationPolicy
def index?
return false unless Flipper.enabled?(:labels, @user)
return false unless record.project.maintainers.include?(@user)

true
end
end
2 changes: 1 addition & 1 deletion src/api/app/views/webui/project/_tabs.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
= tab_link('Staging', staging_workflow_path(project), active, 'scrollable-tab-link')
- elsif policy(Staging::Workflow.new(project: project)).create?
= tab_link('Staging', new_staging_workflow_path(project: project), active, 'scrollable-tab-link')
- if Flipper.enabled?(:labels, User.session)
- if policy(LabelTemplate.new(project: project)).index?
= tab_link('Label templates', project_label_templates_path(project), false, 'scrollable-tab-link')

0 comments on commit 3700b2d

Please sign in to comment.