@griddo/ax 11.13.2 → 11.13.3-rc.1

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.
Files changed (59) hide show
  1. package/config/jest/setup.js +10 -0
  2. package/package.json +2 -2
  3. package/src/GlobalStore.tsx +1 -1
  4. package/src/__tests__/components/Fields/AsyncCheckGroup/AsyncCheckGroup.test.tsx +276 -66
  5. package/src/__tests__/components/FloatingMenu/FloatingMenu.test.tsx +300 -99
  6. package/src/__tests__/modules/Settings/Social/Social.test.tsx +12 -4
  7. package/src/api/checkgroups.tsx +4 -3
  8. package/src/api/selects.tsx +12 -5
  9. package/src/components/ActionMenu/index.tsx +1 -3
  10. package/src/components/Browser/index.tsx +12 -3
  11. package/src/components/Browser/style.tsx +7 -0
  12. package/src/components/ConfigPanel/Form/index.tsx +47 -53
  13. package/src/components/Fields/AnalyticsField/PageAnalytics/atoms.tsx +9 -13
  14. package/src/components/Fields/AnalyticsField/PageAnalytics/index.tsx +37 -29
  15. package/src/components/Fields/AnalyticsField/StructuredDataAnalytics/atoms.tsx +9 -13
  16. package/src/components/Fields/AnalyticsField/StructuredDataAnalytics/index.tsx +17 -11
  17. package/src/components/Fields/AnalyticsField/index.tsx +1 -2
  18. package/src/components/Fields/AnalyticsField/utils.tsx +4 -4
  19. package/src/components/Fields/AsyncCheckGroup/index.tsx +97 -79
  20. package/src/components/Fields/AsyncSelect/index.tsx +33 -22
  21. package/src/components/Fields/DateField/DatePickerInput/index.tsx +2 -2
  22. package/src/components/Fields/DateField/index.tsx +3 -3
  23. package/src/components/Fields/IntegrationsField/SideModal/index.tsx +2 -2
  24. package/src/components/Fields/IntegrationsField/index.tsx +14 -10
  25. package/src/components/Fields/MultiCheckSelect/index.tsx +6 -6
  26. package/src/components/Fields/MultiCheckSelectGroup/index.tsx +39 -37
  27. package/src/components/Fields/MultiCheckSelectGroup/style.tsx +1 -1
  28. package/src/components/Fields/ReferenceField/ManualPanel/index.tsx +0 -2
  29. package/src/components/Fields/RichText/index.tsx +15 -7
  30. package/src/components/Fields/TextArea/index.tsx +9 -6
  31. package/src/components/FloatingMenu/index.tsx +32 -31
  32. package/src/components/FloatingMenu/style.tsx +23 -5
  33. package/src/components/Loader/components/SmallCircle.js +3 -3
  34. package/src/components/MainWrapper/AppBar/style.tsx +1 -0
  35. package/src/components/SideModal/index.tsx +1 -1
  36. package/src/components/TableFilters/CategoryFilter/index.tsx +14 -15
  37. package/src/containers/App/actions.tsx +7 -1
  38. package/src/containers/App/constants.tsx +2 -0
  39. package/src/containers/App/interfaces.tsx +5 -0
  40. package/src/containers/App/reducer.tsx +11 -2
  41. package/src/containers/Forms/actions.tsx +5 -7
  42. package/src/containers/Integrations/actions.tsx +1 -3
  43. package/src/containers/Navigation/Menu/actions.tsx +2 -2
  44. package/src/containers/PageEditor/actions.tsx +3 -2
  45. package/src/containers/Settings/DataPacks/actions.tsx +35 -29
  46. package/src/containers/Sites/actions.tsx +40 -33
  47. package/src/containers/StructuredData/actions.tsx +3 -9
  48. package/src/modules/ActivityLog/LogFilters/DateFilter/index.tsx +5 -4
  49. package/src/modules/Content/NewContentModal/PageImporter/index.tsx +1 -2
  50. package/src/modules/Content/index.tsx +8 -3
  51. package/src/modules/Content/style.tsx +7 -0
  52. package/src/modules/Navigation/Defaults/DefaultsEditor/index.tsx +58 -45
  53. package/src/modules/Navigation/Defaults/index.tsx +103 -104
  54. package/src/modules/PageEditor/index.tsx +9 -1
  55. package/src/modules/PublicPreview/index.tsx +2 -1
  56. package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/index.tsx +60 -44
  57. package/src/modules/Settings/ContentTypes/DataPacks/Config/index.tsx +32 -37
  58. package/src/modules/Sites/index.tsx +3 -3
  59. package/src/modules/Users/UserList/index.tsx +1 -1
@@ -1,8 +1,17 @@
1
- import React, { useEffect, useRef, useState } from "react";
1
+ import { useEffect, useMemo, useRef, useState } from "react";
2
2
  import { connect } from "react-redux";
3
3
  import { withErrorBoundary } from "react-error-boundary";
4
4
 
5
- import { IRootState, ISite, INotification, ILanguage, INavigationLanguage } from "@ax/types";
5
+ import type {
6
+ IRootState,
7
+ ISite,
8
+ INotification,
9
+ ILanguage,
10
+ INavigationLanguage,
11
+ IHeader,
12
+ IFooter,
13
+ INavigation,
14
+ } from "@ax/types";
6
15
  import { useIsDirty, useModal, usePermission } from "@ax/hooks";
7
16
  import { RouteLeavingGuard } from "@ax/guards";
8
17
 
@@ -41,65 +50,67 @@ const DefaultsEditor = (props: IProps) => {
41
50
  const { isOpen, toggleModal } = useModal();
42
51
  const { isOpen: isRestoreOpen, toggleModal: toggleRestoreModal } = useModal();
43
52
  const { isDirty, setIsDirty, resetDirty } = useIsDirty(editorContent, isNewTranslation);
44
- const currentDefaultNav = currentDefaultsContent.find((item: any) => item.setAsDefault);
53
+ const currentDefaultNav = currentDefaultsContent.find((item) => item.setAsDefault);
45
54
  const isNew = !editorContent?.id;
46
55
  const isDeleted = !!editorContent?.deleted;
47
56
 
48
- const deletedNotificationText = `This ${editorContent?.type} has been deleted and cant be edited. It will be permanently removed from the trash after 30 days.`;
57
+ const deletedNotificationText = `This ${editorContent?.type} has been deleted and can't be edited. It will be permanently removed from the trash after 30 days.`;
49
58
 
50
- const currentLanguages: ILanguage[] = [];
51
- navLanguages?.forEach((navLang) => {
52
- const currentLang = siteLanguages.find((lang) => lang.id === navLang.languageId);
53
- if (currentLang) {
54
- currentLanguages.push(currentLang);
55
- }
56
- });
59
+ const currentLanguages = useMemo(() => {
60
+ if (!navLanguages) return [];
61
+ return navLanguages
62
+ .map((navLang) => siteLanguages.find((siteLang) => siteLang.id === navLang.languageId))
63
+ .filter((siteLang): siteLang is ILanguage => !!siteLang);
64
+ }, [navLanguages, siteLanguages]);
57
65
 
58
- const isSetAsDefault = editorContent && editorContent.setAsDefault;
66
+ const isSetAsDefault = editorContent?.setAsDefault;
59
67
  const browserRef = useRef<HTMLDivElement>(null);
60
68
 
61
- const isAllowedToCreateHeaders = usePermission("navigation.createSiteHeaders") && selectedDefault === "Headers";
62
- const isAllowedToCreateFooters = usePermission("navigation.createSiteFooters") && selectedDefault === "Footers";
69
+ const isAllowedToCreate = usePermission(`navigation.createSite${selectedDefault}`);
70
+
71
+ useEffect(() => {
72
+ const init = async () => await getValues();
73
+ init();
74
+ }, [getValues]);
63
75
 
64
- // biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
65
76
  useEffect(() => {
66
- const handleGetValues = async () => await getValues();
67
- handleGetValues();
68
77
  if (isNew) {
69
78
  setIsDirty(false);
70
79
  }
71
- }, []);
80
+ }, [isNew, setIsDirty]);
72
81
 
73
- // biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
82
+ // biome-ignore lint/correctness/useExhaustiveDependencies: resetDirty is not referentially stable (not wrapped in useCallback)
74
83
  useEffect(() => {
75
84
  resetDirty();
76
85
  }, [lang]);
77
86
 
78
- // biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
79
87
  useEffect(() => {
80
- const navigationModuleComponent = currentSiteInfo && currentSiteInfo.navigationModules?.[editorContent?.type];
81
- const currentNavigation = currentDefaultsContent?.find((item: any) => item.id === editorContent?.id);
88
+ const editorType = editorContent?.type;
89
+ const navigationModuleComponent = editorType ? currentSiteInfo?.navigationModules?.[editorType] : undefined;
90
+ const currentNavigation = currentDefaultsContent?.find((item: IHeader | IFooter) => item.id === editorContent?.id);
82
91
  if (navigationModuleComponent && editorContent && currentNavigation) {
83
92
  const isNavigationModuleChanged = navigationModuleComponent !== currentNavigation.component;
84
- isNavigationModuleChanged && setIsDirty(true);
93
+ if (isNavigationModuleChanged) setIsDirty(true);
85
94
  }
86
- }, [currentSiteInfo, editorContent?.id]);
95
+ }, [currentSiteInfo, editorContent, currentDefaultsContent, setIsDirty]);
87
96
 
88
97
  const save = async () => {
89
98
  const isSaved =
90
99
  isNew || isNewTranslation
91
100
  ? await createNavigation(browserRef?.current)
92
- : await updateNavigation(editorContent.id, editorContent, true, browserRef?.current);
101
+ : editorContent?.id
102
+ ? await updateNavigation(editorContent.id, editorContent, true, browserRef?.current)
103
+ : false;
93
104
  if (isSaved) resetDirty();
94
105
  };
95
106
 
96
- const saveAsDefault = () => {
97
- save();
107
+ const saveAsDefault = async () => {
108
+ await save();
98
109
  toggleModal();
99
110
  };
100
111
 
101
112
  const saveButtonAction = () => {
102
- const isCurrentDefault = currentDefaultNav && currentDefaultNav.id === editorContent.id;
113
+ const isCurrentDefault = currentDefaultNav && currentDefaultNav.id === editorContent?.id;
103
114
  const isNewDefault = isNew || !isCurrentDefault;
104
115
  isSetAsDefault && isNewDefault && !isNewTranslation ? toggleModal() : save();
105
116
  };
@@ -107,15 +118,13 @@ const DefaultsEditor = (props: IProps) => {
107
118
  const rightButtonProps = {
108
119
  label: !isDirty && !isNewTranslation && !isNew ? "Saved" : isSaving ? "Saving" : "Save",
109
120
  disabled: (!isDirty && !isNewTranslation && !isNew) || isSaving,
110
- action: () => saveButtonAction(),
121
+ action: saveButtonAction,
111
122
  };
112
123
 
113
- const getNavigation = (id: number): Promise<void> => {
114
- return new Promise(() => {
115
- const isHeader = selectedDefault === "Headers";
116
- isHeader ? setHeader(id) : setFooter(id);
117
- getValues();
118
- });
124
+ const getNavigation = async (id: number) => {
125
+ const isHeader = selectedDefault === "Headers";
126
+ isHeader ? setHeader(id) : setFooter(id);
127
+ await getValues();
119
128
  };
120
129
 
121
130
  const getSelectedNavLanguage = (language: ILanguage) =>
@@ -135,14 +144,15 @@ const DefaultsEditor = (props: IProps) => {
135
144
  setIsDirty(true);
136
145
  createTranslation(true);
137
146
  await getMenus();
138
- editorContent && (await getNavigation(editorContent.id));
147
+ editorContent?.id && (await getNavigation(editorContent.id));
139
148
  }
140
149
  };
141
150
 
142
151
  const handleRestorePage = async () => {
152
+ if (!editorContent?.id) return;
143
153
  const isRestored = await restoreNavigation(editorContent.id, editorContent.type);
144
154
  if (isRestored) {
145
- isRestoreOpen && toggleRestoreModal();
155
+ if (isRestoreOpen) toggleRestoreModal();
146
156
  await getValues();
147
157
  }
148
158
  };
@@ -161,8 +171,7 @@ const DefaultsEditor = (props: IProps) => {
161
171
  const secondaryModalAction = { title: "Cancel", onClick: toggleModal };
162
172
  const goBack = (path: string) => setHistoryPush(path, true);
163
173
 
164
- const availableLanguages =
165
- (isAllowedToCreateHeaders || isAllowedToCreateFooters) && !isDeleted ? siteLanguages : currentLanguages;
174
+ const availableLanguages = isAllowedToCreate && !isDeleted ? siteLanguages : currentLanguages;
166
175
 
167
176
  const backLinkRoute = "/sites/navigations/modules";
168
177
 
@@ -172,7 +181,7 @@ const DefaultsEditor = (props: IProps) => {
172
181
  <>
173
182
  <RouteLeavingGuard when={isDirty || isSaving} action={goBack} text={leavingGuardText} />
174
183
  <MainWrapper
175
- title={editorContent?.title}
184
+ title={editorContent?.title ?? ""}
176
185
  backLink={backLinkRoute}
177
186
  rightButton={rightButtonProps}
178
187
  fixedAppBar={true}
@@ -251,9 +260,9 @@ interface IStateProps {
251
260
  isLoading: boolean;
252
261
  lang: { locale: string; id: number | null };
253
262
  siteLanguages: ILanguage[];
254
- currentDefaultsContent: any;
255
- selectedDefault: any;
256
- editorContent: any;
263
+ currentDefaultsContent: (IHeader | IFooter)[];
264
+ selectedDefault: string;
265
+ editorContent: INavigation | null;
257
266
  header: number | null;
258
267
  footer: number | null;
259
268
  navLanguages: INavigationLanguage[];
@@ -265,7 +274,6 @@ const mapDispatchToProps = {
265
274
  setHistoryPush: appActions.setHistoryPush,
266
275
  setLanguage: appActions.setLanguage,
267
276
  getValues: navigationActions.getValues,
268
- setSchema: navigationActions.setSchema,
269
277
  createNavigation: navigationActions.createNavigation,
270
278
  updateNavigation: navigationActions.updateNavigation,
271
279
  createTranslation: navigationActions.createNewTranslation,
@@ -280,7 +288,12 @@ interface IDispatchProps {
280
288
  setLanguage(lang: { locale: string; id: number | null }): void;
281
289
  getValues(): Promise<void>;
282
290
  createNavigation(navHtml?: HTMLDivElement | null): Promise<boolean>;
283
- updateNavigation(navID: number, data: any, fromEditor?: boolean, navHtml?: HTMLDivElement | null): Promise<boolean>;
291
+ updateNavigation(
292
+ navID: number,
293
+ data: INavigation,
294
+ fromEditor?: boolean,
295
+ navHtml?: HTMLDivElement | null,
296
+ ): Promise<boolean>;
284
297
  createTranslation(isNewTranslation: boolean): void;
285
298
  setHeader(id: number | null): void;
286
299
  setFooter(id: number | null): void;
@@ -1,4 +1,4 @@
1
- import { useCallback, useEffect, useRef, useState } from "react";
1
+ import { useEffect, useMemo, useRef, useState } from "react";
2
2
  import { connect } from "react-redux";
3
3
 
4
4
  import { ErrorToast, MainWrapper, Notification, TableList, Toast } from "@ax/components";
@@ -16,6 +16,9 @@ import ReplaceNavModal from "./ReplaceNavModal";
16
16
 
17
17
  import * as S from "./style";
18
18
 
19
+ const ITEMS_PER_PAGE = 50;
20
+ const DEFAULT_TYPES = ["Headers", "Footers"];
21
+
19
22
  const DefaultsList = (props: IProps): JSX.Element => {
20
23
  const {
21
24
  currentDefaultsContent,
@@ -48,12 +51,13 @@ const DefaultsList = (props: IProps): JSX.Element => {
48
51
  const [isNavigationNotificationOpen, setIsNavigationNotificationOpen] = useState(false);
49
52
  const { isOpen: isReplaceOpened, toggleModal: toggleReplaceModal } = useModal();
50
53
 
51
- const isAllowedToCreateHeaders = usePermission("navigation.createSiteHeaders") && selectedDefault === "Headers";
52
- const isAllowedToCreateFooters = usePermission("navigation.createSiteFooters") && selectedDefault === "Footers";
53
- const isAllowedToDeleteHeaders = usePermission("navigation.deleteSiteHeaders") && selectedDefault === "Headers";
54
- const isAllowedToDeleteFooters = usePermission("navigation.deleteSiteFooters") && selectedDefault === "Footers";
54
+ const isAllowedToCreate = usePermission(`navigation.createSite${selectedDefault}`);
55
+ const isAllowedToDelete = usePermission(`navigation.deleteSite${selectedDefault}`);
55
56
 
56
- const navIds = currentDefaultsContent?.map((nav: any) => nav.id);
57
+ const navIds = useMemo(
58
+ () => currentDefaultsContent?.map((nav: IHeader | IFooter) => nav.id),
59
+ [currentDefaultsContent],
60
+ );
57
61
 
58
62
  const {
59
63
  resetBulkSelection,
@@ -66,99 +70,87 @@ const DefaultsList = (props: IProps): JSX.Element => {
66
70
  setHoverCheck,
67
71
  } = useBulkSelection(navIds);
68
72
 
69
- const itemsPerPage = 50;
70
- const defaultTypes = ["Headers", "Footers"];
71
-
72
73
  const currentType = selectedDefault === "Headers" ? "header" : "footer";
73
74
 
74
75
  const showNavigationModulesWarning = isMultipleNavigationModules();
75
76
 
76
- const getParams = useCallback(() => {
77
- return {
78
- page,
79
- itemsPerPage,
80
- pagination: true,
81
- deleted: false,
82
- include_draft: false,
83
- };
84
- }, [page]);
85
-
86
- // biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
87
- const getContents = useCallback((selectedDefault: string) => {
88
- const params: any = getParams();
89
- params.selectedDefault = selectedDefault;
90
- selectedDefault === "Headers" ? getHeaders(params) : getFooters(params);
91
- setSelectedDefault(selectedDefault);
92
- }, []);
93
-
94
- // biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
95
77
  useEffect(() => {
96
- getContents(selectedDefault);
78
+ const fetchDefaults = async () => {
79
+ const params = {
80
+ page,
81
+ itemsPerPage: ITEMS_PER_PAGE,
82
+ pagination: true,
83
+ deleted: false,
84
+ include_draft: false,
85
+ selectedDefault,
86
+ lang,
87
+ };
88
+ selectedDefault === "Headers" ? await getHeaders(params) : await getFooters(params);
89
+ };
90
+ fetchDefaults();
97
91
  if (tableRef.current) {
98
92
  tableRef.current.scrollTo(0, 0);
99
93
  }
100
- }, [lang]);
101
-
102
- const memoizedGetMenus = useCallback(() => getMenus(), [getMenus]);
94
+ }, [lang, page, selectedDefault, getHeaders, getFooters]);
103
95
 
104
- // biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
105
96
  useEffect(() => {
106
- resetDefaultsValues();
107
- memoizedGetMenus();
108
- }, []);
97
+ const init = async (_lang: typeof lang) => {
98
+ await resetDefaultsValues();
99
+ await getMenus();
100
+ };
101
+ init(lang);
102
+ }, [lang, resetDefaultsValues, getMenus]);
109
103
 
110
- // biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
111
104
  useEffect(() => {
112
- const isNavigationModulesChanged =
105
+ const isNavigationModulesChanged = Boolean(
113
106
  currentSiteInfo?.navigationModules?.[currentType] &&
114
- currentDefaultsContent.some(
115
- (navigation) => navigation.component !== currentSiteInfo?.navigationModules[currentType],
116
- );
107
+ currentDefaultsContent.some(
108
+ (navigation) => navigation.component !== currentSiteInfo?.navigationModules[currentType],
109
+ ),
110
+ );
117
111
  setIsNavigationNotificationOpen(isNavigationModulesChanged);
118
- }, [currentDefaultsContent]);
112
+ }, [currentDefaultsContent, currentSiteInfo, currentType]);
119
113
 
120
- const handleClick = (selectedDefault: string) => {
121
- unselectAllItems();
122
- getContents(selectedDefault);
114
+ const handleClick = (newDefault: string) => {
115
+ resetBulkSelection();
116
+ setPage(1);
117
+ setSelectedDefault(newDefault);
123
118
  };
124
119
 
125
- const setContent = (item: any) => {
120
+ const setContent = (item: IHeader | IFooter) => {
126
121
  const { type, id } = item;
127
- const isHeader = type === "header";
128
- isHeader ? setHeader(id) : setFooter(id);
122
+ type === "header" ? setHeader(id) : setFooter(id);
129
123
  };
130
124
 
131
125
  const addNewDefault = () => {
132
126
  setHeader(null);
133
127
  setFooter(null);
134
- const path = "/sites/navigations/editor";
135
- setHistoryPush(path, true);
128
+ setHistoryPush("/sites/navigations/editor", true);
136
129
  };
137
130
 
138
- const rightButtonProps =
139
- isAllowedToCreateHeaders || isAllowedToCreateFooters
140
- ? {
141
- label: "New",
142
- action: () => addNewDefault(),
143
- }
144
- : undefined;
131
+ const rightButtonProps = isAllowedToCreate
132
+ ? {
133
+ label: "New",
134
+ action: addNewDefault,
135
+ }
136
+ : undefined;
145
137
 
146
138
  const pagination = {
147
139
  setPage,
148
- itemsPerPage,
140
+ itemsPerPage: ITEMS_PER_PAGE,
149
141
  totalItems,
150
142
  currPage: page,
151
143
  };
152
144
 
153
- const undoAction = () => {
145
+ const undoAction = async () => {
154
146
  if (deletedNav) {
155
- restoreNavigation(deletedNav, currentType);
147
+ await restoreNavigation(deletedNav, currentType);
156
148
  }
157
149
  setIsVisible(false);
158
150
  };
159
151
 
160
152
  const toastProps = {
161
- action: () => undoAction(),
153
+ action: undoAction,
162
154
  setIsVisible,
163
155
  message: deletedNav ? `${capitalize(currentType)} deleted` : "",
164
156
  };
@@ -173,11 +165,9 @@ const DefaultsList = (props: IProps): JSX.Element => {
173
165
  togglePagesToast();
174
166
  };
175
167
 
176
- const handleErrorAction = () => toggleReplaceModal();
177
-
178
168
  const bulkDelete = async () => {
179
169
  setIsBulkLoading(true);
180
- const deleted = await deleteNavigation(selectedItems.all, currentType, handleErrorAction);
170
+ const deleted = await deleteNavigation(selectedItems.all, currentType, toggleReplaceModal);
181
171
  setDeletedNav(selectedItems.all);
182
172
  if (deleted) {
183
173
  toggleToast();
@@ -185,44 +175,53 @@ const DefaultsList = (props: IProps): JSX.Element => {
185
175
  setIsBulkLoading(false);
186
176
  };
187
177
 
188
- const unselectAllItems = () => resetBulkSelection();
189
-
190
- const selectItems = () => (checkState.isAllSelected ? unselectAllItems() : handleSelectAll());
191
-
192
- const handleSelectAll = () => selectAllItems();
193
-
194
- const onScroll = (e: any) => setIsScrolling(e.target.scrollTop > 0);
195
-
196
- const bulkActions =
197
- isAllowedToDeleteFooters || isAllowedToDeleteHeaders
198
- ? [
199
- {
200
- icon: "delete",
201
- text: "delete",
202
- action: bulkDelete,
203
- },
204
- ]
205
- : [];
206
-
207
- const TableHeader = (
208
- <BulkHeader
209
- showBulk={areItemsSelected(navIds)}
210
- bulkActions={bulkActions}
211
- selectAllItems={handleSelectAll}
212
- totalItems={totalItems}
213
- selectItems={selectItems}
214
- selectedItems={selectedItems}
215
- checkState={checkState}
216
- isScrolling={isScrolling}
217
- setHoverCheck={setHoverCheck}
218
- isLoading={isBulkLoading}
219
- />
178
+ const onScroll = (e: React.UIEvent<HTMLDivElement>) => setIsScrolling((e.target as HTMLDivElement).scrollTop > 0);
179
+
180
+ const bulkActions = isAllowedToDelete
181
+ ? [
182
+ {
183
+ icon: "delete",
184
+ text: "delete",
185
+ action: bulkDelete,
186
+ },
187
+ ]
188
+ : [];
189
+
190
+ const TableHeader = useMemo(
191
+ () => (
192
+ <BulkHeader
193
+ showBulk={areItemsSelected(navIds)}
194
+ bulkActions={bulkActions}
195
+ selectAllItems={selectAllItems}
196
+ totalItems={totalItems}
197
+ selectItems={() => (checkState.isAllSelected ? resetBulkSelection() : selectAllItems())}
198
+ selectedItems={selectedItems}
199
+ checkState={checkState}
200
+ isScrolling={isScrolling}
201
+ setHoverCheck={setHoverCheck}
202
+ isLoading={isBulkLoading}
203
+ />
204
+ ),
205
+ [
206
+ areItemsSelected,
207
+ navIds,
208
+ bulkActions,
209
+ selectAllItems,
210
+ resetBulkSelection,
211
+ totalItems,
212
+ selectedItems,
213
+ checkState,
214
+ isScrolling,
215
+ setHoverCheck,
216
+ isBulkLoading,
217
+ ],
220
218
  );
221
219
 
222
220
  const goToSiteSettings = () => setHistoryPush("/sites/settings/globals");
223
221
 
224
222
  const handleLanguage = (language: ILanguage) => {
225
223
  const { locale, id } = language;
224
+ setPage(1);
226
225
  setLanguage({ locale, id });
227
226
  };
228
227
 
@@ -235,7 +234,7 @@ const DefaultsList = (props: IProps): JSX.Element => {
235
234
  languageAction={handleLanguage}
236
235
  >
237
236
  <S.DefaultListWrapper>
238
- <DefaultNav current={selectedDefault} defaultTypes={defaultTypes} onClick={handleClick} />
237
+ <DefaultNav current={selectedDefault} defaultTypes={DEFAULT_TYPES} onClick={handleClick} />
239
238
  <S.TableWrapper>
240
239
  <ErrorToast />
241
240
  {isNavigationNotificationOpen && (
@@ -300,21 +299,21 @@ const mapStateToProps = (state: IRootState) => ({
300
299
 
301
300
  interface IDispatchProps {
302
301
  setLanguage(lang: { locale: string; id: number | null }): void;
303
- getHeaders(params: any): void;
304
- getFooters(params: any): void;
302
+ getHeaders(params: Record<string, unknown>): Promise<void>;
303
+ getFooters(params: Record<string, unknown>): Promise<void>;
305
304
  setSelectedDefault(id: string): void;
306
- setHistoryPush(path: string, isEditor?: boolean): any;
305
+ setHistoryPush(path: string, isEditor?: boolean): void;
307
306
  setHeader(id: number | null): void;
308
307
  setFooter(id: number | null): void;
309
- restoreNavigation(navID: number | number[], type: string): void;
308
+ restoreNavigation(navID: number | number[], type: string): Promise<boolean>;
310
309
  deleteNavigation(navID: number[], type: string, errorAction: () => void): Promise<boolean>;
311
- getMenus(): void;
312
- resetDefaultsValues(): void;
310
+ getMenus(): Promise<void>;
311
+ resetDefaultsValues(): Promise<void>;
313
312
  }
314
313
 
315
314
  interface IDefaultsProps {
316
315
  lang: { locale: string; id: number | null };
317
- siteLanguages: any[];
316
+ siteLanguages: ILanguage[];
318
317
  selectedDefault: string;
319
318
  currentDefaultsContent: (IHeader | IFooter)[];
320
319
  totalItems: number;
@@ -73,6 +73,7 @@ const PageEditor = (props: IProps) => {
73
73
  setCurrentPageID,
74
74
  restorePage,
75
75
  schemaVersion,
76
+ setIsLoading,
76
77
  updateEditorContent,
77
78
  } = props;
78
79
 
@@ -145,6 +146,9 @@ const PageEditor = (props: IProps) => {
145
146
  const { pageID, getPage, sendPagePing } = props;
146
147
 
147
148
  const handleGetPage = async () => {
149
+ if (isNewTranslation) {
150
+ await getDefaults();
151
+ }
148
152
  await getPage(pageID);
149
153
  };
150
154
 
@@ -501,7 +505,7 @@ const PageEditor = (props: IProps) => {
501
505
  const { getPage } = props;
502
506
  const pageID = isDraft ? editorContent.draftFromPage : editorContent.haveDraftPage;
503
507
  await getPage(pageID);
504
- resetDirty(true, true);
508
+ resetDirty();
505
509
  };
506
510
 
507
511
  const toggleDraftPage = () => {
@@ -614,6 +618,7 @@ const PageEditor = (props: IProps) => {
614
618
  pageLanguages.find((pageLang) => pageLang.languageId === language.id);
615
619
 
616
620
  const handleLanguage = async (language: ILanguage) => {
621
+ setIsLoading(true);
617
622
  const { locale, id } = language;
618
623
  setLanguage({ locale, id });
619
624
 
@@ -631,6 +636,7 @@ const PageEditor = (props: IProps) => {
631
636
  createNewTranslation(true);
632
637
  await getPage(pageID);
633
638
  }
639
+ setIsLoading(false);
634
640
  };
635
641
 
636
642
  const handleRestorePage = async () => {
@@ -945,6 +951,7 @@ const mapDispatchToProps = {
945
951
  updatePageStatus: pageEditorActions.updatePageStatus,
946
952
  setHistoryPush: appActions.setHistoryPush,
947
953
  setLanguage: appActions.setLanguage,
954
+ setIsLoading: appActions.setIsLoading,
948
955
  createNewTranslation: pageEditorActions.createNewTranslation,
949
956
  setTab: pageEditorActions.setTab,
950
957
  getSiteDataPackbyTemplate: dataPacksActions.getSiteDataPackbyTemplate,
@@ -985,6 +992,7 @@ interface IPageEditorDispatchProps {
985
992
  schedulePublication(date: string | null, isDraft: boolean): Promise<boolean>;
986
993
  setCurrentPageID: (currentPageID: number | null) => void;
987
994
  restorePage(id: number | number[]): Promise<boolean>;
995
+ setIsLoading(loading: boolean): void;
988
996
  updateEditorContent(selectedEditorID: number, key: string, value: any): void;
989
997
  }
990
998
 
@@ -39,8 +39,9 @@ const PublicPreview = () => {
39
39
  setShareEndDate(shareResponse.data.endDate);
40
40
  }
41
41
  } else {
42
- setTokenError(response.status === 404 ? "404" : response.status === 400 ? "linkExpired" : "wrong");
42
+ setTokenError(response.status === 404 ? "404" : response.status === 410 ? "linkExpired" : "wrong");
43
43
  }
44
+
44
45
  setIsLoading(false);
45
46
  };
46
47