diff options
author | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-03-02 16:22:50 +0000 |
---|---|---|
committer | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-03-02 16:22:50 +0000 |
commit | ba9bb4f59f0a8095350c433a303dc46c24bc34b1 (patch) | |
tree | f0206afc57f7a835d0bb75fdc54a8b8129735bbb /app | |
parent | 1fbc4886684b904f2de9e5f726f9e8c0baa76352 (diff) | |
parent | b8ca9bc43a9504dad94a66630170ab6311eb5c09 (diff) | |
download | gitlab-ce-ba9bb4f59f0a8095350c433a303dc46c24bc34b1.tar.gz |
Merge branch 'master' into 'zj-create-mattermost-team'
# Conflicts:
# app/assets/javascripts/dispatcher.js.es6
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/copy_as_gfm.js.es6 | 3 | ||||
-rw-r--r-- | app/assets/javascripts/dispatcher.js.es6 | 5 | ||||
-rw-r--r-- | app/assets/javascripts/groups_list.js | 47 | ||||
-rw-r--r-- | app/assets/stylesheets/pages/events.scss | 5 | ||||
-rw-r--r-- | app/controllers/ci/projects_controller.rb | 47 | ||||
-rw-r--r-- | app/controllers/dashboard/groups_controller.rb | 14 | ||||
-rw-r--r-- | app/controllers/explore/groups_controller.rb | 11 | ||||
-rw-r--r-- | app/helpers/explore_helper.rb | 14 | ||||
-rw-r--r-- | app/services/ci/image_for_build_service.rb | 25 | ||||
-rw-r--r-- | app/views/dashboard/_groups_head.html.haml | 7 | ||||
-rw-r--r-- | app/views/dashboard/groups/_groups.html.haml | 6 | ||||
-rw-r--r-- | app/views/dashboard/groups/index.html.haml | 7 | ||||
-rw-r--r-- | app/views/explore/groups/_groups.html.haml | 6 | ||||
-rw-r--r-- | app/views/explore/groups/index.html.haml | 38 | ||||
-rw-r--r-- | app/views/shared/groups/_dropdown.html.haml | 18 |
15 files changed, 131 insertions, 122 deletions
diff --git a/app/assets/javascripts/copy_as_gfm.js.es6 b/app/assets/javascripts/copy_as_gfm.js.es6 index 4bd537a6f28..2bc3d85fba4 100644 --- a/app/assets/javascripts/copy_as_gfm.js.es6 +++ b/app/assets/javascripts/copy_as_gfm.js.es6 @@ -25,6 +25,9 @@ require('./lib/utils/common_utils'); }, }, ReferenceFilter: { + '.tooltip'(el, text) { + return ''; + }, 'a.gfm:not([data-link=true])'(el, text) { return el.dataset.original || text; }, diff --git a/app/assets/javascripts/dispatcher.js.es6 b/app/assets/javascripts/dispatcher.js.es6 index 2852417b1c9..942b6e26670 100644 --- a/app/assets/javascripts/dispatcher.js.es6 +++ b/app/assets/javascripts/dispatcher.js.es6 @@ -36,6 +36,7 @@ /* global Shortcuts */ import BindInOut from './behaviors/bind_in_out.js.es6'; +import GroupsList from './groups_list'; const ShortcutsBlob = require('./shortcuts_blob'); const UserCallout = require('./user_callout'); @@ -98,6 +99,10 @@ const UserCallout = require('./user_callout'); case 'dashboard:todos:index': new gl.Todos(); break; + case 'dashboard:groups:index': + case 'explore:groups:index': + new GroupsList(); + break; case 'projects:milestones:new': case 'projects:milestones:edit': case 'projects:milestones:update': diff --git a/app/assets/javascripts/groups_list.js b/app/assets/javascripts/groups_list.js new file mode 100644 index 00000000000..0ef81e49444 --- /dev/null +++ b/app/assets/javascripts/groups_list.js @@ -0,0 +1,47 @@ +/** + * Based on project list search. + * Makes search request for groups when user types a value in the search input. + * Updates the html content of the page with the received one. + */ +export default class GroupsList { + constructor() { + this.groupsListFilterElement = document.querySelector('.js-groups-list-filter'); + this.groupsListHolderElement = document.querySelector('.js-groups-list-holder'); + + this.initSearch(); + } + + initSearch() { + this.debounceFilter = _.debounce(this.filterResults.bind(this), 500); + + this.groupsListFilterElement.removeEventListener('input', this.debounceFilter); + this.groupsListFilterElement.addEventListener('input', this.debounceFilter); + } + + filterResults() { + const form = document.querySelector('form#group-filter-form'); + const groupFilterUrl = `${form.getAttribute('action')}?${$(form).serialize()}`; + + $(this.groupsListHolderElement).fadeTo(250, 0.5); + + return $.ajax({ + url: form.getAttribute('action'), + data: $(form).serialize(), + type: 'GET', + dataType: 'json', + context: this, + complete() { + $(this.groupsListHolderElement).fadeTo(250, 1); + }, + success(data) { + this.groupsListHolderElement.innerHTML = data.html; + + // Change url so if user reload a page - search results are saved + return window.history.replaceState({ + page: groupFilterUrl, + + }, document.title, groupFilterUrl); + }, + }); + } +} diff --git a/app/assets/stylesheets/pages/events.scss b/app/assets/stylesheets/pages/events.scss index 5776d86983a..08398bb43a2 100644 --- a/app/assets/stylesheets/pages/events.scss +++ b/app/assets/stylesheets/pages/events.scss @@ -155,7 +155,7 @@ @media (max-width: $screen-xs-max) { .event-item { - padding-left: $gl-padding; + padding-left: 0; .event-title { white-space: normal; @@ -169,8 +169,7 @@ .event-body { margin: 0; - border-left: 2px solid $events-body-border; - padding-left: 10px; + padding-left: 0; } .event-item-timestamp { diff --git a/app/controllers/ci/projects_controller.rb b/app/controllers/ci/projects_controller.rb deleted file mode 100644 index ff297d6ff13..00000000000 --- a/app/controllers/ci/projects_controller.rb +++ /dev/null @@ -1,47 +0,0 @@ -module Ci - class ProjectsController < ::ApplicationController - before_action :project - before_action :no_cache, only: [:badge] - before_action :authorize_read_project!, except: [:badge, :index] - skip_before_action :authenticate_user!, only: [:badge] - protect_from_forgery - - def index - redirect_to root_path - end - - def show - # Temporary compatibility with CI badges pointing to CI project page - redirect_to namespace_project_path(project.namespace, project) - end - - # Project status badge - # Image with build status for sha or ref - # - # This action in DEPRECATED, this is here only for backwards compatibility - # with projects migrated from GitLab CI. - # - def badge - return render_404 unless @project - - image = Ci::ImageForBuildService.new.execute(@project, params) - send_file image.path, filename: image.name, disposition: 'inline', type: "image/svg+xml" - end - - protected - - def project - @project ||= Project.find_by(ci_id: params[:id].to_i) - end - - def no_cache - response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate" - response.headers["Pragma"] = "no-cache" - response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT" - end - - def authorize_read_project! - return access_denied! unless can?(current_user, :read_project, project) - end - end -end diff --git a/app/controllers/dashboard/groups_controller.rb b/app/controllers/dashboard/groups_controller.rb index 0b7cf8167f0..d03265e9f20 100644 --- a/app/controllers/dashboard/groups_controller.rb +++ b/app/controllers/dashboard/groups_controller.rb @@ -1,5 +1,17 @@ class Dashboard::GroupsController < Dashboard::ApplicationController def index - @group_members = current_user.group_members.includes(source: :route).page(params[:page]) + @group_members = current_user.group_members.includes(source: :route).joins(:group) + @group_members = @group_members.merge(Group.search(params[:filter_groups])) if params[:filter_groups].present? + @group_members = @group_members.merge(Group.sort(@sort = params[:sort])) + @group_members = @group_members.page(params[:page]) + + respond_to do |format| + format.html + format.json do + render json: { + html: view_to_html_string("dashboard/groups/_groups", locals: { group_members: @group_members }) + } + end + end end end diff --git a/app/controllers/explore/groups_controller.rb b/app/controllers/explore/groups_controller.rb index a962f9a0937..68228c095da 100644 --- a/app/controllers/explore/groups_controller.rb +++ b/app/controllers/explore/groups_controller.rb @@ -1,8 +1,17 @@ class Explore::GroupsController < Explore::ApplicationController def index @groups = GroupsFinder.new.execute(current_user) - @groups = @groups.search(params[:search]) if params[:search].present? + @groups = @groups.search(params[:filter_groups]) if params[:filter_groups].present? @groups = @groups.sort(@sort = params[:sort]) @groups = @groups.page(params[:page]) + + respond_to do |format| + format.html + format.json do + render json: { + html: view_to_html_string("explore/groups/_groups", locals: { groups: @groups }) + } + end + end end end diff --git a/app/helpers/explore_helper.rb b/app/helpers/explore_helper.rb index 2b1f3825adc..bbcb52f7eaf 100644 --- a/app/helpers/explore_helper.rb +++ b/app/helpers/explore_helper.rb @@ -9,12 +9,20 @@ module ExploreHelper } options = exist_opts.merge(options) - path = request.path - path << "?#{options.to_param}" - path + request_path_with_options(options) + end + + def filter_groups_path(options = {}) + request_path_with_options(options) end def explore_controller? controller.class.name.split("::").first == "Explore" end + + private + + def request_path_with_options(options = {}) + request.path + "?#{options.to_param}" + end end diff --git a/app/services/ci/image_for_build_service.rb b/app/services/ci/image_for_build_service.rb deleted file mode 100644 index 240ddabec36..00000000000 --- a/app/services/ci/image_for_build_service.rb +++ /dev/null @@ -1,25 +0,0 @@ -module Ci - class ImageForBuildService - def execute(project, opts) - ref = opts[:ref] - sha = opts[:sha] || ref_sha(project, ref) - pipelines = project.pipelines.where(sha: sha) - - image_name = image_for_status(pipelines.latest_status(ref)) - image_path = Rails.root.join('public/ci', image_name) - - OpenStruct.new(path: image_path, name: image_name) - end - - private - - def ref_sha(project, ref) - project.commit(ref).try(:sha) if ref - end - - def image_for_status(status) - status ||= 'unknown' - 'build-' + status + ".svg" - end - end -end diff --git a/app/views/dashboard/_groups_head.html.haml b/app/views/dashboard/_groups_head.html.haml index 23c145ebbb4..c6d5937a3c3 100644 --- a/app/views/dashboard/_groups_head.html.haml +++ b/app/views/dashboard/_groups_head.html.haml @@ -6,7 +6,10 @@ = nav_link(page: explore_groups_path) do = link_to explore_groups_path, title: 'Explore groups' do Explore Groups - - if current_user.can_create_group? - .nav-controls + .nav-controls + = form_tag request.path, method: :get, class: 'group-filter-form', id: 'group-filter-form' do |f| + = search_field_tag :filter_groups, params[:filter_groups], placeholder: 'Filter by name...', class: 'group-filter-form-field form-control input-short js-groups-list-filter', spellcheck: false, id: 'group-filter-form-field', tabindex: "2" + = render 'shared/groups/dropdown' + - if current_user.can_create_group? = link_to new_group_path, class: "btn btn-new" do New Group diff --git a/app/views/dashboard/groups/_groups.html.haml b/app/views/dashboard/groups/_groups.html.haml new file mode 100644 index 00000000000..6c3bf1a2b3b --- /dev/null +++ b/app/views/dashboard/groups/_groups.html.haml @@ -0,0 +1,6 @@ +.js-groups-list-holder + %ul.content-list + - @group_members.each do |group_member| + = render 'shared/groups/group', group: group_member.group, group_member: group_member + + = paginate @group_members, theme: 'gitlab' diff --git a/app/views/dashboard/groups/index.html.haml b/app/views/dashboard/groups/index.html.haml index 1a679c51774..73ab2c95ff9 100644 --- a/app/views/dashboard/groups/index.html.haml +++ b/app/views/dashboard/groups/index.html.haml @@ -5,9 +5,4 @@ - if @group_members.empty? = render 'empty_state' - else - %ul.content-list - - @group_members.each do |group_member| - - group = group_member.group - = render 'shared/groups/group', group: group, group_member: group_member - - = paginate @group_members, theme: 'gitlab' + = render 'groups' diff --git a/app/views/explore/groups/_groups.html.haml b/app/views/explore/groups/_groups.html.haml new file mode 100644 index 00000000000..794c6d1d170 --- /dev/null +++ b/app/views/explore/groups/_groups.html.haml @@ -0,0 +1,6 @@ +.js-groups-list-holder + %ul.content-list + - @groups.each do |group| + = render 'shared/groups/group', group: group + + = paginate @groups, theme: 'gitlab' diff --git a/app/views/explore/groups/index.html.haml b/app/views/explore/groups/index.html.haml index 73cf6e87eb4..7f1bacc91cb 100644 --- a/app/views/explore/groups/index.html.haml +++ b/app/views/explore/groups/index.html.haml @@ -6,40 +6,10 @@ - else = render 'explore/head' -.row-content-block.clearfix - .pull-left - = form_tag explore_groups_path, method: :get, class: 'form-inline form-tiny' do |f| - = hidden_field_tag :sort, @sort - .form-group - = search_field_tag :search, params[:search], placeholder: "Filter by name", class: "form-control search-text-input", id: "groups_search", spellcheck: false - .form-group - = button_tag 'Search', class: "btn btn-default" - - .pull-right - .dropdown.inline - %button.dropdown-toggle{ type: 'button', 'data-toggle' => 'dropdown' } - %span.light - - if @sort.present? - = sort_options_hash[@sort] - - else - = sort_title_recently_created - = icon('chevron-down') - %ul.dropdown-menu.dropdown-menu-align-right - %li - = link_to explore_groups_path(sort: sort_value_recently_created) do - = sort_title_recently_created - = link_to explore_groups_path(sort: sort_value_oldest_created) do - = sort_title_oldest_created - = link_to explore_groups_path(sort: sort_value_recently_updated) do - = sort_title_recently_updated - = link_to explore_groups_path(sort: sort_value_oldest_updated) do - = sort_title_oldest_updated - -%ul.content-list - - @groups.each do |group| - = render 'shared/groups/group', group: group - - unless @groups.present? - .nothing-here-block No public groups +- if @groups.present? + = render 'groups' +- else + .nothing-here-block No public groups = paginate @groups, theme: "gitlab" diff --git a/app/views/shared/groups/_dropdown.html.haml b/app/views/shared/groups/_dropdown.html.haml new file mode 100644 index 00000000000..37589b634fa --- /dev/null +++ b/app/views/shared/groups/_dropdown.html.haml @@ -0,0 +1,18 @@ +.dropdown.inline + %button.dropdown-toggle{ type: 'button', 'data-toggle' => 'dropdown' } + %span.light + - if @sort.present? + = sort_options_hash[@sort] + - else + = sort_title_recently_created + = icon('chevron-down') + %ul.dropdown-menu.dropdown-menu-align-right + %li + = link_to filter_groups_path(sort: sort_value_recently_created) do + = sort_title_recently_created + = link_to filter_groups_path(sort: sort_value_oldest_created) do + = sort_title_oldest_created + = link_to filter_groups_path(sort: sort_value_recently_updated) do + = sort_title_recently_updated + = link_to filter_groups_path(sort: sort_value_oldest_updated) do + = sort_title_oldest_updated |