@griddo/ax 11.1.6 → 11.1.7

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": "11.1.6",
4
+ "version": "11.1.7",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Carlos Torres <carlos.torres@secuoyas.com>",
@@ -225,5 +225,5 @@
225
225
  "publishConfig": {
226
226
  "access": "public"
227
227
  },
228
- "gitHead": "1f046739cc82fb91abeaf936919da77ed49f97be"
228
+ "gitHead": "dc9869a7fc62dcb58ae27afd05881e4e71fa8d96"
229
229
  }
@@ -22,7 +22,7 @@ const TabsWrapper = styled.div<{ headerHeight: number }>`
22
22
  background-color: ${(p) => p.theme.color.uiBackground01};
23
23
  position: sticky;
24
24
  top: ${(p) => (p.headerHeight ? `calc(63px + ${p.headerHeight}px)` : "63px")};
25
- z-index: 3;
25
+ z-index: 2;
26
26
  `;
27
27
 
28
28
  export { Wrapper, FieldWrapper, Link, TabsWrapper };
@@ -1,5 +1,4 @@
1
1
  import {
2
- dateToString,
3
2
  getDeactivatedModules,
4
3
  getDefaultSchema,
5
4
  getSchema,
@@ -55,28 +54,12 @@ const VALIDATORS = {
55
54
  return { isValid, errorCode: "ERR004" };
56
55
  }
57
56
  case "fullURL": {
58
- const re = new RegExp(
59
- "^(https?:\\/\\/)" + // protocol
60
- "((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|" + // domain name
61
- "((\\d{1,3}\\.){3}\\d{1,3}))" + // OR ip (v4) address
62
- "(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*" + // port and path
63
- "(\\?[;&a-z\\d%_.~+=-]*)?" + // query string
64
- "(\\#[-a-z\\d_]*)?$",
65
- "i"
66
- );
57
+ const re = /^(https?:\/\/)?([\w.-]+)\.([a-z]{2,6})(:[0-9]{1,5})?(\/[^?]*)?(\?([^#]*))?(#(.*))?$/i;
67
58
  const isValid = re.test(val);
68
59
  return { isValid, errorCode: "ERR005" };
69
60
  }
70
61
  case "URL": {
71
- const re = new RegExp(
72
- "^(https?:\\/\\/)?" + // protocol
73
- "((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|" + // domain name
74
- "((\\d{1,3}\\.){3}\\d{1,3}))" + // OR ip (v4) address
75
- "(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*" + // port and path
76
- "(\\?[;&a-z\\d%_.~+=-]*)?" + // query string
77
- "(\\#[-a-z\\d_]*)?$",
78
- "i"
79
- );
62
+ const re = /^(https?:\/\/)?([\w.-]+)\.([a-z]{2,6})(:[0-9]{1,5})?(\/[^?]*)?(\?([^#]*))?(#(.*))?$/i;
80
63
  const isValid = re.test(val);
81
64
  return { isValid, errorCode: "ERR006" };
82
65
  }
@@ -372,7 +355,7 @@ const findPackagesActivationErrors = (
372
355
  let isCurrentTemplateActivated = true;
373
356
  let hasDeactivatedModules = false;
374
357
 
375
- const { template } = pageEditor?.editorContent;
358
+ const { template } = pageEditor?.editorContent || {};
376
359
 
377
360
  if (template && !isGlobal) {
378
361
  const mainContentModules = template?.mainContent?.modules;
@@ -1,4 +1,4 @@
1
- import React, { memo } from "react";
1
+ import React from "react";
2
2
  import { connect } from "react-redux";
3
3
 
4
4
  import { menuActions } from "@ax/containers/Navigation";
@@ -99,6 +99,4 @@ interface IDispatchProps {
99
99
 
100
100
  type IProps = IDispatchProps & IStateProps & IFormProps;
101
101
 
102
- const memoizedForm = memo(Form);
103
-
104
- export default connect(mapStateToProps, mapDispatchToProps)(memoizedForm);
102
+ export default connect(mapStateToProps, mapDispatchToProps)(Form);
@@ -1,4 +1,4 @@
1
- import { ItemId, TreeData, TreeItem } from "@atlaskit/tree";
1
+ import { ItemId, mutateTree, TreeData, TreeDestinationPosition, TreeItem, TreeSourcePosition } from "@atlaskit/tree";
2
2
  import { isEmptyObj } from "@ax/helpers";
3
3
  import { IMenuItem } from "@ax/types";
4
4
 
@@ -85,4 +85,34 @@ const formatItem = (item: any, tree: TreeData) => {
85
85
  return formattedItem;
86
86
  };
87
87
 
88
- export { normalizeMenu, formatMenu, formatItem };
88
+ const hasLoadedChildren = (item: TreeItem) => !!item.hasChildren && item.children.length > 0;
89
+ const isLeafItem = (item: TreeItem) => !item.children.length;
90
+
91
+ const customMoveItemOnTree = (tree: TreeData, from: TreeSourcePosition, to: TreeDestinationPosition) => {
92
+ const sourceParent = tree.items[from.parentId];
93
+ const newSourceChildren = [...sourceParent.children];
94
+ const itemRemoved = newSourceChildren.splice(from.index, 1)[0];
95
+ const treeWithoutSource = mutateTree(tree, from.parentId, {
96
+ children: newSourceChildren,
97
+ hasChildren: newSourceChildren.length > 0,
98
+ isExpanded: newSourceChildren.length > 0 && sourceParent.isExpanded,
99
+ });
100
+
101
+ const destinationParent = treeWithoutSource.items[to.parentId];
102
+ const newDestinationChildren = [...destinationParent.children];
103
+
104
+ if (typeof to.index === "undefined") {
105
+ if (hasLoadedChildren(destinationParent) || isLeafItem(destinationParent)) {
106
+ newDestinationChildren.push(itemRemoved);
107
+ }
108
+ } else {
109
+ newDestinationChildren.splice(to.index, 0, itemRemoved);
110
+ }
111
+
112
+ return mutateTree(treeWithoutSource, to.parentId, {
113
+ children: newDestinationChildren,
114
+ hasChildren: true,
115
+ });
116
+ };
117
+
118
+ export { normalizeMenu, formatMenu, formatItem, customMoveItemOnTree };
@@ -3,7 +3,6 @@ import React, { useEffect, useState } from "react";
3
3
  import { connect } from "react-redux";
4
4
  import Tree, {
5
5
  mutateTree,
6
- moveItemOnTree,
7
6
  RenderItemParams,
8
7
  TreeItem,
9
8
  TreeData,
@@ -18,7 +17,7 @@ import { Loading, ErrorToast, IconAction } from "@ax/components";
18
17
  import { RouteLeavingGuard } from "@ax/guards";
19
18
  import { IMenuItem, IRootState } from "@ax/types";
20
19
 
21
- import { formatItem, formatMenu, normalizeMenu } from "./helpers";
20
+ import { customMoveItemOnTree, formatItem, formatMenu, normalizeMenu } from "./helpers";
22
21
  import Header from "./Header";
23
22
  import Item from "./Item";
24
23
  import * as S from "./style";
@@ -82,13 +81,12 @@ const ItemList = (props: IItemList): JSX.Element => {
82
81
  };
83
82
 
84
83
  const onDragEnd = (source: TreeSourcePosition, destination?: TreeDestinationPosition) => {
85
- if (!destination) return;
84
+ if (!destination || (source.parentId === destination.parentId && source.index === destination.index)) return;
86
85
 
87
- const newTree = moveItemOnTree(tree, source, destination);
86
+ const newTree = customMoveItemOnTree(tree, source, destination);
88
87
  const { parentId } = destination;
89
88
  newTree.items[parentId].isExpanded = true;
90
89
  setTree(newTree);
91
-
92
90
  const newMenu = formatMenu(newTree);
93
91
  reorderMenu(newMenu);
94
92
  };