@sap-ux/control-property-editor 0.4.3 → 0.4.5
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 +12 -0
- package/dist/app.css +1 -1
- package/dist/app.css.map +3 -3
- package/dist/app.js +50 -50
- package/dist/app.js.map +2 -2
- package/package.json +3 -3
- package/src/App.tsx +59 -34
- package/src/slice.ts +7 -1
- package/test/unit/App.test.tsx +11 -2
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"displayName": "Control Property Editor",
|
|
4
4
|
"description": "Control Property Editor",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
-
"version": "0.4.
|
|
6
|
+
"version": "0.4.5",
|
|
7
7
|
"main": "dist/app.js",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"autoprefixer": "10.4.7",
|
|
50
50
|
"postcss": "8.4.31",
|
|
51
51
|
"yargs-parser": "21.1.1",
|
|
52
|
-
"@sap-ux
|
|
53
|
-
"@sap-ux/
|
|
52
|
+
"@sap-ux/ui-components": "1.13.4",
|
|
53
|
+
"@sap-ux-private/control-property-editor-common": "0.3.1"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"clean": "rimraf ./dist ./coverage *.tsbuildinfo",
|
package/src/App.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import React, { useCallback, useEffect, useState } from 'react';
|
|
|
3
3
|
import { useSelector } from 'react-redux';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { UIDialog, UILink, UIToggle } from '@sap-ux/ui-components';
|
|
6
|
-
|
|
6
|
+
import type { Scenario } from '@sap-ux-private/control-property-editor-common';
|
|
7
7
|
import { PropertiesPanel, LeftPanel } from './panels';
|
|
8
8
|
import { useLocalStorage } from './use-local-storage';
|
|
9
9
|
import type { RootState } from './store';
|
|
@@ -27,6 +27,9 @@ export interface AppProps {
|
|
|
27
27
|
*/
|
|
28
28
|
export default function App(appProps: AppProps): ReactElement {
|
|
29
29
|
const { previewUrl } = appProps;
|
|
30
|
+
const scenario = useSelector<RootState, Scenario>((state) => state.scenario);
|
|
31
|
+
const isAdpProject = scenario === 'ADAPTATION_PROJECT';
|
|
32
|
+
|
|
30
33
|
useEffect(() => {
|
|
31
34
|
const sheet = window.document.styleSheets[0];
|
|
32
35
|
sheet.insertRule(
|
|
@@ -41,6 +44,7 @@ export default function App(appProps: AppProps): ReactElement {
|
|
|
41
44
|
const [isWarningDialogVisible, setWarningDialogVisibility] = useState(() => hideWarningDialog !== true);
|
|
42
45
|
|
|
43
46
|
const [isInitialized, setIsInitialized] = useState(false);
|
|
47
|
+
const [shouldShowDialogMessageForAdpProjects, setShouldShowDialogMessageForAdpProjects] = useState(false);
|
|
44
48
|
|
|
45
49
|
const previewWidth = useSelector<RootState, string>(
|
|
46
50
|
(state) => `${DEVICE_WIDTH_MAP.get(state.deviceType) ?? DEFAULT_DEVICE_WIDTH}px`
|
|
@@ -48,6 +52,7 @@ export default function App(appProps: AppProps): ReactElement {
|
|
|
48
52
|
const previewScale = useSelector<RootState, number>((state) => state.scale);
|
|
49
53
|
const fitPreview = useSelector<RootState, boolean>((state) => state.fitPreview ?? false);
|
|
50
54
|
const windowSize = useWindowSize();
|
|
55
|
+
const dialogMessage = useSelector<RootState, string | undefined>((state) => state.dialogMessage);
|
|
51
56
|
|
|
52
57
|
const containerRef = useCallback(
|
|
53
58
|
(node) => {
|
|
@@ -84,6 +89,12 @@ export default function App(appProps: AppProps): ReactElement {
|
|
|
84
89
|
setWarningDialogVisibility(false);
|
|
85
90
|
}
|
|
86
91
|
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (dialogMessage && isAdpProject) {
|
|
94
|
+
setShouldShowDialogMessageForAdpProjects(true);
|
|
95
|
+
}
|
|
96
|
+
}, [dialogMessage]);
|
|
97
|
+
|
|
87
98
|
return (
|
|
88
99
|
<div className="app">
|
|
89
100
|
<section className="app-panel app-panel-left">
|
|
@@ -91,46 +102,60 @@ export default function App(appProps: AppProps): ReactElement {
|
|
|
91
102
|
</section>
|
|
92
103
|
<section ref={containerRef} className="app-content">
|
|
93
104
|
<div className="app-canvas">
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
105
|
+
{!shouldShowDialogMessageForAdpProjects && (
|
|
106
|
+
<iframe
|
|
107
|
+
className="app-preview"
|
|
108
|
+
id="preview"
|
|
109
|
+
style={{
|
|
110
|
+
width: previewWidth,
|
|
111
|
+
transform: `scale(${previewScale})`
|
|
112
|
+
}}
|
|
113
|
+
src={previewUrl}
|
|
114
|
+
title={t('APPLICATION_PREVIEW_TITLE')}
|
|
115
|
+
/>
|
|
116
|
+
)}
|
|
104
117
|
</div>
|
|
105
118
|
</section>
|
|
106
119
|
<section className="app-panel app-panel-right">
|
|
107
120
|
<PropertiesPanel />
|
|
108
121
|
</section>
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
subText: t('TOOL_DISCLAIMER_TEXT')
|
|
116
|
-
}}
|
|
117
|
-
acceptButtonText={t('OK')}
|
|
118
|
-
onAccept={closeWarningDialog}>
|
|
119
|
-
<UILink href="https://ui5.sap.com/#/topic/03265b0408e2432c9571d6b3feb6b1fd">
|
|
120
|
-
{t('FE_DOCUMENTATION_LINK_TEXT')}
|
|
121
|
-
</UILink>
|
|
122
|
-
<UIToggle
|
|
123
|
-
className="space space-toggle"
|
|
124
|
-
label={t('DONT_SHOW_WARNING_ON_START')}
|
|
125
|
-
inlineLabel
|
|
126
|
-
inlineLabelLeft
|
|
127
|
-
labelFlexGrow
|
|
128
|
-
checked={hideWarningDialog}
|
|
129
|
-
onChange={(_event, checked = false): void => {
|
|
130
|
-
setHideWarningDialog(checked);
|
|
122
|
+
{isAdpProject && (
|
|
123
|
+
<UIDialog
|
|
124
|
+
hidden={!shouldShowDialogMessageForAdpProjects}
|
|
125
|
+
dialogContentProps={{
|
|
126
|
+
title: t('TOOL_DISCLAIMER_TITLE'),
|
|
127
|
+
subText: dialogMessage
|
|
131
128
|
}}
|
|
132
129
|
/>
|
|
133
|
-
|
|
130
|
+
)}
|
|
131
|
+
{scenario === 'FE_FROM_SCRATCH' ? (
|
|
132
|
+
<UIDialog
|
|
133
|
+
hidden={!isWarningDialogVisible}
|
|
134
|
+
closeButtonAriaLabel={t('CLOSE')}
|
|
135
|
+
dialogContentProps={{
|
|
136
|
+
title: t('TOOL_DISCLAIMER_TITLE'),
|
|
137
|
+
subText: t('TOOL_DISCLAIMER_TEXT')
|
|
138
|
+
}}
|
|
139
|
+
acceptButtonText={t('OK')}
|
|
140
|
+
onAccept={closeWarningDialog}>
|
|
141
|
+
<UILink href="https://ui5.sap.com/#/topic/03265b0408e2432c9571d6b3feb6b1fd">
|
|
142
|
+
{t('FE_DOCUMENTATION_LINK_TEXT')}
|
|
143
|
+
</UILink>
|
|
144
|
+
<UIToggle
|
|
145
|
+
className="space space-toggle"
|
|
146
|
+
label={t('DONT_SHOW_WARNING_ON_START')}
|
|
147
|
+
inlineLabel
|
|
148
|
+
inlineLabelLeft
|
|
149
|
+
labelFlexGrow
|
|
150
|
+
checked={hideWarningDialog}
|
|
151
|
+
onChange={(_event, checked = false): void => {
|
|
152
|
+
setHideWarningDialog(checked);
|
|
153
|
+
}}
|
|
154
|
+
/>
|
|
155
|
+
</UIDialog>
|
|
156
|
+
) : (
|
|
157
|
+
<></>
|
|
158
|
+
)}
|
|
134
159
|
</div>
|
|
135
160
|
);
|
|
136
161
|
}
|
package/src/slice.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
outlineChanged,
|
|
18
18
|
propertyChanged,
|
|
19
19
|
propertyChangeFailed,
|
|
20
|
+
showMessage,
|
|
20
21
|
scenario,
|
|
21
22
|
scenarioLoaded
|
|
22
23
|
} from '@sap-ux-private/control-property-editor-common';
|
|
@@ -36,6 +37,7 @@ interface SliceState {
|
|
|
36
37
|
scenario: Scenario;
|
|
37
38
|
icons: IconDetails[];
|
|
38
39
|
changes: ChangesSlice;
|
|
40
|
+
dialogMessage: string | undefined;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
export interface ChangesSlice {
|
|
@@ -101,7 +103,8 @@ export const initialState = {
|
|
|
101
103
|
controls: {},
|
|
102
104
|
pending: [],
|
|
103
105
|
saved: []
|
|
104
|
-
}
|
|
106
|
+
},
|
|
107
|
+
dialogMessage: undefined
|
|
105
108
|
};
|
|
106
109
|
const slice = createSlice<SliceState, SliceCaseReducers<SliceState>, string>({
|
|
107
110
|
name: 'app',
|
|
@@ -219,6 +222,9 @@ const slice = createSlice<SliceState, SliceCaseReducers<SliceState>, string>({
|
|
|
219
222
|
state.changes.controls[key] = control;
|
|
220
223
|
}
|
|
221
224
|
})
|
|
225
|
+
.addMatcher(showMessage.match, (state, action: ReturnType<typeof showMessage>): void => {
|
|
226
|
+
state.dialogMessage = action.payload;
|
|
227
|
+
})
|
|
222
228
|
});
|
|
223
229
|
|
|
224
230
|
export default slice.reducer;
|
package/test/unit/App.test.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import { render, mockDomEventListener } from './utils';
|
|
|
6
6
|
import { initI18n } from '../../src/i18n';
|
|
7
7
|
|
|
8
8
|
import App from '../../src/App';
|
|
9
|
-
import { controlSelected } from '@sap-ux-private/control-property-editor-common';
|
|
9
|
+
import { controlSelected, scenarioLoaded } from '@sap-ux-private/control-property-editor-common';
|
|
10
10
|
import { mockResizeObserver } from '../utils/utils';
|
|
11
11
|
import { InputType } from '../../src/panels/properties/types';
|
|
12
12
|
import { registerAppIcons } from '../../src/icons';
|
|
@@ -163,8 +163,17 @@ test('renders properties', () => {
|
|
|
163
163
|
expect(notFoundException).toBeTruthy();
|
|
164
164
|
});
|
|
165
165
|
|
|
166
|
-
test('
|
|
166
|
+
test('does not render warning dialog', async () => {
|
|
167
167
|
render(<App previewUrl="" />);
|
|
168
|
+
const dialogContent = screen.queryByText(
|
|
169
|
+
/The Control Property Editor enables you to change control properties and behavior directly. These changes may not have the desired effect with Fiori elements applications. Please consult documentation to learn which changes are supported./i
|
|
170
|
+
);
|
|
171
|
+
expect(dialogContent).not.toBeInTheDocument();
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
test('renders warning dialog for "FE_FROM_SCRATCH" scenario', async () => {
|
|
175
|
+
const { store } = render(<App previewUrl="" />, { initialState });
|
|
176
|
+
store.dispatch(scenarioLoaded('FE_FROM_SCRATCH'));
|
|
168
177
|
const dialogContent = screen.getByText(
|
|
169
178
|
/The Control Property Editor enables you to change control properties and behavior directly. These changes may not have the desired effect with Fiori elements applications. Please consult documentation to learn which changes are supported./i
|
|
170
179
|
);
|