summaryrefslogtreecommitdiff
path: root/app/views/shared/wikis/_form.html.haml
blob: 92b9207aaa46a3642d3476e59fb5a7f89289aeb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
- form_classes = %w[wiki-form common-note-form gl-mt-3 js-quick-submit]

- if @page.persisted?
  - form_action = wiki_page_path(@wiki, @page)
  - form_method = :put
- else
  - form_action = wiki_path(@wiki, action: :create)
  - form_method = :post
  - form_classes << 'js-new-wiki-page'

= form_for @page, url: form_action, method: form_method,
           html: { class: form_classes },
           data: { uploads_path: uploads_path } do |f|
  = form_errors(@page, truncate: :title)

  - if @page.persisted?
    = f.hidden_field :last_commit_sha, value: @page.last_commit_sha

  .form-group.row
    .col-sm-12= f.label :title, class: 'control-label-full-width'
    .col-sm-12
      = f.text_field :title, class: 'form-control qa-wiki-title-textbox', value: @page.title, required: true, autofocus: !@page.persisted?, placeholder: s_('Wiki|Page title')
      %span.d-inline-block.mw-100.gl-mt-2
        = icon('lightbulb-o')
        - if @page.persisted?
          = s_("WikiEditPageTip|Tip: You can move this page by adding the path to the beginning of the title.")
          = link_to icon('question-circle'), help_page_path('user/project/wiki/index', anchor: 'moving-a-wiki-page'),
              target: '_blank', rel: 'noopener noreferrer'
        - else
          = s_("WikiNewPageTip|Tip: You can specify the full path for the new file. We will automatically create any missing directories.")
        = succeed '.' do
          = link_to _('Learn more'), help_page_path('user/project/wiki/index', anchor: 'creating-a-new-wiki-page'),
              target: '_blank', rel: 'noopener noreferrer'
  .form-group.row
    .col-sm-12= f.label :format, class: 'control-label-full-width'
    .col-sm-12
      .select-wrapper
        = f.select :format, options_for_select(Wiki::MARKUPS, {selected: @page.format}), {}, class: 'form-control select-control'
        = icon('chevron-down')

  .form-group.row
    .col-sm-12= f.label :content, class: 'control-label-full-width'
    .col-sm-12
      = render layout: 'shared/md_preview', locals: { url: wiki_page_path(@wiki, @page, action: :preview_markdown) } do
        = render 'shared/zen', f: f, attr: :content, classes: 'note-textarea qa-wiki-content-textarea', placeholder: s_("WikiPage|Write your content or drag files hereā€¦")
        = render 'shared/notes/hints'

      .clearfix
      .error-alert

      .form-text.text-muted
        = succeed '.' do
          - case @page.format.to_s
            - when 'rdoc'
              - link_example = '{Link title}[link:page-slug]'
            - when 'asciidoc'
              - link_example = 'link:page-slug[Link title]'
            - when 'org'
              - link_example = '[[page-slug]]'
            - else
              - link_example = '[Link Title](page-slug)'
          = (s_('WikiMarkdownTip|To link to a (new) page, simply type <code class="js-markup-link-example">%{link_example}</code>') % { link_example: link_example }).html_safe
        = succeed '.' do
          - markdown_link = link_to s_("WikiMarkdownDocs|documentation"), help_page_path('user/markdown', anchor: 'wiki-specific-markdown')
          = (s_("WikiMarkdownDocs|More examples are in the %{docs_link}") % { docs_link: markdown_link }).html_safe

  .form-group.row
    .col-sm-12= f.label :commit_message, class: 'control-label-full-width'
    .col-sm-12= f.text_field :message, class: 'form-control qa-wiki-message-textbox', rows: 18, value: nil

  .form-actions
    - if @page && @page.persisted?
      = f.submit _("Save changes"), class: 'btn-success btn qa-save-changes-button'
      .float-right
        = link_to _("Cancel"), wiki_page_path(@wiki, @page), class: 'btn btn-cancel btn-grouped'
    - else
      = f.submit s_("Wiki|Create page"), class: 'btn-success btn qa-create-page-button rspec-create-page-button'
      .float-right
        = link_to _("Cancel"), wiki_path(@wiki), class: 'btn btn-cancel'