orc-shared 1.2.0-dev.7 → 1.3.0-dev.2

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 (60) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/dist/components/AppFrame/About.js +5 -1
  4. package/dist/components/AppFrame/AppFrame.js +14 -4
  5. package/dist/components/AppFrame/MenuItem.js +1 -4
  6. package/dist/components/Culture.js +106 -0
  7. package/dist/components/I18n.js +5 -2
  8. package/dist/components/MaterialUI/Inputs/DatePicker.js +10 -37
  9. package/dist/components/MaterialUI/Inputs/InputBase.js +42 -4
  10. package/dist/components/MaterialUI/Inputs/InputBaseProps.js +4 -1
  11. package/dist/components/MaterialUI/Inputs/TimePicker.js +5 -2
  12. package/dist/components/MaterialUI/ScopeSelector/ScopeSelector.js +8 -2
  13. package/dist/components/Provision.js +3 -1
  14. package/dist/components/Routing/FullPage.js +6 -3
  15. package/dist/content/icons/archives.svg +3 -0
  16. package/dist/content/icons/lock.svg +3 -0
  17. package/dist/content/icons/unlock.svg +3 -0
  18. package/dist/content/iconsSheet.svg +9 -3
  19. package/dist/selectors/metadata.js +13 -3
  20. package/dist/selectors/scope.js +2 -1
  21. package/dist/utils/localizationHelper.js +11 -1
  22. package/dist/utils/setTranslation.js +27 -1
  23. package/dist/utils/setTranslationWithFallback.js +30 -1
  24. package/package.json +1 -1
  25. package/src/components/AppFrame/About.js +8 -1
  26. package/src/components/AppFrame/AppFrame.js +13 -2
  27. package/src/components/AppFrame/AppFrame.test.js +53 -0
  28. package/src/components/AppFrame/MenuItem.js +1 -12
  29. package/src/components/Culture.js +25 -0
  30. package/src/components/Culture.test.js +86 -0
  31. package/src/components/I18n.js +4 -2
  32. package/src/components/I18n.test.js +32 -3
  33. package/src/components/MaterialUI/DataDisplay/PredefinedElements/Translations.test.js +7 -1
  34. package/src/components/MaterialUI/Inputs/DatePicker.js +5 -27
  35. package/src/components/MaterialUI/Inputs/DatePicker.test.js +6 -34
  36. package/src/components/MaterialUI/Inputs/InputBase.js +20 -2
  37. package/src/components/MaterialUI/Inputs/InputBase.test.js +68 -0
  38. package/src/components/MaterialUI/Inputs/InputBaseProps.js +2 -0
  39. package/src/components/MaterialUI/Inputs/InputBaseProps.test.js +2 -0
  40. package/src/components/MaterialUI/Inputs/TimePicker.js +6 -2
  41. package/src/components/MaterialUI/ScopeSelector/ScopeSelector.js +5 -1
  42. package/src/components/Provision.js +2 -0
  43. package/src/components/Routing/FullPage.js +12 -4
  44. package/src/components/Routing/FullPage.test.js +24 -0
  45. package/src/components/Scope/Scope.test.js +4 -0
  46. package/src/content/icons/archives.svg +3 -0
  47. package/src/content/icons/lock.svg +3 -0
  48. package/src/content/icons/unlock.svg +3 -0
  49. package/src/content/iconsSheet.svg +9 -3
  50. package/src/selectors/metadata.js +18 -7
  51. package/src/selectors/metadata.test.js +221 -283
  52. package/src/selectors/scope.js +1 -1
  53. package/src/translations/en-US.json +1 -1
  54. package/src/translations/fr-CA.json +1 -1
  55. package/src/utils/localizationHelper.js +12 -0
  56. package/src/utils/localizationHelper.test.js +64 -0
  57. package/src/utils/setTranslation.js +16 -1
  58. package/src/utils/setTranslation.test.js +24 -0
  59. package/src/utils/setTranslationWithFallback.js +18 -1
  60. package/src/utils/setTranslationWithFallback.test.js +108 -0
@@ -8,6 +8,9 @@
8
8
  <symbol id="icon-app-list" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
9
9
  <path stroke="none" fill-rule="evenodd" d="M21,18 C22.7,18 24,19.3 24,21 C24,22.7 22.7,24 21,24 C19.3,24 18,22.7 18,21 C18,19.3 19.3,18 21,18 Z M3,0 C4.7,0 6,1.3 6,3 C6,4.7 4.7,6 3,6 C1.3,6 0,4.7 0,3 C0,1.3 1.3,0 3,0 Z M12,0 C13.7,0 15,1.3 15,3 C15,4.7 13.7,6 12,6 C10.3,6 9,4.7 9,3 C9,1.3 10.3,0 12,0 Z M21,0 C22.7,0 24,1.3 24,3 C24,4.7 22.7,6 21,6 C19.3,6 18,4.7 18,3 C18,1.3 19.3,0 21,0 Z M3,9 C4.7,9 6,10.3 6,12 C6,13.7 4.7,15 3,15 C1.3,15 0,13.7 0,12 C0,10.3 1.3,9 3,9 Z M12,9 C13.7,9 15,10.3 15,12 C15,13.7 13.7,15 12,15 C10.3,15 9,13.7 9,12 C9,10.3 10.3,9 12,9 Z M21,9 C22.7,9 24,10.3 24,12 C24,13.7 22.7,15 21,15 C19.3,15 18,13.7 18,12 C18,10.3 19.3,9 21,9 Z M3,18 C4.7,18 6,19.3 6,21 C6,22.7 4.7,24 3,24 C1.3,24 0,22.7 0,21 C0,19.3 1.3,18 3,18 Z M12,18 C13.7,18 15,19.3 15,21 C15,22.7 13.7,24 12,24 C10.3,24 9,22.7 9,21 C9,19.3 10.3,18 12,18 Z"/>
10
10
  </symbol>
11
+ <symbol id="icon-archives" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
12
+ <path stroke="none" fill-rule="evenodd" d="M23.5,3 C23.7761424,3 24,3.22385763 24,3.5 L24,3.5 L24,8.5 C24,8.77614237 23.7761424,9 23.5,9 L23.5,9 L23,9 L23,21.5 C23,21.7454599 22.8231248,21.9496084 22.5898756,21.9919443 L22.5,22 L1.5,22 C1.22385763,22 1,21.7761424 1,21.5 L1,21.5 L1,9 L0.5,9 C0.254540111,9 0.0503916296,8.82312484 0.00805566941,8.58987563 L0,8.5 L0,3.5 C0,3.22385763 0.223857625,3 0.5,3 L0.5,3 Z M22,9 L2,9 L2,21 L22,21 L22,9 Z M15.5,11 C15.7761424,11 16,11.2238576 16,11.5 L16,11.5 L16,13.5 C16,13.7761424 15.7761424,14 15.5,14 L15.5,14 L8.5,14 C8.22385763,14 8,13.7761424 8,13.5 L8,13.5 L8,11.5 C8,11.2238576 8.22385763,11 8.5,11 L8.5,11 Z M15,12 L9,12 L9,13 L15,13 L15,12 Z M23,4 L1,4 L1,8 L23,8 L23,4 Z"/>
13
+ </symbol>
11
14
  <symbol id="icon-arrow-large-left" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 21 21">
12
15
  <path stroke="none" fill-rule="evenodd" d="M8.79069767,17.6511628 C8.69302326,17.6511628 8.59534884,17.6511628 8.49767442,17.5534884 L0.195348837,10.7162791 C0.0976744186,10.6186047 0,10.5209302 0,10.3255814 C0,10.1302326 0.0976744186,10.0325581 0.195348837,9.93488372 L8.49767442,3.09767442 C8.59534884,3 8.79069767,3 8.98604651,3 C9.18139535,3.09767442 9.27906977,3.29302326 9.27906977,3.48837209 L9.27906977,6.90697674 L20.5116279,6.90697674 C20.8046512,6.90697674 21,7.10232558 21,7.39534884 L21,13.255814 C21,13.5488372 20.8046512,13.744186 20.5116279,13.744186 L9.27906977,13.744186 L9.27906977,17.1627907 C9.27906977,17.3581395 9.18139535,17.5534884 8.98604651,17.6511628 C8.88837209,17.6511628 8.88837209,17.6511628 8.79069767,17.6511628 Z M1.26976744,10.3255814 L8.30232558,16.0883721 L8.30232558,13.255814 C8.30232558,12.9627907 8.49767442,12.7674419 8.79069767,12.7674419 L20.0232558,12.7674419 L20.0232558,7.88372093 L8.79069767,7.88372093 C8.49767442,7.88372093 8.30232558,7.68837209 8.30232558,7.39534884 L8.30232558,4.5627907 L1.26976744,10.3255814 Z"/>
13
16
  </symbol>
@@ -122,9 +125,6 @@
122
125
  <symbol id="icon-dropdown-chevron-down" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10">
123
126
  <polyline fill="none" stroke-linecap="round" stroke-linejoin="round" points="9 3 5 7 1 3"/>
124
127
  </symbol>
125
- <symbol id="icon-open-in-new-tab" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10">
126
- <path stroke="none" fill-rule="evenodd" d="M8.4375,6.25 L7.8125,6.25 C7.63991102,6.25 7.5,6.38991102 7.5,6.5625 L7.5,8.75 L1.25,8.75 L1.25,2.5 L4.0625,2.5 C4.23508898,2.5 4.375,2.36008898 4.375,2.1875 L4.375,1.5625 C4.375,1.38991102 4.23508898,1.25 4.0625,1.25 L0.9375,1.25 C0.419733047,1.25 0,1.66973305 0,2.1875 L0,9.0625 C0,9.58026695 0.419733047,10 0.9375,10 L7.8125,10 C8.33026695,10 8.75,9.58026695 8.75,9.0625 L8.75,6.5625 C8.75,6.38991102 8.61008898,6.25 8.4375,6.25 Z M9.53125,0 L7.03125,0 C6.61386719,0 6.40527344,0.506054688 6.69921875,0.80078125 L7.39707031,1.49863281 L2.63671875,6.25722656 C2.54845882,6.34518057 2.49884911,6.46465556 2.49884911,6.58925781 C2.49884911,6.71386007 2.54845882,6.83333506 2.63671875,6.92128906 L3.07949219,7.36328125 C3.16744619,7.45154118 3.28692118,7.50115089 3.41152344,7.50115089 C3.53612569,7.50115089 3.65560068,7.45154118 3.74355469,7.36328125 L8.5015625,2.60390625 L9.19921875,3.30078125 C9.4921875,3.59375 10,3.38867188 10,2.96875 L10,0.46875 C10,0.209866524 9.79013348,0 9.53125,0 Z"/>
127
- </symbol>
128
128
  <symbol id="icon-dropdown-chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10">
129
129
  <polyline fill="none" stroke-linecap="round" stroke-linejoin="round" points="9 3 5 7 1 3" transform="rotate(-90 5 5)"/>
130
130
  </symbol>
@@ -333,6 +333,9 @@
333
333
  <symbol id="icon-list-view" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 21 21">
334
334
  <path stroke="none" fill-rule="evenodd" d="M4,18 L4,16 L2,16 L2,18 L4,18 Z M4.5,19 L1.5,19 C1.2,19 1,18.7 1,18.5 L1,15.5 C1,15.2 1.2,15 1.5,15 L4.5,15 C4.8,15 5,15.2 5,15.5 L5,18.5 C5,18.7 4.8,19 4.5,19 Z M7.5,4 L18.5,4 C19.2,4 19.2,5 18.5,5 L7.5,5 C6.8,5 6.8,4 7.5,4 Z M4,6 L4,4 L2,4 L2,6 L4,6 Z M4.5,7 L1.5,7 C1.2,7 1,6.7 1,6.5 L1,3.5 C1,3.2 1.2,3 1.5,3 L4.5,3 C4.8,3 5,3.2 5,3.5 L5,6.5 C5,6.7 4.8,7 4.5,7 Z M7.5,10 L18.5,10 C19.2,10 19.2,11 18.5,11 L7.5,11 C6.8,11 6.8,10 7.5,10 Z M4,12 L4,10 L2,10 L2,12 L4,12 Z M4.5,13 L1.5,13 C1.2,13 1,12.7 1,12.5 L1,9.5 C1,9.2 1.2,9 1.5,9 L4.5,9 C4.8,9 5,9.2 5,9.5 L5,12.5 C5,12.7 4.8,13 4.5,13 Z M7.5,16 L18.5,16 C19.2,16 19.2,17 18.5,17 L7.5,17 C6.8,17 6.8,16 7.5,16 Z"/>
335
335
  </symbol>
336
+ <symbol id="icon-lock" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
337
+ <path stroke="none" fill-rule="evenodd" d="M12,0 C15.3141424,0 18,2.68585763 18,6 L18,6 L18,11 L20.5,11 C20.7454599,11 20.9496084,11.1768752 20.9919443,11.4101244 L21,11.5 L21,23.5 C21,23.7761424 20.7761424,24 20.5,24 L20.5,24 L3.5,24 C3.22385763,24 3,23.7761424 3,23.5 L3,23.5 L3,11.5 C3,11.2238576 3.22385763,11 3.5,11 L3.5,11 L6,11 L6,6 C6,2.76117904 8.56516051,0.122408965 11.7750335,0.00413781501 Z M20,12 L4,12 L4,23 L20,23 L20,12 Z M12,15 C12.5523336,15 13,15.4470481 13,16 C13,16.3687862 12.7995319,16.6916367 12.5015919,16.8649998 L12.5,19.5 C12.5,19.7761424 12.2761424,20 12,20 C11.7545401,20 11.5503916,19.8231248 11.5080557,19.5898756 L11.5,19.5 L11.4994027,16.8655778 C11.2009143,16.6923549 11,16.3691964 11,16 C11,15.4470481 11.4476664,15 12,15 Z M12,1 C9.23814237,1 7,3.23814237 7,6 L7,6 L7,11 L17,11 L17,6 C17,3.31082284 14.8781046,1.11815965 12.2169221,1.00461864 L12.2169221,1.00461864 Z"/>
338
+ </symbol>
336
339
  <symbol id="icon-logout" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
337
340
  <path stroke="none" fill-rule="evenodd" d="M15.4666667,0 C15.7284905,0 15.9462489,0.184565385 15.9914073,0.427955862 L16,0.52173913 L16,4.89440994 C16,5.1825585 15.7612185,5.41614907 15.4666667,5.41614907 C15.2048428,5.41614907 14.9870844,5.23158368 14.941926,4.98819321 L14.9333333,4.89440994 L14.9333333,1.04295652 L1.06666667,1.04295652 L1.06666667,22.956 L14.9333333,22.956 L14.9333333,20.2206211 C14.9333333,19.9644891 15.1220002,19.7514646 15.3707993,19.7072879 L15.4666667,19.698882 C15.7284905,19.698882 15.9462489,19.8834474 15.9914073,20.1268378 L16,20.2206211 L16,23.4782609 C16,23.7343929 15.8113332,23.9474174 15.562534,23.9915941 L15.4666667,24 L0.533333333,24 C0.271509452,24 0.0537510716,23.8154346 0.00859271404,23.5720441 L0,23.4782609 L0,0.52173913 C0,0.265607073 0.188666838,0.0525825701 0.437465992,0.00840591591 L0.533333333,0 L15.4666667,0 Z M18.8035555,6.11113193 L18.8699731,6.17730595 L23.8699701,12.1356358 C23.9447152,12.224707 23.987236,12.3340227 23.9975325,12.4461271 C23.9989527,12.4634134 24,12.4815905 24,12.5 L23.9974814,12.5544268 C23.990112,12.6338364 23.9665709,12.711832 23.9268582,12.7822079 L23.8699701,12.8643642 L18.8699731,18.822694 C18.6842197,19.0440501 18.3679957,19.0603633 18.163667,18.8591305 C17.9820415,18.6802569 17.949963,18.3897047 18.0755373,18.1718804 L18.1300334,18.0939656 L22.405,13 L4.52631579,13 C4.23563961,13 4,12.7761424 4,12.5 C4,12.2545401 4.18618438,12.0503916 4.43170986,12.0080557 L4.52631579,12 L22.406,12 L18.1300334,6.90603439 C17.9649193,6.70927343 17.9584712,6.41673378 18.1025833,6.2128219 L18.163667,6.14086953 C18.3452925,5.96199593 18.6153291,5.95501048 18.8035555,6.11113193 Z"/>
338
341
  </symbol>
@@ -613,6 +616,9 @@
613
616
  <symbol id="icon-tree-view" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 21 21">
614
617
  <path stroke="none" fill-rule="evenodd" d="M1,5 L11,5 L11,3 L1,3 L1,5 Z M10.001,19 L20.001,19 L20.001,17 L10.001,17 L10.001,19 Z M10.001,12 L20.001,12 L20.001,10 L10.001,10 L10.001,12 Z M9.501,13 L20.501,13 C20.777,13 21.001,12.776 21.001,12.5 L21.001,9.5 C21.001,9.224 20.777,9 20.501,9 L9.501,9 C9.225,9 9.001,9.224 9.001,9.5 L9.001,10 L5.997,10 L5.997,6 L11.5,6 C11.776,6 12,5.776 12,5.5 L12,2.5 C12,2.224 11.776,2 11.5,2 L0.5,2 C0.224,2 0,2.224 0,2.5 L0,5.5 C0,5.776 0.224,6 0.5,6 L4.997,6 L4.997,17.477 C4.997,17.753 5.221,17.977 5.497,17.977 L9.001,17.977 L9.001,19.5 C9.001,19.776 9.225,20 9.501,20 L20.501,20 C20.777,20 21.001,19.776 21.001,19.5 L21.001,16.5 C21.001,16.224 20.777,16 20.501,16 L9.501,16 C9.225,16 9.001,16.224 9.001,16.5 L9.001,16.977 L5.997,16.977 L5.997,11 L9.001,11 L9.001,12.5 C9.001,12.776 9.225,13 9.501,13 L9.501,13 Z"/>
615
618
  </symbol>
619
+ <symbol id="icon-unlock" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
620
+ <path stroke="none" fill-rule="evenodd" d="M12,0 C15.2381675,0 17.8775613,2.56547691 17.9958612,5.77505506 L18,6 L18,11 L20.5,11 C20.7454599,11 20.9496084,11.1768752 20.9919443,11.4101244 L21,11.5 L21,23.5 C21,23.7761424 20.7761424,24 20.5,24 L20.5,24 L3.5,24 C3.22385763,24 3,23.7761424 3,23.5 L3,23.5 L3,11.5 C3,11.2238576 3.22385763,11 3.5,11 L3.5,11 L17,11 L17,6 C17,3.23850178 14.7612171,1 12,1 C9.23814237,1 7,3.23814237 7,6 C7,6.27614237 6.77614237,6.5 6.5,6.5 C6.22385763,6.5 6,6.27614237 6,6 C6,2.68585763 8.68585763,0 12,0 Z M20,12 L4,12 L4,23 L20,23 L20,12 Z M12,15 C12.5523336,15 13,15.4470481 13,16 C13,16.3687862 12.7995319,16.6916367 12.5015919,16.8649998 L12.5,19.5 C12.5,19.7761424 12.2761424,20 12,20 C11.7545401,20 11.5503916,19.8231248 11.5080557,19.5898756 L11.5,19.5 L11.4994027,16.8655778 C11.2009143,16.6923549 11,16.3691964 11,16 C11,15.4470481 11.4476664,15 12,15 Z"/>
621
+ </symbol>
616
622
  <symbol id="icon-user-roles" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
617
623
  <path stroke="none" fill-rule="evenodd" d="M19.5031,13.3780522 C19.6602209,13.3780522 19.8082035,13.451908 19.9026601,13.5774665 C20.2862817,14.0874039 20.8587574,14.3777043 21.4951,14.3777043 C22.0321572,14.3777043 22.5621497,14.1609261 23.2052212,13.6913055 C23.535597,13.4500395 24.0001,13.6860022 24.0001,14.0950957 L24.0001,14.0950957 L24.0001,20.2777043 L23.9835753,20.4051862 C23.8374978,20.9591855 23.3900868,21.7397869 22.4808405,22.5024942 C21.7467126,23.1183062 20.8067606,23.6159986 19.6403783,23.9569274 C19.5487759,23.9837024 19.4514241,23.9837024 19.3598217,23.9569274 C18.1934394,23.6159986 17.2534874,23.1183062 16.5193595,22.5024942 C15.6101132,21.7397869 15.1627022,20.9591855 15.0166247,20.4051862 L15.0166247,20.4051862 L15.0001,20.2777043 L15.0001,14.0950957 C15.0001,13.6860022 15.464603,13.4500395 15.7949788,13.6913055 C16.4375333,14.1605485 16.9686498,14.3777043 17.5051,14.3777043 C18.1414426,14.3777043 18.7139183,14.0874039 19.0975399,13.5774665 C19.1919965,13.451908 19.3399791,13.3780522 19.5031,13.3780522 Z M19.5,14.612 L19.3239345,14.7604529 C18.8101178,15.1577421 18.1789949,15.3777043 17.5051,15.3777043 C17.0096002,15.3777043 16.5369786,15.2581354 16.0528484,15.0207931 L16.0528484,15.0207931 L16,14.993 L16,20.202 L16.0185663,20.2524264 C16.0440701,20.3168844 16.0820786,20.4005949 16.1348076,20.5000423 L16.1348076,20.5000423 L16.1925253,20.604605 C16.4113975,20.9864729 16.7281346,21.3723851 17.162028,21.7363499 C17.7890296,22.2623006 18.6054499,22.6945846 19.6403783,22.99709 L19.6403783,22.99709 L19.5,22.953 L19.6967448,22.8914978 C20.4642016,22.6341317 21.1014298,22.3006848 21.6221161,21.9081481 L21.6221161,21.9081481 L21.838172,21.7363499 C22.2720654,21.3723851 22.5888025,20.9864729 22.8076747,20.604605 C22.8913929,20.4585411 22.9476287,20.3383703 22.9816337,20.2524264 L22.9816337,20.2524264 L23,20.202 L23,14.992 L22.9472978,15.0209557 C22.5324656,15.2243804 22.1262069,15.3411781 21.706296,15.3703973 L21.706296,15.3703973 L21.4951,15.3777043 C20.7463279,15.3777043 20.0503607,15.106146 19.5094401,14.621514 L19.5094401,14.621514 L19.5,14.612 Z M19.5,15.7052174 C19.7454599,15.7052174 19.9496084,15.8820926 19.9919443,16.1153418 L20,16.2052174 L19.999664,17.759361 L21.5195,17.7598261 C21.7956424,17.7598261 22.0195,17.9836837 22.0195,18.2598261 C22.0195,18.505286 21.8426248,18.7094345 21.6093756,18.7517704 L21.5195,18.7598261 L19.999664,18.759361 L20,20.3467826 C20,20.622925 19.7761424,20.8467826 19.5,20.8467826 C19.2545401,20.8467826 19.0503916,20.6699074 19.0080557,20.4366582 L19,20.3467826 L18.999664,18.759361 L17.5195,18.7598261 C17.2433576,18.7598261 17.0195,18.5359685 17.0195,18.2598261 C17.0195,18.0143662 17.1963752,17.8102177 17.4296244,17.7678818 L17.5195,17.7598261 L18.999664,17.759361 L19,16.2052174 C19,15.929075 19.2238576,15.7052174 19.5,15.7052174 Z M13.9862583,1.96981303 L14.0281678,2.1762093 C14.1528349,2.91197976 14.0381057,3.65096383 13.7617956,4.46665502 L13.6360115,4.81558961 L13.609,4.885 L13.6618859,4.9344037 C14.2560656,5.56624941 14.2263566,7.04865663 13.572759,7.59544618 L13.489,7.657 L13.4775129,7.83712248 C13.4038188,8.69604279 13.1503611,9.39730571 12.7618562,9.94951059 L12.6412981,10.1107089 C12.4727074,10.3229279 12.3013737,10.4905446 12.139886,10.6190158 L11.999,10.722 L11.999,12.7 L12.4685843,12.8764299 L13.3946906,13.2065538 L14.1283598,13.460207 L13.8032402,14.4058799 L13.0604369,14.1490575 L12.2880214,13.8751328 L11.7967259,13.6930502 L11.3161794,13.5069759 C11.1525303,13.4423624 11.0369805,13.2976443 11.0073061,13.1283507 L10.9998,13.041913 L10.9998,10.4332174 C10.9998,10.2620446 11.0871044,10.1049426 11.2275545,10.0138118 L11.3020502,9.9739843 C11.4186366,9.92378119 11.6329833,9.77230954 11.8583019,9.48868239 C12.2562147,8.98779675 12.4998,8.27771371 12.4998,7.30278261 C12.4998,7.02664023 12.7236576,6.80278261 12.9998,6.80278261 L12.9983048,6.79493225 L13.0446516,6.61514691 C13.0658673,6.51794899 13.0863,6.38532124 13.0863,6.22278261 C13.0863,6.10087864 13.0748066,5.99579953 13.0601096,5.90987361 L13.0289,5.76424919 L12.9983048,5.65063297 C12.9975217,5.64542814 12.9979177,5.64278261 12.9998,5.64278261 C12.7236576,5.64278261 12.4998,5.41892498 12.4998,5.14278261 C12.4998,5.09771364 12.5233658,5.00205597 12.557638,4.8869217 L12.6366473,4.63990273 L12.788871,4.21129345 L12.8153727,4.14225527 L12.8936441,3.89737369 C13.0625747,3.326574 13.1224756,2.81692192 13.0422204,2.34326576 L13.0134497,2.20142314 C12.6716439,0.768735941 8.10999202,0.727802021 7.52705219,2.07862138 L7.45813808,2.28540173 C7.36528954,2.4987833 7.13292796,2.62407138 6.89740504,2.57479428 C6.46643115,2.48462411 6.28475826,2.54025499 6.2020687,2.67534124 C6.1057249,2.8327338 6.07915909,3.14641132 6.13613512,3.57236853 C6.15876036,3.7415166 6.1928592,3.92027213 6.23827631,4.11552233 L6.35697963,4.57756105 L6.44732721,4.90612207 L6.48275591,5.05392008 C6.49504169,5.11538868 6.4998,5.16266995 6.4998,5.21582609 C6.4998,5.49196846 6.27594237,5.71582609 5.9998,5.71582609 L5.99932681,5.7249767 L5.96045364,5.85771867 C5.93721493,5.95030606 5.91255,6.08617562 5.91255,6.25930435 C5.91255,6.43243307 5.93721493,6.56830264 5.96045364,6.66089002 L5.99932681,6.79363199 C6.00093259,6.79970103 6.00122621,6.80278261 5.9998,6.80278261 C6.27594237,6.80278261 6.4998,7.02664023 6.4998,7.30278261 C6.4998,8.27771371 6.74338534,8.98779675 7.14129809,9.48868239 C7.36661669,9.77230954 7.58096337,9.92378119 7.69754976,9.9739843 C7.85476623,10.0416831 7.96453015,10.184003 7.99268277,10.3490438 L7.9998,10.4332174 L7.9998,13.041913 C7.9998,13.2468324 7.87476301,13.4310077 7.68430594,13.5066254 L7.18821619,13.6980869 L5.9051075,14.1572455 L4.32750495,14.7069156 L3.83269728,14.889434 C3.7544249,14.9191801 3.67823564,14.9485984 3.6041075,14.9777027 L3.18389621,15.1486688 L2.81209623,15.3127529 C2.00022172,15.6880967 1.57508475,16.0125924 1.47633505,16.3237227 C1.3524308,16.713779 1.25136302,17.2292785 1.17343637,17.8361953 C1.12061254,18.2476035 1.08052044,18.6827253 1.05149067,19.1239548 L1.02192555,19.6535891 L1.013,19.846 L10.9998,19.8462609 L10.9998,20.8462609 L0.4998,20.8462609 C0.221762673,20.8462609 -0.00287200353,20.6194378 -0.000314408739,20.3414135 L0.0124547607,19.8579012 L0.0272977253,19.5173651 C0.0576097596,18.9020505 0.107433351,18.2863108 0.1815788,17.7088432 C0.266494196,17.0474959 0.378247439,16.4774948 0.523228222,16.0210886 C0.74878462,15.3104289 1.41838558,14.8066131 2.73664169,14.2487159 L3.20036533,14.0603893 L3.71382153,13.8659091 L4.69076079,13.5199898 L6.01515136,13.0601937 L6.57712723,12.8582495 L6.999,12.699 L6.999,10.722 L6.97878695,10.7081147 C6.82300904,10.5988751 6.65423792,10.4518544 6.48506254,10.2615955 L6.35830191,10.1107089 C5.90172808,9.53598172 5.60315061,8.78193482 5.5220871,7.83712248 L5.511,7.66 L5.42644551,7.60023877 C4.77239668,7.06608827 4.74266719,5.61794693 5.33725703,5.00070635 L5.416,4.927 L5.31864514,4.56430996 C5.23914154,4.25345753 5.18104725,3.97471855 5.14496271,3.70494774 C5.060237,3.0715318 5.1040992,2.55362601 5.34917157,2.15326223 C5.60826896,1.7299864 6.04267426,1.52326451 6.6096213,1.53626177 L6.684,1.54 L6.69412529,1.52141884 C7.88818769,-0.519198372 13.4280676,-0.369857688 13.9862583,1.96981303 Z"/>
618
624
  </symbol>
@@ -93,9 +93,9 @@ var namedLookupSelector = (0, _utils.memoize)(function (moduleName, lookupName)
93
93
  });
94
94
  exports.namedLookupSelector = namedLookupSelector;
95
95
  var namedLookupValuesSelector = (0, _utils.memoize)(function (moduleName, lookupName) {
96
- return (0, _reselect.createSelector)(namedLookupSelector(moduleName, lookupName), _locale.currentLocaleOrDefault, function (statuses, locale) {
97
- return (statuses.get("values") || _immutable.default.Map()).map(function (status) {
98
- return (0, _utils.setTranslation)(locale, status, "displayName");
96
+ return (0, _reselect.createSelector)(namedLookupSelector(moduleName, lookupName), _locale.currentLocaleOrDefault, function (lookup, locale) {
97
+ return (lookup.get("values") || _immutable.default.Map()).map(function (lookupValue) {
98
+ return (0, _setTranslationWithFallback.setTranslationWithFallbackField)(locale, lookupValue, "name", "displayName");
99
99
  });
100
100
  });
101
101
  });
@@ -230,6 +230,8 @@ var filterIsBuiltInAttributes = function filterIsBuiltInAttributes(isBuiltIn) {
230
230
  return function (attributes) {
231
231
  return attributes.filter(function (a) {
232
232
  return a.get("isBuiltIn") === isBuiltIn;
233
+ }).sortBy(function (x) {
234
+ return x.get("displayOrder");
233
235
  });
234
236
  };
235
237
  };
@@ -278,8 +280,12 @@ var groupedCustomAttributesDefinitionSelector = (0, _utils.memoize)(function (mo
278
280
  displayOrder: profileAttributeGroup == null ? void 0 : profileAttributeGroup.get("displayOrder")
279
281
  }).set("baseAttributes", group.filter(function (i) {
280
282
  return i.get("dataType") !== _constants.attributeDataType.entityReference;
283
+ }).sortBy(function (x) {
284
+ return x.get("displayOrder");
281
285
  })).set("profileAttributes", group.filter(function (i) {
282
286
  return i.get("dataType") === _constants.attributeDataType.entityReference;
287
+ }).sortBy(function (x) {
288
+ return x.get("displayOrder");
283
289
  }));
284
290
  }).sortBy(function (x) {
285
291
  return x.get("displayOrder");
@@ -291,9 +297,13 @@ var customAttributesDefinitionSelector = (0, _utils.memoize)(function (moduleNam
291
297
  return (0, _reselect.createSelector)(mappedDefinitionEntity(moduleName, profileEntityName), customAttributesSelector(moduleName, profileEntityName), function (definition, attributes) {
292
298
  var profileAttributes = attributes == null ? void 0 : attributes.filter(function (a) {
293
299
  return a.get("dataType") === _constants.attributeDataType.entityReference;
300
+ }).sortBy(function (x) {
301
+ return x.get("displayOrder");
294
302
  });
295
303
  var baseAttributes = attributes == null ? void 0 : attributes.filter(function (a) {
296
304
  return a.get("dataType") !== _constants.attributeDataType.entityReference;
305
+ }).sortBy(function (x) {
306
+ return x.get("displayOrder");
297
307
  });
298
308
  return definition.set("baseAttributes", baseAttributes).set("profileAttributes", profileAttributes);
299
309
  });
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- exports.scopeGetter = exports.scopeDefaultCultureSelector = exports.localizedScopesSelectorByIds = exports.localizedScopeSelector = exports.isCurrentScopeAuthorizedSelector = exports.getScopesSelector = exports.currentScopeSelector = void 0;
4
+ exports.scopeGetter = exports.scopeDefaultCultureSelector = exports.localizedScopesSelectorByIds = exports.localizedScopesSelector = exports.localizedScopeSelector = exports.isCurrentScopeAuthorizedSelector = exports.getScopesSelector = exports.currentScopeSelector = void 0;
5
5
 
6
6
  var _reselect = require("reselect");
7
7
 
@@ -52,6 +52,7 @@ var localizedScopesSelector = (0, _reselect.createSelector)(scopeData, _locale.c
52
52
  });
53
53
  });
54
54
  });
55
+ exports.localizedScopesSelector = localizedScopesSelector;
55
56
  var currentScopeSelector = (0, _reselect.createSelector)(_navigation.getCurrentScope, localizedScopesSelector, function (id, scopes) {
56
57
  return scopes.get(id) || _immutable.default.Map();
57
58
  });
@@ -2,6 +2,7 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.default = void 0;
5
+ exports.findCorrespondingLocale = findCorrespondingLocale;
5
6
  exports.getLocalization = getLocalization;
6
7
  exports.getNotLocalizedString = getNotLocalizedString;
7
8
 
@@ -51,9 +52,16 @@ function getNotLocalizedString(value) {
51
52
  return value && "[".concat(value, "]");
52
53
  }
53
54
 
55
+ function findCorrespondingLocale(locales, language) {
56
+ var _ref, _ref2, _ref3, _ref4, _locales$language;
57
+
58
+ return (_ref = (_ref2 = (_ref3 = (_ref4 = (_locales$language = locales[language]) != null ? _locales$language : locales[language.replace(/-/g, "")]) != null ? _ref4 : locales[language.toLowerCase()]) != null ? _ref3 : locales[language.toLowerCase().replace(/-/g, "")]) != null ? _ref2 : locales[language.substring(0, 2).toLowerCase()]) != null ? _ref : null;
59
+ }
60
+
54
61
  var _default = {
55
62
  getLocalization: getLocalization,
56
- getNotLocalizedString: getNotLocalizedString
63
+ getNotLocalizedString: getNotLocalizedString,
64
+ findCorrespondingLocale: findCorrespondingLocale
57
65
  };
58
66
  var _default2 = _default;
59
67
  var _default3 = _default2;
@@ -69,6 +77,7 @@ exports.default = _default3;
69
77
 
70
78
  reactHotLoader.register(getLocalization, "getLocalization", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
71
79
  reactHotLoader.register(getNotLocalizedString, "getNotLocalizedString", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
80
+ reactHotLoader.register(findCorrespondingLocale, "findCorrespondingLocale", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
72
81
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
73
82
  })();
74
83
 
@@ -90,6 +99,7 @@ exports.default = _default3;
90
99
 
91
100
  reactHotLoader.register(getLocalization, "getLocalization", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
92
101
  reactHotLoader.register(getNotLocalizedString, "getNotLocalizedString", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
102
+ reactHotLoader.register(findCorrespondingLocale, "findCorrespondingLocale", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
93
103
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/utils/localizationHelper.js");
94
104
  })();
95
105
 
@@ -15,6 +15,12 @@ var _flatten = require("./flatten");
15
15
  enterModule && enterModule(module);
16
16
  })();
17
17
 
18
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
19
+
20
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
21
+
22
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
23
+
18
24
  var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
19
25
  return a;
20
26
  };
@@ -30,7 +36,27 @@ var setTranslation = function setTranslation(locale, obj) {
30
36
  }
31
37
 
32
38
  if (!obj || !obj.getIn((0, _flatten.flatten)([field]))) return obj;
33
- var value = obj.getIn((0, _flatten.flatten)([field, locale])) || obj.getIn((0, _flatten.flatten)([field])).filter(function (i) {
39
+ var localeValue = obj.getIn((0, _flatten.flatten)([field, locale]));
40
+
41
+ if (!localeValue && locale.includes("-")) {
42
+ var fieldValue = obj.getIn((0, _flatten.flatten)([field]));
43
+ var fieldKeys = fieldValue.keys();
44
+ var language = locale.substring(0, locale.indexOf("-"));
45
+
46
+ for (var _iterator = _createForOfIteratorHelperLoose(fieldKeys), _step; !(_step = _iterator()).done;) {
47
+ var key = _step.value;
48
+
49
+ if (key !== locale && key.startsWith(language)) {
50
+ localeValue = obj.getIn((0, _flatten.flatten)([field, key]));
51
+
52
+ if (localeValue) {
53
+ break;
54
+ }
55
+ }
56
+ }
57
+ }
58
+
59
+ var value = localeValue || obj.getIn((0, _flatten.flatten)([field])).filter(function (i) {
34
60
  return i;
35
61
  }).first() || "";
36
62
  return obj.setIn((0, _flatten.flatten)([field]), value);
@@ -15,6 +15,12 @@ var _flatten = require("./flatten");
15
15
  enterModule && enterModule(module);
16
16
  })();
17
17
 
18
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
19
+
20
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
21
+
22
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
23
+
18
24
  var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
19
25
  return a;
20
26
  };
@@ -30,7 +36,30 @@ var setTranslationWithFallbackValue = function setTranslationWithFallbackValue(l
30
36
  field[_key - 3] = arguments[_key];
31
37
  }
32
38
 
33
- var value = obj.getIn((0, _flatten.flatten)([field, locale])) || fallbackValue || "";
39
+ var localeValue = obj.getIn((0, _flatten.flatten)([field, locale]));
40
+
41
+ if (!localeValue && locale.includes("-")) {
42
+ var fieldValue = obj.getIn((0, _flatten.flatten)([field]));
43
+
44
+ if (fieldValue) {
45
+ var fieldKeys = fieldValue.keys();
46
+ var language = locale.substring(0, locale.indexOf("-"));
47
+
48
+ for (var _iterator = _createForOfIteratorHelperLoose(fieldKeys), _step; !(_step = _iterator()).done;) {
49
+ var key = _step.value;
50
+
51
+ if (key !== locale && key.startsWith(language)) {
52
+ localeValue = obj.getIn((0, _flatten.flatten)([field, key]));
53
+
54
+ if (localeValue) {
55
+ break;
56
+ }
57
+ }
58
+ }
59
+ }
60
+ }
61
+
62
+ var value = localeValue || fallbackValue || "";
34
63
  return obj.setIn((0, _flatten.flatten)([field]), value);
35
64
  };
36
65
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orc-shared",
3
- "version": "1.2.0-dev.7",
3
+ "version": "1.3.0-dev.2",
4
4
  "description": "Shared code for Orckestra applications",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
@@ -164,7 +164,14 @@ export const About = ({ currentApplication }) => {
164
164
  </AboutLink>
165
165
  </AboutParagraph>
166
166
  <AboutParagraph>
167
- <Text message={sharedMessages.copyright} />
167
+ <Text
168
+ message={{
169
+ ...sharedMessages.copyright,
170
+ values: {
171
+ year: new Date().getFullYear(),
172
+ },
173
+ }}
174
+ />
168
175
  <br />
169
176
  <Text message={sharedMessages.allRightsReserved} />
170
177
  </AboutParagraph>
@@ -1,4 +1,4 @@
1
- import React, { useEffect } from "react";
1
+ import React, { useEffect, useMemo } from "react";
2
2
  import { useIntl } from "react-intl";
3
3
  import pt from "prop-types";
4
4
  import styled, { css } from "styled-components";
@@ -89,6 +89,17 @@ const AppFrame = ({ initOpen, applicationId, modules, activeModules, children, n
89
89
  document.title = currentApplication?.displayName || applicationId;
90
90
  }, [currentApplication, applicationId]);
91
91
 
92
+ // Extract only what's needed for the SideBar and its menuItems
93
+ const menuItemFromModules = useMemo(
94
+ () =>
95
+ (modules ?? []).map(item => ({
96
+ id: item.id,
97
+ label: item.label,
98
+ icon: item.icon,
99
+ })),
100
+ [modules],
101
+ );
102
+
92
103
  const [prefViewState] = useViewState(PREFS_NAME);
93
104
 
94
105
  return (
@@ -109,7 +120,7 @@ const AppFrame = ({ initOpen, applicationId, modules, activeModules, children, n
109
120
  }}
110
121
  onClick={reset}
111
122
  />
112
- <Sidebar {...{ open, toggle, modules, activeModules }} />
123
+ <Sidebar {...{ open, toggle, modules: menuItemFromModules, activeModules }} />
113
124
  <ViewPort open={open} onClick={reset}>
114
125
  {noScope && !forceShowScope.includes(moduleName) ? (
115
126
  <React.Fragment>
@@ -294,6 +294,59 @@ describe("AppFrame", () => {
294
294
  expect(document.title, "to equal", "Marketing Legacy");
295
295
  });
296
296
 
297
+ it("renders a viewport with scope selector, top bar and sidebar with undefined modules", () => {
298
+ props.modules = undefined;
299
+ props.children = [<TestComp1 key="1" />, <TestComp2 key="2" />, <TestComp3 key="3" />];
300
+ expect(
301
+ <Provider store={store}>
302
+ <MemoryRouter initialEntries={["/Foo/bar"]}>
303
+ <ThemeProvider theme={{}}>
304
+ <I18n>
305
+ <AppFrame {...props} />
306
+ </I18n>
307
+ </ThemeProvider>
308
+ </MemoryRouter>
309
+ </Provider>,
310
+ "when mounted",
311
+ "to satisfy",
312
+ <Provider store={store}>
313
+ <ThemeProvider theme={{}}>
314
+ <MemoryRouter initialEntries={["/Foo/bar"]}>
315
+ <Base>
316
+ <Wrapper>
317
+ <AppBox>
318
+ <ApplicationSelector {...props} />
319
+ <AppLabel>
320
+ <AppLogo />
321
+ Marketing Legacy
322
+ </AppLabel>
323
+ </AppBox>
324
+ <MenuWrapper>
325
+ <Ignore />
326
+ </MenuWrapper>
327
+ <HelpLink>Help</HelpLink>
328
+ </Wrapper>
329
+ <SideBar>
330
+ <MenuToggle />
331
+ <Logo />
332
+ </SideBar>
333
+ <ViewPort>
334
+ <ScopeBar name="Test 1" />
335
+ <TestComp1 key="1" />
336
+ <TestComp2 key="2" />
337
+ <TestComp3 key="3" />
338
+ </ViewPort>
339
+ <About messages={props.aboutMessages} />
340
+ <LoadingScreen />
341
+ </Base>
342
+ </MemoryRouter>
343
+ </ThemeProvider>
344
+ </Provider>,
345
+ );
346
+
347
+ expect(document.title, "to equal", "Marketing Legacy");
348
+ });
349
+
297
350
  it("renders a viewport with scope selector, top bar and sidebar when no current application", () => {
298
351
  props.modules = [
299
352
  { id: "test1", component: TestComp1, route: "/test1" },
@@ -116,18 +116,7 @@ export const Label = styled.span`
116
116
  opacity: ${ifFlag("show", 1, 0)};
117
117
  `;
118
118
 
119
- const MenuItem = ({
120
- open = false,
121
- label = "",
122
- icon,
123
- alert,
124
- pageScopeSelector,
125
- closingTabHandler,
126
- hide, // This props is not used in the component, but we need to destructure it so props can be used in ItemWrapper
127
- isHidden = false,
128
- href,
129
- ...props
130
- }) => {
119
+ const MenuItem = ({ open = false, label = "", icon, alert, isHidden = false, href, ...props }) => {
131
120
  let ItemWrapper = Block;
132
121
  if (props.menuToggle) {
133
122
  ItemWrapper = BlockWithA;
@@ -0,0 +1,25 @@
1
+ import React from "react";
2
+ import { useMemo } from "react";
3
+ import { useSelector } from "react-redux";
4
+ import { currentLocaleOrDefault } from "../selectors/locale";
5
+ import { registerLocale, setDefaultLocale } from "react-datepicker";
6
+ import * as date_fns_locale from "date-fns/locale";
7
+ import { findCorrespondingLocale } from "../utils/localizationHelper";
8
+
9
+ const Culture = () => {
10
+ const locale = useSelector(currentLocaleOrDefault);
11
+ const language = navigator.language ?? locale;
12
+
13
+ useMemo(() => {
14
+ const fnsLocale = findCorrespondingLocale(date_fns_locale, language);
15
+
16
+ if (fnsLocale != null) {
17
+ registerLocale(language, fnsLocale);
18
+ setDefaultLocale(language);
19
+ }
20
+ }, [language]);
21
+
22
+ return <React.Fragment />;
23
+ };
24
+
25
+ export default Culture;
@@ -0,0 +1,86 @@
1
+ import React from "react";
2
+ import Immutable from "immutable";
3
+ import { Provider } from "react-redux";
4
+ import { getDefaultLocale } from "react-datepicker";
5
+ import Culture from "./Culture";
6
+
7
+ describe("Culture", () => {
8
+ let state, store, languageGetter;
9
+
10
+ beforeEach(() => {
11
+ languageGetter = jest.spyOn(window.navigator, "language", "get");
12
+
13
+ state = Immutable.fromJS({
14
+ requests: {},
15
+ settings: {
16
+ defaultScope: "aDefaultScope",
17
+ },
18
+ locale: {
19
+ supportedLocales: [
20
+ { language: "English", cultureIso: "en" },
21
+ { language: "Français", cultureIso: "fr" },
22
+ ],
23
+ },
24
+ });
25
+ store = {
26
+ subscribe: () => {},
27
+ getState: () => state,
28
+ dispatch: () => {},
29
+ };
30
+ });
31
+
32
+ afterEach(() => {
33
+ languageGetter.mockReset();
34
+ jest.clearAllMocks();
35
+ });
36
+
37
+ it("shows the wrapped component if authenticated and default scope is known", () => {
38
+ languageGetter.mockReturnValue(null);
39
+
40
+ const component = (
41
+ <Provider store={store}>
42
+ <Culture />
43
+ </Provider>
44
+ );
45
+
46
+ expect(component, "when mounted", "to satisfy", null);
47
+
48
+ expect(getDefaultLocale(), "to be", undefined); // Default behavior for react-datepicker
49
+ });
50
+
51
+ it("shows the wrapped component if authenticated and default scope is known 222", () => {
52
+ state = state.setIn(["locale", "supportedLocales"], [{ language: "English", cultureIso: "en" }]);
53
+ languageGetter.mockReturnValue("en-GB");
54
+
55
+ const component = (
56
+ <Provider store={store}>
57
+ <Culture />
58
+ </Provider>
59
+ );
60
+
61
+ expect(component, "when mounted", "to satisfy", null);
62
+
63
+ expect(getDefaultLocale(), "to equal", "en-GB");
64
+ });
65
+
66
+ it("shows the wrapped component if authenticated and default scope is known 333", () => {
67
+ state = state.setIn(
68
+ ["locale", "supportedLocales"],
69
+ [
70
+ { language: "French", cultureIso: "fr" },
71
+ { language: "EnglishMy", cultureIso: "enMy" },
72
+ ],
73
+ );
74
+ languageGetter.mockReturnValue("fr-FR");
75
+
76
+ const component = (
77
+ <Provider store={store}>
78
+ <Culture />
79
+ </Provider>
80
+ );
81
+
82
+ expect(component, "when mounted", "to satisfy", null);
83
+
84
+ expect(getDefaultLocale(), "to equal", "fr-FR");
85
+ });
86
+ });
@@ -6,10 +6,12 @@ import { currentLocaleOrDefault } from "../selectors/locale";
6
6
  const I18n = props => {
7
7
  const locale = useSelector(currentLocaleOrDefault);
8
8
  const messages = require("translations/" + locale + ".json");
9
+ const language = navigator.language ?? locale;
10
+
9
11
  return (
10
12
  <IntlProvider
11
- key={locale} // TODO: Remove this when react-intl suports new React context API
12
- locale={locale}
13
+ key={language} // TODO: Remove this when react-intl suports new React context API
14
+ locale={language}
13
15
  messages={messages}
14
16
  {...props}
15
17
  />
@@ -9,10 +9,13 @@ import I18n from "./I18n";
9
9
  jest.mock("translations/en-US.json", () => ({
10
10
  WORD: "Word",
11
11
  }));
12
+ jest.mock("translations/fr-CA.json", () => ({
13
+ WORD: "Mots",
14
+ }));
12
15
 
13
16
  describe("I18n", () => {
14
17
  spyOnConsole();
15
- let store, state;
18
+ let store, state, languageGetter;
16
19
  beforeEach(() => {
17
20
  state = Immutable.fromJS({
18
21
  locale: {
@@ -25,9 +28,16 @@ describe("I18n", () => {
25
28
  dispatch: () => {},
26
29
  getState: () => state,
27
30
  };
31
+
32
+ languageGetter = jest.spyOn(window.navigator, "language", "get");
28
33
  });
29
34
 
30
- it("renders a react-intl IntlProvider with locale data provided", () =>
35
+ afterEach(() => {
36
+ languageGetter.mockReset();
37
+ });
38
+
39
+ it("renders a react-intl IntlProvider with locale data provided", () => {
40
+ languageGetter.mockReturnValue(null);
31
41
  expect(
32
42
  <Provider store={store}>
33
43
  <MemoryRouter>
@@ -39,5 +49,24 @@ describe("I18n", () => {
39
49
  "when mounted",
40
50
  "to satisfy",
41
51
  "Word",
42
- ).then(() => expect(console.error, "was not called")));
52
+ ).then(() => expect(console.error, "was not called"));
53
+ });
54
+
55
+ it("renders a react-intl IntlProvider with navigator language provided", () => {
56
+ languageGetter.mockReturnValue("fr-CA");
57
+ state = state.setIn(["locale", "locale"], "fr-CA");
58
+
59
+ expect(
60
+ <Provider store={store}>
61
+ <MemoryRouter>
62
+ <I18n>
63
+ <FormattedMessage id="WORD" defaultMessage="Failure" />
64
+ </I18n>
65
+ </MemoryRouter>
66
+ </Provider>,
67
+ "when mounted",
68
+ "to satisfy",
69
+ "Mots",
70
+ ).then(() => expect(console.error, "was not called"));
71
+ });
43
72
  });
@@ -18,6 +18,8 @@ describe("Translations ", () => {
18
18
  const theme = createMuiTheme();
19
19
 
20
20
  beforeEach(() => {
21
+ window.bypassDebounce = true;
22
+
21
23
  collapsibleListProps = new CollapsibleListProps();
22
24
  collapsibleListProps.set(CollapsibleListProps.propNames.hasMessage, true);
23
25
  collapsibleListProps.set(
@@ -32,6 +34,10 @@ describe("Translations ", () => {
32
34
  collapsibleListProps.set(CollapsibleListProps.propNames.containerWidth, "unset");
33
35
  });
34
36
 
37
+ afterEach(() => {
38
+ delete window.bypassDebounce;
39
+ });
40
+
35
41
  it("Renders Translations correctly", () => {
36
42
  const component = (
37
43
  <TestWrapper stylesProvider muiThemeProvider={{ theme }} intlProvider={{ messages }}>
@@ -135,7 +141,7 @@ describe("Translations ", () => {
135
141
  expect(component, "when mounted", "to satisfy", expected);
136
142
  });
137
143
 
138
- it("Translations component handles change", () => {
144
+ it("Translations component handles change", () => {
139
145
  const aValue = "aValue";
140
146
  const update = sinon.spy().named("update");
141
147