OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Ensure deleting a board from the toolbar menu gets redirected to the Rails-rendered index page
Aaron Contreras41253e4b9f1f
diff --git a/frontend/src/app/features/boards/board/toolbar-menu/boards-toolbar-menu.directive.ts b/frontend/src/app/features/boards/board/toolbar-menu/boards-toolbar-menu.directive.tsindex 79c1e5ae6fd..3dfb2ef303d 100644--- a/frontend/src/app/features/boards/board/toolbar-menu/boards-toolbar-menu.directive.ts+++ b/frontend/src/app/features/boards/board/toolbar-menu/boards-toolbar-menu.directive.ts@@ -29,6 +29,7 @@import {Directive, ElementRef, Injector, Input,} from '@angular/core';+import { HttpClient } from '@angular/common/http';import { I18nService } from 'core-app/core/i18n/i18n.service';import { OpContextMenuTrigger } from 'core-app/shared/components/op-context-menu/handlers/op-context-menu-trigger.directive';import { OPContextMenuService } from 'core-app/shared/components/op-context-menu/op-context-menu.service';@@ -46,18 +47,17 @@ import { triggerEditingEvent } from 'core-app/shared/components/editable-toolbarexport class BoardsToolbarMenuDirective extends OpContextMenuTrigger {@Input('boardsToolbarMenu-resource') public board:Board;- public text = {- deleteSuccessful: this.I18n.t('js.notice_successful_delete'),- };-- constructor(readonly elementRef:ElementRef,+ constructor(+ readonly elementRef:ElementRef,readonly opContextMenu:OPContextMenuService,readonly opModalService:OpModalService,readonly boardService:BoardService,readonly Notifications:ToastService,readonly State:StateService,readonly injector:Injector,- readonly I18n:I18nService) {+ readonly I18n:I18nService,+ readonly http:HttpClient,+ ) {super(elementRef, opContextMenu);}@@ -103,13 +103,17 @@ export class BoardsToolbarMenuDirective extends OpContextMenuTrigger {linkText: this.I18n.t('js.toolbar.settings.delete'),icon: 'icon-delete',onClick: () => {- if (this.board.grid.delete+ if (this.board.id+ && this.board.grid.delete&& window.confirm(this.I18n.t('js.text_query_destroy_confirmation'))) {- this.boardService- .delete(this.board)- .then(() => {- this.State.go('boards.list', { flash_message: { type: 'success', message: this.text.deleteSuccessful } });- });+ void this.http+ .delete(`/boards/${this.board.id}`)+ .toPromise()+ .then(+ (response:{ redirectUrl:string }) => {+ window.location.href = response.redirectUrl;+ },+ );}return true;diff --git a/modules/boards/app/controllers/boards/boards_controller.rb b/modules/boards/app/controllers/boards/boards_controller.rbindex bc689c38b92..a1ec4e8d4eb 100644--- a/modules/boards/app/controllers/boards/boards_controller.rb+++ b/modules/boards/app/controllers/boards/boards_controller.rb@@ -10,7 +10,8 @@ module ::Boardsbefore_action :authorize_work_package_permissionend- before_action :authorize_global, only: %i[overview new create]+ before_action :authorize_global, only: %i[overview new create destroy]+ before_action :find_board_grid, only: %i[destroy]before_action :ensure_board_type_not_restricted, only: %i[create]menu_item :board_view@@ -53,8 +54,25 @@ module ::Boardsendend+ def destroy+ project = @board_grid.project+ @board_grid.destroy++ flash[:notice] = I18n.t(:notice_successful_delete)++ respond_to do |format|+ format.json do+ render json: { redirect_url: project_work_package_boards_path(project) }+ end+ end+ end+private+ def find_board_grid+ @board_grid = Boards::Grid.find(params[:id])+ end+def authorize_work_package_permissionunless current_user.allowed_to?(:view_work_packages, @project, global: @project.nil?)deny_accessdiff --git a/modules/boards/config/routes.rb b/modules/boards/config/routes.rbindex 649cf0c6e72..17dc975b2f2 100644--- a/modules/boards/config/routes.rb+++ b/modules/boards/config/routes.rb@@ -3,7 +3,7 @@ OpenProject::Application.routes.draw doresources :boards,controller: 'boards/boards',- only: %i[index show new create],+ only: %i[index show new create destroy],as: :work_package_boardsscope 'projects/:project_id', as: 'project' dodiff --git a/modules/boards/lib/open_project/boards/engine.rb b/modules/boards/lib/open_project/boards/engine.rbindex 9e8a19d14f4..016c0c97aa9 100644--- a/modules/boards/lib/open_project/boards/engine.rb+++ b/modules/boards/lib/open_project/boards/engine.rb@@ -33,7 +33,7 @@ module OpenProject::Boardsdependencies: :view_work_packages,contract_actions: { boards: %i[read] }permission :manage_board_views,- { 'boards/boards': %i[index new create] },+ { 'boards/boards': %i[index show new create destroy] },dependencies: :manage_public_queries,contract_actions: { boards: %i[create update destroy] }end