@griddo/ax 10.2.11 → 10.2.13
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/Fields/ReferenceField/ReferenceField.test.tsx +1 -1
- package/src/__tests__/components/Fields/UrlField/UrlField.test.tsx +1 -1
- package/src/components/Fields/AsyncSelect/index.tsx +12 -8
- package/src/components/Fields/AsyncSelect/style.tsx +58 -1
- package/src/components/Fields/CheckField/index.tsx +15 -2
- package/src/components/Fields/IntegrationsField/IntegrationItem/CustomPanel/index.tsx +49 -47
- package/src/components/Fields/IntegrationsField/IntegrationItem/CustomPanel/style.tsx +6 -1
- package/src/components/Fields/IntegrationsField/IntegrationItem/VariablesPanel/index.tsx +13 -11
- package/src/components/Fields/IntegrationsField/IntegrationItem/VariablesPanel/style.tsx +6 -3
- package/src/components/Fields/MultiCheckSelect/style.tsx +1 -0
- package/src/components/Fields/ReferenceField/AutoPanel/AutoItem/index.tsx +6 -5
- package/src/components/Fields/ReferenceField/AutoPanel/index.tsx +277 -40
- package/src/components/Fields/ReferenceField/AutoPanel/style.tsx +117 -15
- package/src/components/Fields/ReferenceField/Context/index.tsx +18 -10
- package/src/components/Fields/ReferenceField/ItemList/Item/index.tsx +9 -30
- package/src/components/Fields/ReferenceField/ItemList/Item/style.tsx +9 -51
- package/src/components/Fields/ReferenceField/ItemList/index.tsx +14 -18
- package/src/components/Fields/ReferenceField/ManualPanel/Item/index.tsx +1 -1
- package/src/components/Fields/ReferenceField/ManualPanel/Item/style.tsx +25 -26
- package/src/components/Fields/ReferenceField/ManualPanel/index.tsx +91 -36
- package/src/components/Fields/ReferenceField/ManualPanel/style.tsx +29 -1
- package/src/components/Fields/ReferenceField/index.tsx +18 -11
- package/src/components/Fields/Select/index.tsx +10 -13
- package/src/components/Fields/Select/style.tsx +13 -7
- package/src/components/Fields/TimeField/index.tsx +1 -0
- package/src/components/Fields/UniqueCheck/index.tsx +3 -1
- package/src/components/Fields/UrlField/index.tsx +3 -1
- package/src/components/Fields/UrlField/style.tsx +6 -1
- package/src/components/FloatingPanel/style.tsx +0 -1
- package/src/components/PageFinder/index.tsx +8 -7
- package/src/components/SearchField/index.tsx +2 -3
- package/src/helpers/arrays.tsx +2 -2
- package/src/modules/Analytics/DimensionPanel/index.tsx +44 -42
- package/src/modules/Analytics/DimensionPanel/style.tsx +6 -1
- package/src/modules/Analytics/GroupPanel/index.tsx +57 -64
- package/src/modules/Analytics/GroupPanel/style.tsx +6 -0
- package/src/modules/Categories/CategoriesList/CategoryPanel/index.tsx +15 -13
- package/src/modules/Categories/CategoriesList/CategoryPanel/style.tsx +11 -4
- package/src/modules/GlobalSettings/Robots/Item/RobotsPanel/index.tsx +20 -18
- package/src/modules/GlobalSettings/Robots/Item/RobotsPanel/style.tsx +6 -1
- package/src/modules/Navigation/Menus/List/Table/ConfigPanel/index.tsx +8 -6
- package/src/modules/Navigation/Menus/List/Table/ConfigPanel/style.tsx +6 -1
- package/src/modules/Navigation/Menus/List/Table/SidePanel/index.tsx +15 -13
- package/src/modules/Navigation/Menus/List/Table/SidePanel/style.tsx +9 -2
- package/src/modules/PublicPreview/index.tsx +1 -1
- package/src/modules/Redirects/RedirectPanel/index.tsx +33 -31
- package/src/modules/Redirects/RedirectPanel/style.tsx +6 -1
- package/src/modules/Redirects/index.tsx +0 -1
- package/src/modules/Settings/Integrations/IntegrationForm/VariablePanel/index.tsx +63 -61
- package/src/modules/Settings/Integrations/IntegrationForm/VariablePanel/style.tsx +6 -1
- package/src/modules/Settings/Integrations/IntegrationForm/index.tsx +5 -3
- package/src/modules/Settings/Integrations/IntegrationForm/style.tsx +6 -0
- package/src/modules/Settings/Languages/LanguagePanel/index.tsx +14 -12
- package/src/modules/Settings/Languages/LanguagePanel/style.tsx +8 -1
- package/src/types/index.tsx +1 -1
|
@@ -1,19 +1,51 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
|
+
import { connect } from "react-redux";
|
|
2
3
|
|
|
3
|
-
import { IDataSource, ISite, IStructuredData } from "@ax/types";
|
|
4
|
-
import {
|
|
4
|
+
import { IDataSource, ILanguage, IRootState, ISite, IStructuredData } from "@ax/types";
|
|
5
|
+
import {
|
|
6
|
+
Button,
|
|
7
|
+
FloatingMenu,
|
|
8
|
+
IconAction,
|
|
9
|
+
RadioGroup,
|
|
10
|
+
Select,
|
|
11
|
+
FieldsBehavior,
|
|
12
|
+
AsyncSelect,
|
|
13
|
+
ToggleField,
|
|
14
|
+
UniqueCheck,
|
|
15
|
+
} from "@ax/components";
|
|
5
16
|
|
|
6
17
|
import { IReferenceState, useReference } from "../Context";
|
|
7
18
|
import AutoItem from "./AutoItem";
|
|
19
|
+
|
|
8
20
|
import * as S from "./style";
|
|
9
21
|
|
|
10
22
|
const AutoPanel = (props: IProps): JSX.Element => {
|
|
11
|
-
const { onChange, site, structuredData, validators, categories } = props;
|
|
23
|
+
const { onChange, site, structuredData, validators, categories, globalLangs, lang } = props;
|
|
12
24
|
|
|
13
25
|
const { state, setState } = useReference();
|
|
14
26
|
|
|
15
27
|
const init = state.quantity ? "number" : "all";
|
|
16
28
|
const [allItems, setAllItems] = useState<string | boolean>(init);
|
|
29
|
+
const initConfig = {
|
|
30
|
+
isConfigOpen: false,
|
|
31
|
+
isLanguageOpen: true,
|
|
32
|
+
isDataOpen: true,
|
|
33
|
+
isAllLangOpen: true,
|
|
34
|
+
isCustomLangOpen: true,
|
|
35
|
+
};
|
|
36
|
+
const [configState, setConfigState] = useState<IConfigState>(initConfig);
|
|
37
|
+
const initToggle = {
|
|
38
|
+
isSiteActive: state.site ? true : false,
|
|
39
|
+
isLangActive: state.lang ? true : false,
|
|
40
|
+
errorSite: false,
|
|
41
|
+
errorLang: false,
|
|
42
|
+
errorMsg: "",
|
|
43
|
+
};
|
|
44
|
+
const [toggleState, setToggleState] = useState<IToggleState>(initToggle);
|
|
45
|
+
|
|
46
|
+
const langOptions = globalLangs
|
|
47
|
+
.filter((language) => lang.id !== language.id)
|
|
48
|
+
.map((language) => ({ label: language.label, value: language.id.toString() }));
|
|
17
49
|
|
|
18
50
|
const structuredDataValues: any[] = [];
|
|
19
51
|
for (const [, dataType] of Object.entries(structuredData) as any[]) {
|
|
@@ -92,20 +124,43 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
92
124
|
minValue: validators && validators.minValue ? validators.minValue : undefined,
|
|
93
125
|
};
|
|
94
126
|
|
|
127
|
+
const checkErrors = (): boolean => {
|
|
128
|
+
let errorSite = false;
|
|
129
|
+
let errorLang = false;
|
|
130
|
+
let errorMsg = "";
|
|
131
|
+
if (toggleState.isSiteActive && !state.site) {
|
|
132
|
+
errorSite = true;
|
|
133
|
+
errorMsg = "You need to select site before apply.";
|
|
134
|
+
}
|
|
135
|
+
if (toggleState.isLangActive && !state.lang) {
|
|
136
|
+
errorLang = true;
|
|
137
|
+
errorMsg = "You need to select language before apply.";
|
|
138
|
+
}
|
|
139
|
+
if (errorLang && errorSite) {
|
|
140
|
+
errorMsg = "You need to define some settings before apply.";
|
|
141
|
+
}
|
|
142
|
+
setToggleState({ ...toggleState, errorLang, errorSite, errorMsg });
|
|
143
|
+
return errorSite || errorLang;
|
|
144
|
+
};
|
|
145
|
+
|
|
95
146
|
const handleApply = () => {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
147
|
+
if (!checkErrors()) {
|
|
148
|
+
const order = state.order.concat("-", state.orderDirection);
|
|
149
|
+
const newValue = {
|
|
150
|
+
mode: "auto",
|
|
151
|
+
quantity: state.quantity,
|
|
152
|
+
order,
|
|
153
|
+
source: state.source,
|
|
154
|
+
filter: state.filter,
|
|
155
|
+
fullRelations: state.fullRelations,
|
|
156
|
+
allLanguages: state.allLanguages,
|
|
157
|
+
preferenceLanguage: state.preferenceLanguage,
|
|
158
|
+
lang: state.lang,
|
|
159
|
+
site: state.site,
|
|
160
|
+
};
|
|
107
161
|
|
|
108
|
-
|
|
162
|
+
onChange(newValue);
|
|
163
|
+
}
|
|
109
164
|
};
|
|
110
165
|
|
|
111
166
|
const handleAddSource = (value: string) => {
|
|
@@ -172,12 +227,45 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
172
227
|
}
|
|
173
228
|
};
|
|
174
229
|
|
|
175
|
-
const handleAllLanguagesChange = (value: any) =>
|
|
176
|
-
|
|
230
|
+
const handleAllLanguagesChange = (value: any) => {
|
|
231
|
+
const preferenceLanguage = value ? state.preferenceLanguage : false;
|
|
232
|
+
setState((state: IReferenceState) => ({ ...state, allLanguages: value, preferenceLanguage }));
|
|
233
|
+
};
|
|
177
234
|
|
|
178
235
|
const handlePreferenceLanguageChange = (value: any) =>
|
|
179
236
|
setState((state: IReferenceState) => ({ ...state, preferenceLanguage: value }));
|
|
180
237
|
|
|
238
|
+
const toggleConfig = (value: keyof IConfigState) => setConfigState({ ...configState, [value]: !configState[value] });
|
|
239
|
+
|
|
240
|
+
const handleSiteChange = (value: string | number | null) => {
|
|
241
|
+
setState((state: IReferenceState) => ({ ...state, site: value || undefined }));
|
|
242
|
+
if (value) {
|
|
243
|
+
setToggleState({ ...toggleState, isSiteActive: true, errorSite: false, errorMsg: "" });
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
const handleLangChange = (value: string) => {
|
|
248
|
+
const lang = value.length ? parseInt(value) : undefined;
|
|
249
|
+
setState((state: IReferenceState) => ({ ...state, lang }));
|
|
250
|
+
if (value) {
|
|
251
|
+
setToggleState({ ...toggleState, isLangActive: true, errorLang: false, errorMsg: "" });
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
const handleLangToggleChange = (value: boolean) => {
|
|
256
|
+
setToggleState({ ...toggleState, isLangActive: value });
|
|
257
|
+
if (!value) {
|
|
258
|
+
setState((state: IReferenceState) => ({ ...state, lang: undefined }));
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
const handleSiteToggleChange = (value: boolean) => {
|
|
263
|
+
setToggleState({ ...toggleState, isSiteActive: value });
|
|
264
|
+
if (!value) {
|
|
265
|
+
setState((state: IReferenceState) => ({ ...state, site: undefined }));
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
|
|
181
269
|
return (
|
|
182
270
|
<S.Wrapper data-testid="auto-panel-wrapper">
|
|
183
271
|
<S.FormWrapper>
|
|
@@ -186,7 +274,8 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
186
274
|
<S.SourceActions>
|
|
187
275
|
{state.source && `${state.source.length} items`} {addSource}
|
|
188
276
|
</S.SourceActions>
|
|
189
|
-
{state.source &&
|
|
277
|
+
{state.source &&
|
|
278
|
+
state.source.length > 0 &&
|
|
190
279
|
state.source.map((singleSource: string) => {
|
|
191
280
|
const sourceFilters = state.filter.filter((f: any) => f.source === singleSource);
|
|
192
281
|
const source = state.sourceTitles.find((el: IDataSource) => el.id === singleSource);
|
|
@@ -198,30 +287,15 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
198
287
|
handleDelete={removeItem}
|
|
199
288
|
filter={sourceFilters}
|
|
200
289
|
addFilter={handleAddFilter}
|
|
201
|
-
|
|
290
|
+
currentSite={site}
|
|
202
291
|
structuredDataSite={[...structuredData.site, ...categories.site]}
|
|
292
|
+
siteID={state.site || site?.id}
|
|
203
293
|
/>
|
|
204
|
-
) :
|
|
294
|
+
) : (
|
|
295
|
+
<></>
|
|
296
|
+
);
|
|
205
297
|
})}
|
|
206
298
|
</S.SourcesWrapper>
|
|
207
|
-
<S.AllLanguagesWrapper>
|
|
208
|
-
<S.AllLanguagesText>
|
|
209
|
-
The content is displayed in the language of the page, but if the content you want is not available in that
|
|
210
|
-
language, you have the option to include content in another language.
|
|
211
|
-
</S.AllLanguagesText>
|
|
212
|
-
<UniqueCheck
|
|
213
|
-
name="allLanguagesCheck"
|
|
214
|
-
options={[{ value: false, name: "allLanguages", title: "Include content in another language" }]}
|
|
215
|
-
value={state.allLanguages}
|
|
216
|
-
onChange={handleAllLanguagesChange}
|
|
217
|
-
/>
|
|
218
|
-
{state.allLanguages && <UniqueCheck
|
|
219
|
-
name="preferenceLanguageCheck"
|
|
220
|
-
options={[{ value: false, name: "preferenceLanguage", title: "Language page first" }]}
|
|
221
|
-
value={state.preferenceLanguage}
|
|
222
|
-
onChange={handlePreferenceLanguageChange}
|
|
223
|
-
/>}
|
|
224
|
-
</S.AllLanguagesWrapper>
|
|
225
299
|
<S.RadioWrapper>
|
|
226
300
|
<S.FieldLabel>Sort</S.FieldLabel>
|
|
227
301
|
<RadioGroup {...radioGroupProps} />
|
|
@@ -229,8 +303,148 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
229
303
|
<S.FieldLabel>Number of items</S.FieldLabel>
|
|
230
304
|
<RadioGroup name="quantityGroup" options={quantityOptions} value={allItems} onChange={handleItemsChange} />
|
|
231
305
|
{allItems !== "all" && <FieldsBehavior {...numberFieldProps} />}
|
|
306
|
+
|
|
307
|
+
<S.AdvancedWrapper>
|
|
308
|
+
<S.ConfigLabel
|
|
309
|
+
onClick={() => toggleConfig("isConfigOpen")}
|
|
310
|
+
isOpen={configState.isConfigOpen}
|
|
311
|
+
data-testid="advanced-config-label"
|
|
312
|
+
>
|
|
313
|
+
Advanced Settings
|
|
314
|
+
</S.ConfigLabel>
|
|
315
|
+
<S.ConfigWrapper isOpen={configState.isConfigOpen}>
|
|
316
|
+
<S.OptionLabel
|
|
317
|
+
onClick={() => toggleConfig("isLanguageOpen")}
|
|
318
|
+
isOpen={configState.isLanguageOpen}
|
|
319
|
+
data-testid="advanced-config-label"
|
|
320
|
+
>
|
|
321
|
+
<S.LabelContent>
|
|
322
|
+
<S.OptionText>Language options</S.OptionText>
|
|
323
|
+
</S.LabelContent>
|
|
324
|
+
</S.OptionLabel>
|
|
325
|
+
|
|
326
|
+
<S.ConfigWrapper isOpen={configState.isLanguageOpen}>
|
|
327
|
+
<S.ConfigContent smallMargin={toggleState.isLangActive}>
|
|
328
|
+
<S.OptionLabel
|
|
329
|
+
onClick={() => toggleConfig("isAllLangOpen")}
|
|
330
|
+
isOpen={configState.isAllLangOpen}
|
|
331
|
+
data-testid="advanced-config-label"
|
|
332
|
+
>
|
|
333
|
+
<S.LabelContent>
|
|
334
|
+
<S.SubOptionText>Include content in any language</S.SubOptionText>
|
|
335
|
+
<ToggleField
|
|
336
|
+
name="allLanguages"
|
|
337
|
+
value={state.allLanguages}
|
|
338
|
+
onChange={handleAllLanguagesChange}
|
|
339
|
+
size="s"
|
|
340
|
+
/>
|
|
341
|
+
</S.LabelContent>
|
|
342
|
+
</S.OptionLabel>
|
|
343
|
+
|
|
344
|
+
<S.ConfigWrapper isOpen={configState.isAllLangOpen}>
|
|
345
|
+
<S.SubConfigContent hasMargin={true}>
|
|
346
|
+
<S.OptionDescription>
|
|
347
|
+
By default, data is displayed in the page's language. Enable this option if you want the content
|
|
348
|
+
to <strong>include data in any available language</strong>.
|
|
349
|
+
</S.OptionDescription>
|
|
350
|
+
{state.allLanguages && (
|
|
351
|
+
<S.CheckWrapper>
|
|
352
|
+
<UniqueCheck
|
|
353
|
+
name="preferenceLanguageCheck"
|
|
354
|
+
options={[{ value: false, name: "preferenceLanguage", title: "Language page first" }]}
|
|
355
|
+
value={state.preferenceLanguage}
|
|
356
|
+
onChange={handlePreferenceLanguageChange}
|
|
357
|
+
/>
|
|
358
|
+
</S.CheckWrapper>
|
|
359
|
+
)}
|
|
360
|
+
</S.SubConfigContent>
|
|
361
|
+
</S.ConfigWrapper>
|
|
362
|
+
|
|
363
|
+
{langOptions.length > 0 ? (
|
|
364
|
+
<>
|
|
365
|
+
<S.OptionLabel
|
|
366
|
+
onClick={() => toggleConfig("isCustomLangOpen")}
|
|
367
|
+
isOpen={configState.isCustomLangOpen}
|
|
368
|
+
data-testid="advanced-config-label"
|
|
369
|
+
>
|
|
370
|
+
<S.LabelContent>
|
|
371
|
+
<S.SubOptionText>Specify different language</S.SubOptionText>
|
|
372
|
+
<ToggleField
|
|
373
|
+
name="customLang"
|
|
374
|
+
value={toggleState.isLangActive}
|
|
375
|
+
onChange={handleLangToggleChange}
|
|
376
|
+
size="s"
|
|
377
|
+
/>
|
|
378
|
+
</S.LabelContent>
|
|
379
|
+
</S.OptionLabel>
|
|
380
|
+
|
|
381
|
+
<S.ConfigWrapper>
|
|
382
|
+
<S.SubConfigContent>
|
|
383
|
+
<S.OptionDescription isOpen={configState.isCustomLangOpen}>
|
|
384
|
+
By default, data is displayed in the page's language. Enable this option if you wish to{" "}
|
|
385
|
+
<strong>specify a different language</strong> for the content of this distributor.
|
|
386
|
+
</S.OptionDescription>
|
|
387
|
+
{toggleState.isLangActive && (
|
|
388
|
+
<Select
|
|
389
|
+
name="select"
|
|
390
|
+
options={langOptions}
|
|
391
|
+
onChange={handleLangChange}
|
|
392
|
+
value={state.lang?.toString() || ""}
|
|
393
|
+
type="inline"
|
|
394
|
+
placeholder="Select language"
|
|
395
|
+
error={toggleState.errorLang}
|
|
396
|
+
/>
|
|
397
|
+
)}
|
|
398
|
+
</S.SubConfigContent>
|
|
399
|
+
</S.ConfigWrapper>
|
|
400
|
+
</>
|
|
401
|
+
) : (
|
|
402
|
+
<></>
|
|
403
|
+
)}
|
|
404
|
+
</S.ConfigContent>
|
|
405
|
+
</S.ConfigWrapper>
|
|
406
|
+
|
|
407
|
+
<S.OptionLabel
|
|
408
|
+
onClick={() => toggleConfig("isDataOpen")}
|
|
409
|
+
isOpen={configState.isDataOpen}
|
|
410
|
+
data-testid="advanced-config-label"
|
|
411
|
+
>
|
|
412
|
+
<S.LabelContent>
|
|
413
|
+
<S.OptionText>Data from specific site</S.OptionText>
|
|
414
|
+
<ToggleField
|
|
415
|
+
name="site-toggle"
|
|
416
|
+
value={toggleState.isSiteActive}
|
|
417
|
+
onChange={handleSiteToggleChange}
|
|
418
|
+
size="s"
|
|
419
|
+
/>
|
|
420
|
+
</S.LabelContent>
|
|
421
|
+
</S.OptionLabel>
|
|
422
|
+
|
|
423
|
+
<S.ConfigWrapper>
|
|
424
|
+
<S.ConfigContent smallMargin={toggleState.isSiteActive} isLast={true}>
|
|
425
|
+
<S.OptionDescription isOpen={configState.isDataOpen}>
|
|
426
|
+
Data is retrieved from the site you are on.{" "}
|
|
427
|
+
<strong>If you prefer to display content from another site</strong>, configure this option to select
|
|
428
|
+
the specific site.
|
|
429
|
+
</S.OptionDescription>
|
|
430
|
+
{toggleState.isSiteActive && (
|
|
431
|
+
<AsyncSelect
|
|
432
|
+
name="select"
|
|
433
|
+
entity="sites"
|
|
434
|
+
onChange={handleSiteChange}
|
|
435
|
+
value={state.site || null}
|
|
436
|
+
type="inline"
|
|
437
|
+
placeholder="Select site"
|
|
438
|
+
error={toggleState.errorSite}
|
|
439
|
+
/>
|
|
440
|
+
)}
|
|
441
|
+
</S.ConfigContent>
|
|
442
|
+
</S.ConfigWrapper>
|
|
443
|
+
</S.ConfigWrapper>
|
|
444
|
+
</S.AdvancedWrapper>
|
|
232
445
|
</S.FormWrapper>
|
|
233
446
|
<S.ActionsWrapper>
|
|
447
|
+
<S.ErrorWrapper>{toggleState.errorMsg.length > 0 && toggleState.errorMsg}</S.ErrorWrapper>
|
|
234
448
|
<Button type="button" onClick={handleApply}>
|
|
235
449
|
Apply
|
|
236
450
|
</Button>
|
|
@@ -243,8 +457,31 @@ interface IProps {
|
|
|
243
457
|
structuredData: { global: IStructuredData[]; site: IStructuredData[] };
|
|
244
458
|
categories: { global: IStructuredData[]; site: IStructuredData[] };
|
|
245
459
|
onChange: (value: any) => void;
|
|
246
|
-
site: ISite;
|
|
460
|
+
site: ISite | null;
|
|
247
461
|
validators?: Record<string, unknown>;
|
|
462
|
+
globalLangs: ILanguage[];
|
|
463
|
+
lang: { locale: string; id: number };
|
|
248
464
|
}
|
|
249
465
|
|
|
250
|
-
|
|
466
|
+
interface IConfigState {
|
|
467
|
+
isConfigOpen: boolean;
|
|
468
|
+
isLanguageOpen: boolean;
|
|
469
|
+
isDataOpen: boolean;
|
|
470
|
+
isAllLangOpen: boolean;
|
|
471
|
+
isCustomLangOpen: boolean;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
interface IToggleState {
|
|
475
|
+
isSiteActive: boolean;
|
|
476
|
+
isLangActive: boolean;
|
|
477
|
+
errorSite: boolean;
|
|
478
|
+
errorLang: boolean;
|
|
479
|
+
errorMsg: string;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
const mapStateToProps = (state: IRootState) => ({
|
|
483
|
+
globalLangs: state.app.globalLangs,
|
|
484
|
+
lang: state.app.lang,
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
export default connect(mapStateToProps)(AutoPanel);
|
|
@@ -6,11 +6,15 @@ const Wrapper = styled.div`
|
|
|
6
6
|
justify-content: space-between;
|
|
7
7
|
position: relative;
|
|
8
8
|
height: 100%;
|
|
9
|
-
overflow: auto;
|
|
10
9
|
padding-bottom: ${(p) => `calc(${p.theme.spacing.l} + ${p.theme.spacing.s})`};
|
|
11
10
|
`;
|
|
12
11
|
|
|
13
|
-
const FormWrapper = styled.div
|
|
12
|
+
const FormWrapper = styled.div`
|
|
13
|
+
position: relative;
|
|
14
|
+
padding: ${(p) => p.theme.spacing.m};
|
|
15
|
+
height: 100%;
|
|
16
|
+
overflow: auto;
|
|
17
|
+
`;
|
|
14
18
|
|
|
15
19
|
const SourcesWrapper = styled.div`
|
|
16
20
|
margin-bottom: ${(p) => p.theme.spacing.m};
|
|
@@ -45,7 +49,7 @@ const RadioWrapper = styled.div`
|
|
|
45
49
|
|
|
46
50
|
const SelectWrapper = styled.div`
|
|
47
51
|
position: absolute;
|
|
48
|
-
right:
|
|
52
|
+
right: ${(p) => p.theme.spacing.m};
|
|
49
53
|
margin-top: ${(p) => `-${p.theme.spacing.xs}`};
|
|
50
54
|
div {
|
|
51
55
|
right: 0;
|
|
@@ -53,8 +57,14 @@ const SelectWrapper = styled.div`
|
|
|
53
57
|
`;
|
|
54
58
|
|
|
55
59
|
const ActionsWrapper = styled.div`
|
|
60
|
+
display: flex;
|
|
56
61
|
text-align: right;
|
|
57
|
-
padding
|
|
62
|
+
padding: ${(p) => `${p.theme.spacing.s} ${p.theme.spacing.m} ${p.theme.spacing.m} ${p.theme.spacing.m}`};
|
|
63
|
+
border-top: 1px solid ${(p) => p.theme.color.uiLine};
|
|
64
|
+
align-items: center;
|
|
65
|
+
button {
|
|
66
|
+
flex-shrink: 0;
|
|
67
|
+
}
|
|
58
68
|
`;
|
|
59
69
|
|
|
60
70
|
const IconWrapper = styled.div`
|
|
@@ -75,19 +85,101 @@ const SourceItem = styled.li`
|
|
|
75
85
|
}
|
|
76
86
|
`;
|
|
77
87
|
|
|
78
|
-
const
|
|
88
|
+
const AdvancedWrapper = styled.div`
|
|
89
|
+
margin-top: ${(p) => p.theme.spacing.m};
|
|
90
|
+
`;
|
|
91
|
+
|
|
92
|
+
const ConfigLabel = styled.div<{ isOpen: boolean }>`
|
|
93
|
+
position: relative;
|
|
94
|
+
${(p) => p.theme.textStyle.uiS};
|
|
95
|
+
color: ${(p) => p.theme.colors.interactive01};
|
|
96
|
+
margin-bottom: ${(p) => p.theme.spacing.xs};
|
|
97
|
+
cursor: pointer;
|
|
98
|
+
:after {
|
|
99
|
+
content: "";
|
|
100
|
+
border: solid ${(p) => p.theme.color.interactive01};
|
|
101
|
+
margin-left: ${(p) => p.theme.spacing.xs};
|
|
102
|
+
border-width: 0 2px 2px 0;
|
|
103
|
+
display: inline-block;
|
|
104
|
+
padding: 3px;
|
|
105
|
+
transform: ${(p) => (p.isOpen ? `rotate(-135deg) translate(-2px, 0)` : `rotate(45deg) translate(0, -2px)`)};
|
|
106
|
+
}
|
|
107
|
+
`;
|
|
108
|
+
|
|
109
|
+
const ConfigWrapper = styled.div<{ isOpen?: boolean }>`
|
|
110
|
+
overflow-y: ${(p) => (p.isOpen === false ? "hidden" : "visible")};
|
|
111
|
+
height: ${(p) => (p.isOpen === false ? 0 : "auto")};
|
|
112
|
+
transition: height 0.5s ease-in-out;
|
|
113
|
+
`;
|
|
114
|
+
|
|
115
|
+
const ConfigContent = styled.div<{ smallMargin: boolean; isLast?: boolean }>`
|
|
116
|
+
margin-bottom: ${(p) => p.theme.spacing.m};
|
|
117
|
+
padding: ${(p) =>
|
|
118
|
+
p.smallMargin ? `0 0 ${p.theme.spacing.xs} ${p.theme.spacing.m}` : `0 0 ${p.theme.spacing.m} ${p.theme.spacing.m}`};
|
|
119
|
+
border-bottom: ${(p) => (p.isLast ? "none" : `1px solid ${p.theme.color.uiLine}`)};
|
|
120
|
+
`;
|
|
121
|
+
|
|
122
|
+
const SubConfigContent = styled.div<{ hasMargin?: boolean }>`
|
|
123
|
+
padding-left: ${(p) => p.theme.spacing.m};
|
|
124
|
+
margin-bottom: ${(p) => (p.hasMargin ? p.theme.spacing.s : "0")};
|
|
125
|
+
`;
|
|
126
|
+
|
|
127
|
+
const OptionLabel = styled.div<{ isOpen: boolean }>`
|
|
128
|
+
position: relative;
|
|
129
|
+
margin-bottom: ${(p) => p.theme.spacing.xs};
|
|
130
|
+
padding-left: ${(p) => p.theme.spacing.xxs};
|
|
131
|
+
cursor: pointer;
|
|
132
|
+
:before {
|
|
133
|
+
position: absolute;
|
|
134
|
+
top: 6px;
|
|
135
|
+
content: "";
|
|
136
|
+
border: solid ${(p) => p.theme.color.interactive01};
|
|
137
|
+
margin-right: 12px;
|
|
138
|
+
border-width: 0 2px 2px 0;
|
|
139
|
+
padding: 3px;
|
|
140
|
+
transform: ${(p) => (p.isOpen ? `rotate(45deg) translate(-3px, 0)` : `rotate(-45deg) translate(0, -3px)`)};
|
|
141
|
+
}
|
|
142
|
+
`;
|
|
143
|
+
|
|
144
|
+
const OptionText = styled.div`
|
|
79
145
|
${(p) => p.theme.textStyle.fieldContent};
|
|
80
|
-
color: ${(p) => p.theme.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
146
|
+
color: ${(p) => p.theme.colors.textHighEmphasis};
|
|
147
|
+
`;
|
|
148
|
+
|
|
149
|
+
const SubOptionText = styled.div`
|
|
150
|
+
${(p) => p.theme.textStyle.uiM};
|
|
151
|
+
color: ${(p) => p.theme.colors.textHighEmphasis};
|
|
152
|
+
`;
|
|
153
|
+
|
|
154
|
+
const LabelContent = styled.div`
|
|
155
|
+
display: flex;
|
|
156
|
+
align-items: center;
|
|
157
|
+
justify-content: space-between;
|
|
158
|
+
padding-left: 20px;
|
|
85
159
|
`;
|
|
86
160
|
|
|
87
|
-
const
|
|
161
|
+
const OptionDescription = styled.div<{ isOpen?: boolean }>`
|
|
88
162
|
${(p) => p.theme.textStyle.uiXS};
|
|
89
|
-
color: ${(p) => p.theme.
|
|
90
|
-
|
|
163
|
+
color: ${(p) => p.theme.colors.textMediumEmphasis};
|
|
164
|
+
padding-right: ${(p) => p.theme.spacing.s};
|
|
165
|
+
overflow-y: ${(p) => (p.isOpen === false ? "hidden" : "visible")};
|
|
166
|
+
height: ${(p) => (p.isOpen === false ? 0 : "auto")};
|
|
167
|
+
transition: height 0.5s ease-in-out;
|
|
168
|
+
`;
|
|
169
|
+
|
|
170
|
+
const CheckWrapper = styled.div`
|
|
171
|
+
margin-top: ${(p) => p.theme.spacing.xs};
|
|
172
|
+
label {
|
|
173
|
+
margin-bottom: 0;
|
|
174
|
+
color: ${(p) => p.theme.colors.textHighEmphasis};
|
|
175
|
+
}
|
|
176
|
+
`;
|
|
177
|
+
|
|
178
|
+
const ErrorWrapper = styled.div`
|
|
179
|
+
${(p) => p.theme.textStyle.uiXS};
|
|
180
|
+
color: ${(p) => p.theme.colors.error};
|
|
181
|
+
width: 100%;
|
|
182
|
+
padding-right: ${(p) => p.theme.spacing.s};
|
|
91
183
|
`;
|
|
92
184
|
|
|
93
185
|
export {
|
|
@@ -103,6 +195,16 @@ export {
|
|
|
103
195
|
SourceMenu,
|
|
104
196
|
SourceItem,
|
|
105
197
|
SelectWrapper,
|
|
106
|
-
|
|
107
|
-
|
|
198
|
+
AdvancedWrapper,
|
|
199
|
+
ConfigLabel,
|
|
200
|
+
ConfigWrapper,
|
|
201
|
+
ConfigContent,
|
|
202
|
+
SubConfigContent,
|
|
203
|
+
OptionLabel,
|
|
204
|
+
LabelContent,
|
|
205
|
+
OptionDescription,
|
|
206
|
+
OptionText,
|
|
207
|
+
SubOptionText,
|
|
208
|
+
CheckWrapper,
|
|
209
|
+
ErrorWrapper,
|
|
108
210
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { createContext, useState, useCallback, useContext, ReactElement } from "react";
|
|
2
2
|
import { moveElement } from "@ax/forms";
|
|
3
3
|
import { moveArrayElement } from "@ax/helpers";
|
|
4
|
-
import { IStructuredDataContent } from "@ax/types";
|
|
4
|
+
import { IDataSource, IStructuredDataContent } from "@ax/types";
|
|
5
5
|
|
|
6
|
-
const initState = {
|
|
6
|
+
const initState: IReferenceState = {
|
|
7
7
|
mode: "auto",
|
|
8
8
|
order: "recent",
|
|
9
9
|
orderDirection: "ASC",
|
|
@@ -53,8 +53,8 @@ const useReferenceProvider = (modes?: string[]) => {
|
|
|
53
53
|
const { selectedItems, fixed, fullRelations = false } = state;
|
|
54
54
|
const newItems = moveElement(item.id, selectedItems, newIndex, "id");
|
|
55
55
|
const originalItemId = item.relatedPage?.originalStructuredDataId;
|
|
56
|
-
const itemId = state.fixed.includes(originalItemId) ? originalItemId : item.id;
|
|
57
|
-
const newFixed = moveArrayElement(itemId, fixed, newIndex);
|
|
56
|
+
const itemId = originalItemId && state.fixed.includes(originalItemId) ? originalItemId : item.id;
|
|
57
|
+
const newFixed: number[] = moveArrayElement(itemId, fixed, newIndex);
|
|
58
58
|
const newState: IReferenceState = {
|
|
59
59
|
...state,
|
|
60
60
|
selectedItems: newItems,
|
|
@@ -77,17 +77,25 @@ export interface IReferenceState {
|
|
|
77
77
|
order: string;
|
|
78
78
|
orderDirection: string;
|
|
79
79
|
quantity: number;
|
|
80
|
-
items:
|
|
81
|
-
selectedItems:
|
|
82
|
-
fixed:
|
|
80
|
+
items: IStructuredDataContent[];
|
|
81
|
+
selectedItems: IStructuredDataContent[];
|
|
82
|
+
fixed: number[];
|
|
83
83
|
search: string;
|
|
84
84
|
showSelected: boolean;
|
|
85
|
-
source:
|
|
86
|
-
filter:
|
|
87
|
-
sourceTitles:
|
|
85
|
+
source: string[];
|
|
86
|
+
filter: IFilter[];
|
|
87
|
+
sourceTitles: IDataSource[];
|
|
88
88
|
fullRelations: boolean;
|
|
89
89
|
allLanguages: boolean;
|
|
90
90
|
preferenceLanguage: boolean;
|
|
91
|
+
lang?: number;
|
|
92
|
+
site?: number;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
interface IFilter {
|
|
96
|
+
id: number;
|
|
97
|
+
label: string;
|
|
98
|
+
source: string;
|
|
91
99
|
}
|
|
92
100
|
|
|
93
101
|
export { ReferenceProvider, useReference };
|
|
@@ -4,7 +4,7 @@ import { DraggableProvided } from "react-beautiful-dnd";
|
|
|
4
4
|
import { IDataSource, IStructuredDataContent } from "@ax/types";
|
|
5
5
|
import { getFormattedDateWithTimezone } from "@ax/helpers";
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { Icon } from "@ax/components";
|
|
8
8
|
|
|
9
9
|
import * as S from "./style";
|
|
10
10
|
|
|
@@ -15,34 +15,13 @@ const Item = (props: IProps) => {
|
|
|
15
15
|
handleDelete(item);
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
<S.ActionItem key={item.icon} onClick={item.action} data-testid="action-menu-item">
|
|
26
|
-
<Icon name={item.icon} />
|
|
27
|
-
<S.ActionText>{item.label}</S.ActionText>
|
|
28
|
-
</S.ActionItem>
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
const editMenu = {
|
|
32
|
-
options: [
|
|
33
|
-
{
|
|
34
|
-
label: "delete",
|
|
35
|
-
icon: "delete",
|
|
36
|
-
action: removeItem,
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const ActionMenu = () => (
|
|
42
|
-
<FloatingMenu Button={MoreInfoButton}>
|
|
43
|
-
<S.ActionMenu>{editMenu.options.map((item: any, i: number) => actionMenuItem(item))}</S.ActionMenu>
|
|
44
|
-
</FloatingMenu>
|
|
45
|
-
);
|
|
18
|
+
const menuOptions = [
|
|
19
|
+
{
|
|
20
|
+
label: "delete",
|
|
21
|
+
icon: "delete",
|
|
22
|
+
action: removeItem,
|
|
23
|
+
},
|
|
24
|
+
];
|
|
46
25
|
|
|
47
26
|
return (
|
|
48
27
|
<S.Item ref={innerRef} data-testid="reference-field-item" {...provided?.draggableProps}>
|
|
@@ -58,7 +37,7 @@ const Item = (props: IProps) => {
|
|
|
58
37
|
</S.Header>
|
|
59
38
|
<S.Title>{item.content.title}</S.Title>
|
|
60
39
|
</S.TextWrapper>
|
|
61
|
-
<
|
|
40
|
+
<S.StyledActionMenu icon="more" options={menuOptions} tooltip="Actions" />
|
|
62
41
|
</S.Item>
|
|
63
42
|
);
|
|
64
43
|
};
|