@sap-ux/control-property-editor 0.4.4 → 0.4.6

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/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.4",
6
+ "version": "0.4.6",
7
7
  "main": "dist/app.js",
8
8
  "repository": {
9
9
  "type": "git",
@@ -49,7 +49,7 @@
49
49
  "autoprefixer": "10.4.7",
50
50
  "postcss": "8.4.31",
51
51
  "yargs-parser": "21.1.1",
52
- "@sap-ux/ui-components": "1.13.4",
52
+ "@sap-ux/ui-components": "1.13.5",
53
53
  "@sap-ux-private/control-property-editor-common": "0.3.1"
54
54
  },
55
55
  "scripts": {
package/src/App.tsx CHANGED
@@ -3,9 +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
-
7
6
  import type { Scenario } from '@sap-ux-private/control-property-editor-common';
8
-
9
7
  import { PropertiesPanel, LeftPanel } from './panels';
10
8
  import { useLocalStorage } from './use-local-storage';
11
9
  import type { RootState } from './store';
@@ -29,6 +27,9 @@ export interface AppProps {
29
27
  */
30
28
  export default function App(appProps: AppProps): ReactElement {
31
29
  const { previewUrl } = appProps;
30
+ const scenario = useSelector<RootState, Scenario>((state) => state.scenario);
31
+ const isAdpProject = scenario === 'ADAPTATION_PROJECT';
32
+
32
33
  useEffect(() => {
33
34
  const sheet = window.document.styleSheets[0];
34
35
  sheet.insertRule(
@@ -39,11 +40,11 @@ export default function App(appProps: AppProps): ReactElement {
39
40
  }, []);
40
41
  const { t } = useTranslation();
41
42
  const dispatch = useAppDispatch();
42
- const scenario = useSelector<RootState, Scenario>((state) => state.scenario);
43
43
  const [hideWarningDialog, setHideWarningDialog] = useLocalStorage('hide-warning-dialog', false);
44
44
  const [isWarningDialogVisible, setWarningDialogVisibility] = useState(() => hideWarningDialog !== true);
45
45
 
46
46
  const [isInitialized, setIsInitialized] = useState(false);
47
+ const [shouldShowDialogMessageForAdpProjects, setShouldShowDialogMessageForAdpProjects] = useState(false);
47
48
 
48
49
  const previewWidth = useSelector<RootState, string>(
49
50
  (state) => `${DEVICE_WIDTH_MAP.get(state.deviceType) ?? DEFAULT_DEVICE_WIDTH}px`
@@ -51,6 +52,7 @@ export default function App(appProps: AppProps): ReactElement {
51
52
  const previewScale = useSelector<RootState, number>((state) => state.scale);
52
53
  const fitPreview = useSelector<RootState, boolean>((state) => state.fitPreview ?? false);
53
54
  const windowSize = useWindowSize();
55
+ const dialogMessage = useSelector<RootState, string | undefined>((state) => state.dialogMessage);
54
56
 
55
57
  const containerRef = useCallback(
56
58
  (node) => {
@@ -87,6 +89,12 @@ export default function App(appProps: AppProps): ReactElement {
87
89
  setWarningDialogVisibility(false);
88
90
  }
89
91
 
92
+ useEffect(() => {
93
+ if (dialogMessage && isAdpProject) {
94
+ setShouldShowDialogMessageForAdpProjects(true);
95
+ }
96
+ }, [dialogMessage]);
97
+
90
98
  return (
91
99
  <div className="app">
92
100
  <section className="app-panel app-panel-left">
@@ -94,22 +102,32 @@ export default function App(appProps: AppProps): ReactElement {
94
102
  </section>
95
103
  <section ref={containerRef} className="app-content">
96
104
  <div className="app-canvas">
97
- <iframe
98
- className="app-preview"
99
- id="preview"
100
- style={{
101
- width: previewWidth,
102
- transform: `scale(${previewScale})`
103
- }}
104
- src={previewUrl}
105
- title={t('APPLICATION_PREVIEW_TITLE')}
106
- />
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
+ )}
107
117
  </div>
108
118
  </section>
109
119
  <section className="app-panel app-panel-right">
110
120
  <PropertiesPanel />
111
121
  </section>
112
-
122
+ {isAdpProject && (
123
+ <UIDialog
124
+ hidden={!shouldShowDialogMessageForAdpProjects}
125
+ dialogContentProps={{
126
+ title: t('TOOL_DISCLAIMER_TITLE'),
127
+ subText: dialogMessage
128
+ }}
129
+ />
130
+ )}
113
131
  {scenario === 'FE_FROM_SCRATCH' ? (
114
132
  <UIDialog
115
133
  hidden={!isWarningDialogVisible}
@@ -50,7 +50,7 @@ export function DropdownEditor(propertyInputProps: PropertyInputProps<StringCont
50
50
  selectedKey={value}
51
51
  disabled={!isEnabled}
52
52
  autoComplete="on"
53
- allowFreeform={true}
53
+ allowFreeform={false}
54
54
  text={text}
55
55
  errorMessage={errorMessage}
56
56
  options={options}
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;
@@ -36,14 +36,14 @@ describe('DropdownEditor', () => {
36
36
  const dropDownEditor = screen.getByTestId(testId);
37
37
  const dropDownEditorInput = dropDownEditor.querySelector('input');
38
38
  jest.spyOn(window, 'setTimeout').mockImplementation((cb: any) => {
39
- cb(undefined, undefined, 'test');
39
+ cb(undefined, undefined, 'option2');
40
40
  });
41
41
  if (dropDownEditorInput) {
42
42
  fireEvent.focus(dropDownEditorInput);
43
- fireEvent.input(dropDownEditorInput, { target: { value: 'test' } });
43
+ fireEvent.input(dropDownEditorInput, { target: { value: 'option2' } });
44
44
  fireEvent.blur(dropDownEditorInput);
45
45
  }
46
- expect(dispatch).toBeCalledTimes(2);
46
+ expect(dispatch).toBeCalledTimes(1);
47
47
  });
48
48
  test('valueChanged function', () => {
49
49
  const result = valueChanged('testControlId', 'testPropertyName', 'newValue', 'Button');