summaryrefslogtreecommitdiff
path: root/app/views/shared/wikis/_form.html.haml
diff options
context:
space:
mode:
Diffstat (limited to 'app/views/shared/wikis/_form.html.haml')
-rw-r--r--app/views/shared/wikis/_form.html.haml79
1 files changed, 3 insertions, 76 deletions
diff --git a/app/views/shared/wikis/_form.html.haml b/app/views/shared/wikis/_form.html.haml
index d91e3c73c49..e121725b9af 100644
--- a/app/views/shared/wikis/_form.html.haml
+++ b/app/views/shared/wikis/_form.html.haml
@@ -1,79 +1,6 @@
-- form_classes = %w[wiki-form common-note-form gl-mt-3 js-quick-submit]
+- page_info = { last_commit_sha: @page.last_commit_sha, persisted: @page.persisted?, title: @page.title, content: @page.content || '', format: @page.format.to_s, uploads_path: uploads_path, path: wiki_page_path(@wiki, @page), wiki_path: wiki_path(@wiki), help_path: help_page_path('user/project/wiki/index'), markdown_help_path: help_page_path('user/markdown'), markdown_preview_path: wiki_page_path(@wiki, @page, action: :preview_markdown), create_path: wiki_path(@wiki, action: :create) }
-- 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|
+.gl-mt-3
= form_errors(@page, truncate: :title)
- - if @page.persisted?
- = f.hidden_field :last_commit_sha, value: @page.last_commit_sha
-
- .form-group.row
- .col-sm-2.col-form-label= f.label :title, class: 'control-label-full-width'
- .col-sm-10
- = 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.gl-display-inline-block.gl-max-w-full.gl-mt-2.gl-text-gray-600
- = sprite_icon('bulb', size: 12, css_class: 'gl-mr-n1')
- - if @page.persisted?
- = s_("WikiEditPageTip|Tip: You can move this page by adding the path to the beginning of the title.")
- = link_to sprite_icon('question-o'), 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 _('More information'), help_page_path('user/project/wiki/index', anchor: 'creating-a-new-wiki-page'),
- target: '_blank', rel: 'noopener noreferrer'
- .form-group.row
- .col-sm-2.col-form-label= f.label :format, class: 'control-label-full-width'
- .col-sm-10
- .select-wrapper
- = f.select :format, options_for_select(Wiki::MARKUPS, {selected: @page.format}), {}, class: 'form-control select-control'
- = sprite_icon('chevron-down', css_class: 'gl-absolute gl-top-3 gl-right-3 gl-text-gray-200')
-
- .form-group.row
- .col-sm-2.col-form-label= f.label :content, class: 'control-label-full-width'
- .col-sm-10
- = 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ā€¦"), autofocus: @page.persisted?
- = render 'shared/notes/hints'
-
- .clearfix
- .error-alert
-
- .form-text.gl-text-gray-600
- = 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)'
- = html_escape(s_('WikiMarkdownTip|To link to a (new) page, simply type %{link_example}')) % { link_example: tag.code(link_example, class: 'js-markup-link-example') }
- = 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-2.col-form-label= f.label :commit_message, class: 'control-label-full-width'
- .col-sm-10= 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 gl-button btn-confirm qa-save-changes-button js-wiki-btn-submit', disabled: 'true'
- .float-right
- = link_to _("Cancel"), wiki_page_path(@wiki, @page), class: 'btn gl-button btn-cancel btn-default'
- - else
- = f.submit s_("Wiki|Create page"), class: 'btn-confirm gl-button btn qa-create-page-button rspec-create-page-button js-wiki-btn-submit', disabled: 'true'
- .float-right
- = link_to _("Cancel"), wiki_path(@wiki), class: 'btn gl-button btn-cancel btn-default'
+#js-wiki-form{ data: { page_info: page_info.to_json, format_options: Wiki::MARKUPS.to_json } }