@k-int/stripes-kint-components 1.3.0 → 1.7.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 (251) hide show
  1. package/CHANGELOG.md +34 -2
  2. package/es/artifacts/coverage-jest/lcov-report/block-navigation.js +109 -0
  3. package/es/artifacts/coverage-jest/lcov-report/prettify.js +998 -0
  4. package/es/artifacts/coverage-jest/lcov-report/sorter.js +238 -0
  5. package/es/index.js +69 -17
  6. package/es/lib/ActionList/ActionList.js +63 -24
  7. package/es/lib/ActionList/ActionListFieldArray.js +158 -96
  8. package/es/lib/ActionList/index.js +7 -3
  9. package/es/lib/EditableRefdataList/EditableRefdataList.js +69 -24
  10. package/es/lib/EditableRefdataList/index.js +7 -3
  11. package/es/lib/EditableSettingsList/EditableSettingsList.js +90 -0
  12. package/es/lib/EditableSettingsList/EditableSettingsListFieldArray.js +90 -0
  13. package/es/lib/EditableSettingsList/EditableSettingsListFieldArray.test.js +181 -0
  14. package/es/lib/{Settings → EditableSettingsList/SettingField}/EditSettingValue.js +72 -9
  15. package/es/lib/EditableSettingsList/SettingField/EditSettingValue.test.js +447 -0
  16. package/es/lib/{Settings → EditableSettingsList/SettingField}/RenderSettingValue.js +45 -7
  17. package/es/lib/EditableSettingsList/SettingField/RenderSettingValue.test.js +495 -0
  18. package/es/lib/EditableSettingsList/SettingField/SettingField.js +187 -0
  19. package/es/lib/EditableSettingsList/SettingField/SettingField.test.js +180 -0
  20. package/es/lib/EditableSettingsList/SettingField/index.js +35 -0
  21. package/es/lib/EditableSettingsList/index.js +35 -0
  22. package/es/lib/NoResultsMessage/NoResultsMessage.js +122 -0
  23. package/es/lib/NoResultsMessage/index.js +19 -0
  24. package/es/lib/QueryTypedown/QueryTypedown.js +48 -9
  25. package/es/lib/QueryTypedown/index.js +6 -2
  26. package/es/lib/RefdataButtons/RefdataButtons.js +143 -0
  27. package/es/lib/RefdataButtons/index.js +19 -0
  28. package/es/lib/SASQLookupComponent/SASQLookupComponent.js +202 -131
  29. package/es/lib/SASQLookupComponent/index.js +6 -2
  30. package/es/lib/SASQRoute/SASQRoute.js +55 -18
  31. package/es/lib/SASQRoute/index.js +6 -2
  32. package/es/lib/SASQViewComponent/SASQViewComponent.js +50 -11
  33. package/es/lib/SASQViewComponent/index.js +6 -2
  34. package/es/lib/SearchField/SearchField.js +48 -13
  35. package/es/lib/SearchField/index.js +6 -2
  36. package/es/lib/SettingPage/SettingPage.js +99 -0
  37. package/es/lib/SettingPage/SettingPagePane.js +83 -0
  38. package/es/lib/SettingPage/index.js +27 -0
  39. package/es/lib/TypeDown/TypeDown.js +143 -101
  40. package/es/lib/TypeDown/index.js +6 -2
  41. package/es/lib/Typedown/Typedown.js +140 -96
  42. package/es/lib/Typedown/index.js +6 -2
  43. package/es/lib/constants/eventCodes.js +31 -1
  44. package/es/lib/contexts/SettingsContext.js +41 -0
  45. package/es/lib/contexts/index.js +19 -0
  46. package/es/lib/hooks/index.js +42 -8
  47. package/es/lib/hooks/settingsHooks/index.js +27 -0
  48. package/es/lib/hooks/settingsHooks/useSettingSection.js +74 -0
  49. package/es/lib/hooks/settingsHooks/useSettings.js +175 -0
  50. package/es/lib/hooks/typedownHooks/index.js +8 -28
  51. package/es/lib/hooks/typedownHooks/useTypedown.js +129 -12
  52. package/es/lib/hooks/typedownHooks/useTypedownData.js +35 -2
  53. package/es/lib/hooks/typedownHooks/useTypedownToggle.js +39 -6
  54. package/es/lib/hooks/useActiveElement.js +33 -2
  55. package/es/lib/hooks/useHelperApp.js +51 -12
  56. package/es/lib/hooks/useKiwtFieldArray.js +142 -0
  57. package/es/lib/hooks/useKiwtSASQuery.js +62 -7
  58. package/es/lib/hooks/useLocalStorageState.js +37 -4
  59. package/es/lib/hooks/useMutateRefdataValue.js +42 -9
  60. package/es/lib/hooks/useQIndex.js +108 -0
  61. package/es/lib/hooks/useRefdata.js +56 -12
  62. package/es/lib/hooks/useTemplates.js +36 -3
  63. package/es/lib/utils/buildUrl.js +43 -10
  64. package/es/lib/utils/generateKiwtQuery.js +31 -108
  65. package/es/lib/utils/generateKiwtQueryParams.js +154 -0
  66. package/es/lib/utils/index.js +55 -3
  67. package/es/lib/utils/refdataOptions.js +43 -0
  68. package/es/lib/utils/renderHelpText.js +109 -0
  69. package/es/lib/utils/selectorSafe.js +31 -2
  70. package/es/lib/utils/sortByLabel.js +55 -0
  71. package/es/lib/utils/toCamelCase.js +48 -0
  72. package/jest.config.js +15 -1
  73. package/junit.xml +79 -0
  74. package/package.json +17 -10
  75. package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionList.js.html +256 -0
  76. package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionListFieldArray.js.html +799 -0
  77. package/src/artifacts/coverage-jest/lcov-report/ActionList/index.html +146 -0
  78. package/src/artifacts/coverage-jest/lcov-report/ActionList/index.js.html +88 -0
  79. package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/EditableRefdataList.js.html +376 -0
  80. package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/index.html +131 -0
  81. package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/index.js.html +88 -0
  82. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/EditableSettingsList.js.html +223 -0
  83. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/EditableSettingsListFieldArray.js.html +211 -0
  84. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/EditSettingValue.js.html +376 -0
  85. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/RenderSettingValue.js.html +262 -0
  86. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/SettingField.js.html +436 -0
  87. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/index.html +161 -0
  88. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/index.js.html +94 -0
  89. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/index.html +146 -0
  90. package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/index.js.html +94 -0
  91. package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/NoResultsMessage.js.html +319 -0
  92. package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/index.html +131 -0
  93. package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/index.js.html +88 -0
  94. package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/QueryTypedown.js.html +184 -0
  95. package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.html +131 -0
  96. package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.js.html +88 -0
  97. package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/RefdataButtons.js.html +370 -0
  98. package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/index.html +131 -0
  99. package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/index.js.html +88 -0
  100. package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/SASQLookupComponent.js.html +949 -0
  101. package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/index.html +131 -0
  102. package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/index.js.html +88 -0
  103. package/src/artifacts/coverage-jest/lcov-report/SASQRoute/SASQRoute.js.html +274 -0
  104. package/src/artifacts/coverage-jest/lcov-report/SASQRoute/index.html +131 -0
  105. package/src/artifacts/coverage-jest/lcov-report/SASQRoute/index.js.html +88 -0
  106. package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/SASQViewComponent.js.html +250 -0
  107. package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/index.html +131 -0
  108. package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/index.js.html +88 -0
  109. package/src/artifacts/coverage-jest/lcov-report/SearchField/SearchField.js.html +214 -0
  110. package/src/artifacts/coverage-jest/lcov-report/SearchField/index.html +131 -0
  111. package/src/artifacts/coverage-jest/lcov-report/SearchField/index.js.html +88 -0
  112. package/src/artifacts/coverage-jest/lcov-report/SettingPage/SettingPage.js.html +211 -0
  113. package/src/artifacts/coverage-jest/lcov-report/SettingPage/SettingPagePane.js.html +178 -0
  114. package/src/artifacts/coverage-jest/lcov-report/SettingPage/index.html +146 -0
  115. package/src/artifacts/coverage-jest/lcov-report/SettingPage/index.js.html +91 -0
  116. package/src/artifacts/coverage-jest/lcov-report/TypeDown/TypeDown.js.html +769 -0
  117. package/src/artifacts/coverage-jest/lcov-report/TypeDown/index.html +131 -0
  118. package/src/artifacts/coverage-jest/lcov-report/TypeDown/index.js.html +88 -0
  119. package/src/artifacts/coverage-jest/lcov-report/Typedown/Typedown.js.html +790 -0
  120. package/src/artifacts/coverage-jest/lcov-report/Typedown/index.html +131 -0
  121. package/src/artifacts/coverage-jest/lcov-report/Typedown/index.js.html +88 -0
  122. package/src/artifacts/coverage-jest/lcov-report/base.css +224 -0
  123. package/src/artifacts/coverage-jest/lcov-report/block-navigation.js +87 -0
  124. package/src/artifacts/coverage-jest/lcov-report/constants/eventCodes.js.html +94 -0
  125. package/src/artifacts/coverage-jest/lcov-report/constants/index.html +116 -0
  126. package/src/artifacts/coverage-jest/lcov-report/contexts/SettingsContext.js.html +97 -0
  127. package/src/artifacts/coverage-jest/lcov-report/contexts/index.html +131 -0
  128. package/src/artifacts/coverage-jest/lcov-report/contexts/index.js.html +91 -0
  129. package/src/artifacts/coverage-jest/lcov-report/favicon.png +0 -0
  130. package/src/artifacts/coverage-jest/lcov-report/hooks/index.html +251 -0
  131. package/src/artifacts/coverage-jest/lcov-report/hooks/index.js.html +115 -0
  132. package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/index.html +146 -0
  133. package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/index.js.html +91 -0
  134. package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/useSettingSection.js.html +163 -0
  135. package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/useSettings.js.html +403 -0
  136. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/index.html +161 -0
  137. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/index.js.html +94 -0
  138. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedown.js.html +520 -0
  139. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedownData.js.html +163 -0
  140. package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedownToggle.js.html +163 -0
  141. package/src/artifacts/coverage-jest/lcov-report/hooks/useActiveElement.js.html +157 -0
  142. package/src/artifacts/coverage-jest/lcov-report/hooks/useHelperApp.js.html +283 -0
  143. package/src/artifacts/coverage-jest/lcov-report/hooks/useKiwtFieldArray.js.html +274 -0
  144. package/src/artifacts/coverage-jest/lcov-report/hooks/useKiwtSASQuery.js.html +178 -0
  145. package/src/artifacts/coverage-jest/lcov-report/hooks/useLocalStorageState.js.html +136 -0
  146. package/src/artifacts/coverage-jest/lcov-report/hooks/useMutateRefdataValue.js.html +301 -0
  147. package/src/artifacts/coverage-jest/lcov-report/hooks/useQIndex.js.html +208 -0
  148. package/src/artifacts/coverage-jest/lcov-report/hooks/useRefdata.js.html +268 -0
  149. package/src/artifacts/coverage-jest/lcov-report/hooks/useTemplates.js.html +166 -0
  150. package/src/artifacts/coverage-jest/lcov-report/index.html +401 -0
  151. package/src/artifacts/coverage-jest/lcov-report/prettify.css +1 -0
  152. package/src/artifacts/coverage-jest/lcov-report/prettify.js +2 -0
  153. package/src/artifacts/coverage-jest/lcov-report/sort-arrow-sprite.png +0 -0
  154. package/src/artifacts/coverage-jest/lcov-report/sorter.js +196 -0
  155. package/src/artifacts/coverage-jest/lcov-report/utils/buildUrl.js.html +193 -0
  156. package/src/artifacts/coverage-jest/lcov-report/utils/generateKiwtQuery.js.html +109 -0
  157. package/src/artifacts/coverage-jest/lcov-report/utils/generateKiwtQueryParams.js.html +286 -0
  158. package/src/artifacts/coverage-jest/lcov-report/utils/index.html +236 -0
  159. package/src/artifacts/coverage-jest/lcov-report/utils/index.js.html +121 -0
  160. package/src/artifacts/coverage-jest/lcov-report/utils/refdataOptions.js.html +106 -0
  161. package/src/artifacts/coverage-jest/lcov-report/utils/renderHelpText.js.html +166 -0
  162. package/src/artifacts/coverage-jest/lcov-report/utils/selectorSafe.js.html +103 -0
  163. package/src/artifacts/coverage-jest/lcov-report/utils/sortByLabel.js.html +130 -0
  164. package/src/artifacts/coverage-jest/lcov-report/utils/toCamelCase.js.html +127 -0
  165. package/src/artifacts/coverage-jest/lcov.info +1999 -0
  166. package/src/index.js +21 -6
  167. package/src/lib/ActionList/ActionList.js +5 -2
  168. package/src/lib/ActionList/ActionListFieldArray.js +20 -8
  169. package/src/lib/ActionList/README.md +1 -0
  170. package/src/lib/ActionList/index.js +1 -1
  171. package/src/lib/EditableRefdataList/EditableRefdataList.js +10 -5
  172. package/src/lib/EditableRefdataList/index.js +1 -1
  173. package/src/lib/{Settings → EditableSettingsList}/EditableSettingsList.js +0 -0
  174. package/src/lib/{Settings → EditableSettingsList}/EditableSettingsListFieldArray.js +2 -2
  175. package/src/lib/EditableSettingsList/EditableSettingsListFieldArray.test.js +111 -0
  176. package/src/lib/{Settings → EditableSettingsList/SettingField}/EditSettingValue.js +24 -1
  177. package/src/lib/EditableSettingsList/SettingField/EditSettingValue.test.js +379 -0
  178. package/src/lib/{Settings → EditableSettingsList/SettingField}/RenderSettingValue.js +2 -1
  179. package/src/lib/EditableSettingsList/SettingField/RenderSettingValue.test.js +368 -0
  180. package/src/lib/{Settings → EditableSettingsList/SettingField}/SettingField.js +7 -7
  181. package/src/lib/EditableSettingsList/SettingField/SettingField.test.js +80 -0
  182. package/src/lib/EditableSettingsList/SettingField/index.js +3 -0
  183. package/src/lib/EditableSettingsList/index.js +3 -0
  184. package/src/lib/NoResultsMessage/NoResultsMessage.js +78 -0
  185. package/src/lib/NoResultsMessage/index.js +1 -0
  186. package/src/lib/{Settings → RefdataButtons}/RefdataButtons.js +1 -1
  187. package/src/lib/RefdataButtons/index.js +1 -0
  188. package/src/lib/SASQLookupComponent/SASQLookupComponent.js +36 -8
  189. package/src/lib/SASQRoute/README.md +1 -1
  190. package/src/lib/{Settings → SettingPage}/SettingPage.js +5 -5
  191. package/src/lib/{Settings → SettingPage}/SettingPagePane.js +12 -2
  192. package/src/lib/SettingPage/index.js +2 -0
  193. package/src/lib/TypeDown/README.md +1 -115
  194. package/src/lib/TypeDown/TypeDown.js +4 -2
  195. package/src/lib/Typedown/Typedown.js +2 -1
  196. package/src/lib/{Settings → contexts}/SettingsContext.js +1 -1
  197. package/src/lib/contexts/index.js +2 -0
  198. package/src/lib/hooks/README.md +107 -0
  199. package/src/lib/hooks/index.js +3 -0
  200. package/src/lib/hooks/settingsHooks/index.js +2 -0
  201. package/src/lib/{Settings → hooks/settingsHooks}/useSettingSection.js +0 -0
  202. package/src/lib/{Settings → hooks/settingsHooks}/useSettings.js +14 -6
  203. package/src/lib/hooks/typedownHooks/index.js +0 -3
  204. package/src/lib/hooks/typedownHooks/useTypedown.js +93 -11
  205. package/src/lib/hooks/useHelperApp.js +5 -1
  206. package/src/lib/hooks/useKiwtFieldArray.js +63 -0
  207. package/src/lib/hooks/useKiwtSASQuery.js +9 -1
  208. package/src/lib/hooks/useQIndex.js +41 -0
  209. package/src/lib/hooks/useRefdata.js +17 -6
  210. package/src/lib/utils/README.md +39 -1
  211. package/src/lib/utils/generateKiwtQuery.js +3 -62
  212. package/src/lib/utils/generateKiwtQueryParams.js +67 -0
  213. package/src/lib/utils/index.js +10 -0
  214. package/src/lib/utils/refdataOptions.js +7 -0
  215. package/src/lib/{Settings/utils → utils}/renderHelpText.js +1 -1
  216. package/src/lib/{Settings/utils → utils}/sortByLabel.js +1 -1
  217. package/src/lib/{Settings/utils → utils}/toCamelCase.js +0 -0
  218. package/styles/NoResultsMessage.css +38 -0
  219. package/test/helpers/index.js +1 -0
  220. package/test/helpers/translationsProperties.js +40 -0
  221. package/test/jest/helpers/KintHarness.js +36 -0
  222. package/test/jest/helpers/index.js +2 -0
  223. package/test/jest/helpers/renderWithKintHarness.js +15 -0
  224. package/test/jest/jest-transformer.js +4 -0
  225. package/test/jest/setupTests.js +1 -0
  226. package/translations/stripes-kint-components/en.json +4 -1
  227. package/babelOptions.js +0 -30
  228. package/es/lib/Settings/EditableSettingsList.js +0 -57
  229. package/es/lib/Settings/EditableSettingsListFieldArray.js +0 -59
  230. package/es/lib/Settings/RefdataButtons.js +0 -100
  231. package/es/lib/Settings/SettingField.js +0 -144
  232. package/es/lib/Settings/SettingPage.js +0 -64
  233. package/es/lib/Settings/SettingPagePane.js +0 -43
  234. package/es/lib/Settings/SettingsContext.js +0 -18
  235. package/es/lib/Settings/index.js +0 -71
  236. package/es/lib/Settings/useSettingSection.js +0 -41
  237. package/es/lib/Settings/useSettings.js +0 -126
  238. package/es/lib/Settings/utils/index.js +0 -31
  239. package/es/lib/Settings/utils/renderHelpText.js +0 -57
  240. package/es/lib/Settings/utils/sortByLabel.js +0 -26
  241. package/es/lib/Settings/utils/toCamelCase.js +0 -19
  242. package/es/lib/hooks/typedownHooks/useTypedownFooter.js +0 -47
  243. package/es/lib/hooks/typedownHooks/useTypedownList.js +0 -45
  244. package/es/lib/hooks/typedownHooks/useTypedownSearchField.js +0 -47
  245. package/es/lib/utils/getFocusableElements.js +0 -132
  246. package/src/lib/Settings/index.js +0 -8
  247. package/src/lib/Settings/utils/index.js +0 -3
  248. package/src/lib/hooks/typedownHooks/useTypedownFooter.js +0 -43
  249. package/src/lib/hooks/typedownHooks/useTypedownList.js +0 -36
  250. package/src/lib/hooks/typedownHooks/useTypedownSearchField.js +0 -39
  251. package/src/lib/utils/getFocusableElements.js +0 -99
@@ -0,0 +1,368 @@
1
+ import React from 'react';
2
+ import '@folio/stripes-erm-components/test/jest/__mock__';
3
+ import RenderSettingValue from './RenderSettingValue';
4
+
5
+ import { renderWithKintHarness } from '../../../../test/jest/helpers';
6
+
7
+
8
+ const stringSetting = {
9
+ id: '12345',
10
+ key: 'testSettingKey',
11
+ section: 'testSettingSection',
12
+ settingType: 'String',
13
+ value: 'diku-shared',
14
+ };
15
+
16
+ const stringSettingNoValue = {
17
+ id: '12345',
18
+ key: 'testSettingKey',
19
+ section: 'testSettingSection',
20
+ settingType: 'String',
21
+ defValue: 'diku-shared',
22
+ };
23
+
24
+ const stringSettingNoValueOrDefault = {
25
+ id: '12345',
26
+ key: 'testSettingKey',
27
+ section: 'testSettingSection',
28
+ settingType: 'String'
29
+ };
30
+
31
+ const passwordSetting = {
32
+ id: '12345',
33
+ key: 'testSettingKey',
34
+ section: 'testSettingSection',
35
+ settingType: 'Password',
36
+ value: 'secret password',
37
+ };
38
+
39
+ const passwordSettingNoValue = {
40
+ id: '12345',
41
+ key: 'testSettingKey',
42
+ section: 'testSettingSection',
43
+ settingType: 'Password',
44
+ defValue: 'secret password',
45
+ };
46
+
47
+ const passwordSettingNoValueOrDefault = {
48
+ id: '12345',
49
+ key: 'testSettingKey',
50
+ section: 'testSettingSection',
51
+ settingType: 'Password'
52
+ };
53
+
54
+ const refdata = [
55
+ {
56
+ value: 'test_refdata_value',
57
+ label: 'Test refdata value'
58
+ },
59
+ {
60
+ value: 'other_refdata_value',
61
+ label: 'Other refdata value'
62
+ },
63
+ {
64
+ value: 'final_refdata_value',
65
+ label: 'Final refdata value'
66
+ }
67
+ ];
68
+
69
+ const refdataSetting = {
70
+ id: '12345',
71
+ key: 'testSettingKey',
72
+ section: 'testSettingSection',
73
+ settingType: 'Refdata',
74
+ value: 'test_refdata_value',
75
+ };
76
+
77
+ const refdataSettingNoValue = {
78
+ id: '12345',
79
+ key: 'testSettingKey',
80
+ section: 'testSettingSection',
81
+ settingType: 'Refdata',
82
+ defValue: 'test_refdata_value',
83
+ };
84
+
85
+ const refdataSettingNoValueOrDefault = {
86
+ id: '12345',
87
+ key: 'testSettingKey',
88
+ section: 'testSettingSection',
89
+ settingType: 'Refdata'
90
+ };
91
+
92
+ const templates = [
93
+ {
94
+ id: 'abcde',
95
+ name: 'Test template'
96
+ },
97
+ {
98
+ id: '98765',
99
+ name: 'Red herring template'
100
+ },
101
+ ];
102
+
103
+ const templateSetting = {
104
+ id: '12345',
105
+ key: 'testSettingKey',
106
+ section: 'testSettingSection',
107
+ settingType: 'Template',
108
+ value: 'abcde',
109
+ };
110
+
111
+ const templateSettingNoValue = {
112
+ id: '12345',
113
+ key: 'testSettingKey',
114
+ section: 'testSettingSection',
115
+ settingType: 'Template',
116
+ defValue: 'abcde',
117
+ };
118
+
119
+ const templateSettingNoValueOrDefault = {
120
+ id: '12345',
121
+ key: 'testSettingKey',
122
+ section: 'testSettingSection',
123
+ settingType: 'Template'
124
+ };
125
+
126
+ describe('RenderSettingValue', () => {
127
+ describe('render string settings', () => {
128
+ describe('render a string setting', () => {
129
+ let renderComponent;
130
+ beforeEach(async () => {
131
+ renderComponent = renderWithKintHarness(
132
+ <RenderSettingValue
133
+ currentSetting={stringSetting}
134
+ input={{
135
+ name: 'test'
136
+ }}
137
+ />
138
+ );
139
+ });
140
+
141
+ it('renders the value', () => {
142
+ const { getByText } = renderComponent;
143
+ expect(getByText('diku-shared')).toBeInTheDocument();
144
+ });
145
+ });
146
+
147
+ describe('render a string setting without a value', () => {
148
+ let renderComponent;
149
+ beforeEach(async () => {
150
+ renderComponent = renderWithKintHarness(
151
+ <RenderSettingValue
152
+ currentSetting={stringSettingNoValue}
153
+ input={{
154
+ name: 'test'
155
+ }}
156
+ />
157
+ );
158
+ });
159
+
160
+ it('renders the default value', () => {
161
+ const { getByText } = renderComponent;
162
+ expect(getByText('[default] diku-shared')).toBeInTheDocument();
163
+ });
164
+ });
165
+
166
+ describe('render a string setting without a value or default', () => {
167
+ let renderComponent;
168
+ beforeEach(async () => {
169
+ renderComponent = renderWithKintHarness(
170
+ <RenderSettingValue
171
+ currentSetting={stringSettingNoValueOrDefault}
172
+ input={{
173
+ name: 'test'
174
+ }}
175
+ />
176
+ );
177
+ });
178
+
179
+ it('renders the empty message', () => {
180
+ const { getByText } = renderComponent;
181
+ expect(getByText('No current value')).toBeInTheDocument();
182
+ });
183
+ });
184
+ });
185
+
186
+ describe('render refdata settings', () => {
187
+ describe('render a refdata setting', () => {
188
+ let renderComponent;
189
+ beforeEach(async () => {
190
+ renderComponent = renderWithKintHarness(
191
+ <RenderSettingValue
192
+ currentSetting={refdataSetting}
193
+ input={{
194
+ name: 'test'
195
+ }}
196
+ refdata={refdata}
197
+ />
198
+ );
199
+ });
200
+
201
+ it('renders the value', () => {
202
+ const { getByText } = renderComponent;
203
+ expect(getByText('Test refdata value')).toBeInTheDocument();
204
+ });
205
+ });
206
+
207
+ describe('render a refdata setting without a value', () => {
208
+ let renderComponent;
209
+ beforeEach(async () => {
210
+ renderComponent = renderWithKintHarness(
211
+ <RenderSettingValue
212
+ currentSetting={refdataSettingNoValue}
213
+ input={{
214
+ name: 'test'
215
+ }}
216
+ refdata={refdata}
217
+ />
218
+ );
219
+ });
220
+
221
+ it('renders the default value', () => {
222
+ const { getByText } = renderComponent;
223
+ expect(getByText('[default] Test refdata value')).toBeInTheDocument();
224
+ });
225
+ });
226
+
227
+ describe('render a refdata setting without a value or default', () => {
228
+ let renderComponent;
229
+ beforeEach(async () => {
230
+ renderComponent = renderWithKintHarness(
231
+ <RenderSettingValue
232
+ currentSetting={refdataSettingNoValueOrDefault}
233
+ input={{
234
+ name: 'test'
235
+ }}
236
+ refdata={refdata}
237
+ />
238
+ );
239
+ });
240
+
241
+ it('renders the empty message', () => {
242
+ const { getByText } = renderComponent;
243
+ expect(getByText('No current value')).toBeInTheDocument();
244
+ });
245
+ });
246
+ });
247
+
248
+ describe('render password settings', () => {
249
+ describe('render a password setting', () => {
250
+ let renderComponent;
251
+ beforeEach(async () => {
252
+ renderComponent = renderWithKintHarness(
253
+ <RenderSettingValue
254
+ currentSetting={passwordSetting}
255
+ input={{
256
+ name: 'test'
257
+ }}
258
+ />
259
+ );
260
+ });
261
+
262
+ it('renders the value', () => {
263
+ const { getByText } = renderComponent;
264
+ expect(getByText('********')).toBeInTheDocument();
265
+ });
266
+ });
267
+
268
+ describe('render a password setting without a value', () => {
269
+ let renderComponent;
270
+ beforeEach(async () => {
271
+ renderComponent = renderWithKintHarness(
272
+ <RenderSettingValue
273
+ currentSetting={passwordSettingNoValue}
274
+ input={{
275
+ name: 'test'
276
+ }}
277
+ />
278
+ );
279
+ });
280
+
281
+ it('renders the default value', () => {
282
+ const { getByText } = renderComponent;
283
+ expect(getByText('[default] ********')).toBeInTheDocument();
284
+ });
285
+ });
286
+
287
+ describe('render a password setting without a value or default', () => {
288
+ let renderComponent;
289
+ beforeEach(async () => {
290
+ renderComponent = renderWithKintHarness(
291
+ <RenderSettingValue
292
+ currentSetting={passwordSettingNoValueOrDefault}
293
+ input={{
294
+ name: 'test'
295
+ }}
296
+ />
297
+ );
298
+ });
299
+
300
+ it('renders the empty message', () => {
301
+ const { getByText } = renderComponent;
302
+ expect(getByText('No current value')).toBeInTheDocument();
303
+ });
304
+ });
305
+ });
306
+
307
+ describe('render template settings', () => {
308
+ describe('render a template setting', () => {
309
+ let renderComponent;
310
+ beforeEach(async () => {
311
+ renderComponent = renderWithKintHarness(
312
+ <RenderSettingValue
313
+ currentSetting={templateSetting}
314
+ input={{
315
+ name: 'test'
316
+ }}
317
+ templates={templates}
318
+ />
319
+ );
320
+ });
321
+
322
+ it('renders the value', () => {
323
+ const { getByText } = renderComponent;
324
+ expect(getByText('Test template')).toBeInTheDocument();
325
+ });
326
+ });
327
+
328
+ describe('render a template setting without a value', () => {
329
+ let renderComponent;
330
+ beforeEach(async () => {
331
+ renderComponent = renderWithKintHarness(
332
+ <RenderSettingValue
333
+ currentSetting={templateSettingNoValue}
334
+ input={{
335
+ name: 'test'
336
+ }}
337
+ templates={templates}
338
+ />
339
+ );
340
+ });
341
+
342
+ it('renders the default value', () => {
343
+ const { getByText } = renderComponent;
344
+ expect(getByText('Test template')).toBeInTheDocument(); // TODO this doesn't currently have a [default] marking on it
345
+ });
346
+ });
347
+
348
+ describe('render a template setting without a value or default', () => {
349
+ let renderComponent;
350
+ beforeEach(async () => {
351
+ renderComponent = renderWithKintHarness(
352
+ <RenderSettingValue
353
+ currentSetting={templateSettingNoValueOrDefault}
354
+ input={{
355
+ name: 'test'
356
+ }}
357
+ templates={templates}
358
+ />
359
+ );
360
+ });
361
+
362
+ it('renders the empty message', () => {
363
+ const { getByText } = renderComponent;
364
+ expect(getByText('No current value')).toBeInTheDocument();
365
+ });
366
+ });
367
+ });
368
+ });
@@ -9,9 +9,10 @@ import {
9
9
 
10
10
  import EditSettingValue from './EditSettingValue';
11
11
  import RenderSettingValue from './RenderSettingValue';
12
- import SettingsContext from './SettingsContext';
13
- import { useRefdata, useTemplates } from '../hooks';
14
- import { renderHelpText, toCamelCase } from './utils';
12
+ import { SettingsContext } from '../../contexts';
13
+ import { useRefdata, useTemplates } from '../../hooks';
14
+ import { renderHelpText, toCamelCase } from '../../utils';
15
+
15
16
 
16
17
  const SettingField = (settingFieldProps) => {
17
18
  const {
@@ -33,7 +34,7 @@ const SettingField = (settingFieldProps) => {
33
34
  endpoint: refdataEndpoint,
34
35
  desc: currentSetting.vocab,
35
36
  queryParams: {
36
- enabled: !!currentSetting?.vocab
37
+ enabled: !!currentSetting?.vocab && currentSetting.settingType === 'Refdata'
37
38
  }
38
39
  });
39
40
 
@@ -41,7 +42,7 @@ const SettingField = (settingFieldProps) => {
41
42
  context: currentSetting.vocab,
42
43
  endpoint: templateEndpoint,
43
44
  queryParams: {
44
- enabled: !!currentSetting?.vocab
45
+ enabled: !!currentSetting?.vocab && currentSetting.settingType === 'Template'
45
46
  }
46
47
  });
47
48
 
@@ -85,7 +86,7 @@ const SettingField = (settingFieldProps) => {
85
86
  {settingName}
86
87
  </>
87
88
  );
88
- }
89
+ };
89
90
 
90
91
  return (
91
92
  <Card
@@ -99,7 +100,6 @@ const SettingField = (settingFieldProps) => {
99
100
  templates={templates}
100
101
  {...settingFieldProps}
101
102
  />
102
-
103
103
  </Card>
104
104
  );
105
105
  };
@@ -0,0 +1,80 @@
1
+ import React from 'react';
2
+ import userEvent from '@testing-library/user-event';
3
+ import '@folio/stripes-erm-components/test/jest/__mock__';
4
+ import { TestForm } from '@folio/stripes-erm-components/test/jest/helpers';
5
+ import { Button } from '@folio/stripes-testing';
6
+ import { Field } from 'react-final-form';
7
+ import SettingField from './SettingField';
8
+
9
+ import { renderWithKintHarness } from '../../../../test/jest/helpers';
10
+
11
+ const onSubmit = jest.fn();
12
+ const onSave = jest.fn().mockResolvedValue();
13
+
14
+ jest.mock('./EditSettingValue', () => () => <div>EditSettingValue</div>);
15
+ jest.mock('./RenderSettingValue', () => () => <div>RenderSettingValue</div>);
16
+
17
+ jest.mock('../../hooks', () => ({
18
+ useRefdata: () => [],
19
+ useTemplates: () => [],
20
+ }));
21
+
22
+
23
+ const setting = {
24
+ id: 'ff8081817d94374a017d94449a660049',
25
+ key: 'S3BucketName',
26
+ section: 'fileStorage',
27
+ settingType: 'String',
28
+ value: 'diku-shared'
29
+ };
30
+
31
+ describe('SettingField', () => {
32
+ let renderComponent;
33
+ beforeEach(async () => {
34
+ renderComponent = renderWithKintHarness(
35
+ <TestForm
36
+ initialValues={{}}
37
+ onSubmit={onSubmit}
38
+ >
39
+ <Field
40
+ component={SettingField}
41
+ name="test"
42
+ onSave={onSave}
43
+ settingData={{
44
+ currentSetting: setting
45
+ }}
46
+ />
47
+ </TestForm>
48
+ );
49
+ });
50
+
51
+ it('renders RenderSettingValue', () => {
52
+ const { getByText } = renderComponent;
53
+ expect(getByText('RenderSettingValue')).toBeInTheDocument();
54
+ });
55
+
56
+ test('renders the edit button', () => {
57
+ Button('Edit').exists();
58
+ });
59
+
60
+ it('clicking edit/save works as expected', async () => {
61
+ const { getByRole, findByText } = renderComponent;
62
+
63
+ // before clicking on edit button, we should be rendering setting value
64
+ expect(await findByText('RenderSettingValue')).toBeInTheDocument();
65
+
66
+ // Clicking edit button
67
+ const editButton = getByRole('button', { name: /Edit/i });
68
+ expect(editButton).toBeInTheDocument();
69
+ userEvent.click(editButton);
70
+ // Should be rendering the "edit" for a setting value
71
+ expect(await findByText('EditSettingValue')).toBeInTheDocument();
72
+
73
+ // Clicking finish editing button
74
+ const finishEditing = getByRole('button', { name: /Finish editing/i });
75
+ expect(finishEditing).toBeInTheDocument();
76
+ userEvent.click(finishEditing);
77
+ // Should be rendering the setting value again
78
+ expect(await findByText('RenderSettingValue')).toBeInTheDocument();
79
+ });
80
+ });
@@ -0,0 +1,3 @@
1
+ export { default as SettingField } from './SettingField';
2
+ export { default as RenderSettingValue } from './RenderSettingValue';
3
+ export { default as EditSettingValue } from './EditSettingValue';
@@ -0,0 +1,3 @@
1
+ export { default as EditableSettingsList } from './EditableSettingsList';
2
+ export { default as EditableSettingsListFieldArray } from './EditableSettingsListFieldArray';
3
+ export { SettingField } from './SettingField';
@@ -0,0 +1,78 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { FormattedMessage } from 'react-intl';
4
+ import { Button, Icon } from '@folio/stripes/components';
5
+ import css from '../../../styles/NoResultsMessage.css';
6
+
7
+ const NoResultsMessage = ({
8
+ icon: userIcon,
9
+ isLoading,
10
+ isError,
11
+ error,
12
+ filterPaneIsVisible,
13
+ label: userLabel,
14
+ searchTerm,
15
+ toggleFilterPane,
16
+ }) => {
17
+ let icon = 'search';
18
+ let label = <FormattedMessage id="stripes-smart-components.sas.noResults.default" values={{ searchTerm }} />;
19
+
20
+ // No search term but no results
21
+ if (!searchTerm) {
22
+ icon = 'search';
23
+ label = <FormattedMessage id="stripes-smart-components.sas.noResults.noResults" />;
24
+ }
25
+
26
+ // Loading results
27
+ if (isLoading) {
28
+ icon = 'spinner-ellipsis';
29
+ label = <FormattedMessage id="stripes-smart-components.sas.noResults.loading" />;
30
+ }
31
+
32
+ // Request failure
33
+ if (isError) {
34
+ icon = 'exclamation-circle';
35
+ label = error?.message;
36
+ }
37
+
38
+ return (
39
+ <div className={css.noResultsMessage}>
40
+ <div className={css.noResultsMessageLabelWrap}>
41
+ {(icon || userIcon) &&
42
+ <Icon
43
+ icon={userIcon ?? icon}
44
+ iconRootClass={css.noResultsMessageIcon}
45
+ />
46
+ }
47
+ <span className={css.noResultsMessageLabel}>{userLabel ?? label}</span>
48
+ </div>
49
+ {/* If the filter pane is closed we show a button that toggles filter pane */}
50
+ {!filterPaneIsVisible && (
51
+ <Button
52
+ buttonClass={css.noResultsMessageButton}
53
+ marginBottom0
54
+ onClick={toggleFilterPane}
55
+ >
56
+ <FormattedMessage id="stripes-kint-components.noResultsMessage.showFilters" />
57
+ </Button>
58
+ )}
59
+ </div>
60
+ );
61
+ };
62
+
63
+ NoResultsMessage.propTypes = {
64
+ error: PropTypes.object,
65
+ filterPaneIsVisible: PropTypes.bool.isRequired,
66
+ icon: PropTypes.string,
67
+ isLoading: PropTypes.bool,
68
+ isError: PropTypes.bool,
69
+ label: PropTypes.oneOfType(
70
+ PropTypes.string,
71
+ PropTypes.node,
72
+ PropTypes.func
73
+ ),
74
+ searchTerm: PropTypes.string.isRequired,
75
+ toggleFilterPane: PropTypes.func.isRequired,
76
+ };
77
+
78
+ export default NoResultsMessage;
@@ -0,0 +1 @@
1
+ export { default } from './NoResultsMessage';
@@ -27,7 +27,7 @@ const RefdataButtons = (props) => {
27
27
  };
28
28
 
29
29
  return (
30
- <Col xs={dynamicColumnWidth ? (12 / numberOfButtons) : (12 / maximumColumns)} key={`${input.name}:${option.id}`}>
30
+ <Col key={`${input.name}:${option.id}`} xs={dynamicColumnWidth ? (12 / numberOfButtons) : (12 / maximumColumns)}>
31
31
  <RadioButton
32
32
  {...buttonProps}
33
33
  />
@@ -0,0 +1 @@
1
+ export { default } from './RefdataButtons';
@@ -20,15 +20,18 @@ import {
20
20
  MultiColumnList,
21
21
  Pane,
22
22
  PaneMenu,
23
- SearchField
23
+ SearchField,
24
24
  } from '@folio/stripes/components';
25
+ import NoResultsMessage from '../NoResultsMessage';
25
26
 
26
27
  import { generateKiwtQuery } from '../utils';
27
28
  import { useKiwtSASQuery, useLocalStorageState } from '../hooks';
28
29
 
30
+
29
31
  const SASQLookupComponent = ({
30
32
  children,
31
33
  fetchParameters = {},
34
+ FilterPaneHeaderComponent = () => null,
32
35
  FilterComponent = () => null,
33
36
  history,
34
37
  id,
@@ -55,7 +58,15 @@ const SASQLookupComponent = ({
55
58
  };
56
59
 
57
60
  const [filterPaneVisible, setFilterPaneVisible] = useLocalStorageState(filterPaneVisibileKey, true);
58
- const { data: totalData = {}, fetchNextPage } = useInfiniteQuery(
61
+ const toggleFilterPane = () => setFilterPaneVisible(!filterPaneVisible);
62
+
63
+ const {
64
+ data: totalData = {},
65
+ error,
66
+ isError,
67
+ isLoading,
68
+ fetchNextPage,
69
+ } = useInfiniteQuery(
59
70
  [namespace, id, 'data', query],
60
71
  fetchPageData
61
72
  );
@@ -88,13 +99,13 @@ const SASQLookupComponent = ({
88
99
  fetchNextPage({ pageParam: index });
89
100
  };
90
101
 
91
- // Build the map of column definitions
92
- const columnMapping = Object.fromEntries(
93
- resultColumns.map(e => [e.propertyPath, e.label])
94
- );
102
+ // Build the map of column definitions
103
+ const columnMapping = Object.fromEntries(
104
+ resultColumns.map(e => [e.propertyPath, e.label])
105
+ );
95
106
 
96
- // Build the list of visible columns
97
- const visibleColumns = resultColumns.map(e => e.propertyPath);
107
+ // Build the list of visible columns
108
+ const visibleColumns = resultColumns.map(e => e.propertyPath);
98
109
 
99
110
  return (
100
111
  <SearchAndSortQuery
@@ -126,6 +137,18 @@ const SASQLookupComponent = ({
126
137
  autosize
127
138
  columnMapping={columnMapping}
128
139
  contentData={data?.results}
140
+ isEmptyMessage={
141
+ <NoResultsMessage
142
+ {...{
143
+ error,
144
+ isError,
145
+ isLoading,
146
+ filterPaneIsVisible: filterPaneVisible,
147
+ searchTerm: query.query,
148
+ toggleFilterPane
149
+ }}
150
+ />
151
+ }
129
152
  isSelected={({ item }) => item.id === match?.params?.id}
130
153
  onHeaderClick={onSort}
131
154
  onNeedMoreData={onNeedMoreData}
@@ -163,6 +186,7 @@ const SASQLookupComponent = ({
163
186
  paneTitle={<FormattedMessage id="stripes-smart-components.searchAndFilter" />}
164
187
  >
165
188
  <form onSubmit={onSubmitSearch}>
189
+ <FilterPaneHeaderComponent />
166
190
  {!noSearchField &&
167
191
  <>
168
192
  <SearchField
@@ -240,6 +264,10 @@ SASQLookupComponent.propTypes = {
240
264
  PropTypes.func,
241
265
  PropTypes.node
242
266
  ]),
267
+ FilterPaneHeaderComponent: PropTypes.oneOfType([
268
+ PropTypes.func,
269
+ PropTypes.node
270
+ ]),
243
271
  history: PropTypes.object,
244
272
  id: PropTypes.string.isRequired,
245
273
  location: PropTypes.object,
@@ -6,7 +6,7 @@ A component designed to speed up the basic 3-pane layout setup process, SASQRout
6
6
  import React from 'react';
7
7
  import { FormattedMessage } from 'react-intl';
8
8
 
9
- import SASQRoute from '@k-int/stripes-kint-components/src/lib/SASQRoute/SASQRoute';
9
+ import { SASQRoute } from '@k-int/stripes-kint-components';
10
10
  import ActionItem from '../components/ActionItem';
11
11
 
12
12
  const ActionedRoute = ({ path }) => {