Commit a016abab authored by Peter Hegman's avatar Peter Hegman Committed by Nicolò Maria Mezzopera

Refactor admin labels to use shared HAML partial

Use shared HAML partial for admin labels edit/create actions.
Results in a few very minor button text changes.

Changelog: changed
parent 1b6fd3e0
= form_for [:admin, @label], html: { class: 'label-form js-requires-input' } do |f|
= form_errors(@label)
.form-group.row
.col-sm-2.col-form-label
= f.label :title
.col-sm-10
= f.text_field :title, class: "form-control gl-form-input", required: true
.form-group.row
.col-sm-2.col-form-label
= f.label :description
.col-sm-10
= f.text_field :description, class: "form-control gl-form-input js-quick-submit"
.form-group.row
.col-sm-2.col-form-label
= f.label :color, _("Background color")
.col-sm-10
.input-group
.input-group-prepend
.input-group-text.label-color-preview  
= f.text_field :color, class: "form-control gl-form-input"
.form-text.text-muted
= _('Choose any color.')
%br
= _("Or you can choose one of the suggested colors below")
= render_suggested_colors
.form-actions
= f.submit _('Save'), class: 'btn gl-button btn-confirm js-save-button'
= link_to _("Cancel"), admin_labels_path, class: 'btn gl-button btn-default btn-cancel'
...@@ -4,4 +4,4 @@ ...@@ -4,4 +4,4 @@
%h3.page-title %h3.page-title
= _('Edit Label') = _('Edit Label')
%hr %hr
= render 'form' = render 'shared/labels/form', url: admin_label_path(@label), back_path: admin_labels_path
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
%h3.page-title %h3.page-title
= _('New Label') = _('New Label')
%hr %hr
= render 'form' = render 'shared/labels/form', url: admin_labels_path, back_path: admin_labels_path
...@@ -5,30 +5,30 @@ ...@@ -5,30 +5,30 @@
.col-sm-2.col-form-label .col-sm-2.col-form-label
= f.label :title = f.label :title
.col-sm-10 .col-sm-10
= f.text_field :title, class: "form-control js-label-title qa-label-title", required: true, autofocus: true = f.text_field :title, class: "gl-form-input form-control js-label-title qa-label-title", required: true, autofocus: true
= render_if_exists 'shared/labels/create_label_help_text' = render_if_exists 'shared/labels/create_label_help_text'
.form-group.row .form-group.row
.col-sm-2.col-form-label .col-sm-2.col-form-label
= f.label :description = f.label :description
.col-sm-10 .col-sm-10
= f.text_field :description, class: "form-control js-quick-submit qa-label-description" = f.text_field :description, class: "gl-form-input form-control js-quick-submit qa-label-description"
.form-group.row .form-group.row
.col-sm-2.col-form-label .col-sm-2.col-form-label
= f.label :color, "Background color" = f.label :color, _("Background color")
.col-sm-10 .col-sm-10
.input-group .input-group
.input-group-prepend .input-group-prepend
.input-group-text.label-color-preview   .input-group-text.label-color-preview  
= f.text_field :color, class: "form-control qa-label-color" = f.text_field :color, class: "gl-form-input form-control qa-label-color"
.form-text.text-muted .form-text.text-muted
Choose any color. = _('Choose any color.')
%br %br
Or you can choose one of the suggested colors below = _("Or you can choose one of the suggested colors below")
= render_suggested_colors = render_suggested_colors
.form-actions .form-actions
- if @label.persisted? - if @label.persisted?
= f.submit _('Save changes'), class: 'btn gl-button btn-confirm js-save-button' = f.submit _('Save changes'), class: 'btn gl-button btn-confirm js-save-button'
- else - else
= f.submit 'Create label', class: 'btn gl-button btn-confirm js-save-button qa-label-create-button' = f.submit _('Create label'), class: 'btn gl-button btn-confirm js-save-button qa-label-create-button'
= link_to _('Cancel'), back_path, class: 'btn gl-button btn-default btn-cancel' = link_to _('Cancel'), back_path, class: 'btn gl-button btn-default btn-cancel'
- if @label.subject.feature_available?(:scoped_labels) - if @label.respond_to?(:subject) && @label.subject.feature_available?(:scoped_labels)
- docs_url = help_page_path('user/project/labels.md', anchor: 'scoped-labels') - docs_url = help_page_path('user/project/labels.md', anchor: 'scoped-labels')
- docs_link_start = "<a href='#{docs_url}' target='_blank' rel='noreferrer noopener'>".html_safe - docs_link_start = "<a href='#{docs_url}' target='_blank' rel='noreferrer noopener'>".html_safe
- docs_link_end = '</a>'.html_safe - docs_link_end = '</a>'.html_safe
......
...@@ -10042,6 +10042,9 @@ msgstr "" ...@@ -10042,6 +10042,9 @@ msgstr ""
msgid "Create iteration" msgid "Create iteration"
msgstr "" msgstr ""
msgid "Create label"
msgstr ""
msgid "Create list" msgid "Create list"
msgstr "" msgstr ""
......
...@@ -59,7 +59,7 @@ RSpec.describe 'admin issues labels' do ...@@ -59,7 +59,7 @@ RSpec.describe 'admin issues labels' do
it 'creates new label' do it 'creates new label' do
fill_in 'Title', with: 'support' fill_in 'Title', with: 'support'
fill_in 'Background color', with: '#F95610' fill_in 'Background color', with: '#F95610'
click_button 'Save' click_button 'Create label'
page.within '.manage-labels-list' do page.within '.manage-labels-list' do
expect(page).to have_content('support') expect(page).to have_content('support')
...@@ -69,7 +69,7 @@ RSpec.describe 'admin issues labels' do ...@@ -69,7 +69,7 @@ RSpec.describe 'admin issues labels' do
it 'does not creates label with invalid color' do it 'does not creates label with invalid color' do
fill_in 'Title', with: 'support' fill_in 'Title', with: 'support'
fill_in 'Background color', with: '#12' fill_in 'Background color', with: '#12'
click_button 'Save' click_button 'Create label'
page.within '.label-form' do page.within '.label-form' do
expect(page).to have_content('Color must be a valid color code') expect(page).to have_content('Color must be a valid color code')
...@@ -79,7 +79,7 @@ RSpec.describe 'admin issues labels' do ...@@ -79,7 +79,7 @@ RSpec.describe 'admin issues labels' do
it 'does not creates label if label already exists' do it 'does not creates label if label already exists' do
fill_in 'Title', with: 'bug' fill_in 'Title', with: 'bug'
fill_in 'Background color', with: '#F95610' fill_in 'Background color', with: '#F95610'
click_button 'Save' click_button 'Create label'
page.within '.label-form' do page.within '.label-form' do
expect(page).to have_content 'Title has already been taken' expect(page).to have_content 'Title has already been taken'
...@@ -93,7 +93,7 @@ RSpec.describe 'admin issues labels' do ...@@ -93,7 +93,7 @@ RSpec.describe 'admin issues labels' do
fill_in 'Title', with: 'fix' fill_in 'Title', with: 'fix'
fill_in 'Background color', with: '#F15610' fill_in 'Background color', with: '#F15610'
click_button 'Save' click_button 'Save changes'
page.within '.manage-labels-list' do page.within '.manage-labels-list' do
expect(page).to have_content('fix') expect(page).to have_content('fix')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment