Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move package edit action close to the target #10879

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/api/app/views/webui/package/_basic_info.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.basic-info.in-place-editing.mb-3
.editing-form.d-none
= render partial: 'edit', locals: { package: package, project: package.project }

.basic-info.mb-3
%h3#package-title
= package.title.presence || package.name
- if package.url.present?
Expand All @@ -8,3 +11,19 @@
%i No description set
- else
= render partial: 'webui/shared/collapsible_text', locals: { text: package.description }

- if policy(package).update?
= link_to('javascript:void(0);', id: 'toggle-in-place-editing', class: 'nav-link', title: 'Edit') do
%i.fas.fa-edit
%span.nav-item-name Edit

:javascript
$('#toggle-in-place-editing').on('click', function () {
$('.in-place-editing .basic-info').toggleClass('d-none');
$('.in-place-editing .editing-form').toggleClass('d-none');
});
$('#cancel-in-place-editing').on('click', function () {
$('.in-place-editing .basic-info').toggleClass('d-none');
$('.in-place-editing .editing-form').toggleClass('d-none');
return false;
});
2 changes: 1 addition & 1 deletion src/api/app/views/webui/package/_edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
= form.label(:description, 'Description:')
= form.text_area(:description, rows: 8, class: 'form-control')
.form-group.text-right
= link_to 'Cancel', package_show_path(project, package), class: 'cancel btn btn-outline-danger px-4', remote: true
= button_tag('Cancel', id: 'cancel-in-place-editing', class: 'cancel btn btn-outline-danger px-4')
= submit_tag('Update', class: 'btn btn-primary px-4')
1 change: 0 additions & 1 deletion src/api/app/views/webui/package/_show_actions.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
= render partial: 'webui/package/show_actions/submit_package', locals: { package: package, project: project,
revision: revision }
- if User.possibly_nobody.can_modify?(package)
= render partial: 'webui/package/actions/edit_package', locals: { project: project, package: package }
= render partial: 'webui/package/show_actions/delete_package'

- if package.kiwi_image? && policy(package).update?
Expand Down

This file was deleted.

10 changes: 0 additions & 10 deletions src/api/app/views/webui/package/edit.js.erb

This file was deleted.

3 changes: 2 additions & 1 deletion src/api/app/views/webui/package/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
.card-body
.row
.col-md-8
= render partial: 'basic_info', locals: { package: @package }
.in-place-editing
= render partial: 'basic_info', locals: { package: @package, project: @project }
.col-md-4
= render partial: 'side_links', locals: { devel_package: @package.develpackage,
failures: @failures,
Expand Down
8 changes: 0 additions & 8 deletions src/api/app/views/webui/package/show.js.erb

This file was deleted.

3 changes: 2 additions & 1 deletion src/api/app/views/webui/package/update.js.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ resetFormValidation();
opacity: 0.25
}, 400, function() {
scrollToInPlace();
$('.in-place-editing').html("#{escape_javascript(render(partial: 'webui/package/basic_info', locals: { package: @package }))}");
$('.in-place-editing').html("#{escape_javascript(render(partial: 'webui/package/basic_info',
locals: { package: @package, project: @project }))}");
setCollapsible();
$('.in-place-editing').animate({ opacity: 1 }, 400, function() {
$('#flash').html("#{escape_javascript(render(layout: false, partial: 'layouts/webui/flash', object: flash))}");
Expand Down
2 changes: 1 addition & 1 deletion src/api/spec/features/webui/packages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@
it 'updates the package title and description' do
login user
visit package_show_path(package: package, project: user.home_project)
desktop? ? click_link('Edit Package') : click_menu_link('Actions', 'Edit Package')
click_link('Edit')
wait_for_ajax

within('#edit_package_details') do
Expand Down