Commit cadbd3f0c1bd53fed7d081ef514833c4030a19da
Exists in
spb-stable
and in
3 other branches
Merge pull request #6027 from jvanbaarsen/snippet-fix
Removed expiration from snippets
Showing
4 changed files
with
7 additions
and
16 deletions
Show diff stats
app/views/projects/snippets/_form.html.haml
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | = @snippet.new_record? ? "New Snippet" : "Edit Snippet ##{@snippet.id}" |
| 3 | 3 | %hr |
| 4 | 4 | .snippet-form-holder |
| 5 | - = form_for [@project, @snippet], as: :project_snippet, url: url do |f| | |
| 5 | + = form_for [@project, @snippet], as: :project_snippet, url: url, html: {class: "form-horizontal snippet-form"} do |f| | |
| 6 | 6 | -if @snippet.errors.any? |
| 7 | 7 | .alert.alert-danger |
| 8 | 8 | %ul |
| ... | ... | @@ -10,14 +10,11 @@ |
| 10 | 10 | %li= msg |
| 11 | 11 | |
| 12 | 12 | .form-group |
| 13 | - = f.label :title | |
| 13 | + = f.label :title, class: 'control-label' | |
| 14 | 14 | .col-sm-10= f.text_field :title, placeholder: "Example Snippet", class: 'form-control', required: true |
| 15 | 15 | .form-group |
| 16 | - = f.label "Lifetime" | |
| 17 | - .col-sm-10= f.select :expires_at, lifetime_select_options, {}, {class: 'select2 span2'} | |
| 18 | - .form-group | |
| 19 | 16 | .file-editor |
| 20 | - = f.label :file_name, "File" | |
| 17 | + = f.label :file_name, "File", class: 'control-label' | |
| 21 | 18 | .col-sm-10 |
| 22 | 19 | .file-holder.snippet |
| 23 | 20 | .file-title |
| ... | ... | @@ -31,10 +28,11 @@ |
| 31 | 28 | = f.submit 'Create snippet', class: "btn-create btn" |
| 32 | 29 | - else |
| 33 | 30 | = f.submit 'Save', class: "btn-save btn" |
| 34 | - = link_to "Cancel", project_snippets_path(@project), class: "btn btn-cancel" | |
| 35 | 31 | |
| 36 | - - unless @snippet.new_record? | |
| 37 | - = 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}" | |
| 32 | + - unless @snippet.new_record? | |
| 33 | + .pull-right.prepend-left-20 | |
| 34 | + = 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}" | |
| 35 | + = link_to "Cancel", project_snippets_path(@project), class: "btn btn-cancel" | |
| 38 | 36 | |
| 39 | 37 | :javascript |
| 40 | 38 | var editor = ace.edit("editor"); | ... | ... |
doc/api/project_snippets.md
| ... | ... | @@ -57,7 +57,6 @@ Parameters: |
| 57 | 57 | + `id` (required) - The ID of a project |
| 58 | 58 | + `title` (required) - The title of a snippet |
| 59 | 59 | + `file_name` (required) - The name of a snippet file |
| 60 | -+ `lifetime` (optional) - The expiration date of a snippet | |
| 61 | 60 | + `code` (required) - The content of a snippet |
| 62 | 61 | |
| 63 | 62 | |
| ... | ... | @@ -75,7 +74,6 @@ Parameters: |
| 75 | 74 | + `snippet_id` (required) - The ID of a project's snippet |
| 76 | 75 | + `title` (optional) - The title of a snippet |
| 77 | 76 | + `file_name` (optional) - The name of a snippet file |
| 78 | -+ `lifetime` (optional) - The expiration date of a snippet | |
| 79 | 77 | + `code` (optional) - The content of a snippet |
| 80 | 78 | |
| 81 | 79 | ... | ... |
features/steps/project/project_snippets.rb
| ... | ... | @@ -53,7 +53,6 @@ class ProjectSnippets < Spinach::FeatureSteps |
| 53 | 53 | |
| 54 | 54 | And 'I submit new snippet "Snippet three"' do |
| 55 | 55 | fill_in "project_snippet_title", :with => "Snippet three" |
| 56 | - select "forever", :from => "project_snippet_expires_at" | |
| 57 | 56 | fill_in "project_snippet_file_name", :with => "my_snippet.rb" |
| 58 | 57 | within('.file-editor') do |
| 59 | 58 | find(:xpath, "//input[@id='project_snippet_content']").set 'Content of snippet three' | ... | ... |
lib/api/project_snippets.rb
| ... | ... | @@ -41,7 +41,6 @@ module API |
| 41 | 41 | # id (required) - The ID of a project |
| 42 | 42 | # title (required) - The title of a snippet |
| 43 | 43 | # file_name (required) - The name of a snippet file |
| 44 | - # lifetime (optional) - The expiration date of a snippet | |
| 45 | 44 | # code (required) - The content of a snippet |
| 46 | 45 | # Example Request: |
| 47 | 46 | # POST /projects/:id/snippets |
| ... | ... | @@ -50,7 +49,6 @@ module API |
| 50 | 49 | required_attributes! [:title, :file_name, :code] |
| 51 | 50 | |
| 52 | 51 | attrs = attributes_for_keys [:title, :file_name] |
| 53 | - attrs[:expires_at] = params[:lifetime] if params[:lifetime].present? | |
| 54 | 52 | attrs[:content] = params[:code] if params[:code].present? |
| 55 | 53 | @snippet = user_project.snippets.new attrs |
| 56 | 54 | @snippet.author = current_user |
| ... | ... | @@ -69,7 +67,6 @@ module API |
| 69 | 67 | # snippet_id (required) - The ID of a project snippet |
| 70 | 68 | # title (optional) - The title of a snippet |
| 71 | 69 | # file_name (optional) - The name of a snippet file |
| 72 | - # lifetime (optional) - The expiration date of a snippet | |
| 73 | 70 | # code (optional) - The content of a snippet |
| 74 | 71 | # Example Request: |
| 75 | 72 | # PUT /projects/:id/snippets/:snippet_id |
| ... | ... | @@ -78,7 +75,6 @@ module API |
| 78 | 75 | authorize! :modify_project_snippet, @snippet |
| 79 | 76 | |
| 80 | 77 | attrs = attributes_for_keys [:title, :file_name] |
| 81 | - attrs[:expires_at] = params[:lifetime] if params[:lifetime].present? | |
| 82 | 78 | attrs[:content] = params[:code] if params[:code].present? |
| 83 | 79 | |
| 84 | 80 | if @snippet.update_attributes attrs | ... | ... |