From e8f9345b93914c989c206c8609029f7e61af2937 Mon Sep 17 00:00:00 2001 From: Ceciliadrc <145673389+Ceciliadrc@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:40:53 +0200 Subject: [PATCH] feat(removeButton) : add remove button from toolbar option (#4408) --- .../src/services/ToolBarService/ToolbarService.ts | 11 +++++++++++ .../docs/platform/services/data/ToolbarService.md | 2 ++ 2 files changed, 13 insertions(+) diff --git a/platform/core/src/services/ToolBarService/ToolbarService.ts b/platform/core/src/services/ToolBarService/ToolbarService.ts index 3f8c0e85f..287ab1b9e 100644 --- a/platform/core/src/services/ToolBarService/ToolbarService.ts +++ b/platform/core/src/services/ToolBarService/ToolbarService.ts @@ -112,6 +112,17 @@ export default class ToolbarService extends PubSubService { unsubscriptions.forEach(unsub => this._serviceSubscriptions.push(unsub)); } + /** + * Removes buttons from the toolbar. + * @param buttonId - The button to be removed. + */ + public removeButton(buttonId : string ){ + if(this.state.buttons[buttonId]) delete this.state.buttons[buttonId] + this._broadcastEvent(this.EVENTS.TOOL_BAR_MODIFIED, { + ...this.state, + }); + } + /** * Adds buttons to the toolbar. * @param buttons - The buttons to be added. diff --git a/platform/docs/docs/platform/services/data/ToolbarService.md b/platform/docs/docs/platform/services/data/ToolbarService.md index 3eb03ffd2..3c8aff777 100644 --- a/platform/docs/docs/platform/services/data/ToolbarService.md +++ b/platform/docs/docs/platform/services/data/ToolbarService.md @@ -27,6 +27,8 @@ The `ToolBarService` is a straightforward service designed to handle the toolbar - `addButtons`: add the button definition to the service. [See below for button definition](#button-definitions). +- `removeButton(key)` : remove a button from the toolbar. + - `setButtons`: sets the buttons defined in the service. It overrides all the previous buttons