@sap-ux/control-property-editor 0.3.1 → 0.4.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 +6 -0
- package/dist/app.css.map +1 -1
- package/dist/app.js +112 -66
- package/dist/app.js.map +3 -3
- package/package.json +2 -2
- package/src/i18n/i18n.json +2 -1
- package/src/panels/changes/ChangeStack.tsx +68 -30
- package/src/panels/changes/ChangesPanel.module.scss +0 -1
- package/src/panels/changes/ChangesPanel.tsx +16 -0
- package/src/panels/changes/ControlGroup.tsx +13 -5
- package/src/panels/changes/OtherChange.module.scss +13 -0
- package/src/panels/changes/OtherChange.tsx +41 -0
- package/src/panels/changes/PropertyChange.module.scss +0 -4
- package/src/panels/changes/PropertyChange.tsx +2 -16
- package/src/panels/changes/UnknownChange.module.scss +36 -1
- package/src/panels/changes/UnknownChange.tsx +23 -8
- package/src/panels/changes/index.tsx +1 -1
- package/src/panels/properties/PropertyDocumentation.tsx +2 -6
- package/test/unit/panels/changes/ChangesPanel.test.tsx +126 -15
|
@@ -9,7 +9,7 @@ import { DeviceType } from '../../../../src/devices';
|
|
|
9
9
|
import { registerAppIcons } from '../../../../src/icons';
|
|
10
10
|
import { ChangesPanel } from '../../../../src/panels/changes';
|
|
11
11
|
import { initI18n } from '../../../../src/i18n';
|
|
12
|
-
import type {
|
|
12
|
+
import type { PendingChange, SavedPropertyChange } from '@sap-ux-private/control-property-editor-common';
|
|
13
13
|
|
|
14
14
|
export type State = ReturnType<typeof reducer>;
|
|
15
15
|
|
|
@@ -33,7 +33,8 @@ const getModel = (saved = false): ChangesSlice => {
|
|
|
33
33
|
propertyName: 'testPropertyName1',
|
|
34
34
|
type: 'pending',
|
|
35
35
|
value: 'testValue1',
|
|
36
|
-
isActive: true
|
|
36
|
+
isActive: true,
|
|
37
|
+
changeType: 'propertyChange'
|
|
37
38
|
},
|
|
38
39
|
{
|
|
39
40
|
controlId: 'testId1BoolFalse',
|
|
@@ -41,7 +42,8 @@ const getModel = (saved = false): ChangesSlice => {
|
|
|
41
42
|
propertyName: 'testPropertyNameBoolFalse',
|
|
42
43
|
type: 'pending',
|
|
43
44
|
value: false,
|
|
44
|
-
isActive: true
|
|
45
|
+
isActive: true,
|
|
46
|
+
changeType: 'propertyChange'
|
|
45
47
|
},
|
|
46
48
|
{
|
|
47
49
|
controlId: 'testId1Exp',
|
|
@@ -49,9 +51,24 @@ const getModel = (saved = false): ChangesSlice => {
|
|
|
49
51
|
propertyName: 'testPropertyNameExp',
|
|
50
52
|
type: 'pending',
|
|
51
53
|
value: '{expression}',
|
|
52
|
-
isActive: true
|
|
54
|
+
isActive: true,
|
|
55
|
+
changeType: 'propertyBindingChange'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
controlId: 'ListReport::TableToolbar',
|
|
59
|
+
controlName: 'OverflowToolbar',
|
|
60
|
+
type: 'pending',
|
|
61
|
+
isActive: true,
|
|
62
|
+
changeType: 'addXML'
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
controlId: 'FieldGroup::TechnicalData::FormGroup',
|
|
66
|
+
controlName: 'Group',
|
|
67
|
+
type: 'pending',
|
|
68
|
+
isActive: true,
|
|
69
|
+
changeType: 'addFields'
|
|
53
70
|
}
|
|
54
|
-
] as
|
|
71
|
+
] as PendingChange[])
|
|
55
72
|
: [],
|
|
56
73
|
saved: saved
|
|
57
74
|
? ([
|
|
@@ -63,7 +80,19 @@ const getModel = (saved = false): ChangesSlice => {
|
|
|
63
80
|
value: 'testValue2',
|
|
64
81
|
fileName: 'testFileName',
|
|
65
82
|
kind: 'valid',
|
|
66
|
-
timestamp: new Date('2022-02-09T12:06:53.939Z').getTime()
|
|
83
|
+
timestamp: new Date('2022-02-09T12:06:53.939Z').getTime(),
|
|
84
|
+
changeType: 'propertyChange'
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
controlId: 'testId2',
|
|
88
|
+
controlName: 'controlName2',
|
|
89
|
+
propertyName: 'Icon',
|
|
90
|
+
type: 'saved',
|
|
91
|
+
value: 'sap-icon://accept',
|
|
92
|
+
fileName: 'testFileName',
|
|
93
|
+
kind: 'valid',
|
|
94
|
+
timestamp: new Date('2022-02-09T12:06:53.939Z').getTime(),
|
|
95
|
+
changeType: 'propertyChange'
|
|
67
96
|
},
|
|
68
97
|
{
|
|
69
98
|
controlId: 'testId3',
|
|
@@ -73,7 +102,8 @@ const getModel = (saved = false): ChangesSlice => {
|
|
|
73
102
|
value: true,
|
|
74
103
|
fileName: 'testFileNameBool',
|
|
75
104
|
kind: 'valid',
|
|
76
|
-
timestamp: new Date('2022-02-09T12:06:53.939Z').getTime()
|
|
105
|
+
timestamp: new Date('2022-02-09T12:06:53.939Z').getTime(),
|
|
106
|
+
changeType: 'propertyChange'
|
|
77
107
|
},
|
|
78
108
|
{
|
|
79
109
|
controlId: 'testId4',
|
|
@@ -83,7 +113,22 @@ const getModel = (saved = false): ChangesSlice => {
|
|
|
83
113
|
value: 2,
|
|
84
114
|
fileName: 'testFileNameNum',
|
|
85
115
|
kind: 'valid',
|
|
86
|
-
timestamp: new Date('2022-02-09T12:06:53.939Z').getTime()
|
|
116
|
+
timestamp: new Date('2022-02-09T12:06:53.939Z').getTime(),
|
|
117
|
+
changeType: 'propertyChange'
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
controlId: 'supplierView--supplierForm',
|
|
121
|
+
type: 'saved',
|
|
122
|
+
fileName: 'id_1698648267087_373_moveSimpleFormField',
|
|
123
|
+
kind: 'unknown',
|
|
124
|
+
timestamp: new Date('2023-10-11T12:06:53.939Z').getTime()
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
controlId: 'supplierView--supplierForm',
|
|
128
|
+
type: 'saved',
|
|
129
|
+
fileName: 'id_1698648267088_374_moveSimpleFormField',
|
|
130
|
+
kind: 'unknown',
|
|
131
|
+
timestamp: new Date('2023-10-12T12:06:53.939Z').getTime()
|
|
87
132
|
}
|
|
88
133
|
] as SavedPropertyChange[])
|
|
89
134
|
: []
|
|
@@ -115,7 +160,7 @@ describe('ChangePanel', () => {
|
|
|
115
160
|
expect(noControlFound).toBeInTheDocument();
|
|
116
161
|
});
|
|
117
162
|
|
|
118
|
-
test('
|
|
163
|
+
test('unsaved changes - all changes', () => {
|
|
119
164
|
const model = getModel();
|
|
120
165
|
const initialState: State = {
|
|
121
166
|
deviceType: DeviceType.Desktop,
|
|
@@ -140,9 +185,15 @@ describe('ChangePanel', () => {
|
|
|
140
185
|
|
|
141
186
|
const value = screen.getByText(/testValue1/i);
|
|
142
187
|
expect(value).toBeInTheDocument();
|
|
188
|
+
|
|
189
|
+
const controlToolbar = screen.getByRole('button', { name: /overflow toolbar/i });
|
|
190
|
+
expect(controlToolbar).toBeInTheDocument();
|
|
191
|
+
|
|
192
|
+
const changeAddXML = screen.getByText(/add fields/i);
|
|
193
|
+
expect(changeAddXML).toBeInTheDocument();
|
|
143
194
|
});
|
|
144
195
|
|
|
145
|
-
test('
|
|
196
|
+
test('saved changes - property change', () => {
|
|
146
197
|
const model = getModel(true);
|
|
147
198
|
const initialState: State = {
|
|
148
199
|
deviceType: DeviceType.Desktop,
|
|
@@ -169,6 +220,9 @@ describe('ChangePanel', () => {
|
|
|
169
220
|
const value1 = screen.getByText(/testValue2/i);
|
|
170
221
|
expect(value1).toBeInTheDocument();
|
|
171
222
|
|
|
223
|
+
const propertyIcon = screen.getByText(/sap\-icon:\/\/accept/i);
|
|
224
|
+
expect(propertyIcon).toBeInTheDocument();
|
|
225
|
+
|
|
172
226
|
const deleteButton = screen.getAllByRole('button')[1];
|
|
173
227
|
const iTagAttributes = deleteButton?.children?.item(0)?.children?.item(0)?.attributes;
|
|
174
228
|
const iconName = iTagAttributes?.getNamedItem('data-icon-name')?.value;
|
|
@@ -203,7 +257,7 @@ describe('ChangePanel', () => {
|
|
|
203
257
|
expect(screen.queryByText(/Test Property Name2/i)).toStrictEqual(null);
|
|
204
258
|
});
|
|
205
259
|
|
|
206
|
-
test('
|
|
260
|
+
test('saved changes - Other change', () => {
|
|
207
261
|
const model: ChangesSlice = {
|
|
208
262
|
controls: {} as any,
|
|
209
263
|
pending: [],
|
|
@@ -211,7 +265,9 @@ describe('ChangePanel', () => {
|
|
|
211
265
|
{
|
|
212
266
|
fileName: 'testFileName2',
|
|
213
267
|
type: 'saved',
|
|
214
|
-
kind: 'unknown'
|
|
268
|
+
kind: 'unknown',
|
|
269
|
+
controlId: 'someSelectorId',
|
|
270
|
+
header: true
|
|
215
271
|
} as any
|
|
216
272
|
]
|
|
217
273
|
};
|
|
@@ -230,11 +286,20 @@ describe('ChangePanel', () => {
|
|
|
230
286
|
const savedChangesTitle = screen.getByText(/saved changes/i);
|
|
231
287
|
expect(savedChangesTitle).toBeInTheDocument();
|
|
232
288
|
|
|
233
|
-
const title = screen.getByText(/Test File Name2/i);
|
|
289
|
+
const title = screen.getByText(/Test File Name2 Change/i);
|
|
234
290
|
expect(title).toBeInTheDocument();
|
|
235
291
|
|
|
236
|
-
const
|
|
237
|
-
expect(
|
|
292
|
+
const fileLabel = screen.getByText(/file:/i);
|
|
293
|
+
expect(fileLabel).toBeInTheDocument();
|
|
294
|
+
|
|
295
|
+
const fileName = screen.getByText(/testfilename2/i);
|
|
296
|
+
expect(fileName).toBeInTheDocument();
|
|
297
|
+
|
|
298
|
+
const selectorIdLabel = screen.getByText(/selector id:/i);
|
|
299
|
+
expect(selectorIdLabel).toBeInTheDocument();
|
|
300
|
+
|
|
301
|
+
const selectorId = screen.getByText(/someSelectorId/i);
|
|
302
|
+
expect(selectorId).toBeInTheDocument();
|
|
238
303
|
|
|
239
304
|
const deleteButton = screen.getAllByRole('button')[0];
|
|
240
305
|
const iTagAttributes = deleteButton?.children?.item(0)?.children?.item(0)?.attributes;
|
|
@@ -258,4 +323,50 @@ describe('ChangePanel', () => {
|
|
|
258
323
|
const confirmButton = screen.getByRole('button', { name: /^Delete$/i });
|
|
259
324
|
confirmButton.click();
|
|
260
325
|
});
|
|
326
|
+
|
|
327
|
+
test('Filter unsaved changes', () => {
|
|
328
|
+
const model = getModel();
|
|
329
|
+
const filterInitOptions: FilterOptions[] = [{ name: FilterName.changeSummaryFilterQuery, value: 'toolbar' }];
|
|
330
|
+
const initialState: State = {
|
|
331
|
+
deviceType: DeviceType.Desktop,
|
|
332
|
+
scale: 1,
|
|
333
|
+
outline: {} as any,
|
|
334
|
+
filterQuery: filterInitOptions,
|
|
335
|
+
selectedControl: undefined,
|
|
336
|
+
changes: model,
|
|
337
|
+
icons: []
|
|
338
|
+
};
|
|
339
|
+
render(<ChangesPanel />, { initialState });
|
|
340
|
+
|
|
341
|
+
// check unsaved changes
|
|
342
|
+
const savedChangesTitle = screen.getByText(/unsaved changes/i);
|
|
343
|
+
expect(savedChangesTitle).toBeInTheDocument();
|
|
344
|
+
|
|
345
|
+
const controlToolbar = screen.getByRole('button', { name: /overflow toolbar/i });
|
|
346
|
+
expect(controlToolbar).toBeInTheDocument();
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
test('Filter saved changes', () => {
|
|
350
|
+
const model = getModel(true);
|
|
351
|
+
const filterInitOptions: FilterOptions[] = [
|
|
352
|
+
{ name: FilterName.changeSummaryFilterQuery, value: 'Simple Form' }
|
|
353
|
+
];
|
|
354
|
+
const initialState: State = {
|
|
355
|
+
deviceType: DeviceType.Desktop,
|
|
356
|
+
scale: 1,
|
|
357
|
+
outline: {} as any,
|
|
358
|
+
filterQuery: filterInitOptions,
|
|
359
|
+
selectedControl: undefined,
|
|
360
|
+
changes: model,
|
|
361
|
+
icons: []
|
|
362
|
+
};
|
|
363
|
+
render(<ChangesPanel />, { initialState });
|
|
364
|
+
|
|
365
|
+
// check unsaved changes
|
|
366
|
+
const savedChangesTitle = screen.getByText(/saved changes/i);
|
|
367
|
+
expect(savedChangesTitle).toBeInTheDocument();
|
|
368
|
+
|
|
369
|
+
const formFieldChange = screen.getByText(/id_1698648267087_373_movesimpleformfield/i);
|
|
370
|
+
expect(formFieldChange).toBeInTheDocument();
|
|
371
|
+
});
|
|
261
372
|
});
|