@learningpool/ui 1.18.1 → 1.19.1
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/components/datadisplay/WelcomeBanner/WelcomeBannerStyles.js +4 -1
- package/components/navigation/VerticalNavigation/VerticalNavigation.js +5 -5
- package/components/navigation/VerticalNavigation/VerticalNavigationStyles.js +0 -4
- package/components/stream/AppHub/AppHub.js +14 -11
- package/components/stream/AppHub/AppHubBannerAdvert.js +13 -2
- package/components/stream/AppHub/AppHubCustom.d.ts +1 -0
- package/components/stream/AppHub/AppHubCustom.js +20 -12
- package/components/stream/AppHub/AppHubCustomStyles.d.ts +1 -13
- package/components/stream/AppHub/AppHubProduct.d.ts +1 -0
- package/components/stream/AppHub/AppHubProduct.js +7 -13
- package/components/stream/AppHub/AppHubProductStyles.d.ts +2 -26
- package/components/stream/AppHub/AppHubProductStyles.js +1 -0
- package/components/stream/AppHub/AppHubStyles.js +2 -1
- package/components/stream/AppSwitcher/AppSwitcher.d.ts +2 -32
- package/components/stream/AppSwitcher/AppSwitcher.js +117 -261
- package/components/stream/AppSwitcher/AppSwitcherStyles.d.ts +46 -74
- package/components/stream/AppSwitcher/AppSwitcherStyles.js +46 -322
- package/components/stream/AppSwitcher/constants.d.ts +5 -0
- package/components/stream/AppSwitcher/constants.js +8 -3
- package/lang/en-us.d.ts +1 -0
- package/lang/en-us.js +2 -1
- package/package.json +1 -1
- package/types/components/navigation/VerticalNavigation.d.ts +0 -5
- package/types/components/stream/AppHub.d.ts +8 -0
- package/types/components/stream/AppSwitcher.d.ts +58 -8
- package/utils/helpers.d.ts +2 -1
- package/utils/helpers.js +11 -5
- package/components/stream/AppSwitcher/AppSwitcherItem.d.ts +0 -17
- package/components/stream/AppSwitcher/AppSwitcherItem.js +0 -40
- package/components/stream/AppSwitcher/AppSwitcherStylesStandalone.d.ts +0 -16
- package/components/stream/AppSwitcher/AppSwitcherStylesStandalone.js +0 -256
- package/components/stream/AppSwitcher/PromotionalCampaignItem.d.ts +0 -9
- package/components/stream/AppSwitcher/PromotionalCampaignItem.js +0 -29
|
@@ -1,156 +1,49 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { useState, useEffect } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import jwtDecode from 'jwt-decode';
|
|
5
5
|
import * as queryString from 'query-string';
|
|
6
|
-
import
|
|
7
|
-
import { AppListHeader, AppListItem, AppOrganisationCount, StyledSVG, BackButton, MenuContent, OrganisationLink, OrganisationList, SearchBox, SearchContent, SelectedOrganisation, AppSwitcherPanel, StyleHomeButton } from './AppSwitcherStyles';
|
|
6
|
+
import { AppSwitcherPanel, AppSwitcherHeaderPanel, AppSwitcherHeader, AppSwitcherCloseButton, AppSwitcherFooterPanel, StyledHomeButton, AppSwitcherShadow } from './AppSwitcherStyles';
|
|
8
7
|
import { Constants } from './constants';
|
|
9
8
|
import { defaultAttributes } from '../../../utils/dataAttributes';
|
|
9
|
+
import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
|
|
10
10
|
import ChevronRightIcon from '@mui/icons-material/ChevronRight';
|
|
11
|
-
import PromotionalCampaignItem from './PromotionalCampaignItem';
|
|
12
11
|
import { EVENT_KEYS } from '../../../utils/constants';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
url.searchParams.append('utm_medium', medium);
|
|
18
|
-
url.searchParams.append('utm_campaign', campaign);
|
|
19
|
-
return url.toString();
|
|
20
|
-
}
|
|
21
|
-
catch (error) {
|
|
22
|
-
console.error('Error adding UTM params to advert redirect - invalid URL:', baseUrl, error);
|
|
23
|
-
return baseUrl;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
12
|
+
import { HubEventTypeID } from '../../../utils/Enums/HubEventTypes.enum';
|
|
13
|
+
import AppHub from '../AppHub/AppHub';
|
|
14
|
+
import { Box, Typography } from '@mui/material';
|
|
15
|
+
import { DrawerShadow } from '../../navigation/VerticalNavigation/VerticalNavigationStyles';
|
|
26
16
|
const AppSwitcher = (props) => {
|
|
27
|
-
const { isAppSwitcherOpen, handleToggleAppSwitcher, isDrawerOpen, localization, dataAttributes, apiKey = '',
|
|
17
|
+
const { isAppSwitcherOpen, handleToggleAppSwitcher, isDrawerOpen, localization, dataAttributes, baseUrl, avatarName, apiKey = '', isStandalone = true } = props;
|
|
28
18
|
let { token } = props;
|
|
29
|
-
|
|
30
|
-
const [
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
// Controls which tab is active.
|
|
34
|
-
const [activeTab, setActiveTab] = useState(Constants.Tabs.ListApplications);
|
|
35
|
-
// Holds the list of filtered organisations (on the second tab).
|
|
36
|
-
const [filteredOrgs, setFilteredOrgs] = useState([]);
|
|
37
|
-
// Holds a reference to the active application (on the second tab).
|
|
38
|
-
const [activeApplication, setActiveApplication] = useState(null);
|
|
39
|
-
// Stores any org filter text (on the second tab).
|
|
40
|
-
const [searchString, setSearchString] = useState('');
|
|
41
|
-
// Holds the number of valid promotional campaigns.
|
|
42
|
-
const [validCampaignCount, setValidCampaignCount] = useState(promotionalCampaigns?.length || 0);
|
|
43
|
-
// Decrease the valid campaign count if an image fails to load.
|
|
44
|
-
const handleCampaignImageError = () => {
|
|
45
|
-
setValidCampaignCount(prev => Math.max(0, prev - 1));
|
|
46
|
-
};
|
|
19
|
+
const [dashboardData, setDashboardData] = useState([]);
|
|
20
|
+
const [hasPromotionalCampaigns, setHasPromotionalCampaigns] = useState(false);
|
|
21
|
+
const [userOrg, setUserOrg] = useState('');
|
|
22
|
+
const userFirstName = avatarName?.split(' ')[0];
|
|
47
23
|
const messages = { ...Constants.DefaultMessages, ...localization };
|
|
48
24
|
const dataIds = { ...defaultAttributes, ...dataAttributes };
|
|
49
25
|
let userId = props.userId ?? '';
|
|
50
|
-
/**
|
|
51
|
-
* Queries the Hub/Home API to fetch latest promotional campaign.
|
|
52
|
-
* @returns {Promise<IApplication[]>} Get a Promotional Campaign to show.
|
|
53
|
-
*/
|
|
54
|
-
const getLatestPromotionalCampaign = async () => {
|
|
55
|
-
// If the access token has changed the endpoint should be called again.
|
|
56
|
-
if (!token || typeof token !== 'string') {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
try {
|
|
60
|
-
const response = await fetch(`${baseUrl ?? Constants.BaseUrl}/promotional-campaigns?onlyLatest=true&isActive=true`, {
|
|
61
|
-
method: 'get',
|
|
62
|
-
headers: new Headers({
|
|
63
|
-
Authorization: `Bearer ${token}`,
|
|
64
|
-
'x-api-key': apiKey
|
|
65
|
-
})
|
|
66
|
-
});
|
|
67
|
-
if (!response.ok) {
|
|
68
|
-
console.error('Unable to retrieve latest promotional campaign from Hub API, returned statuscode:', response.status);
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
const responseData = await response.json();
|
|
72
|
-
const data = responseData.records;
|
|
73
|
-
// Store the latest access token
|
|
74
|
-
window.localStorage.setItem(Constants.LocalStorageKey.Token, token);
|
|
75
|
-
return data?.map(({ id, name, appSwitcherImageUrl, hubImageUrl, altText, basePromoUrl, isActive }) => ({
|
|
76
|
-
id,
|
|
77
|
-
name,
|
|
78
|
-
appSwitcherImageUrl,
|
|
79
|
-
hubImageUrl,
|
|
80
|
-
altText,
|
|
81
|
-
basePromoUrl,
|
|
82
|
-
isActive
|
|
83
|
-
})) || null;
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
console.error('Unable to retrieve and display latest promotional campaign from Hub API', error);
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
26
|
/**
|
|
91
27
|
* Handles closing of the application dialog.
|
|
92
28
|
*/
|
|
93
29
|
const handleDialogClose = () => {
|
|
94
30
|
handleToggleAppSwitcher();
|
|
95
|
-
setTimeout(() => {
|
|
96
|
-
setSearchString('');
|
|
97
|
-
setActiveApplication(null);
|
|
98
|
-
setActiveTab(Constants.Tabs.ListApplications);
|
|
99
|
-
}, 400);
|
|
100
|
-
};
|
|
101
|
-
/**
|
|
102
|
-
* Updates the search/filter text.
|
|
103
|
-
* @param event {React.ChangeEvent}
|
|
104
|
-
*/
|
|
105
|
-
const handleSearchChange = (event) => {
|
|
106
|
-
setSearchString(event.target.value);
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* Navigates to the organisation tab for an application with children.
|
|
110
|
-
* @param event {React.MouseEvent} - Click event.
|
|
111
|
-
* @param applicationId {number | undefined} - Unique identifier of the application.
|
|
112
|
-
* @returns {void}
|
|
113
|
-
*/
|
|
114
|
-
const handleGoToAppClick = (event, applicationId) => {
|
|
115
|
-
event?.preventDefault();
|
|
116
|
-
event?.stopPropagation();
|
|
117
|
-
if (!applicationId) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
const selectedApplication = applications.find(a => a.applicationId === applicationId);
|
|
121
|
-
if (!selectedApplication) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
setFilteredOrgs(selectedApplication.children);
|
|
125
|
-
setActiveApplication(selectedApplication);
|
|
126
|
-
setActiveTab(Constants.Tabs.ListOrgs);
|
|
127
31
|
};
|
|
128
32
|
/**
|
|
129
|
-
*
|
|
130
|
-
* @
|
|
131
|
-
* @returns {ReactElement | null } SVG containing the application logo retrieved from the CDN.
|
|
33
|
+
* Queries the Steam Home API to fetch dashboard data.
|
|
34
|
+
* @returns {Promise<IHubDashboard>} A list of data from hub dashboard.
|
|
132
35
|
*/
|
|
133
|
-
const
|
|
134
|
-
if (!internalName) {
|
|
135
|
-
return _jsx(_Fragment, {});
|
|
136
|
-
}
|
|
137
|
-
const urlToIcon = `${Constants.AssetsUrl}${internalName}/logo/latest/${logoVariant ?? LogoVariants.Default}.svg`;
|
|
138
|
-
return (_jsx("svg", { children: _jsx("image", { xlinkHref: urlToIcon, width: "60", height: "60" }) }));
|
|
139
|
-
};
|
|
140
|
-
/**
|
|
141
|
-
* Queries the Steam Home API to fetch a list of applications.
|
|
142
|
-
* @returns {Promise<IApplication[]>} A list of applications the user has access to.
|
|
143
|
-
*/
|
|
144
|
-
const getApplicationsForUser = async () => {
|
|
36
|
+
const getHubDashboardData = async () => {
|
|
145
37
|
// If the access token has changed the endpoint should be called again.
|
|
146
|
-
if (token && typeof token === 'string'
|
|
38
|
+
if (token && typeof token === 'string') {
|
|
147
39
|
if (!userId) {
|
|
148
40
|
// Extract user identifier from the JWT.
|
|
149
41
|
const decodedToken = jwtDecode(token);
|
|
150
42
|
userId = decodedToken[Constants.HomeAttributes.UserId];
|
|
151
43
|
}
|
|
152
|
-
const
|
|
153
|
-
|
|
44
|
+
const hubAPIEndpoint = new URL(baseUrl || Constants.BaseUrl);
|
|
45
|
+
const response = await fetch(`${hubAPIEndpoint.toString()}users/${userId}/dashboard`, {
|
|
46
|
+
method: 'GET',
|
|
154
47
|
headers: new Headers({
|
|
155
48
|
Authorization: `Bearer ${token}`,
|
|
156
49
|
'x-api-key': apiKey
|
|
@@ -158,31 +51,28 @@ const AppSwitcher = (props) => {
|
|
|
158
51
|
});
|
|
159
52
|
if (response.status !== 200) {
|
|
160
53
|
console.error('Unable to retrieve user applications from Stream Home');
|
|
161
|
-
return
|
|
54
|
+
return null;
|
|
162
55
|
}
|
|
163
56
|
const data = await response.json();
|
|
164
57
|
// Store the latest access token.
|
|
165
58
|
window.localStorage.setItem(Constants.LocalStorageKey.Token, token);
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
return {
|
|
169
|
-
applicationId,
|
|
170
|
-
applicationName,
|
|
171
|
-
shortName,
|
|
172
|
-
internalName,
|
|
173
|
-
customName,
|
|
174
|
-
url: url || ''
|
|
175
|
-
};
|
|
176
|
-
});
|
|
59
|
+
window.localStorage.setItem(Constants.LocalStorageKey.Applications, JSON.stringify(data));
|
|
60
|
+
return data;
|
|
177
61
|
}
|
|
178
62
|
else {
|
|
179
|
-
|
|
63
|
+
console.warn('Accessing dashboard data from local storage');
|
|
64
|
+
const localDashboardData = window.localStorage.getItem(Constants.LocalStorageKey.Applications);
|
|
65
|
+
if (localDashboardData) {
|
|
66
|
+
return JSON.parse(localDashboardData);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
console.warn('Token required');
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
180
72
|
}
|
|
181
73
|
};
|
|
182
74
|
useEffect(() => {
|
|
183
75
|
const loadData = async () => {
|
|
184
|
-
let applicationInstances = [];
|
|
185
|
-
let userApplications = [];
|
|
186
76
|
if (!token) {
|
|
187
77
|
const parsedQueryString = queryString.parse(window.location.search);
|
|
188
78
|
if (parsedQueryString.token && typeof parsedQueryString.token === 'string') {
|
|
@@ -194,110 +84,84 @@ const AppSwitcher = (props) => {
|
|
|
194
84
|
token = (match && match.length === 2 && match[1]) || '';
|
|
195
85
|
}
|
|
196
86
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
applicationInstances = props.applications;
|
|
87
|
+
// Store the latest access token.
|
|
88
|
+
window.localStorage.setItem(Constants.LocalStorageKey.Token, token);
|
|
89
|
+
const userDashboard = await getHubDashboardData();
|
|
90
|
+
if (!userDashboard) {
|
|
91
|
+
return;
|
|
203
92
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
93
|
+
userDashboard.applications.forEach((application) => {
|
|
94
|
+
if (application.children) {
|
|
95
|
+
application.children.forEach(a => {
|
|
96
|
+
a.onClick = () => window.open(a.url, '_blank');
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
const userDashboardData = [{
|
|
101
|
+
items: userDashboard.applications.map((app) => {
|
|
102
|
+
return Object.assign(app, {
|
|
103
|
+
hubReferenceId: app.applicationId,
|
|
104
|
+
hubEventTypeId: HubEventTypeID.APP_OPENED
|
|
105
|
+
});
|
|
106
|
+
}),
|
|
107
|
+
type: 'product',
|
|
108
|
+
title: messages['your-apps']
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
items: userDashboard.customLinks.map((customLink) => {
|
|
112
|
+
return Object.assign(customLink, {
|
|
113
|
+
hubReferenceId: customLink.name,
|
|
114
|
+
hubEventTypeId: HubEventTypeID.LINK_OPENED
|
|
225
115
|
});
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
116
|
+
}),
|
|
117
|
+
type: 'custom-link',
|
|
118
|
+
title: messages['explore-custom-apps'],
|
|
119
|
+
allowEditLinks: true
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
items: userDashboard.usefulLinks.map((link) => {
|
|
123
|
+
return Object.assign(link, {
|
|
124
|
+
hubReferenceId: link.name,
|
|
125
|
+
hubEventTypeId: HubEventTypeID.LINK_OPENED
|
|
236
126
|
});
|
|
237
|
-
}
|
|
127
|
+
}),
|
|
128
|
+
type: 'custom-link',
|
|
129
|
+
title: messages['useful-links']
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
items: userDashboard.otherProducts.map((product) => {
|
|
133
|
+
return Object.assign(product, {
|
|
134
|
+
hubReferenceId: product.applicationId,
|
|
135
|
+
hubEventTypeId: HubEventTypeID.OTHER_PRODUCT
|
|
136
|
+
});
|
|
137
|
+
}),
|
|
138
|
+
type: 'product',
|
|
139
|
+
title: messages['explore-more'],
|
|
140
|
+
allowTitle: true
|
|
141
|
+
}];
|
|
142
|
+
if (userDashboard.promotionalCampaigns?.length > 0) {
|
|
143
|
+
userDashboardData.unshift({
|
|
144
|
+
// @ts-ignore
|
|
145
|
+
items: userDashboard.promotionalCampaigns,
|
|
146
|
+
type: 'banner-advert'
|
|
238
147
|
});
|
|
239
|
-
// Serialize and cache the applications returned.
|
|
240
|
-
window.localStorage.setItem(Constants.LocalStorageKey.Applications, JSON.stringify(userApplications));
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
const localApplications = window.localStorage.getItem(Constants.LocalStorageKey.Applications);
|
|
244
|
-
if (localApplications) {
|
|
245
|
-
// Recreate the application state from local storage.
|
|
246
|
-
userApplications = JSON.parse(localApplications);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
// Store the user's applications.
|
|
250
|
-
setApplications(userApplications);
|
|
251
|
-
};
|
|
252
|
-
loadData()
|
|
253
|
-
.catch(console.error);
|
|
254
|
-
}, [token, userId, props.applications]);
|
|
255
|
-
useEffect(() => {
|
|
256
|
-
const loadPromotionalCampaigns = async () => {
|
|
257
|
-
try {
|
|
258
|
-
let promotionalCampaigns = null;
|
|
259
|
-
// Use props if available
|
|
260
|
-
if (props.promotionalCampaigns && props.promotionalCampaigns.length > 0) {
|
|
261
|
-
promotionalCampaigns = props.promotionalCampaigns;
|
|
262
|
-
}
|
|
263
|
-
else if (token && typeof token === 'string' &&
|
|
264
|
-
token !== window.localStorage.getItem(Constants.LocalStorageKey.Token)) {
|
|
265
|
-
// Fetch from API if token has changed
|
|
266
|
-
promotionalCampaigns = await getLatestPromotionalCampaign();
|
|
267
|
-
}
|
|
268
|
-
else {
|
|
269
|
-
// Check localStorage
|
|
270
|
-
const localPromotionalCampaignsJson = window.localStorage.getItem(Constants.LocalStorageKey.PromotionalCampaigns);
|
|
271
|
-
if (localPromotionalCampaignsJson) {
|
|
272
|
-
try {
|
|
273
|
-
const parsedCampaigns = JSON.parse(localPromotionalCampaignsJson);
|
|
274
|
-
if (Array.isArray(parsedCampaigns)) {
|
|
275
|
-
promotionalCampaigns = parsedCampaigns;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
catch (error) {
|
|
279
|
-
console.error('Error parsing stored campaigns:', error);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
// Update state and cache if we have campaigns
|
|
284
|
-
if (Array.isArray(promotionalCampaigns) && promotionalCampaigns.length > 0) {
|
|
285
|
-
setPromotionalCampaigns(promotionalCampaigns);
|
|
286
|
-
setValidCampaignCount(promotionalCampaigns.length);
|
|
287
|
-
window.localStorage.setItem(Constants.LocalStorageKey.PromotionalCampaigns, JSON.stringify(promotionalCampaigns));
|
|
288
|
-
}
|
|
289
|
-
else {
|
|
290
|
-
setPromotionalCampaigns(null);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
catch (error) {
|
|
294
|
-
console.error('Error loading promotional campaigns:', error);
|
|
295
|
-
setPromotionalCampaigns(null);
|
|
296
148
|
}
|
|
149
|
+
userDashboard.promotionalCampaigns.map(promotionalCampaign => {
|
|
150
|
+
return Object.assign(promotionalCampaign, {
|
|
151
|
+
hubReferenceId: promotionalCampaign.name,
|
|
152
|
+
hubEventTypeId: HubEventTypeID.REQUEST_DEMO
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
setHasPromotionalCampaigns(userDashboard.promotionalCampaigns?.length > 0);
|
|
156
|
+
setDashboardData(userDashboardData);
|
|
157
|
+
setUserOrg(userDashboard.customerAccountName);
|
|
158
|
+
window.localStorage.setItem(Constants.LocalStorageKey.HubDashboard, JSON.stringify({
|
|
159
|
+
hasPromotionalCampaigns: userDashboard.promotionalCampaigns?.length > 0,
|
|
160
|
+
hubCustomerAccountName: userDashboard.customerAccountName
|
|
161
|
+
}));
|
|
297
162
|
};
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}, [token, props.promotionalCampaigns]);
|
|
163
|
+
loadData().catch(console.error);
|
|
164
|
+
}, [token, userId]);
|
|
301
165
|
useEffect(() => {
|
|
302
166
|
if (isAppSwitcherOpen) {
|
|
303
167
|
document.addEventListener('mousedown', handleAppSwitcherClose);
|
|
@@ -326,26 +190,21 @@ const AppSwitcher = (props) => {
|
|
|
326
190
|
}
|
|
327
191
|
}
|
|
328
192
|
};
|
|
329
|
-
if (
|
|
193
|
+
if ((!token || !apiKey)) {
|
|
330
194
|
return null;
|
|
331
195
|
}
|
|
332
|
-
const
|
|
333
|
-
return (_jsxs(AppSwitcherPanel, { id: "app-switcher-menu", style: {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
:
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
}, "data-id": dataIds.AppSwitcherOrgPanel, children: [_jsxs(BackButton, { onClick: () => {
|
|
345
|
-
setActiveTab(Constants.Tabs.ListApplications);
|
|
346
|
-
setSearchString('');
|
|
347
|
-
}, "data-id": dataIds.AppSwitcherOrgBackButton, children: [_jsx(StyledSVG, { 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, { "data-id": dataIds.AppSwitcherOrgHeader, children: [renderApplicationLogo(activeApplication?.internalName, LogoVariants.Solid), _jsx("span", { children: activeApplication ? activeApplication.applicationName : '' })] }), _jsx(SearchBox, { id: "app-switcher-search-org", type: 'text', value: searchString, onChange: handleSearchChange, placeholder: messages.search, "data-id": dataIds.AppSwitcherOrgSearch }), _jsx(OrganisationList, { "data-id": dataIds.AppSwitcherOrgList, children: filteredOrgs?.filter(o => o.name.toLowerCase().includes(searchString.toLowerCase())).map((org, i) => (_jsxs(OrganisationLink, { href: org.url, target: "_blank", "data-id": dataIds.AppSwitcherOrgItem, children: [org.name, _jsx(StyledSVG, { 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))) })] }))
|
|
348
|
-
: null] }));
|
|
196
|
+
const docTextDirection = window.document?.dir;
|
|
197
|
+
return (_jsxs(_Fragment, { children: [_jsxs(AppSwitcherPanel, { id: "app-switcher-menu", style: {
|
|
198
|
+
display: isAppSwitcherOpen ? 'block' : 'none',
|
|
199
|
+
left: isDrawerOpen ? Constants.DrawerWidth.Expanded : Constants.DrawerWidth.Collapsed - 3,
|
|
200
|
+
right: (docTextDirection === 'rtl' && isDrawerOpen) ? Constants.DrawerWidth.Expanded : Constants.DrawerWidth.Collapsed - 3
|
|
201
|
+
}, role: 'dialog', "aria-label": "App Switcher", onKeyDown: handleKeyDown, "data-id": dataIds.AppSwitcherContainer, onMouseDown: (event) => event.stopPropagation(), children: [_jsxs(AppSwitcherHeaderPanel, { children: [_jsx(AppSwitcherHeader, { children: messages['your-apps'] }), _jsx(AppSwitcherCloseButton, { onClick: handleDialogClose })] }), dashboardData.length > 0 && _jsx(Box, { sx: { marginBottom: '3rem' }, children: _jsx(AppHub, { data: dashboardData, hasPromotionalCampaigns: hasPromotionalCampaigns, isAppSwitcher: true, userName: userFirstName || avatarName, userOrganization: userOrg, hubApiUrl: baseUrl || Constants.BaseUrl, hubApiKey: apiKey, hubToken: token }) }), dashboardData.length === 0 && _jsx(Typography, { variant: 'h2', component: 'h4', sx: { marginTop: '1rem', justifySelf: 'anchor-center' }, children: messages['data-not-found'] }), _jsx(AppSwitcherFooterPanel, { children: _jsx(StyledHomeButton, { "aria-label": messages['go-to-hub'], endIcon: docTextDirection === 'rtl' ? _jsx(ChevronLeftIcon, { sx: { marginRight: '0.5em' } }) : _jsx(ChevronRightIcon, {}), onClick: e => window.open(props.StreamHomeUrl || Constants.DefaultStreamHomeUrl), children: messages['go-to-hub'] }) })] }), _jsx(AppSwitcherShadow, { style: {
|
|
202
|
+
display: isAppSwitcherOpen ? 'block' : 'none',
|
|
203
|
+
left: isDrawerOpen ? Constants.DrawerWidth.Expanded : Constants.DrawerWidth.Collapsed - 3
|
|
204
|
+
} }), isAppSwitcherOpen && !isStandalone &&
|
|
205
|
+
_jsx(DrawerShadow, { className: 'drawerShadow', "aria-hidden": 'true', sx: {
|
|
206
|
+
zIndex: -1
|
|
207
|
+
} })] }));
|
|
349
208
|
};
|
|
350
209
|
AppSwitcher.propTypes = {
|
|
351
210
|
token: PropTypes.string,
|
|
@@ -353,10 +212,7 @@ AppSwitcher.propTypes = {
|
|
|
353
212
|
layout: PropTypes.string,
|
|
354
213
|
userId: PropTypes.string,
|
|
355
214
|
baseUrl: PropTypes.string,
|
|
356
|
-
localization: PropTypes.object
|
|
357
|
-
currentApplicationId: PropTypes.number,
|
|
358
|
-
applications: PropTypes.array,
|
|
359
|
-
hidePromotionalCampaign: PropTypes.bool
|
|
215
|
+
localization: PropTypes.object
|
|
360
216
|
};
|
|
361
217
|
AppSwitcher.defaultProps = {
|
|
362
218
|
layout: Constants.Layout.Vertical,
|