Fix namespace api autocomplete
This commit is contained in:
		
							parent
							
								
									105f5ba3c9
								
							
						
					
					
						commit
						439d03bbed
					
				| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
:javascript
 | 
					:javascript
 | 
				
			||||||
  $(function() {
 | 
					  $(function() {
 | 
				
			||||||
    GitLab.GfmAutoComplete.Members.url = "#{ "/api/v2/projects/#{@project.path}/members" if @project }";
 | 
					    GitLab.GfmAutoComplete.Members.url = "#{ "/api/v2/projects/#{@project.id}/members" if @project }";
 | 
				
			||||||
    GitLab.GfmAutoComplete.Members.params.private_token = "#{current_user.private_token}";
 | 
					    GitLab.GfmAutoComplete.Members.params.private_token = "#{current_user.private_token}";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    GitLab.GfmAutoComplete.Emoji.data = #{raw emoji_autocomplete_source};
 | 
					    GitLab.GfmAutoComplete.Emoji.data = #{raw emoji_autocomplete_source};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,13 +5,18 @@ module Gitlab
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def user_project
 | 
					    def user_project
 | 
				
			||||||
      if @project ||= current_user.projects.find_by_id(params[:id]) ||
 | 
					      @project ||= find_project
 | 
				
			||||||
                      current_user.projects.find_by_path(params[:id])
 | 
					      @project || not_found!
 | 
				
			||||||
      else
 | 
					    end
 | 
				
			||||||
        not_found!
 | 
					 | 
				
			||||||
      end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
      @project
 | 
					    def find_project
 | 
				
			||||||
 | 
					      project = Project.find_by_id(params[:id]) || Project.find_with_namespace(params[:id])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if project && can?(current_user, :read_project, project)
 | 
				
			||||||
 | 
					        project
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
 | 
					        nil
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def paginate(object)
 | 
					    def paginate(object)
 | 
				
			||||||
| 
						 | 
					@ -32,6 +37,10 @@ module Gitlab
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def can?(object, action, subject)
 | 
				
			||||||
 | 
					      abilities.allowed?(object, action, subject)
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def attributes_for_keys(keys)
 | 
					    def attributes_for_keys(keys)
 | 
				
			||||||
      attrs = {}
 | 
					      attrs = {}
 | 
				
			||||||
      keys.each do |key|
 | 
					      keys.each do |key|
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue