@imposium-hub/components 1.39.1 → 1.41.0
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/Entry.ts +11 -2
- package/components/assets/AssetsUploadMenu.tsx +24 -5
- package/components/publish-wizard/PublishWizard.tsx +477 -0
- package/components/publish-wizard/publish/APIIntegration.tsx +28 -0
- package/components/publish-wizard/publish/EmailWorkflow.tsx +255 -0
- package/components/publish-wizard/publish/HubSpotFlow.tsx +80 -0
- package/components/publish-wizard/publish/PublishStatusIndicator.tsx +84 -0
- package/components/publish-wizard/publish/WebpageHosted.tsx +120 -0
- package/constants/copy.ts +100 -0
- package/constants/icons.tsx +21 -0
- package/dist/components.js +2 -2
- package/dist/components.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.css.map +1 -1
- package/dist/styles.less +145 -12
- package/dist/styles.less.map +1 -1
- package/less/components/assets.less +7 -0
- package/less/components/publish-status-indicator.less +22 -0
- package/less/components/publish-wizard.less +101 -0
- package/less/components/section.less +13 -12
- package/less/styles.less +2 -0
- package/package.json +4 -1
- package/redux/actions/asset-uploads.ts +19 -6
- package/redux/actions/publish.ts +84 -0
- package/redux/reducers/publish.ts +36 -0
- package/services/API.ts +29 -6
- package/utils/routing.ts +12 -0
- package/utils/template-generator.ts +32 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
|
|
2
|
+
import * as copy from '../../constants/copy';
|
|
3
|
+
import { IImposiumAPI } from '../../services/API';
|
|
4
|
+
|
|
5
|
+
const publish : any = {
|
|
6
|
+
CLEAR_PUBLISH_STATUS: 'publish/CLEAR_PUBLISH_STATUS',
|
|
7
|
+
UPDATE_PUBLISH_STATUS: 'publish/UPDATE_PUBLISH_STATUS'
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const getStoryPublishStatus = (api : IImposiumAPI , storyId : string) : any => {
|
|
11
|
+
|
|
12
|
+
return (dispatch) => {
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
api.getStoryStatus(storyId).then((resStatus) => {
|
|
15
|
+
|
|
16
|
+
if (resStatus) {
|
|
17
|
+
|
|
18
|
+
dispatch({type: publish.UPDATE_PUBLISH_STATUS, data: resStatus});
|
|
19
|
+
|
|
20
|
+
if (resStatus.publishing) {
|
|
21
|
+
|
|
22
|
+
const jobId = resStatus.job_id;
|
|
23
|
+
api.pollJob(jobId).then(() => {
|
|
24
|
+
return dispatch(getStoryPublishStatus(api, storyId));
|
|
25
|
+
|
|
26
|
+
// Error polling job
|
|
27
|
+
}).catch((e) => {
|
|
28
|
+
console.error(e);
|
|
29
|
+
reject(copy.header.publishPollError);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}).catch((e) => {
|
|
35
|
+
|
|
36
|
+
// 404 = no published version = using working copy
|
|
37
|
+
if (e?.response?.status !== 404) {
|
|
38
|
+
console.error(e);
|
|
39
|
+
reject(copy.header.publishPollError);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const cancelPublish = (api : IImposiumAPI, storyId : string) => {
|
|
47
|
+
return (dispatch) => {
|
|
48
|
+
return new Promise((resolve, reject) => {
|
|
49
|
+
api.cancelPublish(storyId).then(() => {
|
|
50
|
+
api.cancelJobPolling().then(() => {
|
|
51
|
+
dispatch(getStoryPublishStatus(api, storyId));
|
|
52
|
+
}).catch((e) => {
|
|
53
|
+
reject(e);
|
|
54
|
+
throw e;
|
|
55
|
+
});
|
|
56
|
+
}).catch((e) => {
|
|
57
|
+
reject(e);
|
|
58
|
+
throw e;
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const publishVersion = (api : IImposiumAPI, storyId : string) => {
|
|
66
|
+
return (dispatch) => {
|
|
67
|
+
return new Promise((resolve, reject) => {
|
|
68
|
+
api.runPublish(storyId, '').then((d) => {
|
|
69
|
+
dispatch(getStoryPublishStatus(api, storyId));
|
|
70
|
+
}).catch(() => {
|
|
71
|
+
reject(copy.header.publishJobError);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const clearStoryPublishStatus = (api : IImposiumAPI) => {
|
|
78
|
+
return (dispatch) => {
|
|
79
|
+
api.cancelJobPolling();
|
|
80
|
+
dispatch({type: publish.CLEAR_PUBLISH_STATUS});
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export default publish;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import actions from '../actions/publish';
|
|
2
|
+
|
|
3
|
+
export interface IChanges {
|
|
4
|
+
date_created? : number;
|
|
5
|
+
id? : string;
|
|
6
|
+
job_id? : string;
|
|
7
|
+
message? : string;
|
|
8
|
+
publishing : boolean;
|
|
9
|
+
story_id? : string;
|
|
10
|
+
version ? : number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const initialState : IChanges = {
|
|
14
|
+
publishing: false
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const publish = (state = initialState, action) : any => {
|
|
18
|
+
|
|
19
|
+
let newState : IChanges;
|
|
20
|
+
|
|
21
|
+
switch (action.type) {
|
|
22
|
+
|
|
23
|
+
case actions.UPDATE_PUBLISH_STATUS:
|
|
24
|
+
|
|
25
|
+
newState = {...state, ...action.data};
|
|
26
|
+
return newState;
|
|
27
|
+
|
|
28
|
+
case actions.CLEAR_PUBLISH_STATUS:
|
|
29
|
+
return initialState;
|
|
30
|
+
|
|
31
|
+
default:
|
|
32
|
+
return state;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default publish;
|
package/services/API.ts
CHANGED
|
@@ -10,6 +10,7 @@ export interface IImposiumAPI {
|
|
|
10
10
|
getAssets(filters : any, storyId : string);
|
|
11
11
|
getAssetItem(assetId : string);
|
|
12
12
|
uploadAsset(storyId : string, tags : string, file : File);
|
|
13
|
+
cancelUploadAssets();
|
|
13
14
|
deleteAsset(assetId : string);
|
|
14
15
|
deleteAssets(assetIds : string[]);
|
|
15
16
|
copyAsset(assetId : string, data);
|
|
@@ -31,7 +32,7 @@ export interface IImposiumAPI {
|
|
|
31
32
|
getExperience(experienceId : string, poll : boolean);
|
|
32
33
|
blockByExperience(experienceId : string);
|
|
33
34
|
triggerEvent(experienceId : string, compositionId ? : string, useWorkingCopy ? : boolean);
|
|
34
|
-
getBatches(storyId : string);
|
|
35
|
+
getBatches(storyId : string, params ? : any);
|
|
35
36
|
getBatch(batchId : string, page : number);
|
|
36
37
|
getBatchProgress(batchId : string);
|
|
37
38
|
createFreshBatch(storyId : string, batchName : string);
|
|
@@ -60,6 +61,8 @@ export interface IImposiumAPI {
|
|
|
60
61
|
runReRenderCuts(storyId : string, actId : string, sceneId : string);
|
|
61
62
|
runProcessBaseVideo(storyId : string, fileKey : string);
|
|
62
63
|
runPublish(storyId : string, message : string);
|
|
64
|
+
cancelPublish(storyId : string);
|
|
65
|
+
cancelJobPolling();
|
|
63
66
|
getAccssCredentials();
|
|
64
67
|
createAccessCredentials(name : string);
|
|
65
68
|
deleteAccessCrednetials(access_key_id : string);
|
|
@@ -91,6 +94,8 @@ export default class API {
|
|
|
91
94
|
system: undefined
|
|
92
95
|
};
|
|
93
96
|
|
|
97
|
+
private cancelTokens : object = {};
|
|
98
|
+
|
|
94
99
|
constructor(baseURL : string, idToken : string, organizationId? : string) {
|
|
95
100
|
|
|
96
101
|
// JWT
|
|
@@ -130,7 +135,7 @@ export default class API {
|
|
|
130
135
|
})
|
|
131
136
|
.catch((e : AxiosError) => {
|
|
132
137
|
if (!axios.isCancel(e) && reqAlias) { this.clearCache(reqAlias); }
|
|
133
|
-
if (e.response.status === 403 || e.response.status === 401) {
|
|
138
|
+
if (e.response && (e.response.status === 403 || e.response.status === 401)) {
|
|
134
139
|
alert(copy.sessionExpired);
|
|
135
140
|
if (SessionService.getSession()) {
|
|
136
141
|
SessionService.removeSession();
|
|
@@ -329,9 +334,19 @@ export default class API {
|
|
|
329
334
|
});
|
|
330
335
|
}
|
|
331
336
|
|
|
332
|
-
|
|
333
|
-
const
|
|
337
|
+
private cancelRequest = (reqAlias : string) : CancelToken => {
|
|
338
|
+
const source : CancelTokenSource = axios.CancelToken.source();
|
|
339
|
+
this.cancelTokens[reqAlias] = source;
|
|
340
|
+
return source.token;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
private clearCancelTokes = () => {
|
|
344
|
+
this.cancelTokens = {};
|
|
345
|
+
}
|
|
334
346
|
|
|
347
|
+
public uploadAsset = (storyId : string, tags : string, file : File, onUploadProgress : (e : any) => void, fileName? : string) : Promise<any | Error> => {
|
|
348
|
+
const formData = new FormData();
|
|
349
|
+
const token = this.cancelRequest(fileName);
|
|
335
350
|
if (storyId) {
|
|
336
351
|
formData.append('story_id', storyId);
|
|
337
352
|
}
|
|
@@ -342,10 +357,18 @@ export default class API {
|
|
|
342
357
|
method: 'POST',
|
|
343
358
|
url: '/assets',
|
|
344
359
|
data: formData,
|
|
345
|
-
onUploadProgress
|
|
360
|
+
onUploadProgress,
|
|
361
|
+
cancelToken: token
|
|
346
362
|
});
|
|
347
363
|
}
|
|
348
364
|
|
|
365
|
+
public cancelUploadAssets = (alias) => {
|
|
366
|
+
const currentSource = this.cancelTokens[alias];
|
|
367
|
+
if (currentSource) {
|
|
368
|
+
currentSource.cancel();
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
349
372
|
public createCompositionAsset = (storyId : string, compositionData : any, name? : string) : Promise<any | Error> => {
|
|
350
373
|
|
|
351
374
|
const formData = new FormData();
|
|
@@ -475,7 +498,7 @@ export default class API {
|
|
|
475
498
|
});
|
|
476
499
|
}
|
|
477
500
|
|
|
478
|
-
public getBatches = (storyId : string, params : any) : Promise<any | Error> => {
|
|
501
|
+
public getBatches = (storyId : string, params ? : any) : Promise<any | Error> => {
|
|
479
502
|
return this.doRequest({
|
|
480
503
|
method: 'GET',
|
|
481
504
|
url: `/story/${storyId}/batches`,
|
package/utils/routing.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const getDemoURL = () : string => {
|
|
2
|
+
|
|
3
|
+
const {location: {href}} = window;
|
|
4
|
+
|
|
5
|
+
if (href.indexOf('localhost') !== -1) {
|
|
6
|
+
return 'http://localhost:3044';
|
|
7
|
+
} else if (href.indexOf('staging') !== -1) {
|
|
8
|
+
return 'https://demo.staging.imposium.com';
|
|
9
|
+
} else {
|
|
10
|
+
return 'https://demo.imposium.com';
|
|
11
|
+
}
|
|
12
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import axios, { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { saveAs } from 'file-saver';
|
|
3
|
+
|
|
4
|
+
export interface ISDKArchiveBody {
|
|
5
|
+
storyId : string;
|
|
6
|
+
compositionId : string;
|
|
7
|
+
accessToken : string;
|
|
8
|
+
storyName : string;
|
|
9
|
+
inventory : any;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const DEFAULT_GENERATOR_REQ_CONFIG : any = {
|
|
13
|
+
method: 'POST',
|
|
14
|
+
responseType: 'blob',
|
|
15
|
+
headers: {'Content-Type': 'application/json'}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const downloadSDKArchive = (archiveName : string, config : ISDKArchiveBody) : void => {
|
|
19
|
+
const request : AxiosRequestConfig = {
|
|
20
|
+
...DEFAULT_GENERATOR_REQ_CONFIG,
|
|
21
|
+
url: 'https://template-generator.imposium.com/sdk-archive',
|
|
22
|
+
data: JSON.stringify(config)
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
axios(request)
|
|
26
|
+
.then((res) => {
|
|
27
|
+
saveAs(res.data, archiveName);
|
|
28
|
+
})
|
|
29
|
+
.catch((e) => {
|
|
30
|
+
console.error('Failed to download sdk archive:', e);
|
|
31
|
+
});
|
|
32
|
+
};
|