Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
52d59a4e
Commit
52d59a4e
authored
Apr 25, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Load milestone tabs asynchronously
parent
f00bb1c2
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
118 additions
and
20 deletions
+118
-20
app/assets/javascripts/milestone.js
app/assets/javascripts/milestone.js
+20
-9
app/controllers/concerns/milestone_actions.rb
app/controllers/concerns/milestone_actions.rb
+42
-0
app/controllers/groups/milestones_controller.rb
app/controllers/groups/milestones_controller.rb
+3
-1
app/controllers/projects/milestones_controller.rb
app/controllers/projects/milestones_controller.rb
+3
-1
app/helpers/milestones_helper.rb
app/helpers/milestones_helper.rb
+24
-0
app/views/shared/milestones/_tabs.html.haml
app/views/shared/milestones/_tabs.html.haml
+16
-8
config/routes/group.rb
config/routes/group.rb
+7
-1
config/routes/project.rb
config/routes/project.rb
+3
-0
No files found.
app/assets/javascripts/milestone.js
View file @
52d59a4e
...
@@ -81,9 +81,7 @@
...
@@ -81,9 +81,7 @@
};
};
function
Milestone
()
{
function
Milestone
()
{
var
oldMouseStart
;
this
.
bindIssuesSorting
();
this
.
bindIssuesSorting
();
this
.
bindMergeRequestSorting
();
this
.
bindTabsSwitching
();
this
.
bindTabsSwitching
();
}
}
...
@@ -100,13 +98,14 @@
...
@@ -100,13 +98,14 @@
};
};
Milestone
.
prototype
.
bindTabsSwitching
=
function
()
{
Milestone
.
prototype
.
bindTabsSwitching
=
function
()
{
return
$
(
'
a[data-toggle="tab"]
'
).
on
(
'
show.bs.tab
'
,
function
(
e
)
{
return
$
(
'
a[data-toggle="tab"]
'
).
on
(
'
show.bs.tab
'
,
(
e
)
=>
{
var
currentTabClass
,
previousTabClass
;
const
$target
=
$
(
e
.
target
);
currentTabClass
=
$
(
e
.
target
).
data
(
'
show
'
);
const
endpoint
=
$target
.
data
(
'
endpoint
'
);
previousTabClass
=
$
(
e
.
relatedTarget
).
data
(
'
show
'
);
$
(
previousTabClass
).
hide
();
if
(
endpoint
&&
!
$target
.
hasClass
(
'
is-loaded
'
))
{
$
(
currentTabClass
).
removeClass
(
'
hidden
'
);
this
.
loadMergeRequests
(
$target
.
attr
(
'
href
'
),
endpoint
)
return
$
(
currentTabClass
).
show
();
.
done
(()
=>
$target
.
addClass
(
'
is-loaded
'
));
}
});
});
};
};
...
@@ -169,6 +168,18 @@
...
@@ -169,6 +168,18 @@
});
});
};
};
Milestone
.
prototype
.
loadMergeRequests
=
function
(
elId
,
url
)
{
return
$
.
ajax
({
url
,
dataType
:
'
JSON
'
,
})
.
fail
(()
=>
new
Flash
(
'
Error loading merge requests
'
))
.
done
((
data
)
=>
{
$
(
elId
).
html
(
data
.
html
);
this
.
bindMergeRequestSorting
();
});
};
return
Milestone
;
return
Milestone
;
})();
})();
}).
call
(
window
);
}).
call
(
window
);
app/controllers/concerns/milestone_actions.rb
0 → 100644
View file @
52d59a4e
module
MilestoneActions
extend
ActiveSupport
::
Concern
def
merge_requests
respond_to
do
|
format
|
format
.
json
do
render
json:
tabs_json
(
"shared/milestones/_merge_requests_tab"
,
{
merge_requests:
@milestone
.
merge_requests
,
show_project_name:
true
})
end
end
end
def
participants
respond_to
do
|
format
|
format
.
json
do
render
json:
tabs_json
(
"shared/milestones/_participants_tab"
,
{
users:
@milestone
.
participants
})
end
end
end
def
labels
respond_to
do
|
format
|
format
.
json
do
render
json:
tabs_json
(
"shared/milestones/_labels_tab"
,
{
labels:
@milestone
.
labels
})
end
end
end
private
def
tabs_json
(
partial
,
data
=
{})
{
html:
view_to_html_string
(
partial
,
data
)
}
end
end
app/controllers/groups/milestones_controller.rb
View file @
52d59a4e
class
Groups::MilestonesController
<
Groups
::
ApplicationController
class
Groups::MilestonesController
<
Groups
::
ApplicationController
include
MilestoneActions
before_action
:group_projects
before_action
:group_projects
before_action
:milestone
,
only:
[
:show
,
:update
]
before_action
:milestone
,
only:
[
:show
,
:update
,
:merge_requests
,
:participants
,
:labels
]
before_action
:authorize_admin_milestones!
,
only:
[
:new
,
:create
,
:update
]
before_action
:authorize_admin_milestones!
,
only:
[
:new
,
:create
,
:update
]
def
index
def
index
...
...
app/controllers/projects/milestones_controller.rb
View file @
52d59a4e
class
Projects::MilestonesController
<
Projects
::
ApplicationController
class
Projects::MilestonesController
<
Projects
::
ApplicationController
include
MilestoneActions
before_action
:module_enabled
before_action
:module_enabled
before_action
:milestone
,
only:
[
:edit
,
:update
,
:destroy
,
:show
,
:sort_issues
,
:sort_merge_requests
]
before_action
:milestone
,
only:
[
:edit
,
:update
,
:destroy
,
:show
,
:sort_issues
,
:sort_merge_requests
,
:merge_requests
,
:participants
,
:labels
]
# Allow read any milestone
# Allow read any milestone
before_action
:authorize_read_milestone!
before_action
:authorize_read_milestone!
...
...
app/helpers/milestones_helper.rb
View file @
52d59a4e
...
@@ -115,4 +115,28 @@ module MilestonesHelper
...
@@ -115,4 +115,28 @@ module MilestonesHelper
end
end
end
end
end
end
def
milestone_merge_request_path
(
milestone
)
if
@project
merge_requests_namespace_project_milestone_path
(
@project
.
namespace
,
@project
,
milestone
,
format: :json
)
elsif
@group
merge_requests_group_milestone_path
(
@group
,
milestone
.
safe_title
,
title:
milestone
.
title
,
format: :json
)
end
end
def
milestone_participants_path
(
milestone
)
if
@project
participants_namespace_project_milestone_path
(
@project
.
namespace
,
@project
,
milestone
,
format: :json
)
elsif
@group
participants_group_milestone_path
(
@group
,
milestone
.
safe_title
,
title:
milestone
.
title
,
format: :json
)
end
end
def
milestone_labels_path
(
milestone
)
if
@project
labels_namespace_project_milestone_path
(
@project
.
namespace
,
@project
,
milestone
,
format: :json
)
elsif
@group
labels_group_milestone_path
(
@group
,
milestone
.
safe_title
,
title:
milestone
.
title
,
format: :json
)
end
end
end
end
app/views/shared/milestones/_tabs.html.haml
View file @
52d59a4e
...
@@ -8,20 +8,20 @@
...
@@ -8,20 +8,20 @@
Issues
Issues
%span
.badge
=
milestone
.
issues_visible_to_user
(
current_user
).
size
%span
.badge
=
milestone
.
issues_visible_to_user
(
current_user
).
size
%li
%li
=
link_to
'#tab-merge-requests'
,
'data-toggle'
=>
'tab'
,
'data-
show'
=>
'.tab-merge-requests-buttons'
do
=
link_to
'#tab-merge-requests'
,
'data-toggle'
=>
'tab'
,
'data-
endpoint'
:
milestone_merge_request_path
(
milestone
)
do
Merge Requests
Merge Requests
%span
.badge
=
milestone
.
merge_requests
.
size
%span
.badge
=
milestone
.
merge_requests
.
size
-
else
-
else
%li
.active
%li
.active
=
link_to
'#tab-merge-requests'
,
'data-toggle'
=>
'tab'
,
'data-
show'
=>
'.tab-merge-requests-buttons'
do
=
link_to
'#tab-merge-requests'
,
'data-toggle'
=>
'tab'
,
'data-
endpoint'
:
milestone_merge_request_path
(
milestone
)
do
Merge Requests
Merge Requests
%span
.badge
=
milestone
.
merge_requests
.
size
%span
.badge
=
milestone
.
merge_requests
.
size
%li
%li
=
link_to
'#tab-participants'
,
'data-toggle'
=>
'tab'
do
=
link_to
'#tab-participants'
,
'data-toggle'
=>
'tab'
,
'data-endpoint'
:
milestone_participants_path
(
milestone
)
do
Participants
Participants
%span
.badge
=
milestone
.
participants
.
count
%span
.badge
=
milestone
.
participants
.
count
%li
%li
=
link_to
'#tab-labels'
,
'data-toggle'
=>
'tab'
do
=
link_to
'#tab-labels'
,
'data-toggle'
=>
'tab'
,
'data-endpoint'
:
milestone_labels_path
(
milestone
)
do
Labels
Labels
%span
.badge
=
milestone
.
labels
.
count
%span
.badge
=
milestone
.
labels
.
count
...
@@ -33,11 +33,19 @@
...
@@ -33,11 +33,19 @@
.tab-pane.active
#tab-issues
.tab-pane.active
#tab-issues
=
render
'shared/milestones/issues_tab'
,
issues:
milestone
.
issues_visible_to_user
(
current_user
).
include_associations
,
show_project_name:
show_project_name
,
show_full_project_name:
show_full_project_name
=
render
'shared/milestones/issues_tab'
,
issues:
milestone
.
issues_visible_to_user
(
current_user
).
include_associations
,
show_project_name:
show_project_name
,
show_full_project_name:
show_full_project_name
.tab-pane
#tab-merge-requests
.tab-pane
#tab-merge-requests
=
render
'shared/milestones/merge_requests_tab'
,
merge_requests:
milestone
.
merge_requests
,
show_project_name:
show_project_name
,
show_full_project_name:
show_full_project_name
-# loaded async
.text-center.prepend-top-default
=
icon
(
'spin spinner 2x'
)
-
else
-
else
.tab-pane.active
#tab-merge-requests
.tab-pane.active
#tab-merge-requests
=
render
'shared/milestones/merge_requests_tab'
,
merge_requests:
milestone
.
merge_requests
,
show_project_name:
show_project_name
,
show_full_project_name:
show_full_project_name
-# loaded async
.text-center.prepend-top-default
=
icon
(
'spin spinner 2x'
)
.tab-pane
#tab-participants
.tab-pane
#tab-participants
=
render
'shared/milestones/participants_tab'
,
users:
milestone
.
participants
-# loaded async
.text-center.prepend-top-default
=
icon
(
'spin spinner 2x'
)
.tab-pane
#tab-labels
.tab-pane
#tab-labels
=
render
'shared/milestones/labels_tab'
,
labels:
milestone
.
labels
-# loaded async
.text-center.prepend-top-default
=
icon
(
'spin spinner 2x'
)
config/routes/group.rb
View file @
52d59a4e
...
@@ -10,7 +10,13 @@ scope(path: 'groups/*group_id',
...
@@ -10,7 +10,13 @@ scope(path: 'groups/*group_id',
end
end
resource
:avatar
,
only:
[
:destroy
]
resource
:avatar
,
only:
[
:destroy
]
resources
:milestones
,
constraints:
{
id:
/[^\/]+/
},
only:
[
:index
,
:show
,
:update
,
:new
,
:create
]
resources
:milestones
,
constraints:
{
id:
/[^\/]+/
},
only:
[
:index
,
:show
,
:update
,
:new
,
:create
]
do
member
do
get
:merge_requests
get
:participants
get
:labels
end
end
resources
:labels
,
except:
[
:show
]
do
resources
:labels
,
except:
[
:show
]
do
post
:toggle_subscription
,
on: :member
post
:toggle_subscription
,
on: :member
...
...
config/routes/project.rb
View file @
52d59a4e
...
@@ -205,6 +205,9 @@ constraints(ProjectUrlConstrainer.new) do
...
@@ -205,6 +205,9 @@ constraints(ProjectUrlConstrainer.new) do
member
do
member
do
put
:sort_issues
put
:sort_issues
put
:sort_merge_requests
put
:sort_merge_requests
get
:merge_requests
get
:participants
get
:labels
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment