Commit e9c6d4ad authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'refactor_issues' of dev.gitlabhq.com:gitlab/gitlabhq

parents 450c434a adb17d60
function switchToNewIssue(){
$(".issues_content").hide("fade", { direction: "left" }, 150, function(){
$('select#issue_assignee_id').chosen();
$('select#issue_milestone_id').chosen();
$("#new_issue_dialog").show("fade", { direction: "right" }, 150);
$('.top-tabs .add_new').hide();
disableButtonIfEmptyField("#issue_title", ".save-btn");
GitLab.GfmAutoComplete.setup();
});
}
function switchToEditIssue(){
$(".issues_content").hide("fade", { direction: "left" }, 150, function(){
$('select#issue_assignee_id').chosen();
$('select#issue_milestone_id').chosen();
$("#edit_issue_dialog").show("fade", { direction: "right" }, 150);
$('.add_new').hide();
disableButtonIfEmptyField("#issue_title", ".save-btn");
GitLab.GfmAutoComplete.setup();
});
}
function switchFromNewIssue(){
backToIssues();
}
function switchFromEditIssue(){
backToIssues();
}
function backToIssues(){
$("#edit_issue_dialog, #new_issue_dialog").hide("fade", { direction: "right" }, 150, function(){
$(".issues_content").show("fade", { direction: "left" }, 150, function() {
$("#edit_issue_dialog").html("");
$("#new_issue_dialog").html("");
$('.add_new').show();
});
});
}
function initIssuesSearch() { function initIssuesSearch() {
var href = $('#issue_search_form').attr('action'); var href = $('#issue_search_form').attr('action');
var last_terms = ''; var last_terms = '';
...@@ -76,23 +36,15 @@ function issuesPage(){ ...@@ -76,23 +36,15 @@ function issuesPage(){
$(this).closest("form").submit(); $(this).closest("form").submit();
}); });
$("#new_issue_link").click(function(){ $('body').on('ajax:success', '.close_issue, .reopen_issue', function(){
updateNewIssueURL();
});
$('body').on('ajax:success', '.close_issue, .reopen_issue, #new_issue', function(){
var t = $(this), var t = $(this),
totalIssues, totalIssues,
reopen = t.hasClass('reopen_issue'), reopen = t.hasClass('reopen_issue');
newIssue = false; $('.issue_counter').each(function(){
if( this.id == 'new_issue' ){
newIssue = true;
}
$('.issue_counter, #new_issue').each(function(){
var issue = $(this); var issue = $(this);
totalIssues = parseInt( $(this).html(), 10 ); totalIssues = parseInt( $(this).html(), 10 );
if( newIssue || ( reopen && issue.closest('.main_menu').length ) ){ if( reopen && issue.closest('.main_menu').length ){
$(this).html( totalIssues+1 ); $(this).html( totalIssues+1 );
}else { }else {
$(this).html( totalIssues-1 ); $(this).html( totalIssues-1 );
...@@ -126,20 +78,3 @@ function issuesCheckChanged() { ...@@ -126,20 +78,3 @@ function issuesCheckChanged() {
$('.issues_filters').show(); $('.issues_filters').show();
} }
} }
function updateNewIssueURL(){
var new_issue_link = $("#new_issue_link");
var milestone_id = $("#milestone_id").val();
var assignee_id = $("#assignee_id").val();
var new_href = "";
if(milestone_id){
new_href = "issue[milestone_id]=" + milestone_id + "&";
}
if(assignee_id){
new_href = new_href + "issue[assignee_id]=" + assignee_id;
}
if(new_href.length){
new_href = new_issue_link.attr("href") + "?" + new_href;
new_issue_link.attr("href", new_href);
}
};
class IssuesController < ProjectResourceController class IssuesController < ProjectResourceController
before_filter :module_enabled before_filter :module_enabled
before_filter :issue, only: [:edit, :update, :destroy, :show] before_filter :issue, only: [:edit, :update, :show]
# Allow read any issue # Allow read any issue
before_filter :authorize_read_issue! before_filter :authorize_read_issue!
...@@ -11,9 +11,6 @@ class IssuesController < ProjectResourceController ...@@ -11,9 +11,6 @@ class IssuesController < ProjectResourceController
# Allow modify issue # Allow modify issue
before_filter :authorize_modify_issue!, only: [:edit, :update] before_filter :authorize_modify_issue!, only: [:edit, :update]
# Allow destroy issue
before_filter :authorize_admin_issue!, only: [:destroy]
respond_to :js, :html respond_to :js, :html
def index def index
...@@ -77,15 +74,6 @@ class IssuesController < ProjectResourceController ...@@ -77,15 +74,6 @@ class IssuesController < ProjectResourceController
end end
end end
def destroy
@issue.destroy
respond_to do |format|
format.html { redirect_to project_issues_path }
format.js { render nothing: true }
end
end
def sort def sort
return render_404 unless can?(current_user, :admin_issue, @project) return render_404 unless can?(current_user, :admin_issue, @project)
......
class MergeRequestsController < ProjectResourceController class MergeRequestsController < ProjectResourceController
before_filter :module_enabled before_filter :module_enabled
before_filter :merge_request, only: [:edit, :update, :destroy, :show, :commits, :diffs, :automerge, :automerge_check, :ci_status] before_filter :merge_request, only: [:edit, :update, :show, :commits, :diffs, :automerge, :automerge_check, :ci_status]
before_filter :validates_merge_request, only: [:show, :diffs] before_filter :validates_merge_request, only: [:show, :diffs]
before_filter :define_show_vars, only: [:show, :diffs] before_filter :define_show_vars, only: [:show, :diffs]
...@@ -13,9 +13,6 @@ class MergeRequestsController < ProjectResourceController ...@@ -13,9 +13,6 @@ class MergeRequestsController < ProjectResourceController
# Allow modify merge_request # Allow modify merge_request
before_filter :authorize_modify_merge_request!, only: [:close, :edit, :update, :sort] before_filter :authorize_modify_merge_request!, only: [:close, :edit, :update, :sort]
# Allow destroy merge_request
before_filter :authorize_admin_merge_request!, only: [:destroy]
def index def index
@merge_requests = MergeRequestsLoadContext.new(project, current_user, params).execute @merge_requests = MergeRequestsLoadContext.new(project, current_user, params).execute
end end
...@@ -85,14 +82,6 @@ class MergeRequestsController < ProjectResourceController ...@@ -85,14 +82,6 @@ class MergeRequestsController < ProjectResourceController
end end
end end
def destroy
@merge_request.destroy
respond_to do |format|
format.html { redirect_to project_merge_requests_url(@project) }
end
end
def branch_from def branch_from
@commit = project.commit(params[:ref]) @commit = project.commit(params[:ref])
@commit = CommitDecorator.decorate(@commit) @commit = CommitDecorator.decorate(@commit)
......
...@@ -62,7 +62,11 @@ class Milestone < ActiveRecord::Base ...@@ -62,7 +62,11 @@ class Milestone < ActiveRecord::Base
end end
def can_be_closed? def can_be_closed?
issues.count > 0 && open? && issues.opened.count.zero? open? && issues.opened.count.zero?
end
def is_empty?
total_items_count.zero?
end end
def open? def open?
......
%div.issue-form-holder %div.issue-form-holder
%h3.page_title= @issue.new_record? ? "New Issue" : "Edit Issue ##{@issue.id}" %h3.page_title= @issue.new_record? ? "New Issue" : "Edit Issue ##{@issue.id}"
= form_for [@project, @issue], remote: request.xhr? do |f| = form_for [@project, @issue] do |f|
-if @issue.errors.any? -if @issue.errors.any?
.alert-message.block-message.error .alert-message.block-message.error
%ul
- @issue.errors.full_messages.each do |msg| - @issue.errors.full_messages.each do |msg|
%li= msg %span= msg
%br
.issue_form_box .issue_form_box
.issue_title .issue_title
.clearfix .clearfix
= f.label :title do = f.label :title do
%strong= "Subject *" %strong= "Subject *"
.input .input
= f.text_field :title, maxlength: 255, class: "xxlarge js-gfm-input", autofocus: true = f.text_field :title, maxlength: 255, class: "xxlarge js-gfm-input", autofocus: true, required: true
.issue_middle_block .issue_middle_block
.issue_assignee .issue_assignee
= f.label :assignee_id do = f.label :assignee_id do
...@@ -47,14 +47,8 @@ ...@@ -47,14 +47,8 @@
-else -else
= f.submit 'Save changes', class: "save-btn btn" = f.submit 'Save changes', class: "save-btn btn"
- cancel_class = 'btn cancel-btn' - cancel_path = @issue.new_record? ? project_issues_path(@project) : project_issue_path(@project, @issue)
- if request.xhr? = link_to "Cancel", cancel_path, class: 'btn cancel-btn'
= link_to "Cancel", "#back", onclick: "backToIssues();", class: cancel_class
- else
- if @issue.new_record?
= link_to "Cancel", project_issues_path(@project), class: cancel_class
- else
= link_to "Cancel", project_issue_path(@project, @issue), class: cancel_class
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
= link_to 'Reopen', project_issue_path(issue.project, issue, issue: {closed: false }, status_only: true), method: :put, class: "btn small grouped reopen_issue", remote: true = link_to 'Reopen', project_issue_path(issue.project, issue, issue: {closed: false }, status_only: true), method: :put, class: "btn small grouped reopen_issue", remote: true
- else - else
= link_to 'Close', project_issue_path(issue.project, issue, issue: {closed: true }, status_only: true), method: :put, class: "btn small grouped close_issue", remote: true = link_to 'Close', project_issue_path(issue.project, issue, issue: {closed: true }, status_only: true), method: :put, class: "btn small grouped close_issue", remote: true
= link_to edit_project_issue_path(issue.project, issue), class: "btn small edit-issue-link grouped", remote: true do = link_to edit_project_issue_path(issue.project, issue), class: "btn small edit-issue-link grouped" do
%i.icon-edit %i.icon-edit
Edit Edit
......
- if @issue.valid?
:plain
switchFromNewIssue();
$("#issues-table").prepend("#{escape_javascript(render(partial: 'show', locals: {issue: @issue}))}");
$.ajax({type: "GET", url: location.href, dataType: "script"});
- else
:plain
$("#new_issue_dialog").empty();
$("#new_issue_dialog").append("#{escape_javascript(render('form'))}");
$('select#issue_assignee_id').chosen();
:plain
$("#edit_issue_dialog").html("#{escape_javascript(render('form'))}");
switchToEditIssue();
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
.right .right
.span5 .span5
- if can? current_user, :write_issue, @project - if can? current_user, :write_issue, @project
= link_to new_project_issue_path(@project), class: "right btn", title: "New Issue", remote: true, id: "new_issue_link" do = link_to new_project_issue_path(@project, issue: { assignee_id: params[:assignee_id], milestone_id: params[:milestone_id]}), class: "right btn", title: "New Issue", id: "new_issue_link" do
%i.icon-plus %i.icon-plus
New Issue New Issue
= form_tag search_project_issues_path(@project), method: :get, remote: true, id: "issue_search_form", class: :right do = form_tag search_project_issues_path(@project), method: :get, remote: true, id: "issue_search_form", class: :right do
...@@ -58,9 +58,6 @@ ...@@ -58,9 +58,6 @@
%ul#issues-table.well-list.issues_table %ul#issues-table.well-list.issues_table
= render "issues" = render "issues"
#new_issue_dialog
#edit_issue_dialog
:javascript :javascript
$(function(){ $(function(){
issuesPage(); issuesPage();
......
:plain
$("#new_issue_dialog").html("#{escape_javascript(render('form'))}");
switchToNewIssue();
- if params[:status_only]
- if @issue.valid?
:plain
$("##{dom_id(@issue)}").fadeOut();
- else
- if @issue.valid?
:plain
updatePage();
switchFromEditIssue();
- else
:plain
$("#edit_issue_dialog").empty();
$("#edit_issue_dialog").append("#{escape_javascript(render('form'))}");
$('select#issue_assignee_id').chosen();
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
.top_box_content .top_box_content
= f.label :title do = f.label :title do
%strong= "Title *" %strong= "Title *"
.input= f.text_field :title, class: "input-xxlarge pad js-gfm-input", maxlength: 255, rows: 5 .input= f.text_field :title, class: "input-xxlarge pad js-gfm-input", maxlength: 255, rows: 5, required: true
.merge_requests_middle_box .merge_requests_middle_box
.merge_requests_assignee .merge_requests_assignee
= f.label :assignee_id do = f.label :assignee_id do
......
...@@ -10,6 +10,9 @@ ...@@ -10,6 +10,9 @@
%span.cred (Expired) %span.cred (Expired)
%small %small
= milestone.expires_at = milestone.expires_at
- if milestone.is_empty?
%span.muted Empty
- else
.row .row
.span4 .span4
.progress.progress-info .progress.progress-info
......
...@@ -164,7 +164,7 @@ Gitlab::Application.routes.draw do ...@@ -164,7 +164,7 @@ Gitlab::Application.routes.draw do
end end
end end
resources :merge_requests, constraints: {id: /\d+/} do resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do
member do member do
get :diffs get :diffs
get :automerge get :automerge
...@@ -200,9 +200,9 @@ Gitlab::Application.routes.draw do ...@@ -200,9 +200,9 @@ Gitlab::Application.routes.draw do
:via => [:get, :post], constraints: {from: /.+/, to: /.+/} :via => [:get, :post], constraints: {from: /.+/, to: /.+/}
resources :team, controller: 'team_members', only: [:index] resources :team, controller: 'team_members', only: [:index]
resources :milestones resources :milestones, except: [:destroy]
resources :labels, only: [:index] resources :labels, only: [:index]
resources :issues do resources :issues, except: [:destroy] do
collection do collection do
post :sort post :sort
post :bulk_update post :bulk_update
......
...@@ -24,11 +24,9 @@ Feature: Project Issues ...@@ -24,11 +24,9 @@ Feature: Project Issues
Given I click link "Release 0.4" Given I click link "Release 0.4"
Then I should see issue "Release 0.4" Then I should see issue "Release 0.4"
@javascript
Scenario: I submit new unassigned issue Scenario: I submit new unassigned issue
Given I click link "New Issue" Given I click link "New Issue"
And I submit new issue "500 error on profile" And I submit new issue "500 error on profile"
Given I click link "500 error on profile"
Then I should see issue "500 error on profile" Then I should see issue "500 error on profile"
@javascript @javascript
...@@ -57,26 +55,19 @@ Feature: Project Issues ...@@ -57,26 +55,19 @@ Feature: Project Issues
Then I should see "Release 0.3" in issues Then I should see "Release 0.3" in issues
And I should not see "Release 0.4" in issues And I should not see "Release 0.4" in issues
# TODO: find out solution for poltergeist/phantomjs or remove # Disable this two cause of random failing
# @javascript # TODO: fix after v4.0 released
# Scenario: I clear search #@javascript
# Given I click link "All" #Scenario: I create Issue with pre-selected milestone
# And I fill in issue search with "Something" #Given project "Shop" has milestone "v2.2"
# And I fill in issue search with "" #And project "Shop" has milestone "v3.0"
# Then I should see "Release 0.4" in issues #And I visit project "Shop" issues page
# And I should see "Release 0.3" in issues #When I select milestone "v3.0"
#And I click link "New Issue"
#Then I should see selected milestone with title "v3.0"
@javascript #@javascript
Scenario: I create Issue with pre-selected milestone #Scenario: I create Issue with pre-selected assignee
Given project "Shop" has milestone "v2.2" #When I select first assignee from "Shop" project
And project "Shop" has milestone "v3.0" #And I click link "New Issue"
And I visit project "Shop" issues page #Then I should see first assignee from "Shop" as selected assignee
When I select milestone "v3.0"
And I click link "New Issue"
Then I should see selected milestone with title "v3.0"
@javascript
Scenario: I create Issue with pre-selected assignee
When I select first assignee from "Shop" project
And I click link "New Issue"
Then I should see first assignee from "Shop" as selected assignee
...@@ -95,7 +95,7 @@ class ProjectIssues < Spinach::FeatureSteps ...@@ -95,7 +95,7 @@ class ProjectIssues < Spinach::FeatureSteps
end end
Then 'I should see selected milestone with title "v3.0"' do Then 'I should see selected milestone with title "v3.0"' do
issues_milestone_selector = "#milestone_id_chzn > a" issues_milestone_selector = "#issue_milestone_id_chzn > a"
page.find(issues_milestone_selector).should have_content("v3.0") page.find(issues_milestone_selector).should have_content("v3.0")
end end
...@@ -106,7 +106,7 @@ class ProjectIssues < Spinach::FeatureSteps ...@@ -106,7 +106,7 @@ class ProjectIssues < Spinach::FeatureSteps
end end
Then 'I should see first assignee from "Shop" as selected assignee' do Then 'I should see first assignee from "Shop" as selected assignee' do
issues_assignee_selector = "#assignee_id_chzn > a" issues_assignee_selector = "#issue_assignee_id_chzn > a"
project = Project.find_by_name "Shop" project = Project.find_by_name "Shop"
assignee_name = project.users.first.name assignee_name = project.users.first.name
page.find(issues_assignee_selector).should have_content(assignee_name) page.find(issues_assignee_selector).should have_content(assignee_name)
......
...@@ -11,7 +11,7 @@ describe "Issues" do ...@@ -11,7 +11,7 @@ describe "Issues" do
project.add_access(user2, :read, :write) project.add_access(user2, :read, :write)
end end
describe "Edit issue", js: true do describe "Edit issue" do
let!(:issue) do let!(:issue) do
create(:issue, create(:issue,
author: @user, author: @user,
......
...@@ -245,6 +245,7 @@ describe MergeRequestsController, "routing" do ...@@ -245,6 +245,7 @@ describe MergeRequestsController, "routing" do
it_behaves_like "RESTful project resources" do it_behaves_like "RESTful project resources" do
let(:controller) { 'merge_requests' } let(:controller) { 'merge_requests' }
let(:actions) { [:index, :create, :new, :edit, :show, :update] }
end end
end end
...@@ -325,6 +326,7 @@ end ...@@ -325,6 +326,7 @@ end
describe MilestonesController, "routing" do describe MilestonesController, "routing" do
it_behaves_like "RESTful project resources" do it_behaves_like "RESTful project resources" do
let(:controller) { 'milestones' } let(:controller) { 'milestones' }
let(:actions) { [:index, :create, :new, :edit, :show, :update] }
end end
end end
...@@ -360,6 +362,7 @@ describe IssuesController, "routing" do ...@@ -360,6 +362,7 @@ describe IssuesController, "routing" do
it_behaves_like "RESTful project resources" do it_behaves_like "RESTful project resources" do
let(:controller) { 'issues' } let(:controller) { 'issues' }
let(:actions) { [:index, :create, :new, :edit, :show, :update] }
end end
end end
......
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