Skip to content

Commit

Permalink
Allow toggling page smart bar
Browse files Browse the repository at this point in the history
  • Loading branch information
sydinh committed Sep 17, 2024
1 parent 2a45d2b commit ad9a06e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/soft-chicken-applaud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@shopware-ag/meteor-admin-sdk": minor
---

Allow toggling page smart bar
19 changes: 19 additions & 0 deletions docs/admin-sdk/docs/guide/2_api-reference/ui/mainModule.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 |
3 changes: 2 additions & 1 deletion packages/admin-sdk/src/message-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -72,6 +72,7 @@ export interface ShopwareMessageTypes {
settingsItemAdd: settingsItemAdd,
mainModuleAdd: mainModuleAdd,
smartBarButtonAdd: smartBarButtonAdd,
smartBarHide: smartBarHide,
uiModalOpen: uiModalOpen,
uiModalClose: uiModalClose,
actionButtonAdd: actionButtonAdd,
Expand Down
10 changes: 10 additions & 0 deletions packages/admin-sdk/src/ui/main-module/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -62,3 +63,12 @@ export type smartBarButtonAdd = {
*/
onClickCallback: () => void,
}

export type smartBarHide = {
responseType: void,

/**
* The locationId you want to hide.
*/
locationId: string,
};

0 comments on commit ad9a06e

Please sign in to comment.