@griddo/ax 11.14.2 → 11.14.3-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/config/jest/setup.js +13 -7
  2. package/package.json +2 -2
  3. package/src/__tests__/components/KeywordsPreviewModal/KeywordsPreviewModal.test.tsx +4 -3
  4. package/src/components/CategoryCell/index.tsx +3 -1
  5. package/src/components/ElementsTooltip/index.tsx +8 -4
  6. package/src/components/ErrorPage/index.tsx +3 -1
  7. package/src/components/FilterTagsBar/index.tsx +3 -3
  8. package/src/components/HeadingsPreviewModal/utils.tsx +2 -1
  9. package/src/components/KeywordsPreviewModal/atoms.tsx +2 -2
  10. package/src/components/KeywordsPreviewModal/index.tsx +6 -6
  11. package/src/components/KeywordsPreviewModal/utils.tsx +5 -3
  12. package/src/components/Modal/style.tsx +5 -5
  13. package/src/components/TableFilters/CheckGroupFilter/index.tsx +3 -2
  14. package/src/components/TableFilters/LiveFilter/index.tsx +4 -4
  15. package/src/components/TableFilters/SiteFilter/index.tsx +11 -12
  16. package/src/components/TableFilters/TranslationsFilter/index.tsx +2 -2
  17. package/src/components/TableFilters/TranslationsFilter/style.tsx +2 -2
  18. package/src/components/Tag/index.tsx +15 -7
  19. package/src/components/TruncatedTooltip/index.tsx +48 -0
  20. package/src/components/index.tsx +2 -0
  21. package/src/constants/index.ts +3 -0
  22. package/src/helpers/categoryColumns.tsx +55 -0
  23. package/src/helpers/images.tsx +3 -1
  24. package/src/helpers/index.tsx +2 -0
  25. package/src/modules/ActivityLog/ItemLog/EventItem/index.tsx +17 -10
  26. package/src/modules/ActivityLog/ItemLog/EventItem/style.tsx +18 -1
  27. package/src/modules/ActivityLog/ItemLogUser/UserItem/EventItem/index.tsx +10 -7
  28. package/src/modules/ActivityLog/ItemLogUser/UserItem/index.tsx +9 -3
  29. package/src/modules/ActivityLog/ItemLogUser/UserItem/style.tsx +17 -1
  30. package/src/modules/App/Routing/NavMenu/NavItem/style.tsx +1 -0
  31. package/src/modules/App/Routing/index.tsx +2 -2
  32. package/src/modules/App/Routing/style.tsx +8 -1
  33. package/src/modules/Categories/CategoriesList/BulkHeader/TableHeader/style.tsx +1 -0
  34. package/src/modules/Categories/CategoriesList/CategoryItem/index.tsx +7 -3
  35. package/src/modules/Categories/CategoriesList/CategoryItem/style.tsx +38 -5
  36. package/src/modules/Content/BulkHeader/TableHeader/style.tsx +1 -1
  37. package/src/modules/Content/PageItem/index.tsx +80 -204
  38. package/src/modules/Content/PageItem/style.tsx +18 -10
  39. package/src/modules/Content/atoms.tsx +147 -18
  40. package/src/modules/Content/index.tsx +2 -9
  41. package/src/modules/Forms/FormCategoriesList/CategoryItem/index.tsx +7 -3
  42. package/src/modules/Forms/FormCategoriesList/CategoryItem/style.tsx +34 -0
  43. package/src/modules/Forms/FormEditor/index.tsx +28 -50
  44. package/src/modules/Forms/FormList/FormItem/index.tsx +91 -120
  45. package/src/modules/Forms/FormList/FormItem/style.tsx +19 -0
  46. package/src/modules/Forms/FormList/index.tsx +27 -48
  47. package/src/modules/Forms/atoms.tsx +44 -32
  48. package/src/modules/StructuredData/StructuredDataList/BulkHeader/TableHeader/index.tsx +8 -8
  49. package/src/modules/StructuredData/StructuredDataList/BulkHeader/TableHeader/style.tsx +2 -2
  50. package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +83 -101
  51. package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/style.tsx +11 -5
  52. package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/index.tsx +31 -54
  53. package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/style.tsx +13 -7
  54. package/src/modules/Users/Roles/BulkHeader/TableHeader/style.tsx +6 -6
  55. package/src/modules/Users/Roles/RoleItem/index.tsx +3 -4
  56. package/src/modules/Users/Roles/RoleItem/style.tsx +12 -15
  57. package/src/modules/Users/Roles/index.tsx +1 -2
  58. package/src/modules/Users/UserCreate/SiteItem/index.tsx +10 -4
  59. package/src/modules/Users/UserCreate/SiteItem/style.tsx +33 -1
  60. package/src/modules/Users/UserForm/index.tsx +6 -4
  61. package/src/modules/Users/UserList/BulkHeader/TableHeader/index.tsx +2 -4
  62. package/src/modules/Users/UserList/BulkHeader/TableHeader/style.tsx +1 -1
  63. package/src/modules/Users/UserList/UserItem/index.tsx +18 -10
  64. package/src/modules/Users/UserList/UserItem/style.tsx +60 -4
@@ -1,21 +1,12 @@
1
1
  import type { Dispatch, SetStateAction } from "react";
2
2
 
3
+ import { AsyncSelect, FieldsBehavior, Modal } from "@ax/components";
3
4
  import type { IModal } from "@ax/types";
4
- import { Modal, FieldsBehavior, AsyncSelect } from "@ax/components";
5
5
 
6
6
  import * as S from "./style";
7
7
 
8
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;
9
+ const { isOpen, toggleModal, onDelete, isTranslated, deleteAllVersions, setDeleteAllVersions, title } = props;
19
10
 
20
11
  const options = [
21
12
  {
@@ -32,15 +23,18 @@ const DeleteModal = (props: IDeleteModal): JSX.Element => {
32
23
 
33
24
  const formTitle = title ? <strong>{title}</strong> : "this form";
34
25
 
26
+ const mainAction = { title: "Delete form", onClick: onDelete };
27
+ const secondaryAction = { title: "Cancel", onClick: toggleModal };
28
+
35
29
  return (
36
30
  <Modal
37
31
  isOpen={isOpen}
38
32
  hide={toggleModal}
39
33
  title="Delete Form"
40
- secondaryAction={secondaryModalAction}
41
- mainAction={mainModalAction}
34
+ secondaryAction={secondaryAction}
35
+ mainAction={mainAction}
42
36
  size="S"
43
- height={isTranslated ? 285 : 240}
37
+ height="auto"
44
38
  >
45
39
  {isTranslated ? (
46
40
  <>
@@ -72,19 +66,22 @@ const DeleteModal = (props: IDeleteModal): JSX.Element => {
72
66
  };
73
67
 
74
68
  const UnPublishModal = (props: IUnpublishModal): JSX.Element => {
75
- const { isOpen, toggleModal, mainModalAction, secondaryModalAction, title } = props;
69
+ const { isOpen, toggleModal, onUnpublish, title } = props;
76
70
 
77
71
  const formTitle = title ? <strong>{title}</strong> : "this form";
78
72
 
73
+ const mainAction = { title: "Unpublish form", onClick: onUnpublish };
74
+ const secondaryAction = { title: "Cancel", onClick: toggleModal };
75
+
79
76
  return (
80
77
  <Modal
81
78
  isOpen={isOpen}
82
79
  hide={toggleModal}
83
80
  title="Unpublish Form"
84
- secondaryAction={secondaryModalAction}
85
- mainAction={mainModalAction}
81
+ secondaryAction={secondaryAction}
82
+ mainAction={mainAction}
86
83
  size="S"
87
- height={240}
84
+ height="auto"
88
85
  >
89
86
  <S.ModalContent>
90
87
  Are you sure you want to unpublish {formTitle}?
@@ -98,17 +95,20 @@ const UnPublishModal = (props: IUnpublishModal): JSX.Element => {
98
95
  };
99
96
 
100
97
  const DuplicateModal = (props: IDuplicateModal): JSX.Element => {
101
- const { isOpen, toggleModal, mainModalAction, secondaryModalAction, title, handleChange } = props;
98
+ const { isOpen, toggleModal, onDuplicate, title, handleChange } = props;
99
+
100
+ const mainAction = { title: "Duplicate form", onClick: onDuplicate, disabled: !title.length };
101
+ const secondaryAction = { title: "Cancel", onClick: toggleModal };
102
102
 
103
103
  return (
104
104
  <Modal
105
105
  isOpen={isOpen}
106
106
  hide={toggleModal}
107
107
  title="Duplicate form"
108
- secondaryAction={secondaryModalAction}
109
- mainAction={mainModalAction}
108
+ secondaryAction={secondaryAction}
109
+ mainAction={mainAction}
110
110
  size="S"
111
- height={284}
111
+ height="auto"
112
112
  >
113
113
  <S.ModalContent>
114
114
  <p>Please enter a new name for the duplicated form.</p>
@@ -127,22 +127,25 @@ const DuplicateModal = (props: IDuplicateModal): JSX.Element => {
127
127
  };
128
128
 
129
129
  const CopyModal = (props: ICopyModal): JSX.Element => {
130
- const { isOpen, toggleModal, mainModalAction, secondaryModalAction, setSite, site, lang, currentSite } = props;
130
+ const { isOpen, toggleModal, onCopy, setSite, site, lang, currentSite } = props;
131
131
 
132
132
  const handleSelectChange = (value: string | number | null) => {
133
133
  if (typeof value === "number") setSite(value);
134
134
  };
135
135
 
136
+ const mainAction = { title: "Copy form", onClick: onCopy, disabled: !site };
137
+ const secondaryAction = { title: "Cancel", onClick: toggleModal };
138
+
136
139
  return (
137
140
  <Modal
138
141
  isOpen={isOpen}
139
142
  hide={toggleModal}
140
143
  size="S"
141
144
  title="Copy form in another site"
142
- mainAction={mainModalAction}
143
- secondaryAction={secondaryModalAction}
145
+ mainAction={mainAction}
146
+ secondaryAction={secondaryAction}
144
147
  overflow="visible"
145
- height={278}
148
+ height="auto"
146
149
  >
147
150
  <S.ModalContent>
148
151
  <p>
@@ -166,20 +169,21 @@ const CopyModal = (props: ICopyModal): JSX.Element => {
166
169
  );
167
170
  };
168
171
 
169
- const UpdateModal = (props: IModal): JSX.Element => {
170
- const { isOpen, toggleModal, mainModalAction } = props;
172
+ const UpdateModal = (props: IUpdateModal): JSX.Element => {
173
+ const { isOpen, toggleModal, onUpdate } = props;
171
174
 
172
- const secondaryModalAction = { title: "Cancel", onClick: toggleModal };
175
+ const mainAction = { title: "Update changes", onClick: onUpdate };
176
+ const secondaryAction = { title: "Cancel", onClick: toggleModal };
173
177
 
174
178
  return (
175
179
  <Modal
176
180
  isOpen={isOpen}
177
181
  hide={toggleModal}
178
182
  title="Confirm Changes to Form"
179
- secondaryAction={secondaryModalAction}
180
- mainAction={mainModalAction}
183
+ secondaryAction={secondaryAction}
184
+ mainAction={mainAction}
181
185
  size="S"
182
- height={240}
186
+ height="auto"
183
187
  >
184
188
  <S.ModalContent>
185
189
  Saving changes <strong>will update this form on all pages where it’s in use.</strong>
@@ -192,6 +196,7 @@ const UpdateModal = (props: IModal): JSX.Element => {
192
196
  };
193
197
 
194
198
  interface IDeleteModal extends IModal {
199
+ onDelete(): void;
195
200
  isTranslated: boolean;
196
201
  deleteAllVersions: boolean;
197
202
  setDeleteAllVersions: Dispatch<SetStateAction<boolean>>;
@@ -199,19 +204,26 @@ interface IDeleteModal extends IModal {
199
204
  }
200
205
 
201
206
  interface IUnpublishModal extends IModal {
207
+ onUnpublish(): void;
202
208
  title?: string;
203
209
  }
204
210
 
205
211
  interface IDuplicateModal extends IModal {
212
+ onDuplicate(): void;
206
213
  title: string;
207
214
  handleChange(title: string): void;
208
215
  }
209
216
 
210
217
  interface ICopyModal extends IModal {
218
+ onCopy(): void;
211
219
  setSite: Dispatch<SetStateAction<number | null>>;
212
220
  site: number | null;
213
221
  lang: number;
214
222
  currentSite: number | null;
215
223
  }
216
224
 
225
+ interface IUpdateModal extends IModal {
226
+ onUpdate(): void;
227
+ }
228
+
217
229
  export { DeleteModal, UnPublishModal, DuplicateModal, CopyModal, UpdateModal };
@@ -1,19 +1,19 @@
1
1
  import React from "react";
2
2
 
3
3
  import {
4
+ CategoryFilter,
4
5
  CheckField,
5
- TableCounter,
6
6
  CustomizeFilters,
7
- CategoryFilter,
7
+ LiveFilter,
8
8
  NameFilter,
9
- StatusFilter,
10
9
  SiteFilter,
11
- LiveFilter,
12
- TranslationsFilter,
10
+ StatusFilter,
11
+ TableCounter,
13
12
  Tooltip,
13
+ TranslationsFilter,
14
14
  } from "@ax/components";
15
- import { IColumn, IQueryValue, ISchemaField } from "@ax/types";
16
15
  import { getGlobalPageTypes } from "@ax/helpers";
16
+ import type { IColumn, IQueryValue, ISchemaField } from "@ax/types";
17
17
 
18
18
  import * as S from "./style";
19
19
 
@@ -86,9 +86,9 @@ const TableHeader = (props: IProps): JSX.Element => {
86
86
  </S.NameWrapper>
87
87
  {isAllPages && activeColumns.includes("type") && <S.TypeHeader>Type</S.TypeHeader>}
88
88
  {activeColumns.includes("site") && (
89
- <S.HeaderWrapper>
89
+ <S.SiteHeader>
90
90
  <SiteFilter filterItems={filterItems} value={filterValues} pointer="filterSites" />
91
- </S.HeaderWrapper>
91
+ </S.SiteHeader>
92
92
  )}
93
93
  {activeColumns.includes("live") && (
94
94
  <S.HeaderWrapper>
@@ -22,7 +22,7 @@ const NameHeader = styled(Header)`
22
22
 
23
23
  const SiteHeader = styled(Header)`
24
24
  width: 175px;
25
- justify-content: flex-start;
25
+ justify-content: center;
26
26
  `;
27
27
 
28
28
  const LiveHeader = styled(Header)`
@@ -67,7 +67,7 @@ const HeaderWrapper = styled.div`
67
67
  `;
68
68
 
69
69
  const ColumnHeader = styled(Header)`
70
- flex: 0 0 150px;
70
+ flex: 0 0 215px;
71
71
  justify-content: center;
72
72
  `;
73
73
 
@@ -1,33 +1,39 @@
1
- import React, { useRef, useState } from "react";
1
+ import { useState } from "react";
2
2
  import { connect } from "react-redux";
3
- import { useTheme } from "styled-components";
4
3
 
5
- import type {
6
- ICheck,
7
- IAvailableSites,
8
- ISavePageParams,
9
- ILanguage,
10
- IPageLanguage,
11
- IPage,
12
- IColumn,
13
- ISchemaField,
14
- IRootState,
15
- } from "@ax/types";
16
- import { getHumanLastModifiedDate, getScheduleFormatDate, getStructuredDataTitle, trimText } from "@ax/helpers";
17
- import { appActions } from "@ax/containers/App";
18
- import { pageStatus, type ISetCurrentPageIDAction } from "@ax/containers/PageEditor/interfaces";
19
4
  import {
20
5
  CheckField,
6
+ ElementsTooltip,
7
+ Flag,
21
8
  FloatingMenu,
22
9
  Icon,
23
- Flag,
24
10
  LanguageMenu,
25
11
  Tooltip,
26
- ElementsTooltip,
27
- CategoryCell,
12
+ TruncatedTooltip,
28
13
  } from "@ax/components";
14
+ import { appActions } from "@ax/containers/App";
29
15
  import { pageEditorActions } from "@ax/containers/PageEditor";
30
- import { useAdaptiveText, useModal, usePermission } from "@ax/hooks";
16
+ import { type ISetCurrentPageIDAction, pageStatus } from "@ax/containers/PageEditor/interfaces";
17
+ import {
18
+ buildCategoryColumns,
19
+ getHumanLastModifiedDate,
20
+ getScheduleFormatDate,
21
+ getStructuredDataTitle,
22
+ trimText,
23
+ } from "@ax/helpers";
24
+ import { useModals, usePermissions } from "@ax/hooks";
25
+ import type {
26
+ IAvailableSites,
27
+ ICheck,
28
+ IColumn,
29
+ ILanguage,
30
+ IPage,
31
+ IPageLanguage,
32
+ IRootState,
33
+ ISavePageParams,
34
+ ISchemaField,
35
+ } from "@ax/types";
36
+
31
37
  import { DeleteModal, DuplicateModal, UnpublishModal } from "./atoms";
32
38
  import { getCurrentLanguages } from "./utils";
33
39
 
@@ -87,23 +93,18 @@ const GlobalPageItem = (props: IGlobalPageItemProps): JSX.Element => {
87
93
 
88
94
  const initValue = { title: "", slug: "" };
89
95
  const [duplicateModalState, setDuplicateModalState] = useState(initValue);
90
- const { isOpen: isDuplicateOpen, toggleModal: toggleDuplicateModal } = useModal();
91
- const { isOpen: isDeleteOpen, toggleModal: toggleDeleteModal } = useModal();
92
- const { isOpen: isUnpublishOpen, toggleModal: toggleUnpublishModal } = useModal();
96
+ const { isOpen, toggleModal } = useModals(["duplicate", "delete", "unpublish"]);
93
97
  const [deleteAllVersions, setDeleteAllVersions] = useState(false);
94
98
 
95
- const nameCellRef = useRef<HTMLDivElement>(null);
96
- const theme: any = useTheme();
97
- const nameCellPadding = Number(theme.spacing.s.slice(0, -2));
98
- const title = useAdaptiveText(nameCellRef, globalPage.title, nameCellPadding);
99
- const path = useAdaptiveText(nameCellRef, fullPath.page, nameCellPadding);
100
99
  const API_URL = process.env.GRIDDO_API_URL || process.env.REACT_APP_API_ENDPOINT;
101
100
 
102
- const isAllowedToDuplicatePages = usePermission("global.globalData.duplicateGlobalData");
103
- const isAllowedToPublishPages = usePermission("global.globalData.publishUnpublishAllGlobalData");
104
- const isAllowedToCreatePages = usePermission("global.globalData.createAllGlobalData");
105
- const isAllowedToDeletePage = usePermission("global.globalData.deleteAllGlobalData");
106
- const isAllowedToEditContentPage = usePermission("global.globalData.editAllGlobalData");
101
+ const isAllowedTo = usePermissions({
102
+ duplicatePages: "global.globalData.duplicateGlobalData",
103
+ publishPages: "global.globalData.publishUnpublishAllGlobalData",
104
+ createPages: "global.globalData.createAllGlobalData",
105
+ deletePages: "global.globalData.deleteAllGlobalData",
106
+ editContentPages: "global.globalData.editAllGlobalData",
107
+ });
107
108
 
108
109
  const publishedTooltip: Record<string, string> = {
109
110
  active: "Live",
@@ -179,7 +180,7 @@ const GlobalPageItem = (props: IGlobalPageItemProps): JSX.Element => {
179
180
  setDeletedItem(deletedItems);
180
181
  toggleToast();
181
182
  }
182
- toggleDeleteModal();
183
+ toggleModal("delete");
183
184
  getGlobalPages();
184
185
  };
185
186
 
@@ -206,26 +207,26 @@ const GlobalPageItem = (props: IGlobalPageItemProps): JSX.Element => {
206
207
  const handleDuplicatePage = async () => {
207
208
  const isDuplicated = await duplicatePage(globalPage.id, duplicateModalState);
208
209
  if (isDuplicated) {
209
- toggleDuplicateModal();
210
+ toggleModal("duplicate");
210
211
  setHistoryPush("data/pages/editor", true);
211
212
  }
212
213
  };
213
214
 
214
- let menuOptions = [];
215
+ let menuOptions: IPageOption[] = [];
215
216
 
216
- if (isAllowedToDuplicatePages) {
217
+ if (isAllowedTo.duplicatePages) {
217
218
  menuOptions.push({
218
219
  label: "duplicate",
219
220
  icon: "duplicate",
220
- action: toggleDuplicateModal,
221
+ action: () => toggleModal("duplicate"),
221
222
  });
222
223
  }
223
224
 
224
- if (isAllowedToDeletePage) {
225
+ if (isAllowedTo.deletePages) {
225
226
  menuOptions.push({
226
227
  label: "delete",
227
228
  icon: "delete",
228
- action: toggleDeleteModal,
229
+ action: () => toggleModal("delete"),
229
230
  });
230
231
  }
231
232
 
@@ -242,20 +243,22 @@ const GlobalPageItem = (props: IGlobalPageItemProps): JSX.Element => {
242
243
  return {
243
244
  label: "unpublish",
244
245
  icon: "offline",
245
- action: globalPage.haveDraftPage ? toggleUnpublishModal : unpublishPage,
246
+ action: globalPage.haveDraftPage ? () => toggleModal("unpublish") : unpublishPage,
246
247
  };
247
248
  case pageStatus.UPLOAD_PENDING:
248
249
  return {
249
250
  label: "unpublish",
250
251
  icon: "offline",
251
- action: globalPage.haveDraftPage ? toggleUnpublishModal : cancelPublishPage,
252
+ action: globalPage.haveDraftPage ? () => toggleModal("unpublish") : cancelPublishPage,
252
253
  };
253
254
  default:
254
255
  return null;
255
256
  }
256
257
  };
257
258
 
258
- const viewPage = () => window.open(globalPage.fullUrl || `${API_URL}/page/go/${globalPage.id}`, "_blank");
259
+ const viewPage = () => {
260
+ window.open(globalPage.fullUrl || `${API_URL}/page/go/${globalPage.id}`, "_blank");
261
+ };
259
262
 
260
263
  const viewOption = {
261
264
  label: "View online",
@@ -272,7 +275,7 @@ const GlobalPageItem = (props: IGlobalPageItemProps): JSX.Element => {
272
275
  },
273
276
  ];
274
277
 
275
- if (isAllowedToEditContentPage) {
278
+ if (isAllowedTo.editContentPages) {
276
279
  editOptions.unshift({
277
280
  label: "Edit draft",
278
281
  icon: "modified",
@@ -282,14 +285,15 @@ const GlobalPageItem = (props: IGlobalPageItemProps): JSX.Element => {
282
285
  }
283
286
 
284
287
  const publishAction = getPublishItem(globalPage.liveStatus?.status);
285
- menuOptions = publishAction && isAllowedToPublishPages ? [publishAction, ...menuOptions] : menuOptions;
288
+ const publishItems = publishAction && isAllowedTo.publishPages ? [publishAction] : [];
289
+ menuOptions = [...publishItems, ...menuOptions];
286
290
 
287
291
  menuOptions = globalPage.haveDraftPage ? [...editOptions, ...menuOptions] : menuOptions;
288
292
 
289
293
  menuOptions = globalPage.liveStatus?.status === pageStatus.PUBLISHED ? [viewOption, ...menuOptions] : menuOptions;
290
294
 
291
295
  const handleCloseDuplicate = () => {
292
- toggleDuplicateModal();
296
+ toggleModal("duplicate");
293
297
  setDuplicateModalState({ title: "", slug: "" });
294
298
  };
295
299
 
@@ -307,7 +311,7 @@ const GlobalPageItem = (props: IGlobalPageItemProps): JSX.Element => {
307
311
  title: "Delete page",
308
312
  onClick: removeItem,
309
313
  };
310
- const secondaryDeleteModalAction = { title: "Cancel", onClick: toggleDeleteModal };
314
+ const secondaryDeleteModalAction = { title: "Cancel", onClick: () => toggleModal("delete") };
311
315
 
312
316
  const currentLanguages = getCurrentLanguages(languages, pageLanguages);
313
317
 
@@ -347,7 +351,7 @@ const GlobalPageItem = (props: IGlobalPageItemProps): JSX.Element => {
347
351
  const languageMenu = () => (
348
352
  <LanguageMenu
349
353
  language={locale}
350
- availableLanguages={isAllowedToCreatePages ? languages : currentLanguages}
354
+ availableLanguages={isAllowedTo.createPages ? languages : currentLanguages}
351
355
  setLanguage={handleLanguage}
352
356
  currentLanguages={currentLanguages}
353
357
  />
@@ -372,38 +376,16 @@ const GlobalPageItem = (props: IGlobalPageItemProps): JSX.Element => {
372
376
 
373
377
  const getLiveStatus = () => (isScheduledPub ? "scheduled" : haveDraftPage ? "modified" : liveStatus.status);
374
378
 
375
- const mainUnpublishAction = { title: "Ok", onClick: toggleUnpublishModal };
376
-
377
- const CategoryColumns = categoryColumns.map((col) => {
378
- if (!activeColumns.includes(col.key)) {
379
- return <React.Fragment key={col.key} />;
380
- }
381
-
382
- const type: any = structuredDataContent?.[col.key];
383
-
384
- if (typeof type !== "object") {
385
- return (
386
- <S.ColumnCell key={col.key} onClick={_handleClick}>
387
- {type}
388
- </S.ColumnCell>
389
- );
390
- }
379
+ const mainUnpublishAction = { title: "Ok", onClick: () => toggleModal("unpublish") };
391
380
 
392
- const categories: string[] = !type
393
- ? []
394
- : Array.isArray(type)
395
- ? type.map((cat: any) => cat.label || cat.title)
396
- : [type.label || type.title];
397
-
398
- return (
399
- <CategoryCell
400
- key={col.key}
401
- categories={categories}
402
- categoryColors={categoryColors}
403
- addCategoryColors={addCategoryColors}
404
- />
405
- );
406
- });
381
+ const CategoryColumns = buildCategoryColumns(
382
+ categoryColumns,
383
+ activeColumns,
384
+ structuredDataContent,
385
+ categoryColors,
386
+ addCategoryColors,
387
+ _handleClick,
388
+ );
407
389
 
408
390
  const structuredDataTitle = structuredData ? getStructuredDataTitle(structuredData) : "";
409
391
  const typeTitle =
@@ -421,22 +403,13 @@ const GlobalPageItem = (props: IGlobalPageItemProps): JSX.Element => {
421
403
  <S.CheckCell role="cell">
422
404
  <CheckField name="check" value={globalPage.id} checked={isSelected || hoverCheck} onChange={handleOnChange} />
423
405
  </S.CheckCell>
424
- <S.NameCell role="cell" onClick={_handleClick} ref={nameCellRef}>
425
- <Tooltip
426
- content={[
427
- <React.Fragment key="page-title">
428
- <strong>{globalPage.title}</strong>
429
- <br />
430
- </React.Fragment>,
431
- <React.Fragment key="page-slug">{fullPath.page}</React.Fragment>,
432
- ]}
433
- left={0}
434
- top={1}
435
- expanded
436
- >
437
- <S.Title width={title.width}>{title.text}</S.Title>
438
- <S.Slug width={path.width}>{path.text}</S.Slug>
439
- </Tooltip>
406
+ <S.NameCell role="cell" onClick={_handleClick}>
407
+ <TruncatedTooltip content={globalPage.title} expanded top={-5}>
408
+ <S.Title>{globalPage.title}</S.Title>
409
+ </TruncatedTooltip>
410
+ <TruncatedTooltip content={fullPath.page} expanded top={5}>
411
+ <S.Slug>{fullPath.page}</S.Slug>
412
+ </TruncatedTooltip>
440
413
  </S.NameCell>
441
414
  {isAllPages && activeColumns.includes("type") && <S.TypeCell role="cell">{typeTitle}</S.TypeCell>}
442
415
  {activeColumns.includes("site") && (
@@ -470,28 +443,37 @@ const GlobalPageItem = (props: IGlobalPageItemProps): JSX.Element => {
470
443
  </S.ActionsCell>
471
444
  </S.StructuredDataRow>
472
445
  <DuplicateModal
473
- isOpen={isDuplicateOpen}
474
- toggleModal={toggleDuplicateModal}
446
+ isOpen={isOpen("duplicate")}
447
+ toggleModal={() => toggleModal("duplicate")}
475
448
  mainModalAction={mainDuplicateModalAction}
476
449
  secondaryModalAction={secondaryDuplicateModalAction}
477
450
  {...{ duplicateModalState, setDuplicateModalState }}
478
451
  />
479
452
  <DeleteModal
480
- isOpen={isDeleteOpen}
481
- toggleModal={toggleDeleteModal}
453
+ isOpen={isOpen("delete")}
454
+ toggleModal={() => toggleModal("delete")}
482
455
  mainModalAction={mainDeleteModalAction}
483
456
  secondaryModalAction={secondaryDeleteModalAction}
484
457
  {...{ title: globalPage.title, isTranslated, deleteAllVersions, setDeleteAllVersions }}
485
458
  />
486
459
  <UnpublishModal
487
- isOpen={isUnpublishOpen}
488
- toggleModal={toggleUnpublishModal}
460
+ isOpen={isOpen("unpublish")}
461
+ toggleModal={() => toggleModal("unpublish")}
489
462
  mainModalAction={mainUnpublishAction}
490
463
  />
491
464
  </>
492
465
  );
493
466
  };
494
467
 
468
+ interface IPageOption {
469
+ label: string;
470
+ icon: string;
471
+ action: () => void | Promise<void>;
472
+ disabled?: boolean;
473
+ helpText?: string | null;
474
+ color?: boolean;
475
+ }
476
+
495
477
  interface IGlobalPageItemProps {
496
478
  languages: ILanguage[];
497
479
  lang: { locale: string; id: number | null };
@@ -14,22 +14,28 @@ const CheckCell = styled(Cell)`
14
14
 
15
15
  const NameCell = styled(Cell)`
16
16
  flex-grow: 1;
17
+ min-width: 0;
18
+ position: relative;
19
+ flex-flow: column;
20
+ > * {
21
+ min-width: 0;
22
+ }
17
23
  `;
18
24
 
19
- const Title = styled.div<{ width: number }>`
25
+ const Title = styled.div`
26
+ width: 100%;
20
27
  ${(p) => p.theme.textStyle.uiL};
21
28
  color: ${(p) => p.theme.color.textHighEmphasis};
22
29
  overflow: hidden;
23
30
  white-space: nowrap;
24
31
  text-overflow: ellipsis;
25
- width: ${(p) => `${p.width}px`};
26
32
  `;
27
33
 
28
- const Slug = styled.div<{ width: number }>`
34
+ const Slug = styled.div`
35
+ width: 100%;
29
36
  overflow: hidden;
30
37
  white-space: nowrap;
31
38
  text-overflow: ellipsis;
32
- width: ${(p) => `${p.width}px`};
33
39
  `;
34
40
 
35
41
  const TypeCell = styled(Cell)`
@@ -164,7 +170,7 @@ const ModalContent = styled.div`
164
170
  `;
165
171
 
166
172
  const ColumnCell = styled(Cell)`
167
- flex: 0 0 150px;
173
+ flex: 0 0 215px;
168
174
  position: relative;
169
175
  align-items: center;
170
176
  `;