@griddo/ax 1.63.5 → 1.64.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/builder.ssr.js +6 -0
- package/config/griddo-config/cx-polyfills/componentsBundle.js +4 -0
- package/config/{griddo-config.js → griddo-config/index.js} +36 -15
- package/config/griddo-config/ssrHelpers.js +47 -0
- package/config/jest/componentsMock.js +29 -0
- package/config/jest/fileMock.js +1 -0
- package/config/jest/setup.js +5 -0
- package/config/jest/styleMock.js +1 -0
- package/config/jest/test-utils.js +17 -0
- package/config/paths.js +36 -5
- package/config/webpack.config.js +1 -1
- package/config/webpackDevServer.config.js +4 -1
- package/config/webpackSchemas.config.js +4 -1
- package/package.json +33 -59
- package/scripts/build.js +9 -2
- package/src/__mocks__/reducers/analyticsState.tsx +14 -0
- package/src/__mocks__/reducers/pageEditor.tsx +30 -0
- package/src/api/sites.tsx +28 -6
- package/src/api/structuredData.tsx +1 -1
- package/src/api/users.tsx +5 -4
- package/src/components/ActionMenu/style.tsx +2 -0
- package/src/components/Browser/index.tsx +9 -5
- package/src/{modules/Content/PageItem/atoms.tsx → components/CategoryCell/index.tsx} +4 -6
- package/src/components/CategoryCell/style.tsx +11 -0
- package/src/components/Fields/AnalyticsField/PageAnalytics/index.tsx +19 -19
- package/src/components/Fields/AnalyticsField/StructuredDataAnalytics/atoms.tsx +26 -16
- package/src/components/Fields/AnalyticsField/StructuredDataAnalytics/index.tsx +8 -13
- package/src/components/Fields/AnalyticsField/index.test.tsx +100 -0
- package/src/components/Fields/AnalyticsField/index.tsx +9 -2
- package/src/components/Fields/AnalyticsField/utils.tsx +2 -2
- package/src/components/Fields/ArrayFieldGroup/ArrayFieldItem/style.tsx +2 -1
- package/src/components/Fields/CheckField/index.test.tsx +95 -0
- package/src/components/Fields/CheckField/index.tsx +9 -3
- package/src/components/Fields/CheckField/style.tsx +32 -24
- package/src/components/Fields/CheckGroup/index.test.tsx +274 -0
- package/src/components/Fields/CheckGroup/index.tsx +2 -1
- package/src/components/Fields/FileField/FileDragAndDrop/style.tsx +3 -2
- package/src/components/Fields/FileField/style.tsx +2 -1
- package/src/components/Fields/MultiCheckSelect/style.tsx +18 -18
- package/src/components/Fields/NoteField/style.tsx +9 -9
- package/src/components/Fields/ReferenceField/AutoPanel/AutoItem/index.tsx +1 -1
- package/src/components/Fields/Select/style.tsx +41 -37
- package/src/components/Fields/TagField/index.test.tsx +136 -0
- package/src/components/Fields/TagField/index.tsx +8 -12
- package/src/components/Fields/TextArea/index.test.tsx +69 -0
- package/src/components/Fields/TextArea/index.tsx +4 -13
- package/src/components/Fields/TextArea/style.tsx +2 -2
- package/src/components/Fields/TextField/index.test.tsx +144 -0
- package/src/components/Fields/TextField/index.tsx +23 -19
- package/src/components/Fields/TextField/style.tsx +16 -7
- package/src/components/Fields/UniqueCheck/index.test.tsx +43 -0
- package/src/components/Fields/UrlField/utils.tsx +8 -6
- package/src/components/FieldsBehavior/index.tsx +0 -2
- package/src/components/FieldsBehavior/style.tsx +21 -21
- package/src/components/Gallery/GalleryFilters/Orientation/style.tsx +2 -1
- package/src/components/Gallery/GalleryFilters/SortBy/style.tsx +2 -1
- package/src/components/Icon/index.tsx +12 -10
- package/src/components/IconAction/index.tsx +7 -1
- package/src/components/IconAction/style.tsx +10 -10
- package/src/components/SearchField/index.tsx +11 -8
- package/src/components/SearchField/style.tsx +21 -12
- package/src/components/TableFilters/CategoryFilter/index.tsx +1 -1
- package/src/components/TableFilters/CategoryFilter/style.tsx +2 -1
- package/src/components/TableFilters/DateFilter/style.tsx +2 -1
- package/src/components/TableFilters/LiveFilter/index.tsx +2 -2
- package/src/components/TableFilters/LiveFilter/style.tsx +2 -1
- package/src/components/TableFilters/NameFilter/style.tsx +2 -1
- package/src/components/TableFilters/SiteFilter/index.tsx +38 -24
- package/src/components/TableFilters/SiteFilter/style.tsx +2 -1
- package/src/components/TableFilters/StatusFilter/style.tsx +2 -1
- package/src/components/TableFilters/TranslationsFilter/style.tsx +2 -1
- package/src/components/TableFilters/TypeFilter/style.tsx +2 -1
- package/src/components/Tag/index.tsx +9 -7
- package/src/components/Tag/style.tsx +20 -8
- package/src/components/index.tsx +4 -2
- package/src/containers/App/reducer.tsx +0 -2
- package/src/containers/PageEditor/actions.tsx +2 -2
- package/src/containers/Sites/actions.tsx +30 -19
- package/src/containers/Users/actions.tsx +10 -2
- package/src/containers/Users/reducer.tsx +3 -1
- package/src/helpers/fields.tsx +2 -4
- package/src/helpers/index.tsx +3 -0
- package/src/helpers/themes.tsx +9 -0
- package/src/modules/Analytics/GroupPanel/utils.tsx +3 -3
- package/src/modules/App/Routing/NavMenu/index.tsx +13 -12
- package/src/modules/Content/PageItem/index.tsx +31 -9
- package/src/modules/Content/PageItem/style.tsx +0 -7
- package/src/modules/Content/atoms.tsx +78 -0
- package/src/modules/Content/index.tsx +104 -33
- package/src/modules/Content/style.tsx +10 -7
- package/src/modules/GlobalEditor/PageBrowser/index.tsx +0 -4
- package/src/modules/GlobalEditor/index.tsx +3 -3
- package/src/modules/Navigation/Defaults/DefaultsEditor/Editor/DefaultsBrowser/index.tsx +0 -4
- package/src/modules/PageEditor/PageBrowser/index.tsx +0 -4
- package/src/modules/PageEditor/atoms.tsx +74 -0
- package/src/modules/PageEditor/index.tsx +30 -9
- package/src/modules/PageEditor/style.tsx +4 -0
- package/src/modules/PublicPreview/index.tsx +3 -5
- package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/TemplateBrowser/index.tsx +0 -4
- package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/index.tsx +2 -3
- package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/index.tsx +1 -1
- package/src/modules/Settings/Globals/index.tsx +3 -3
- package/src/modules/StructuredData/Form/index.tsx +2 -4
- package/src/modules/StructuredData/StructuredDataList/BulkHeader/TableHeader/index.tsx +22 -18
- package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/atoms.tsx +3 -24
- package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +2 -2
- package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/style.tsx +0 -7
- package/src/modules/StructuredData/StructuredDataList/OptionTable/index.tsx +2 -4
- package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/index.tsx +46 -14
- package/src/modules/StructuredData/StructuredDataList/hooks.tsx +21 -9
- package/src/modules/StructuredData/StructuredDataList/index.tsx +48 -20
- package/src/modules/Users/Profile/index.tsx +12 -7
- package/src/modules/Users/UserCreate/SiteItem/index.tsx +44 -0
- package/src/modules/Users/UserCreate/SiteItem/style.tsx +30 -0
- package/src/modules/Users/UserCreate/index.tsx +120 -10
- package/src/modules/Users/UserCreate/style.tsx +54 -1
- package/src/modules/Users/UserEdit/index.tsx +53 -15
- package/src/modules/Users/UserForm/index.tsx +152 -5
- package/src/modules/Users/UserForm/style.tsx +40 -2
- package/src/modules/Users/UserList/BulkHeader/TableHeader/index.tsx +40 -2
- package/src/modules/Users/UserList/BulkHeader/TableHeader/style.tsx +0 -1
- package/src/modules/Users/UserList/BulkHeader/index.tsx +10 -1
- package/src/modules/Users/UserList/UserItem/index.tsx +70 -15
- package/src/modules/Users/UserList/hooks.tsx +58 -1
- package/src/modules/Users/UserList/index.tsx +80 -34
- package/src/modules/Users/index.tsx +18 -11
- package/src/routes/site.tsx +8 -0
- package/src/types/index.tsx +7 -0
- package/tsconfig.json +2 -0
- package/scripts/test.js +0 -45
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { IModal } from "@ax/types";
|
|
4
|
+
import { Modal, FieldsBehavior } from "@ax/components";
|
|
5
|
+
|
|
6
|
+
import * as S from "./style";
|
|
7
|
+
|
|
8
|
+
const DeleteModal = (props: IDeleteModal): JSX.Element => {
|
|
9
|
+
const {
|
|
10
|
+
isOpen,
|
|
11
|
+
toggleModal,
|
|
12
|
+
mainModalAction,
|
|
13
|
+
secondaryModalAction,
|
|
14
|
+
isTranslated,
|
|
15
|
+
deleteAllVersions,
|
|
16
|
+
setDeleteAllVersions,
|
|
17
|
+
title,
|
|
18
|
+
} = props;
|
|
19
|
+
|
|
20
|
+
const options = [
|
|
21
|
+
{
|
|
22
|
+
title: "Delete only this version",
|
|
23
|
+
name: "deletePage",
|
|
24
|
+
value: false,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
title: "Delete all languages versions",
|
|
28
|
+
name: "deleteAll",
|
|
29
|
+
value: true,
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
const pageTitle = title ? <strong>{title}</strong> : "this";
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Modal
|
|
37
|
+
isOpen={isOpen}
|
|
38
|
+
hide={toggleModal}
|
|
39
|
+
title="Delete Page?"
|
|
40
|
+
secondaryAction={secondaryModalAction}
|
|
41
|
+
mainAction={mainModalAction}
|
|
42
|
+
size="S"
|
|
43
|
+
>
|
|
44
|
+
{isTranslated ? (
|
|
45
|
+
<>
|
|
46
|
+
<S.ModalContent>
|
|
47
|
+
<p>
|
|
48
|
+
You are going to delete {pageTitle} page that have some translations associated. Choose if you want to
|
|
49
|
+
delete all languages versions or only this one.
|
|
50
|
+
</p>
|
|
51
|
+
<FieldsBehavior
|
|
52
|
+
name="removeAllVersions"
|
|
53
|
+
fieldType="RadioGroup"
|
|
54
|
+
value={deleteAllVersions}
|
|
55
|
+
options={options}
|
|
56
|
+
onChange={setDeleteAllVersions}
|
|
57
|
+
/>
|
|
58
|
+
</S.ModalContent>
|
|
59
|
+
</>
|
|
60
|
+
) : (
|
|
61
|
+
<S.ModalContent>
|
|
62
|
+
Are you sure you want to delete {pageTitle} page?
|
|
63
|
+
<br />
|
|
64
|
+
This action <strong>cannot be undone</strong>.
|
|
65
|
+
</S.ModalContent>
|
|
66
|
+
)}
|
|
67
|
+
</Modal>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
interface IDeleteModal extends IModal {
|
|
72
|
+
isTranslated: boolean;
|
|
73
|
+
deleteAllVersions: boolean;
|
|
74
|
+
setDeleteAllVersions: React.Dispatch<React.SetStateAction<boolean>>;
|
|
75
|
+
title?: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export { DeleteModal };
|
|
@@ -39,6 +39,7 @@ import PageItem from "./PageItem";
|
|
|
39
39
|
import StructuredDataItem from "./../StructuredData/StructuredDataList/StructuredDataItem";
|
|
40
40
|
import BulkHeader from "./BulkHeader";
|
|
41
41
|
import PageImporter from "./PageImporter";
|
|
42
|
+
import { DeleteModal } from "./atoms";
|
|
42
43
|
|
|
43
44
|
import * as S from "./style";
|
|
44
45
|
|
|
@@ -81,15 +82,18 @@ const Content = (props: IProps): JSX.Element => {
|
|
|
81
82
|
resetPageEditor,
|
|
82
83
|
removePageFromSite,
|
|
83
84
|
importPageFromGlobal,
|
|
85
|
+
restorePage,
|
|
84
86
|
getDataPack,
|
|
85
87
|
dataPacks,
|
|
86
88
|
} = props;
|
|
87
89
|
|
|
88
|
-
|
|
90
|
+
const itemsPerPage = 50;
|
|
91
|
+
const firstPage = 1;
|
|
89
92
|
|
|
90
93
|
const tableRef = useRef<HTMLDivElement>(null);
|
|
91
94
|
const { isOpen: isNewOpen, toggleModal: toggleNewModal } = useModal();
|
|
92
95
|
const { isOpen: isImporterOpen, toggleModal: toggleImporterModal } = useModal();
|
|
96
|
+
const { isOpen: isDeleteOpen, toggleModal: toggleDeleteModal } = useModal();
|
|
93
97
|
const { sortedListStatus, setSortedListStatus } = useSortedListStatus();
|
|
94
98
|
const { setFiltersSelection, setFilterQuery, resetFilterQuery, filterValues } = useFilterQuery();
|
|
95
99
|
const { state: locationState } = useLocation<{ isFromEditor: boolean }>();
|
|
@@ -123,23 +127,9 @@ const Content = (props: IProps): JSX.Element => {
|
|
|
123
127
|
}, {});
|
|
124
128
|
|
|
125
129
|
const filterColumns = { ...extraColumns, ...defaultColumns };
|
|
126
|
-
|
|
127
130
|
const initialColumns = isGlobalPages ? filterColumns : defaultColumns;
|
|
128
|
-
|
|
129
131
|
const [columnsState, setColumnsState] = useState(initialColumns);
|
|
130
132
|
|
|
131
|
-
const {
|
|
132
|
-
resetBulkSelection,
|
|
133
|
-
selectedItems,
|
|
134
|
-
isSelected,
|
|
135
|
-
areItemsSelected,
|
|
136
|
-
checkState,
|
|
137
|
-
addToBulkSelection,
|
|
138
|
-
selectAllItems,
|
|
139
|
-
} = useBulkSelection(contentIds);
|
|
140
|
-
|
|
141
|
-
const itemsPerPage = 50;
|
|
142
|
-
const firstPage = 1;
|
|
143
133
|
const [page, setPage] = useState(firstPage);
|
|
144
134
|
const lastPage = Math.ceil(totalItems / itemsPerPage);
|
|
145
135
|
const isLastItem = page === lastPage && currentSitePages.length === 1;
|
|
@@ -147,19 +137,35 @@ const Content = (props: IProps): JSX.Element => {
|
|
|
147
137
|
const [isScrolling, setIsScrolling] = useState(false);
|
|
148
138
|
const [currentFilterQuery, setCurrentFilterQuery] = useState("");
|
|
149
139
|
const [deletedItem, setDeletedItem] = useState<number | number[] | null>(null);
|
|
150
|
-
const { isVisible, toggleToast, setIsVisible } = useToast();
|
|
151
140
|
const [searchQuery, setSearchQuery] = useState<string>("");
|
|
152
141
|
const [pagesToImport, setPagesToImport] = useState([]);
|
|
153
|
-
|
|
154
142
|
const [isEmpty, setIsEmpty] = useState(false);
|
|
155
143
|
const [emptyStateProps, setEmptyStateProps] = useState<IEmptyStateProps>({});
|
|
156
|
-
|
|
157
144
|
const [removedPage, setRemovedPage] = useState<number | number[] | null>(null);
|
|
145
|
+
const [deleteAllVersions, setDeleteAllVersions] = useState(false);
|
|
146
|
+
const [arePagesTranslated, setArePagesTranslated] = useState(false);
|
|
147
|
+
|
|
148
|
+
const {
|
|
149
|
+
resetBulkSelection,
|
|
150
|
+
selectedItems,
|
|
151
|
+
isSelected,
|
|
152
|
+
areItemsSelected,
|
|
153
|
+
checkState,
|
|
154
|
+
addToBulkSelection,
|
|
155
|
+
selectAllItems,
|
|
156
|
+
} = useBulkSelection(contentIds);
|
|
157
|
+
|
|
158
|
+
const { isVisible, toggleToast, setIsVisible } = useToast();
|
|
158
159
|
const {
|
|
159
160
|
isVisible: isVisibleRemovedToast,
|
|
160
161
|
toggleToast: toggleRemovedToast,
|
|
161
162
|
setIsVisible: setIsVisibleRemovedToast,
|
|
162
163
|
} = useToast();
|
|
164
|
+
const {
|
|
165
|
+
isVisible: isVisibleDeletedToast,
|
|
166
|
+
toggleToast: toggleDeletedToast,
|
|
167
|
+
setIsVisible: setIsVisibleDeletedToast,
|
|
168
|
+
} = useToast();
|
|
163
169
|
|
|
164
170
|
const { categoryColors, addCategoryColors } = useCategoryColors();
|
|
165
171
|
|
|
@@ -189,16 +195,6 @@ const Content = (props: IProps): JSX.Element => {
|
|
|
189
195
|
return params;
|
|
190
196
|
}, [filter, currentSiteInfo, isStructuredData, page, searchQuery]);
|
|
191
197
|
|
|
192
|
-
const bulkFilter = (bulkSelection: number[]) => filterByStatus(bulkSelection, currentSitePages);
|
|
193
|
-
|
|
194
|
-
const handleAddToBulk = (item: ICheck) => addToBulkSelection(item, bulkFilter);
|
|
195
|
-
|
|
196
|
-
const handleSelectAll = () => selectAllItems(bulkFilter);
|
|
197
|
-
|
|
198
|
-
const unselectAllItems = () => resetBulkSelection();
|
|
199
|
-
|
|
200
|
-
const selectItems = () => (checkState.isAllSelected ? unselectAllItems() : handleSelectAll());
|
|
201
|
-
|
|
202
198
|
const getPages = (params: any, filterQuery?: any) => {
|
|
203
199
|
const isStructuredDataPage = filter !== "unique-pages";
|
|
204
200
|
const pageFilter = isStructuredDataPage ? filter : undefined;
|
|
@@ -263,6 +259,16 @@ const Content = (props: IProps): JSX.Element => {
|
|
|
263
259
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
264
260
|
}, [isLoading, currentSitePages]);
|
|
265
261
|
|
|
262
|
+
const bulkFilter = (bulkSelection: number[]) => filterByStatus(bulkSelection, currentSitePages);
|
|
263
|
+
|
|
264
|
+
const handleAddToBulk = (item: ICheck) => addToBulkSelection(item, bulkFilter);
|
|
265
|
+
|
|
266
|
+
const handleSelectAll = () => selectAllItems(bulkFilter);
|
|
267
|
+
|
|
268
|
+
const unselectAllItems = () => resetBulkSelection();
|
|
269
|
+
|
|
270
|
+
const selectItems = () => (checkState.isAllSelected ? unselectAllItems() : handleSelectAll());
|
|
271
|
+
|
|
266
272
|
const addNewData = () => {
|
|
267
273
|
resetForm();
|
|
268
274
|
const path = `/sites/data/${currentStructuredData.id}/editor`;
|
|
@@ -296,11 +302,17 @@ const Content = (props: IProps): JSX.Element => {
|
|
|
296
302
|
.filter((page: IPage) => pageIds.includes(page.id) && page.origin !== "GLOBAL")
|
|
297
303
|
.map((page: IPage) => page.id);
|
|
298
304
|
|
|
305
|
+
let deleted = false;
|
|
299
306
|
if (filteredPageIds.length > 0) {
|
|
300
|
-
await deleteBulk(filteredPageIds);
|
|
307
|
+
deleted = await deleteBulk(filteredPageIds);
|
|
301
308
|
}
|
|
302
309
|
if (globalPageIds.length > 0) {
|
|
303
|
-
await removePageFromSite(globalPageIds, false);
|
|
310
|
+
deleted = await removePageFromSite(globalPageIds, false);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
if (deleted) {
|
|
314
|
+
setDeletedItem(pageIds);
|
|
315
|
+
toggleDeletedToast();
|
|
304
316
|
}
|
|
305
317
|
};
|
|
306
318
|
|
|
@@ -313,12 +325,20 @@ const Content = (props: IProps): JSX.Element => {
|
|
|
313
325
|
}
|
|
314
326
|
})
|
|
315
327
|
: await handleBulkDelete(selectedItems.all);
|
|
328
|
+
toggleDeleteModal();
|
|
316
329
|
const allPageItemsSelected = selectedItems.all.length >= currentSitePages.length;
|
|
317
330
|
const previousPage = page - 1;
|
|
318
331
|
page > 1 && (isLastItem || allPageItemsSelected) ? setPage(previousPage) : getSiteContent();
|
|
319
332
|
unselectAllItems();
|
|
320
333
|
};
|
|
321
334
|
|
|
335
|
+
const handleToggleDeleteModal = () => {
|
|
336
|
+
const selectedPages = currentSitePages.filter((page) => selectedItems.all.includes(page.id));
|
|
337
|
+
const hasTranslations = selectedPages.some((page) => page.pageLanguages.length > 1);
|
|
338
|
+
setArePagesTranslated(hasTranslations);
|
|
339
|
+
toggleDeleteModal();
|
|
340
|
+
};
|
|
341
|
+
|
|
322
342
|
const bulkPublishAction = async (isPublish: boolean) => {
|
|
323
343
|
const { notPublished, published } = selectedItems;
|
|
324
344
|
|
|
@@ -362,7 +382,7 @@ const Content = (props: IProps): JSX.Element => {
|
|
|
362
382
|
const Header = (
|
|
363
383
|
<BulkHeader
|
|
364
384
|
showBulk={areItemsSelected(contentIds)}
|
|
365
|
-
bulkDelete={
|
|
385
|
+
bulkDelete={handleToggleDeleteModal}
|
|
366
386
|
bulkPublish={bulkPublish}
|
|
367
387
|
bulkUnpublish={bulkUnpublish}
|
|
368
388
|
selectAllItems={handleSelectAll}
|
|
@@ -427,6 +447,10 @@ const Content = (props: IProps): JSX.Element => {
|
|
|
427
447
|
setDeletedItem={setDeletedItem}
|
|
428
448
|
isEditable={isDataEditable}
|
|
429
449
|
activatedDataPacks={activatedDataPacks}
|
|
450
|
+
categoryColumns={categoryColumns}
|
|
451
|
+
columns={columnsState}
|
|
452
|
+
categoryColors={categoryColors}
|
|
453
|
+
addCategoryColors={addCategoryColors}
|
|
430
454
|
/>
|
|
431
455
|
);
|
|
432
456
|
});
|
|
@@ -458,7 +482,22 @@ const Content = (props: IProps): JSX.Element => {
|
|
|
458
482
|
};
|
|
459
483
|
const previousPage = page - 1 || 1;
|
|
460
484
|
|
|
461
|
-
await deletePage(deletePageParams);
|
|
485
|
+
const deleted = await deletePage(deletePageParams);
|
|
486
|
+
if (deleted) {
|
|
487
|
+
setDeletedItem(item.page.id);
|
|
488
|
+
toggleDeletedToast();
|
|
489
|
+
}
|
|
490
|
+
isLastItem && previousPage !== 1 ? setPage(previousPage) : getSiteContent();
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
const deleteCurrentPageBulk = async (ids: number[]) => {
|
|
494
|
+
const previousPage = page - 1 || 1;
|
|
495
|
+
|
|
496
|
+
const deleted = await deleteBulk(ids);
|
|
497
|
+
if (deleted) {
|
|
498
|
+
setDeletedItem(ids);
|
|
499
|
+
toggleDeletedToast();
|
|
500
|
+
}
|
|
462
501
|
isLastItem && previousPage !== 1 ? setPage(previousPage) : getSiteContent();
|
|
463
502
|
};
|
|
464
503
|
|
|
@@ -473,6 +512,7 @@ const Content = (props: IProps): JSX.Element => {
|
|
|
473
512
|
duplicatePage,
|
|
474
513
|
removePageFromSite,
|
|
475
514
|
languageActions: pageLanguageActions,
|
|
515
|
+
deleteBulk: deleteCurrentPageBulk,
|
|
476
516
|
getDataPack: getDataPack,
|
|
477
517
|
};
|
|
478
518
|
|
|
@@ -570,6 +610,27 @@ const Content = (props: IProps): JSX.Element => {
|
|
|
570
610
|
setCurrentFilterQuery("");
|
|
571
611
|
};
|
|
572
612
|
|
|
613
|
+
const mainDeleteModalAction = {
|
|
614
|
+
title: "Delete pages",
|
|
615
|
+
onClick: bulkDelete,
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
const secondaryDeleteModalAction = { title: "Cancel", onClick: toggleDeleteModal };
|
|
619
|
+
|
|
620
|
+
const undoDeleteAction = async () => {
|
|
621
|
+
if (deletedItem) {
|
|
622
|
+
await restorePage(deletedItem);
|
|
623
|
+
getSiteContent();
|
|
624
|
+
}
|
|
625
|
+
setIsVisible(false);
|
|
626
|
+
};
|
|
627
|
+
|
|
628
|
+
const deletedToastProps = {
|
|
629
|
+
action: () => undoDeleteAction(),
|
|
630
|
+
setIsVisible: setIsVisibleDeletedToast,
|
|
631
|
+
message: "Page deleted.",
|
|
632
|
+
};
|
|
633
|
+
|
|
573
634
|
return (
|
|
574
635
|
<MainWrapper
|
|
575
636
|
title={title}
|
|
@@ -620,8 +681,16 @@ const Content = (props: IProps): JSX.Element => {
|
|
|
620
681
|
>
|
|
621
682
|
<PageImporter structuredData={selectedOptionType} {...{ setPagesToImport }} />
|
|
622
683
|
</Modal>
|
|
684
|
+
<DeleteModal
|
|
685
|
+
isOpen={isDeleteOpen}
|
|
686
|
+
toggleModal={toggleDeleteModal}
|
|
687
|
+
mainModalAction={mainDeleteModalAction}
|
|
688
|
+
secondaryModalAction={secondaryDeleteModalAction}
|
|
689
|
+
{...{ isTranslated: arePagesTranslated, deleteAllVersions, setDeleteAllVersions }}
|
|
690
|
+
/>
|
|
623
691
|
{isVisible && <Toast {...toastProps} />}
|
|
624
692
|
{isVisibleRemovedToast && <Toast {...removedToastProps} />}
|
|
693
|
+
{isVisibleDeletedToast && <Toast {...deletedToastProps} />}
|
|
625
694
|
</MainWrapper>
|
|
626
695
|
);
|
|
627
696
|
};
|
|
@@ -654,7 +723,7 @@ interface IDispatchProps {
|
|
|
654
723
|
addTemplate(template: string): void;
|
|
655
724
|
getSitePages(params: IGetSitePagesParams, structuredData?: string | undefined, filterQuery?: string): Promise<void>;
|
|
656
725
|
updatePageStatus(ids: number[], status: string, updatePageStatus?: boolean): Promise<boolean>;
|
|
657
|
-
deletePage(params?: ISavePageParams):
|
|
726
|
+
deletePage(params?: ISavePageParams): Promise<boolean>;
|
|
658
727
|
setHistoryPush(page: string, isEditor: boolean): any;
|
|
659
728
|
setLanguage(lang: { locale: string; id: number | null }): void;
|
|
660
729
|
createNewTranslation(isNewTranslation: boolean): void;
|
|
@@ -670,6 +739,7 @@ interface IDispatchProps {
|
|
|
670
739
|
resetPageEditor(): Promise<void>;
|
|
671
740
|
removePageFromSite(pageID: number | number[], refresh?: boolean): Promise<boolean>;
|
|
672
741
|
importPageFromGlobal(pageID: number | number[]): Promise<boolean>;
|
|
742
|
+
restorePage(id: number | number[]): Promise<boolean>;
|
|
673
743
|
getDataPack: (id: string) => Promise<void>;
|
|
674
744
|
}
|
|
675
745
|
|
|
@@ -697,6 +767,7 @@ const mapDispatchToProps = {
|
|
|
697
767
|
resetPageEditor: pageEditorActions.resetPageEditor,
|
|
698
768
|
removePageFromSite: sitesActions.removePageFromSite,
|
|
699
769
|
importPageFromGlobal: sitesActions.importPageFromGlobal,
|
|
770
|
+
restorePage: pageEditorActions.restorePage,
|
|
700
771
|
getDataPack: dataPacksActions.getSiteDataPack,
|
|
701
772
|
};
|
|
702
773
|
|
|
@@ -22,14 +22,17 @@ const PaginationWrapper = styled.span`
|
|
|
22
22
|
`;
|
|
23
23
|
|
|
24
24
|
const EmptyWrapper = styled.div`
|
|
25
|
-
height: ${p =>
|
|
25
|
+
height: ${(p) => `calc(100vh - (${p.theme.spacing.xl} * 3))`};
|
|
26
26
|
display: flex;
|
|
27
27
|
align-items: center;
|
|
28
28
|
`;
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
30
|
+
const ModalContent = styled.div`
|
|
31
|
+
padding: ${(p) => p.theme.spacing.m};
|
|
32
|
+
|
|
33
|
+
p {
|
|
34
|
+
margin-bottom: ${(p) => p.theme.spacing.m};
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
export { ContentListWrapper, TableWrapper, PaginationWrapper, EmptyWrapper, ModalContent };
|
|
@@ -9,7 +9,6 @@ const PageBrowser = (props: IProps) => {
|
|
|
9
9
|
const {
|
|
10
10
|
socials,
|
|
11
11
|
cloudinaryName,
|
|
12
|
-
damDomain,
|
|
13
12
|
content: {
|
|
14
13
|
editorContent: { path, slug, canonicalSite },
|
|
15
14
|
},
|
|
@@ -35,7 +34,6 @@ const PageBrowser = (props: IProps) => {
|
|
|
35
34
|
url={url}
|
|
36
35
|
theme={theme}
|
|
37
36
|
cloudinaryName={cloudinaryName}
|
|
38
|
-
damDomain={damDomain}
|
|
39
37
|
siteLangs={globalLangs}
|
|
40
38
|
disabled={isReadOnly}
|
|
41
39
|
siteID={canonicalSite}
|
|
@@ -50,7 +48,6 @@ interface IEditorStateProps {
|
|
|
50
48
|
selectedEditorID: number;
|
|
51
49
|
socials: ISocialState;
|
|
52
50
|
cloudinaryName: string | null;
|
|
53
|
-
damDomain: string | null;
|
|
54
51
|
globalLangs: ILanguage[];
|
|
55
52
|
schema: ISchema | Record<string, unknown>;
|
|
56
53
|
breadcrumb: IBreadcrumbItem[];
|
|
@@ -72,7 +69,6 @@ const mapStateToProps = (state: IRootState): IEditorStateProps => ({
|
|
|
72
69
|
selectedEditorID: state.pageEditor.selectedEditorID as number,
|
|
73
70
|
socials: state.social,
|
|
74
71
|
cloudinaryName: state.app.globalSettings.cloudinaryName,
|
|
75
|
-
damDomain: state.app.globalSettings.damDomain,
|
|
76
72
|
globalLangs: state.app.globalLangs,
|
|
77
73
|
schema: state.pageEditor.schema,
|
|
78
74
|
breadcrumb: state.pageEditor.breadcrumb,
|
|
@@ -2,7 +2,6 @@ import React, { useEffect, useState } from "react";
|
|
|
2
2
|
import { connect } from "react-redux";
|
|
3
3
|
import { RouteComponentProps } from "react-router-dom";
|
|
4
4
|
|
|
5
|
-
import { themes } from "components";
|
|
6
5
|
import { IErrorItem, IRootState, ISavePageParams, IUserEditing } from "@ax/types";
|
|
7
6
|
import { MainWrapper, Loading, ErrorToast, Notification, Modal } from "@ax/components";
|
|
8
7
|
import { pageEditorActions } from "@ax/containers/PageEditor";
|
|
@@ -12,6 +11,8 @@ import { sitesActions } from "@ax/containers/Sites";
|
|
|
12
11
|
import { pageStatus } from "@ax/containers/PageEditor/interfaces";
|
|
13
12
|
import { RouteLeavingGuard } from "@ax/guards";
|
|
14
13
|
import { useIsDirty, useModal } from "@ax/hooks";
|
|
14
|
+
import { getDefaultTheme } from "@ax/helpers";
|
|
15
|
+
|
|
15
16
|
import Editor from "./Editor";
|
|
16
17
|
import Preview from "./Preview";
|
|
17
18
|
|
|
@@ -55,8 +56,7 @@ const GlobalEditor = (props: IProps) => {
|
|
|
55
56
|
const isLivePageChanged = editorContent.editorContent && editorContent.editorContent.liveChanged;
|
|
56
57
|
const structuredData = editorContent.editorContent ? editorContent.editorContent.structuredData : "";
|
|
57
58
|
|
|
58
|
-
const
|
|
59
|
-
const theme = defaultTheme ? defaultTheme.value : themes[0].value;
|
|
59
|
+
const theme = getDefaultTheme();
|
|
60
60
|
|
|
61
61
|
useEffect(() => {
|
|
62
62
|
const { pageID, getPage, setTab, setCurrentSiteInfo, sendPagePing, setStructuredDataFilter } = props;
|
|
@@ -9,7 +9,6 @@ const DefaultsBrowser = (props: IProps) => {
|
|
|
9
9
|
const {
|
|
10
10
|
socials,
|
|
11
11
|
cloudinaryName,
|
|
12
|
-
damDomain,
|
|
13
12
|
content,
|
|
14
13
|
selectedEditorID,
|
|
15
14
|
setSelectedContent,
|
|
@@ -29,7 +28,6 @@ const DefaultsBrowser = (props: IProps) => {
|
|
|
29
28
|
url={content.slug}
|
|
30
29
|
theme={theme}
|
|
31
30
|
cloudinaryName={cloudinaryName}
|
|
32
|
-
damDomain={damDomain}
|
|
33
31
|
siteLangs={siteLangs}
|
|
34
32
|
siteID={siteID}
|
|
35
33
|
/>
|
|
@@ -43,7 +41,6 @@ interface IEditorStateProps {
|
|
|
43
41
|
currentSiteInfo: any;
|
|
44
42
|
socials: ISocialState;
|
|
45
43
|
cloudinaryName: string | null;
|
|
46
|
-
damDomain: string | null;
|
|
47
44
|
siteLangs: ILanguage[];
|
|
48
45
|
}
|
|
49
46
|
|
|
@@ -59,7 +56,6 @@ const mapStateToProps = (state: IRootState): IEditorStateProps => ({
|
|
|
59
56
|
currentSiteInfo: state.sites.currentSiteInfo,
|
|
60
57
|
socials: state.social,
|
|
61
58
|
cloudinaryName: state.app.globalSettings.cloudinaryName,
|
|
62
|
-
damDomain: state.app.globalSettings.damDomain,
|
|
63
59
|
siteLangs: state.sites.currentSiteLanguages,
|
|
64
60
|
});
|
|
65
61
|
|
|
@@ -9,7 +9,6 @@ const PageBrowser = (props: IProps) => {
|
|
|
9
9
|
const {
|
|
10
10
|
socials,
|
|
11
11
|
cloudinaryName,
|
|
12
|
-
damDomain,
|
|
13
12
|
content: {
|
|
14
13
|
editorContent: { path, slug },
|
|
15
14
|
header,
|
|
@@ -41,7 +40,6 @@ const PageBrowser = (props: IProps) => {
|
|
|
41
40
|
url={url}
|
|
42
41
|
theme={theme}
|
|
43
42
|
cloudinaryName={cloudinaryName}
|
|
44
|
-
damDomain={damDomain}
|
|
45
43
|
siteLangs={siteLangs}
|
|
46
44
|
disabled={disabled}
|
|
47
45
|
siteID={siteID}
|
|
@@ -57,7 +55,6 @@ interface IEditorStateProps {
|
|
|
57
55
|
currentSiteInfo: any;
|
|
58
56
|
socials: ISocialState;
|
|
59
57
|
cloudinaryName: string | null;
|
|
60
|
-
damDomain: string | null;
|
|
61
58
|
siteLangs: ILanguage[];
|
|
62
59
|
schema: ISchema | Record<string, unknown>;
|
|
63
60
|
breadcrumb: IBreadcrumbItem[];
|
|
@@ -80,7 +77,6 @@ const mapStateToProps = (state: IRootState): IEditorStateProps => ({
|
|
|
80
77
|
currentSiteInfo: state.sites.currentSiteInfo,
|
|
81
78
|
socials: state.social,
|
|
82
79
|
cloudinaryName: state.app.globalSettings.cloudinaryName,
|
|
83
|
-
damDomain: state.app.globalSettings.damDomain,
|
|
84
80
|
siteLangs: state.sites.currentSiteLanguages,
|
|
85
81
|
schema: state.pageEditor.schema,
|
|
86
82
|
breadcrumb: state.pageEditor.breadcrumb,
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { IModal } from "@ax/types";
|
|
4
|
+
import { Modal, FieldsBehavior } from "@ax/components";
|
|
5
|
+
|
|
6
|
+
import * as S from "./style";
|
|
7
|
+
|
|
8
|
+
const DeleteModal = (props: IDeleteModal): JSX.Element => {
|
|
9
|
+
const {
|
|
10
|
+
isOpen,
|
|
11
|
+
toggleModal,
|
|
12
|
+
mainModalAction,
|
|
13
|
+
secondaryModalAction,
|
|
14
|
+
isTranslated,
|
|
15
|
+
deleteAllVersions,
|
|
16
|
+
setDeleteAllVersions,
|
|
17
|
+
} = props;
|
|
18
|
+
|
|
19
|
+
const options = [
|
|
20
|
+
{
|
|
21
|
+
title: "Delete only this version",
|
|
22
|
+
name: "deletePage",
|
|
23
|
+
value: false,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
title: "Delete all languages versions",
|
|
27
|
+
name: "deleteAll",
|
|
28
|
+
value: true,
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<Modal
|
|
34
|
+
isOpen={isOpen}
|
|
35
|
+
hide={toggleModal}
|
|
36
|
+
title="Delete Page?"
|
|
37
|
+
secondaryAction={secondaryModalAction}
|
|
38
|
+
mainAction={mainModalAction}
|
|
39
|
+
size="S"
|
|
40
|
+
>
|
|
41
|
+
{isTranslated ? (
|
|
42
|
+
<>
|
|
43
|
+
<S.ModalContent>
|
|
44
|
+
<p>
|
|
45
|
+
You are going to delete this page that have some translations associated. Choose if you want to delete all
|
|
46
|
+
languages versions or only this one.
|
|
47
|
+
</p>
|
|
48
|
+
<FieldsBehavior
|
|
49
|
+
name="removeAllVersions"
|
|
50
|
+
fieldType="RadioGroup"
|
|
51
|
+
value={deleteAllVersions}
|
|
52
|
+
options={options}
|
|
53
|
+
onChange={setDeleteAllVersions}
|
|
54
|
+
/>
|
|
55
|
+
</S.ModalContent>
|
|
56
|
+
</>
|
|
57
|
+
) : (
|
|
58
|
+
<S.ModalContent>
|
|
59
|
+
Are you sure you want to delete this page?
|
|
60
|
+
<br />
|
|
61
|
+
This action <strong>cannot be undone</strong>.
|
|
62
|
+
</S.ModalContent>
|
|
63
|
+
)}
|
|
64
|
+
</Modal>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
interface IDeleteModal extends IModal {
|
|
69
|
+
isTranslated: boolean;
|
|
70
|
+
deleteAllVersions: boolean;
|
|
71
|
+
setDeleteAllVersions: React.Dispatch<React.SetStateAction<boolean>>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { DeleteModal };
|