@commercetools-frontend-extensions/delete-resources-modal 2.0.3 → 2.1.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.
@@ -458,12 +458,206 @@ var messages$4 = reactIntl.defineMessages({
458
458
  defaultMessage: 'Invalid CSV file'
459
459
  },
460
460
  csvFormatErrorDescription: {
461
- id: 'UnpublishProductsModal.csvFormatErrorDescription',
461
+ id: 'DeleteResourcesModal.csvFormatErrorDescription',
462
462
  description: 'Error message displayed when the CSV file is not formatted correctly',
463
- defaultMessage: "Your CSV file is not formatted correctly. Make sure the file contains only one column named 'key', which includes the product keys"
463
+ defaultMessage: "Your CSV file is not formatted correctly. Make sure the file contains only one column named 'key', which includes the {resourceType} keys"
464
464
  }
465
465
  });
466
466
 
467
+ var sharedMessages = reactIntl.defineMessages({
468
+ deleteModalTitle: {
469
+ id: 'DeleteResourcesModal.deleteModalTitle',
470
+ description: 'The title of the modal',
471
+ defaultMessage: 'Bulk delete via CSV'
472
+ },
473
+ startBulkDelete: {
474
+ id: 'DeleteResourcesModal.startBulkDelete',
475
+ description: 'Start bulk delete button',
476
+ defaultMessage: 'Start bulk delete'
477
+ },
478
+ cancel: {
479
+ id: 'DeleteResourcesModal.cancel',
480
+ description: 'The label for the cancel button',
481
+ defaultMessage: 'Cancel'
482
+ },
483
+ product: {
484
+ id: 'DeleteResourcesModal.product',
485
+ description: 'Label for the product resource type',
486
+ defaultMessage: 'product'
487
+ },
488
+ products: {
489
+ id: 'DeleteResourcesModal.products',
490
+ description: 'Plural form of product',
491
+ defaultMessage: 'products'
492
+ },
493
+ inventory: {
494
+ id: 'DeleteResourcesModal.inventory',
495
+ description: 'Label for the inventory entry resource type',
496
+ defaultMessage: 'inventory entry'
497
+ },
498
+ inventories: {
499
+ id: 'DeleteResourcesModal.inventories',
500
+ description: 'Plural form of inventory entry',
501
+ defaultMessage: 'inventory entries'
502
+ },
503
+ category: {
504
+ id: 'DeleteResourcesModal.category',
505
+ description: 'Label for the category resource type',
506
+ defaultMessage: 'category'
507
+ },
508
+ categories: {
509
+ id: 'DeleteResourcesModal.categories',
510
+ description: 'Plural form of category',
511
+ defaultMessage: 'categories'
512
+ },
513
+ customer: {
514
+ id: 'DeleteResourcesModal.customer',
515
+ description: 'Label for the customer resource type',
516
+ defaultMessage: 'customer'
517
+ },
518
+ customers: {
519
+ id: 'DeleteResourcesModal.customers',
520
+ description: 'Plural form of customer',
521
+ defaultMessage: 'customers'
522
+ },
523
+ order: {
524
+ id: 'DeleteResourcesModal.order',
525
+ description: 'Label for the order resource type',
526
+ defaultMessage: 'order'
527
+ },
528
+ orders: {
529
+ id: 'DeleteResourcesModal.orders',
530
+ description: 'Plural form of order',
531
+ defaultMessage: 'orders'
532
+ },
533
+ price: {
534
+ id: 'DeleteResourcesModal.price',
535
+ description: 'Label for the price resource type',
536
+ defaultMessage: 'price'
537
+ },
538
+ prices: {
539
+ id: 'DeleteResourcesModal.prices',
540
+ description: 'Plural form of price',
541
+ defaultMessage: 'prices'
542
+ },
543
+ 'product-draft': {
544
+ id: 'DeleteResourcesModal.product-draft',
545
+ description: 'Label for the product-draft resource type',
546
+ defaultMessage: 'product draft'
547
+ },
548
+ 'product-drafts': {
549
+ id: 'DeleteResourcesModal.product-drafts',
550
+ description: 'Plural form of product draft',
551
+ defaultMessage: 'product drafts'
552
+ },
553
+ 'product-type': {
554
+ id: 'DeleteResourcesModal.product-type',
555
+ description: 'Label for the product-type resource type',
556
+ defaultMessage: 'product type'
557
+ },
558
+ 'product-types': {
559
+ id: 'DeleteResourcesModal.product-types',
560
+ description: 'Plural form of product type',
561
+ defaultMessage: 'product types'
562
+ },
563
+ 'product-variant': {
564
+ id: 'DeleteResourcesModal.product-variant',
565
+ description: 'Label for the product-variant resource type',
566
+ defaultMessage: 'product variant'
567
+ },
568
+ 'product-variants': {
569
+ id: 'DeleteResourcesModal.product-variants',
570
+ description: 'Plural form of product variant',
571
+ defaultMessage: 'product variants'
572
+ },
573
+ 'product-variant-patch': {
574
+ id: 'DeleteResourcesModal.product-variant-patch',
575
+ description: 'Label for the product-variant-patch resource type',
576
+ defaultMessage: 'product variant patch'
577
+ },
578
+ 'product-variant-patches': {
579
+ id: 'DeleteResourcesModal.product-variant-patches',
580
+ description: 'Plural form of product variant patch',
581
+ defaultMessage: 'product variant patches'
582
+ },
583
+ 'standalone-price': {
584
+ id: 'DeleteResourcesModal.standalone-price',
585
+ description: 'Label for the standalone-price resource type',
586
+ defaultMessage: 'standalone price'
587
+ },
588
+ 'standalone-prices': {
589
+ id: 'DeleteResourcesModal.standalone-prices',
590
+ description: 'Plural form of standalone price',
591
+ defaultMessage: 'standalone prices'
592
+ },
593
+ 'discount-code': {
594
+ id: 'DeleteResourcesModal.discount-code',
595
+ description: 'Label for the discount-code resource type',
596
+ defaultMessage: 'discount code'
597
+ },
598
+ 'discount-codes': {
599
+ id: 'DeleteResourcesModal.discount-codes',
600
+ description: 'Plural form of discount code',
601
+ defaultMessage: 'discount codes'
602
+ },
603
+ unknownResourceType: {
604
+ id: 'DeleteResourcesModal.unknown-resource-type',
605
+ description: 'Label for the unknown resource type',
606
+ defaultMessage: 'unknown resource type'
607
+ }
608
+ });
609
+
610
+ function resourceTypeToMessage(resourceType) {
611
+ const resourceTypeMap = {
612
+ category: sharedMessages.category,
613
+ product: sharedMessages.product,
614
+ 'product-type': sharedMessages['product-type'],
615
+ order: sharedMessages.order,
616
+ customer: sharedMessages.customer,
617
+ 'discount-code': sharedMessages['discount-code'],
618
+ inventory: sharedMessages.inventory,
619
+ // TODO: remove `inventory` after aligning the resource type names in the file upload API
620
+ 'inventory-entry': sharedMessages.inventory,
621
+ 'order-patch': sharedMessages['order-patch'],
622
+ price: sharedMessages.price,
623
+ 'product-draft': sharedMessages['product-draft'],
624
+ 'product-variant': sharedMessages['product-variant'],
625
+ 'product-variant-patch': sharedMessages['product-variant-patch'],
626
+ 'standalone-price': sharedMessages['standalone-price']
627
+ };
628
+ const message = resourceTypeMap[resourceType];
629
+ if (!message) {
630
+ console.warn(new UnexpectedResourceTypeError(resourceType));
631
+ return sharedMessages.unknownResourceType;
632
+ }
633
+ return message;
634
+ }
635
+ function resourceTypeToPluralMessage(resourceType) {
636
+ const resourceTypePluralMap = {
637
+ category: sharedMessages.categories,
638
+ product: sharedMessages.products,
639
+ 'product-type': sharedMessages['product-types'],
640
+ order: sharedMessages.orders,
641
+ customer: sharedMessages.customers,
642
+ 'discount-code': sharedMessages['discount-codes'],
643
+ inventory: sharedMessages.inventories,
644
+ // TODO: remove `inventory` after aligning the resource type names in the file upload API
645
+ 'inventory-entry': sharedMessages.inventories,
646
+ 'order-patch': sharedMessages['order-patches'],
647
+ price: sharedMessages.prices,
648
+ 'product-draft': sharedMessages['product-drafts'],
649
+ 'product-variant': sharedMessages['product-variants'],
650
+ 'product-variant-patch': sharedMessages['product-variant-patches'],
651
+ 'standalone-price': sharedMessages['standalone-prices']
652
+ };
653
+ const message = resourceTypePluralMap[resourceType];
654
+ if (!message) {
655
+ console.warn(new UnexpectedResourceTypeError(resourceType));
656
+ return sharedMessages.unknownResourceType;
657
+ }
658
+ return message;
659
+ }
660
+
467
661
  const useUpload = () => {
468
662
  const intl = reactIntl.useIntl();
469
663
  const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
@@ -495,7 +689,9 @@ const useUpload = () => {
495
689
  if (!(await operations.hasSingleKeyColumn(file))) {
496
690
  errors.push({
497
691
  title: intl.formatMessage(messages$4.csvFormatErrorTitle),
498
- description: intl.formatMessage(messages$4.csvFormatErrorDescription)
692
+ description: intl.formatMessage(messages$4.csvFormatErrorDescription, {
693
+ resourceType: intl.formatMessage(resourceTypeToMessage(resourceType))
694
+ })
499
695
  });
500
696
  }
501
697
  if (rowCount > operations.IMPORT_MAX_ITEM_COUNT) errors.push({
@@ -687,149 +883,6 @@ const FileDropArea = () => {
687
883
  });
688
884
  };
689
885
 
690
- var sharedMessages = reactIntl.defineMessages({
691
- deleteModalTitle: {
692
- id: 'DeleteResourcesModal.deleteModalTitle',
693
- description: 'The title of the modal',
694
- defaultMessage: 'Bulk delete via CSV'
695
- },
696
- startBulkDelete: {
697
- id: 'DeleteResourcesModal.startBulkDelete',
698
- description: 'Start bulk delete button',
699
- defaultMessage: 'Start bulk delete'
700
- },
701
- cancel: {
702
- id: 'DeleteResourcesModal.cancel',
703
- description: 'The label for the cancel button',
704
- defaultMessage: 'Cancel'
705
- },
706
- product: {
707
- id: 'DeleteResourcesModal.product',
708
- description: 'Label for the product resource type',
709
- defaultMessage: 'product'
710
- },
711
- products: {
712
- id: 'DeleteResourcesModal.products',
713
- description: 'Plural form of product',
714
- defaultMessage: 'products'
715
- },
716
- inventory: {
717
- id: 'DeleteResourcesModal.inventory',
718
- description: 'Label for the inventory entry resource type',
719
- defaultMessage: 'inventory entry'
720
- },
721
- inventories: {
722
- id: 'DeleteResourcesModal.inventories',
723
- description: 'Plural form of inventory entry',
724
- defaultMessage: 'inventory entries'
725
- },
726
- category: {
727
- id: 'DeleteResourcesModal.category',
728
- description: 'Label for the category resource type',
729
- defaultMessage: 'category'
730
- },
731
- categories: {
732
- id: 'DeleteResourcesModal.categories',
733
- description: 'Plural form of category',
734
- defaultMessage: 'categories'
735
- },
736
- customer: {
737
- id: 'DeleteResourcesModal.customer',
738
- description: 'Label for the customer resource type',
739
- defaultMessage: 'customer'
740
- },
741
- customers: {
742
- id: 'DeleteResourcesModal.customers',
743
- description: 'Plural form of customer',
744
- defaultMessage: 'customers'
745
- },
746
- order: {
747
- id: 'DeleteResourcesModal.order',
748
- description: 'Label for the order resource type',
749
- defaultMessage: 'order'
750
- },
751
- orders: {
752
- id: 'DeleteResourcesModal.orders',
753
- description: 'Plural form of order',
754
- defaultMessage: 'orders'
755
- },
756
- price: {
757
- id: 'DeleteResourcesModal.price',
758
- description: 'Label for the price resource type',
759
- defaultMessage: 'price'
760
- },
761
- prices: {
762
- id: 'DeleteResourcesModal.prices',
763
- description: 'Plural form of price',
764
- defaultMessage: 'prices'
765
- },
766
- 'product-draft': {
767
- id: 'DeleteResourcesModal.product-draft',
768
- description: 'Label for the product-draft resource type',
769
- defaultMessage: 'product draft'
770
- },
771
- 'product-drafts': {
772
- id: 'DeleteResourcesModal.product-drafts',
773
- description: 'Plural form of product draft',
774
- defaultMessage: 'product drafts'
775
- },
776
- 'product-type': {
777
- id: 'DeleteResourcesModal.product-type',
778
- description: 'Label for the product-type resource type',
779
- defaultMessage: 'product type'
780
- },
781
- 'product-types': {
782
- id: 'DeleteResourcesModal.product-types',
783
- description: 'Plural form of product type',
784
- defaultMessage: 'product types'
785
- },
786
- 'product-variant': {
787
- id: 'DeleteResourcesModal.product-variant',
788
- description: 'Label for the product-variant resource type',
789
- defaultMessage: 'product variant'
790
- },
791
- 'product-variants': {
792
- id: 'DeleteResourcesModal.product-variants',
793
- description: 'Plural form of product variant',
794
- defaultMessage: 'product variants'
795
- },
796
- 'product-variant-patch': {
797
- id: 'DeleteResourcesModal.product-variant-patch',
798
- description: 'Label for the product-variant-patch resource type',
799
- defaultMessage: 'product variant patch'
800
- },
801
- 'product-variant-patches': {
802
- id: 'DeleteResourcesModal.product-variant-patches',
803
- description: 'Plural form of product variant patch',
804
- defaultMessage: 'product variant patches'
805
- },
806
- 'standalone-price': {
807
- id: 'DeleteResourcesModal.standalone-price',
808
- description: 'Label for the standalone-price resource type',
809
- defaultMessage: 'standalone price'
810
- },
811
- 'standalone-prices': {
812
- id: 'DeleteResourcesModal.standalone-prices',
813
- description: 'Plural form of standalone price',
814
- defaultMessage: 'standalone prices'
815
- },
816
- 'discount-code': {
817
- id: 'DeleteResourcesModal.discount-code',
818
- description: 'Label for the discount-code resource type',
819
- defaultMessage: 'discount code'
820
- },
821
- 'discount-codes': {
822
- id: 'DeleteResourcesModal.discount-codes',
823
- description: 'Plural form of discount code',
824
- defaultMessage: 'discount codes'
825
- },
826
- unknownResourceType: {
827
- id: 'DeleteResourcesModal.unknown-resource-type',
828
- description: 'Label for the unknown resource type',
829
- defaultMessage: 'unknown resource type'
830
- }
831
- });
832
-
833
886
  var messages$3 = reactIntl.defineMessages({
834
887
  fileUploadInstruction: {
835
888
  id: 'DeleteResourcesModal.fileUploadInstruction',
@@ -849,63 +902,14 @@ var messages$3 = reactIntl.defineMessages({
849
902
  });
850
903
 
851
904
  const DOCUMENTATION_LINKS = {
852
- product: 'https://docs.commercetools.com/merchant-center/product-list#bulk-delete-via-csv-import'
905
+ product: 'https://docs.commercetools.com/merchant-center/product-list#bulk-delete-via-csv-import',
906
+ 'standalone-price': 'https://docs.commercetools.com/merchant-center/prices#bulk-delete-via-csv-import'
853
907
  };
854
908
  const TEMPLATE_DOWNLOAD_LINKS = {
855
- product: 'https://docs.commercetools.com/merchant-center/downloads/product_delete_import_template.csv'
909
+ product: 'https://docs.commercetools.com/merchant-center/downloads/product_delete_import_template.csv',
910
+ 'standalone-price': 'https://docs.commercetools.com/merchant-center/downloads/standalone_price_delete_import_template.csv'
856
911
  };
857
912
 
858
- function resourceTypeToMessage(resourceType) {
859
- const resourceTypeMap = {
860
- category: sharedMessages.category,
861
- product: sharedMessages.product,
862
- 'product-type': sharedMessages['product-type'],
863
- order: sharedMessages.order,
864
- customer: sharedMessages.customer,
865
- 'discount-code': sharedMessages['discount-code'],
866
- inventory: sharedMessages.inventory,
867
- // TODO: remove `inventory` after aligning the resource type names in the file upload API
868
- 'inventory-entry': sharedMessages.inventory,
869
- 'order-patch': sharedMessages['order-patch'],
870
- price: sharedMessages.price,
871
- 'product-draft': sharedMessages['product-draft'],
872
- 'product-variant': sharedMessages['product-variant'],
873
- 'product-variant-patch': sharedMessages['product-variant-patch'],
874
- 'standalone-price': sharedMessages['standalone-price']
875
- };
876
- const message = resourceTypeMap[resourceType];
877
- if (!message) {
878
- console.warn(new UnexpectedResourceTypeError(resourceType));
879
- return sharedMessages.unknownResourceType;
880
- }
881
- return message;
882
- }
883
- function resourceTypeToPluralMessage(resourceType) {
884
- const resourceTypePluralMap = {
885
- category: sharedMessages.categories,
886
- product: sharedMessages.products,
887
- 'product-type': sharedMessages['product-types'],
888
- order: sharedMessages.orders,
889
- customer: sharedMessages.customers,
890
- 'discount-code': sharedMessages['discount-codes'],
891
- inventory: sharedMessages.inventories,
892
- // TODO: remove `inventory` after aligning the resource type names in the file upload API
893
- 'inventory-entry': sharedMessages.inventories,
894
- 'order-patch': sharedMessages['order-patches'],
895
- price: sharedMessages.prices,
896
- 'product-draft': sharedMessages['product-drafts'],
897
- 'product-variant': sharedMessages['product-variants'],
898
- 'product-variant-patch': sharedMessages['product-variant-patches'],
899
- 'standalone-price': sharedMessages['standalone-prices']
900
- };
901
- const message = resourceTypePluralMap[resourceType];
902
- if (!message) {
903
- console.warn(new UnexpectedResourceTypeError(resourceType));
904
- return sharedMessages.unknownResourceType;
905
- }
906
- return message;
907
- }
908
-
909
913
  function ownKeys$5(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
910
914
  function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$5(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$5(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
911
915
  const Instructions = () => {
@@ -919,7 +923,7 @@ const Instructions = () => {
919
923
  children: [jsxRuntime.jsxs(uiKit.Text.Body, {
920
924
  children: [intl.formatMessage(messages$3.fileUploadInstruction, {
921
925
  resourceType: intl.formatMessage(resourceTypeToMessage(resourceType))
922
- }), ' ', intl.formatMessage(messages$3.unpublishNote, {
926
+ }), ' ', operations.isPublishableResourceType(resourceType) && intl.formatMessage(messages$3.unpublishNote, {
923
927
  b: msg => jsxRuntime.jsx("b", {
924
928
  children: msg
925
929
  }, "bold")