From 24e83086c1b54c463766c8010d2c3e5f42be7c06 Mon Sep 17 00:00:00 2001 From: Jannis Leifeld Date: Wed, 24 May 2023 14:30:24 +0200 Subject: [PATCH] NEXT-25020 - add user context information --- src/context/index.ts | 26 ++++++++++++++++++++++++++ src/messages.types.ts | 3 ++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/context/index.ts b/src/context/index.ts index b4a4d81f..20f200e4 100644 --- a/src/context/index.ts +++ b/src/context/index.ts @@ -7,6 +7,7 @@ export const getLocale = createSender('contextLocale', {}); export const subscribeLocale = createSubscriber('contextLocale'); export const getCurrency = createSender('contextCurrency', {}); export const getShopwareVersion = createSender('contextShopwareVersion', {}); +export const getUserInformation = createSender('contextUserInformation', {}); export const getAppInformation = createSender('contextAppInformation', {}); export const getModuleInformation = createSender('contextModuleInformation', {}); @@ -65,6 +66,31 @@ export type contextAppInformation = { }, } +/** + * Get the current user information + */ +export type contextUserInformation = { + responseType: { + aclRoles: Array<{ + name: string, + type: string, + id: string, + privileges: Array, + }>, + active: boolean, + admin: boolean, + avatarId: string, + email: string, + firstName: string, + id: string, + lastName: string, + localeId: string, + title: string, + type: string, + username: string, + }, +} + /** * Get all registered module information for the extension */ diff --git a/src/messages.types.ts b/src/messages.types.ts index 7b27650b..b7d6bc35 100644 --- a/src/messages.types.ts +++ b/src/messages.types.ts @@ -1,6 +1,6 @@ import type { notificationDispatch } from './notification/index'; import type { windowRedirect, windowReload, windowRouterPush } from './window/index'; -import type { contextLanguage, contextEnvironment, contextLocale, contextCurrency, contextShopwareVersion, contextAppInformation, contextModuleInformation } from './context/index'; +import type { contextLanguage, contextEnvironment, contextLocale, contextCurrency, contextShopwareVersion, contextAppInformation, contextModuleInformation, contextUserInformation } from './context/index'; import type { uiComponentSectionRenderer } from './ui/componentSection/index'; import type { uiTabsAddTabItem } from './ui/tabs'; import type { uiModulePaymentOverviewCard } from './ui/module/payment/overviewCard'; @@ -42,6 +42,7 @@ export interface ShopwareMessageTypes { contextLocale: contextLocale, contextCurrency: contextCurrency, contextShopwareVersion: contextShopwareVersion, + contextUserInformation: contextUserInformation, contextAppInformation: contextAppInformation, contextModuleInformation: contextModuleInformation, getPageTitle: getPageTitle,