diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/views/dashboard/_snippets_head.html.haml | 4 | ||||
-rw-r--r-- | app/views/dashboard/snippets/index.html.haml | 12 | ||||
-rw-r--r-- | app/views/explore/snippets/index.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/snippets/index.html.haml | 18 | ||||
-rw-r--r-- | app/views/projects/snippets/new.html.haml | 4 | ||||
-rw-r--r-- | app/views/shared/empty_states/_snippets.html.haml | 20 | ||||
-rw-r--r-- | app/views/shared/snippets/_list.html.haml | 12 | ||||
-rw-r--r-- | app/views/snippets/index.html.haml | 2 |
8 files changed, 59 insertions, 15 deletions
diff --git a/app/views/dashboard/_snippets_head.html.haml b/app/views/dashboard/_snippets_head.html.haml index 8d99f84755a..a05d0190efb 100644 --- a/app/views/dashboard/_snippets_head.html.haml +++ b/app/views/dashboard/_snippets_head.html.haml @@ -1,9 +1,9 @@ .page-title-holder %h1.page-title= _('Snippets') - - if current_user + - if current_user && current_user.snippets.any? || @snippets.any? .page-title-controls - = link_to "New snippet", new_snippet_path, class: "btn btn-success", title: "New snippet" + = link_to _("New snippet"), new_snippet_path, class: "btn btn-success", title: _("New snippet") .top-area %ul.nav-links.nav.nav-tabs diff --git a/app/views/dashboard/snippets/index.html.haml b/app/views/dashboard/snippets/index.html.haml index 6eb067da95c..b649fe91c24 100644 --- a/app/views/dashboard/snippets/index.html.haml +++ b/app/views/dashboard/snippets/index.html.haml @@ -3,6 +3,14 @@ - header_title "Snippets", dashboard_snippets_path = render 'dashboard/snippets_head' -= render partial: 'snippets/snippets_scope_menu', locals: { include_private: true } +- if current_user.snippets.exists? + = render partial: 'snippets/snippets_scope_menu', locals: { include_private: true } -= render partial: 'snippets/snippets', locals: { link_project: true } +.d-block.d-sm-none + + = link_to _("New snippet"), new_snippet_path, class: "btn btn-success btn-block", title: _("New snippet") + +- if current_user.snippets.exists? + = render partial: 'shared/snippets/list', locals: { link_project: true } +- else + = render 'shared/empty_states/snippets', button_path: new_snippet_path diff --git a/app/views/explore/snippets/index.html.haml b/app/views/explore/snippets/index.html.haml index 94fc4ac21d2..d23c8301b10 100644 --- a/app/views/explore/snippets/index.html.haml +++ b/app/views/explore/snippets/index.html.haml @@ -7,4 +7,4 @@ - else = render 'explore/head' -= render partial: 'snippets/snippets', locals: { link_project: true } += render partial: 'shared/snippets/list', locals: { link_project: true } diff --git a/app/views/projects/snippets/index.html.haml b/app/views/projects/snippets/index.html.haml index a4974d89c1a..7682d01a5a1 100644 --- a/app/views/projects/snippets/index.html.haml +++ b/app/views/projects/snippets/index.html.haml @@ -1,12 +1,16 @@ - page_title _("Snippets") -- if current_user - .top-area - - include_private = @project.team.member?(current_user) || current_user.admin? - = render partial: 'snippets/snippets_scope_menu', locals: { subject: @project, include_private: include_private } +- if @snippets.exists? + - if current_user + .top-area + - include_private = @project.team.member?(current_user) || current_user.admin? + = render partial: 'snippets/snippets_scope_menu', locals: { subject: @project, include_private: include_private } - .nav-controls - if can?(current_user, :create_project_snippet, @project) - = link_to _("New snippet"), new_project_snippet_path(@project), class: "btn btn-success", title: _("New snippet") + .nav-controls + - if can?(current_user, :create_project_snippet, @project) + = link_to _("New snippet"), new_project_snippet_path(@project), class: "btn btn-success", title: _("New snippet") -= render 'snippets/snippets' + = render 'shared/snippets/list' +- else + = render 'shared/empty_states/snippets', button_path: new_namespace_project_snippet_path(@project.namespace, @project) diff --git a/app/views/projects/snippets/new.html.haml b/app/views/projects/snippets/new.html.haml index 26b333d4ecf..d64e3a49a81 100644 --- a/app/views/projects/snippets/new.html.haml +++ b/app/views/projects/snippets/new.html.haml @@ -1,8 +1,8 @@ - add_to_breadcrumbs _("Snippets"), project_snippets_path(@project) - breadcrumb_title _("New") -- page_title _("New Snippets") +- page_title _("New Snippet") %h3.page-title - = _('New Snippet') + = _("New Snippet") %hr = render "shared/snippets/form", url: project_snippets_path(@project, @snippet) diff --git a/app/views/shared/empty_states/_snippets.html.haml b/app/views/shared/empty_states/_snippets.html.haml new file mode 100644 index 00000000000..a1a16b9d067 --- /dev/null +++ b/app/views/shared/empty_states/_snippets.html.haml @@ -0,0 +1,20 @@ +- button_path = local_assigns.fetch(:button_path, false) + +.row.empty-state + .col-12 + .svg-content + = image_tag 'illustrations/snippets_empty.svg' + .text-content + - if current_user + %h4 + = s_('SnippetsEmptyState|Snippets are small pieces of code or notes that you want to keep.') + %p + = s_('SnippetsEmptyState|They can be either public or private.') + .text-center + = link_to s_('SnippetsEmptyState|New snippet'), button_path, class: 'btn btn-success', title: s_('SnippetsEmptyState|New snippet'), id: 'new_snippet_link' + - unless current_page?(dashboard_snippets_path) + = link_to s_('SnippetsEmptyState|Explore public snippets'), explore_snippets_path, class: 'btn btn-default', title: s_('SnippetsEmptyState|Explore public snippets') + - else + %h4.text-center= s_('SnippetsEmptyState|There are no snippets to show.') + + diff --git a/app/views/shared/snippets/_list.html.haml b/app/views/shared/snippets/_list.html.haml new file mode 100644 index 00000000000..5d2152eb411 --- /dev/null +++ b/app/views/shared/snippets/_list.html.haml @@ -0,0 +1,12 @@ +- remote = local_assigns.fetch(:remote, false) +- link_project = local_assigns.fetch(:link_project, false) + +- if @snippets.exists? + .snippets-list-holder + %ul.content-list + = render partial: 'shared/snippets/snippet', collection: @snippets, locals: { link_project: link_project } + + = paginate @snippets, theme: 'gitlab', remote: remote + +- else + .nothing-here-block= s_("SnippetsEmptyState|No snippets found") diff --git a/app/views/snippets/index.html.haml b/app/views/snippets/index.html.haml index 4f418e2381f..f5fe75bed5a 100644 --- a/app/views/snippets/index.html.haml +++ b/app/views/snippets/index.html.haml @@ -10,4 +10,4 @@ = link_to user_path(@user) do = _("%{user_name} profile page") % { user_name: @user.name } -= render 'snippets' += render 'shared/snippets/list' |