@commercetools-frontend-extensions/export-resources-modal 4.6.11 → 4.6.12

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.
@@ -43,7 +43,6 @@ var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-arr
43
43
  var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
44
44
  var _sortInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/sort');
45
45
  var _indexOfInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/index-of');
46
- var moment = require('moment');
47
46
  var actionsGlobal = require('@commercetools-frontend/actions-global');
48
47
  var constants = require('@commercetools-frontend/constants');
49
48
  var sdk = require('@commercetools-frontend/sdk');
@@ -87,7 +86,6 @@ var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
87
86
  var _Set__default = /*#__PURE__*/_interopDefault(_Set);
88
87
  var _sortInstanceProperty__default = /*#__PURE__*/_interopDefault(_sortInstanceProperty);
89
88
  var _indexOfInstanceProperty__default = /*#__PURE__*/_interopDefault(_indexOfInstanceProperty);
90
- var moment__default = /*#__PURE__*/_interopDefault(moment);
91
89
  var sortBy__default = /*#__PURE__*/_interopDefault(sortBy);
92
90
  var _styled__default = /*#__PURE__*/_interopDefault(_styled);
93
91
  var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
@@ -670,8 +668,26 @@ function validate(_ref) {
670
668
  return omitEmpty__default["default"](errors);
671
669
  }
672
670
 
673
- function resourceTypeToFileName(resourceType) {
674
- const todayFormatted = moment__default["default"]().format('DD-MM-YY_HH-mm');
671
+ function resourceTypeToFileName(resourceType, locale) {
672
+ var _context;
673
+ const date = new Date();
674
+ const dateFormatter = new Intl.DateTimeFormat(locale, {
675
+ year: '2-digit',
676
+ month: '2-digit',
677
+ day: '2-digit',
678
+ hour: '2-digit',
679
+ minute: '2-digit',
680
+ hour12: false
681
+ });
682
+ const parts = dateFormatter.formatToParts(date);
683
+ const dateParts = _reduceInstanceProperty__default["default"](parts).call(parts, (acc, part) => {
684
+ if (part.type !== 'literal') {
685
+ acc[part.type] = part.value;
686
+ }
687
+ return acc;
688
+ }, {});
689
+ const orderedDateParts = _mapInstanceProperty__default["default"](_context = _filterInstanceProperty__default["default"](parts).call(parts, part => part.type === 'day' || part.type === 'month' || part.type === 'year')).call(_context, part => dateParts[part.type]).join('-');
690
+ const formattedDate = `${orderedDateParts}_${dateParts.hour}-${dateParts.minute}`;
675
691
  const resourceTypeMap = {
676
692
  [EXPORTABLE_RESOURCES.CATEGORY]: 'Categories',
677
693
  [EXPORTABLE_RESOURCES.PRODUCT]: 'Products',
@@ -685,7 +701,7 @@ function resourceTypeToFileName(resourceType) {
685
701
  if (!displayName) {
686
702
  throw new UnexpectedResourceTypeError(resourceType);
687
703
  }
688
- return `${displayName}_Export_${todayFormatted}`;
704
+ return `${displayName}_Export_${formattedDate}`;
689
705
  }
690
706
  function mapLocalesToOptions(locales) {
691
707
  return _mapInstanceProperty__default["default"](locales).call(locales, locale => ({
@@ -889,9 +905,11 @@ const updateFieldDependenciesStatus = formik => {
889
905
  const useInitialValues = props => {
890
906
  var _context;
891
907
  const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => ({
892
- locale: applicationContext.dataLocale
908
+ locale: applicationContext.dataLocale,
909
+ userLocale: applicationContext.user?.locale
893
910
  })),
894
- locale = _useApplicationContex.locale;
911
+ locale = _useApplicationContex.locale,
912
+ userLocale = _useApplicationContex.userLocale;
895
913
  const _useApplicationContex2 = applicationShellConnectors.useApplicationContext(context => ({
896
914
  projectKey: context.project?.key
897
915
  })),
@@ -912,11 +930,11 @@ const useInitialValues = props => {
912
930
  groups = updateFieldGroupsWithIsExpandedValue(groups, cachedExpandedGroups[props.resourceType] || {});
913
931
  return {
914
932
  outputFormat: props.outputFormat,
915
- fileName: `${resourceTypeToFileName(props.resourceType)}`,
933
+ fileName: `${resourceTypeToFileName(props.resourceType, userLocale)}`,
916
934
  locales: [locale],
917
935
  groups: updateFieldGroupWithAdditionalFieldExtensions(groups)
918
936
  };
919
- }, [props.fieldGroups, props.resourceType, props.outputFormat, cachedSelectedGroups, cachedExpandedGroups, locale]);
937
+ }, [props.fieldGroups, props.resourceType, props.outputFormat, cachedSelectedGroups, cachedExpandedGroups, locale, userLocale]);
920
938
  };
921
939
 
922
940
  async function createExportOperation(_ref, asyncDispatchFn) {
@@ -43,7 +43,6 @@ var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-arr
43
43
  var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
44
44
  var _sortInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/sort');
45
45
  var _indexOfInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/index-of');
46
- var moment = require('moment');
47
46
  var actionsGlobal = require('@commercetools-frontend/actions-global');
48
47
  var constants = require('@commercetools-frontend/constants');
49
48
  var sdk = require('@commercetools-frontend/sdk');
@@ -87,7 +86,6 @@ var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
87
86
  var _Set__default = /*#__PURE__*/_interopDefault(_Set);
88
87
  var _sortInstanceProperty__default = /*#__PURE__*/_interopDefault(_sortInstanceProperty);
89
88
  var _indexOfInstanceProperty__default = /*#__PURE__*/_interopDefault(_indexOfInstanceProperty);
90
- var moment__default = /*#__PURE__*/_interopDefault(moment);
91
89
  var sortBy__default = /*#__PURE__*/_interopDefault(sortBy);
92
90
  var _styled__default = /*#__PURE__*/_interopDefault(_styled);
93
91
  var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
@@ -670,8 +668,26 @@ function validate(_ref) {
670
668
  return omitEmpty__default["default"](errors);
671
669
  }
672
670
 
673
- function resourceTypeToFileName(resourceType) {
674
- const todayFormatted = moment__default["default"]().format('DD-MM-YY_HH-mm');
671
+ function resourceTypeToFileName(resourceType, locale) {
672
+ var _context;
673
+ const date = new Date();
674
+ const dateFormatter = new Intl.DateTimeFormat(locale, {
675
+ year: '2-digit',
676
+ month: '2-digit',
677
+ day: '2-digit',
678
+ hour: '2-digit',
679
+ minute: '2-digit',
680
+ hour12: false
681
+ });
682
+ const parts = dateFormatter.formatToParts(date);
683
+ const dateParts = _reduceInstanceProperty__default["default"](parts).call(parts, (acc, part) => {
684
+ if (part.type !== 'literal') {
685
+ acc[part.type] = part.value;
686
+ }
687
+ return acc;
688
+ }, {});
689
+ const orderedDateParts = _mapInstanceProperty__default["default"](_context = _filterInstanceProperty__default["default"](parts).call(parts, part => part.type === 'day' || part.type === 'month' || part.type === 'year')).call(_context, part => dateParts[part.type]).join('-');
690
+ const formattedDate = `${orderedDateParts}_${dateParts.hour}-${dateParts.minute}`;
675
691
  const resourceTypeMap = {
676
692
  [EXPORTABLE_RESOURCES.CATEGORY]: 'Categories',
677
693
  [EXPORTABLE_RESOURCES.PRODUCT]: 'Products',
@@ -685,7 +701,7 @@ function resourceTypeToFileName(resourceType) {
685
701
  if (!displayName) {
686
702
  throw new UnexpectedResourceTypeError(resourceType);
687
703
  }
688
- return `${displayName}_Export_${todayFormatted}`;
704
+ return `${displayName}_Export_${formattedDate}`;
689
705
  }
690
706
  function mapLocalesToOptions(locales) {
691
707
  return _mapInstanceProperty__default["default"](locales).call(locales, locale => ({
@@ -889,9 +905,11 @@ const updateFieldDependenciesStatus = formik => {
889
905
  const useInitialValues = props => {
890
906
  var _context;
891
907
  const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => ({
892
- locale: applicationContext.dataLocale
908
+ locale: applicationContext.dataLocale,
909
+ userLocale: applicationContext.user?.locale
893
910
  })),
894
- locale = _useApplicationContex.locale;
911
+ locale = _useApplicationContex.locale,
912
+ userLocale = _useApplicationContex.userLocale;
895
913
  const _useApplicationContex2 = applicationShellConnectors.useApplicationContext(context => ({
896
914
  projectKey: context.project?.key
897
915
  })),
@@ -912,11 +930,11 @@ const useInitialValues = props => {
912
930
  groups = updateFieldGroupsWithIsExpandedValue(groups, cachedExpandedGroups[props.resourceType] || {});
913
931
  return {
914
932
  outputFormat: props.outputFormat,
915
- fileName: `${resourceTypeToFileName(props.resourceType)}`,
933
+ fileName: `${resourceTypeToFileName(props.resourceType, userLocale)}`,
916
934
  locales: [locale],
917
935
  groups: updateFieldGroupWithAdditionalFieldExtensions(groups)
918
936
  };
919
- }, [props.fieldGroups, props.resourceType, props.outputFormat, cachedSelectedGroups, cachedExpandedGroups, locale]);
937
+ }, [props.fieldGroups, props.resourceType, props.outputFormat, cachedSelectedGroups, cachedExpandedGroups, locale, userLocale]);
920
938
  };
921
939
 
922
940
  async function createExportOperation(_ref, asyncDispatchFn) {
@@ -39,7 +39,6 @@ import _Array$isArray from '@babel/runtime-corejs3/core-js-stable/array/is-array
39
39
  import _Set from '@babel/runtime-corejs3/core-js-stable/set';
40
40
  import _sortInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/sort';
41
41
  import _indexOfInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/index-of';
42
- import moment from 'moment';
43
42
  import { useShowNotification } from '@commercetools-frontend/actions-global';
44
43
  import { MC_API_PROXY_TARGETS, DOMAINS } from '@commercetools-frontend/constants';
45
44
  import { actions, useAsyncDispatch } from '@commercetools-frontend/sdk';
@@ -631,8 +630,26 @@ function validate(_ref) {
631
630
  return omitEmpty(errors);
632
631
  }
633
632
 
634
- function resourceTypeToFileName(resourceType) {
635
- const todayFormatted = moment().format('DD-MM-YY_HH-mm');
633
+ function resourceTypeToFileName(resourceType, locale) {
634
+ var _context;
635
+ const date = new Date();
636
+ const dateFormatter = new Intl.DateTimeFormat(locale, {
637
+ year: '2-digit',
638
+ month: '2-digit',
639
+ day: '2-digit',
640
+ hour: '2-digit',
641
+ minute: '2-digit',
642
+ hour12: false
643
+ });
644
+ const parts = dateFormatter.formatToParts(date);
645
+ const dateParts = _reduceInstanceProperty(parts).call(parts, (acc, part) => {
646
+ if (part.type !== 'literal') {
647
+ acc[part.type] = part.value;
648
+ }
649
+ return acc;
650
+ }, {});
651
+ const orderedDateParts = _mapInstanceProperty(_context = _filterInstanceProperty(parts).call(parts, part => part.type === 'day' || part.type === 'month' || part.type === 'year')).call(_context, part => dateParts[part.type]).join('-');
652
+ const formattedDate = `${orderedDateParts}_${dateParts.hour}-${dateParts.minute}`;
636
653
  const resourceTypeMap = {
637
654
  [EXPORTABLE_RESOURCES.CATEGORY]: 'Categories',
638
655
  [EXPORTABLE_RESOURCES.PRODUCT]: 'Products',
@@ -646,7 +663,7 @@ function resourceTypeToFileName(resourceType) {
646
663
  if (!displayName) {
647
664
  throw new UnexpectedResourceTypeError(resourceType);
648
665
  }
649
- return `${displayName}_Export_${todayFormatted}`;
666
+ return `${displayName}_Export_${formattedDate}`;
650
667
  }
651
668
  function mapLocalesToOptions(locales) {
652
669
  return _mapInstanceProperty(locales).call(locales, locale => ({
@@ -850,9 +867,11 @@ const updateFieldDependenciesStatus = formik => {
850
867
  const useInitialValues = props => {
851
868
  var _context;
852
869
  const _useApplicationContex = useApplicationContext(applicationContext => ({
853
- locale: applicationContext.dataLocale
870
+ locale: applicationContext.dataLocale,
871
+ userLocale: applicationContext.user?.locale
854
872
  })),
855
- locale = _useApplicationContex.locale;
873
+ locale = _useApplicationContex.locale,
874
+ userLocale = _useApplicationContex.userLocale;
856
875
  const _useApplicationContex2 = useApplicationContext(context => ({
857
876
  projectKey: context.project?.key
858
877
  })),
@@ -873,11 +892,11 @@ const useInitialValues = props => {
873
892
  groups = updateFieldGroupsWithIsExpandedValue(groups, cachedExpandedGroups[props.resourceType] || {});
874
893
  return {
875
894
  outputFormat: props.outputFormat,
876
- fileName: `${resourceTypeToFileName(props.resourceType)}`,
895
+ fileName: `${resourceTypeToFileName(props.resourceType, userLocale)}`,
877
896
  locales: [locale],
878
897
  groups: updateFieldGroupWithAdditionalFieldExtensions(groups)
879
898
  };
880
- }, [props.fieldGroups, props.resourceType, props.outputFormat, cachedSelectedGroups, cachedExpandedGroups, locale]);
899
+ }, [props.fieldGroups, props.resourceType, props.outputFormat, cachedSelectedGroups, cachedExpandedGroups, locale, userLocale]);
881
900
  };
882
901
 
883
902
  async function createExportOperation(_ref, asyncDispatchFn) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-frontend-extensions/export-resources-modal",
3
3
  "description": "Shared export modal for exporting resources",
4
- "version": "4.6.11",
4
+ "version": "4.6.12",
5
5
  "license": "BSD-3-Clause",
6
6
  "publishConfig": {
7
7
  "access": "public"