@griddo/ax 10.6.19 → 10.6.20

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@griddo/ax",
3
3
  "description": "Griddo Author Experience",
4
- "version": "10.6.19",
4
+ "version": "10.6.20",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Carlos Torres <carlos.torres@secuoyas.com>",
@@ -233,5 +233,5 @@
233
233
  "publishConfig": {
234
234
  "access": "public"
235
235
  },
236
- "gitHead": "92b2da3974ba50064e2c9b33f9b5dc752da7a33e"
236
+ "gitHead": "12ae17b68dfb1b977eeb213b383aa65da91ab928"
237
237
  }
@@ -23,7 +23,15 @@ const ScheduleModal = (props: IScheduleModal): JSX.Element => {
23
23
  }
24
24
  };
25
25
 
26
- const handleTimeChange = (time: string) => setScheduleDate({ ...scheduleDate, time });
26
+ const handleTimeChange = (time: string) => {
27
+ setScheduleDate({ ...scheduleDate, time });
28
+ const timeArray = time.split(":");
29
+ if (timeArray[0] === "00") {
30
+ setError(true);
31
+ } else {
32
+ setError(false);
33
+ }
34
+ };
27
35
 
28
36
  const modalAction: any = { ...mainModalAction, disabled: error };
29
37
 
@@ -350,11 +350,12 @@ function getPage(pageID?: number, global?: boolean): (dispatch: Dispatch, getSta
350
350
 
351
351
  if (global) page["component"] = component;
352
352
 
353
- const pageLiveStatus = page.draftFromPage
354
- ? pageStatus.MODIFIED
355
- : isNewTranslation
356
- ? pageStatus.OFFLINE
357
- : page.liveStatus.status;
353
+ const pageLiveStatus =
354
+ page.draftFromPage && !page.publicationScheduled
355
+ ? pageStatus.MODIFIED
356
+ : isNewTranslation
357
+ ? pageStatus.OFFLINE
358
+ : page.liveStatus.status;
358
359
 
359
360
  if (isReqOk(response.status)) {
360
361
  addTemplate(page.templateId)(dispatch);
@@ -1460,14 +1461,17 @@ function setIsTranslated(isTranslated: boolean): (dispatch: Dispatch) => Promise
1460
1461
  };
1461
1462
  }
1462
1463
 
1463
- function schedulePublication(date: string | null): (dispatch: Dispatch, getState: any) => Promise<boolean> {
1464
+ function schedulePublication(
1465
+ date: string | null,
1466
+ isDraft: boolean
1467
+ ): (dispatch: Dispatch, getState: any) => Promise<boolean> {
1464
1468
  return async (dispatch, getState) => {
1465
1469
  try {
1466
1470
  const {
1467
1471
  pageEditor: { editorContent },
1468
1472
  } = getState();
1469
1473
 
1470
- const status = date ? pageStatus.SCHEDULED : pageStatus.OFFLINE;
1474
+ const status = date ? pageStatus.SCHEDULED : isDraft ? pageStatus.MODIFIED : pageStatus.OFFLINE;
1471
1475
  const updatedEditorContent = { ...editorContent, publicationScheduled: date };
1472
1476
 
1473
1477
  dispatch(setEditorContent(updatedEditorContent));
@@ -108,7 +108,7 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
108
108
  const API_URL = process.env.REACT_APP_API_ENDPOINT;
109
109
  const isPublished = liveStatus.status === pageStatus.PUBLISHED || liveStatus.status === pageStatus.UPLOAD_PENDING;
110
110
  const isAllowedToDelete = (isPublished && isAllowedToDeletePublishedPage) || (!isPublished && isAllowedToDeletePage);
111
- const isScheduledPub = !!publicationScheduled && liveStatus.status === pageStatus.SCHEDULED;
111
+ const isScheduledPub = !!publicationScheduled && (liveStatus.status === pageStatus.SCHEDULED || haveDraftPage);
112
112
 
113
113
  const publishedTooltip: Record<string, string> = {
114
114
  active: "Live",
@@ -461,7 +461,7 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
461
461
 
462
462
  const mainCopyModalAction = { title: "Copy page", onClick: copyToOtherSite, disabled: !site };
463
463
 
464
- const getLiveStatus = () => (haveDraftPage ? "modified" : liveStatus.status);
464
+ const getLiveStatus = () => (isScheduledPub ? "scheduled" : haveDraftPage ? "modified" : liveStatus.status);
465
465
 
466
466
  const mainUnpublishAction = { title: "Ok", onClick: toggleUnpublishModal };
467
467
 
@@ -71,13 +71,13 @@ const GlobalEditor = (props: IProps) => {
71
71
  const [notification, setNotification] = useState<INotification | null>(null);
72
72
  const { isDirty, setIsDirty, resetDirty } = useIsDirty(editorContent, isNewTranslation);
73
73
  const [errorPagesChecked, setErrorPagesChecked] = useState(false);
74
- const [scheduleDate, setScheduleDate] = useState({ date: "", time: "" });
74
+ const [scheduleDate, setScheduleDate] = useState({ date: "", time: "12:00 am" });
75
75
  const { isOpen: isScheduleOpen, toggleModal: toggleScheduleModal } = useModal();
76
76
  const { isOpen: isCancelScheduleOpen, toggleModal: toggleCancelScheduleModal } = useModal();
77
77
  const browserRef = useRef<HTMLDivElement>(null);
78
78
 
79
79
  const isPublished = props.pageStatus === pageStatus.PUBLISHED || props.pageStatus === pageStatus.UPLOAD_PENDING;
80
- const isDraft = props.pageStatus === pageStatus.MODIFIED;
80
+ const isDraft = props.pageStatus === pageStatus.MODIFIED || !!editorContent.draftFromPage;
81
81
  const hasDraft: boolean = editorContent && !!editorContent.haveDraftPage;
82
82
  const isLivePageChanged = editorContent && editorContent.liveChanged;
83
83
  const structuredData = editorContent ? editorContent.structuredData : "";
@@ -245,7 +245,7 @@ const GlobalEditor = (props: IProps) => {
245
245
  const handleSchedulePublication = async () => {
246
246
  const date = new Date(`${scheduleDate.date} ${scheduleDate.time}`);
247
247
  const dateString = dateToString(date, "dd/MM/yyyy HH:mm:ss");
248
- const saved = await schedulePublication(dateString);
248
+ const saved = await schedulePublication(dateString, isDraft);
249
249
  if (saved) {
250
250
  resetDirty();
251
251
  toggleScheduleModal();
@@ -253,9 +253,9 @@ const GlobalEditor = (props: IProps) => {
253
253
  };
254
254
 
255
255
  const handleCancelSchedulePublication = async () => {
256
- const saved = await schedulePublication(null);
256
+ const saved = await schedulePublication(null, isDraft);
257
257
  if (saved) {
258
- setScheduleDate({ date: "", time: "" });
258
+ setScheduleDate({ date: "", time: "12:00 am" });
259
259
  resetDirty();
260
260
  toggleCancelScheduleModal();
261
261
  }
@@ -266,7 +266,7 @@ const GlobalEditor = (props: IProps) => {
266
266
  case pageStatus.OFFLINE:
267
267
  case pageStatus.OFFLINE_PENDING:
268
268
  return {
269
- label: "Publish",
269
+ label: status === pageStatus.OFFLINE_PENDING ? "Cancel Unpublishing" : "Publish",
270
270
  action: publishPage,
271
271
  };
272
272
  case pageStatus.PUBLISHED:
@@ -277,13 +277,14 @@ const GlobalEditor = (props: IProps) => {
277
277
  action: handleCreateDraft,
278
278
  }
279
279
  : {
280
- label: "Unpublish",
280
+ label: status === pageStatus.UPLOAD_PENDING ? "Cancel publication" : "Unpublish",
281
281
  action: hasDraft ? toggleUnpublishModal : unpublishPage,
282
282
  };
283
283
  case pageStatus.MODIFIED:
284
+ case pageStatus.SCHEDULED:
284
285
  return {
285
- label: "Publish changes",
286
- action: handlePublishDraft,
286
+ label: isDraft ? "Publish changes" : "Publish",
287
+ action: isDraft ? handlePublishDraft : publishPage,
287
288
  };
288
289
  default:
289
290
  return null;
@@ -303,7 +304,7 @@ const GlobalEditor = (props: IProps) => {
303
304
 
304
305
  const menuOptions = [];
305
306
 
306
- if (isAllowedToPublishPages && !isScheduled) {
307
+ if (isAllowedToPublishPages && !isScheduled && !isPublished && props.pageStatus !== pageStatus.OFFLINE_PENDING) {
307
308
  menuOptions.push({
308
309
  label: "Schedule",
309
310
  icon: "calendar",
@@ -319,7 +320,14 @@ const GlobalEditor = (props: IProps) => {
319
320
  });
320
321
  }
321
322
 
322
- if (isAllowedToEditContentPage) {
323
+ if (
324
+ isAllowedToEditContentPage &&
325
+ (props.pageStatus === pageStatus.PUBLISHED ||
326
+ props.pageStatus === pageStatus.OFFLINE ||
327
+ props.pageStatus === pageStatus.OFFLINE_PENDING ||
328
+ props.pageStatus === pageStatus.SCHEDULED ||
329
+ (isDraft && isDirty))
330
+ ) {
323
331
  menuOptions.push({
324
332
  label: "Review",
325
333
  icon: "question",
@@ -327,7 +335,7 @@ const GlobalEditor = (props: IProps) => {
327
335
  });
328
336
  }
329
337
 
330
- if (isAllowedToEditContentPage && (isDraft || (isPublished && isDirty))) {
338
+ if (isAllowedToEditContentPage && !isScheduled && (isDraft || (isPublished && isDirty))) {
331
339
  menuOptions.push({
332
340
  label: "Discard changes",
333
341
  icon: "close",
@@ -345,7 +353,7 @@ const GlobalEditor = (props: IProps) => {
345
353
 
346
354
  if (!isDraft && isAllowedToDeletePage) {
347
355
  menuOptions.push({
348
- label: "Delete",
356
+ label: "Delete page",
349
357
  icon: "delete",
350
358
  action: removePage,
351
359
  });
@@ -691,7 +699,7 @@ interface IPageEditorDispatchProps {
691
699
  setStructuredDataFilter(filter: string | null): void;
692
700
  discardDraft(): Promise<void>;
693
701
  getUserCurrentPermissions(): void;
694
- schedulePublication(date: string | null): Promise<boolean>;
702
+ schedulePublication(date: string | null, isDraft: boolean): Promise<boolean>;
695
703
  }
696
704
 
697
705
  type IProps = IPageEditorStateProps & IPageEditorDispatchProps & RouteComponentProps;
@@ -70,7 +70,7 @@ const PageEditor = (props: IProps) => {
70
70
  const [isReadOnly, setIsReadOnly] = useState(false);
71
71
  const [selectedTab, setSelectedTab] = useState(defaultTab);
72
72
  const [notification, setNotification] = useState<INotification | null>(null);
73
- const [scheduleDate, setScheduleDate] = useState({ date: "", time: "" });
73
+ const [scheduleDate, setScheduleDate] = useState({ date: "", time: "12:00 am" });
74
74
  const { isDirty, setIsDirty, resetDirty } = useIsDirty(editorContent, isNewTranslation);
75
75
  const { isOpen, toggleModal } = useModal();
76
76
  const { isOpen: isUnpublishOpen, toggleModal: toggleUnpublishModal } = useModal();
@@ -83,7 +83,7 @@ const PageEditor = (props: IProps) => {
83
83
  const isGlobal = editorContent && editorContent.origin === "GLOBAL";
84
84
  const isEditable = editorContent && editorContent.editable;
85
85
  const isPublished = props.pageStatus === pageStatus.PUBLISHED || props.pageStatus === pageStatus.UPLOAD_PENDING;
86
- const isDraft = props.pageStatus === pageStatus.MODIFIED;
86
+ const isDraft = props.pageStatus === pageStatus.MODIFIED || !!editorContent.draftFromPage;
87
87
  const hasDraft = editorContent && editorContent.haveDraftPage;
88
88
  const isLivePageChanged = editorContent && editorContent.liveChanged;
89
89
  const isTranslated = pageLanguages.length > 1;
@@ -258,7 +258,7 @@ const PageEditor = (props: IProps) => {
258
258
  const handleSchedulePublication = async () => {
259
259
  const date = new Date(`${scheduleDate.date} ${scheduleDate.time}`);
260
260
  const dateString = dateToString(date, "dd/MM/yyyy HH:mm:ss");
261
- const saved = await schedulePublication(dateString);
261
+ const saved = await schedulePublication(dateString, isDraft);
262
262
  if (saved) {
263
263
  resetDirty();
264
264
  toggleScheduleModal();
@@ -266,9 +266,9 @@ const PageEditor = (props: IProps) => {
266
266
  };
267
267
 
268
268
  const handleCancelSchedulePublication = async () => {
269
- const saved = await schedulePublication(null);
269
+ const saved = await schedulePublication(null, isDraft);
270
270
  if (saved) {
271
- setScheduleDate({ date: "", time: "" });
271
+ setScheduleDate({ date: "", time: "12:00 am" });
272
272
  resetDirty();
273
273
  toggleCancelScheduleModal();
274
274
  }
@@ -279,7 +279,7 @@ const PageEditor = (props: IProps) => {
279
279
  case pageStatus.OFFLINE:
280
280
  case pageStatus.OFFLINE_PENDING:
281
281
  return {
282
- label: "Publish",
282
+ label: status === pageStatus.OFFLINE_PENDING ? "Cancel Unpublishing" : "Publish",
283
283
  action: publishPage,
284
284
  };
285
285
  case pageStatus.PUBLISHED:
@@ -290,15 +290,16 @@ const PageEditor = (props: IProps) => {
290
290
  action: handleCreateDraft,
291
291
  }
292
292
  : {
293
- label: "Unpublish",
293
+ label: status === pageStatus.UPLOAD_PENDING ? "Cancel publication" : "Unpublish",
294
294
  action: hasDraft ? toggleUnpublishModal : unpublishPage,
295
295
  disabled: !canBeUnpublished,
296
296
  helpText: deleteHelpText,
297
297
  };
298
298
  case pageStatus.MODIFIED:
299
+ case pageStatus.SCHEDULED:
299
300
  return {
300
- label: "Publish changes",
301
- action: handlePublishDraft,
301
+ label: isDraft ? "Publish changes" : "Publish",
302
+ action: isDraft ? handlePublishDraft : publishPage,
302
303
  };
303
304
  default:
304
305
  return null;
@@ -318,7 +319,7 @@ const PageEditor = (props: IProps) => {
318
319
 
319
320
  const menuOptions = [];
320
321
 
321
- if (isAllowedToPublishPages && !isScheduled) {
322
+ if (isAllowedToPublishPages && !isScheduled && !isPublished && props.pageStatus !== pageStatus.OFFLINE_PENDING) {
322
323
  menuOptions.push({
323
324
  label: "Schedule",
324
325
  icon: "calendar",
@@ -334,7 +335,14 @@ const PageEditor = (props: IProps) => {
334
335
  });
335
336
  }
336
337
 
337
- if (isAllowedToEditContentPage) {
338
+ if (
339
+ isAllowedToEditContentPage &&
340
+ (props.pageStatus === pageStatus.PUBLISHED ||
341
+ props.pageStatus === pageStatus.OFFLINE ||
342
+ props.pageStatus === pageStatus.OFFLINE_PENDING ||
343
+ props.pageStatus === pageStatus.SCHEDULED ||
344
+ (isDraft && isDirty))
345
+ ) {
338
346
  menuOptions.push({
339
347
  label: "Review",
340
348
  icon: "question",
@@ -350,7 +358,7 @@ const PageEditor = (props: IProps) => {
350
358
  });
351
359
  }
352
360
 
353
- if (isAllowedToEditContentPage && (isDraft || (isPublished && isDirty))) {
361
+ if (isAllowedToEditContentPage && !isScheduled && (isDraft || (isPublished && isDirty))) {
354
362
  menuOptions.push({
355
363
  label: "Discard changes",
356
364
  icon: "close",
@@ -360,7 +368,7 @@ const PageEditor = (props: IProps) => {
360
368
 
361
369
  if (!isDraft && isAllowedToDelete) {
362
370
  menuOptions.push({
363
- label: "Delete",
371
+ label: "Delete page",
364
372
  icon: "delete",
365
373
  action: toggleDeleteModal,
366
374
  });
@@ -766,7 +774,7 @@ interface IPageEditorDispatchProps {
766
774
  sendPagePing(pageID: number): Promise<boolean>;
767
775
  discardDraft(): Promise<void>;
768
776
  deleteBulk(ids: number[]): Promise<boolean>;
769
- schedulePublication(date: string | null): Promise<boolean>;
777
+ schedulePublication(date: string | null, isDraft: boolean): Promise<boolean>;
770
778
  }
771
779
 
772
780
  type IProps = IPageEditorStateProps & IPageEditorDispatchProps & RouteComponentProps;
@@ -44,7 +44,7 @@ const Form = (props: IProps) => {
44
44
 
45
45
  const [isNewStructuredData, setIsNewStructuredData] = useState(!currentStructuredDataId);
46
46
  const [notification, setNotification] = useState<INotification | null>(null);
47
- const [scheduleDate, setScheduleDate] = useState({ date: "", time: "" });
47
+ const [scheduleDate, setScheduleDate] = useState({ date: "", time: "12:00 am" });
48
48
  const { isOpen: isScheduleOpen, toggleModal: toggleScheduleModal } = useModal();
49
49
  const { isOpen: isCancelScheduleOpen, toggleModal: toggleCancelScheduleModal } = useModal();
50
50
  const { isDirty, resetDirty, setIsDirty } = useIsDirty(form);
@@ -264,7 +264,7 @@ const Form = (props: IProps) => {
264
264
 
265
265
  const handleCancelSchedulePublication = () => {
266
266
  handleSave(false, null);
267
- setScheduleDate({ date: "", time: "" });
267
+ setScheduleDate({ date: "", time: "12:00 am" });
268
268
  toggleCancelScheduleModal();
269
269
  };
270
270
 
@@ -71,7 +71,8 @@ const GlobalPageItem = (props: IGlobalPageItemProps): JSX.Element => {
71
71
  } = globalPage;
72
72
 
73
73
  const activeColumns = columns.filter((col) => col.show).map((col) => col.id);
74
- const isScheduledPub = !!publicationScheduled && liveStatus.status === pageStatus.SCHEDULED;
74
+ const isScheduledPub =
75
+ !!publicationScheduled && (liveStatus.status === pageStatus.SCHEDULED || liveStatus.status === pageStatus.MODIFIED);
75
76
 
76
77
  const initValue = { title: "", slug: "" };
77
78
  const [duplicateModalState, setDuplicateModalState] = useState(initValue);
@@ -352,7 +353,7 @@ const GlobalPageItem = (props: IGlobalPageItemProps): JSX.Element => {
352
353
 
353
354
  const availableSiteNames = availableSites && availableSites.map((site: IAvailableSites) => site.name);
354
355
 
355
- const getLiveStatus = () => (haveDraftPage ? "modified" : liveStatus.status);
356
+ const getLiveStatus = () => (isScheduledPub ? "scheduled" : haveDraftPage ? "modified" : liveStatus.status);
356
357
 
357
358
  const mainUnpublishAction = { title: "Ok", onClick: toggleUnpublishModal };
358
359
 
@@ -11,6 +11,8 @@ import {
11
11
  IDataLanguage,
12
12
  IColumn,
13
13
  ISite,
14
+ IStructuredData,
15
+ ISchemaField,
14
16
  } from "@ax/types";
15
17
  import { getActivatedDataPacksIds, getHumanLastModifiedDate, getScheduleFormatDate } from "@ax/helpers";
16
18
  import { setIsSavedData } from "@ax/forms";
@@ -135,7 +137,9 @@ const StructuredDataItem = (props: IStructuredDataItemProps): JSX.Element => {
135
137
  const currentLanguages = getCurrentLanguages();
136
138
  const activatedDataPacksIds = getActivatedDataPacksIds(activatedDataPacks);
137
139
  const isDisabled =
138
- currentStructuredData && currentStructuredData.local && !activatedDataPacksIds.includes(currentStructuredData.id);
140
+ currentStructuredData &&
141
+ currentStructuredData.dataPacks[0] &&
142
+ !activatedDataPacksIds.includes(currentStructuredData.dataPacks[0]);
139
143
 
140
144
  const availableLanguages = isDisabled || !isAllowedToCreatePages ? currentLanguages : languages;
141
145
 
@@ -276,7 +280,7 @@ interface IStructuredDataItemProps {
276
280
  structuredData: IStructuredDataContent;
277
281
  languages: ILanguage[];
278
282
  lang: { locale: string; id: number | null };
279
- currentStructuredData: any;
283
+ currentStructuredData: IStructuredData | null;
280
284
  handleClick: () => void;
281
285
  updateForm: (form: any) => void;
282
286
  setLanguage(lang: { locale: string; id: number | null }): void;
@@ -285,13 +289,13 @@ interface IStructuredDataItemProps {
285
289
  getDataContent(id: number, lang: { locale: string; id: number }): void;
286
290
  resetForm(): void;
287
291
  isSelected: boolean;
288
- onChange: (e: any) => void;
292
+ onChange: (value: ICheck) => void;
289
293
  toggleToast(): void;
290
294
  setDeletedItem(item: number): void;
291
295
  isEditable?: boolean | null;
292
296
  activatedDataPacks?: IDataPack[];
293
297
  setDataStatus(id: number, status: string): void;
294
- categoryColumns: any[];
298
+ categoryColumns: ISchemaField[];
295
299
  columns: IColumn[];
296
300
  categoryColors: any;
297
301
  addCategoryColors(cats: string[]): void;