@k-int/stripes-kint-components 1.5.0 → 2.0.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.
- package/CHANGELOG.md +40 -1
- package/es/index.js +80 -25
- package/es/lib/ActionList/ActionList.js +92 -33
- package/es/lib/ActionList/ActionListFieldArray.js +202 -104
- package/es/lib/ActionList/index.js +7 -3
- package/es/lib/CustomProperties/Config/CustomPropertiesLookup.js +198 -0
- package/es/lib/CustomProperties/Config/CustomPropertiesSettings.js +321 -0
- package/es/lib/CustomProperties/Config/CustomPropertiesView.js +166 -0
- package/es/lib/CustomProperties/Config/CustomPropertyForm.js +357 -0
- package/es/lib/CustomProperties/Config/index.js +41 -0
- package/es/lib/EditableRefdataList/EditableRefdataList.js +69 -24
- package/es/lib/EditableRefdataList/index.js +7 -3
- package/es/lib/EditableSettingsList/EditableSettingsList.js +90 -0
- package/es/lib/EditableSettingsList/EditableSettingsListFieldArray.js +90 -0
- package/es/lib/EditableSettingsList/EditableSettingsListFieldArray.test.js +181 -0
- package/es/lib/{Settings → EditableSettingsList/SettingField}/EditSettingValue.js +72 -9
- package/es/lib/EditableSettingsList/SettingField/EditSettingValue.test.js +447 -0
- package/es/lib/{Settings → EditableSettingsList/SettingField}/RenderSettingValue.js +45 -7
- package/es/lib/EditableSettingsList/SettingField/RenderSettingValue.test.js +495 -0
- package/es/lib/EditableSettingsList/SettingField/SettingField.js +187 -0
- package/es/lib/EditableSettingsList/SettingField/SettingField.test.js +180 -0
- package/es/lib/EditableSettingsList/SettingField/index.js +35 -0
- package/es/lib/EditableSettingsList/index.js +35 -0
- package/es/lib/FormModal/FormModal.js +126 -0
- package/es/lib/FormModal/index.js +19 -0
- package/es/lib/NoResultsMessage/NoResultsMessage.js +65 -32
- package/es/lib/NoResultsMessage/index.js +7 -3
- package/es/lib/QueryTypedown/QueryTypedown.js +48 -9
- package/es/lib/QueryTypedown/index.js +6 -2
- package/es/lib/RefdataButtons/RefdataButtons.js +143 -0
- package/es/lib/RefdataButtons/index.js +19 -0
- package/es/lib/SASQLookupComponent/SASQLookupComponent.js +194 -140
- package/es/lib/SASQLookupComponent/index.js +6 -2
- package/es/lib/SASQRoute/SASQRoute.js +55 -18
- package/es/lib/SASQRoute/index.js +6 -2
- package/es/lib/SASQViewComponent/SASQViewComponent.js +50 -11
- package/es/lib/SASQViewComponent/index.js +6 -2
- package/es/lib/SearchField/SearchField.js +48 -13
- package/es/lib/SearchField/index.js +6 -2
- package/es/lib/SettingPage/SettingPage.js +99 -0
- package/es/lib/SettingPage/SettingPagePane.js +83 -0
- package/es/lib/SettingPage/index.js +27 -0
- package/es/lib/Typedown/Typedown.js +174 -99
- package/es/lib/Typedown/index.js +6 -2
- package/es/lib/constants/customProperties.js +60 -0
- package/es/lib/constants/eventCodes.js +31 -1
- package/es/lib/contexts/SettingsContext.js +41 -0
- package/es/lib/contexts/index.js +19 -0
- package/es/lib/hooks/index.js +44 -10
- package/es/lib/hooks/settingsHooks/index.js +27 -0
- package/es/lib/hooks/settingsHooks/useSettingSection.js +74 -0
- package/es/lib/hooks/settingsHooks/useSettings.js +175 -0
- package/es/lib/hooks/typedownHooks/index.js +8 -28
- package/es/lib/hooks/typedownHooks/useTypedown.js +129 -12
- package/es/lib/hooks/typedownHooks/useTypedownData.js +35 -2
- package/es/lib/hooks/typedownHooks/useTypedownToggle.js +39 -6
- package/es/lib/hooks/useActiveElement.js +33 -2
- package/es/lib/hooks/useCustomProperties.js +112 -0
- package/es/lib/hooks/useHelperApp.js +44 -11
- package/es/lib/hooks/useKiwtFieldArray.js +37 -4
- package/es/lib/hooks/useKiwtSASQuery.js +43 -9
- package/es/lib/hooks/useLocalStorageState.js +37 -4
- package/es/lib/hooks/useMutateCustomProperties.js +143 -0
- package/es/lib/hooks/useMutateRefdataValue.js +42 -9
- package/es/lib/hooks/useQIndex.js +42 -9
- package/es/lib/hooks/useRefdata.js +43 -16
- package/es/lib/hooks/useTemplates.js +36 -3
- package/es/lib/utils/buildUrl.js +43 -10
- package/es/lib/utils/generateKiwtQuery.js +33 -4
- package/es/lib/utils/generateKiwtQueryParams.js +31 -2
- package/es/lib/utils/index.js +41 -5
- package/es/lib/utils/refdataOptions.js +43 -0
- package/es/lib/utils/renderHelpText.js +109 -0
- package/es/lib/utils/selectorSafe.js +31 -2
- package/es/lib/utils/sortByLabel.js +55 -0
- package/es/lib/utils/toCamelCase.js +48 -0
- package/jest.config.js +15 -1
- package/package.json +19 -10
- package/src/index.js +25 -10
- package/src/lib/ActionList/ActionList.js +32 -22
- package/src/lib/ActionList/ActionListFieldArray.js +56 -10
- package/src/lib/ActionList/README.md +5 -1
- package/src/lib/ActionList/index.js +1 -1
- package/src/lib/CustomProperties/Config/CustomPropertiesLookup.js +111 -0
- package/src/lib/CustomProperties/Config/CustomPropertiesSettings.js +237 -0
- package/src/lib/CustomProperties/Config/CustomPropertiesView.js +150 -0
- package/src/lib/CustomProperties/Config/CustomPropertyForm.js +295 -0
- package/src/lib/CustomProperties/Config/index.js +4 -0
- package/src/lib/EditableRefdataList/EditableRefdataList.js +10 -5
- package/src/lib/EditableRefdataList/index.js +1 -1
- package/src/lib/{Settings → EditableSettingsList}/EditableSettingsList.js +0 -0
- package/src/lib/{Settings → EditableSettingsList}/EditableSettingsListFieldArray.js +2 -2
- package/src/lib/EditableSettingsList/EditableSettingsListFieldArray.test.js +111 -0
- package/src/lib/{Settings → EditableSettingsList/SettingField}/EditSettingValue.js +24 -1
- package/src/lib/EditableSettingsList/SettingField/EditSettingValue.test.js +379 -0
- package/src/lib/{Settings → EditableSettingsList/SettingField}/RenderSettingValue.js +2 -1
- package/src/lib/EditableSettingsList/SettingField/RenderSettingValue.test.js +368 -0
- package/src/lib/{Settings → EditableSettingsList/SettingField}/SettingField.js +7 -7
- package/src/lib/EditableSettingsList/SettingField/SettingField.test.js +80 -0
- package/src/lib/EditableSettingsList/SettingField/index.js +3 -0
- package/src/lib/EditableSettingsList/index.js +3 -0
- package/src/lib/FormModal/FormModal.js +71 -0
- package/src/lib/FormModal/index.js +1 -0
- package/src/lib/NoResultsMessage/NoResultsMessage.js +2 -2
- package/src/lib/NoResultsMessage/index.js +1 -1
- package/src/lib/{Settings → RefdataButtons}/RefdataButtons.js +1 -1
- package/src/lib/RefdataButtons/index.js +1 -0
- package/src/lib/SASQLookupComponent/SASQLookupComponent.js +7 -1
- package/src/lib/{Settings → SettingPage}/SettingPage.js +5 -5
- package/src/lib/{Settings → SettingPage}/SettingPagePane.js +12 -2
- package/src/lib/SettingPage/index.js +2 -0
- package/src/lib/Typedown/Typedown.js +52 -9
- package/src/lib/constants/customProperties.js +9 -0
- package/src/lib/{Settings → contexts}/SettingsContext.js +1 -1
- package/src/lib/contexts/index.js +2 -0
- package/src/lib/hooks/index.js +3 -0
- package/src/lib/hooks/settingsHooks/index.js +2 -0
- package/src/lib/{Settings → hooks/settingsHooks}/useSettingSection.js +0 -0
- package/src/lib/{Settings → hooks/settingsHooks}/useSettings.js +14 -6
- package/src/lib/hooks/typedownHooks/index.js +0 -3
- package/src/lib/hooks/typedownHooks/useTypedown.js +93 -11
- package/src/lib/hooks/useCustomProperties.js +73 -0
- package/src/lib/hooks/useMutateCustomProperties.js +62 -0
- package/src/lib/hooks/useRefdata.js +2 -8
- package/src/lib/utils/index.js +7 -0
- package/src/lib/utils/refdataOptions.js +7 -0
- package/src/lib/{Settings/utils → utils}/renderHelpText.js +1 -1
- package/src/lib/{Settings/utils → utils}/sortByLabel.js +1 -1
- package/src/lib/{Settings/utils → utils}/toCamelCase.js +0 -0
- package/test/helpers/index.js +1 -0
- package/test/helpers/translationsProperties.js +40 -0
- package/test/jest/helpers/KintHarness.js +36 -0
- package/test/jest/helpers/index.js +2 -0
- package/test/jest/helpers/renderWithKintHarness.js +15 -0
- package/test/jest/jest-transformer.js +4 -0
- package/test/jest/setupTests.js +1 -0
- package/translations/stripes-kint-components/en.json +48 -1
- package/yarn-error.log +14118 -0
- package/babelOptions.js +0 -30
- package/es/lib/Settings/EditableSettingsList.js +0 -57
- package/es/lib/Settings/EditableSettingsListFieldArray.js +0 -59
- package/es/lib/Settings/RefdataButtons.js +0 -100
- package/es/lib/Settings/SettingField.js +0 -144
- package/es/lib/Settings/SettingPage.js +0 -64
- package/es/lib/Settings/SettingPagePane.js +0 -43
- package/es/lib/Settings/SettingsContext.js +0 -18
- package/es/lib/Settings/index.js +0 -71
- package/es/lib/Settings/useSettingSection.js +0 -41
- package/es/lib/Settings/useSettings.js +0 -126
- package/es/lib/Settings/utils/index.js +0 -31
- package/es/lib/Settings/utils/renderHelpText.js +0 -57
- package/es/lib/Settings/utils/sortByLabel.js +0 -26
- package/es/lib/Settings/utils/toCamelCase.js +0 -19
- package/es/lib/TypeDown/TypeDown.js +0 -209
- package/es/lib/TypeDown/index.js +0 -15
- package/es/lib/hooks/typedownHooks/useTypedownFooter.js +0 -47
- package/es/lib/hooks/typedownHooks/useTypedownList.js +0 -45
- package/es/lib/hooks/typedownHooks/useTypedownSearchField.js +0 -47
- package/es/lib/utils/getFocusableElements.js +0 -132
- package/src/lib/Settings/index.js +0 -8
- package/src/lib/Settings/utils/index.js +0 -3
- package/src/lib/TypeDown/README.md +0 -1
- package/src/lib/TypeDown/TypeDown.js +0 -226
- package/src/lib/TypeDown/index.js +0 -1
- package/src/lib/hooks/typedownHooks/useTypedownFooter.js +0 -43
- package/src/lib/hooks/typedownHooks/useTypedownList.js +0 -36
- package/src/lib/hooks/typedownHooks/useTypedownSearchField.js +0 -39
- 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 '
|
|
13
|
-
import { useRefdata, useTemplates } from '
|
|
14
|
-
import { renderHelpText, toCamelCase } from '
|
|
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,71 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
|
|
3
|
+
import { Form } from 'react-final-form';
|
|
4
|
+
import { FormattedMessage } from 'react-intl';
|
|
5
|
+
import { Button, Modal, ModalFooter } from '@folio/stripes/components';
|
|
6
|
+
|
|
7
|
+
const FormModal = ({ children, modalProps: { onClose, ...modalProps }, onSubmit, ...formProps }) => {
|
|
8
|
+
return (
|
|
9
|
+
<Form
|
|
10
|
+
onSubmit={onSubmit}
|
|
11
|
+
{...formProps}
|
|
12
|
+
>
|
|
13
|
+
{({ handleSubmit, form: { restart } }) => {
|
|
14
|
+
const handleClose = (e) => {
|
|
15
|
+
onClose(e);
|
|
16
|
+
restart();
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const handleSubmitAndClear = () => {
|
|
20
|
+
handleSubmit();
|
|
21
|
+
restart();
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const renderFooter = () => (
|
|
25
|
+
<ModalFooter>
|
|
26
|
+
<Button
|
|
27
|
+
buttonStyle="primary"
|
|
28
|
+
onClick={handleSubmitAndClear}
|
|
29
|
+
>
|
|
30
|
+
<FormattedMessage id="stripes-kint-components.save" />
|
|
31
|
+
</Button>
|
|
32
|
+
<Button
|
|
33
|
+
onClick={handleClose}
|
|
34
|
+
>
|
|
35
|
+
<FormattedMessage id="stripes-kint-components.cancel" />
|
|
36
|
+
</Button>
|
|
37
|
+
</ModalFooter>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<form
|
|
42
|
+
onSubmit={handleSubmitAndClear}
|
|
43
|
+
>
|
|
44
|
+
<Modal
|
|
45
|
+
enforceFocus={false}
|
|
46
|
+
footer={renderFooter()}
|
|
47
|
+
onClose={handleClose}
|
|
48
|
+
{...modalProps}
|
|
49
|
+
>
|
|
50
|
+
{children}
|
|
51
|
+
</Modal>
|
|
52
|
+
</form>
|
|
53
|
+
);
|
|
54
|
+
}}
|
|
55
|
+
</Form>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
FormModal.propTypes = {
|
|
60
|
+
children: PropTypes.oneOfType([
|
|
61
|
+
PropTypes.arrayOf(PropTypes.node),
|
|
62
|
+
PropTypes.node,
|
|
63
|
+
PropTypes.func,
|
|
64
|
+
]),
|
|
65
|
+
modalProps: PropTypes.shape({
|
|
66
|
+
onClose: PropTypes.func
|
|
67
|
+
}),
|
|
68
|
+
onSubmit: PropTypes.func
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export default FormModal;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './FormModal';
|
|
@@ -66,11 +66,11 @@ NoResultsMessage.propTypes = {
|
|
|
66
66
|
icon: PropTypes.string,
|
|
67
67
|
isLoading: PropTypes.bool,
|
|
68
68
|
isError: PropTypes.bool,
|
|
69
|
-
label: PropTypes.oneOfType(
|
|
69
|
+
label: PropTypes.oneOfType([
|
|
70
70
|
PropTypes.string,
|
|
71
71
|
PropTypes.node,
|
|
72
72
|
PropTypes.func
|
|
73
|
-
),
|
|
73
|
+
]),
|
|
74
74
|
searchTerm: PropTypes.string.isRequired,
|
|
75
75
|
toggleFilterPane: PropTypes.func.isRequired,
|
|
76
76
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default
|
|
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)}
|
|
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';
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
PaneMenu,
|
|
23
23
|
SearchField,
|
|
24
24
|
} from '@folio/stripes/components';
|
|
25
|
-
import
|
|
25
|
+
import NoResultsMessage from '../NoResultsMessage';
|
|
26
26
|
|
|
27
27
|
import { generateKiwtQuery } from '../utils';
|
|
28
28
|
import { useKiwtSASQuery, useLocalStorageState } from '../hooks';
|
|
@@ -31,6 +31,7 @@ import { useKiwtSASQuery, useLocalStorageState } from '../hooks';
|
|
|
31
31
|
const SASQLookupComponent = ({
|
|
32
32
|
children,
|
|
33
33
|
fetchParameters = {},
|
|
34
|
+
FilterPaneHeaderComponent = () => null,
|
|
34
35
|
FilterComponent = () => null,
|
|
35
36
|
history,
|
|
36
37
|
id,
|
|
@@ -185,6 +186,7 @@ const SASQLookupComponent = ({
|
|
|
185
186
|
paneTitle={<FormattedMessage id="stripes-smart-components.searchAndFilter" />}
|
|
186
187
|
>
|
|
187
188
|
<form onSubmit={onSubmitSearch}>
|
|
189
|
+
<FilterPaneHeaderComponent />
|
|
188
190
|
{!noSearchField &&
|
|
189
191
|
<>
|
|
190
192
|
<SearchField
|
|
@@ -262,6 +264,10 @@ SASQLookupComponent.propTypes = {
|
|
|
262
264
|
PropTypes.func,
|
|
263
265
|
PropTypes.node
|
|
264
266
|
]),
|
|
267
|
+
FilterPaneHeaderComponent: PropTypes.oneOfType([
|
|
268
|
+
PropTypes.func,
|
|
269
|
+
PropTypes.node
|
|
270
|
+
]),
|
|
265
271
|
history: PropTypes.object,
|
|
266
272
|
id: PropTypes.string.isRequired,
|
|
267
273
|
location: PropTypes.object,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
|
|
4
|
-
import EditableSettingsList from '
|
|
5
|
-
import SettingsContext from '
|
|
6
|
-
import useSettingSection from '
|
|
4
|
+
import { EditableSettingsList } from '../EditableSettingsList';
|
|
5
|
+
import { SettingsContext } from '../contexts';
|
|
6
|
+
import { useSettingSection } from '../hooks';
|
|
7
7
|
|
|
8
8
|
const SettingPage = ({ sectionName }) => {
|
|
9
9
|
const { settingEndpoint } = useContext(SettingsContext);
|
|
@@ -31,10 +31,10 @@ SettingPage.propTypes = {
|
|
|
31
31
|
sectionName: PropTypes.string,
|
|
32
32
|
resources: PropTypes.shape({
|
|
33
33
|
settings: PropTypes.shape({
|
|
34
|
-
records: PropTypes.
|
|
34
|
+
records: PropTypes.arrayOf(PropTypes.object)
|
|
35
35
|
}),
|
|
36
36
|
refdatavalues: PropTypes.shape({
|
|
37
|
-
records: PropTypes.
|
|
37
|
+
records: PropTypes.arrayOf(PropTypes.object)
|
|
38
38
|
})
|
|
39
39
|
})
|
|
40
40
|
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
2
4
|
import { Pane } from '@folio/stripes/components';
|
|
3
5
|
import { FormattedMessage } from 'react-intl';
|
|
4
|
-
import SettingsContext from '
|
|
5
|
-
import { toCamelCase } from '
|
|
6
|
+
import { SettingsContext } from '../contexts';
|
|
7
|
+
import { toCamelCase } from '../utils';
|
|
6
8
|
|
|
7
9
|
const SettingPagePane = ({ sectionName, children }) => {
|
|
8
10
|
const { intlKey } = useContext(SettingsContext);
|
|
@@ -18,4 +20,12 @@ const SettingPagePane = ({ sectionName, children }) => {
|
|
|
18
20
|
);
|
|
19
21
|
};
|
|
20
22
|
|
|
23
|
+
SettingPagePane.propTypes = {
|
|
24
|
+
sectionName: PropTypes.string,
|
|
25
|
+
children: PropTypes.oneOfType([
|
|
26
|
+
PropTypes.func,
|
|
27
|
+
PropTypes.node
|
|
28
|
+
])
|
|
29
|
+
};
|
|
30
|
+
|
|
21
31
|
export default SettingPagePane;
|