@aarhus-university/au-lib-react-components 11.3.1 → 11.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sideEffects": false,
3
3
  "name": "@aarhus-university/au-lib-react-components",
4
- "version": "11.3.1",
4
+ "version": "11.3.2",
5
5
  "description": "Library for shared React components for various applications on au.dk",
6
6
  "scripts": {
7
7
  "test": "jest",
@@ -74,7 +74,7 @@
74
74
  "dependencies": {
75
75
  "@aarhus-university/au-designsystem-delphinus": "0.34.8",
76
76
  "@aarhus-university/au-designsystem-delphinus-dev": "0.2.0",
77
- "@aarhus-university/types": "^0.17.10",
77
+ "@aarhus-university/types": "^0.17.11",
78
78
  "@reduxjs/toolkit": "^1.8.3",
79
79
  "@types/google.analytics": "^0.0.42",
80
80
  "@types/history": "^5.0.0",
@@ -43,6 +43,7 @@ export const usePortalContext = (): AU.IPortalContext | null => {
43
43
  };
44
44
 
45
45
  export const ImpersonationContext = createContext<AU.IImpersonationContext>({
46
+ canImpersonate: false,
46
47
  isImpersonating: false,
47
48
  impersonatateError: false,
48
49
  });
@@ -16,6 +16,8 @@ declare global {
16
16
  PHASE: number;
17
17
  REAL_PHASE: number;
18
18
  authenticated: boolean;
19
+ userContext: AU.IUserContext;
20
+ impersonateError: boolean;
19
21
  }
20
22
  }
21
23
 
@@ -101,3 +103,17 @@ export const getPortalByName = (
101
103
  lang: string,
102
104
  name: string,
103
105
  ): AU.IPortalContext | null => portals(lang).find((portal) => portal.name === name) ?? null;
106
+
107
+ export const impersonationPortalElement = document.querySelector('.page__pre-header');
108
+
109
+ export const isImpersonating = (): boolean => {
110
+ if (window.userContext == null) {
111
+ return false;
112
+ }
113
+ if (window.userContext.impersonatedUser == null) {
114
+ return false;
115
+ }
116
+ return true;
117
+ };
118
+
119
+ export const impersonationHasErrored = (): boolean => window.impersonateError;