BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
da531c39
Commit
da531c39
authored
Feb 23, 2018
by
André Luís
Committed by
Phil Hughes
Feb 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Tip about Push to Create project on New Project page
parent
7834f63c
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
118 additions
and
10 deletions
+118
-10
common_utils.js
app/assets/javascripts/lib/utils/common_utils.js
+10
-0
main.js
app/assets/javascripts/main.js
+2
-8
project_new.js
app/assets/javascripts/projects/project_new.js
+31
-0
typography.scss
app/assets/stylesheets/framework/typography.scss
+4
-0
projects.scss
app/assets/stylesheets/pages/projects.scss
+6
-0
projects_helper.rb
app/helpers/projects_helper.rb
+11
-0
_new_project_push_tip.html.haml
app/views/projects/_new_project_push_tip.html.haml
+11
-0
new.html.haml
app/views/projects/new.html.haml
+7
-0
create-project.md
doc/gitlab-basics/create-project.md
+2
-2
projects_spec.rb
spec/features/projects_spec.rb
+18
-0
projects_helper_spec.rb
spec/helpers/projects_helper_spec.rb
+16
-0
No files found.
app/assets/javascripts/lib/utils/common_utils.js
View file @
da531c39
...
...
@@ -418,6 +418,16 @@ export const convertObjectPropsToCamelCase = (obj = {}) => {
export
const
imagePath
=
imgUrl
=>
`
${
gon
.
asset_host
||
''
}${
gon
.
relative_url_root
||
''
}
/assets/
${
imgUrl
}
`
;
export
const
addSelectOnFocusBehaviour
=
(
selector
=
'.js-select-on-focus'
)
=>
{
// Click a .js-select-on-focus field, select the contents
// Prevent a mouseup event from deselecting the input
$
(
selector
).
on
(
'focusin'
,
function
selectOnFocusCallback
()
{
$
(
this
).
select
().
one
(
'mouseup'
,
(
e
)
=>
{
e
.
preventDefault
();
});
});
};
window
.
gl
=
window
.
gl
||
{};
window
.
gl
.
utils
=
{
...(
window
.
gl
.
utils
||
{}),
...
...
app/assets/javascripts/main.js
View file @
da531c39
...
...
@@ -10,7 +10,7 @@ window.jQuery = jQuery;
window
.
$
=
jQuery
;
// lib/utils
import
{
handleLocationHash
}
from
'./lib/utils/common_utils'
;
import
{
handleLocationHash
,
addSelectOnFocusBehaviour
}
from
'./lib/utils/common_utils'
;
import
{
localTimeAgo
}
from
'./lib/utils/datetime_utility'
;
import
{
getLocationHash
,
visitUrl
}
from
'./lib/utils/url_utility'
;
...
...
@@ -104,13 +104,7 @@ document.addEventListener('DOMContentLoaded', () => {
return
true
;
});
// Click a .js-select-on-focus field, select the contents
// Prevent a mouseup event from deselecting the input
$
(
'.js-select-on-focus'
).
on
(
'focusin'
,
function
selectOnFocusCallback
()
{
$
(
this
).
select
().
one
(
'mouseup'
,
(
e
)
=>
{
e
.
preventDefault
();
});
});
addSelectOnFocusBehaviour
(
'.js-select-on-focus'
);
$
(
'.remove-row'
).
on
(
'ajax:success'
,
function
removeRowAjaxSuccessCallback
()
{
$
(
this
).
tooltip
(
'destroy'
)
...
...
app/assets/javascripts/projects/project_new.js
View file @
da531c39
import
{
addSelectOnFocusBehaviour
}
from
'../lib/utils/common_utils'
;
let
hasUserDefinedProjectPath
=
false
;
const
deriveProjectPathFromUrl
=
(
$projectImportUrl
)
=>
{
...
...
@@ -36,6 +38,7 @@ const bindEvents = () => {
const
$changeTemplateBtn
=
$
(
'.change-template'
);
const
$selectedIcon
=
$
(
'.selected-icon svg'
);
const
$templateProjectNameInput
=
$
(
'#template-project-name #project_path'
);
const
$pushNewProjectTipTrigger
=
$
(
'.push-new-project-tip'
);
if
(
$newProjectForm
.
length
!==
1
)
{
return
;
...
...
@@ -55,6 +58,34 @@ const bindEvents = () => {
$
(
'.btn_import_gitlab_project'
).
attr
(
'href'
,
`
${
importHref
}
?namespace_id=
${
$
(
'#project_namespace_id'
).
val
()}
&path=
${
$projectPath
.
val
()}
`
);
});
if
(
$pushNewProjectTipTrigger
)
{
$pushNewProjectTipTrigger
.
removeAttr
(
'rel'
)
.
removeAttr
(
'target'
)
.
on
(
'click'
,
(
e
)
=>
{
e
.
preventDefault
();
})
.
popover
({
title
:
$pushNewProjectTipTrigger
.
data
(
'title'
),
placement
:
'auto bottom'
,
html
:
'true'
,
content
:
$
(
'.push-new-project-tip-template'
).
html
(),
})
.
on
(
'shown.bs.popover'
,
()
=>
{
$
(
document
).
on
(
'click.popover touchstart.popover'
,
(
event
)
=>
{
if
(
$
(
event
.
target
).
closest
(
'.popover'
).
length
===
0
)
{
$pushNewProjectTipTrigger
.
trigger
(
'click'
);
}
});
const
target
=
$
(
`#
${
$pushNewProjectTipTrigger
.
attr
(
'aria-describedby'
)}
`
).
find
(
'.js-select-on-focus'
);
addSelectOnFocusBehaviour
(
target
);
target
.
focus
();
})
.
on
(
'hide.bs.popover'
,
()
=>
{
$
(
document
).
off
(
'click.popover touchstart.popover'
);
});
}
function
chooseTemplate
()
{
$
(
'.template-option'
).
hide
();
$projectFieldsForm
.
addClass
(
'selected'
);
...
...
app/assets/stylesheets/framework/typography.scss
View file @
da531c39
...
...
@@ -333,6 +333,10 @@ a > code {
font-family
:
$monospace_font
;
}
.weight-normal
{
font-weight
:
$gl-font-weight-normal
;
}
.commit-sha
,
.ref-name
{
@extend
.monospace
;
...
...
app/assets/stylesheets/pages/projects.scss
View file @
da531c39
...
...
@@ -896,6 +896,12 @@ pre.light-well {
}
}
.project-tip-command
{
>
.input-group-btn
:first-child
{
width
:
auto
;
}
}
.protected-branches-list
,
.protected-tags-list
{
margin-bottom
:
30px
;
...
...
app/helpers/projects_helper.rb
View file @
da531c39
...
...
@@ -260,6 +260,17 @@ module ProjectsHelper
!!
(
params
[
:personal
]
||
params
[
:name
]
||
any_projects?
(
projects
))
end
def
push_to_create_project_command
(
user
=
current_user
)
repository_url
=
if
Gitlab
::
CurrentSettings
.
current_application_settings
.
enabled_git_access_protocol
==
'http'
user_url
(
user
)
else
Gitlab
.
config
.
gitlab_shell
.
ssh_path_prefix
+
user
.
username
end
"git push --set-upstream
#{
repository_url
}
/$(git rev-parse --show-toplevel | xargs basename).git $(git rev-parse --abbrev-ref HEAD)"
end
private
def
repo_children_classes
(
field
)
...
...
app/views/projects/_new_project_push_tip.html.haml
0 → 100644
View file @
da531c39
.push-to-create-popover
%p
=
label_tag
(
:push_to_create_tip
,
_
(
"Private projects can be created in your personal namespace with:"
),
class:
"weight-normal"
)
%p
.input-group.project-tip-command
%span
.input-group-btn
=
text_field_tag
:push_to_create_tip
,
push_to_create_project_command
,
class:
"js-select-on-focus form-control monospace"
,
readonly:
true
,
aria:
{
label:
_
(
"Push project from command line"
)
}
%span
.input-group-btn
=
clipboard_button
(
text:
push_to_create_project_command
,
title:
_
(
"Copy command to clipboard"
),
placement:
"right"
)
%p
=
link_to
(
"What does this command do?"
,
help_page_path
(
"gitlab-basics/create-project"
,
anchor:
"push-to-create-a-new-project"
),
target:
"_blank"
)
app/views/projects/new.html.haml
View file @
da531c39
...
...
@@ -18,6 +18,13 @@
All features are enabled when you create a project, but you can disable the ones you don’t need in the project settings.
.md
=
brand_new_project_guidelines
%p
%strong
=
_
(
"Tip:"
)
=
_
(
"You can also create a project from the command line."
)
%a
.push-new-project-tip
{
data:
{
title:
_
(
"Push to create a project"
)
},
href:
help_page_path
(
'gitlab-basics/create-project'
,
anchor:
'push-to-create-a-new-project'
),
target:
"_blank"
,
rel:
"noopener noreferrer"
}
=
_
(
"Show command"
)
%template
.push-new-project-tip-template
=
render
partial:
"new_project_push_tip"
.col-lg-9.js-toggle-container
%ul
.nav-links.gitlab-tabs
{
role:
'tablist'
}
%li
.active
{
role:
'presentation'
}
...
...
doc/gitlab-basics/create-project.md
View file @
da531c39
...
...
@@ -47,10 +47,10 @@ This can be done by using either SSH or HTTP:
```
## Git push using SSH
git push
git@gitlab.example.com:namespace/nonexistent-project.git
git push
--set-upstream git@gitlab.example.com:namespace/nonexistent-project.git master
## Git push using HTTP
git push
https://gitlab.example.com/namespace/nonexistent-project.git
git push
--set-upstream https://gitlab.example.com/namespace/nonexistent-project.git master
```
Once the push finishes successfully, a remote message will indicate
...
...
spec/features/projects_spec.rb
View file @
da531c39
...
...
@@ -25,6 +25,24 @@ feature 'Project' do
end
end
describe
'shows tip about push to create git command'
do
let
(
:user
)
{
create
(
:user
)
}
before
do
sign_in
user
visit
new_project_path
end
it
'shows the command in a popover'
,
:js
do
page
.
within
'.profile-settings-sidebar'
do
click_link
'Show command'
end
expect
(
page
).
to
have_css
(
'.popover .push-to-create-popover #push_to_create_tip'
)
expect
(
page
).
to
have_content
'Private projects can be created in your personal namespace with:'
end
end
describe
'description'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:path
)
{
project_path
(
project
)
}
...
...
spec/helpers/projects_helper_spec.rb
View file @
da531c39
...
...
@@ -436,6 +436,22 @@ describe ProjectsHelper do
end
end
describe
(
'#push_to_create_project_command'
)
do
let
(
:user
)
{
create
(
:user
,
username:
'john'
)
}
it
'returns the command to push to create project over HTTP'
do
allow
(
Gitlab
::
CurrentSettings
.
current_application_settings
).
to
receive
(
:enabled_git_access_protocol
)
{
'http'
}
expect
(
helper
.
push_to_create_project_command
(
user
)).
to
eq
(
'git push --set-upstream http://test.host/john/$(git rev-parse --show-toplevel | xargs basename).git $(git rev-parse --abbrev-ref HEAD)'
)
end
it
'returns the command to push to create project over SSH'
do
allow
(
Gitlab
::
CurrentSettings
.
current_application_settings
).
to
receive
(
:enabled_git_access_protocol
)
{
'ssh'
}
expect
(
helper
.
push_to_create_project_command
(
user
)).
to
eq
(
'git push --set-upstream git@localhost:john/$(git rev-parse --show-toplevel | xargs basename).git $(git rev-parse --abbrev-ref HEAD)'
)
end
end
describe
'#any_projects?'
do
let!
(
:project
)
{
create
(
:project
)
}
...
...
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