Commit 2122d7b9 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'master' into ci-build-list

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parents e8666898 1eb3dde4
......@@ -53,6 +53,7 @@ v 8.0.0 (unreleased)
- Add FogBugz project import (Jared Szechy)
- Sort users autocomplete lists by user (Allister Antosik)
- Webhook for issue now contains repository field (Jungkook Park)
- Add ability to add custom text to the help page (Jeroen van Baarsen)
v 7.14.3
- No changes
......
......@@ -928,6 +928,3 @@ DEPENDENCIES
webmock (~> 1.21.0)
whenever (~> 0.8.4)
wikicloth (= 0.8.1)
BUNDLED WITH
1.10.6
......@@ -46,6 +46,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
:gravatar_enabled,
:twitter_sharing_enabled,
:sign_in_text,
:help_page_text,
:home_page_url,
:after_sign_out_path,
:max_attachment_size,
......
......@@ -10,9 +10,7 @@ module Ci
def authenticate_public_page!
unless project.public
unless current_user
redirect_to(new_user_sessions_path) and return
end
authenticate_user!
return access_denied! unless can?(current_user, :read_project, gl_project)
end
......
......@@ -5,38 +5,32 @@ module Ci
before_action :authenticate_user!, except: [:build, :badge, :index, :show]
before_action :authenticate_public_page!, only: :show
before_action :project, only: [:build, :integration, :show, :badge, :edit, :update, :destroy, :toggle_shared_runners, :dumped_yaml]
before_action :authorize_access_project!, except: [:build, :gitlab, :badge, :index, :show, :new, :create]
before_action :authorize_access_project!, except: [:build, :badge, :index, :show, :new, :create]
before_action :authorize_manage_project!, only: [:edit, :integration, :update, :destroy, :toggle_shared_runners, :dumped_yaml]
before_action :authenticate_token!, only: [:build]
before_action :no_cache, only: [:badge]
protect_from_forgery except: :build
layout 'ci/project', except: [:index, :gitlab]
layout 'ci/project', except: :index
def index
@projects = Ci::Project.ordered_by_last_commit_date.public_only.page(params[:page]) unless current_user
end
def gitlab
@limit, @offset = (params[:limit] || PROJECTS_BATCH).to_i, (params[:offset] || 0).to_i
@page = @offset == 0 ? 1 : (@offset / @limit + 1)
@gl_projects = current_user.authorized_projects
@gl_projects = @gl_projects.where("name LIKE ?", "%#{params[:search]}%") if params[:search]
@gl_projects = @gl_projects.page(@page).per(@limit)
if current_user
@projects = ProjectListBuilder.new.execute(current_user, params[:search])
@projects = Ci::Project.where(gitlab_id: @gl_projects.map(&:id)).ordered_by_last_commit_date
@total_count = @gl_projects.size
@projects = @projects.page(@page).per(@limit)
@gl_projects = @gl_projects.where.not(id: @projects.map(&:gitlab_id))
@total_count = @projects.size
end
respond_to do |format|
format.json do
pager_json("ci/projects/gitlab", @total_count)
pager_json("ci/projects/index", @total_count)
end
format.html
end
rescue
@error = 'Failed to fetch GitLab projects'
end
def show
......
......@@ -2,21 +2,12 @@ class TrendingProjectsFinder
def execute(current_user, start_date = nil)
start_date ||= Date.today - 1.month
projects = projects_for(current_user)
# Determine trending projects based on comments count
# for period of time - ex. month
trending_project_ids = Note.
select("notes.project_id, count(notes.project_id) as pcount").
where('notes.created_at > ?', start_date).
group("project_id").
reorder("pcount DESC").
map(&:project_id)
sql_order_ids = trending_project_ids.reverse.
map { |project_id| "id = #{project_id}" }.join(", ")
# Get list of projects that user allowed to see
projects = projects_for(current_user)
projects.where(id: trending_project_ids).reorder(sql_order_ids)
projects.joins(:notes).where('notes.created_at > ?', start_date).
group("projects.id").reorder("count(notes.id) DESC")
end
private
......
......@@ -31,12 +31,12 @@ module GroupsHelper
end
end
def group_title(group, name, url)
def group_title(group, name = nil, url = nil)
full_title = link_to(simple_sanitize(group.name), group_path(group))
full_title += ' &middot; '.html_safe + link_to(simple_sanitize(name), url) if name
content_tag :span do
link_to(
simple_sanitize(group.name), group_path(group)
) + ' &middot; '.html_safe +
link_to(simple_sanitize(name), url)
full_title
end
end
end
......@@ -317,41 +317,6 @@ module ProjectsHelper
@ref || @repository.try(:root_ref)
end
def detect_project_title(project)
name, url =
if current_controller? 'wikis'
['Wiki', get_project_wiki_path(project)]
elsif current_controller? 'project_members'
['Members', namespace_project_project_members_path(project.namespace, project)]
elsif current_controller? 'labels'
['Labels', namespace_project_labels_path(project.namespace, project)]
elsif current_controller? 'members'
['Members', project_files_path(project)]
elsif current_controller? 'commits'
['Commits', project_commits_path(project)]
elsif current_controller? 'graphs'
['Graphs', namespace_project_graph_path(project.namespace, project, current_ref)]
elsif current_controller? 'network'
['Network', namespace_project_network_path(project.namespace, project, current_ref)]
elsif current_controller? 'milestones'
['Milestones', namespace_project_milestones_path(project.namespace, project)]
elsif current_controller? 'snippets'
['Snippets', namespace_project_snippets_path(project.namespace, project)]
elsif current_controller? 'issues'
['Issues', namespace_project_issues_path(project.namespace, project)]
elsif current_controller? 'merge_requests'
['Merge Requests', namespace_project_merge_requests_path(project.namespace, project)]
elsif current_controller? 'tree', 'blob'
['Files', project_files_path(project)]
elsif current_path? 'projects#activity'
['Activity', activity_project_path(project)]
else
[nil, nil]
end
project_title(project, name, url)
end
private
def filename_path(project, filename)
......
......@@ -118,6 +118,11 @@
.col-sm-10
= f.text_area :sign_in_text, class: 'form-control', rows: 4
.help-block Markdown enabled
.form-group
= f.label :help_page_text, class: 'control-label col-sm-2'
.col-sm-10
= f.text_area :help_page_text, class: 'form-control', rows: 4
.help-block Markdown enabled
.form-actions
= f.submit 'Save', class: 'btn btn-primary'
......@@ -96,6 +96,5 @@
.form-actions
= f.submit 'Save changes', class: 'btn btn-save'
= link_to 'Cancel', projects_path, class: 'btn'
- unless @project.new_record?
= link_to 'Remove Project', ci_project_path(@project), method: :delete, data: { confirm: 'Project will be removed. Are you sure?' }, class: 'btn btn-danger pull-right'
- @gl_projects.sort_by(&:name_with_namespace).each do |project|
%tr.light
%td
= project.name_with_namespace
%td
%small Not added to CI
%td
%td
- if Ci::Project.already_added?(project)
%strong.cgreen
Added
- else
= form_tag ci_projects_path do
= hidden_field_tag :project, project.to_json(methods: [:name_with_namespace, :path_with_namespace, :ssh_url_to_repo])
= submit_tag 'Add project to CI', class: 'btn btn-default btn-sm'
- last_commit = project.last_commit
%tr{class: commit_status_css_class(last_commit) }
%td
= link_to [:ci, project] do
= project.name
%td
- if last_commit
#{last_commit.status} (#{commit_link(last_commit)})
- if project.last_commit_date
= time_ago_in_words project.last_commit_date
ago
- else
No builds yet
%td
- if project.public
%i.fa.fa-globe
Public
- else
%i.fa.fa-lock
Private
%td
= project.commits.count
- if project.gitlab_ci_project
- ci_project = project.gitlab_ci_project
- last_commit = ci_project.last_commit
%tr{class: commit_status_css_class(last_commit) }
%td
= link_to [:ci, ci_project] do
= ci_project.name
%td
- if last_commit
%span.ci-status<
= last_commit.status
= commit_link(last_commit)
&middot;
- if ci_project.last_commit_date
= time_ago_in_words ci_project.last_commit_date
ago
- else
No builds yet
%td
- if ci_project.public
%i.fa.fa-globe
Public
- else
%i.fa.fa-lock
Private
%td
= ci_project.commits.count
- else
%tr.light
%td
= project.name_with_namespace
%td
%small Not added to CI
%td
%td
= form_tag ci_projects_path do
= hidden_field_tag :project, project.to_json(methods: [:name_with_namespace, :path_with_namespace, :ssh_url_to_repo])
= submit_tag 'Add project to CI', class: 'btn btn-default btn-sm'
......@@ -5,13 +5,7 @@
.input-group-addon
%i.fa.fa-search
:coffeescript
$('.ci-search-form').submit ->
NProgress.start()
query = $('.ci-search-form .search-input').val()
$.get '#{gitlab_ci_projects_path}', { search: query }, (data) ->
$(".projects").html data.html
NProgress.done()
CiPager.init "#{gitlab_ci_projects_path}" + "?search=" + query, #{Ci::ProjectsController::PROJECTS_BATCH}, false
CiPager.init "#{ci_projects_path}" + "?search=" + query, #{Ci::ProjectsController::PROJECTS_BATCH}, false
false
- if @offset == 0
.gray-content-block.clearfix.light.second-block
.pull-left.fetch-status
- if params[:search].present?
by keyword: "#{params[:search]}",
#{@total_count} projects, #{@projects.size} of them added to CI
.wide-table-holder
%table.table.projects-table.content-list
%thead
%tr
%th Project Name
%th Last commit
%th Access
%th Commits
= render @projects
= render "gl_projects"
%p.text-center.hide.loading
%i.fa.fa-refresh.fa-spin
- else
= render @projects
= render "gl_projects"
- if current_user
.gray-content-block.top-block
= render "search"
.projects
%p.fetch-status.light
%i.fa.fa-refresh.fa-spin
- if @offset > 0
= render @projects
- else
.gray-content-block.top-block
= render "search"
.projects
.gray-content-block.clearfix.light.second-block
.pull-left.fetch-status
- if params[:search].present?
by keyword: "#{params[:search]}",
#{@total_count} projects
.wide-table-holder
%table.table.projects-table.content-list
%thead
%tr
%th Project Name
%th Last commit
%th Access
%th Commits
= render @projects
%p.text-center.hide.loading
%i.fa.fa-refresh.fa-spin
:coffeescript
$.get '#{gitlab_ci_projects_path}', (data) ->
$(".projects").html data.html
CiPager.init "#{gitlab_ci_projects_path}", #{Ci::ProjectsController::PROJECTS_BATCH}, false
CiPager.init "#{ci_projects_path}", #{Ci::ProjectsController::PROJECTS_BATCH}, false
- else
= render 'public'
- header_title group_title(@group, "Milestones", group_milestones_path(@group))
- page_title @group_milestone.title, "Milestones"
= render "header_title"
%h4.page-title
.issue-box{ class: "issue-box-#{@group_milestone.closed? ? 'closed' : 'open'}" }
- if @group_milestone.closed?
......
......@@ -17,6 +17,9 @@
Used by more than 100,000 organizations, GitLab is the most popular solution to manage git repositories on-premises.
%br
Read more about GitLab at #{link_to promo_host, promo_url, target: '_blank'}.
- if current_application_settings.help_page_text.present?
%hr
= markdown(current_application_settings.help_page_text)
%hr
......
%ul.nav.nav-sidebar
= nav_link do
= link_to admin_root_path, title: 'Back to dashboard', data: {placement: 'right'}, class: 'back-link' do
= link_to admin_root_path, title: 'Back to admin', data: {placement: 'right'}, class: 'back-link' do
= icon('caret-square-o-left fw')
%span
Back to Admin
Back to admin
%li.separate-item
= nav_link path: 'projects#index' do
......
- page_title "Dashboard"
- unless @header_title
- header_title "Dashboard", root_path
- header_title "Dashboard", root_path unless header_title
- sidebar "dashboard"
= render template: "layouts/application"
- page_title @group.name
- unless @header_title
- header_title @group.name, group_path(@group)
- sidebar "group" unless sidebar
- header_title group_title(@group) unless header_title
- sidebar "group" unless sidebar
= render template: "layouts/application"
- page_title "Settings"
- header_title group_title(@group, "Settings", edit_group_path(@group))
- sidebar "group_settings"
= render template: "layouts/group"
......@@ -46,6 +46,8 @@
= icon('question-circle fw')
%span
Help
%li.separate-item
= nav_link(controller: :profile) do
= link_to profile_path, title: 'Profile settings', data: {placement: 'bottom'} do
= icon('user fw')
......
- page_title "Profile Settings"
- unless @header_title
- header_title "Profile Settings", profile_path
- header_title "Profile Settings", profile_path unless header_title
- sidebar "profile"
= render template: "layouts/application"
- page_title @project.name_with_namespace
- header_title detect_project_title(@project)
- sidebar "project" unless sidebar
- header_title project_title(@project) unless header_title
- sidebar "project" unless sidebar
- content_for :scripts_body_top do
- if current_user
......
- page_title "Settings"
- header_title project_title(@project, "Settings", edit_project_path(@project))
- sidebar "project_settings"
= render template: "layouts/project"
- page_title "Activity"
- header_title project_title(@project, "Activity", activity_project_path(@project))
= render 'projects/activity'
- page_title "Blame", @blob.path, @ref
- header_title project_title(@project, "Files", project_files_path(@project))
%h3.page-title Blame view
#tree-holder.tree-holder
......
- header_title project_title(@project, "Files", project_files_path(@project))
- page_title "Edit", @blob.path, @ref
= render "header_title"
.file-editor
%ul.center-top-menu.no-bottom.js-edit-mode
%li.active
......
- page_title "New File", @path.presence, @ref
= render "header_title"
.gray-content-block.top-block
Create a new file or
= link_to 'upload', '#modal-upload-blob',
......
- page_title @blob.path, @ref
= render "header_title"
= render 'projects/last_push'
......
- page_title "Branches"
= render "projects/commits/header_title"
= render "projects/commits/head"
.gray-content-block
.pull-right
......
- page_title "New Branch"
= render "projects/commits/header_title"
- if @error
.alert.alert-danger
%button{ type: "button", class: "close", "data-dismiss" => "alert"} &times;
......
- page_title "#{@commit.title} (#{@commit.short_id})", "Commits"
= render "projects/commits/header_title"
= render "commit_box"
= render "projects/diffs/diffs", diffs: @diffs, project: @project
= render "projects/notes/notes_with_form", view: params[:view]
- header_title project_title(@project, "Commits", project_commits_path(@project))
- page_title "Commits", @ref
= render "header_title"
= content_for :meta_tags do
- if current_user
= auto_discovery_link_tag(:atom, namespace_project_commits_url(@project.namespace, @project, @ref, format: :atom, private_token: current_user.private_token), title: "#{@project.name}:#{@ref} commits")
......
- page_title "Compare"
= render "projects/commits/header_title"
= render "projects/commits/head"
.gray-content-block
......
- page_title "#{params[:from]}...#{params[:to]}"
= render "projects/commits/header_title"
= render "projects/commits/head"
......
- header_title project_title(@project, "Graphs", namespace_project_graph_path(@project.namespace, @project, current_ref))
- page_title "Commit statistics"
- page_title "Commits", "Graphs"
= render "header_title"
.tree-ref-holder
= render 'shared/ref_switcher', destination: 'graphs_commits'
= render 'head'
......
- page_title "Contributor statistics"
- page_title "Contributors", "Graphs"
= render "header_title"
.tree-ref-holder
= render 'shared/ref_switcher', destination: 'graphs'
= render 'head'
......
- header_title project_title(@project, "Issues", namespace_project_issues_path(@project.namespace, @project))
- page_title "Issues"
= render "header_title"
= content_for :meta_tags do
- if current_user
= auto_discovery_link_tag(:atom, namespace_project_issues_url(@project.namespace, @project, :atom, private_token: current_user.private_token), title: "#{@project.name} issues")
......
- page_title "New Issue"
= render "header_title"
= render "form"
- page_title "#{@issue.title} (##{@issue.iid})", "Issues"
= render "header_title"
.issue
.issue-details.issuable-details
.page-title
......
- header_title project_title(@project, "Labels", namespace_project_labels_path(@project.namespace, @project))
- page_title "Edit", @label.name, "Labels"
= render "header_title"
%h3
Edit label
%span.light #{@label.name}
......
- page_title "Labels"
= render "header_title"
.gray-content-block.top-block
- if can? current_user, :admin_label, @project
......
- page_title "New Label"
= render "header_title"
%h3 New label
.back-link
= link_to namespace_project_labels_path(@project.namespace, @project) do
......
- header_title project_title(@project, "Merge Requests", namespace_project_merge_requests_path(@project.namespace, @project))
- page_title "#{@merge_request.title} (##{@merge_request.iid})", "Merge Requests"
= render "header_title"
- if params[:view] == 'parallel'
- fluid_layout true
......
- page_title "Edit", "#{@merge_request.title} (##{@merge_request.iid})", "Merge Requests"
= render "header_title"
%h3.page-title
= "Edit merge request ##{@merge_request.iid}"
%hr
......
- page_title "Merge Requests"
= render "header_title"
= render 'projects/last_push'
.project-issuable-filter
.controls
......
- page_title "#{@merge_request.title} (##{@merge_request.iid})", "Merge Requests"
= render "header_title"
.merge-request
= render "projects/merge_requests/show/mr_title"
= render "projects/merge_requests/show/mr_box"
......
- page_title "New Merge Request"
= render "header_title"
- if @merge_request.can_be_created
= render 'new_submit'
- else
......
- header_title project_title(@project, "Milestones", namespace_project_milestones_path(@project.namespace, @project))
- page_title "Edit", @milestone.title, "Milestones"
= render "header_title"
= render "form"
- page_title "Milestones"
= render "header_title"
= render 'shared/milestones_filter'
.gray-content-block
......
- page_title "New Milestone"
= render "header_title"
= render "form"
- page_title @milestone.title, "Milestones"
= render "header_title"
%h4.page-title
.issue-box{ class: issue_box_class(@milestone) }
- if @milestone.closed?
......
- page_title "Network", @ref
= header_title project_title(@project, "Network", namespace_project_network_path(@project.namespace, @project, current_ref))
= render "head"
.project-network
.controls
......
- header_title project_title(@project, "Members", namespace_project_project_members_path(@project.namespace, @project))
- page_title "Import members"
= render "header_title"
%h3.page-title
Import members from another project
%p.light
......
- page_title "Members"
= render "header_title"
.gray-content-block.top-block
.clearfix.js-toggle-container
......
- header_title project_title(@project, "Snippets", namespace_project_snippets_path(@project.namespace, @project))
- page_title "Edit", @snippet.title, "Snippets"
= render "header_title"
%h3.page-title
Edit snippet
%hr
......
- page_title "Snippets"
= render "header_title"
%h3.page-title
Snippets
- if can? current_user, :create_project_snippet, @project
......
- page_title "New Snippets"
= render "header_title"
%h3.page-title
New snippet
%hr
......
- page_title @snippet.title, "Snippets"
= render "header_title"
%h3.page-title
= @snippet.title
......
- page_title "Tags"
= render "projects/commits/header_title"
= render "projects/commits/head"
.gray-content-block
......
- page_title "New Tag"
= render "projects/commits/header_title"
- if @error
.alert.alert-danger
%button{ type: "button", class: "close", "data-dismiss" => "alert"} &times;
......
- page_title @path.presence || "Files", @ref
- header_title project_title(@project, "Files", project_files_path(@project))
= content_for :meta_tags do
- if current_user
= auto_discovery_link_tag(:atom, namespace_project_commits_url(@project.namespace, @project, @ref, format: :atom, private_token: current_user.private_token), title: "#{@project.name}:#{@ref} commits")
......
- header_title project_title(@project, 'Wiki', get_project_wiki_path(@project))
- page_title "Edit", @page.title, "Wiki"
= render "header_title"
= render 'nav'
.pull-right
= render 'main_links'
......
- page_title "Wiki"
= render "header_title"
%h3.page-title Empty page
%hr
.error_message
......
- page_title "Git Access", "Wiki"
= render "header_title"
= render 'nav'
.gray-content-block
.row
......
- page_title "History", @page.title, "Wiki"
- page_title "History", @page.title.capitalize, "Wiki"
= render "header_title"
= render 'nav'
.gray-content-block
%h3.page-title
......
- page_title "All Pages", "Wiki"
= render "header_title"
= render 'nav'
.gray-content-block
%h3.page-title
......
- page_title @page.title, "Wiki"
- page_title @page.title.capitalize, "Wiki"
= render "header_title"
= render 'nav'
.gray-content-block
......
......@@ -8,7 +8,7 @@
= render "shared/projects/project", project: project,
avatar: avatar, stars: stars, css_class: css_class
- if projects.count > projects_limit
- if projects.size > projects_limit
%li.bottom.center
.light
#{projects_limit} of #{pluralize(projects.count, 'project')} displayed.
......
class AddHelpPageTextToApplicationSettings < ActiveRecord::Migration
def change
add_column :application_settings, :help_page_text, :text
end
end
......@@ -45,6 +45,7 @@ ActiveRecord::Schema.define(version: 20150916145038) do
t.string "after_sign_out_path"
t.integer "session_expire_delay", default: 10080, null: false
t.text "import_sources"
t.text "help_page_text"
end
create_table "audit_events", force: true do |t|
......
......@@ -72,6 +72,8 @@ access can happen through being a direct member of the project, or through
a group. See `def accessible_deploy_keys` in `app/models/user.rb` for more
information.
Deploy keys can be shared between projects, you just need to add them to each project.
## Applications
### Eclipse
......
......@@ -7,6 +7,7 @@ class Spinach::Features::AdminSettings < Spinach::FeatureSteps
step 'I modify settings and save form' do
uncheck 'Gravatar enabled'
fill_in 'Home page URL', with: 'https://about.gitlab.com/'
fill_in 'Help page text', with: 'Example text'
click_button 'Save'
end
......
module Ci
class ProjectListBuilder
def execute(current_user, search = nil)
projects = current_user.authorized_projects
projects = projects.search(search) if search
projects.
joins("LEFT JOIN ci_projects ON projects.id = ci_projects.gitlab_id
LEFT JOIN #{last_commit_subquery} AS last_commit ON #{Ci::Project.table_name}.id = last_commit.project_id").
reorder("ci_projects.id is NULL ASC,
CASE WHEN last_commit.committed_at IS NULL THEN 1 ELSE 0 END,
last_commit.committed_at DESC")
end
private
def last_commit_subquery
"(SELECT project_id, MAX(committed_at) committed_at FROM #{Ci::Commit.table_name} GROUP BY project_id)"
end
end
end
......@@ -84,7 +84,7 @@ describe Ci::ProjectsController do
end
it "searches projects" do
xhr :get, :gitlab, { search: "str", format: "js" }.with_indifferent_access
xhr :get, :index, { search: "str", format: "json" }.with_indifferent_access
expect(response).to be_success
expect(response.code).to eq('200')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment