Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow toggling page smart bar #255

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
sydinh marked this conversation as resolved.
Show resolved Hide resolved
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,
};
Loading