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
5ab3e38e
Commit
5ab3e38e
authored
Sep 04, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1371 from tsigo/project_panel
Refactor the project clone panel
parents
874a86f8
0bc4ecfe
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
66 additions
and
96 deletions
+66
-96
app/assets/javascripts/projects.js
app/assets/javascripts/projects.js
+0
-25
app/assets/javascripts/projects.js.coffee
app/assets/javascripts/projects.js.coffee
+21
-0
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+1
-1
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+1
-1
app/roles/repository.rb
app/roles/repository.rb
+8
-4
app/views/projects/_clone_panel.html.haml
app/views/projects/_clone_panel.html.haml
+11
-11
app/views/projects/_show.html.haml
app/views/projects/_show.html.haml
+0
-23
app/views/projects/empty.html.haml
app/views/projects/empty.html.haml
+2
-21
app/views/projects/show.html.haml
app/views/projects/show.html.haml
+0
-5
app/views/refs/_head.html.haml
app/views/refs/_head.html.haml
+0
-5
spec/roles/repository_spec.rb
spec/roles/repository_spec.rb
+22
-0
No files found.
app/assets/javascripts/projects.js
deleted
100644 → 0
View file @
874a86f8
function
Projects
()
{
$
(
"
#project_name
"
).
live
(
"
change
"
,
function
(){
var
slug
=
slugify
(
$
(
this
).
val
());
$
(
"
#project_code
"
).
val
(
slug
);
$
(
"
#project_path
"
).
val
(
slug
);
});
$
(
'
.new_project, .edit_project
'
).
live
(
'
ajax:before
'
,
function
()
{
$
(
'
.project_new_holder, .project_edit_holder
'
).
hide
();
$
(
'
.save-project-loader
'
).
show
();
});
$
(
'
form #project_default_branch
'
).
chosen
();
disableButtonIfEmtpyField
(
"
#project_name
"
,
"
.project-submit
"
)
}
function
initGitCloneSwitcher
()
{
var
link_sel
=
"
.project_clone_holder button
"
;
$
(
link_sel
).
bind
(
"
click
"
,
function
(
e
)
{
$
(
link_sel
).
removeClass
(
"
active
"
);
$
(
this
).
addClass
(
"
active
"
);
$
(
"
#project_clone
"
).
val
(
$
(
this
).
attr
(
"
data-clone
"
));
})
}
app/assets/javascripts/projects.js.coffee
0 → 100644
View file @
5ab3e38e
window
.
Projects
=
->
$
(
"#project_name"
).
live
"change"
,
->
slug
=
slugify
(
$
(
this
).
val
())
$
(
"#project_code"
).
val
(
slug
)
$
(
"#project_path"
).
val
(
slug
)
$
(
".new_project, .edit_project"
).
live
"ajax:before"
,
->
$
(
".project_new_holder, .project_edit_holder"
).
hide
()
$
(
".save-project-loader"
).
show
()
$
(
"form #project_default_branch"
).
chosen
()
disableButtonIfEmtpyField
"#project_name"
,
".project-submit"
# Git clone panel switcher
$
->
scope
=
$
(
'.project_clone_holder'
)
if
scope
.
length
>
0
$
(
'a, button'
,
scope
).
click
->
$
(
'a, button'
,
scope
).
removeClass
(
'active'
)
$
(
this
).
addClass
(
'active'
)
$
(
'#project_clone'
,
scope
).
val
(
$
(
this
).
data
(
'clone'
))
app/controllers/application_controller.rb
View file @
5ab3e38e
...
...
@@ -135,7 +135,7 @@ class ApplicationController < ActionController::Base
end
def
require_non_empty_project
redirect_to
@project
unless
@project
.
repo_exists?
&&
@project
.
has_commits
?
redirect_to
@project
if
@project
.
empty_repo
?
end
def
no_cache_headers
...
...
app/controllers/projects_controller.rb
View file @
5ab3e38e
...
...
@@ -50,7 +50,7 @@ class ProjectsController < ApplicationController
respond_to
do
|
format
|
format
.
html
do
if
@project
.
repo_exists?
&&
@project
.
has_commits
?
unless
@project
.
empty_repo
?
@last_push
=
current_user
.
recent_push
(
@project
.
id
)
render
:show
else
...
...
app/roles/repository.rb
View file @
5ab3e38e
...
...
@@ -8,6 +8,10 @@ module Repository
false
end
def
empty_repo?
!
repo_exists?
||
!
has_commits?
end
def
commit
(
commit_id
=
nil
)
Commit
.
find_or_first
(
repo
,
commit_id
,
root_ref
)
end
...
...
app/views/projects/_clone_panel.html.haml
View file @
5ab3e38e
...
...
@@ -8,6 +8,7 @@
=
text_field_tag
:project_clone
,
@project
.
url_to_repo
,
class:
"one_click_select span5"
.span4.right
.right
-
unless
@project
.
empty_repo?
-
if
can?
current_user
,
:download_code
,
@project
=
link_to
archive_project_repository_path
(
@project
),
class:
"btn small grouped"
do
%i
.icon-download-alt
...
...
@@ -18,4 +19,3 @@
-
if
@project
.
issues_enabled
&&
can?
(
current_user
,
:write_issue
,
@project
)
=
link_to
new_project_issue_path
(
@project
),
title:
"New Issue"
,
class:
"btn small grouped"
do
Issue
app/views/projects/_show.html.haml
deleted
100644 → 0
View file @
874a86f8
%h5
.title
=
@project
.
name
%br
%div
%a
.btn.info
{
href:
tree_project_ref_path
(
@project
,
@project
.
root_ref
)}
Browse code
%a
.btn
{
href:
project_commits_path
(
@project
)}
Commits
%strong
.right
=
link_to
project_path
(
@project
)
do
Switch to project
→
%br
.alert-message.block-message.warning
.input
.input-prepend
%span
.add-on
git clone
=
text_field_tag
:project_clone
,
@project
.
url_to_repo
,
class:
"xlarge one_click_select git_clone_url"
=
simple_format
@project
.
description
-
unless
@events
.
blank?
%h4
.middle_title
Recent Activity
.content_list
=
render
@events
app/views/projects/empty.html.haml
View file @
5ab3e38e
=
render
'shared/no_ssh'
.project_clone_panel
.row
.span7
.form-horizontal
.input-prepend.project_clone_holder
=
link_to
"SSH"
,
"#"
,
class:
"btn small active"
,
:"data-clone"
=>
@project
.
ssh_url_to_repo
=
link_to
"HTTP"
,
"#"
,
class:
"btn small"
,
:"data-clone"
=>
@project
.
http_url_to_repo
=
text_field_tag
:project_clone
,
@project
.
url_to_repo
,
class:
"one_click_select span5"
=
render
'clone_panel'
%div
.git-empty
%h4
Git global setup:
%pre
.dark
...
...
@@ -36,16 +30,3 @@
-
if
can?
current_user
,
:admin_project
,
@project
.prepend-top-20
=
link_to
'Remove project'
,
@project
,
confirm:
'Are you sure?'
,
method: :delete
,
class:
"btn danger right"
:javascript
$
(
function
(){
var
link_sel
=
"
.project_clone_holder a
"
;
$
(
link_sel
).
bind
(
"
click
"
,
function
()
{
$
(
link_sel
).
removeClass
(
"
active
"
);
$
(
this
).
addClass
(
"
active
"
);
$
(
"
#project_clone
"
).
val
(
$
(
this
).
attr
(
"
data-clone
"
));
})
})
app/views/projects/show.html.haml
View file @
5ab3e38e
...
...
@@ -2,8 +2,3 @@
=
render
'clone_panel'
=
render
"events/event_last_push"
,
event:
@last_push
.content_list
=
render
@events
:javascript
$
(
function
(){
initGitCloneSwitcher
();
})
app/views/refs/_head.html.haml
View file @
5ab3e38e
...
...
@@ -12,8 +12,3 @@
%button
{
class:
"btn small active"
,
:"data-clone"
=>
@project
.
ssh_url_to_repo
}
SSH
%button
{
class:
"btn small"
,
:"data-clone"
=>
@project
.
http_url_to_repo
}
HTTP
=
text_field_tag
:project_clone
,
@project
.
url_to_repo
,
class:
"one_click_select span5"
:javascript
$
(
function
(){
initGitCloneSwitcher
();
})
spec/roles/repository_spec.rb
0 → 100644
View file @
5ab3e38e
require
'spec_helper'
describe
Project
,
"Repository"
do
let
(
:project
)
{
build
(
:project
)
}
describe
"#empty_repo?"
do
it
"should return true if the repo doesn't exist"
do
project
.
stub
(
repo_exists?:
false
,
has_commits?:
true
)
project
.
should
be_empty_repo
end
it
"should return true if the repo has commits"
do
project
.
stub
(
repo_exists?:
true
,
has_commits?:
false
)
project
.
should
be_empty_repo
end
it
"should return false if the repo exists and has commits"
do
project
.
stub
(
repo_exists?:
true
,
has_commits?:
true
)
project
.
should_not
be_empty_repo
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