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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
cadbd3f0
Commit
cadbd3f0
authored
Jan 12, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6027 from jvanbaarsen/snippet-fix
Removed expiration from snippets
parents
753a2f17
ef404d8e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
16 deletions
+7
-16
app/views/projects/snippets/_form.html.haml
app/views/projects/snippets/_form.html.haml
+7
-9
doc/api/project_snippets.md
doc/api/project_snippets.md
+0
-2
features/steps/project/project_snippets.rb
features/steps/project/project_snippets.rb
+0
-1
lib/api/project_snippets.rb
lib/api/project_snippets.rb
+0
-4
No files found.
app/views/projects/snippets/_form.html.haml
View file @
cadbd3f0
...
...
@@ -2,7 +2,7 @@
=
@snippet
.
new_record?
?
"New Snippet"
:
"Edit Snippet #
#{
@snippet
.
id
}
"
%hr
.snippet-form-holder
=
form_for
[
@project
,
@snippet
],
as: :project_snippet
,
url:
url
do
|
f
|
=
form_for
[
@project
,
@snippet
],
as: :project_snippet
,
url:
url
,
html:
{
class:
"form-horizontal snippet-form"
}
do
|
f
|
-
if
@snippet
.
errors
.
any?
.alert.alert-danger
%ul
...
...
@@ -10,14 +10,11 @@
%li
=
msg
.form-group
=
f
.
label
:title
=
f
.
label
:title
,
class:
'control-label'
.col-sm-10
=
f
.
text_field
:title
,
placeholder:
"Example Snippet"
,
class:
'form-control'
,
required:
true
.form-group
=
f
.
label
"Lifetime"
.col-sm-10
=
f
.
select
:expires_at
,
lifetime_select_options
,
{},
{
class:
'select2 span2'
}
.form-group
.file-editor
=
f
.
label
:file_name
,
"File"
=
f
.
label
:file_name
,
"File"
,
class:
'control-label'
.col-sm-10
.file-holder.snippet
.file-title
...
...
@@ -31,10 +28,11 @@
=
f
.
submit
'Create snippet'
,
class:
"btn-create btn"
-
else
=
f
.
submit
'Save'
,
class:
"btn-save btn"
=
link_to
"Cancel"
,
project_snippets_path
(
@project
),
class:
"btn btn-cancel"
-
unless
@snippet
.
new_record?
=
link_to
'Remove snippet'
,
project_snippet_path
(
@project
,
@snippet
),
data:
{
confirm:
'Are you sure?'
},
method: :delete
,
class:
"btn pull-right btn-remove delete-snippet prepend-left-10"
,
id:
"destroy_snippet_
#{
@snippet
.
id
}
"
-
unless
@snippet
.
new_record?
.pull-right.prepend-left-20
=
link_to
'Remove snippet'
,
project_snippet_path
(
@project
,
@snippet
),
data:
{
confirm:
'Are you sure?'
},
method: :delete
,
class:
"btn pull-right btn-remove delete-snippet prepend-left-10"
,
id:
"destroy_snippet_
#{
@snippet
.
id
}
"
=
link_to
"Cancel"
,
project_snippets_path
(
@project
),
class:
"btn btn-cancel"
:javascript
var
editor
=
ace
.
edit
(
"
editor
"
);
...
...
doc/api/project_snippets.md
View file @
cadbd3f0
...
...
@@ -57,7 +57,6 @@ Parameters:
+
`id`
(required) - The ID of a project
+
`title`
(required) - The title of a snippet
+
`file_name`
(required) - The name of a snippet file
+
`lifetime`
(optional) - The expiration date of a snippet
+
`code`
(required) - The content of a snippet
...
...
@@ -75,7 +74,6 @@ Parameters:
+
`snippet_id`
(required) - The ID of a project's snippet
+
`title`
(optional) - The title of a snippet
+
`file_name`
(optional) - The name of a snippet file
+
`lifetime`
(optional) - The expiration date of a snippet
+
`code`
(optional) - The content of a snippet
...
...
features/steps/project/project_snippets.rb
View file @
cadbd3f0
...
...
@@ -53,7 +53,6 @@ class ProjectSnippets < Spinach::FeatureSteps
And
'I submit new snippet "Snippet three"'
do
fill_in
"project_snippet_title"
,
:with
=>
"Snippet three"
select
"forever"
,
:from
=>
"project_snippet_expires_at"
fill_in
"project_snippet_file_name"
,
:with
=>
"my_snippet.rb"
within
(
'.file-editor'
)
do
find
(
:xpath
,
"//input[@id='project_snippet_content']"
).
set
'Content of snippet three'
...
...
lib/api/project_snippets.rb
View file @
cadbd3f0
...
...
@@ -41,7 +41,6 @@ module API
# id (required) - The ID of a project
# title (required) - The title of a snippet
# file_name (required) - The name of a snippet file
# lifetime (optional) - The expiration date of a snippet
# code (required) - The content of a snippet
# Example Request:
# POST /projects/:id/snippets
...
...
@@ -50,7 +49,6 @@ module API
required_attributes!
[
:title
,
:file_name
,
:code
]
attrs
=
attributes_for_keys
[
:title
,
:file_name
]
attrs
[
:expires_at
]
=
params
[
:lifetime
]
if
params
[
:lifetime
].
present?
attrs
[
:content
]
=
params
[
:code
]
if
params
[
:code
].
present?
@snippet
=
user_project
.
snippets
.
new
attrs
@snippet
.
author
=
current_user
...
...
@@ -69,7 +67,6 @@ module API
# snippet_id (required) - The ID of a project snippet
# title (optional) - The title of a snippet
# file_name (optional) - The name of a snippet file
# lifetime (optional) - The expiration date of a snippet
# code (optional) - The content of a snippet
# Example Request:
# PUT /projects/:id/snippets/:snippet_id
...
...
@@ -78,7 +75,6 @@ module API
authorize!
:modify_project_snippet
,
@snippet
attrs
=
attributes_for_keys
[
:title
,
:file_name
]
attrs
[
:expires_at
]
=
params
[
:lifetime
]
if
params
[
:lifetime
].
present?
attrs
[
:content
]
=
params
[
:code
]
if
params
[
:code
].
present?
if
@snippet
.
update_attributes
attrs
...
...
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