@griddo/ax 11.0.29-rc.0 → 11.0.30-rc.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/config/griddo-config/cx-polyfills/componentsBundle.js +1 -1
- package/package.json +2 -2
- package/scripts/griddo-sync-schemas.js +49 -42
- package/src/GlobalStore.tsx +3 -0
- package/src/__tests__/components/TableFilters/LiveFilter/LiveFilter.test.tsx +6 -0
- package/src/api/forms.tsx +191 -0
- package/src/api/index.tsx +2 -0
- package/src/components/Browser/index.tsx +42 -37
- package/src/components/Browser/style.tsx +3 -3
- package/src/components/BrowserContent/index.tsx +1 -1
- package/src/components/ConfigPanel/Form/index.tsx +6 -5
- package/src/components/ConfigPanel/GlobalPageForm/index.tsx +3 -1
- package/src/components/ConfigPanel/Header/index.tsx +1 -0
- package/src/components/Fields/ComponentArray/MixableComponentArray/AddItemButton/index.tsx +4 -5
- package/src/components/Fields/ComponentArray/MixableComponentArray/index.tsx +4 -4
- package/src/components/Fields/ComponentArray/helpers.tsx +1 -1
- package/src/components/Fields/FormFieldArray/index.tsx +13 -0
- package/src/components/Fields/ReferenceField/AutoPanel/index.tsx +1 -2
- package/src/components/Fields/ReferenceField/Context/index.tsx +0 -2
- package/src/components/Fields/ReferenceField/ItemList/index.tsx +1 -2
- package/src/components/Fields/ReferenceField/ManualPanel/index.tsx +2 -2
- package/src/components/Fields/ReferenceField/index.tsx +1 -5
- package/src/components/Fields/TranslateButton/index.tsx +48 -10
- package/src/components/Fields/Wysiwyg/helpers.tsx +2 -2
- package/src/components/Fields/Wysiwyg/index.tsx +4 -11
- package/src/components/Fields/index.tsx +2 -0
- package/src/components/FieldsBehavior/index.tsx +8 -2
- package/src/components/Icon/components/Form.js +12 -0
- package/src/components/Icon/svgs/Form.svg +3 -0
- package/src/components/LanguageMenu/index.tsx +30 -27
- package/src/components/MainWrapper/AppBar/index.tsx +23 -68
- package/src/components/MainWrapper/index.tsx +4 -9
- package/src/components/MenuItem/index.tsx +2 -2
- package/src/components/ResizePanel/index.tsx +3 -2
- package/src/components/ResizePanel/style.tsx +11 -9
- package/src/components/SearchField/style.tsx +2 -2
- package/src/components/SideModal/SideModalOption/index.tsx +3 -2
- package/src/components/SideModal/SideModalOption/style.tsx +2 -2
- package/src/components/SideModal/index.tsx +11 -4
- package/src/components/SideModal/style.tsx +9 -7
- package/src/components/TableFilters/LiveFilter/index.tsx +4 -3
- package/src/components/index.tsx +4 -0
- package/src/containers/App/reducer.tsx +4 -1
- package/src/containers/Forms/actions.tsx +853 -0
- package/src/containers/Forms/constants.tsx +46 -0
- package/src/containers/Forms/index.tsx +4 -0
- package/src/containers/Forms/interfaces.tsx +95 -0
- package/src/containers/Forms/reducer.tsx +81 -0
- package/src/containers/Forms/utils.tsx +42 -0
- package/src/containers/Navigation/Menu/actions.tsx +6 -13
- package/src/containers/Navigation/Menu/reducer.tsx +0 -4
- package/src/containers/PageEditor/actions.tsx +3 -2
- package/src/containers/PageEditor/reducer.tsx +2 -2
- package/src/forms/editor.tsx +3 -1
- package/src/helpers/index.tsx +12 -1
- package/src/helpers/schemas.tsx +35 -9
- package/src/helpers/structuredData.tsx +3 -1
- package/src/helpers/themes.tsx +3 -1
- package/src/helpers/thumbnails.tsx +20 -2
- package/src/modules/Analytics/GroupPanel/utils.tsx +3 -1
- package/src/modules/App/Routing/NavMenu/index.tsx +16 -6
- package/src/modules/App/Routing/index.tsx +26 -9
- package/src/modules/Categories/CategoriesList/CategoryItem/index.tsx +4 -4
- package/src/modules/Categories/CategoriesList/index.tsx +16 -16
- package/src/modules/Content/BulkHeader/TableHeader/index.tsx +1 -5
- package/src/modules/Content/PageItem/index.tsx +34 -33
- package/src/modules/Content/index.tsx +23 -36
- package/src/modules/Content/utils.tsx +3 -1
- package/src/modules/Forms/FormCategoriesList/BulkHeader/TableHeader/index.tsx +42 -0
- package/src/modules/Forms/FormCategoriesList/BulkHeader/TableHeader/style.tsx +36 -0
- package/src/modules/Forms/FormCategoriesList/BulkHeader/index.tsx +37 -0
- package/src/modules/Forms/FormCategoriesList/BulkHeader/style.tsx +9 -0
- package/src/modules/Forms/FormCategoriesList/CategoryItem/index.tsx +125 -0
- package/src/modules/Forms/FormCategoriesList/CategoryItem/style.tsx +91 -0
- package/src/modules/Forms/FormCategoriesList/CategoryPanel/Form/index.tsx +50 -0
- package/src/modules/Forms/FormCategoriesList/CategoryPanel/index.tsx +112 -0
- package/src/modules/Forms/FormCategoriesList/CategoryPanel/style.tsx +31 -0
- package/src/modules/Forms/FormCategoriesList/atoms.tsx +33 -0
- package/src/modules/Forms/FormCategoriesList/hooks.tsx +61 -0
- package/src/modules/Forms/FormCategoriesList/index.tsx +245 -0
- package/src/modules/Forms/FormCategoriesList/style.tsx +82 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/Field/index.tsx +95 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/TemplateManager/index.tsx +102 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/TemplateManager/style.tsx +9 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/index.tsx +109 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/index.tsx +76 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/style.tsx +28 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Header/index.tsx +132 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Header/style.tsx +30 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/index.tsx +86 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/style.tsx +7 -0
- package/src/modules/Forms/FormEditor/Editor/index.tsx +106 -0
- package/src/modules/Forms/FormEditor/PageBrowser/index.tsx +96 -0
- package/src/modules/Forms/FormEditor/index.tsx +295 -0
- package/src/modules/Forms/FormEditor/style.tsx +32 -0
- package/src/modules/Forms/FormList/BulkHeader/TableHeader/index.tsx +61 -0
- package/src/modules/Forms/FormList/BulkHeader/TableHeader/style.tsx +47 -0
- package/src/modules/Forms/FormList/BulkHeader/index.tsx +60 -0
- package/src/modules/Forms/FormList/FormItem/index.tsx +218 -0
- package/src/modules/Forms/FormList/FormItem/style.tsx +87 -0
- package/src/modules/Forms/FormList/Summary/index.tsx +51 -0
- package/src/modules/Forms/FormList/Summary/style.tsx +46 -0
- package/src/modules/Forms/FormList/TemplateModal/index.tsx +67 -0
- package/src/modules/Forms/FormList/TemplateModal/style.tsx +54 -0
- package/src/modules/Forms/FormList/index.tsx +266 -0
- package/src/modules/Forms/FormList/style.tsx +31 -0
- package/src/modules/Forms/FormsMenu/MenuGroup/index.tsx +57 -0
- package/src/modules/Forms/FormsMenu/MenuGroup/style.tsx +55 -0
- package/src/modules/Forms/FormsMenu/index.tsx +78 -0
- package/src/modules/Forms/FormsMenu/style.tsx +9 -0
- package/src/modules/Forms/atoms.tsx +111 -0
- package/src/modules/Forms/style.tsx +11 -0
- package/src/modules/FramePreview/index.tsx +26 -12
- package/src/modules/GlobalEditor/index.tsx +52 -21
- package/src/modules/Navigation/Defaults/DefaultsEditor/index.tsx +32 -15
- package/src/modules/Navigation/Defaults/Item/atoms.tsx +6 -5
- package/src/modules/Navigation/Defaults/Item/index.tsx +10 -10
- package/src/modules/Navigation/Defaults/index.tsx +7 -6
- package/src/modules/Navigation/Menus/List/Nav/index.tsx +2 -10
- package/src/modules/Navigation/Menus/List/Table/SidePanel/Form/index.tsx +14 -11
- package/src/modules/Navigation/Menus/List/index.tsx +15 -16
- package/src/modules/Navigation/Menus/index.tsx +9 -17
- package/src/modules/PageEditor/index.tsx +54 -31
- package/src/modules/Settings/Globals/index.tsx +3 -1
- package/src/modules/Settings/Languages/Table/Item/index.tsx +11 -9
- package/src/modules/Sites/SitesList/ListView/BulkHeader/TableHeader/index.tsx +1 -1
- package/src/modules/StructuredData/Form/index.tsx +41 -28
- package/src/modules/StructuredData/StructuredDataList/BulkHeader/TableHeader/index.tsx +1 -5
- package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +6 -8
- package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/index.tsx +5 -7
- package/src/modules/StructuredData/StructuredDataList/index.tsx +13 -10
- package/src/modules/StructuredData/StructuredDataList/utils.tsx +2 -1
- package/src/routes/multisite.tsx +53 -16
- package/src/routes/site.tsx +1 -0
- package/src/schemas/pages/FormPage.tsx +49 -0
- package/src/schemas/pages/GlobalPage.tsx +1 -0
- package/src/schemas/pages/Page.tsx +4 -1
- package/src/schemas/pages/index.tsx +2 -1
- package/src/types/forms.tsx +87 -0
- package/src/types/index.tsx +43 -7
- /package/src/modules/Navigation/Menus/{helpers.tsx → List/helpers.tsx} +0 -0
|
@@ -84,7 +84,7 @@ const MixableComponentArray = (props: IMixableComponentArrayProps): JSX.Element
|
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
const isComponentModule = contentType === "components";
|
|
87
|
-
const isModuleArr = contentType === "modules";
|
|
87
|
+
const isModuleArr = contentType === "modules" || contentType === "fields";
|
|
88
88
|
|
|
89
89
|
const handleAddModule = (moduleType: string) =>
|
|
90
90
|
addModuleAction && addModuleAction(moduleType, objKey, editorID, isComponentModule);
|
|
@@ -97,7 +97,7 @@ const MixableComponentArray = (props: IMixableComponentArrayProps): JSX.Element
|
|
|
97
97
|
const { modules } = selectedContent;
|
|
98
98
|
if (isModuleArr && deleteModuleAction && modules?.length > 0) {
|
|
99
99
|
const currentModule: IModule = modules[0];
|
|
100
|
-
deleteModuleAction([currentModule.editorID],
|
|
100
|
+
deleteModuleAction([currentModule.editorID], objKey);
|
|
101
101
|
handleAddModule(moduleType);
|
|
102
102
|
} else {
|
|
103
103
|
replaceElementsInCollectionAction && replaceElementsInCollectionAction(moduleType);
|
|
@@ -278,8 +278,8 @@ const MixableComponentArray = (props: IMixableComponentArrayProps): JSX.Element
|
|
|
278
278
|
whiteList={whiteList}
|
|
279
279
|
categories={categories}
|
|
280
280
|
handleClick={handleAdd}
|
|
281
|
-
isModuleArr={isModuleArr}
|
|
282
281
|
theme={theme}
|
|
282
|
+
contentType={contentType}
|
|
283
283
|
/>
|
|
284
284
|
)}
|
|
285
285
|
</S.ActionsWrapper>
|
|
@@ -333,7 +333,7 @@ export interface IMixableComponentArrayProps {
|
|
|
333
333
|
setNotificationAction: (notification: INotification) => void;
|
|
334
334
|
replaceModuleAction: (module: any, parent: any, objKey: string) => void;
|
|
335
335
|
};
|
|
336
|
-
categories?: any;
|
|
336
|
+
categories?: any[];
|
|
337
337
|
disabled?: boolean;
|
|
338
338
|
activatedModules: string[];
|
|
339
339
|
objKey: string;
|
|
@@ -19,7 +19,7 @@ const getComponentProps = (element: IModule, activatedModules: string[], isModul
|
|
|
19
19
|
const schemaType = getSchemaType(component);
|
|
20
20
|
const displayName = getDisplayName(component);
|
|
21
21
|
const title = getComponentTitle(component, element.title);
|
|
22
|
-
const isModule = schemaType === "module";
|
|
22
|
+
const isModule = schemaType === "module" || schemaType === "formComponent";
|
|
23
23
|
const moduleTitle = isModule && displayName !== title && title;
|
|
24
24
|
const componentTitle = !isModule && displayName !== title && title;
|
|
25
25
|
const isModuleDeactivated = isModuleArr && activatedModules && !activatedModules.includes(component);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import MixableComponentArray, { IMixableComponentArrayProps } from "../ComponentArray/MixableComponentArray";
|
|
4
|
+
|
|
5
|
+
const FormFieldArray = (props: IMixableComponentArrayProps): JSX.Element => {
|
|
6
|
+
const formFieldArrayProps: IMixableComponentArrayProps = {
|
|
7
|
+
...props,
|
|
8
|
+
field: { ...props.field, contentType: "fields" },
|
|
9
|
+
};
|
|
10
|
+
return <MixableComponentArray {...formFieldArrayProps} />;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default FormFieldArray;
|
|
@@ -158,7 +158,6 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
158
158
|
preferenceLanguage: state.preferenceLanguage,
|
|
159
159
|
lang: state.lang,
|
|
160
160
|
site: state.site,
|
|
161
|
-
fields: state.fields,
|
|
162
161
|
};
|
|
163
162
|
|
|
164
163
|
onChange(newValue);
|
|
@@ -354,7 +353,7 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
354
353
|
<S.ConfigWrapper>
|
|
355
354
|
<S.SubConfigContent hasMargin={true}>
|
|
356
355
|
<S.OptionDescription isOpen={configState.isCustomLangOpen}>
|
|
357
|
-
By default, content is shown in the page
|
|
356
|
+
By default, content is shown in the page's language. Activate this option to{" "}
|
|
358
357
|
<strong>specifically set a different language</strong> for the content shown in this
|
|
359
358
|
distributor.
|
|
360
359
|
</S.OptionDescription>
|
|
@@ -96,7 +96,6 @@ export interface IReferenceState {
|
|
|
96
96
|
preferenceLanguage: boolean;
|
|
97
97
|
lang?: number;
|
|
98
98
|
site?: number;
|
|
99
|
-
fields?: string[];
|
|
100
99
|
}
|
|
101
100
|
|
|
102
101
|
export interface IRefField {
|
|
@@ -110,7 +109,6 @@ export interface IRefField {
|
|
|
110
109
|
preferenceLanguage?: boolean;
|
|
111
110
|
lang?: number;
|
|
112
111
|
site?: number;
|
|
113
|
-
fields?: string[];
|
|
114
112
|
}
|
|
115
113
|
|
|
116
114
|
export interface IFilter {
|
|
@@ -14,7 +14,7 @@ const ItemList = (props: IProps) => {
|
|
|
14
14
|
const { items, currentSite, handleListDelete, handleListMove, site } = props;
|
|
15
15
|
|
|
16
16
|
const { state, setState, setReorderElements } = useReference();
|
|
17
|
-
const { fixed, selectedItems, sourceTitles, fullRelations
|
|
17
|
+
const { fixed, selectedItems, sourceTitles, fullRelations } = state;
|
|
18
18
|
|
|
19
19
|
const getParams = useCallback(() => {
|
|
20
20
|
const params = {
|
|
@@ -22,7 +22,6 @@ const ItemList = (props: IProps) => {
|
|
|
22
22
|
fixed: items,
|
|
23
23
|
fullRelations,
|
|
24
24
|
site,
|
|
25
|
-
fields,
|
|
26
25
|
};
|
|
27
26
|
|
|
28
27
|
return params;
|
|
@@ -94,8 +94,8 @@ const ManualPanel = (props: IProps) => {
|
|
|
94
94
|
setState((state: IReferenceState) => ({ ...state, showSelected: !state.showSelected }));
|
|
95
95
|
|
|
96
96
|
const handleAdd = () => {
|
|
97
|
-
const { mode, fixed, fullRelations, site, lang
|
|
98
|
-
const newValue = { mode, fixed, fullRelations, site, lang
|
|
97
|
+
const { mode, fixed, fullRelations, site, lang } = state;
|
|
98
|
+
const newValue = { mode, fixed, fullRelations, site, lang };
|
|
99
99
|
onChange(newValue);
|
|
100
100
|
handleValidation && handleValidation(state.fixed, validators);
|
|
101
101
|
};
|
|
@@ -45,7 +45,7 @@ const ReferenceField = (props: IReferenceFieldProps) => {
|
|
|
45
45
|
const isAuto = mode === "auto";
|
|
46
46
|
const hasMaxItems = !!(value && value.fixed && maxItems && !isAuto && value.fixed.length >= maxItems);
|
|
47
47
|
const sourcesIDs = sources.map((source: ISource) => source.structuredData);
|
|
48
|
-
const { fixed, order, quantity, allLanguages, preferenceLanguage, fullRelations = false
|
|
48
|
+
const { fixed, order, quantity, allLanguages, preferenceLanguage, fullRelations = false } = state;
|
|
49
49
|
|
|
50
50
|
const handleMode = (mode: string) => {
|
|
51
51
|
const manualSources: string[] = state.selectedItems.reduce(
|
|
@@ -69,14 +69,12 @@ const ReferenceField = (props: IReferenceFieldProps) => {
|
|
|
69
69
|
fullRelations,
|
|
70
70
|
allLanguages,
|
|
71
71
|
preferenceLanguage,
|
|
72
|
-
fields,
|
|
73
72
|
}
|
|
74
73
|
: {
|
|
75
74
|
mode,
|
|
76
75
|
sources,
|
|
77
76
|
fixed,
|
|
78
77
|
fullRelations,
|
|
79
|
-
fields,
|
|
80
78
|
};
|
|
81
79
|
onChange(newValue);
|
|
82
80
|
setModeAndSource(mode, mappedSources);
|
|
@@ -136,7 +134,6 @@ const ReferenceField = (props: IReferenceFieldProps) => {
|
|
|
136
134
|
mode,
|
|
137
135
|
fixed,
|
|
138
136
|
fullRelations,
|
|
139
|
-
fields,
|
|
140
137
|
};
|
|
141
138
|
onChange(newValue);
|
|
142
139
|
resetValidation && resetValidation();
|
|
@@ -147,7 +144,6 @@ const ReferenceField = (props: IReferenceFieldProps) => {
|
|
|
147
144
|
mode,
|
|
148
145
|
fixed,
|
|
149
146
|
fullRelations,
|
|
150
|
-
fields,
|
|
151
147
|
};
|
|
152
148
|
onChange(newValue);
|
|
153
149
|
};
|
|
@@ -2,9 +2,10 @@ import React, { useState } from "react";
|
|
|
2
2
|
import { connect } from "react-redux";
|
|
3
3
|
import { Icon, Modal } from "@ax/components";
|
|
4
4
|
import { useModal } from "@ax/hooks";
|
|
5
|
-
import { IRootState } from "@ax/types";
|
|
5
|
+
import { FormContent, IRootState } from "@ax/types";
|
|
6
6
|
import { pageEditorActions } from "@ax/containers/PageEditor";
|
|
7
7
|
import { structuredDataActions } from "@ax/containers/StructuredData";
|
|
8
|
+
import { formsActions } from "@ax/containers/Forms";
|
|
8
9
|
|
|
9
10
|
import * as S from "./style";
|
|
10
11
|
|
|
@@ -12,17 +13,45 @@ const TranslateButton = (props: ITranslateButtonProps): JSX.Element => {
|
|
|
12
13
|
const {
|
|
13
14
|
lang,
|
|
14
15
|
autoTranslation,
|
|
16
|
+
contentType,
|
|
15
17
|
getPageTranslation,
|
|
16
|
-
|
|
18
|
+
editorContent,
|
|
17
19
|
isPageIATranslated,
|
|
18
20
|
isDataContentIATranslated,
|
|
19
21
|
setIsPageTranslated,
|
|
20
22
|
structuredDataForm,
|
|
21
23
|
getDataContentTranslation,
|
|
22
24
|
setIsContentTranslated,
|
|
25
|
+
formContent,
|
|
26
|
+
isFormIATranslated,
|
|
27
|
+
getFormTranslation,
|
|
28
|
+
setIsFormTranslated,
|
|
23
29
|
} = props;
|
|
24
30
|
|
|
25
|
-
const
|
|
31
|
+
const getContent = (type: "page" | "data" | "form") => {
|
|
32
|
+
return {
|
|
33
|
+
page: {
|
|
34
|
+
content: editorContent,
|
|
35
|
+
isIATranslated: isPageIATranslated,
|
|
36
|
+
getTranslationAction: getPageTranslation,
|
|
37
|
+
setIsTranslated: setIsPageTranslated,
|
|
38
|
+
},
|
|
39
|
+
data: {
|
|
40
|
+
content: structuredDataForm,
|
|
41
|
+
isIATranslated: isDataContentIATranslated,
|
|
42
|
+
getTranslationAction: getDataContentTranslation,
|
|
43
|
+
setIsTranslated: setIsContentTranslated,
|
|
44
|
+
},
|
|
45
|
+
form: {
|
|
46
|
+
content: formContent,
|
|
47
|
+
isIATranslated: isFormIATranslated,
|
|
48
|
+
getTranslationAction: getFormTranslation,
|
|
49
|
+
setIsTranslated: setIsFormTranslated,
|
|
50
|
+
},
|
|
51
|
+
}[type];
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const { content, isIATranslated, getTranslationAction, setIsTranslated } = getContent(contentType);
|
|
26
55
|
|
|
27
56
|
const initialState = {
|
|
28
57
|
isLoading: false,
|
|
@@ -35,20 +64,20 @@ const TranslateButton = (props: ITranslateButtonProps): JSX.Element => {
|
|
|
35
64
|
const handleClick = async () => {
|
|
36
65
|
toggleModal();
|
|
37
66
|
setState((state) => ({ ...state, isLoading: true, error: false }));
|
|
38
|
-
const generated =
|
|
67
|
+
const generated = await getTranslationAction(lang);
|
|
39
68
|
setState((state) => ({ ...state, isLoading: false }));
|
|
40
69
|
if (!generated) {
|
|
41
70
|
setState((state) => ({ ...state, error: true }));
|
|
42
71
|
}
|
|
43
72
|
};
|
|
44
73
|
|
|
45
|
-
const handleClose = () =>
|
|
74
|
+
const handleClose = () => setIsTranslated(false);
|
|
46
75
|
|
|
47
76
|
const buttonText = state.isLoading ? "Processing..." : "Translate page with AI";
|
|
48
77
|
|
|
49
78
|
return (
|
|
50
79
|
<>
|
|
51
|
-
{
|
|
80
|
+
{isIATranslated && !content?.canBeTranslated && (
|
|
52
81
|
<S.Wrapper data-testid="translated-notification-wrapper" isSmall={false}>
|
|
53
82
|
<S.NotificationContent>
|
|
54
83
|
<S.Text>This page is translated with Artificial Intelligence.</S.Text>
|
|
@@ -58,7 +87,7 @@ const TranslateButton = (props: ITranslateButtonProps): JSX.Element => {
|
|
|
58
87
|
</S.NotificationContent>
|
|
59
88
|
</S.Wrapper>
|
|
60
89
|
)}
|
|
61
|
-
{autoTranslation && canBeTranslated ? (
|
|
90
|
+
{autoTranslation && content?.canBeTranslated ? (
|
|
62
91
|
<>
|
|
63
92
|
<S.Wrapper data-testid="translate-button-wrapper" isSmall={!!structuredDataForm}>
|
|
64
93
|
<S.Text>
|
|
@@ -74,7 +103,7 @@ const TranslateButton = (props: ITranslateButtonProps): JSX.Element => {
|
|
|
74
103
|
{buttonText}
|
|
75
104
|
</S.StyledButton>
|
|
76
105
|
</S.ButtonWrapper>
|
|
77
|
-
{state.error && <S.ErrorText>We
|
|
106
|
+
{state.error && <S.ErrorText>We're having problems. Please try again in a few minutes.</S.ErrorText>}
|
|
78
107
|
</S.Wrapper>
|
|
79
108
|
<Modal
|
|
80
109
|
isOpen={isOpen}
|
|
@@ -100,14 +129,19 @@ const TranslateButton = (props: ITranslateButtonProps): JSX.Element => {
|
|
|
100
129
|
export interface ITranslateButtonProps {
|
|
101
130
|
lang: number;
|
|
102
131
|
autoTranslation: boolean;
|
|
103
|
-
|
|
132
|
+
editorContent: any;
|
|
104
133
|
structuredDataForm: any | null;
|
|
105
134
|
isPageIATranslated: boolean;
|
|
106
135
|
isDataContentIATranslated: boolean;
|
|
136
|
+
isFormIATranslated: boolean;
|
|
137
|
+
contentType: "page" | "data" | "form";
|
|
138
|
+
formContent: FormContent | null;
|
|
107
139
|
getPageTranslation: (langID: number) => Promise<boolean>;
|
|
108
140
|
getDataContentTranslation: (langID: number) => Promise<boolean>;
|
|
141
|
+
getFormTranslation: (langID: number) => Promise<boolean>;
|
|
109
142
|
setIsPageTranslated: (isTranslated: boolean) => Promise<void>;
|
|
110
143
|
setIsContentTranslated: (isTranslated: boolean) => Promise<void>;
|
|
144
|
+
setIsFormTranslated: (isTranslated: boolean) => void;
|
|
111
145
|
}
|
|
112
146
|
|
|
113
147
|
const mapDispatchToProps = {
|
|
@@ -115,14 +149,18 @@ const mapDispatchToProps = {
|
|
|
115
149
|
setIsPageTranslated: pageEditorActions.setIsTranslated,
|
|
116
150
|
getDataContentTranslation: structuredDataActions.getDataContentTranslation,
|
|
117
151
|
setIsContentTranslated: structuredDataActions.setIsTranslated,
|
|
152
|
+
getFormTranslation: formsActions.getFormTranslation,
|
|
153
|
+
setIsFormTranslated: formsActions.setIsIATranslated,
|
|
118
154
|
};
|
|
119
155
|
|
|
120
156
|
const mapStateToProps = (state: IRootState) => ({
|
|
121
157
|
autoTranslation: state.app.globalSettings.autoTranslation,
|
|
122
|
-
|
|
158
|
+
editorContent: state.pageEditor.editorContent,
|
|
123
159
|
isPageIATranslated: state.pageEditor.isIATranslated,
|
|
124
160
|
isDataContentIATranslated: state.structuredData.isIATranslated,
|
|
125
161
|
structuredDataForm: state.structuredData.form,
|
|
162
|
+
formContent: state.forms.formContent,
|
|
163
|
+
isFormIATranslated: state.forms.isIATranslated,
|
|
126
164
|
});
|
|
127
165
|
|
|
128
166
|
export default connect(mapStateToProps, mapDispatchToProps)(TranslateButton);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { config } from "components";
|
|
2
2
|
|
|
3
3
|
const getRichTextConfig = (): IRichTextConfig | null => {
|
|
4
|
-
return schemas
|
|
4
|
+
return config.schemas.config.richTextConfig || null;
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
const parseClassNames = (styles: { label: string; className: string }[]) =>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { connect } from "react-redux";
|
|
3
|
-
import
|
|
3
|
+
import FroalaEditor from "react-froala-wysiwyg";
|
|
4
4
|
import { decodeEntities } from "@ax/helpers";
|
|
5
5
|
import { IImage, ISite, IRootState } from "@ax/types";
|
|
6
6
|
import { galleryActions } from "@ax/containers/Gallery";
|
|
@@ -40,7 +40,6 @@ const Wysiwyg = (props: IWysiwygProps): JSX.Element => {
|
|
|
40
40
|
},
|
|
41
41
|
events: {
|
|
42
42
|
initialized() {
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
44
43
|
const editor: any = this;
|
|
45
44
|
if (disabled) {
|
|
46
45
|
setTimeout(() => {
|
|
@@ -49,18 +48,12 @@ const Wysiwyg = (props: IWysiwygProps): JSX.Element => {
|
|
|
49
48
|
}
|
|
50
49
|
},
|
|
51
50
|
"image.beforeUpload": async function (images: FileList) {
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
53
51
|
const editor: any = this;
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
editor.image.insert(response.url, null, null, editor.image.get());
|
|
57
|
-
} else {
|
|
58
|
-
editor.image.remove(editor.image.get());
|
|
59
|
-
}
|
|
52
|
+
const { url } = await uploadImage(images[0], imageSite);
|
|
53
|
+
editor.image.insert(url, true, null, editor.image.get(), null);
|
|
60
54
|
return false;
|
|
61
55
|
},
|
|
62
56
|
blur: function () {
|
|
63
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
64
57
|
const editor: any = this;
|
|
65
58
|
const html = editor.html.get();
|
|
66
59
|
const stripedHtml = decodeEntities(html);
|
|
@@ -73,7 +66,7 @@ const Wysiwyg = (props: IWysiwygProps): JSX.Element => {
|
|
|
73
66
|
|
|
74
67
|
return (
|
|
75
68
|
<S.EditorWrapper error={error} disabled={disabled} data-testid="wysiwyg-wrapper">
|
|
76
|
-
<
|
|
69
|
+
<FroalaEditor tag="textarea" model={value} config={config} onModelChange={handleChange} />
|
|
77
70
|
</S.EditorWrapper>
|
|
78
71
|
);
|
|
79
72
|
};
|
|
@@ -12,6 +12,7 @@ import DateField from "./DateField";
|
|
|
12
12
|
import FieldGroup from "./FieldGroup";
|
|
13
13
|
import FieldsDivider from "./FieldsDivider";
|
|
14
14
|
import FileField from "./FileField";
|
|
15
|
+
import FormFieldArray from "./FormFieldArray";
|
|
15
16
|
import HeadingField from "./HeadingField";
|
|
16
17
|
import HiddenField from "./HiddenField";
|
|
17
18
|
import ImageField from "./ImageField";
|
|
@@ -55,6 +56,7 @@ export {
|
|
|
55
56
|
FieldGroup,
|
|
56
57
|
FieldsDivider,
|
|
57
58
|
FileField,
|
|
59
|
+
FormFieldArray,
|
|
58
60
|
HeadingField,
|
|
59
61
|
HiddenField,
|
|
60
62
|
ImageField,
|
|
@@ -41,8 +41,14 @@ const FieldsBehavior = (props: any): JSX.Element => {
|
|
|
41
41
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
42
42
|
}, [editorID, error]);
|
|
43
43
|
|
|
44
|
-
const helpTextWrapper = message ?
|
|
45
|
-
|
|
44
|
+
const helpTextWrapper = message ? (
|
|
45
|
+
<S.HelpText error={errorField} inversed={inversed}>
|
|
46
|
+
{message}
|
|
47
|
+
</S.HelpText>
|
|
48
|
+
) : (
|
|
49
|
+
""
|
|
50
|
+
);
|
|
51
|
+
const isComponentArray = fieldType === "ComponentArray" || fieldType === "FormFieldArray";
|
|
46
52
|
const isComponentContainer = fieldType === "ComponentContainer";
|
|
47
53
|
const hasMultipleOptions: boolean = whiteList && whiteList.length > 1;
|
|
48
54
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const SvgForm = (props) => (
|
|
3
|
+
<svg xmlns="http://www.w3.org/2000/svg" width={24} height={24} fill="none" {...props}>
|
|
4
|
+
<path
|
|
5
|
+
fill="#5057FF"
|
|
6
|
+
fillRule="evenodd"
|
|
7
|
+
d="M19 19V5H5v14h14ZM5 3h14c1.1 0 2 .9 2 2v14c0 1.1-.9 2-2 2H5c-1.1 0-2-.9-2-2V5c0-1.1.9-2 2-2Zm12 4H7v2h10V7ZM7 11h10v2H7v-2Zm4 4H7v2h4v-2Z"
|
|
8
|
+
clipRule="evenodd"
|
|
9
|
+
/>
|
|
10
|
+
</svg>
|
|
11
|
+
);
|
|
12
|
+
export default SvgForm;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M19 19V5H5V19H19ZM5 3H19C20.1 3 21 3.9 21 5V19C21 20.1 20.1 21 19 21H5C3.9 21 3 20.1 3 19V5C3 3.9 3.9 3 5 3ZM17 7H7V9H17V7ZM7 11H17V13H7V11ZM11 15H7V17H11V15Z" fill="#5057FF"/>
|
|
3
|
+
</svg>
|
|
@@ -9,7 +9,7 @@ const LanguageMenu = (props: ILanguageMenuProps): JSX.Element => {
|
|
|
9
9
|
const { availableLanguages, language, setLanguage, isInAppBar, currentLanguages } = props;
|
|
10
10
|
|
|
11
11
|
const getCurrentLanguage = (lang: string) =>
|
|
12
|
-
currentLanguages && currentLanguages.find((currLanguage
|
|
12
|
+
currentLanguages && currentLanguages.find((currLanguage) => currLanguage.locale === lang);
|
|
13
13
|
|
|
14
14
|
const isNewVersion = (lang: string) => currentLanguages && !getCurrentLanguage(lang);
|
|
15
15
|
const isEditableVersion = (lang: string) => currentLanguages && getCurrentLanguage(lang);
|
|
@@ -36,41 +36,44 @@ const LanguageMenu = (props: ILanguageMenuProps): JSX.Element => {
|
|
|
36
36
|
);
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
const languageMenuItem = (item: ILanguage) =>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<S.
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
39
|
+
const languageMenuItem = (item: ILanguage) => {
|
|
40
|
+
const handleClick = () => setLanguage(item);
|
|
41
|
+
return (
|
|
42
|
+
<S.LanguageItem
|
|
43
|
+
key={item.locale}
|
|
44
|
+
selected={item.locale === language}
|
|
45
|
+
onClick={handleClick}
|
|
46
|
+
data-testid="language-menu-item"
|
|
47
|
+
>
|
|
48
|
+
<S.LanguageItemWrapper>
|
|
49
|
+
<S.LanguageLabel>
|
|
50
|
+
<Flag name={item.locale} />
|
|
51
|
+
<S.LanguageText data-testid="language-text">
|
|
52
|
+
<S.Locale>{item.label}</S.Locale> - {item.language}
|
|
53
|
+
</S.LanguageText>
|
|
54
|
+
</S.LanguageLabel>
|
|
55
|
+
{isNewVersion(item.locale) && language !== item.locale && (
|
|
56
|
+
<S.LanguageSubtext> Add new version </S.LanguageSubtext>
|
|
57
|
+
)}
|
|
58
|
+
</S.LanguageItemWrapper>
|
|
59
|
+
{getLanguageIcon(item.locale)}
|
|
60
|
+
</S.LanguageItem>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
60
63
|
|
|
61
64
|
return (
|
|
62
65
|
<S.ActionMenu data-testid="language-menu">
|
|
63
|
-
{availableLanguages && availableLanguages.map((item
|
|
66
|
+
{availableLanguages && availableLanguages.map((item) => languageMenuItem(item))}
|
|
64
67
|
</S.ActionMenu>
|
|
65
68
|
);
|
|
66
69
|
};
|
|
67
70
|
|
|
68
71
|
export interface ILanguageMenuProps {
|
|
69
|
-
language
|
|
70
|
-
availableLanguages
|
|
71
|
-
currentLanguages
|
|
72
|
+
language: string | null;
|
|
73
|
+
availableLanguages: ILanguage[];
|
|
74
|
+
currentLanguages: ILanguage[];
|
|
72
75
|
isInAppBar?: boolean;
|
|
73
|
-
setLanguage(lang: ILanguage):
|
|
76
|
+
setLanguage(lang: ILanguage): void;
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
export default LanguageMenu;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
import { withRouter, RouteComponentProps } from "react-router-dom";
|
|
3
3
|
|
|
4
|
-
import { IErrorItem } from "@ax/types";
|
|
4
|
+
import { IErrorItem, ILanguage } from "@ax/types";
|
|
5
5
|
import { getScheduleFormatDate, trimText } from "@ax/helpers";
|
|
6
6
|
import { useModal } from "@ax/hooks";
|
|
7
7
|
import {
|
|
@@ -35,8 +35,8 @@ const AppBar = (props: IProps): JSX.Element => {
|
|
|
35
35
|
pageStatus,
|
|
36
36
|
language,
|
|
37
37
|
availableLanguages,
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
currentLanguages,
|
|
39
|
+
languageAction,
|
|
40
40
|
additionalClass,
|
|
41
41
|
subtitle,
|
|
42
42
|
inversed,
|
|
@@ -55,7 +55,7 @@ const AppBar = (props: IProps): JSX.Element => {
|
|
|
55
55
|
scheduledPublication,
|
|
56
56
|
} = props;
|
|
57
57
|
|
|
58
|
-
const publishedTooltip:
|
|
58
|
+
const publishedTooltip: Record<string, string> = {
|
|
59
59
|
active: "Live",
|
|
60
60
|
"upload-pending": "Publication pending",
|
|
61
61
|
offline: "Offline",
|
|
@@ -66,71 +66,26 @@ const AppBar = (props: IProps): JSX.Element => {
|
|
|
66
66
|
|
|
67
67
|
const fixedClass = fixedAppBar ? "fixed" : "";
|
|
68
68
|
const isScheduledPub = !!scheduledPublication && pageStatus === "scheduled";
|
|
69
|
+
const currentLang = availableLanguages?.find((lang) => lang.id === language?.id);
|
|
69
70
|
|
|
70
71
|
const { isOpen, toggleModal } = useModal();
|
|
71
|
-
const [langSelected, setLangSelected] = useState(
|
|
72
|
+
const [langSelected, setLangSelected] = useState<ILanguage | undefined>(currentLang);
|
|
72
73
|
|
|
73
|
-
const goToPages = () =>
|
|
74
|
+
const goToPages = () =>
|
|
74
75
|
typeof backLink === "string" ? props.history.push(backLink, { isFromEditor }) : props.history.goBack();
|
|
75
|
-
};
|
|
76
76
|
|
|
77
|
-
const
|
|
78
|
-
|
|
77
|
+
const handleLanguage = (item?: ILanguage) => {
|
|
78
|
+
if (!item || !languageAction) return;
|
|
79
79
|
|
|
80
|
-
const handleLanguage = (item: any) => async () => {
|
|
81
80
|
if (langSelected && langSelected.locale !== item.locale && isDirty) {
|
|
82
81
|
setLangSelected(item);
|
|
83
82
|
toggleModal();
|
|
84
83
|
return;
|
|
85
|
-
} else {
|
|
86
|
-
isOpen && toggleModal();
|
|
87
84
|
}
|
|
88
|
-
if (!languageActions || !languageActions.setLanguage) return;
|
|
89
|
-
|
|
90
|
-
const lang = {
|
|
91
|
-
locale: item.locale,
|
|
92
|
-
id: item.id,
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const setNewTranslation = (isNewTranslation: boolean) => {
|
|
96
|
-
languageActions.createNewTranslation && languageActions.createNewTranslation(isNewTranslation, lang);
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
languageActions.setLanguage(lang);
|
|
100
|
-
const currentLanguage = getCurrentLanguage(item.locale);
|
|
101
85
|
|
|
102
|
-
|
|
103
|
-
setNewTranslation(false);
|
|
104
|
-
const id = currentLanguage && currentLanguage.pageId ? currentLanguage.pageId : currentLanguage.navigationId;
|
|
105
|
-
currentLanguage && (await languageActions.getContent(id));
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (languageActions.getDataContent && currentLanguage) {
|
|
109
|
-
currentLanguage && (await languageActions.getDataContent(currentLanguage.dataID));
|
|
110
|
-
setNewTranslation(false);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (languageActions.getSiteContent) {
|
|
114
|
-
languageActions.getSiteContent();
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (pageLanguages && !getCurrentLanguage(item.locale)) {
|
|
118
|
-
languageActions.getDataContent && currentPageID && (await languageActions.getDataContent(currentPageID));
|
|
119
|
-
setNewTranslation(true);
|
|
120
|
-
languageActions.getContent && currentPageID && languageActions.getContent(currentPageID);
|
|
121
|
-
}
|
|
86
|
+
languageAction(item);
|
|
122
87
|
};
|
|
123
88
|
|
|
124
|
-
const languageMenu = (
|
|
125
|
-
<LanguageMenu
|
|
126
|
-
language={language && language.locale}
|
|
127
|
-
availableLanguages={availableLanguages}
|
|
128
|
-
currentLanguages={pageLanguages}
|
|
129
|
-
setLanguage={handleLanguage}
|
|
130
|
-
isInAppBar={true}
|
|
131
|
-
/>
|
|
132
|
-
);
|
|
133
|
-
|
|
134
89
|
const LanguageBtn = () =>
|
|
135
90
|
language && (
|
|
136
91
|
<>
|
|
@@ -176,13 +131,13 @@ const AppBar = (props: IProps): JSX.Element => {
|
|
|
176
131
|
|
|
177
132
|
const mainAction = {
|
|
178
133
|
title: "Change language",
|
|
179
|
-
onClick: handleLanguage(langSelected),
|
|
134
|
+
onClick: () => handleLanguage(langSelected),
|
|
180
135
|
};
|
|
181
136
|
|
|
182
137
|
const secondaryAction = {
|
|
183
138
|
title: "Cancel",
|
|
184
139
|
onClick: () => {
|
|
185
|
-
setLangSelected(
|
|
140
|
+
setLangSelected(currentLang);
|
|
186
141
|
toggleModal();
|
|
187
142
|
},
|
|
188
143
|
};
|
|
@@ -249,7 +204,7 @@ const AppBar = (props: IProps): JSX.Element => {
|
|
|
249
204
|
{(language || pageStatus || rightButton || rightLineButton) && <S.Separator />}
|
|
250
205
|
</>
|
|
251
206
|
)}
|
|
252
|
-
{language && (
|
|
207
|
+
{language && availableLanguages && (
|
|
253
208
|
<>
|
|
254
209
|
<ChangeLanguageModal />
|
|
255
210
|
<S.LanguageWrapper data-testid="language-wrapper">
|
|
@@ -260,7 +215,13 @@ const AppBar = (props: IProps): JSX.Element => {
|
|
|
260
215
|
position="left"
|
|
261
216
|
offset={rightButton || rightLineButton ? 0 : -85}
|
|
262
217
|
>
|
|
263
|
-
|
|
218
|
+
<LanguageMenu
|
|
219
|
+
language={language.locale}
|
|
220
|
+
availableLanguages={availableLanguages}
|
|
221
|
+
currentLanguages={currentLanguages || availableLanguages}
|
|
222
|
+
setLanguage={handleLanguage}
|
|
223
|
+
isInAppBar={true}
|
|
224
|
+
/>
|
|
264
225
|
</FloatingMenu>
|
|
265
226
|
</Tooltip>
|
|
266
227
|
</S.LanguageWrapper>
|
|
@@ -330,15 +291,9 @@ export interface IAppBarProps {
|
|
|
330
291
|
fixedAppBar?: boolean;
|
|
331
292
|
pageStatus?: string;
|
|
332
293
|
language?: { locale: string; id: number | null } | null;
|
|
333
|
-
availableLanguages?:
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
setLanguage?(lang: { locale: string; id: number | null }): void;
|
|
337
|
-
createNewTranslation?(isNewTranslation: boolean, lang: { locale: string; id: number }): void;
|
|
338
|
-
getContent?(id?: number): Promise<void>;
|
|
339
|
-
getSiteContent?(page?: number, itemsPerPage?: number): Promise<void>;
|
|
340
|
-
getDataContent?(dataID: number): Promise<void>;
|
|
341
|
-
} | null;
|
|
294
|
+
availableLanguages?: ILanguage[];
|
|
295
|
+
currentLanguages?: ILanguage[];
|
|
296
|
+
languageAction?: (lang: ILanguage) => void;
|
|
342
297
|
additionalClass?: string;
|
|
343
298
|
inversed?: boolean;
|
|
344
299
|
currentPageID?: number;
|