Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-14 13:36:46 +0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-14 13:36:46 +0400
commit9be5425a887d96aaf603dd537d36f410eb663e4f (patch)
treecf881f310c6732b9092e0c0e375a66a6567217e5 /app
parent600f4c68940160556b0a4c6ecf18c40dd6ad94d5 (diff)
Refactor snippets views
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/sections/snippets.scss3
-rw-r--r--app/views/projects/snippets/_blob.html.haml13
-rw-r--r--app/views/projects/snippets/edit.html.haml5
-rw-r--r--app/views/projects/snippets/new.html.haml5
-rw-r--r--app/views/projects/snippets/show.html.haml34
-rw-r--r--app/views/shared/snippets/_blob.html.haml (renamed from app/views/snippets/_blob_content.html.haml)0
-rw-r--r--app/views/shared/snippets/_form.html.haml (renamed from app/views/projects/snippets/_form.html.haml)33
-rw-r--r--app/views/snippets/_blob.html.haml13
-rw-r--r--app/views/snippets/_form.html.haml58
-rw-r--r--app/views/snippets/edit.html.haml5
-rw-r--r--app/views/snippets/new.html.haml5
-rw-r--r--app/views/snippets/show.html.haml14
12 files changed, 85 insertions, 103 deletions
diff --git a/app/assets/stylesheets/sections/snippets.scss b/app/assets/stylesheets/sections/snippets.scss
index 84404b6ee36..d79591d9915 100644
--- a/app/assets/stylesheets/sections/snippets.scss
+++ b/app/assets/stylesheets/sections/snippets.scss
@@ -3,3 +3,6 @@
padding-top: 0;
}
+.snippet-form-holder .file-holder .file-title {
+ padding: 2px;
+}
diff --git a/app/views/projects/snippets/_blob.html.haml b/app/views/projects/snippets/_blob.html.haml
deleted file mode 100644
index c6350cb7d1b..00000000000
--- a/app/views/projects/snippets/_blob.html.haml
+++ /dev/null
@@ -1,13 +0,0 @@
-.file-holder
- .file-title
- %i.icon-file
- %span.file_name
- = @snippet.file_name
- .options
- .btn-group
- - if can?(current_user, :modify_project_snippet, @snippet)
- = link_to "edit", edit_project_snippet_path(@project, @snippet), class: "btn btn-small", title: 'Edit Snippet'
- = link_to "raw", raw_project_snippet_path(@project, @snippet), class: "btn btn-small", target: "_blank"
- - if can?(current_user, :admin_project_snippet, @snippet)
- = link_to "remove", project_snippet_path(@project, @snippet), method: :delete, data: { confirm: "Are you sure?" }, class: "btn btn-small btn-remove", title: 'Delete Snippet'
- = render 'snippets/blob_content'
diff --git a/app/views/projects/snippets/edit.html.haml b/app/views/projects/snippets/edit.html.haml
index e28b7d4937e..f6a5bf9e4ff 100644
--- a/app/views/projects/snippets/edit.html.haml
+++ b/app/views/projects/snippets/edit.html.haml
@@ -1 +1,4 @@
-= render "projects/snippets/form", url: project_snippet_path(@project, @snippet)
+%h3.page-title
+ Edit snippet
+%hr
+= render "shared/snippets/form", url: project_snippet_path(@project, @snippet)
diff --git a/app/views/projects/snippets/new.html.haml b/app/views/projects/snippets/new.html.haml
index 460af34f676..10f684b6316 100644
--- a/app/views/projects/snippets/new.html.haml
+++ b/app/views/projects/snippets/new.html.haml
@@ -1 +1,4 @@
-= render "projects/snippets/form", url: project_snippets_path(@project, @snippet)
+%h3.page-title
+ New snippet
+%hr
+= render "shared/snippets/form", url: project_snippets_path(@project, @snippet)
diff --git a/app/views/projects/snippets/show.html.haml b/app/views/projects/snippets/show.html.haml
index ac32f4866b6..e4fdbd868c3 100644
--- a/app/views/projects/snippets/show.html.haml
+++ b/app/views/projects/snippets/show.html.haml
@@ -1,11 +1,37 @@
%h3.page-title
= @snippet.title
- %small.pull-right
+ .pull-right
+ = link_to new_project_snippet_path(@project), class: "btn btn-new", title: "New Snippet" do
+ Add new snippet
+
+%hr
+
+.append-bottom-20
+ .pull-right
= "##{@snippet.id}"
%span.light
by
- = image_tag avatar_icon(@snippet.author_email), class: "avatar avatar-inline s16"
- = @snippet.author_name
-%div= render 'projects/snippets/blob'
+ = link_to user_path(@snippet.author) do
+ = image_tag avatar_icon(@snippet.author_email), class: "avatar avatar-inline s16"
+ = @snippet.author_name
+
+ .back-link
+ = link_to project_snippets_path(@project) do
+ &larr; project snippets
+
+.file-holder
+ .file-title
+ %i.icon-file
+ %span.file_name
+ = @snippet.file_name
+ .options
+ .btn-group
+ - if can?(current_user, :modify_project_snippet, @snippet)
+ = link_to "edit", edit_project_snippet_path(@project, @snippet), class: "btn btn-small", title: 'Edit Snippet'
+ = link_to "raw", raw_project_snippet_path(@project, @snippet), class: "btn btn-small", target: "_blank"
+ - if can?(current_user, :admin_project_snippet, @snippet)
+ = link_to "remove", project_snippet_path(@project, @snippet), method: :delete, data: { confirm: "Are you sure?" }, class: "btn btn-small btn-remove", title: 'Delete Snippet'
+ = render 'shared/snippets/blob'
+
%div#notes= render "projects/notes/notes_with_form"
diff --git a/app/views/snippets/_blob_content.html.haml b/app/views/shared/snippets/_blob.html.haml
index 8cec6168ab8..8cec6168ab8 100644
--- a/app/views/snippets/_blob_content.html.haml
+++ b/app/views/shared/snippets/_blob.html.haml
diff --git a/app/views/projects/snippets/_form.html.haml b/app/views/shared/snippets/_form.html.haml
index 866346990d3..49ea8460e7d 100644
--- a/app/views/projects/snippets/_form.html.haml
+++ b/app/views/shared/snippets/_form.html.haml
@@ -1,9 +1,6 @@
-%h3.page-title
- = @snippet.new_record? ? "New Snippet" : "Edit Snippet ##{@snippet.id}"
-%hr
.snippet-form-holder
- = form_for [@project, @snippet], as: :project_snippet, url: url, html: {class: "form-horizontal snippet-form"} do |f|
- -if @snippet.errors.any?
+ = form_for @snippet, url: url, html: { class: "form-horizontal snippet-form" } do |f|
+ - if @snippet.errors.any?
.alert.alert-danger
%ul
- @snippet.errors.full_messages.each do |msg|
@@ -12,6 +9,23 @@
.form-group
= f.label :title, class: 'control-label'
.col-sm-10= f.text_field :title, placeholder: "Example Snippet", class: 'form-control', required: true
+
+ - unless @snippet.respond_to?(:project)
+ .form-group
+ = f.label "Access", class: 'control-label'
+ .col-sm-10
+ = f.label :private_true, class: 'radio-label' do
+ = f.radio_button :private, true
+ %span
+ %strong Private
+ (only you can see this snippet)
+ %br
+ = f.label :private_false, class: 'radio-label' do
+ = f.radio_button :private, false
+ %span
+ %strong Public
+ (GitLab users can see this snippet)
+
.form-group
.file-editor
= f.label :file_name, "File", class: 'control-label'
@@ -29,14 +43,13 @@
- else
= f.submit 'Save', class: "btn-save btn"
- - 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"
+ - if @snippet.respond_to?(:project)
+ = link_to "Cancel", project_snippets_path(@project), class: "btn btn-cancel"
+ - else
+ = link_to "Cancel", snippets_path(@project), class: "btn btn-cancel"
:javascript
var editor = ace.edit("editor");
$(".snippet-form-holder form").submit(function(){
$(".snippet-file-content").val(editor.getValue());
});
-
diff --git a/app/views/snippets/_blob.html.haml b/app/views/snippets/_blob.html.haml
deleted file mode 100644
index 4a907011ad1..00000000000
--- a/app/views/snippets/_blob.html.haml
+++ /dev/null
@@ -1,13 +0,0 @@
-.file-holder
- .file-title
- %i.icon-file
- %span.file_name
- = @snippet.file_name
- .options
- .btn-group
- - if can?(current_user, :modify_personal_snippet, @snippet)
- = link_to "edit", edit_snippet_path(@snippet), class: "btn btn-small", title: 'Edit Snippet'
- = link_to "raw", raw_snippet_path(@snippet), class: "btn btn-small", target: "_blank"
- - if can?(current_user, :admin_personal_snippet, @snippet)
- = link_to "remove", snippet_path(@snippet), method: :delete, data: { confirm: "Are you sure?" }, class: "btn btn-small btn-remove", title: 'Delete Snippet'
- = render 'snippets/blob_content'
diff --git a/app/views/snippets/_form.html.haml b/app/views/snippets/_form.html.haml
deleted file mode 100644
index d466dc1af14..00000000000
--- a/app/views/snippets/_form.html.haml
+++ /dev/null
@@ -1,58 +0,0 @@
-%h3.page-title
- = @snippet.new_record? ? "New Snippet" : "Edit Snippet ##{@snippet.id}"
-%hr
-.snippet-form-holder
- = form_for @snippet, as: :personal_snippet, url: url, html: { class: "form-horizontal snippet-form" } do |f|
- -if @snippet.errors.any?
- .alert.alert-danger
- %ul
- - @snippet.errors.full_messages.each do |msg|
- %li= msg
-
- .form-group
- = 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 "Access", class: 'control-label'
- .col-sm-10
- = f.label :private_true, class: 'radio-label' do
- = f.radio_button :private, true
- %span
- %strong Private
- (only you can see this snippet)
- %br
- = f.label :private_false, class: 'radio-label' do
- = f.radio_button :private, false
- %span
- %strong Public
- (GitLab users can see this snippet)
-
- .form-group
- .file-editor
- = f.label :file_name, "File", class: 'control-label'
- .col-sm-10
- .file-holder.snippet
- .file-title
- = f.text_field :file_name, placeholder: "example.rb", class: 'form-control snippet-file-name', required: true
- .file-content.code
- %pre#editor= @snippet.content
- = f.hidden_field :content, class: 'snippet-file-content'
-
- .form-actions
- - if @snippet.new_record?
- = f.submit 'Create snippet', class: "btn-create btn"
- - else
- = f.submit 'Save', class: "btn-save btn"
-
- - unless @snippet.new_record?
- .pull-right.prepend-left-20
- = link_to 'Remove', snippet_path(@snippet), data: { confirm: 'Removed snippet cannot be restored! Are you sure?'}, method: :delete, class: "btn btn-remove delete-snippet", id: "destroy_snippet_#{@snippet.id}"
- = link_to "Cancel", snippets_path(@project), class: "btn btn-cancel"
-
-
-:javascript
- var editor = ace.edit("editor");
- $(".snippet-form-holder form").submit(function(){
- $(".snippet-file-content").val(editor.getValue());
- });
-
diff --git a/app/views/snippets/edit.html.haml b/app/views/snippets/edit.html.haml
index 1b88a85faf1..7042d07d5e8 100644
--- a/app/views/snippets/edit.html.haml
+++ b/app/views/snippets/edit.html.haml
@@ -1 +1,4 @@
-= render "snippets/form", url: snippet_path(@snippet)
+%h3.page-title
+ Edit snippet
+%hr
+= render "shared/snippets/form", url: snippet_path(@snippet)
diff --git a/app/views/snippets/new.html.haml b/app/views/snippets/new.html.haml
index 90e0a1f79da..694d7058317 100644
--- a/app/views/snippets/new.html.haml
+++ b/app/views/snippets/new.html.haml
@@ -1 +1,4 @@
-= render "snippets/form", url: snippets_path(@snippet)
+%h3.page-title
+ New snippet
+%hr
+= render "shared/snippets/form", url: snippets_path(@snippet)
diff --git a/app/views/snippets/show.html.haml b/app/views/snippets/show.html.haml
index 655ff947d20..1d2e3d5ae4a 100644
--- a/app/views/snippets/show.html.haml
+++ b/app/views/snippets/show.html.haml
@@ -28,4 +28,16 @@
= link_to snippets_path do
&larr; discover snippets
-%div= render 'blob'
+.file-holder
+ .file-title
+ %i.icon-file
+ %span.file_name
+ = @snippet.file_name
+ .options
+ .btn-group
+ - if can?(current_user, :modify_personal_snippet, @snippet)
+ = link_to "edit", edit_snippet_path(@snippet), class: "btn btn-small", title: 'Edit Snippet'
+ = link_to "raw", raw_snippet_path(@snippet), class: "btn btn-small", target: "_blank"
+ - if can?(current_user, :admin_personal_snippet, @snippet)
+ = link_to "remove", snippet_path(@snippet), method: :delete, data: { confirm: "Are you sure?" }, class: "btn btn-small btn-remove", title: 'Delete Snippet'
+ = render 'shared/snippets/blob'