@learningpool/ui 1.6.0-beta.8 → 1.6.0-beta.9

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.
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { IApplication } from '../../stream/AppSwitcher/AppSwitcher';
2
3
  import { IVerticalNavigationItemProps } from './VerticalNavigationItem/VerticalNavigationItem';
3
4
  import { IAvatarMenuItemProps } from './VerticalNavigationAvatar';
4
5
  interface VerticalNavigationProps {
@@ -11,6 +12,7 @@ interface VerticalNavigationProps {
11
12
  streamHomeAccessToken?: string;
12
13
  streamHomeBaseUrl?: string;
13
14
  streamHomeApiKey?: string;
15
+ streamHomeApplications?: IApplication[];
14
16
  avatarName?: string;
15
17
  isDrawerOpen?: boolean;
16
18
  isPersistent?: boolean;
@@ -26,11 +26,11 @@ import { useTheme } from '@mui/material/styles';
26
26
  import { Avatar, List, Tooltip } from '../../../index';
27
27
  import { Box } from '@mui/material';
28
28
  import { StreamSuiteLogo, NotchSVG, NotchExtendSVG } from '../../../assets/Images';
29
- import { AppSwitcher } from '@learningpool/app-switcher';
30
- import { ChevronLeft, ChevronRight, PushPin } from '@mui/icons-material';
29
+ import AppSwitcher from '../../stream/AppSwitcher/AppSwitcher';
30
+ import { Apps, ChevronLeft, ChevronRight, PushPin } from '@mui/icons-material';
31
31
  import VerticalNavigationItem from './VerticalNavigationItem/VerticalNavigationItem';
32
32
  import { DRAWER_WIDTH, DrawerHeader, DrawerToggle, DrawerToggleHitboxContent, StyledDivider, StyledNav, StyledNavSecondary, DrawerShadow, StyledAside, NotchContainer, NotchBackground, NotchBackgroundClip, NotchSeemMask, StyledDrawer } from './VerticalNavigationStyles';
33
- import { ListItem, ListItemButton, ListItemIcon, ListItemText } from './VerticalNavigationItem/VerticalNavigationItemStyles';
33
+ import { ListItemText } from './VerticalNavigationItem/VerticalNavigationItemStyles';
34
34
  import AvatarPanel from './VerticalNavigationAvatar';
35
35
  import { motion } from '../../../utils/theme';
36
36
  import { handleAvatarInitials } from '../../../utils/helpers';
@@ -38,12 +38,20 @@ import { DEFAULT_REACT_APP_ID } from '../../../utils/constants';
38
38
  var VerticalNavigation = function (props) {
39
39
  var _a, _b;
40
40
  var theme = useTheme();
41
- var items = props.items, secondaryItems = props.secondaryItems, logo = props.logo, logoText = props.logoText, logoOnClick = props.logoOnClick, appRootID = props.appRootID, hasStreamHome = props.hasStreamHome, streamHomeApiKey = props.streamHomeApiKey, streamHomeBaseUrl = props.streamHomeBaseUrl, streamHomeAccessToken = props.streamHomeAccessToken, rest = __rest(props, ["items", "secondaryItems", "logo", "logoText", "logoOnClick", "appRootID", "hasStreamHome", "streamHomeApiKey", "streamHomeBaseUrl", "streamHomeAccessToken"]);
41
+ var items = props.items, secondaryItems = props.secondaryItems, logo = props.logo, logoText = props.logoText, logoOnClick = props.logoOnClick, appRootID = props.appRootID, hasStreamHome = props.hasStreamHome, streamHomeApiKey = props.streamHomeApiKey, streamHomeBaseUrl = props.streamHomeBaseUrl, streamHomeAccessToken = props.streamHomeAccessToken, streamHomeApplications = props.streamHomeApplications, rest = __rest(props, ["items", "secondaryItems", "logo", "logoText", "logoOnClick", "appRootID", "hasStreamHome", "streamHomeApiKey", "streamHomeBaseUrl", "streamHomeAccessToken", "streamHomeApplications"]);
42
42
  var propIsDrawerOpen = typeof (props === null || props === void 0 ? void 0 : props.isDrawerOpen) === 'boolean' ? props.isDrawerOpen : undefined;
43
43
  var propIsPersistent = typeof (props === null || props === void 0 ? void 0 : props.isPersistent) === 'boolean' ? props.isPersistent : undefined;
44
44
  var avatarName = (_a = props === null || props === void 0 ? void 0 : props.avatarName) !== null && _a !== void 0 ? _a : 'Avatar name';
45
45
  var _c = React.useState(propIsDrawerOpen !== null && propIsDrawerOpen !== void 0 ? propIsDrawerOpen : false), isDrawerOpen = _c[0], setIsDrawerOpen = _c[1];
46
46
  var _d = React.useState(propIsPersistent !== null && propIsPersistent !== void 0 ? propIsPersistent : false), isPersistent = _d[0], setIsPersistent = _d[1];
47
+ // Controls whether the application panel is open or not.
48
+ var _e = React.useState(false), isAppSwitcherOpen = _e[0], setIsAppSwitcherOpen = _e[1];
49
+ /**
50
+ * Toggles display of the Stream suite application dialog.
51
+ */
52
+ var handleToggleAppsClick = function () {
53
+ setIsAppSwitcherOpen(!isAppSwitcherOpen);
54
+ };
47
55
  var logoHeight = 38;
48
56
  var logoWidth = 38;
49
57
  useEffect(function () { return setIsDrawerOpen(propIsDrawerOpen !== null && propIsDrawerOpen !== void 0 ? propIsDrawerOpen : false); }, [propIsDrawerOpen]);
@@ -70,7 +78,7 @@ var VerticalNavigation = function (props) {
70
78
  }
71
79
  setIsPersistent(propIsPersistent !== null && propIsPersistent !== void 0 ? propIsPersistent : false);
72
80
  };
73
- var _e = React.useState((_b = handleAvatarInitials(avatarName)) !== null && _b !== void 0 ? _b : 'AN'), avatarInitials = _e[0], setAvatarInitials = _e[1];
81
+ var _f = React.useState((_b = handleAvatarInitials(avatarName)) !== null && _b !== void 0 ? _b : 'AN'), avatarInitials = _f[0], setAvatarInitials = _f[1];
74
82
  var toggleDrawer = function (open) { return function (event) {
75
83
  event === null || event === void 0 ? void 0 : event.stopPropagation();
76
84
  if (event.type === 'keydown') {
@@ -78,6 +86,7 @@ var VerticalNavigation = function (props) {
78
86
  return;
79
87
  }
80
88
  }
89
+ setIsAppSwitcherOpen(false);
81
90
  setIsDrawerOpen(open !== null && open !== void 0 ? open : !isDrawerOpen);
82
91
  }; };
83
92
  var listContent = function () { return (_jsxs(Box, __assign({ sx: {
@@ -190,14 +199,7 @@ var VerticalNavigation = function (props) {
190
199
  ? theme.palette.primary.main
191
200
  : theme.palette.background.paper
192
201
  } }, { children: [hasStreamHome
193
- ? (_jsx(ListItem, __assign({ disablePadding: true, isDrawerOpen: isDrawerOpen || isPersistent }, { children: _jsxs(ListItemButton, __assign({ sx: {
194
- minHeight: 48,
195
- justifyContent: isDrawerOpen || isPersistent ? 'initial' : 'center'
196
- } }, { children: [_jsx(Tooltip, __assign({ disableHoverListener: isDrawerOpen || isPersistent, disableFocusListener: isDrawerOpen || isPersistent, disableTouchListener: isDrawerOpen || isPersistent, title: 'App switcher', placement: theme.direction === 'rtl' ? 'left' : 'right' }, { children: _jsx(ListItemIcon, __assign({ sx: {
197
- minWidth: 0,
198
- mr: isDrawerOpen || isPersistent ? 2.5 : 'auto',
199
- justifyContent: 'center'
200
- } }, { children: _jsx(AppSwitcher, { apiKey: streamHomeApiKey !== null && streamHomeApiKey !== void 0 ? streamHomeApiKey : '', baseUrl: streamHomeBaseUrl !== null && streamHomeBaseUrl !== void 0 ? streamHomeBaseUrl : '', token: streamHomeAccessToken !== null && streamHomeAccessToken !== void 0 ? streamHomeAccessToken : '' }) })) })), _jsx(ListItemText, { primary: 'App switcher', isDrawerOpen: isDrawerOpen || isPersistent })] })) })))
202
+ ? (_jsx(VerticalNavigationItem, { label: 'App Switcher', icon: _jsx(Apps, {}), onClick: handleToggleAppsClick, content: (_jsx(AppSwitcher, { isAppSwitcherOpen: isAppSwitcherOpen, setIsAppSwitcherOpen: setIsAppSwitcherOpen, applications: streamHomeApplications !== null && streamHomeApplications !== void 0 ? streamHomeApplications : [], apiKey: streamHomeApiKey !== null && streamHomeApiKey !== void 0 ? streamHomeApiKey : '', baseUrl: streamHomeBaseUrl !== null && streamHomeBaseUrl !== void 0 ? streamHomeBaseUrl : '', token: streamHomeAccessToken !== null && streamHomeAccessToken !== void 0 ? streamHomeAccessToken : '', isDrawerOpen: isDrawerOpen })), isDrawerOpen: isDrawerOpen || isPersistent, isSecondary: true, hasCustomContent: true }))
201
203
  : null, secondaryItems && secondaryItems.length > 0 && secondaryItems.map(function (item, index) { return (_jsx(VerticalNavigationItem, __assign({}, item, { index: index, isDrawerOpen: isDrawerOpen || isPersistent, isSecondary: true }))); }), avatarName
202
204
  ? (_jsx(VerticalNavigationItem, { label: avatarName, "aria-controls": 'avatar-panel', icon: _jsx(Avatar, __assign({ style: {
203
205
  // backgroundColor: mainTheme.colorButtonText,
@@ -13,6 +13,7 @@ export interface IVerticalNavigationItemProps {
13
13
  content?: React.ReactElement;
14
14
  style?: any;
15
15
  open?: boolean;
16
+ hasCustomContent?: boolean;
16
17
  }
17
18
  declare const VerticalNavigationItem: (props: IVerticalNavigationItemProps) => React.ReactElement;
18
19
  export default VerticalNavigationItem;
@@ -31,7 +31,7 @@ import VerticalNavigationItemFlyoutMenu from './VerticalNavigationItemFlyoutMenu
31
31
  var VerticalNavigationItem = function (props) {
32
32
  var _a, _b, _c;
33
33
  var theme = useTheme();
34
- var label = props.label, icon = props.icon, onClick = props.onClick, isActive = props.isActive, children = props.children, isDrawerOpen = props.isDrawerOpen, index = props.index, hasFlyout = props.hasFlyout, fullHeightFlyout = props.fullHeightFlyout, isSecondary = props.isSecondary, content = props.content, style = props.style, rest = __rest(props, ["label", "icon", "onClick", "isActive", "children", "isDrawerOpen", "index", "hasFlyout", "fullHeightFlyout", "isSecondary", "content", "style"]);
34
+ var label = props.label, icon = props.icon, onClick = props.onClick, isActive = props.isActive, children = props.children, isDrawerOpen = props.isDrawerOpen, index = props.index, hasFlyout = props.hasFlyout, fullHeightFlyout = props.fullHeightFlyout, isSecondary = props.isSecondary, content = props.content, style = props.style, hasCustomContent = props.hasCustomContent, rest = __rest(props, ["label", "icon", "onClick", "isActive", "children", "isDrawerOpen", "index", "hasFlyout", "fullHeightFlyout", "isSecondary", "content", "style", "hasCustomContent"]);
35
35
  var _d = React.useState(false), isExpanded = _d[0], setIsExpanded = _d[1];
36
36
  var _e = React.useState(null), anchorEl = _e[0], setAnchorEl = _e[1];
37
37
  var open = Boolean(anchorEl);
@@ -86,6 +86,6 @@ var VerticalNavigationItem = function (props) {
86
86
  ? theme.palette.primary.contrastText
87
87
  : theme.palette.getContrastText(theme.palette.background.paper)
88
88
  }
89
- } })] }), label) }))); }) })) })))] }), label), !fullHeightFlyout && children && children.length > 0 && (!isExpanded || !isDrawerOpen) && (_jsx(VerticalNavigationItemFlyoutMenu, { isDrawerOpen: isDrawerOpen, anchorEl: anchorEl, open: open, children: children, label: label })), fullHeightFlyout && content && (_jsx(VerticalNavigationItemFlyoutMenu, { isDrawerOpen: isDrawerOpen, fullHeightFlyout: true, anchorEl: anchorEl, open: open, content: content }))] })));
89
+ } })] }), label) }))); }) })) })))] }), label), hasCustomContent && content, !fullHeightFlyout && children && children.length > 0 && (!isExpanded || !isDrawerOpen) && (_jsx(VerticalNavigationItemFlyoutMenu, { isDrawerOpen: isDrawerOpen, anchorEl: anchorEl, open: open, children: children, label: label })), fullHeightFlyout && content && (_jsx(VerticalNavigationItemFlyoutMenu, { isDrawerOpen: isDrawerOpen, fullHeightFlyout: true, anchorEl: anchorEl, open: open, content: content }))] })));
90
90
  };
91
91
  export default VerticalNavigationItem;
@@ -0,0 +1,44 @@
1
+ import { ReactElement } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ export interface IApplication {
4
+ applicationId: number;
5
+ applicationName: string;
6
+ shortName: string;
7
+ internalName: string;
8
+ customName?: string;
9
+ url: string;
10
+ children?: object[];
11
+ }
12
+ interface IProps {
13
+ userId?: string;
14
+ layout?: string;
15
+ token?: string;
16
+ apiKey?: string;
17
+ baseUrl?: string;
18
+ applications?: IApplication[] | null;
19
+ currentApplicationId?: number;
20
+ localization?: any;
21
+ isAppSwitcherOpen?: boolean;
22
+ setIsAppSwitcherOpen?: any;
23
+ isDrawerOpen?: boolean;
24
+ }
25
+ declare const AppSwitcher: {
26
+ (props: IProps): ReactElement | null;
27
+ propTypes: {
28
+ accessToken: PropTypes.Requireable<string>;
29
+ apiKey: PropTypes.Requireable<string>;
30
+ layout: PropTypes.Requireable<string>;
31
+ userId: PropTypes.Requireable<number>;
32
+ baseUrl: PropTypes.Requireable<string>;
33
+ localization: PropTypes.Requireable<object>;
34
+ currentApplicationId: PropTypes.Requireable<number>;
35
+ applications: PropTypes.Requireable<any[]>;
36
+ };
37
+ defaultProps: {
38
+ layout: string;
39
+ baseUrl: string;
40
+ localization: {};
41
+ applications: never[];
42
+ };
43
+ };
44
+ export default AppSwitcher;
@@ -0,0 +1,307 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (_) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
49
+ import { useState, useEffect } from 'react';
50
+ import PropTypes from 'prop-types';
51
+ import jwtDecode from 'jwt-decode';
52
+ import queryString from 'query-string';
53
+ import { defaultMessages } from '../../../lang/en-us';
54
+ import AppSwitcherItem, { LogoVariants } from './AppSwitcherItem';
55
+ import { AppListHeader, AppListItem, AppOrganisationCount, StyledSVG, BackButton, MenuContent, OrganisationLink, OrganisationList, SearchBox, SearchContent, SelectedOrganisation, AppSwitcherPanel } from './AppSwitcherStyles';
56
+ import { Constants } from './constants';
57
+ import { DRAWER_WIDTH } from '../../navigation/VerticalNavigation/VerticalNavigationStyles';
58
+ var AppSwitcher = function (props) {
59
+ var _a;
60
+ var isAppSwitcherOpen = props.isAppSwitcherOpen, setIsAppSwitcherOpen = props.setIsAppSwitcherOpen, isDrawerOpen = props.isDrawerOpen, localization = props.localization, _b = props.apiKey, apiKey = _b === void 0 ? '' : _b, baseUrl = props.baseUrl;
61
+ var token = props.token;
62
+ // Controls whether the application panel is open or not.
63
+ // const [isOpen, setIsOpen] = useState(isAppSwitcherOpen)
64
+ // Holds the applications which are displayed.
65
+ var _c = useState([]), applications = _c[0], setApplications = _c[1];
66
+ // Controls which tab is active.
67
+ var _d = useState(Constants.Tabs.ListApplications), activeTab = _d[0], setActiveTab = _d[1];
68
+ // Holds the list of filtered organisations (on the second tab).
69
+ var _e = useState([]), filteredOrgs = _e[0], setFilteredOrgs = _e[1];
70
+ // Holds a reference to the active application (on the second tab).
71
+ var _f = useState(null), activeApplication = _f[0], setActiveApplication = _f[1];
72
+ // Stores any org filter text (on the second tab).
73
+ var _g = useState(''), searchString = _g[0], setSearchString = _g[1];
74
+ var messages = __assign(__assign({}, localization), defaultMessages);
75
+ var userId = (_a = props.userId) !== null && _a !== void 0 ? _a : '';
76
+ /**
77
+ * Toggles display of the Stream suite application dialog.
78
+ * @param event {React.MouseEvent} - Click event.
79
+ */
80
+ // const handleToggleAppsClick = (event: React.MouseEvent<HTMLButtonElement>): void => {
81
+ // setIsOpen(!isOpen)
82
+ // }
83
+ /**
84
+ * Handles closing of the application dialog.
85
+ */
86
+ var handleDialogClose = function () {
87
+ // setIsOpen(false)
88
+ setIsAppSwitcherOpen(false);
89
+ setTimeout(function () {
90
+ setSearchString('');
91
+ setActiveApplication(null);
92
+ setActiveTab(Constants.Tabs.ListApplications);
93
+ }, 400);
94
+ };
95
+ /**
96
+ * Updates the search/filter text.
97
+ * @param event {React.ChangeEvent}
98
+ */
99
+ var handleSearchChange = function (event) {
100
+ setSearchString(event.target.value);
101
+ };
102
+ /**
103
+ * Navigates to the organisation tab for an application with children.
104
+ * @param event {React.MouseEvent} - Click event.
105
+ * @param applicationId {number | undefined} - Unique identifier of the application.
106
+ * @returns {void}
107
+ */
108
+ var handleGoToAppClick = function (event, applicationId) {
109
+ event === null || event === void 0 ? void 0 : event.preventDefault();
110
+ event === null || event === void 0 ? void 0 : event.stopPropagation();
111
+ if (!applicationId) {
112
+ return;
113
+ }
114
+ var selectedApplication = applications.find(function (a) { return a.applicationId === applicationId; });
115
+ if (!selectedApplication) {
116
+ return;
117
+ }
118
+ setFilteredOrgs(selectedApplication.children);
119
+ setActiveApplication(selectedApplication);
120
+ setActiveTab(Constants.Tabs.ListOrgs);
121
+ };
122
+ /**
123
+ * Renders an application logo.
124
+ * @param internalName {string | null | undefined } - Internal name of the application.
125
+ * @returns {ReactElement | null } SVG containing the application logo retrieved from the CDN.
126
+ */
127
+ var renderApplicationLogo = function (internalName, logoVariant) {
128
+ if (!internalName) {
129
+ return _jsx(_Fragment, {});
130
+ }
131
+ var urlToIcon = "".concat(Constants.AssetsUrl).concat(internalName, "/logo/latest/").concat(logoVariant !== null && logoVariant !== void 0 ? logoVariant : LogoVariants.Default, ".svg");
132
+ return (_jsx("svg", { children: _jsx("image", { xlinkHref: urlToIcon, width: "60", height: "60" }) }));
133
+ };
134
+ /**
135
+ * Queries the Steam Home API to fetch a list of applications.
136
+ * @returns {Promise<IApplication[]>} A list of applications the user has access to.
137
+ */
138
+ var getApplicationsForUser = function () { return __awaiter(void 0, void 0, void 0, function () {
139
+ var decodedToken, response, data;
140
+ return __generator(this, function (_a) {
141
+ switch (_a.label) {
142
+ case 0:
143
+ if (!(typeof token === 'string' && token !== window.localStorage.getItem(Constants.LocalStorageKey.Token))) return [3 /*break*/, 3];
144
+ if (!userId) {
145
+ decodedToken = jwtDecode(token);
146
+ userId = decodedToken[Constants.HomeAttributes.UserId];
147
+ }
148
+ return [4 /*yield*/, fetch("".concat(baseUrl !== null && baseUrl !== void 0 ? baseUrl : Constants.BaseUrl, "/users/").concat(userId, "/application-instances"), {
149
+ method: 'get',
150
+ headers: new Headers({
151
+ Authorization: "Bearer ".concat(token),
152
+ 'x-api-key': apiKey
153
+ })
154
+ })];
155
+ case 1:
156
+ response = _a.sent();
157
+ if (response.status !== 200) {
158
+ console.error('Unable to retrieve user applications from Stream Home');
159
+ return [2 /*return*/, []];
160
+ }
161
+ return [4 /*yield*/, response.json()
162
+ // Store the latest access token.
163
+ ];
164
+ case 2:
165
+ data = _a.sent();
166
+ // Store the latest access token.
167
+ window.localStorage.setItem(Constants.LocalStorageKey.Token, token);
168
+ return [2 /*return*/, data.map(function (application) {
169
+ var applicationId = application.applicationId, applicationName = application.applicationName, shortName = application.shortName, internalName = application.internalName, customName = application.customName, url = application.url;
170
+ return {
171
+ applicationId: applicationId,
172
+ applicationName: applicationName,
173
+ shortName: shortName,
174
+ internalName: internalName,
175
+ customName: customName,
176
+ url: url || ''
177
+ };
178
+ })];
179
+ case 3: return [2 /*return*/, []];
180
+ }
181
+ });
182
+ }); };
183
+ useEffect(function () {
184
+ var loadData = function () { return __awaiter(void 0, void 0, void 0, function () {
185
+ var applicationInstances, userApplications, parsedQueryString, uniqueApplicationIds, localApplications;
186
+ return __generator(this, function (_a) {
187
+ switch (_a.label) {
188
+ case 0:
189
+ applicationInstances = [];
190
+ userApplications = [];
191
+ if (!token) {
192
+ parsedQueryString = queryString.parse(window.location.search);
193
+ if (parsedQueryString.accessToken && typeof parsedQueryString.accessToken === 'string') {
194
+ token = parsedQueryString.accessToken;
195
+ }
196
+ }
197
+ if (!!props.applications) return [3 /*break*/, 2];
198
+ return [4 /*yield*/, getApplicationsForUser()];
199
+ case 1:
200
+ applicationInstances = _a.sent();
201
+ return [3 /*break*/, 3];
202
+ case 2:
203
+ // A hard-coded list of applications has been passed to the component.
204
+ applicationInstances = props.applications;
205
+ _a.label = 3;
206
+ case 3:
207
+ if (Array.isArray(applicationInstances) && applicationInstances.length) {
208
+ uniqueApplicationIds = applicationInstances.map(function (item) { return item.applicationId; }).filter(function (value, index, self) { return self.indexOf(value) === index; });
209
+ // Iterate over these to build up the userApplications array.
210
+ uniqueApplicationIds.forEach(function (applicationId) {
211
+ var applications = applicationInstances.filter(function (instance) { return instance.applicationId === applicationId; });
212
+ if (applications.length > 1) {
213
+ // This is an application with multiple orgs/tenants the user has access to.
214
+ userApplications.push({
215
+ applicationId: applicationId,
216
+ applicationName: applications[0].applicationName,
217
+ shortName: applications[0].shortName,
218
+ internalName: applications[0].internalName,
219
+ url: '',
220
+ children: applications.map(function (a) {
221
+ var _a;
222
+ return {
223
+ name: (_a = a.customName) !== null && _a !== void 0 ? _a : a.applicationName,
224
+ url: a.url
225
+ };
226
+ })
227
+ });
228
+ }
229
+ else {
230
+ // This is a standalone application.
231
+ userApplications.push({
232
+ applicationId: applications[0].applicationId,
233
+ applicationName: applications[0].applicationName,
234
+ shortName: applications[0].shortName,
235
+ internalName: applications[0].internalName,
236
+ url: applications[0].url
237
+ });
238
+ }
239
+ });
240
+ // Serialize and cache the applications returned.
241
+ window.localStorage.setItem(Constants.LocalStorageKey.Applications, JSON.stringify(userApplications));
242
+ }
243
+ else {
244
+ localApplications = window.localStorage.getItem(Constants.LocalStorageKey.Applications);
245
+ if (localApplications) {
246
+ // Recreate the application state from local storage.
247
+ userApplications = JSON.parse(localApplications);
248
+ }
249
+ }
250
+ // Store the user's applications.
251
+ setApplications(userApplications);
252
+ return [2 /*return*/];
253
+ }
254
+ });
255
+ }); };
256
+ loadData()
257
+ .catch(console.error);
258
+ }, [token, apiKey, baseUrl, userId]);
259
+ var handleKeyDown = function (event) {
260
+ if (event && event.type === 'keydown') {
261
+ // Close AppSwitcher if Escape key is pressed
262
+ if (event.key === 'Escape') {
263
+ handleDialogClose();
264
+ // Doesnt return focus but we need to investigate MUI again
265
+ // so that should handle it
266
+ }
267
+ }
268
+ };
269
+ if (!props.applications && (!token || !apiKey)) {
270
+ return null;
271
+ }
272
+ return (_jsxs(AppSwitcherPanel, __assign({ id: "app-switcher-menu", style: {
273
+ display: isAppSwitcherOpen ? 'block' : 'none',
274
+ left: isDrawerOpen ? DRAWER_WIDTH.Expanded : DRAWER_WIDTH.Collapsed - 3
275
+ }, role: 'dialog', onKeyDown: handleKeyDown }, { children: [activeTab === Constants.Tabs.ListApplications
276
+ ? (_jsxs("div", { children: [_jsxs(AppListHeader, { children: [_jsx("svg", { children: _jsx("image", { xlinkHref: "".concat(Constants.AssetsUrl, "suite/logo/latest/icon.svg"), width: "24", height: "24" }) }), messages['your-apps']] }), _jsx(MenuContent, __assign({ style: {
277
+ display: activeTab === 1 ? 'flex' : 'none'
278
+ } }, { children: applications.map(function (_a) {
279
+ var applicationId = _a.applicationId, applicationName = _a.applicationName, shortName = _a.shortName, internalName = _a.internalName, url = _a.url, children = _a.children;
280
+ return (_jsxs(AppListItem, { children: [url && (_jsx(AppSwitcherItem, { internalName: internalName, shortName: shortName, url: url, handleGoToAppClick: handleGoToAppClick })), !url && (_jsx(AppSwitcherItem, { internalName: internalName, shortName: shortName, handleGoToAppClick: handleGoToAppClick, applicationId: applicationId })), children && (_jsx(AppOrganisationCount, { children: children.length }))] }, applicationId));
281
+ }) }))] }))
282
+ : null, activeTab === Constants.Tabs.ListOrgs
283
+ ? (_jsxs(SearchContent, __assign({ style: {
284
+ display: activeTab === 2 ? 'flex' : 'none'
285
+ } }, { children: [_jsxs(BackButton, __assign({ onClick: function () {
286
+ setActiveTab(Constants.Tabs.ListApplications);
287
+ setSearchString('');
288
+ } }, { children: [_jsx(StyledSVG, __assign({ className: "MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiBox-root css-1om0hkc", focusable: "false", "aria-hidden": "true", viewBox: "0 0 24 24", "data-testid": "ChevronLeftIcon" }, { children: _jsx("path", { d: "M15.41 7.41 14 6l-6 6 6 6 1.41-1.41L10.83 12z" }) })), messages['back-to']] })), _jsxs(SelectedOrganisation, { children: [renderApplicationLogo(activeApplication === null || activeApplication === void 0 ? void 0 : activeApplication.internalName, LogoVariants.Solid), _jsx("h6", { children: activeApplication ? activeApplication.applicationName : '' })] }), _jsx(SearchBox, { id: "app-switcher-search-org", type: 'text', value: searchString, onChange: handleSearchChange, placeholder: messages.search }), _jsx(OrganisationList, { children: filteredOrgs === null || filteredOrgs === void 0 ? void 0 : filteredOrgs.filter(function (o) { return o.name.toLowerCase().includes(searchString.toLowerCase()); }).map(function (org, i) { return (_jsxs(OrganisationLink, __assign({ href: org.url, target: "_blank" }, { children: [org.name, _jsx(StyledSVG, __assign({ className: "MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiBox-root css-1om0hkc", focusable: "false", "aria-hidden": "true", viewBox: "0 0 24 24", "data-testid": "ChevronRightIcon" }, { children: _jsx("path", { d: "M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" }) }))] }), i)); }) })] })))
289
+ : null] })));
290
+ };
291
+ AppSwitcher.propTypes = {
292
+ accessToken: PropTypes.string,
293
+ apiKey: PropTypes.string,
294
+ layout: PropTypes.string,
295
+ userId: PropTypes.number,
296
+ baseUrl: PropTypes.string,
297
+ localization: PropTypes.object,
298
+ currentApplicationId: PropTypes.number,
299
+ applications: PropTypes.array
300
+ };
301
+ AppSwitcher.defaultProps = {
302
+ layout: Constants.Layout.Vertical,
303
+ baseUrl: Constants.BaseUrl,
304
+ localization: {},
305
+ applications: []
306
+ };
307
+ export default AppSwitcher;
@@ -0,0 +1,16 @@
1
+ import { ReactElement } from 'react';
2
+ export declare const LogoVariants: {
3
+ Default: string;
4
+ Solid: string;
5
+ Outlined: string;
6
+ White: string;
7
+ };
8
+ interface IAppSwitcherItemProps {
9
+ internalName: string;
10
+ shortName: string;
11
+ handleGoToAppClick: Function;
12
+ applicationId?: number;
13
+ url?: string;
14
+ }
15
+ declare const AppSwitcherItem: (props: IAppSwitcherItemProps) => ReactElement;
16
+ export default AppSwitcherItem;
@@ -0,0 +1,51 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { Constants } from './constants';
14
+ import { AppLink, AppName, StyledLogoSVG } from './AppSwitcherStyles';
15
+ // Bug in the naming of the icons on the CDN
16
+ export var LogoVariants = {
17
+ Default: 'icon',
18
+ Solid: 'icon-solid',
19
+ Outlined: 'icon-outlined',
20
+ White: 'icon-white'
21
+ };
22
+ var AppSwitcherItem = function (props) {
23
+ var applicationId = props.applicationId, internalName = props.internalName, shortName = props.shortName, url = props.url, handleGoToAppClick = props.handleGoToAppClick;
24
+ /**
25
+ * Renders an application logo.
26
+ * @param internalName {string | null | undefined } - Internal name of the application.
27
+ * @returns {ReactElement | null } SVG containing the application logo retrieved from the CDN.
28
+ */
29
+ var renderApplicationLogo = function (internalName, logoVariant) {
30
+ if (!internalName) {
31
+ return _jsx(_Fragment, {});
32
+ }
33
+ var urlToIcon = "".concat(Constants.AssetsUrl).concat(internalName, "/logo/latest/").concat(logoVariant !== null && logoVariant !== void 0 ? logoVariant : LogoVariants.Default, ".svg");
34
+ return (_jsx(StyledLogoSVG, { children: _jsx("image", { xlinkHref: urlToIcon, width: "60", height: "60" }) }));
35
+ };
36
+ var solidLogo = renderApplicationLogo(internalName, LogoVariants.Solid);
37
+ return (_jsxs(AppLink, __assign({ href: url !== null && url !== void 0 ? url : '#', target: "_blank", onClick: function (event) { return applicationId ? handleGoToAppClick(event, applicationId) : null; } }, { children: [applicationId && (
38
+ // Create a stack effect to indicate multiple
39
+ _jsxs(_Fragment, { children: [_jsx("span", __assign({ style: {
40
+ position: 'absolute',
41
+ top: '4px',
42
+ transform: 'scale(0.8)',
43
+ zIndex: 0
44
+ } }, { children: solidLogo })), _jsx("span", __assign({ style: {
45
+ position: 'absolute',
46
+ top: '10px',
47
+ transform: 'scale(0.9)',
48
+ zIndex: 0
49
+ } }, { children: solidLogo }))] })), solidLogo, _jsx(AppName, { children: shortName })] })));
50
+ };
51
+ export default AppSwitcherItem;
@@ -0,0 +1,17 @@
1
+ /// <reference types="react" />
2
+ export declare const AppSwitcherPanel: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
3
+ export declare const List: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, {}>;
4
+ export declare const MenuContent: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
5
+ export declare const SearchContent: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
6
+ export declare const AppListHeader: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, {}>;
7
+ export declare const AppListItem: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
8
+ export declare const AppLink: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, {}>;
9
+ export declare const BackButton: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {}>;
10
+ export declare const SearchBox: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, {}>;
11
+ export declare const AppName: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, {}>;
12
+ export declare const AppOrganisationCount: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
13
+ export declare const SelectedOrganisation: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
14
+ export declare const StyledSVG: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").SVGProps<SVGSVGElement>, {}>;
15
+ export declare const OrganisationList: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
16
+ export declare const OrganisationLink: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, {}>;
17
+ export declare const StyledLogoSVG: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").SVGProps<SVGSVGElement>, {}>;
@@ -0,0 +1,48 @@
1
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
2
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3
+ return cooked;
4
+ };
5
+ import { styled } from '@mui/material/styles';
6
+ export var AppSwitcherPanel = styled('div')(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background-color: ", ";\n border-radius: 0 4px 4px 0;\n bottom: 0;\n box-shadow: 5px 7px 8px -10px rgb(0 0 0 / 20%), 5px 12px 17px -10px rgb(0 0 0 / 14%), 5px 5px 22px -10px rgb(0 0 0 / 12%);\n box-sizing: border-box;\n font-family: 'Roboto';\n height: 450px;\n left: 57px;\n padding: 1rem 1.5rem;\n position: fixed;\n width: 360px;\n z-index: 1;\n"], ["\n background-color: ", ";\n border-radius: 0 4px 4px 0;\n bottom: 0;\n box-shadow: 5px 7px 8px -10px rgb(0 0 0 / 20%), 5px 12px 17px -10px rgb(0 0 0 / 14%), 5px 5px 22px -10px rgb(0 0 0 / 12%);\n box-sizing: border-box;\n font-family: 'Roboto';\n height: 450px;\n left: 57px;\n padding: 1rem 1.5rem;\n position: fixed;\n width: 360px;\n z-index: 1;\n"])), function (props) { return props.theme.palette.mode === 'dark'
7
+ ? props.theme.palette.primary.dark
8
+ : '#E6EAF0'; });
9
+ export var List = styled('ul')(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n"], ["\n"])));
10
+ export var MenuContent = styled('div')(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n align-items: flex-start;\n flex-direction: row;\n flex-wrap: wrap;\n justify-content: flex-start;\n margin-top: 1rem;\n"], ["\n align-items: flex-start;\n flex-direction: row;\n flex-wrap: wrap;\n justify-content: flex-start;\n margin-top: 1rem;\n"])));
11
+ export var SearchContent = styled('div')(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n align-items: flex-start;\n box-sizing: border-box;\n flex-direction: column;\n justify-content: flex-start;\n padding: 1rem 1rem 2rem;\n"], ["\n align-items: flex-start;\n box-sizing: border-box;\n flex-direction: column;\n justify-content: flex-start;\n padding: 1rem 1rem 2rem;\n"])));
12
+ export var AppListHeader = styled('p')(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n align-items: center;\n color: ", ";\n display: flex;\n font-weight: normal;\n justify-content: flex-start;\n padding: 0.5rem 1.25rem 0;\n text-transform: uppercase;\n\n & svg {\n height: 24px;\n margin-right: 0.5rem;\n width: 24px;\n }\n"], ["\n align-items: center;\n color: ", ";\n display: flex;\n font-weight: normal;\n justify-content: flex-start;\n padding: 0.5rem 1.25rem 0;\n text-transform: uppercase;\n\n & svg {\n height: 24px;\n margin-right: 0.5rem;\n width: 24px;\n }\n"])), function (props) { return props.theme.palette.mode === 'dark'
13
+ ? props.theme.palette.primary.contrastText
14
+ : '#757575'; });
15
+ export var AppListItem = styled('div')(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n align-items: center;\n align-self: stretch;\n box-sizing: border-box;\n flex-direction: column;\n flex: 0 0 ", "%;\n overflow: visible;\n padding: 0.25rem;\n position: relative;\n\n &:hover {\n background-color: transparent;\n }\n"], ["\n align-items: center;\n align-self: stretch;\n box-sizing: border-box;\n flex-direction: column;\n flex: 0 0 ", "%;\n overflow: visible;\n padding: 0.25rem;\n position: relative;\n\n &:hover {\n background-color: transparent;\n }\n"])), 100 / 3);
16
+ export var AppLink = styled('a')(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n align-items: center;\n border-radius: 4px;\n box-shadow: none;\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n font-size: 0.85rem;\n justify-content: center;\n overflow: hidden;\n padding: 1rem 0 0.5rem;\n position: relative;\n text-align: center;\n text-decoration: none;\n transition: all 200ms ease;\n width: 100%;\n\n & .MuiTouchRipple-rippleVisible {\n color: #004071;\n opacity: 0.25;\n }\n\n &:hover,\n &:focus {\n background-color: ", ";\n text-decoration: none;\n }\n\n &:active {\n background-color: #f1f1f1;\n }\n\n & svg {\n height: 60px;\n width: 60px;\n }\n\n &:hover + span,\n &:focus + span {\n opacity: 1;\n }\n\n &:hover svg,\n &:focus svg {\n background-color: ", ";\n border-color: ", ";\n }\n"], ["\n align-items: center;\n border-radius: 4px;\n box-shadow: none;\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n font-size: 0.85rem;\n justify-content: center;\n overflow: hidden;\n padding: 1rem 0 0.5rem;\n position: relative;\n text-align: center;\n text-decoration: none;\n transition: all 200ms ease;\n width: 100%;\n\n & .MuiTouchRipple-rippleVisible {\n color: #004071;\n opacity: 0.25;\n }\n\n &:hover,\n &:focus {\n background-color: ", ";\n text-decoration: none;\n }\n\n &:active {\n background-color: #f1f1f1;\n }\n\n & svg {\n height: 60px;\n width: 60px;\n }\n\n &:hover + span,\n &:focus + span {\n opacity: 1;\n }\n\n &:hover svg,\n &:focus svg {\n background-color: ", ";\n border-color: ", ";\n }\n"])), function (props) { return props.theme.palette.mode === 'dark'
17
+ ? 'rgba(22, 92, 141, 1)'
18
+ : '#ebf2fc'; }, function (props) { return props.theme.palette.mode === 'dark'
19
+ ? 'rgba(22, 92, 141, 1)'
20
+ : '#ebf2fc'; }, function (props) { return props.theme.palette.mode === 'dark'
21
+ ? 'rgba(22, 92, 141, 1)'
22
+ : '#ebf2fc'; });
23
+ export var BackButton = styled('button')(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n align-items: center;\n background: transparent;\n border: 0;\n color: ", ";\n cursor: pointer;\n display: flex;\n padding: 0.25rem 0;\n text-align: left;\n width: 100%;\n\n &:focus,\n &:hover {\n background-color: ", ";\n }\n"], ["\n align-items: center;\n background: transparent;\n border: 0;\n color: ", ";\n cursor: pointer;\n display: flex;\n padding: 0.25rem 0;\n text-align: left;\n width: 100%;\n\n &:focus,\n &:hover {\n background-color: ", ";\n }\n"])), function (props) { return props.theme.palette.mode === 'dark'
24
+ ? props.theme.palette.primary.contrastText
25
+ : '#757575'; }, function (props) { return props.theme.palette.mode === 'dark'
26
+ ? 'rgba(255, 255, 255, 0.1)'
27
+ : 'rgba(0, 0, 0, 0.1)'; });
28
+ export var SearchBox = styled('input')(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n background: #f4f4f4;\n border: thin solid #888;\n box-sizing: border-box;\n color: #777;\n padding: 0.5rem;\n width: 100%;\n\n &:hover .MuiOutlinedInput-notchedOutline {\n border-color: #888;\n }\n\n & .MuiOutlinedInput-root {\n border-radius: 0;\n color: #777;\n padding: 0;\n }\n\n & .MuiOutlinedInput-input {\n padding: 0.5rem;\n }\n\n & ::placeholder {\n opacity: 0.75;\n }\n"], ["\n background: #f4f4f4;\n border: thin solid #888;\n box-sizing: border-box;\n color: #777;\n padding: 0.5rem;\n width: 100%;\n\n &:hover .MuiOutlinedInput-notchedOutline {\n border-color: #888;\n }\n\n & .MuiOutlinedInput-root {\n border-radius: 0;\n color: #777;\n padding: 0;\n }\n\n & .MuiOutlinedInput-input {\n padding: 0.5rem;\n }\n\n & ::placeholder {\n opacity: 0.75;\n }\n"])));
29
+ export var AppName = styled('p')(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n color: ", ";\n font-weight: normal;\n margin: 0.5rem 0 0;\n white-space: nowrap;\n"], ["\n color: ", ";\n font-weight: normal;\n margin: 0.5rem 0 0;\n white-space: nowrap;\n"])), function (props) { return props.theme.palette.mode === 'dark'
30
+ ? props.theme.palette.primary.contrastText
31
+ : '#757575'; });
32
+ export var AppOrganisationCount = styled('span')(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n background: #00497D;\n border-color: #616161;\n border-radius: 4px;\n border: none;\n color: white;\n font-size: 1rem;\n font-weight: bold;\n height: 50px;\n left: 50%;\n line-height: 50px;\n margin-top: 0;\n opacity: 0;\n pointer-events: none;\n position: absolute;\n text-align: center;\n top: 43%;\n transform: translate(-50%, -50%);\n width: 50px;\n z-index: 1;\n"], ["\n background: #00497D;\n border-color: #616161;\n border-radius: 4px;\n border: none;\n color: white;\n font-size: 1rem;\n font-weight: bold;\n height: 50px;\n left: 50%;\n line-height: 50px;\n margin-top: 0;\n opacity: 0;\n pointer-events: none;\n position: absolute;\n text-align: center;\n top: 43%;\n transform: translate(-50%, -50%);\n width: 50px;\n z-index: 1;\n"])));
33
+ export var SelectedOrganisation = styled('div')(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n align-items: center;\n color: ", ";\n display: flex;\n flex-direction: row;\n justify-content: flex-start;\n padding: 1.5rem 0;\n text-transform: uppercase;\n width: 100%;\n\n & svg,\n & svg image {\n height: 24px;\n width: 24px;\n }\n\n & h6 {\n font-size: 1.2rem;\n font-weight: 600;\n margin: 0 0 0 1rem;\n }\n"], ["\n align-items: center;\n color: ", ";\n display: flex;\n flex-direction: row;\n justify-content: flex-start;\n padding: 1.5rem 0;\n text-transform: uppercase;\n width: 100%;\n\n & svg,\n & svg image {\n height: 24px;\n width: 24px;\n }\n\n & h6 {\n font-size: 1.2rem;\n font-weight: 600;\n margin: 0 0 0 1rem;\n }\n"])), function (props) { return props.theme.palette.mode === 'dark'
34
+ ? props.theme.palette.primary.contrastText
35
+ : '#757575'; });
36
+ export var StyledSVG = styled('svg')(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n box-sizing: content-box;\n display: inline-block;\n fill: currentcolor;\n flex-shrink: 0;\n font-size: 1.5rem;\n height: 1em;\n margin: 4px;\n padding: 0;\n user-select: none;\n width: 1em;\n"], ["\n box-sizing: content-box;\n display: inline-block;\n fill: currentcolor;\n flex-shrink: 0;\n font-size: 1.5rem;\n height: 1em;\n margin: 4px;\n padding: 0;\n user-select: none;\n width: 1em;\n"])));
37
+ export var OrganisationList = styled('div')(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n height: 300px;\n overflow: auto;\n padding-top: 0.5rem;\n width: 100%;\n"], ["\n height: 300px;\n overflow: auto;\n padding-top: 0.5rem;\n width: 100%;\n"])));
38
+ export var OrganisationLink = styled('a')(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n align-items: center;\n border-radius: 4px;\n box-shadow: none;\n color: ", ";\n display: flex;\n font-size: 1rem;\n justify-content: space-between;\n margin: 0 0.125rem;\n padding: 0.5rem;\n text-decoration: none;\n transition: all 200ms ease;\n\n & .MuiTouchRipple-rippleVisible {\n color: #004071;\n opacity: 0.25;\n }\n\n &:focus,\n &:hover {\n background-color: ", ";\n\n & svg {\n visibility: visible;\n }\n }\n\n &:active {\n background-color: #f1f1f1;\n }\n\n & .MuiLink-root {\n align-items: center;\n color: #777;\n display: flex;\n justify-content: space-between;\n text-decoration: none;\n width: 100%;\n }\n\n & svg {\n visibility: hidden;\n }\n"], ["\n align-items: center;\n border-radius: 4px;\n box-shadow: none;\n color: ", ";\n display: flex;\n font-size: 1rem;\n justify-content: space-between;\n margin: 0 0.125rem;\n padding: 0.5rem;\n text-decoration: none;\n transition: all 200ms ease;\n\n & .MuiTouchRipple-rippleVisible {\n color: #004071;\n opacity: 0.25;\n }\n\n &:focus,\n &:hover {\n background-color: ", ";\n\n & svg {\n visibility: visible;\n }\n }\n\n &:active {\n background-color: #f1f1f1;\n }\n\n & .MuiLink-root {\n align-items: center;\n color: #777;\n display: flex;\n justify-content: space-between;\n text-decoration: none;\n width: 100%;\n }\n\n & svg {\n visibility: hidden;\n }\n"])), function (props) { return props.theme.palette.mode === 'dark'
39
+ ? props.theme.palette.primary.contrastText
40
+ : '#757575'; }, function (props) { return props.theme.palette.mode === 'dark'
41
+ ? 'rgba(255, 255, 255, 0.1)'
42
+ : 'rgba(0, 0, 0, 0.1)'; });
43
+ export var StyledLogoSVG = styled('svg')(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n background-color: ", ";\n border: thin solid ", ";\n position: relative;\n z-index: 1;\n"], ["\n background-color: ", ";\n border: thin solid ", ";\n position: relative;\n z-index: 1;\n"])), function (props) { return props.theme.palette.mode === 'dark'
44
+ ? props.theme.palette.primary.dark
45
+ : '#E6EAF0'; }, function (props) { return props.theme.palette.mode === 'dark'
46
+ ? props.theme.palette.primary.dark
47
+ : '#E6EAF0'; });
48
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16;
@@ -0,0 +1,34 @@
1
+ export declare const Constants: Readonly<{
2
+ LocalStorageKey: {
3
+ Token: string;
4
+ Applications: string;
5
+ };
6
+ HomeAttributes: {
7
+ UserId: string;
8
+ };
9
+ BaseUrl: "https://api.home.learningpool.com/";
10
+ AssetsUrl: "https://uuicdn.learningpool.com/";
11
+ Layout: {
12
+ Vertical: string;
13
+ Horizontal: string;
14
+ };
15
+ Tabs: {
16
+ ListApplications: number;
17
+ ListOrgs: number;
18
+ };
19
+ }>;
20
+ export declare const applications: ({
21
+ applicationId: number;
22
+ applicationName: string;
23
+ shortName: string;
24
+ internalName: string;
25
+ url: string;
26
+ customName?: undefined;
27
+ } | {
28
+ applicationId: number;
29
+ applicationName: string;
30
+ shortName: string;
31
+ internalName: string;
32
+ customName: string;
33
+ url: string;
34
+ })[];
@@ -0,0 +1,27 @@
1
+ export var Constants = Object.freeze({
2
+ LocalStorageKey: {
3
+ Token: 'lp-home-access-token',
4
+ Applications: 'lp-home-applications'
5
+ },
6
+ HomeAttributes: {
7
+ UserId: 'lp-home-user-id'
8
+ },
9
+ BaseUrl: 'https://api.home.learningpool.com/',
10
+ AssetsUrl: 'https://uuicdn.learningpool.com/',
11
+ Layout: {
12
+ Vertical: 'vertical',
13
+ Horizontal: 'horizontal'
14
+ },
15
+ Tabs: {
16
+ ListApplications: 1,
17
+ ListOrgs: 2
18
+ }
19
+ });
20
+ export var applications = [
21
+ { applicationId: 1, applicationName: 'Stream LXP', shortName: 'LXP', internalName: 'stream', url: 'https://learningpool.com' },
22
+ { applicationId: 2, applicationName: 'Stream Analytics', shortName: 'Analytics', internalName: 'analytics', url: 'https://learningpool.com' },
23
+ { applicationId: 3, applicationName: 'Stream Automation', shortName: 'Automation', internalName: 'automation', customName: 'Waves 1', url: 'https://learningpool.com' },
24
+ { applicationId: 3, applicationName: 'Stream Automation', shortName: 'Automation', internalName: 'automation', customName: 'Waves 2', url: 'https://learningpool.com' },
25
+ { applicationId: 7, applicationName: 'Stream LMS', shortName: 'LMS', internalName: 'lms', customName: '', url: 'https://learningpool.com' },
26
+ { applicationId: 4, applicationName: 'Stream Authoring', shortName: 'Authoring', internalName: 'authoring', customName: '', url: 'https://learningpool.com' }
27
+ ];
@@ -0,0 +1,6 @@
1
+ export const defaultMessages: {
2
+ 'your-apps': string;
3
+ 'back-to': string;
4
+ 'select-an-organisation': string;
5
+ search: string;
6
+ };
package/lang/en-us.js ADDED
@@ -0,0 +1,6 @@
1
+ export var defaultMessages = {
2
+ 'your-apps': 'Your Stream suite apps',
3
+ 'back-to': 'Back',
4
+ 'select-an-organisation': 'Select an organisation',
5
+ search: 'Search'
6
+ };
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "components",
10
10
  "ui"
11
11
  ],
12
- "version": "1.6.0-beta.8",
12
+ "version": "1.6.0-beta.9",
13
13
  "private": false,
14
14
  "main": "index.js",
15
15
  "module": "index.js",
@@ -17,7 +17,6 @@
17
17
  "@emotion/react": "^11.7.1",
18
18
  "@emotion/styled": "^11.6.0",
19
19
  "@learningpool/design-tokens": "^1.1.0-beta.7",
20
- "@learningpool/app-switcher": "1.1.0-beta.4",
21
20
  "@mui/icons-material": "^5.8.4",
22
21
  "@mui/material": "^5.8.5",
23
22
  "@mui/x-data-grid": "^5.12.3",
@@ -30,6 +29,8 @@
30
29
  "eslint-plugin-n": "^15.2.4",
31
30
  "focus-trap-react": "^8.11.0",
32
31
  "framer-motion": "^6.5.1",
32
+ "jwt-decode": "^3.1.2",
33
+ "query-string": "^7.1.1",
33
34
  "tss-react": "^3.3.6",
34
35
  "typescript": "^4.6.2",
35
36
  "web-vitals": "^2.1.4"