From 1efc49c977365dd96e96fea675904c986b736a50 Mon Sep 17 00:00:00 2001 From: Sy Dinh Date: Tue, 17 Sep 2024 16:19:59 +0700 Subject: [PATCH] Allow toggling page smart bar (#255) --- .changeset/soft-chicken-applaud.md | 5 +++++ .../guide/2_api-reference/ui/mainModule.md | 19 +++++++++++++++++++ packages/admin-sdk/src/message-types.ts | 3 ++- .../admin-sdk/src/ui/main-module/index.ts | 10 ++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 .changeset/soft-chicken-applaud.md diff --git a/.changeset/soft-chicken-applaud.md b/.changeset/soft-chicken-applaud.md new file mode 100644 index 000000000..216571394 --- /dev/null +++ b/.changeset/soft-chicken-applaud.md @@ -0,0 +1,5 @@ +--- +"@shopware-ag/meteor-admin-sdk": minor +--- + +Allow toggling page smart bar diff --git a/docs/admin-sdk/docs/guide/2_api-reference/ui/mainModule.md b/docs/admin-sdk/docs/guide/2_api-reference/ui/mainModule.md index 857a9b507..cc6db38ae 100644 --- a/docs/admin-sdk/docs/guide/2_api-reference/ui/mainModule.md +++ b/docs/admin-sdk/docs/guide/2_api-reference/ui/mainModule.md @@ -41,6 +41,10 @@ if (location.is(location.MAIN_HIDDEN)) { variant: 'primary', // The button variant onClickCallback: () => {} }); + + ui.mainModule.hideSmartBar({ + locationId: 'main-location-id', + }); } // Render your custom view @@ -72,3 +76,18 @@ ui.mainModule.addSmartbarButton({ | `variant` | false | `primary` | Set the variant of the button. Possible values: `primary`, `ghost`, `danger`, `ghost-danger`, `contrast`, `context` | | `onClickCallback` | true | | Callback function which will be called once the button is clicked | | `disabled` | false | false | Toggle disabled state of the button | + +### Hide smart bar +Turn the smart bar off as needed. + +#### Usage: +```ts +ui.mainModule.hideSmartBar({ + locationId: 'main-location-id', +}); +``` + +#### Parameters +| Name | Required | Default | Description | Available at Shopware | +| :----------- | :------- | :-------- | :--------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------| +| `locationId` | true | | The locationId of the module you want to hide the smart bar | v6.6.6.1 | diff --git a/packages/admin-sdk/src/message-types.ts b/packages/admin-sdk/src/message-types.ts index 2c0f29e50..825ea1ee5 100644 --- a/packages/admin-sdk/src/message-types.ts +++ b/packages/admin-sdk/src/message-types.ts @@ -20,7 +20,7 @@ import type { locationUpdateHeight, locationUpdateUrl } from './location/index'; import type { menuCollapse, menuExpand, menuItemAdd } from './ui/menu'; import type { settingsItemAdd } from './ui/settings'; import type { mainModuleAdd } from './ui/main-module'; -import type { smartBarButtonAdd } from './ui/main-module'; +import type { smartBarButtonAdd, smartBarHide } from './ui/main-module'; import type { uiModalOpen, uiModalClose } from './ui/modal/index'; import type { actionButtonAdd } from './ui/action-button'; import type { actionExecute } from './app/action'; @@ -72,6 +72,7 @@ export interface ShopwareMessageTypes { settingsItemAdd: settingsItemAdd, mainModuleAdd: mainModuleAdd, smartBarButtonAdd: smartBarButtonAdd, + smartBarHide: smartBarHide, uiModalOpen: uiModalOpen, uiModalClose: uiModalClose, actionButtonAdd: actionButtonAdd, diff --git a/packages/admin-sdk/src/ui/main-module/index.ts b/packages/admin-sdk/src/ui/main-module/index.ts index 6f0ff02e8..867f89b63 100644 --- a/packages/admin-sdk/src/ui/main-module/index.ts +++ b/packages/admin-sdk/src/ui/main-module/index.ts @@ -2,6 +2,7 @@ import { createSender } from '../../channel'; export const addMainModule = createSender('mainModuleAdd'); export const addSmartBarButton = createSender('smartBarButtonAdd'); +export const hideSmartBar = createSender('smartBarHide'); export type mainModuleAdd = { responseType: void, @@ -62,3 +63,12 @@ export type smartBarButtonAdd = { */ onClickCallback: () => void, } + +export type smartBarHide = { + responseType: void, + + /** + * The locationId you want to hide. + */ + locationId: string, +};