@griddo/ax 1.75.238 → 1.75.240
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 +2 -2
- package/src/__tests__/components/Browser/Browser.test.tsx +1 -1
- package/src/__tests__/components/Fields/AsyncCheckGroup/AsyncCheckGroup.test.tsx +25 -7
- package/src/__tests__/modules/Sites/SitesList/SitesList.test.tsx +2 -3
- package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/Field/index.tsx +1 -1
- package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/TemplateManager/index.tsx +3 -0
- package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/index.tsx +2 -1
- package/src/components/FieldContainer/index.tsx +1 -1
- package/src/components/Fields/AsyncCheckGroup/index.tsx +35 -12
- package/src/components/Fields/AsyncSelect/index.tsx +4 -4
- package/src/components/Fields/ComponentArray/MixableComponentArray/index.tsx +3 -3
- package/src/components/Fields/ComponentArray/SameComponentArray/index.tsx +3 -3
- package/src/components/Fields/ComponentArray/helpers.tsx +2 -2
- package/src/components/Fields/MultiCheckSelect/index.tsx +23 -25
- package/src/components/Fields/MultiCheckSelect/style.tsx +20 -19
- package/src/containers/App/actions.tsx +1 -1
- package/src/containers/App/reducer.tsx +1 -1
- package/src/containers/Navigation/Menu/actions.tsx +3 -2
- package/src/containers/Navigation/Menu/reducer.tsx +2 -5
- package/src/containers/Sites/actions.tsx +6 -7
- package/src/helpers/index.tsx +2 -0
- package/src/helpers/schemas.tsx +3 -0
- package/src/modules/Content/index.tsx +2 -1
- package/src/modules/GlobalEditor/index.tsx +16 -14
- package/src/modules/Navigation/Menus/List/Table/Item/index.tsx +6 -9
- package/src/modules/Navigation/Menus/List/Table/SidePanel/Form/ConnectedField/index.tsx +45 -0
- package/src/modules/Navigation/Menus/List/Table/SidePanel/Form/index.tsx +21 -52
- package/src/modules/Navigation/Menus/List/Table/SidePanel/index.tsx +2 -6
- package/src/modules/PageEditor/index.tsx +15 -21
- package/src/modules/Sites/SitesList/GridView/GridSiteItem/index.tsx +11 -11
- package/src/modules/Sites/SitesList/ListView/ListSiteItem/index.tsx +11 -11
- package/src/modules/Sites/SitesList/RecentSiteItem/index.tsx +3 -3
- package/src/types/index.tsx +2 -5
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griddo/ax",
|
|
3
3
|
"description": "Griddo Author Experience",
|
|
4
|
-
"version": "1.75.
|
|
4
|
+
"version": "1.75.240",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Carlos Torres <carlos.torres@secuoyas.com>",
|
|
@@ -230,5 +230,5 @@
|
|
|
230
230
|
"publishConfig": {
|
|
231
231
|
"access": "public"
|
|
232
232
|
},
|
|
233
|
-
"gitHead": "
|
|
233
|
+
"gitHead": "3e2c8b6a025d58796f9c431bce441ec421bba2f7"
|
|
234
234
|
}
|
|
@@ -10,8 +10,6 @@ import { mock } from "jest-mock-extended";
|
|
|
10
10
|
|
|
11
11
|
afterEach(cleanup);
|
|
12
12
|
|
|
13
|
-
const defaultProps = mock<IAsyncCheckGroup>();
|
|
14
|
-
|
|
15
13
|
jest.mock("axios");
|
|
16
14
|
const mockedAxios = axios as jest.MockedFunction<typeof axios>;
|
|
17
15
|
|
|
@@ -19,36 +17,53 @@ describe("AsyncCheckGroup component rendering", () => {
|
|
|
19
17
|
afterEach(() => {
|
|
20
18
|
jest.resetAllMocks();
|
|
21
19
|
});
|
|
20
|
+
|
|
22
21
|
it("should render the component with 6 options", async () => {
|
|
23
22
|
const defaultSite = mock<ISite>();
|
|
24
23
|
defaultSite.id = 113;
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
|
|
25
|
+
const defaultDataProps: IAsyncCheckGroup = {
|
|
26
|
+
site: defaultSite,
|
|
27
|
+
value: [{
|
|
28
|
+
value: 3622,
|
|
29
|
+
name: "Home",
|
|
30
|
+
title: "Home"
|
|
31
|
+
}],
|
|
32
|
+
onChange: jest.fn(),
|
|
33
|
+
source: "NEWS",
|
|
34
|
+
}
|
|
35
|
+
|
|
27
36
|
const data = {
|
|
28
37
|
data: [
|
|
29
38
|
{
|
|
30
39
|
value: 3622,
|
|
31
40
|
name: "Home",
|
|
41
|
+
title: "Home"
|
|
32
42
|
},
|
|
33
43
|
{
|
|
34
44
|
value: 3731,
|
|
35
45
|
name: "English child",
|
|
46
|
+
title: "English child",
|
|
36
47
|
},
|
|
37
48
|
{
|
|
38
49
|
value: 3730,
|
|
39
50
|
name: "English Parent",
|
|
51
|
+
title: "English Parent",
|
|
40
52
|
},
|
|
41
53
|
{
|
|
42
54
|
value: 3787,
|
|
43
55
|
name: "English test",
|
|
56
|
+
title: "English test",
|
|
44
57
|
},
|
|
45
58
|
{
|
|
46
59
|
value: 3745,
|
|
47
60
|
name: "New Page",
|
|
61
|
+
title: "New Page",
|
|
48
62
|
},
|
|
49
63
|
{
|
|
50
64
|
value: 3784,
|
|
51
65
|
name: "Prueba",
|
|
66
|
+
title: "Prueba",
|
|
52
67
|
},
|
|
53
68
|
],
|
|
54
69
|
status: 200,
|
|
@@ -62,7 +77,7 @@ describe("AsyncCheckGroup component rendering", () => {
|
|
|
62
77
|
await act(async () => {
|
|
63
78
|
render(
|
|
64
79
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
65
|
-
<AsyncCheckGroup {...
|
|
80
|
+
<AsyncCheckGroup {...defaultDataProps} />
|
|
66
81
|
</ThemeProvider>
|
|
67
82
|
);
|
|
68
83
|
});
|
|
@@ -71,8 +86,11 @@ describe("AsyncCheckGroup component rendering", () => {
|
|
|
71
86
|
});
|
|
72
87
|
|
|
73
88
|
it("should render the component with no options", async () => {
|
|
74
|
-
defaultProps
|
|
75
|
-
|
|
89
|
+
const defaultProps: IAsyncCheckGroup = {
|
|
90
|
+
value: [],
|
|
91
|
+
onChange: jest.fn(),
|
|
92
|
+
source: "NEWS",
|
|
93
|
+
}
|
|
76
94
|
|
|
77
95
|
const data = {
|
|
78
96
|
data: [],
|
|
@@ -447,8 +447,7 @@ describe("Sites module events", () => {
|
|
|
447
447
|
expect(recentSiteItems.length).toEqual(2);
|
|
448
448
|
|
|
449
449
|
fireEvent.click(recentSiteItems[0]);
|
|
450
|
-
|
|
451
|
-
expect(history.location.pathname).toEqual("/sites/pages");
|
|
450
|
+
await waitFor(() => expect(history.location.pathname).toEqual("/sites/pages"));
|
|
452
451
|
});
|
|
453
452
|
|
|
454
453
|
it("should display list view on click list option button", async () => {
|
|
@@ -896,7 +895,7 @@ describe("Sites module events", () => {
|
|
|
896
895
|
await act(async () => {
|
|
897
896
|
render(Component, { store });
|
|
898
897
|
});
|
|
899
|
-
|
|
898
|
+
|
|
900
899
|
const gridIconAction = screen.getByTestId("icon-action-Grid2");
|
|
901
900
|
fireEvent.click(gridIconAction);
|
|
902
901
|
|
package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/TemplateManager/index.tsx
CHANGED
|
@@ -28,6 +28,7 @@ export const TemplateManager = (props: IProps): JSX.Element => {
|
|
|
28
28
|
moduleCopy,
|
|
29
29
|
availableDataPacks,
|
|
30
30
|
setHistoryPush,
|
|
31
|
+
lang
|
|
31
32
|
} = props;
|
|
32
33
|
|
|
33
34
|
const isConfig = selectedTab === "config";
|
|
@@ -99,6 +100,7 @@ export const TemplateManager = (props: IProps): JSX.Element => {
|
|
|
99
100
|
availableDataPacks={availableDataPacks}
|
|
100
101
|
template={template}
|
|
101
102
|
setHistoryPush={setHistoryPush}
|
|
103
|
+
lang={lang}
|
|
102
104
|
/>
|
|
103
105
|
);
|
|
104
106
|
})}
|
|
@@ -126,6 +128,7 @@ interface IProps {
|
|
|
126
128
|
moduleCopy: { date: string; element: Record<string, unknown> } | null;
|
|
127
129
|
availableDataPacks: Record<string, any>[];
|
|
128
130
|
setHistoryPush?: (path: string, isEditor: boolean) => void;
|
|
131
|
+
lang: number;
|
|
129
132
|
}
|
|
130
133
|
|
|
131
134
|
const mapStateToProps = (state: IRootState) => ({
|
|
@@ -163,6 +163,7 @@ const PageConnectedField = (props: any) => {
|
|
|
163
163
|
theme={theme}
|
|
164
164
|
moduleCopy={moduleCopy}
|
|
165
165
|
setHistoryPush={setHistoryPush}
|
|
166
|
+
lang={lang.id}
|
|
166
167
|
/>
|
|
167
168
|
);
|
|
168
169
|
}
|
|
@@ -178,7 +179,7 @@ const PageConnectedField = (props: any) => {
|
|
|
178
179
|
pages={pages}
|
|
179
180
|
actions={actions}
|
|
180
181
|
site={site}
|
|
181
|
-
lang={lang}
|
|
182
|
+
lang={lang.id}
|
|
182
183
|
disabled={isDisabled}
|
|
183
184
|
readonly={isFieldReadOnly}
|
|
184
185
|
activatedModules={activatedModules}
|
|
@@ -10,17 +10,16 @@ import * as S from "./style";
|
|
|
10
10
|
const AsyncCheckGroup = (props: IAsyncCheckGroup): JSX.Element => {
|
|
11
11
|
const { onChange, value, site, source, disabled, error, handleValidation, fullHeight, allLanguages = false } = props;
|
|
12
12
|
|
|
13
|
-
const [options, setOptions] = useState<
|
|
14
|
-
|
|
15
|
-
const safeValue = value ? value : [];
|
|
13
|
+
const [options, setOptions] = useState<ICheckValue[]>([]);
|
|
14
|
+
const safeValue = value && Array.isArray(value) ? value : [];
|
|
16
15
|
|
|
17
16
|
useEffect((): any => {
|
|
18
17
|
let isSubscribed = true;
|
|
19
18
|
|
|
20
|
-
const getItems = async () => {
|
|
19
|
+
const getItems = async (): Promise<ICheckValue[]> => {
|
|
21
20
|
try {
|
|
22
21
|
let result = null;
|
|
23
|
-
const siteID = site ? site.id :
|
|
22
|
+
const siteID = site ? site.id : "global";
|
|
24
23
|
result = await checkgroups.getCheckGroupItems(siteID, source, allLanguages);
|
|
25
24
|
if (result && isReqOk(result.status)) {
|
|
26
25
|
return result.data;
|
|
@@ -28,12 +27,29 @@ const AsyncCheckGroup = (props: IAsyncCheckGroup): JSX.Element => {
|
|
|
28
27
|
} catch (e) {
|
|
29
28
|
console.log(e);
|
|
30
29
|
}
|
|
31
|
-
return
|
|
30
|
+
return [];
|
|
32
31
|
};
|
|
33
32
|
|
|
34
33
|
getItems()
|
|
35
|
-
.then((result) =>
|
|
36
|
-
|
|
34
|
+
.then((result) => {
|
|
35
|
+
if(isSubscribed){
|
|
36
|
+
setOptions(result);
|
|
37
|
+
// clean array of old values and set translations
|
|
38
|
+
const resultIDs = result && result.map((opt: ICheckValue) => opt.value);
|
|
39
|
+
const fixedState = safeValue.reduce((acc: ICheckValue[], current: ICheckValue) => {
|
|
40
|
+
if(resultIDs.includes(current.value)){
|
|
41
|
+
return [...acc, current];
|
|
42
|
+
} else {
|
|
43
|
+
const trad = result.find((value: ICheckValue) => value.dataLanguages && value.dataLanguages.find((data: any) => data.id === current.value ));
|
|
44
|
+
if(trad){
|
|
45
|
+
return [...acc, trad]
|
|
46
|
+
}
|
|
47
|
+
return acc;
|
|
48
|
+
}
|
|
49
|
+
}, []);
|
|
50
|
+
onChange(fixedState);
|
|
51
|
+
}
|
|
52
|
+
}).catch((apiError) => console.log(apiError));
|
|
37
53
|
|
|
38
54
|
return () => (isSubscribed = false);
|
|
39
55
|
}, [site, source, allLanguages]);
|
|
@@ -52,13 +68,13 @@ const AsyncCheckGroup = (props: IAsyncCheckGroup): JSX.Element => {
|
|
|
52
68
|
newArray = [...arrayIds, newValue.value];
|
|
53
69
|
}
|
|
54
70
|
|
|
55
|
-
const newArrayObject = options.filter((e:
|
|
71
|
+
const newArrayObject = options.filter((e: ICheckValue) => newArray.includes(e.value));
|
|
56
72
|
|
|
57
73
|
onChange(newArrayObject);
|
|
58
74
|
error && handleValidation && handleValidation(newArrayObject);
|
|
59
75
|
};
|
|
60
76
|
|
|
61
|
-
const isChecked = (id: number)
|
|
77
|
+
const isChecked = (id: number) : boolean =>!!safeValue.find((e: ICheckValue) => (typeof e === "number" ? e === id : e.value === id));
|
|
62
78
|
|
|
63
79
|
const checks =
|
|
64
80
|
options &&
|
|
@@ -78,11 +94,18 @@ const AsyncCheckGroup = (props: IAsyncCheckGroup): JSX.Element => {
|
|
|
78
94
|
return <S.FieldGroup full={fullHeight}>{checks}</S.FieldGroup>;
|
|
79
95
|
};
|
|
80
96
|
|
|
97
|
+
interface ICheckValue {
|
|
98
|
+
value: number;
|
|
99
|
+
name: string;
|
|
100
|
+
title: string;
|
|
101
|
+
dataLanguages?: { id: number; language: number }[];
|
|
102
|
+
}
|
|
103
|
+
|
|
81
104
|
export interface IAsyncCheckGroup {
|
|
82
|
-
value:
|
|
105
|
+
value: ICheckValue[] | null;
|
|
83
106
|
site?: ISite | null;
|
|
84
107
|
source: string;
|
|
85
|
-
onChange: (value:
|
|
108
|
+
onChange: (value: ICheckValue[]) => void;
|
|
86
109
|
disabled?: boolean;
|
|
87
110
|
error?: boolean;
|
|
88
111
|
handleValidation?: (value: string | any[]) => void;
|
|
@@ -86,7 +86,7 @@ const AsyncSelect = (props: IAsyncSelectProps): JSX.Element => {
|
|
|
86
86
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
87
87
|
}, [entity, site, lang, selectedContent, entityId, mandatory, placeholder, filter, isCategories, isPage, options]);
|
|
88
88
|
|
|
89
|
-
const handleChange = (selectedValue:
|
|
89
|
+
const handleChange = (selectedValue: ICheck | IOption | null) => {
|
|
90
90
|
const newValue = selectedValue ? selectedValue.value : selectedValue;
|
|
91
91
|
onChange(newValue);
|
|
92
92
|
};
|
|
@@ -154,19 +154,19 @@ interface ICheck {
|
|
|
154
154
|
}
|
|
155
155
|
export interface IAsyncSelectProps {
|
|
156
156
|
name: string;
|
|
157
|
-
value
|
|
157
|
+
value?: string | number | null;
|
|
158
158
|
entity?: string;
|
|
159
159
|
entityId?: string | number;
|
|
160
160
|
error?: boolean;
|
|
161
161
|
disabled?: boolean;
|
|
162
|
-
onChange: (value: string) => void;
|
|
162
|
+
onChange: (value: string | number | null) => void;
|
|
163
163
|
site: ISite | null;
|
|
164
164
|
lang: string;
|
|
165
165
|
selectedContent: any;
|
|
166
166
|
mandatory?: boolean;
|
|
167
167
|
placeholder?: string;
|
|
168
168
|
filter?: any[];
|
|
169
|
-
options?: any;
|
|
169
|
+
options?: any[];
|
|
170
170
|
source?: string;
|
|
171
171
|
}
|
|
172
172
|
|
|
@@ -98,11 +98,11 @@ const MixableComponentArray = (props: IMixableComponentArrayProps): JSX.Element
|
|
|
98
98
|
showAddItemButton &&
|
|
99
99
|
(isModuleArr || objKey === "componentModules") &&
|
|
100
100
|
!!moduleCopy &&
|
|
101
|
-
timeSinceModuleCopy < eightHoursInSeconds &&
|
|
101
|
+
timeSinceModuleCopy && timeSinceModuleCopy < eightHoursInSeconds &&
|
|
102
102
|
(whiteList.includes(moduleCopyComponent) || isModuleCopyUnavailable);
|
|
103
103
|
|
|
104
104
|
const canReplace = maxItems === 1 && whiteList.length > 1;
|
|
105
|
-
const displayReplaceSideModal =
|
|
105
|
+
const displayReplaceSideModal = fixedValue.length > 0 && canReplace;
|
|
106
106
|
const optionsType = isModuleArr ? "modules" : "components";
|
|
107
107
|
|
|
108
108
|
const Asterisk = () => (mandatory ? <S.Asterisk>*</S.Asterisk> : null);
|
|
@@ -224,7 +224,7 @@ export interface IMixableComponentArrayProps {
|
|
|
224
224
|
maxItems: number;
|
|
225
225
|
title: string;
|
|
226
226
|
whiteList: any[];
|
|
227
|
-
value
|
|
227
|
+
value?: IModule[];
|
|
228
228
|
selectedContent: any;
|
|
229
229
|
editorID: number;
|
|
230
230
|
goTo: (editorID: string) => void;
|
|
@@ -40,7 +40,7 @@ const SameComponentArray = (props: ISameComponentArrayProps): JSX.Element => {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
const getText = (name: string, index: number) => {
|
|
43
|
-
return value.length > 1 ? `#${index + 1} ${name}` : name;
|
|
43
|
+
return value && value.length > 1 ? `#${index + 1} ${name}` : name;
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
const { kind } = selectedContent;
|
|
@@ -54,7 +54,7 @@ const SameComponentArray = (props: ISameComponentArrayProps): JSX.Element => {
|
|
|
54
54
|
|
|
55
55
|
const handleAdd = isModuleArr ? handleAddModule : handleAddComponent;
|
|
56
56
|
|
|
57
|
-
const showAddItemButton = !maxItems || value.length < maxItems;
|
|
57
|
+
const showAddItemButton = !maxItems || (value && value.length < maxItems);
|
|
58
58
|
|
|
59
59
|
const Asterisk = () => (mandatory ? <S.Asterisk>*</S.Asterisk> : null);
|
|
60
60
|
|
|
@@ -141,7 +141,7 @@ export interface ISameComponentArrayProps {
|
|
|
141
141
|
maxItems: number;
|
|
142
142
|
title: string;
|
|
143
143
|
whiteList: string[];
|
|
144
|
-
value
|
|
144
|
+
value?: IModule[];
|
|
145
145
|
elementUniqueSelection: boolean;
|
|
146
146
|
selectedContent: any;
|
|
147
147
|
editorID: number;
|
|
@@ -26,8 +26,8 @@ const getComponentProps = (element: any, activatedModules: string[], isModuleArr
|
|
|
26
26
|
return { moduleTitle, isModuleDeactivated, componentTitle, displayName, isModule };
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
const containerToComponentArray = (value
|
|
30
|
-
Object.values(value).filter((item: IComponent) => !isComponentEmpty(item));
|
|
29
|
+
const containerToComponentArray = (value?: Record<string, IComponent>): IComponent[] =>
|
|
30
|
+
value ? Object.values(value).filter((item: IComponent) => !isComponentEmpty(item)): [];
|
|
31
31
|
|
|
32
32
|
const getTypefromKey = (key: string) => {
|
|
33
33
|
switch (key) {
|
|
@@ -32,36 +32,34 @@ const MultiCheckSelect = (props: IMultiCheckSelectProps) => {
|
|
|
32
32
|
<S.Field isOpen={isOpen} onClick={handleClick} disabled={disabled} data-testid="field">
|
|
33
33
|
{placeholder} <Asterisk />
|
|
34
34
|
</S.Field>
|
|
35
|
-
{isOpen &&
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
</S.DropDown>
|
|
57
|
-
)}
|
|
35
|
+
{isOpen && <S.DropDown floating={floating} isOpen={isOpen}>
|
|
36
|
+
{options && (
|
|
37
|
+
<CheckGroup
|
|
38
|
+
options={options}
|
|
39
|
+
value={value}
|
|
40
|
+
onChange={onChange}
|
|
41
|
+
selectAllOption={selectAllOption}
|
|
42
|
+
disabled={disabled}
|
|
43
|
+
/>
|
|
44
|
+
)}
|
|
45
|
+
{source && !options && (
|
|
46
|
+
<AsyncCheckGroup
|
|
47
|
+
source={source}
|
|
48
|
+
site={site}
|
|
49
|
+
value={value}
|
|
50
|
+
onChange={onChange}
|
|
51
|
+
fullHeight={true}
|
|
52
|
+
disabled={disabled}
|
|
53
|
+
/>
|
|
54
|
+
)}
|
|
55
|
+
</S.DropDown>}
|
|
58
56
|
</S.Wrapper>
|
|
59
57
|
);
|
|
60
58
|
};
|
|
61
59
|
|
|
62
60
|
export interface IMultiCheckSelectProps {
|
|
63
|
-
value:
|
|
64
|
-
onChange: (value: string |
|
|
61
|
+
value: any[];
|
|
62
|
+
onChange: (value: string | any[]) => void;
|
|
65
63
|
site?: ISite | null;
|
|
66
64
|
placeholder: string;
|
|
67
65
|
source?: string;
|
|
@@ -2,34 +2,34 @@ import styled from "styled-components";
|
|
|
2
2
|
|
|
3
3
|
const Wrapper = styled.div`
|
|
4
4
|
position: relative;
|
|
5
|
-
min-width: calc(${(p) => p.theme.spacing
|
|
6
|
-
max-width: calc(${(p) => p.theme.spacing
|
|
5
|
+
min-width: calc(${(p) => p.theme.spacing.xl} * 2);
|
|
6
|
+
max-width: calc(${(p) => p.theme.spacing.xl} * 6);
|
|
7
7
|
z-index: 2;
|
|
8
8
|
`;
|
|
9
9
|
|
|
10
10
|
const Field = styled.div<{ isOpen: boolean; disabled?: boolean }>`
|
|
11
11
|
position: relative;
|
|
12
|
-
${(p) => p.theme.textStyle
|
|
13
|
-
color: ${(p) => (p.disabled ? p.theme.color
|
|
12
|
+
${(p) => p.theme.textStyle.fieldContent};
|
|
13
|
+
color: ${(p) => (p.disabled ? p.theme.color.interactiveDisabled : p.theme.color.textHighEmphasis)};
|
|
14
14
|
display: flex;
|
|
15
15
|
width: 100%;
|
|
16
|
-
height: ${(p) => p.theme.spacing
|
|
17
|
-
background-color: ${(p) => p.theme.color
|
|
16
|
+
height: ${(p) => p.theme.spacing.l};
|
|
17
|
+
background-color: ${(p) => p.theme.color.interactiveBackground};
|
|
18
18
|
border: 1px solid
|
|
19
19
|
${(p) =>
|
|
20
20
|
p.isOpen
|
|
21
|
-
? p.theme.color
|
|
21
|
+
? p.theme.color.interactive01
|
|
22
22
|
: p.disabled
|
|
23
|
-
? p.theme.color
|
|
24
|
-
: p.theme.color
|
|
25
|
-
border-radius: ${(p) => p.theme.radii
|
|
23
|
+
? p.theme.color.interactiveDisabled
|
|
24
|
+
: p.theme.color.uiLine};
|
|
25
|
+
border-radius: ${(p) => p.theme.radii.s};
|
|
26
26
|
align-items: center;
|
|
27
27
|
cursor: pointer;
|
|
28
|
-
padding: 0 ${(p) => p.theme.spacing
|
|
28
|
+
padding: 0 ${(p) => p.theme.spacing.s};
|
|
29
29
|
|
|
30
30
|
:focus,
|
|
31
31
|
:active {
|
|
32
|
-
border: 1px solid ${(p) => p.theme.color
|
|
32
|
+
border: 1px solid ${(p) => p.theme.color.interactive01};
|
|
33
33
|
outline: none;
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -38,7 +38,7 @@ const Field = styled.div<{ isOpen: boolean; disabled?: boolean }>`
|
|
|
38
38
|
right: 16px;
|
|
39
39
|
top: ${(p) => (p.isOpen ? `22px` : `18px`)};
|
|
40
40
|
content: "";
|
|
41
|
-
border: solid ${(p) => p.theme.color
|
|
41
|
+
border: solid ${(p) => p.theme.color.interactive01};
|
|
42
42
|
border-width: 0 2px 2px 0;
|
|
43
43
|
display: inline-block;
|
|
44
44
|
padding: 3px;
|
|
@@ -46,15 +46,16 @@ const Field = styled.div<{ isOpen: boolean; disabled?: boolean }>`
|
|
|
46
46
|
}
|
|
47
47
|
`;
|
|
48
48
|
|
|
49
|
-
const DropDown = styled.div<{ floating?: boolean }>`
|
|
50
|
-
background-color: ${(p) => p.theme.color
|
|
51
|
-
border:
|
|
52
|
-
border-radius: ${(p) => p.theme.radii
|
|
53
|
-
padding: ${(p) => `${p.theme.spacing
|
|
49
|
+
const DropDown = styled.div<{ floating?: boolean; isOpen: boolean }>`
|
|
50
|
+
background-color: ${(p) => p.theme.color.uiBarBackground};
|
|
51
|
+
border: ${(p) => (p.isOpen ? `1px solid ${p.theme.color.uiLine}` : "none")};
|
|
52
|
+
border-radius: ${(p) => p.theme.radii.s};
|
|
53
|
+
padding: ${(p) => p.isOpen ? `${p.theme.spacing.s} ${p.theme.spacing.xs} ${p.theme.spacing.xs} ${p.theme.spacing.s}` : 0};
|
|
54
54
|
width: 100%;
|
|
55
55
|
z-index: 2;
|
|
56
|
+
height: ${(p) => (p.isOpen ? "100%" : 0)};
|
|
56
57
|
max-height: 130px;
|
|
57
|
-
overflow: auto;
|
|
58
|
+
overflow: ${(p) => (p.isOpen ? "auto" : "hidden")};
|
|
58
59
|
position: ${(p) => (p.floating ? "absolute" : "block")};
|
|
59
60
|
`;
|
|
60
61
|
|
|
@@ -122,7 +122,7 @@ function handleError(response: any, isMultiple = false, msg?: string): (dispatch
|
|
|
122
122
|
text,
|
|
123
123
|
} = response;
|
|
124
124
|
|
|
125
|
-
const firstMsg = Array.isArray(message) ? message[0].error : message || text;
|
|
125
|
+
const firstMsg = Array.isArray(message) && message[0] ? message[0].error : message || text;
|
|
126
126
|
|
|
127
127
|
const error = {
|
|
128
128
|
code,
|
|
@@ -281,12 +281,13 @@ function setItemValue(page: IMenuItem): (dispatch: Dispatch) => Promise<void> {
|
|
|
281
281
|
};
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
-
function
|
|
284
|
+
function updateFormValue(valueObj: any): (dispatch: Dispatch, getState: any) => void {
|
|
285
285
|
return (dispatch, getState) => {
|
|
286
286
|
const {
|
|
287
287
|
menu: { form },
|
|
288
288
|
} = getState();
|
|
289
289
|
const updatedForm = { ...form, ...valueObj };
|
|
290
|
+
|
|
290
291
|
dispatch(setMenuFormData(updatedForm));
|
|
291
292
|
};
|
|
292
293
|
}
|
|
@@ -338,5 +339,5 @@ export {
|
|
|
338
339
|
resetItemValues,
|
|
339
340
|
resetMenuValues,
|
|
340
341
|
reorderMenu,
|
|
341
|
-
|
|
342
|
+
updateFormValue,
|
|
342
343
|
};
|
|
@@ -33,14 +33,11 @@ const initialState = {
|
|
|
33
33
|
type: "MainMenu",
|
|
34
34
|
item: null,
|
|
35
35
|
form: {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
itemLabel: "",
|
|
39
|
-
itemAuxText: "",
|
|
36
|
+
url: null,
|
|
37
|
+
label: "",
|
|
40
38
|
type: "link",
|
|
41
39
|
headerStyle: "",
|
|
42
40
|
footerStyle: "",
|
|
43
|
-
itemSpecial: false,
|
|
44
41
|
},
|
|
45
42
|
totalItems: 0,
|
|
46
43
|
};
|
|
@@ -599,7 +599,7 @@ function deleteAndRemoveFromSiteBulk(
|
|
|
599
599
|
|
|
600
600
|
const responseGlobalPageActions = {
|
|
601
601
|
handleSuccess: () => {
|
|
602
|
-
if (responseErrorPages.data.message
|
|
602
|
+
if (responseErrorPages.data.message?.length > 0) {
|
|
603
603
|
getMessageErrors();
|
|
604
604
|
}
|
|
605
605
|
},
|
|
@@ -617,14 +617,13 @@ function deleteAndRemoveFromSiteBulk(
|
|
|
617
617
|
},
|
|
618
618
|
};
|
|
619
619
|
|
|
620
|
-
const callbackPages = async () =>
|
|
621
|
-
const callbackGlobalPages = async () =>
|
|
622
|
-
globalPageIds.length > 0 && sites.removePageBulk(currentSiteInfo.id, globalPageIds);
|
|
620
|
+
const callbackPages = async () => pages.bulkDelete(pageIds);
|
|
621
|
+
const callbackGlobalPages = async () => sites.removePageBulk(currentSiteInfo.id, globalPageIds);
|
|
623
622
|
|
|
624
|
-
const resultPages = await handleRequest(callbackPages, responsePageActions, [])(dispatch);
|
|
625
|
-
const resultGlobalPages = await handleRequest(callbackGlobalPages, responseGlobalPageActions, [])(dispatch);
|
|
623
|
+
const resultPages = pageIds.length > 0 ? await handleRequest(callbackPages, responsePageActions, [])(dispatch) : true;
|
|
624
|
+
const resultGlobalPages = globalPageIds.length > 0 ? await handleRequest(callbackGlobalPages, responseGlobalPageActions, [])(dispatch) : true;
|
|
626
625
|
|
|
627
|
-
return resultPages
|
|
626
|
+
return resultPages || resultGlobalPages;
|
|
628
627
|
} catch (e) {
|
|
629
628
|
console.log(e);
|
|
630
629
|
return false;
|
package/src/helpers/index.tsx
CHANGED
|
@@ -46,6 +46,7 @@ import {
|
|
|
46
46
|
getDisplayName,
|
|
47
47
|
getTemplateType,
|
|
48
48
|
getTemplateDisplayName,
|
|
49
|
+
getMenuItems,
|
|
49
50
|
filterByCategory,
|
|
50
51
|
getSchemaType,
|
|
51
52
|
getModuleCategories,
|
|
@@ -133,6 +134,7 @@ export {
|
|
|
133
134
|
getTemplateDisplayName,
|
|
134
135
|
getSchemaThumbnails,
|
|
135
136
|
getTemplateThumbnails,
|
|
137
|
+
getMenuItems,
|
|
136
138
|
filterByCategory,
|
|
137
139
|
getStructuredDataFromPage,
|
|
138
140
|
getCurrentPageStructuredData,
|
package/src/helpers/schemas.tsx
CHANGED
|
@@ -74,6 +74,8 @@ const getTemplateDisplayName = (template: string) => {
|
|
|
74
74
|
return schema ? schema.displayName : undefined;
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
+
const getMenuItems = (type: string): ({ fields: any[] } | undefined) => schemas.menuItems[type];
|
|
78
|
+
|
|
77
79
|
const filterByCategory = (options: any, category: string) =>
|
|
78
80
|
options.filter((option: any) => allSchemas[option].category === category);
|
|
79
81
|
|
|
@@ -153,6 +155,7 @@ export {
|
|
|
153
155
|
getSchemaType,
|
|
154
156
|
getTemplateType,
|
|
155
157
|
getTemplateDisplayName,
|
|
158
|
+
getMenuItems,
|
|
156
159
|
filterByCategory,
|
|
157
160
|
getModuleCategories,
|
|
158
161
|
getModuleStyles,
|
|
@@ -229,10 +229,11 @@ const Content = (props: IProps): JSX.Element => {
|
|
|
229
229
|
itemsPerPage,
|
|
230
230
|
query: searchQuery,
|
|
231
231
|
format: "list",
|
|
232
|
+
lang: lang.id
|
|
232
233
|
};
|
|
233
234
|
|
|
234
235
|
return params;
|
|
235
|
-
}, [filter, currentSiteInfo, isStructuredData, page, searchQuery]);
|
|
236
|
+
}, [filter, currentSiteInfo, isStructuredData, page, searchQuery, lang]);
|
|
236
237
|
|
|
237
238
|
const getPages = (params: any, filterQuery?: any) => {
|
|
238
239
|
const isStructuredDataPage = filter !== "unique-pages";
|
|
@@ -136,13 +136,13 @@ const GlobalEditor = (props: IProps) => {
|
|
|
136
136
|
status: pageStatus.UPLOAD_PENDING,
|
|
137
137
|
};
|
|
138
138
|
|
|
139
|
-
pageID
|
|
140
|
-
? updatePageStatus([pageID], pageStatus.UPLOAD_PENDING)
|
|
141
|
-
: savePage(false, publishPage)
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
139
|
+
const isSaved = pageID
|
|
140
|
+
? await updatePageStatus([pageID], pageStatus.UPLOAD_PENDING)
|
|
141
|
+
: await savePage(false, publishPage);
|
|
142
|
+
|
|
143
|
+
if (isSaved) {
|
|
144
|
+
resetDirty();
|
|
145
|
+
}
|
|
146
146
|
} else {
|
|
147
147
|
setNotification({ text: errorNotificationText, type: "error" });
|
|
148
148
|
}
|
|
@@ -158,20 +158,22 @@ const GlobalEditor = (props: IProps) => {
|
|
|
158
158
|
status: pageStatus.UPLOAD_PENDING,
|
|
159
159
|
};
|
|
160
160
|
|
|
161
|
-
savePage(false, publishPage)
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
});
|
|
161
|
+
const isSaved = await savePage(false, publishPage);
|
|
162
|
+
if (isSaved) {
|
|
163
|
+
resetDirty();
|
|
164
|
+
}
|
|
166
165
|
} else {
|
|
167
166
|
setNotification({ text: errorNotificationText, type: "error" });
|
|
168
167
|
}
|
|
169
168
|
};
|
|
170
169
|
|
|
171
|
-
const unpublishPage = () => {
|
|
170
|
+
const unpublishPage = async () => {
|
|
172
171
|
const { updatePageStatus, pageID } = props;
|
|
173
172
|
|
|
174
|
-
updatePageStatus([pageID], pageStatus.OFFLINE_PENDING);
|
|
173
|
+
const isSaved = await updatePageStatus([pageID], pageStatus.OFFLINE_PENDING);
|
|
174
|
+
if (isSaved) {
|
|
175
|
+
resetDirty();
|
|
176
|
+
}
|
|
175
177
|
};
|
|
176
178
|
|
|
177
179
|
const reviewPage = async () => {
|
|
@@ -44,18 +44,15 @@ const Item = (props: IItemProps): JSX.Element => {
|
|
|
44
44
|
const resetValues = () => resetItemValues();
|
|
45
45
|
|
|
46
46
|
const setItem = (item: IMenuItem) => {
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
47
|
+
const { config, ...rest } = item;
|
|
48
|
+
const type = config ? config.type : "link";
|
|
49
|
+
const headerStyle = config ? config.headerStyle : "";
|
|
50
|
+
const footerStyle = config ? config.footerStyle : "";
|
|
50
51
|
setItemValue(item);
|
|
51
|
-
updateFormValue({ itemLink: item.url });
|
|
52
|
-
updateFormValue({ itemLabel: item.label });
|
|
53
|
-
updateFormValue({ itemAuxText: item.auxText });
|
|
54
|
-
updateFormValue({ itemImage: item.image });
|
|
55
52
|
updateFormValue({ type });
|
|
56
53
|
updateFormValue({ headerStyle });
|
|
57
54
|
updateFormValue({ footerStyle });
|
|
58
|
-
updateFormValue(
|
|
55
|
+
updateFormValue(rest);
|
|
59
56
|
};
|
|
60
57
|
|
|
61
58
|
const openModal = () => {
|
|
@@ -132,7 +129,7 @@ const mapDispatchToProps = {
|
|
|
132
129
|
deleteMenuItem: menuActions.deleteMenuItem,
|
|
133
130
|
resetItemValues: menuActions.resetItemValues,
|
|
134
131
|
setItemValue: menuActions.setItemValue,
|
|
135
|
-
updateFormValue: menuActions.
|
|
132
|
+
updateFormValue: menuActions.updateFormValue,
|
|
136
133
|
};
|
|
137
134
|
|
|
138
135
|
type IItemProps = IProps & IDispatchProps;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { connect } from "react-redux";
|
|
3
|
+
|
|
4
|
+
import { IRootState } from "@ax/types";
|
|
5
|
+
import { menuActions } from "@ax/containers/Navigation/Menu";
|
|
6
|
+
import { FieldsBehavior } from "@ax/components";
|
|
7
|
+
|
|
8
|
+
const ConnectedField = (props: IProps) => {
|
|
9
|
+
const { form, type, name, updateFormValue, setIsGalleryOpened } = props;
|
|
10
|
+
|
|
11
|
+
const value = form[name];
|
|
12
|
+
|
|
13
|
+
const handleChange = (newValue: any) => updateFormValue({ [name]: newValue });
|
|
14
|
+
|
|
15
|
+
const fieldProps = {
|
|
16
|
+
value,
|
|
17
|
+
onChange: handleChange,
|
|
18
|
+
setIsGalleryOpened: type === "ImageField" ? setIsGalleryOpened : undefined,
|
|
19
|
+
...props,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return <FieldsBehavior fieldType={type} {...fieldProps} />;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
interface IProps {
|
|
26
|
+
form: any;
|
|
27
|
+
type: string;
|
|
28
|
+
title: string;
|
|
29
|
+
name: string;
|
|
30
|
+
mandatory?: boolean;
|
|
31
|
+
helptext?: string;
|
|
32
|
+
options?: any;
|
|
33
|
+
updateFormValue: (value: any) => void;
|
|
34
|
+
setIsGalleryOpened?: (isGalleryOpened: boolean) => void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const mapStateToProps = (state: IRootState) => ({
|
|
38
|
+
form: state.menu.form,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const mapDispatchToProps = {
|
|
42
|
+
updateFormValue: menuActions.updateFormValue,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default connect(mapStateToProps, mapDispatchToProps)(ConnectedField)
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import React, { memo } from "react";
|
|
2
|
-
|
|
3
2
|
import { connect } from "react-redux";
|
|
3
|
+
|
|
4
4
|
import { menuActions } from "@ax/containers/Navigation";
|
|
5
5
|
import { sitesActions } from "@ax/containers/Sites";
|
|
6
6
|
import { FieldsBehavior } from "@ax/components";
|
|
7
|
+
import { IRootState, IMenuForm, ISchemaField } from "@ax/types";
|
|
8
|
+
import { getMenuItems } from "@ax/helpers";
|
|
7
9
|
|
|
8
|
-
import
|
|
10
|
+
import ConnectedField from "./ConnectedField";
|
|
9
11
|
|
|
10
12
|
const Form = (props: IProps): JSX.Element => {
|
|
11
|
-
const { form,
|
|
13
|
+
const { form, updateFormValue, toggleSecondaryPanel, setIsGalleryOpened } = props;
|
|
12
14
|
|
|
13
|
-
const {
|
|
15
|
+
const { url, label, type } = form;
|
|
14
16
|
|
|
15
|
-
const setLinkValue = (value: any) =>
|
|
16
|
-
const setLabelValue = (value: string) =>
|
|
17
|
-
const
|
|
18
|
-
const setTypeValue = (value: string) => updateForm({ type: value });
|
|
19
|
-
const setImageValue = (value: IImage) => updateForm({ itemImage: value });
|
|
20
|
-
const setSpecial = (value: boolean) => updateForm({ itemSpecial: value });
|
|
17
|
+
const setLinkValue = (value: any) => updateFormValue({ url: value });
|
|
18
|
+
const setLabelValue = (value: string) => updateFormValue({ label: value });
|
|
19
|
+
const setTypeValue = (value: string) => updateFormValue({ type: value });
|
|
21
20
|
|
|
22
21
|
const typeLinkOptions = [
|
|
23
22
|
{
|
|
@@ -34,6 +33,11 @@ const Form = (props: IProps): JSX.Element => {
|
|
|
34
33
|
|
|
35
34
|
const typeLink = type ? type : "link";
|
|
36
35
|
|
|
36
|
+
const menuItems = getMenuItems(typeLink);
|
|
37
|
+
const schemaFields = menuItems && menuItems.fields ? menuItems.fields : [];
|
|
38
|
+
|
|
39
|
+
const generateFields = (fields: ISchemaField[]) => fields.map((field: ISchemaField) => <ConnectedField {...field } name={field.key} setIsGalleryOpened={setIsGalleryOpened} />);
|
|
40
|
+
|
|
37
41
|
return (
|
|
38
42
|
<>
|
|
39
43
|
<FieldsBehavior
|
|
@@ -49,57 +53,22 @@ const Form = (props: IProps): JSX.Element => {
|
|
|
49
53
|
name="navigationLabel"
|
|
50
54
|
fieldType="TextField"
|
|
51
55
|
autoComplete="nav-label"
|
|
52
|
-
value={
|
|
56
|
+
value={label || ""}
|
|
53
57
|
onChange={setLabelValue}
|
|
54
58
|
/>
|
|
55
|
-
{type
|
|
59
|
+
{type === "link" ? (
|
|
56
60
|
<FieldsBehavior
|
|
57
|
-
title="Image"
|
|
58
|
-
name="image"
|
|
59
|
-
fullWidth={true}
|
|
60
|
-
fieldType="ImageField"
|
|
61
|
-
value={itemImage || null}
|
|
62
|
-
onChange={setImageValue}
|
|
63
|
-
setIsGalleryOpened={setIsGalleryOpened}
|
|
64
|
-
/>
|
|
65
|
-
) : (
|
|
66
|
-
<>
|
|
67
|
-
<FieldsBehavior
|
|
68
61
|
title="Link"
|
|
69
62
|
name="link"
|
|
70
63
|
fieldType="UrlField"
|
|
71
|
-
value={
|
|
64
|
+
value={url || null}
|
|
72
65
|
onChange={setLinkValue}
|
|
73
66
|
advanced={true}
|
|
74
67
|
handlePanel={toggleSecondaryPanel}
|
|
75
68
|
inFloatingPanel={true}
|
|
76
69
|
/>
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
name="auxText"
|
|
80
|
-
fieldType="TextArea"
|
|
81
|
-
value={itemAuxText || ""}
|
|
82
|
-
onChange={setAuxTextValue}
|
|
83
|
-
/>
|
|
84
|
-
<FieldsBehavior
|
|
85
|
-
title="Image"
|
|
86
|
-
name="image"
|
|
87
|
-
fullWidth={true}
|
|
88
|
-
fieldType="ImageField"
|
|
89
|
-
value={itemImage || null}
|
|
90
|
-
onChange={setImageValue}
|
|
91
|
-
setIsGalleryOpened={setIsGalleryOpened}
|
|
92
|
-
/>
|
|
93
|
-
<FieldsBehavior
|
|
94
|
-
name="special"
|
|
95
|
-
fieldType="ToggleField"
|
|
96
|
-
value={itemSpecial}
|
|
97
|
-
onChange={setSpecial}
|
|
98
|
-
background
|
|
99
|
-
auxText="Check it if the link has a special behavior."
|
|
100
|
-
/>
|
|
101
|
-
</>
|
|
102
|
-
)}
|
|
70
|
+
) : null }
|
|
71
|
+
{generateFields(schemaFields)}
|
|
103
72
|
</>
|
|
104
73
|
);
|
|
105
74
|
};
|
|
@@ -109,7 +78,7 @@ const mapStateToProps = (state: IRootState) => ({
|
|
|
109
78
|
});
|
|
110
79
|
|
|
111
80
|
const mapDispatchToProps = {
|
|
112
|
-
|
|
81
|
+
updateFormValue: menuActions.updateFormValue,
|
|
113
82
|
getSitePages: sitesActions.getSitePages,
|
|
114
83
|
};
|
|
115
84
|
|
|
@@ -122,7 +91,7 @@ interface IFormProps {
|
|
|
122
91
|
setIsGalleryOpened?: (isGalleryOpened: boolean) => void;
|
|
123
92
|
}
|
|
124
93
|
interface IDispatchProps {
|
|
125
|
-
|
|
94
|
+
updateFormValue(value: any): void;
|
|
126
95
|
}
|
|
127
96
|
|
|
128
97
|
type IProps = IDispatchProps & IStateProps & IFormProps;
|
|
@@ -14,7 +14,7 @@ const SidePanel = (props: IProps): JSX.Element => {
|
|
|
14
14
|
const { isOpen, isOpenedSecond, toggleModal, toggleSecondaryPanel, addMenuItem, updateMenuItem, item, edit, form } =
|
|
15
15
|
props;
|
|
16
16
|
|
|
17
|
-
const {
|
|
17
|
+
const { type, headerStyle, footerStyle } = form;
|
|
18
18
|
|
|
19
19
|
const [isGalleryOpened, setIsGalleryOpened] = useState(false);
|
|
20
20
|
|
|
@@ -23,13 +23,9 @@ const SidePanel = (props: IProps): JSX.Element => {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
let menuItem: any = {
|
|
26
|
-
|
|
27
|
-
url: itemLink,
|
|
28
|
-
image: itemImage,
|
|
29
|
-
auxText: itemAuxText,
|
|
26
|
+
...form,
|
|
30
27
|
component: "Menu",
|
|
31
28
|
config: { type, headerStyle, footerStyle },
|
|
32
|
-
special: itemSpecial,
|
|
33
29
|
};
|
|
34
30
|
|
|
35
31
|
menuItem.children = edit && item ? item.children : [];
|
|
@@ -144,21 +144,13 @@ const PageEditor = (props: IProps) => {
|
|
|
144
144
|
status: pageStatus.UPLOAD_PENDING,
|
|
145
145
|
};
|
|
146
146
|
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
resetDirty();
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
const handleUpdatePageStatus = async () => {
|
|
155
|
-
const isUpdated = await updatePageStatus([pageID], pageStatus.UPLOAD_PENDING);
|
|
156
|
-
if (isUpdated) {
|
|
157
|
-
resetDirty();
|
|
158
|
-
}
|
|
159
|
-
};
|
|
147
|
+
const isSaved = pageID
|
|
148
|
+
? await updatePageStatus([pageID], pageStatus.UPLOAD_PENDING)
|
|
149
|
+
: await savePage(false, publishPage);
|
|
160
150
|
|
|
161
|
-
|
|
151
|
+
if (isSaved) {
|
|
152
|
+
resetDirty();
|
|
153
|
+
}
|
|
162
154
|
} else {
|
|
163
155
|
setNotification({ text: errorNotificationText, type: "error" });
|
|
164
156
|
}
|
|
@@ -174,20 +166,22 @@ const PageEditor = (props: IProps) => {
|
|
|
174
166
|
status: pageStatus.UPLOAD_PENDING,
|
|
175
167
|
};
|
|
176
168
|
|
|
177
|
-
savePage(false, publishPage)
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
});
|
|
169
|
+
const isSaved = await savePage(false, publishPage);
|
|
170
|
+
if (isSaved) {
|
|
171
|
+
resetDirty();
|
|
172
|
+
}
|
|
182
173
|
} else {
|
|
183
174
|
setNotification({ text: errorNotificationText, type: "error" });
|
|
184
175
|
}
|
|
185
176
|
};
|
|
186
177
|
|
|
187
|
-
const unpublishPage = () => {
|
|
178
|
+
const unpublishPage = async () => {
|
|
188
179
|
const { updatePageStatus, pageID } = props;
|
|
189
180
|
|
|
190
|
-
updatePageStatus([pageID], pageStatus.OFFLINE_PENDING);
|
|
181
|
+
const isSaved = await updatePageStatus([pageID], pageStatus.OFFLINE_PENDING);
|
|
182
|
+
if (isSaved) {
|
|
183
|
+
resetDirty();
|
|
184
|
+
}
|
|
191
185
|
};
|
|
192
186
|
|
|
193
187
|
const reviewPage = async () => {
|
|
@@ -38,7 +38,7 @@ const GridSiteItem = (props: IGridSiteItemProps): JSX.Element => {
|
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
const setSite = async () => {
|
|
41
|
-
setSiteInfo(site);
|
|
41
|
+
await setSiteInfo(site);
|
|
42
42
|
const contentPath = "/sites/pages";
|
|
43
43
|
setHistoryPush(contentPath, false);
|
|
44
44
|
};
|
|
@@ -61,9 +61,9 @@ const GridSiteItem = (props: IGridSiteItemProps): JSX.Element => {
|
|
|
61
61
|
},
|
|
62
62
|
];
|
|
63
63
|
|
|
64
|
-
const handleDeleteSite = () => {
|
|
64
|
+
const handleDeleteSite = async () => {
|
|
65
65
|
const params = getParams();
|
|
66
|
-
deleteSite(site.id, params);
|
|
66
|
+
await deleteSite(site.id, params);
|
|
67
67
|
toggleDeleteModal();
|
|
68
68
|
};
|
|
69
69
|
|
|
@@ -74,15 +74,15 @@ const GridSiteItem = (props: IGridSiteItemProps): JSX.Element => {
|
|
|
74
74
|
};
|
|
75
75
|
const secondaryDeleteAction = { title: "Cancel", onClick: toggleDeleteModal };
|
|
76
76
|
|
|
77
|
-
const handlePublishSite = () => {
|
|
77
|
+
const handlePublishSite = async () => {
|
|
78
78
|
const params = getParams();
|
|
79
|
-
publishSite(site.id, params);
|
|
79
|
+
await publishSite(site.id, params);
|
|
80
80
|
togglePublishModal();
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
-
const handleUnpublishSite = () => {
|
|
83
|
+
const handleUnpublishSite = async () => {
|
|
84
84
|
const params = getParams();
|
|
85
|
-
unpublishSite(site.id, params);
|
|
85
|
+
await unpublishSite(site.id, params);
|
|
86
86
|
togglePublishModal();
|
|
87
87
|
};
|
|
88
88
|
|
|
@@ -171,11 +171,11 @@ const GridSiteItem = (props: IGridSiteItemProps): JSX.Element => {
|
|
|
171
171
|
|
|
172
172
|
interface IGridSiteItemProps {
|
|
173
173
|
site: ISite;
|
|
174
|
-
setSiteInfo(currentSiteInfo: any): void
|
|
174
|
+
setSiteInfo(currentSiteInfo: any): Promise<void>;
|
|
175
175
|
setHistoryPush(page: string, isEditor: boolean): void;
|
|
176
|
-
deleteSite(siteID: number, params?: IGetSitesParams): void
|
|
177
|
-
publishSite(siteID: number, params?: IGetSitesParams): void
|
|
178
|
-
unpublishSite(siteID: number, params?: IGetSitesParams): void
|
|
176
|
+
deleteSite(siteID: number, params?: IGetSitesParams): Promise<void>;
|
|
177
|
+
publishSite(siteID: number, params?: IGetSitesParams): Promise<void>;
|
|
178
|
+
unpublishSite(siteID: number, params?: IGetSitesParams): Promise<void>;
|
|
179
179
|
getParams: () => IGetSitesParams;
|
|
180
180
|
}
|
|
181
181
|
|
|
@@ -40,7 +40,7 @@ const ListSiteItem = (props: IListSiteItemProps): JSX.Element => {
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
const setSite = async () => {
|
|
43
|
-
setSiteInfo(site);
|
|
43
|
+
await setSiteInfo(site);
|
|
44
44
|
const contentPath = "/sites/pages";
|
|
45
45
|
setHistoryPush(contentPath, false);
|
|
46
46
|
};
|
|
@@ -63,9 +63,9 @@ const ListSiteItem = (props: IListSiteItemProps): JSX.Element => {
|
|
|
63
63
|
},
|
|
64
64
|
];
|
|
65
65
|
|
|
66
|
-
const handleDeleteSite = () => {
|
|
66
|
+
const handleDeleteSite = async () => {
|
|
67
67
|
const params = getParams();
|
|
68
|
-
deleteSite(site.id, params);
|
|
68
|
+
await deleteSite(site.id, params);
|
|
69
69
|
toggleDeleteModal();
|
|
70
70
|
};
|
|
71
71
|
|
|
@@ -76,15 +76,15 @@ const ListSiteItem = (props: IListSiteItemProps): JSX.Element => {
|
|
|
76
76
|
};
|
|
77
77
|
const secondaryDeleteAction = { title: "Cancel", onClick: toggleDeleteModal };
|
|
78
78
|
|
|
79
|
-
const handlePublishSite = () => {
|
|
79
|
+
const handlePublishSite = async () => {
|
|
80
80
|
const params = getParams();
|
|
81
|
-
publishSite(site.id, params);
|
|
81
|
+
await publishSite(site.id, params);
|
|
82
82
|
togglePublishModal();
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
const handleUnpublishSite = () => {
|
|
85
|
+
const handleUnpublishSite = async () => {
|
|
86
86
|
const params = getParams();
|
|
87
|
-
unpublishSite(site.id, params);
|
|
87
|
+
await unpublishSite(site.id, params);
|
|
88
88
|
togglePublishModal();
|
|
89
89
|
};
|
|
90
90
|
|
|
@@ -185,11 +185,11 @@ const ListSiteItem = (props: IListSiteItemProps): JSX.Element => {
|
|
|
185
185
|
interface IListSiteItemProps {
|
|
186
186
|
site: ISite;
|
|
187
187
|
isSelected: boolean;
|
|
188
|
-
setSiteInfo(currentSiteInfo: any): void
|
|
188
|
+
setSiteInfo(currentSiteInfo: any): Promise<void>;
|
|
189
189
|
setHistoryPush(site: string, isEditor: boolean): void;
|
|
190
|
-
deleteSite(siteID: number, params?: IGetSitesParams): void
|
|
191
|
-
publishSite(siteID: number, params?: IGetSitesParams): void
|
|
192
|
-
unpublishSite(siteID: number, params?: IGetSitesParams): void
|
|
190
|
+
deleteSite(siteID: number, params?: IGetSitesParams): Promise<void>;
|
|
191
|
+
publishSite(siteID: number, params?: IGetSitesParams): Promise<void>;
|
|
192
|
+
unpublishSite(siteID: number, params?: IGetSitesParams): Promise<void>;
|
|
193
193
|
onCheck: (e: any) => void;
|
|
194
194
|
getParams: () => IGetSitesParams;
|
|
195
195
|
}
|
|
@@ -14,8 +14,8 @@ import * as S from "./style";
|
|
|
14
14
|
const RecentSiteItem = (props: IRecentSiteItemProps): JSX.Element => {
|
|
15
15
|
const { site, setSiteInfo, setHistoryPush } = props;
|
|
16
16
|
|
|
17
|
-
const setSite = () => {
|
|
18
|
-
setSiteInfo(site);
|
|
17
|
+
const setSite = async () => {
|
|
18
|
+
await setSiteInfo(site);
|
|
19
19
|
const contentPath = "/sites/pages";
|
|
20
20
|
setHistoryPush(contentPath, false);
|
|
21
21
|
};
|
|
@@ -38,7 +38,7 @@ const RecentSiteItem = (props: IRecentSiteItemProps): JSX.Element => {
|
|
|
38
38
|
|
|
39
39
|
interface IRecentSiteItemProps {
|
|
40
40
|
site: ISite;
|
|
41
|
-
setSiteInfo(currentSiteInfo: any): void
|
|
41
|
+
setSiteInfo(currentSiteInfo: any): Promise<void>;
|
|
42
42
|
setHistoryPush(page: string, isEditor: boolean): void;
|
|
43
43
|
}
|
|
44
44
|
|
package/src/types/index.tsx
CHANGED
|
@@ -364,14 +364,11 @@ export interface IMenuItemConfig {
|
|
|
364
364
|
}
|
|
365
365
|
|
|
366
366
|
export interface IMenuForm {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
itemAuxText: string;
|
|
370
|
-
itemImage: IImage | string | null;
|
|
367
|
+
url: any;
|
|
368
|
+
label: string;
|
|
371
369
|
type: string;
|
|
372
370
|
headerStyle: string;
|
|
373
371
|
footerStyle: string;
|
|
374
|
-
itemSpecial: boolean;
|
|
375
372
|
}
|
|
376
373
|
|
|
377
374
|
export interface IHeader {
|