@griddo/ax 1.75.111 → 1.75.113
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/config/jest/componentsMock.js +122 -1
- package/package.json +2 -2
- package/src/__tests__/components/Avatar/__snapshots__/Avatar.test.tsx.snap +10 -10
- package/src/__tests__/components/ConfigPanel/ConfigPanel.test.tsx +252 -0
- package/src/__tests__/components/ConfigPanel/Form/ConnectedField/ConnectedField.test.tsx +177 -0
- package/src/__tests__/components/ConfigPanel/Form/ConnectedField/NavConnectedField/NavConnectedField.test.tsx +161 -0
- package/src/__tests__/components/ConfigPanel/Form/ConnectedField/PageConnectedField/Field/Field.test.tsx +115 -0
- package/src/__tests__/components/ConfigPanel/Form/ConnectedField/PageConnectedField/PageConnectedField.test.tsx +518 -0
- package/src/__tests__/components/ConfigPanel/Form/ConnectedField/PageConnectedField/TemplateManager/TemplateManager.test.tsx +144 -0
- package/src/__tests__/components/ConfigPanel/Form/Form.test.tsx +235 -0
- package/src/__tests__/components/ConfigPanel/GlobalPageForm/GlobalPageForm.test.tsx +196 -0
- package/src/__tests__/components/ConfigPanel/Header/Header.test.tsx +152 -0
- package/src/__tests__/components/ConfigPanel/NavigationForm/Field/Field.test.tsx +106 -0
- package/src/__tests__/components/ConfigPanel/NavigationForm/NavigationForm.test.tsx +93 -0
- package/src/__tests__/components/ConfigPanel/PreviewForm/PreviewForm.test.tsx +93 -0
- package/src/__tests__/components/Fields/FieldGroup/FieldGroup.test.tsx +5 -5
- package/src/__tests__/components/Fields/NoteField/NoteField.test.tsx +3 -3
- package/src/__tests__/components/Fields/SliderField/SliderField.test.tsx +4 -4
- package/src/__tests__/components/Fields/TagField/TagField.test.tsx +10 -10
- package/src/__tests__/components/Fields/TextArea/TextArea.test.tsx +3 -3
- package/src/__tests__/components/Fields/TextField/TextField.test.tsx +8 -8
- package/src/__tests__/components/Fields/UrlField/UrlField.test.tsx +2 -2
- package/src/__tests__/components/Gallery/Gallery.test.tsx +613 -0
- package/src/__tests__/components/Gallery/GalleryFilters/Orientation/Orientation.test.tsx +51 -0
- package/src/__tests__/components/Gallery/GalleryFilters/SortBy/SortBy.test.tsx +117 -0
- package/src/__tests__/components/Gallery/GalleryFilters/Type/Type.test.tsx +51 -0
- package/src/__tests__/components/Gallery/GalleryPanel/DetailPanel/DetailPanel.test.tsx +853 -0
- package/src/__tests__/components/Gallery/GalleryPanel/GalleryDragAndDrop/GalleryDragAndDrop.test.tsx +252 -0
- package/src/__tests__/components/Gallery/GalleryPanel/GalleryPanel.test.tsx +56 -0
- package/src/__tests__/components/Image/Image.test.tsx +5 -5
- package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/Field/index.tsx +3 -4
- package/src/components/ConfigPanel/Form/index.tsx +13 -5
- package/src/components/ConfigPanel/GlobalPageForm/index.tsx +5 -5
- package/src/components/ConfigPanel/Header/index.tsx +3 -3
- package/src/components/ConfigPanel/NavigationForm/Field/index.tsx +5 -3
- package/src/components/ConfigPanel/NavigationForm/index.tsx +2 -2
- package/src/components/ConfigPanel/PreviewForm/index.tsx +3 -3
- package/src/components/ConfigPanel/index.tsx +2 -3
- package/src/components/Fields/FieldGroup/index.tsx +3 -3
- package/src/components/Fields/NoteField/index.tsx +2 -2
- package/src/components/Fields/SliderField/index.tsx +10 -3
- package/src/components/Fields/TagField/index.tsx +2 -2
- package/src/components/Fields/TextArea/index.tsx +1 -1
- package/src/components/Fields/TextField/index.tsx +3 -3
- package/src/components/Gallery/GalleryFilters/Orientation/index.tsx +14 -6
- package/src/components/Gallery/GalleryFilters/SortBy/index.tsx +2 -2
- package/src/components/Gallery/GalleryFilters/Type/index.tsx +2 -2
- package/src/components/Gallery/GalleryPanel/DetailPanel/index.tsx +4 -4
- package/src/components/Gallery/GalleryPanel/GalleryDragAndDrop/index.tsx +5 -4
- package/src/components/Gallery/GalleryPanel/index.tsx +3 -11
- package/src/components/Gallery/index.tsx +6 -5
- package/src/containers/PageEditor/actions.tsx +1 -2
package/src/__tests__/components/Gallery/GalleryPanel/GalleryDragAndDrop/GalleryDragAndDrop.test.tsx
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { ThemeProvider } from "styled-components";
|
|
4
|
+
import { render, cleanup, screen, fireEvent, act, waitFor } from "../../../../../../config/jest/test-utils";
|
|
5
|
+
import { mock } from "jest-mock-extended";
|
|
6
|
+
import configureStore from "redux-mock-store";
|
|
7
|
+
import "@testing-library/jest-dom";
|
|
8
|
+
import thunk from "redux-thunk";
|
|
9
|
+
|
|
10
|
+
import { parseTheme } from "@ax/helpers";
|
|
11
|
+
import GalleryDragAndDrop, {
|
|
12
|
+
IGalleryDragAndDropProps,
|
|
13
|
+
IDispatchProps,
|
|
14
|
+
} from "@ax/components/Gallery/GalleryPanel/GalleryDragAndDrop";
|
|
15
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
16
|
+
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
cleanup();
|
|
19
|
+
jest.clearAllMocks();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const middlewares: any = [thunk];
|
|
23
|
+
const mockStore = configureStore(middlewares);
|
|
24
|
+
|
|
25
|
+
const defaultGalleryDDProps = mock<IGalleryDragAndDropProps>();
|
|
26
|
+
const defaultDispatchProps = mock<IDispatchProps>();
|
|
27
|
+
|
|
28
|
+
describe("GalleryDragAndDrop component rendering", () => {
|
|
29
|
+
it("should render the component", () => {
|
|
30
|
+
defaultGalleryDDProps.validFormats = ["png", "jpg"];
|
|
31
|
+
defaultGalleryDDProps.allowUpload = false;
|
|
32
|
+
const initialStore = {
|
|
33
|
+
gallery: {
|
|
34
|
+
isSaving: {
|
|
35
|
+
save: false,
|
|
36
|
+
saveAdd: false,
|
|
37
|
+
delete: false,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const store = mockStore(initialStore);
|
|
43
|
+
|
|
44
|
+
const defaultProps = {
|
|
45
|
+
...defaultGalleryDDProps,
|
|
46
|
+
...defaultDispatchProps,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
render(
|
|
50
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
51
|
+
<GalleryDragAndDrop {...defaultProps} />
|
|
52
|
+
</ThemeProvider>,
|
|
53
|
+
{ store }
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
expect(screen.getByTestId("gallery-drag-drop-wrapper")).toBeTruthy();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("should render the component with the DragAndDrop", () => {
|
|
60
|
+
defaultGalleryDDProps.validFormats = ["png", "jpg"];
|
|
61
|
+
defaultGalleryDDProps.allowUpload = true;
|
|
62
|
+
const initialStore = {
|
|
63
|
+
gallery: {
|
|
64
|
+
isSaving: {
|
|
65
|
+
save: false,
|
|
66
|
+
saveAdd: false,
|
|
67
|
+
delete: false,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const store = mockStore(initialStore);
|
|
73
|
+
|
|
74
|
+
const defaultProps = {
|
|
75
|
+
...defaultGalleryDDProps,
|
|
76
|
+
...defaultDispatchProps,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
render(
|
|
80
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
81
|
+
<GalleryDragAndDrop {...defaultProps} />
|
|
82
|
+
</ThemeProvider>,
|
|
83
|
+
{ store }
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
expect(screen.getByTestId("gallery-drag-drop-wrapper")).toBeTruthy();
|
|
87
|
+
expect(screen.getAllByTestId("drag-drop-wrapper")).toBeTruthy();
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
describe("GalleryDragAndDrop component actions", () => {
|
|
92
|
+
it("should trigger the handleFileclick", () => {
|
|
93
|
+
defaultGalleryDDProps.validFormats = ["png", "jpg"];
|
|
94
|
+
defaultGalleryDDProps.allowUpload = true;
|
|
95
|
+
|
|
96
|
+
const initialStore = {
|
|
97
|
+
gallery: {
|
|
98
|
+
isSaving: {
|
|
99
|
+
save: false,
|
|
100
|
+
saveAdd: false,
|
|
101
|
+
delete: false,
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const clickInputSpy = jest.spyOn(HTMLInputElement.prototype, "click");
|
|
107
|
+
|
|
108
|
+
const store = mockStore(initialStore);
|
|
109
|
+
|
|
110
|
+
const defaultProps = {
|
|
111
|
+
...defaultGalleryDDProps,
|
|
112
|
+
...defaultDispatchProps,
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
render(
|
|
116
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
117
|
+
<GalleryDragAndDrop {...defaultProps} />
|
|
118
|
+
</ThemeProvider>,
|
|
119
|
+
{ store }
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const buttonSelect = screen.getByTestId("button-line-inverse");
|
|
123
|
+
act(() => {
|
|
124
|
+
fireEvent.click(buttonSelect);
|
|
125
|
+
});
|
|
126
|
+
expect(clickInputSpy).toBeCalled();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it("should trigger the handleTryAgain", () => {
|
|
130
|
+
defaultGalleryDDProps.validFormats = ["png", "jpg"];
|
|
131
|
+
defaultGalleryDDProps.allowUpload = true;
|
|
132
|
+
|
|
133
|
+
const initialStore = {
|
|
134
|
+
gallery: {
|
|
135
|
+
isSaving: {
|
|
136
|
+
save: false,
|
|
137
|
+
saveAdd: false,
|
|
138
|
+
delete: false,
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const store = mockStore(initialStore);
|
|
144
|
+
|
|
145
|
+
const defaultProps = {
|
|
146
|
+
...defaultGalleryDDProps,
|
|
147
|
+
...defaultDispatchProps,
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
render(
|
|
151
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
152
|
+
<GalleryDragAndDrop {...defaultProps} />
|
|
153
|
+
</ThemeProvider>,
|
|
154
|
+
{ store }
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
const buttonTry = screen.getByText(/TRY AGAIN/i);
|
|
158
|
+
fireEvent.click(buttonTry);
|
|
159
|
+
expect(store.getActions()).toContainEqual({
|
|
160
|
+
payload: { errorMsg: "", inDropZone: false, isError: false, isUploading: false },
|
|
161
|
+
type: "gallery/SET_UPLOAD_ERROR",
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it("should trigger the DragAndDrop handleDragOver action", () => {
|
|
166
|
+
defaultGalleryDDProps.validFormats = ["png", "jpg"];
|
|
167
|
+
defaultGalleryDDProps.allowUpload = true;
|
|
168
|
+
|
|
169
|
+
const initialStore = {
|
|
170
|
+
gallery: {
|
|
171
|
+
isSaving: {
|
|
172
|
+
save: false,
|
|
173
|
+
saveAdd: false,
|
|
174
|
+
delete: false,
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const store = mockStore(initialStore);
|
|
180
|
+
|
|
181
|
+
const defaultProps = {
|
|
182
|
+
...defaultGalleryDDProps,
|
|
183
|
+
...defaultDispatchProps,
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const galleryDragAndDropComponent = (
|
|
187
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
188
|
+
<GalleryDragAndDrop {...defaultProps} />
|
|
189
|
+
</ThemeProvider>
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
render(galleryDragAndDropComponent, { store });
|
|
193
|
+
|
|
194
|
+
expect(screen.getByTestId("gallery-drag-drop-wrapper")).toBeTruthy();
|
|
195
|
+
const dragDropComponent = screen.getAllByTestId("drag-drop-wrapper");
|
|
196
|
+
expect(dragDropComponent).toBeTruthy();
|
|
197
|
+
|
|
198
|
+
const dataTransfer = {
|
|
199
|
+
dropEffect: "",
|
|
200
|
+
};
|
|
201
|
+
fireEvent.dragOver(dragDropComponent[0], {
|
|
202
|
+
dataTransfer,
|
|
203
|
+
});
|
|
204
|
+
expect(dataTransfer.dropEffect).toBe("copy");
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it("should trigger the DragAndDrop handleDrop action", async () => {
|
|
208
|
+
defaultGalleryDDProps.validFormats = ["png", "jpg"];
|
|
209
|
+
defaultGalleryDDProps.allowUpload = true;
|
|
210
|
+
const refreshImagesMock = defaultGalleryDDProps.refreshImages as jest.MockedFunction<() => Promise<void>>;
|
|
211
|
+
|
|
212
|
+
const initialStore = {
|
|
213
|
+
gallery: {
|
|
214
|
+
isSaving: {
|
|
215
|
+
save: false,
|
|
216
|
+
saveAdd: false,
|
|
217
|
+
delete: false,
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
const store = mockStore(initialStore);
|
|
223
|
+
|
|
224
|
+
const defaultProps = {
|
|
225
|
+
...defaultGalleryDDProps,
|
|
226
|
+
...defaultDispatchProps,
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const clearDataMock = jest.fn();
|
|
230
|
+
|
|
231
|
+
const galleryDragAndDropComponent = (
|
|
232
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
233
|
+
<GalleryDragAndDrop {...defaultProps} />
|
|
234
|
+
</ThemeProvider>
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
render(galleryDragAndDropComponent, { store });
|
|
238
|
+
|
|
239
|
+
expect(screen.getByTestId("gallery-drag-drop-wrapper")).toBeTruthy();
|
|
240
|
+
const dragDropComponent = screen.getAllByTestId("drag-drop-wrapper");
|
|
241
|
+
expect(dragDropComponent).toBeTruthy();
|
|
242
|
+
|
|
243
|
+
fireEvent.drop(dragDropComponent[0], {
|
|
244
|
+
dataTransfer: {
|
|
245
|
+
files: [new File([""], "darthvader.png", { type: "png" })],
|
|
246
|
+
clearData: clearDataMock,
|
|
247
|
+
},
|
|
248
|
+
});
|
|
249
|
+
expect(clearDataMock).toBeCalled();
|
|
250
|
+
await waitFor(() => expect(refreshImagesMock).toBeCalled());
|
|
251
|
+
});
|
|
252
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { ThemeProvider } from "styled-components";
|
|
4
|
+
import { render, cleanup, screen } from "../../../../../config/jest/test-utils";
|
|
5
|
+
import { mock } from "jest-mock-extended";
|
|
6
|
+
import "@testing-library/jest-dom";
|
|
7
|
+
import configureStore from "redux-mock-store";
|
|
8
|
+
import thunk from "redux-thunk";
|
|
9
|
+
|
|
10
|
+
import { parseTheme } from "@ax/helpers";
|
|
11
|
+
import GalleryPanel, { IGalleryPanelProps } from "@ax/components/Gallery/GalleryPanel";
|
|
12
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
13
|
+
|
|
14
|
+
afterEach(() => {
|
|
15
|
+
cleanup();
|
|
16
|
+
jest.clearAllMocks();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const middlewares: any = [thunk];
|
|
20
|
+
const mockStore = configureStore(middlewares);
|
|
21
|
+
|
|
22
|
+
const defaultProps = mock<IGalleryPanelProps>();
|
|
23
|
+
|
|
24
|
+
defaultProps.isImageSelected = true;
|
|
25
|
+
defaultProps.imageSelected = null;
|
|
26
|
+
defaultProps.validFormats = ["png", "jpg"];
|
|
27
|
+
const setImageMocked = defaultProps.setImage as jest.MockedFunction<(imageData: any) => void>;
|
|
28
|
+
defaultProps.isGlobalTab = true;
|
|
29
|
+
defaultProps.site = 1;
|
|
30
|
+
defaultProps.selectedTab = "";
|
|
31
|
+
const refreshImagesMocked = defaultProps.refreshImages as jest.MockedFunction<() => Promise<void>>;
|
|
32
|
+
|
|
33
|
+
describe("GalleryPanel component rendering", () => {
|
|
34
|
+
it("should render the component", () => {
|
|
35
|
+
const initialStore = {
|
|
36
|
+
gallery: {
|
|
37
|
+
isSaving: {
|
|
38
|
+
save: false,
|
|
39
|
+
saveAdd: false,
|
|
40
|
+
delete: false,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
const store = mockStore(initialStore);
|
|
45
|
+
|
|
46
|
+
render(
|
|
47
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
48
|
+
<GalleryPanel {...defaultProps} />
|
|
49
|
+
</ThemeProvider>,
|
|
50
|
+
{ store }
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
expect(screen.getByTestId("gallery-drag-drop-wrapper")).toBeTruthy();
|
|
54
|
+
expect(screen.getByTestId("detail-panel-wrapper")).toBeTruthy();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { ThemeProvider } from "styled-components";
|
|
3
3
|
import { render, cleanup, screen } from "@testing-library/react";
|
|
4
|
-
import { mock } from "jest-mock-extended";
|
|
5
4
|
import "@testing-library/jest-dom";
|
|
6
5
|
|
|
7
6
|
import { parseTheme } from "@ax/helpers";
|
|
8
|
-
import Image
|
|
7
|
+
import Image from "@ax/components/Image";
|
|
9
8
|
import globalTheme from "@ax/themes/theme.json";
|
|
10
9
|
|
|
11
10
|
afterEach(cleanup);
|
|
12
11
|
|
|
13
|
-
const defaultProps =
|
|
12
|
+
const defaultProps = {
|
|
13
|
+
width: 1,
|
|
14
|
+
url: "",
|
|
15
|
+
};
|
|
14
16
|
|
|
15
17
|
describe("Image component rendering", () => {
|
|
16
18
|
it("should render the component with img tag", () => {
|
|
17
|
-
defaultProps.width = 1;
|
|
18
19
|
defaultProps.url = "https://res.cloudinary.com/url-example.png";
|
|
19
20
|
|
|
20
21
|
render(
|
|
@@ -28,7 +29,6 @@ describe("Image component rendering", () => {
|
|
|
28
29
|
});
|
|
29
30
|
|
|
30
31
|
it("should render the component griddoImage", () => {
|
|
31
|
-
defaultProps.width = 1;
|
|
32
32
|
defaultProps.url = "/url-example.png";
|
|
33
33
|
|
|
34
34
|
render(
|
|
@@ -4,7 +4,7 @@ import { getInnerFields } from "@ax/forms";
|
|
|
4
4
|
import { FieldContainer, FieldGroup } from "@ax/components";
|
|
5
5
|
import { IErrorItem, IPage, ISite } from "@ax/types";
|
|
6
6
|
|
|
7
|
-
const Field = (props:
|
|
7
|
+
const Field = (props: IFieldProps): JSX.Element => {
|
|
8
8
|
const {
|
|
9
9
|
whiteList,
|
|
10
10
|
objKey,
|
|
@@ -30,7 +30,6 @@ const Field = (props: IProps): JSX.Element => {
|
|
|
30
30
|
template,
|
|
31
31
|
setHistoryPush,
|
|
32
32
|
} = props;
|
|
33
|
-
|
|
34
33
|
const isGroup = field.type === "FieldGroup";
|
|
35
34
|
const isCollapsed = isGroup && field.collapsed;
|
|
36
35
|
const isConditional = field.type === "ConditionalField";
|
|
@@ -48,7 +47,7 @@ const Field = (props: IProps): JSX.Element => {
|
|
|
48
47
|
theme,
|
|
49
48
|
site,
|
|
50
49
|
errors,
|
|
51
|
-
deleteError
|
|
50
|
+
deleteError
|
|
52
51
|
);
|
|
53
52
|
}
|
|
54
53
|
|
|
@@ -85,7 +84,7 @@ const Field = (props: IProps): JSX.Element => {
|
|
|
85
84
|
);
|
|
86
85
|
};
|
|
87
86
|
|
|
88
|
-
interface
|
|
87
|
+
export interface IFieldProps {
|
|
89
88
|
whiteList: any;
|
|
90
89
|
objKey: string;
|
|
91
90
|
field: any;
|
|
@@ -7,7 +7,7 @@ import ConnectedField from "./ConnectedField";
|
|
|
7
7
|
|
|
8
8
|
import * as S from "./style";
|
|
9
9
|
|
|
10
|
-
export const Form = (props:
|
|
10
|
+
export const Form = (props: IFormProps): JSX.Element => {
|
|
11
11
|
const { schema, selectedTab, setSelectedTab, actions, isPage, isGlobal, theme, setHistoryPush, header, footer } =
|
|
12
12
|
props;
|
|
13
13
|
const tabContent = schema.configTabs.find((tab: ISchemaTab) => tab.title === selectedTab);
|
|
@@ -63,16 +63,24 @@ export const Form = (props: IProps): JSX.Element => {
|
|
|
63
63
|
actions.restorePageNavigationAction && actions.restorePageNavigationAction("footer");
|
|
64
64
|
|
|
65
65
|
return (
|
|
66
|
-
<section>
|
|
66
|
+
<section data-testid="form-section">
|
|
67
67
|
<Tabs tabs={tabs} active={selectedTab} setSelectedTab={setTab} />
|
|
68
68
|
{selectedTab === "content" && !isGlobal && header === 0 && (
|
|
69
69
|
<S.FieldWrapper>
|
|
70
|
-
This page doesn't have a header. Click
|
|
70
|
+
This page doesn't have a header. Click{" "}
|
|
71
|
+
<S.Link data-testid="header-link" onClick={handleRestoreHeader}>
|
|
72
|
+
here
|
|
73
|
+
</S.Link>{" "}
|
|
74
|
+
to restore it.
|
|
71
75
|
</S.FieldWrapper>
|
|
72
76
|
)}
|
|
73
77
|
{selectedTab === "content" && !isGlobal && footer === 0 && (
|
|
74
78
|
<S.FieldWrapper>
|
|
75
|
-
This page doesn't have a footer. Click
|
|
79
|
+
This page doesn't have a footer. Click{" "}
|
|
80
|
+
<S.Link data-testid="footer-link" onClick={handleRestoreFooter}>
|
|
81
|
+
here
|
|
82
|
+
</S.Link>{" "}
|
|
83
|
+
to restore it.
|
|
76
84
|
</S.FieldWrapper>
|
|
77
85
|
)}
|
|
78
86
|
{tabContent && tabContent.fields.map((field: ISchemaField) => generateFields(field))}
|
|
@@ -80,7 +88,7 @@ export const Form = (props: IProps): JSX.Element => {
|
|
|
80
88
|
);
|
|
81
89
|
};
|
|
82
90
|
|
|
83
|
-
interface
|
|
91
|
+
export interface IFormProps {
|
|
84
92
|
selectedTab: string;
|
|
85
93
|
schema: ISchema;
|
|
86
94
|
actions: any;
|
|
@@ -9,7 +9,7 @@ import * as S from "./style";
|
|
|
9
9
|
const noteText = "This is Global content and you cannot edit it here. To do so, you must go to the Global page";
|
|
10
10
|
const noteTitle = "Global content";
|
|
11
11
|
|
|
12
|
-
const GlobalPageForm = (props:
|
|
12
|
+
const GlobalPageForm = (props: IGlobalPageFormProps): JSX.Element => {
|
|
13
13
|
const { selectedTab, setSelectedTab, schema, pageTitle, setHistoryPush, actions, header, footer } = props;
|
|
14
14
|
const tabs = ["content", "config"];
|
|
15
15
|
|
|
@@ -39,19 +39,19 @@ const GlobalPageForm = (props: IProps): JSX.Element => {
|
|
|
39
39
|
actions.restorePageNavigationAction && actions.restorePageNavigationAction("footer");
|
|
40
40
|
|
|
41
41
|
return (
|
|
42
|
-
<section>
|
|
42
|
+
<section data-testid="global-page-section">
|
|
43
43
|
<Tabs tabs={tabs} active={selectedTab} setSelectedTab={setSelectedTab} />
|
|
44
44
|
<S.NoteWrapper>
|
|
45
45
|
<NoteField value={{ text: noteText, title: noteTitle }} />
|
|
46
46
|
</S.NoteWrapper>
|
|
47
47
|
{selectedTab === "content" && header === 0 && (
|
|
48
48
|
<S.FieldWrapper>
|
|
49
|
-
This page doesn't have a header. Click <S.Link onClick={handleRestoreHeader}>here</S.Link> to restore it.
|
|
49
|
+
This page doesn't have a header. Click <S.Link data-testid="header-link" onClick={handleRestoreHeader}>here</S.Link> to restore it.
|
|
50
50
|
</S.FieldWrapper>
|
|
51
51
|
)}
|
|
52
52
|
{selectedTab === "content" && footer === 0 && (
|
|
53
53
|
<S.FieldWrapper>
|
|
54
|
-
This page doesn't have a footer. Click <S.Link onClick={handleRestoreFooter}>here</S.Link> to restore it.
|
|
54
|
+
This page doesn't have a footer. Click <S.Link data-testid="footer-link" onClick={handleRestoreFooter}>here</S.Link> to restore it.
|
|
55
55
|
</S.FieldWrapper>
|
|
56
56
|
)}
|
|
57
57
|
{selectedTab === "content" && (
|
|
@@ -80,7 +80,7 @@ const GlobalPageForm = (props: IProps): JSX.Element => {
|
|
|
80
80
|
);
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
-
interface
|
|
83
|
+
export interface IGlobalPageFormProps {
|
|
84
84
|
selectedTab: string;
|
|
85
85
|
setSelectedTab(tab: string): void;
|
|
86
86
|
schema: ISchema;
|
|
@@ -6,7 +6,7 @@ import { useToast } from "@ax/hooks";
|
|
|
6
6
|
|
|
7
7
|
import * as S from "./style";
|
|
8
8
|
|
|
9
|
-
const Header = (props:
|
|
9
|
+
const Header = (props: IHeaderProps) => {
|
|
10
10
|
const { breadcrumb, schema, selectedParent, activatedModules, actions, setSelectedContent } = props;
|
|
11
11
|
const { duplicateModuleAction, deleteModuleAction, copyModuleAction } = actions;
|
|
12
12
|
const title = breadcrumb[breadcrumb.length - 1].displayName;
|
|
@@ -59,7 +59,7 @@ const Header = (props: IProps) => {
|
|
|
59
59
|
|
|
60
60
|
return (
|
|
61
61
|
<>
|
|
62
|
-
<S.HeaderWrapper>
|
|
62
|
+
<S.HeaderWrapper data-testid="header-config-wrapper">
|
|
63
63
|
<S.Title>{title}</S.Title>
|
|
64
64
|
<Breadcrumb breadcrumb={breadcrumb} setSelectedContent={setSelectedContent} />
|
|
65
65
|
{isInArray && <S.StyledActionMenu icon="more" options={menuOptions} tooltip="Actions" />}
|
|
@@ -69,7 +69,7 @@ const Header = (props: IProps) => {
|
|
|
69
69
|
);
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
interface
|
|
72
|
+
export interface IHeaderProps {
|
|
73
73
|
schema: any;
|
|
74
74
|
actions: any;
|
|
75
75
|
breadcrumb: IBreadcrumbItem[];
|
|
@@ -9,6 +9,7 @@ import * as S from "./style";
|
|
|
9
9
|
|
|
10
10
|
const Field = (props: IProps) => {
|
|
11
11
|
const { type, defaults, updateEditorContent, selectedContent, theme, removeNavigationFromPage } = props;
|
|
12
|
+
|
|
12
13
|
const { isOpen, toggleModal } = useModal();
|
|
13
14
|
const isDefault = selectedContent.setAsDefault;
|
|
14
15
|
|
|
@@ -19,6 +20,7 @@ const Field = (props: IProps) => {
|
|
|
19
20
|
});
|
|
20
21
|
|
|
21
22
|
const hasMultipleOptions: boolean | undefined = options && options.length > 0;
|
|
23
|
+
|
|
22
24
|
let filteredByDefaultOptions = options;
|
|
23
25
|
if (!isDefault && hasMultipleOptions) {
|
|
24
26
|
filteredByDefaultOptions = options.filter((component: any) => !component.setAsDefault);
|
|
@@ -85,17 +87,17 @@ const Field = (props: IProps) => {
|
|
|
85
87
|
);
|
|
86
88
|
};
|
|
87
89
|
|
|
88
|
-
interface IField {
|
|
90
|
+
export interface IField {
|
|
89
91
|
type: string;
|
|
90
92
|
theme: string;
|
|
91
93
|
}
|
|
92
94
|
|
|
93
|
-
interface IStateProps {
|
|
95
|
+
export interface IStateProps {
|
|
94
96
|
defaults: any;
|
|
95
97
|
selectedContent: any;
|
|
96
98
|
}
|
|
97
99
|
|
|
98
|
-
interface IDispatchProps {
|
|
100
|
+
export interface IDispatchProps {
|
|
99
101
|
updateEditorContent: (selectedEditorID: number, key: string, value: any) => void;
|
|
100
102
|
removeNavigationFromPage: (key: string) => void;
|
|
101
103
|
}
|
|
@@ -7,7 +7,7 @@ import * as S from "./style";
|
|
|
7
7
|
|
|
8
8
|
const noteText = "To create a new header or configure one of them, go to Navigation/Navigations modules";
|
|
9
9
|
|
|
10
|
-
const NavigationForm = (props:
|
|
10
|
+
const NavigationForm = (props: INavigationFormProps): JSX.Element => {
|
|
11
11
|
const { schema, theme } = props;
|
|
12
12
|
|
|
13
13
|
return (
|
|
@@ -23,7 +23,7 @@ const NavigationForm = (props: IProps): JSX.Element => {
|
|
|
23
23
|
);
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
interface
|
|
26
|
+
export interface INavigationFormProps {
|
|
27
27
|
schema: any;
|
|
28
28
|
theme: string;
|
|
29
29
|
}
|
|
@@ -5,7 +5,7 @@ import { IUserEditing } from "@ax/types";
|
|
|
5
5
|
|
|
6
6
|
import * as S from "./style";
|
|
7
7
|
|
|
8
|
-
const PreviewForm = (props:
|
|
8
|
+
const PreviewForm = (props: IPreviewFormProps): JSX.Element => {
|
|
9
9
|
const { selectedTab, setSelectedTab, userEditing } = props;
|
|
10
10
|
const tabs = ["content"];
|
|
11
11
|
|
|
@@ -20,14 +20,14 @@ const PreviewForm = (props: IProps): JSX.Element => {
|
|
|
20
20
|
return (
|
|
21
21
|
<section>
|
|
22
22
|
<Tabs tabs={tabs} active={selectedTab} setSelectedTab={setSelectedTab} />
|
|
23
|
-
<S.FieldWrapper>
|
|
23
|
+
<S.FieldWrapper data-testid="preview-form-wrapper">
|
|
24
24
|
<NoteField value={{ text: noteText, title: noteTitle }} />
|
|
25
25
|
</S.FieldWrapper>
|
|
26
26
|
</section>
|
|
27
27
|
);
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
interface
|
|
30
|
+
export interface IPreviewFormProps {
|
|
31
31
|
selectedTab: string;
|
|
32
32
|
setSelectedTab(tab: string): void;
|
|
33
33
|
userEditing?: IUserEditing | null;
|
|
@@ -49,7 +49,6 @@ const ConfigPanel = (props: IStateProps): JSX.Element => {
|
|
|
49
49
|
if (isLoading || isEmptyObj(schema)) {
|
|
50
50
|
return <Loading />;
|
|
51
51
|
}
|
|
52
|
-
|
|
53
52
|
const showNavigationForm = navigationModulesTypes.includes(schema.type) && isPage;
|
|
54
53
|
const isGlobalPageNotEditable = isGlobal && isPage && !isEditable;
|
|
55
54
|
|
|
@@ -91,7 +90,7 @@ const ConfigPanel = (props: IStateProps): JSX.Element => {
|
|
|
91
90
|
};
|
|
92
91
|
|
|
93
92
|
return (
|
|
94
|
-
<S.Wrapper ref={wrapperRef}>
|
|
93
|
+
<S.Wrapper data-testid="config-panel-wrapper" ref={wrapperRef}>
|
|
95
94
|
<Header
|
|
96
95
|
schema={schema}
|
|
97
96
|
actions={actions}
|
|
@@ -105,7 +104,7 @@ const ConfigPanel = (props: IStateProps): JSX.Element => {
|
|
|
105
104
|
);
|
|
106
105
|
};
|
|
107
106
|
|
|
108
|
-
interface IStateProps {
|
|
107
|
+
export interface IStateProps {
|
|
109
108
|
isLoading: boolean;
|
|
110
109
|
schema: any;
|
|
111
110
|
actions: any;
|
|
@@ -11,11 +11,11 @@ const FieldGroup = (props: IFieldsGroupProps): React.ReactElement => {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
|
-
<S.Wrapper data-testid="
|
|
15
|
-
<S.Label data-testid="
|
|
14
|
+
<S.Wrapper data-testid="field-group-wrapper">
|
|
15
|
+
<S.Label data-testid="field-group-label" onClick={handleClick} isOpen={isOpen}>
|
|
16
16
|
{title}
|
|
17
17
|
</S.Label>
|
|
18
|
-
<S.Content data-testid="
|
|
18
|
+
<S.Content data-testid="field-group-content" isOpen={isOpen}>
|
|
19
19
|
{children}
|
|
20
20
|
</S.Content>
|
|
21
21
|
</S.Wrapper>
|
|
@@ -7,8 +7,8 @@ const NoteField = (props: INoteFieldProps): JSX.Element => {
|
|
|
7
7
|
const { title, text } = value;
|
|
8
8
|
|
|
9
9
|
return (
|
|
10
|
-
<S.Wrapper className={className} data-testid="
|
|
11
|
-
{title && <S.Title data-testid="title">{title}</S.Title>}
|
|
10
|
+
<S.Wrapper className={className} data-testid="note-field-wrapper">
|
|
11
|
+
{title && <S.Title data-testid="note-field-title">{title}</S.Title>}
|
|
12
12
|
<S.Text>{text}</S.Text>
|
|
13
13
|
</S.Wrapper>
|
|
14
14
|
);
|
|
@@ -31,13 +31,20 @@ const SliderField = (props: ITextFieldProps): JSX.Element => {
|
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
return (
|
|
34
|
-
<S.Slider data-testid="
|
|
35
|
-
<S.Bubble data-testid="
|
|
34
|
+
<S.Slider data-testid="slider-component">
|
|
35
|
+
<S.Bubble data-testid="bubble-component" ref={bubbleRef}>
|
|
36
36
|
{prefix && `${prefix} `}
|
|
37
37
|
{val}
|
|
38
38
|
{suffix && ` ${suffix}`}
|
|
39
39
|
</S.Bubble>
|
|
40
|
-
<S.Input
|
|
40
|
+
<S.Input
|
|
41
|
+
data-testid="input-slider-component"
|
|
42
|
+
value={val}
|
|
43
|
+
min={min}
|
|
44
|
+
max={max}
|
|
45
|
+
step={step}
|
|
46
|
+
onChange={handleChange}
|
|
47
|
+
/>
|
|
41
48
|
</S.Slider>
|
|
42
49
|
);
|
|
43
50
|
};
|
|
@@ -36,14 +36,14 @@ const TagField = (props: IProps): JSX.Element => {
|
|
|
36
36
|
const placeholder = valueArray.length > 0 ? "" : "Type a tag...";
|
|
37
37
|
|
|
38
38
|
return (
|
|
39
|
-
<S.Wrapper data-testid="
|
|
39
|
+
<S.Wrapper data-testid="tag-field-wrapper" onClick={_handleClick}>
|
|
40
40
|
{valueArray &&
|
|
41
41
|
valueArray.map((tag: string, index: number) => {
|
|
42
42
|
const handleDelete = () => deleteTag(index);
|
|
43
43
|
return <Tag key={tag} text={tag} onDeleteAction={handleDelete} />;
|
|
44
44
|
})}
|
|
45
45
|
<S.Input
|
|
46
|
-
data-testid="
|
|
46
|
+
data-testid="tag-field-input"
|
|
47
47
|
ref={inputRef}
|
|
48
48
|
type="text"
|
|
49
49
|
value={inputValue}
|