Allow copying work packages to other projects

pull/10163/head
Oliver Günther 3 years ago
parent fec32c7d60
commit a3b862d5a6
  1. 1
      config/locales/js-en.yml
  2. 6
      frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-static-context-menu-actions.ts
  3. 8
      frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-view-context-menu.directive.ts
  4. 2
      spec/features/work_packages/copy_spec.rb
  5. 6
      spec/features/work_packages/table/context_menu_spec.rb
  6. 2
      spec/support/components/work_packages/context_menu.rb

@ -78,6 +78,7 @@ en:
button_confirm: "Confirm"
button_continue: "Continue"
button_copy: "Copy"
button_copy_to_other_project: "Copy to other project"
button_custom-fields: "Custom fields"
button_delete: "Delete"
button_delete_watcher: "Delete watcher"

@ -15,6 +15,12 @@ export const PERMITTED_CONTEXT_MENU_ACTIONS = [
link: 'copy',
resource: 'workPackage',
},
{
key: 'copy_to_other_project',
link: 'copy',
icon: 'icon-project-types',
resource: 'workPackage',
},
{
key: 'delete',
link: 'delete',

@ -21,6 +21,7 @@ import { TimeEntryCreateService } from 'core-app/shared/components/time_entries/
import { splitViewRoute } from 'core-app/features/work-packages/routing/split-view-routes.helper';
import { WpDestroyModalComponent } from 'core-app/shared/components/modals/wp-destroy-modal/wp-destroy.modal';
import isNewResource from 'core-app/features/hal/helpers/is-new-resource';
import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';
export class WorkPackageViewContextMenu extends OpContextMenuHandler {
@InjectField() protected states!:States;
@ -37,6 +38,8 @@ export class WorkPackageViewContextMenu extends OpContextMenuHandler {
@InjectField() protected timeEntryCreateService:TimeEntryCreateService;
@InjectField() protected pathHelper:PathHelperService;
protected workPackage = this.states.workPackages.get(this.workPackageId).value!;
protected selectedWorkPackages = this.getSelectedWorkPackages();
@ -73,6 +76,7 @@ export class WorkPackageViewContextMenu extends OpContextMenuHandler {
public triggerContextMenuAction(action:WorkPackageAction) {
const { link } = action;
const id = this.workPackage.id as string;
switch (action.key) {
case 'delete':
@ -87,6 +91,10 @@ export class WorkPackageViewContextMenu extends OpContextMenuHandler {
this.copySelectedWorkPackages(link!);
break;
case 'copy_to_other_project':
window.location.href = `${this.pathHelper.staticBase}/work_packages/move/new?copy=true&ids[]=${id}`;
break;
case 'relation-new-child':
this.wpRelationsHierarchyService.addNewChildWp(this.baseRoute, this.workPackage);
break;

@ -138,7 +138,7 @@ RSpec.feature 'Work package copy', js: true, selenium: true do
# Go to add cost entry page
find('#action-show-more-dropdown-menu .button').click
find('.menu-item', text: 'Copy').click
find('.menu-item', text: 'Copy', exact_text: true).click
to_copy_work_package_page = Pages::FullWorkPackageCreate.new original_work_package: original_work_package
to_copy_work_package_page.update_attributes Description: 'Copied WP Description'

@ -84,6 +84,12 @@ describe 'Work package table context menu', js: true do
goto_context_menu list_view
menu.expect_no_options 'Add predecessor', 'Add follower'
# Copy to other project
goto_context_menu list_view
menu.choose('Copy to other project')
expect(page).to have_selector('h2', text: I18n.t(:button_copy))
expect(page).to have_selector('a.work_package', text: "##{work_package.id}")
end
end

@ -55,7 +55,7 @@ module Components
end
def choose(target)
find("#{selector} .menu-item", text: target).click
find("#{selector} .menu-item", text: target, exact_text: true).click
end
def expect_no_options(*options)

Loading…
Cancel
Save