@configuratorware/configurator-frontendgui 1.29.2 → 1.30.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.
Files changed (33) hide show
  1. package/App/Modules/Creator/Components/Option/index.js +2 -2
  2. package/App/Modules/Creator/Components/Optiondetail/index.js +9 -6
  3. package/App/Modules/Creator/Components/OptionsList/index.js +54 -28
  4. package/App/Modules/Designer/Components/ImageColorPicker/ImageColorPicker.js +5 -6
  5. package/App/Modules/Designer/Components/ImageEditDialog/ImageThumbnail.js +1 -1
  6. package/App/Modules/Designer/Components/ImageEditDialog/index.js +3 -1
  7. package/App/Modules/Designer/Containers/ImageEditDialog.js +163 -113
  8. package/App/Modules/Designer/Utils/SvgFixers.js +59 -0
  9. package/App/Modules/Designer/Utils/Transformers.js +17 -10
  10. package/App/Reducers/ImageGallery/Selectors.js +6 -3
  11. package/App/Services/AnalyticsService.js +13 -64
  12. package/App/Services/ConfiguratorService.js +4 -2
  13. package/App/Services/DesignDataService.js +125 -138
  14. package/App/configuration.js +1 -1
  15. package/package.json +4 -4
  16. package/src/App/Modules/Creator/Components/Option/__snapshots__/index.test.js.snap +2 -2
  17. package/src/App/Modules/Creator/Components/Option/index.js +12 -2
  18. package/src/App/Modules/Creator/Components/Optiondetail/__snapshots__/index.test.js.snap +3 -3
  19. package/src/App/Modules/Creator/Components/Optiondetail/index.js +15 -13
  20. package/src/App/Modules/Creator/Components/OptionsList/index.js +46 -32
  21. package/src/App/Modules/Designer/Components/ImageColorPicker/ImageColorPicker.js +5 -6
  22. package/src/App/Modules/Designer/Components/ImageEditDialog/ImageThumbnail.js +1 -1
  23. package/src/App/Modules/Designer/Components/ImageEditDialog/index.js +3 -1
  24. package/src/App/Modules/Designer/Containers/ImageEditDialog.js +36 -12
  25. package/src/App/Modules/Designer/Utils/SvgFixers.js +36 -0
  26. package/src/App/Modules/Designer/Utils/Transformers.js +6 -3
  27. package/src/App/Modules/Designer/Utils/__tests__/Transformers.test.js +2 -2
  28. package/src/App/Reducers/ImageGallery/Selectors.js +5 -3
  29. package/src/App/Services/AnalyticsService.js +7 -20
  30. package/src/App/Services/ConfiguratorService.js +3 -2
  31. package/src/App/Services/DesignDataService.js +39 -24
  32. package/src/App/Services/__tests__/AnalyticsService.test.js +24 -37
  33. package/src/App/configuration.js +1 -1
@@ -373,16 +373,18 @@ export const makeOperationsCompatible = (operations, compatibilityInfo, colorPal
373
373
 
374
374
  export const getSvgContent = (() => {
375
375
  const svgContentMap = new Map();
376
- return async function getSvgContent(url, absolute = false, forceFetch = false) {
376
+ return function getSvgContent(url, absolute = false, forceFetch = false) {
377
377
  const absUrl = absolute ? url : `${getConf('network.host')}${url}`;
378
378
  if (!forceFetch && svgContentMap.has(absUrl)) {
379
379
  return svgContentMap.get(absUrl);
380
380
  }
381
381
  try {
382
- const result = await axios.get(absUrl);
383
- const svgContent = initDefaultColor(result.data);
384
- svgContentMap.set(absUrl, svgContent);
385
- return svgContent;
382
+ const promise = (async function() {
383
+ const result = await axios.get(absUrl);
384
+ return initDefaultColor(result.data);
385
+ })();
386
+ svgContentMap.set(absUrl, promise);
387
+ return promise;
386
388
  } catch (e) {
387
389
  return '';
388
390
  }
@@ -1042,12 +1044,18 @@ export default class DesignDataService {
1042
1044
  );
1043
1045
 
1044
1046
  const designArea = getSelectedDesignArea(state);
1045
- const images = getImagesByDesignArea(state, designArea.identifier);
1047
+ const nonVectorizedImages = getImagesByDesignArea(state, designArea.identifier).filter(
1048
+ obj => !get(obj, 'imageData.operations.vectorize')
1049
+ );
1046
1050
 
1047
1051
  if (
1048
- images.length === 1 &&
1052
+ nonVectorizedImages.length === 1 &&
1049
1053
  ((!currentVectorsRequired && newVectorsRequired) ||
1050
- !isColorPreviewCompatible(state, images[0].imageData, designProductionMethodIdentifier))
1054
+ !isColorPreviewCompatible(
1055
+ state,
1056
+ nonVectorizedImages[0].imageData,
1057
+ designProductionMethodIdentifier
1058
+ ))
1051
1059
  ) {
1052
1060
  await Services.store.dispatch(showSwitchToProductionMethodWithVectorization());
1053
1061
  return true;
@@ -1083,7 +1091,7 @@ export default class DesignDataService {
1083
1091
  }
1084
1092
 
1085
1093
  return (
1086
- !isEditableVectorImage(obj.imageData.preview) ||
1094
+ !get(obj, 'imageData.operations.vectorize') ||
1087
1095
  !isColorPreviewCompatible(state, obj.imageData, designProductionMethodIdentifier)
1088
1096
  );
1089
1097
  })
@@ -1183,12 +1191,14 @@ export default class DesignDataService {
1183
1191
  const state = Services.store.state;
1184
1192
  const designArea = getSelectedDesignArea(state);
1185
1193
  const canvas = this._getCanvas(designArea);
1186
- const images = getImagesByDesignArea(state, designArea.identifier);
1194
+ const firstNonVectorizedImage = getImagesByDesignArea(state, designArea.identifier).find(
1195
+ obj => !get(obj, 'imageData.operations.vectorize')
1196
+ );
1187
1197
  const operations = {
1188
- ...images[0].imageData.operations,
1198
+ ...firstNonVectorizedImage.imageData.operations,
1189
1199
  vectorize: true,
1190
1200
  };
1191
- const imageData = images[0].imageData;
1201
+ const imageData = firstNonVectorizedImage.imageData;
1192
1202
 
1193
1203
  try {
1194
1204
  //returing if placeHolderImage, from executing edit operations
@@ -1202,10 +1212,14 @@ export default class DesignDataService {
1202
1212
  .find(obj => obj._imageData.identifier === imageData.identifier);
1203
1213
  imageToSelect.selected = true;
1204
1214
 
1205
- await Services.designer.openImageEditDialog(images[0].imageData.identifier, canvas, {
1206
- placeholderImageUpdate: false,
1207
- submitOnExitClick: true,
1208
- });
1215
+ await Services.designer.openImageEditDialog(
1216
+ firstNonVectorizedImage.imageData.identifier,
1217
+ canvas,
1218
+ {
1219
+ placeholderImageUpdate: false,
1220
+ submitOnExitClick: true,
1221
+ }
1222
+ );
1209
1223
  } finally {
1210
1224
  Services.ui.hide('globalLoader');
1211
1225
  }
@@ -1875,8 +1889,8 @@ export default class DesignDataService {
1875
1889
 
1876
1890
  const isBackendNeeded = createCopy || !isEqual(editData, currentEditData);
1877
1891
 
1878
- isBackendNeeded &&
1879
- (await Services.store.dispatch(
1892
+ if (isBackendNeeded) {
1893
+ await Services.store.dispatch(
1880
1894
  editImage(
1881
1895
  {
1882
1896
  ...editData,
@@ -1890,12 +1904,13 @@ export default class DesignDataService {
1890
1904
  },
1891
1905
  { immediateCommit }
1892
1906
  )
1893
- ));
1894
- const {
1895
- imageGallery: { selectedImage },
1896
- } = Services.store.state;
1897
- preview = get(selectedImage, 'preview');
1898
- imageIdentifier = get(selectedImage, 'identifier');
1907
+ );
1908
+ const {
1909
+ imageGallery: { selectedImage },
1910
+ } = Services.store.state;
1911
+ preview = get(selectedImage, 'preview');
1912
+ imageIdentifier = get(selectedImage, 'identifier');
1913
+ }
1899
1914
  }
1900
1915
  }
1901
1916
 
@@ -23,16 +23,33 @@ describe('Services/AnalyticsService', () => {
23
23
  dispatch = jest.fn();
24
24
  }
25
25
 
26
+ class ConfiguratorService {
27
+ static serviceName = 'ConfiguratorService';
28
+
29
+ state = {
30
+ loadIdentifier: 'softshell_creator_2d',
31
+ };
32
+ }
33
+
26
34
  // add the mock services
27
- const storeSrvc = new StoreService();
28
- ServiceLocator.provide(storeSrvc);
35
+ ServiceLocator.provide(new StoreService());
36
+ ServiceLocator.provide(new ConfiguratorService());
37
+
38
+ const mockDataLayer = {
39
+ push: jest.fn(),
40
+ };
29
41
 
30
- test('Event load_request dispatches the correct action', () => {
42
+ test('Event load_request pushes the correct ga data to the dataLayer', () => {
31
43
  const analyticsSrvc = new AnalyticsService();
32
- analyticsSrvc.triggerEvent(EventTypes.load_request, {});
33
- expect(storeSrvc.dispatch).toBeCalledWith({
34
- type: 'header_load_configuration_request',
35
- data: {},
44
+ analyticsSrvc.setDataLayer(mockDataLayer);
45
+ analyticsSrvc.triggerEvent(EventTypes.load_request, 'softshell_designer_2d');
46
+ expect(mockDataLayer.push).toHaveBeenNthCalledWith(1, {
47
+ event: 'load_item',
48
+ item_identifier: 'softshell_creator_2d',
49
+ });
50
+ expect(mockDataLayer.push).toHaveBeenNthCalledWith(2, {
51
+ event: 'header_load_configuration_request',
52
+ configuration_code: 'softshell_designer_2d',
36
53
  });
37
54
  });
38
55
 
@@ -122,34 +139,4 @@ describe('Services/AnalyticsService', () => {
122
139
  };
123
140
  expect(result).toEqual(expected);
124
141
  });
125
-
126
- test('createMiddleware should return next action', () => {
127
- const store = {
128
- getState: jest.fn(() => ({})),
129
- dispatch: jest.fn(),
130
- };
131
- const analyticsSrvc = new AnalyticsService();
132
- const next = jest.fn(v => v);
133
- const action = { type: 'test_action' };
134
- const dataLayer = [];
135
-
136
- const result = analyticsSrvc.createMiddleware(dataLayer)(store)(next)(action);
137
-
138
- expect(result).toEqual(action);
139
- });
140
-
141
- test('action should be pushed into DataLayer if it is in trackList ', () => {
142
- const store = {
143
- getState: jest.fn(() => ({})),
144
- dispatch: jest.fn(),
145
- };
146
- const analyticsSrvc = new AnalyticsService();
147
- const next = jest.fn(v => v);
148
- const action = { type: 'preview_open' };
149
- const dataLayer = [];
150
-
151
- analyticsSrvc.createMiddleware(dataLayer)(store)(next)(action);
152
-
153
- expect(dataLayer.length).toBe(1);
154
- });
155
142
  });
@@ -13,7 +13,7 @@ const DEVELOPMENT_HOST_LOCAL = 'http://localhost:10030';
13
13
 
14
14
  const hostsByNodeEnv = {
15
15
  production: '',
16
- development: DEVELOPMENT_HOST_INT,
16
+ development: DEVELOPMENT_HOST_LOCAL,
17
17
  test: '',
18
18
  };
19
19