@imposium-hub/components 2.6.0-1 → 2.6.0-3

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.
Files changed (46) hide show
  1. package/dist/cjs/Util.d.ts +1 -1
  2. package/dist/cjs/Util.js +33 -20
  3. package/dist/cjs/Util.js.map +1 -1
  4. package/dist/cjs/components/app-wrapper/AppWrapper.d.ts +3 -1
  5. package/dist/cjs/components/app-wrapper/AppWrapper.js +14 -3
  6. package/dist/cjs/components/app-wrapper/AppWrapper.js.map +1 -1
  7. package/dist/cjs/components/header/Header.d.ts +1 -0
  8. package/dist/cjs/components/header/Header.js +3 -5
  9. package/dist/cjs/components/header/Header.js.map +1 -1
  10. package/dist/cjs/index.d.ts +2 -2
  11. package/dist/cjs/index.js +2 -2
  12. package/dist/cjs/index.js.map +1 -1
  13. package/dist/cjs/redux/actions/access.js +44 -37
  14. package/dist/cjs/redux/actions/access.js.map +1 -1
  15. package/dist/cjs/services/API.d.ts +4 -0
  16. package/dist/cjs/services/API.js.map +1 -1
  17. package/dist/cjs/utils/pendo.d.ts +2 -24
  18. package/dist/cjs/utils/pendo.js +4 -27
  19. package/dist/cjs/utils/pendo.js.map +1 -1
  20. package/dist/esm/Util.d.ts +1 -1
  21. package/dist/esm/Util.js +10 -19
  22. package/dist/esm/Util.js.map +1 -1
  23. package/dist/esm/components/app-wrapper/AppWrapper.d.ts +3 -1
  24. package/dist/esm/components/app-wrapper/AppWrapper.js +14 -3
  25. package/dist/esm/components/app-wrapper/AppWrapper.js.map +1 -1
  26. package/dist/esm/components/header/Header.d.ts +1 -0
  27. package/dist/esm/components/header/Header.js +3 -5
  28. package/dist/esm/components/header/Header.js.map +1 -1
  29. package/dist/esm/index.d.ts +2 -2
  30. package/dist/esm/index.js +2 -2
  31. package/dist/esm/index.js.map +1 -1
  32. package/dist/esm/redux/actions/access.js +63 -56
  33. package/dist/esm/redux/actions/access.js.map +1 -1
  34. package/dist/esm/services/API.d.ts +4 -0
  35. package/dist/esm/services/API.js.map +1 -1
  36. package/dist/esm/utils/pendo.d.ts +2 -24
  37. package/dist/esm/utils/pendo.js +4 -27
  38. package/dist/esm/utils/pendo.js.map +1 -1
  39. package/package.json +8 -7
  40. package/src/Util.ts +10 -16
  41. package/src/components/app-wrapper/AppWrapper.tsx +19 -2
  42. package/src/components/header/Header.tsx +5 -5
  43. package/src/index.ts +3 -3
  44. package/src/redux/actions/access.ts +64 -72
  45. package/src/services/API.ts +4 -0
  46. package/src/utils/pendo.ts +5 -28
@@ -7,13 +7,16 @@ import { useAuth0 } from '@auth0/auth0-react';
7
7
  import { replaceRoute } from '../../utils/routing';
8
8
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
9
9
  import { faExclamationTriangle } from '@fortawesome/pro-light-svg-icons';
10
+ import { initPendo } from '../../utils/pendo';
10
11
 
11
12
  export interface IAppWrapperProps {
13
+ appLabel: string;
14
+ environment: string;
12
15
  baseUrl: string;
13
16
  api: IImposiumAPI;
14
17
  organizationId: string;
15
18
  serviceId: number;
16
- unsavedChanges: boolean;
19
+ unsavedChanges?: boolean;
17
20
  setAccessData(getAccessData): void;
18
21
  onAuthenticated: (orgId: string, storyId?: string) => any;
19
22
  allowNoStories?: boolean;
@@ -48,12 +51,20 @@ export const AppWrapper: React.FC<IAppWrapperProps> = (props) => {
48
51
  serviceId,
49
52
  unsavedChanges,
50
53
  saveStory,
54
+ environment,
55
+ appLabel,
51
56
  allowNoStories
52
57
  } = props;
53
58
  const { isAuthenticated, isLoading, getAccessTokenSilently, loginWithRedirect, logout, user } =
54
59
  useAuth0();
55
60
  const [errorState, setErrorState] = React.useState(null);
56
61
 
62
+ React.useEffect(() => {
63
+ if (user) {
64
+ initPendo(appLabel, environment, user);
65
+ }
66
+ }, [user]);
67
+
57
68
  React.useEffect(() => {
58
69
  void doCheckSession(true);
59
70
  }, [isAuthenticated, isLoading]);
@@ -142,7 +153,12 @@ export const AppWrapper: React.FC<IAppWrapperProps> = (props) => {
142
153
  if (validAccessLevel) {
143
154
  api.init(baseUrl, getAccessTokenSilently, organization_id);
144
155
  onAuthenticated(organization_id, story_id);
145
- replaceRoute(`/${organization_id}/${story_id}`);
156
+
157
+ if (!hideStoryPicker) {
158
+ replaceRoute(`/${organization_id}/${story_id}`);
159
+ } else {
160
+ replaceRoute(`/${organization_id}`);
161
+ }
146
162
  setBlockRender(false);
147
163
  setErrorState(null);
148
164
  } else {
@@ -228,6 +244,7 @@ export const AppWrapper: React.FC<IAppWrapperProps> = (props) => {
228
244
  id='app'
229
245
  className='app'>
230
246
  <Header
247
+ email={user?.userEmail}
231
248
  errorState={errorState}
232
249
  saveStory={saveStory}
233
250
  onLogout={onLogout}
@@ -21,6 +21,7 @@ import { header } from '../../constants/copy';
21
21
  import { ProjectDropdown } from './ProjectDropdown';
22
22
  import { APP_WRAPPER_ERROR_STATES } from '../app-wrapper/AppWrapper';
23
23
  export interface IHeaderProps {
24
+ email: string;
24
25
  auth0: any;
25
26
  api: IImposiumAPI;
26
27
  errorState?: string;
@@ -189,7 +190,7 @@ class ImposiumHeader extends React.PureComponent<IHeaderProps, IHeaderState> {
189
190
  };
190
191
 
191
192
  private toggleAccountDropdown = (toggle: boolean, orgId: string = ''): void => {
192
- const { api, activeServiceId, unsavedChanges } = this.props;
193
+ const { api, activeServiceId, unsavedChanges, hideStoryPicker } = this.props;
193
194
  if (toggle) {
194
195
  this.setState({ showAccountDropdown: true });
195
196
  } else {
@@ -202,7 +203,7 @@ class ImposiumHeader extends React.PureComponent<IHeaderProps, IHeaderState> {
202
203
  api.getCachedStoryForOrg(activeServiceId, orgId)
203
204
  .then((res) => {
204
205
  storyId = res.story_id ? res.story_id : lastModified;
205
- if (storyId) {
206
+ if (storyId && !hideStoryPicker) {
206
207
  pushRoute(`/${orgId}/${storyId}`);
207
208
  api.cacheActiveStory(activeServiceId, orgId, storyId);
208
209
  } else {
@@ -299,7 +300,8 @@ class ImposiumHeader extends React.PureComponent<IHeaderProps, IHeaderState> {
299
300
  access,
300
301
  api,
301
302
  access: { organizations },
302
- errorState
303
+ errorState,
304
+ email
303
305
  } = this.props;
304
306
  const {
305
307
  showAccountDropdown,
@@ -474,8 +476,6 @@ class ImposiumHeader extends React.PureComponent<IHeaderProps, IHeaderState> {
474
476
  });
475
477
  }
476
478
 
477
- const email = '';
478
- // const email = scrapeEmail(auth);
479
479
  // TODO: plug this back in
480
480
  const orgSelect = () => {
481
481
  return (
package/src/index.ts CHANGED
@@ -129,7 +129,6 @@ import {
129
129
  toFixed,
130
130
  padStart,
131
131
  parameterizeServiceUrl,
132
- scrapeEmail,
133
132
  fitToContainer,
134
133
  filterHotkeys,
135
134
  mimetypeConformsToOverlay,
@@ -139,7 +138,8 @@ import {
139
138
  formattedTime,
140
139
  getSMPTE,
141
140
  checkStoryId,
142
- IMAGE_EXTENSIONS
141
+ IMAGE_EXTENSIONS,
142
+ getOrgIdFromStory
143
143
  } from './Util';
144
144
  import PublishStatusIndicator from './components/publish-wizard/publish/PublishStatusIndicator';
145
145
  import { getMediaPreviewStyle } from './utils/assets';
@@ -281,8 +281,8 @@ export {
281
281
  getFirstStoryInOrg,
282
282
  string2HexCode,
283
283
  parameterizeServiceUrl,
284
- scrapeEmail,
285
284
  fitToContainer,
285
+ getOrgIdFromStory,
286
286
  formattedTime,
287
287
  filterHotkeys,
288
288
  mimetypeConformsToOverlay,
@@ -1,33 +1,31 @@
1
+ import { getOrgIdFromStory } from '../../Util';
2
+
1
3
  export const storyAdded = (storyId: string, storyName: string): any => {
2
4
  return (dispatch, getStore) => {
3
- const {
4
- access,
5
- routing: {
6
- locationBeforeTransitions: { query }
7
- }
8
- } = getStore();
9
- const orgId: string = query.organization_id;
10
-
11
- const accessData: any = {
12
- ...access,
13
- organizations: access.organizations.map((o: any) => {
14
- if (o.id === orgId) {
15
- return {
16
- ...o,
17
- stories: [
18
- ...o.stories,
19
- {
20
- id: storyId,
21
- name: storyName
22
- }
23
- ].sort((a, b) => a.name.localeCompare(b.name))
24
- };
25
- }
5
+ const { access } = getStore();
6
+ const orgId = getOrgIdFromStory(storyId, access);
7
+ if (orgId) {
8
+ const accessData: any = {
9
+ ...access,
10
+ organizations: access.organizations.map((o: any) => {
11
+ if (o.id === orgId) {
12
+ return {
13
+ ...o,
14
+ stories: [
15
+ ...o.stories,
16
+ {
17
+ id: storyId,
18
+ name: storyName
19
+ }
20
+ ].sort((a, b) => a.name.localeCompare(b.name))
21
+ };
22
+ }
26
23
 
27
- return o;
28
- })
29
- };
30
- dispatch({ type: actions.STORY_ADDED, accessData });
24
+ return o;
25
+ })
26
+ };
27
+ dispatch({ type: actions.STORY_ADDED, accessData });
28
+ }
31
29
  };
32
30
  };
33
31
 
@@ -54,61 +52,55 @@ export const orgNameMutated = (orgId: string, newOrgName: string): any => {
54
52
 
55
53
  export const storyNameMutated = (storyId: string, newStoryName: string): any => {
56
54
  return (dispatch, getStore) => {
57
- const {
58
- access,
59
- routing: {
60
- locationBeforeTransitions: { query }
61
- }
62
- } = getStore();
63
- const orgId: string = query.organization_id;
55
+ const { access } = getStore();
64
56
 
65
- const accessData: any = {
66
- ...access,
67
- organizations: access.organizations.map((o: any) => {
68
- if (o.id === orgId) {
69
- return {
70
- ...o,
71
- stories: o.stories.map((s: any) => {
72
- if (s.id === storyId) {
73
- return { ...s, name: newStoryName };
74
- }
57
+ const orgId = getOrgIdFromStory(storyId, access);
58
+ if (orgId) {
59
+ const accessData: any = {
60
+ ...access,
61
+ organizations: access.organizations.map((o: any) => {
62
+ if (o.id === orgId) {
63
+ return {
64
+ ...o,
65
+ stories: o.stories.map((s: any) => {
66
+ if (s.id === storyId) {
67
+ return { ...s, name: newStoryName };
68
+ }
75
69
 
76
- return s;
77
- })
78
- };
79
- }
70
+ return s;
71
+ })
72
+ };
73
+ }
80
74
 
81
- return o;
82
- })
83
- };
84
- dispatch({ type: actions.STORY_NAME_MUTATION, accessData });
75
+ return o;
76
+ })
77
+ };
78
+ dispatch({ type: actions.STORY_NAME_MUTATION, accessData });
79
+ }
85
80
  };
86
81
  };
87
82
 
88
83
  export const storyDeleted = (storyId: string): any => {
89
84
  return (dispatch, getStore) => {
90
- const {
91
- access,
92
- routing: {
93
- locationBeforeTransitions: { query }
94
- }
95
- } = getStore();
96
- const orgId: string = query.organization_id;
85
+ const { access } = getStore();
97
86
 
98
- const accessData: any = {
99
- ...access,
100
- organizations: access.organizations.map((o: any) => {
101
- if (o.id === orgId) {
102
- return {
103
- ...o,
104
- stories: o.stories.filter((s: any) => s.id !== storyId)
105
- };
106
- }
87
+ const orgId = getOrgIdFromStory(storyId, access);
88
+ if (orgId) {
89
+ const accessData: any = {
90
+ ...access,
91
+ organizations: access.organizations.map((o: any) => {
92
+ if (o.id === orgId) {
93
+ return {
94
+ ...o,
95
+ stories: o.stories.filter((s: any) => s.id !== storyId)
96
+ };
97
+ }
107
98
 
108
- return o;
109
- })
110
- };
111
- dispatch({ type: actions.STORY_DELETED, accessData });
99
+ return o;
100
+ })
101
+ };
102
+ dispatch({ type: actions.STORY_DELETED, accessData });
103
+ }
112
104
  };
113
105
  };
114
106
 
@@ -150,6 +150,10 @@ export interface IImposiumAPI {
150
150
  cacheActiveStory(serviceId: any, orgId: string, storyId: string);
151
151
  getCachedStoryForOrg(serviceId: string, orgId: string);
152
152
  getAccessData(includeTotalRenders?: boolean, orgId?: string);
153
+ deleteExperience(experienceId: string, eraseMedia?: boolean);
154
+ exportExperiences(experienceId: string, params: any);
155
+ addOrReplaceNote(experienceId: string, notes: string);
156
+ updateModerationStatus(experienceId: string, status: string, reason?: string);
153
157
  }
154
158
 
155
159
  interface ITTSOptions {
@@ -1,31 +1,8 @@
1
- /**
2
- * [initPendo description]
3
- * This initalizes the Pendo Help system in the application
4
- * The Pendo script should be added to the DOM in `index.html`
5
- * This function takes the user object and sets some initial information on Pendo for tracking
6
- * For full documentation of Pendo object please see Pendo Docs
7
- *
8
- * To prevent application breaking things, we wrap both groups in a try/catch
9
- * This allows our Application to work regardless of the status of Pendo
10
- * *************************************************************
11
- * We DO NOT WANT TO BREAK OUR APP if a 3rd party script fails
12
- * *************************************************************
13
- *
14
- * @param {object} userInfo User object from crm/v1/user
15
- * Each application's `user/` endpoint returns slightly different data
16
- * The `visitor` object will need to be adjusted based on the data returned
17
- * We should always have access to:
18
- * id
19
- * email
20
- * full_name
21
- *
22
- * @return {undefined} Nothing
23
- */
24
-
1
+ import { User } from '@auth0/auth0-react';
25
2
  declare const pendo;
26
3
 
27
- export const initPendo = (environment, userInfo) => {
28
- if (/dev/gi.test(environment)) {
4
+ export const initPendo = (appLabel, environment, userInfo: User) => {
5
+ if (environment !== 'production') {
29
6
  console.info(
30
7
  '%cPendo%c is %cdisabled%c for local testing',
31
8
  'color: #e247e5; font-weight:bold;',
@@ -39,7 +16,7 @@ export const initPendo = (environment, userInfo) => {
39
16
  try {
40
17
  const visitor = {
41
18
  id: userInfo.sub,
42
- email: userInfo['https://imposium.com/email']
19
+ email: userInfo.email
43
20
  };
44
21
 
45
22
  /* eslint-disable no-undef */
@@ -47,7 +24,7 @@ export const initPendo = (environment, userInfo) => {
47
24
  visitor: {
48
25
  ...visitor,
49
26
  environment,
50
- product: 'Imposium Project Editor',
27
+ product: appLabel,
51
28
  language: navigator.language
52
29
  }
53
30
  });