@griddo/ax 10.6.12 → 10.6.14

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.12",
4
+ "version": "10.6.14",
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": "082f6dfe0abb06f73d81d7fb31684f3aa7910b95"
236
+ "gitHead": "bf6a44085efc5362970097d5e1c02a2d47dade9d"
237
237
  }
@@ -27,7 +27,7 @@ describe("StatusFilter component rendering", () => {
27
27
 
28
28
  const statusFilter = screen.getByTestId("status-filter-header");
29
29
  expect(statusFilter).toBeTruthy();
30
- expect(statusFilter.textContent).toEqual("Status");
30
+ expect(statusFilter.textContent).toEqual("Last update");
31
31
  });
32
32
 
33
33
  it("should render interactive arrow if not filter selected", () => {
@@ -157,6 +157,8 @@ const ComponentContainer = (props: IComponentContainerProps): JSX.Element => {
157
157
  </>
158
158
  );
159
159
 
160
+ const dragProps = provided && isArray && arrayLength >= 2 ? provided.dragHandleProps : {};
161
+
160
162
  return isEmpty ? (
161
163
  <EmptyContainer
162
164
  whiteList={whiteList}
@@ -177,9 +179,10 @@ const ComponentContainer = (props: IComponentContainerProps): JSX.Element => {
177
179
  ref={innerRef}
178
180
  data-testid="component-container"
179
181
  {...provided?.draggableProps}
182
+ {...dragProps}
180
183
  >
181
184
  {isArray && provided && (
182
- <S.HandleWrapper {...provided?.dragHandleProps} hidden={arrayLength < 2} data-testid="handle-wrapper">
185
+ <S.HandleWrapper hidden={arrayLength < 2} data-testid="handle-wrapper">
183
186
  <S.IconHandleWrapper>
184
187
  <Icon name="drag" size="16" />
185
188
  </S.IconHandleWrapper>
@@ -43,6 +43,7 @@ const Component = styled.span<{ disabled?: boolean }>`
43
43
 
44
44
  &:hover {
45
45
  border: 1px solid ${(p) => p.theme.color.overlayHoverPrimary};
46
+ cursor: pointer;
46
47
  &:before {
47
48
  content: "";
48
49
  position: absolute;
@@ -140,6 +141,9 @@ const HandleWrapper = styled.div<{ hidden?: boolean }>`
140
141
  display: ${(p) => (p.hidden ? "none" : "flex")};
141
142
  align-items: center;
142
143
  z-index: 1;
144
+ :hover {
145
+ cursor: grab;
146
+ }
143
147
  `;
144
148
 
145
149
  const IconHandleWrapper = styled.div`
@@ -8,7 +8,7 @@ import { Icon } from "@ax/components";
8
8
 
9
9
  import * as S from "./style";
10
10
 
11
- const Item = (props: IProps) => {
11
+ const Item = (props: IProps): JSX.Element => {
12
12
  const { item, handleDelete, listLength, source, innerRef, provided } = props;
13
13
 
14
14
  const removeItem = () => {
@@ -23,9 +23,11 @@ const Item = (props: IProps) => {
23
23
  },
24
24
  ];
25
25
 
26
+ const dragProps = listLength < 2 ? {} : provided?.dragHandleProps;
27
+
26
28
  return (
27
- <S.Item ref={innerRef} data-testid="reference-field-item" {...provided?.draggableProps}>
28
- <S.HandleWrapper {...provided?.dragHandleProps} hidden={listLength < 2} data-testid="handle-wrapper">
29
+ <S.Item ref={innerRef} data-testid="reference-field-item" {...provided?.draggableProps} {...dragProps}>
30
+ <S.HandleWrapper hidden={listLength < 2} data-testid="handle-wrapper">
29
31
  <S.IconHandleWrapper>
30
32
  <Icon name="drag" size="16" />
31
33
  </S.IconHandleWrapper>
@@ -30,7 +30,6 @@ const ManualPanel = (props: IProps) => {
30
30
  site: state.site || currentSite,
31
31
  };
32
32
  const [form, setForm] = useState(initForm);
33
- const [itemSite, setItemSite] = useState<number | null>(state.site || currentSite);
34
33
  const debouncedSearch = useDebounce(state.search);
35
34
 
36
35
  const langOptions = globalLangs.map((lang) => ({ label: lang.label, value: lang.id.toString() }));
@@ -83,13 +82,9 @@ const ManualPanel = (props: IProps) => {
83
82
  if (itemSelectedID) {
84
83
  newSelIds = state.fixed.filter((a: number) => a !== itemSelectedID);
85
84
  selItems = state.selectedItems.filter((b: IStructuredDataContent) => b.id !== itemSelectedID);
86
- if (selItems.length === 0) {
87
- setItemSite(form.site);
88
- }
89
85
  } else {
90
86
  newSelIds = [...state.fixed, item.id];
91
87
  selItems = [...state.selectedItems, item];
92
- setItemSite(form.site);
93
88
  }
94
89
  const showSelected = state.showSelected && newSelIds.length === 0 ? false : state.showSelected;
95
90
  setState((state: IReferenceState) => ({ ...state, fixed: newSelIds, selectedItems: selItems, showSelected }));
@@ -131,8 +126,6 @@ const ManualPanel = (props: IProps) => {
131
126
  setState((state: IReferenceState) => ({ ...state, site: siteID }));
132
127
  };
133
128
 
134
- const hasContentFromOtherSite = state.fixed.length > 0 && form.site !== itemSite && !state.showSelected;
135
-
136
129
  return (
137
130
  <S.Wrapper>
138
131
  {state.fixed.length > 0 && (
@@ -191,17 +184,6 @@ const ManualPanel = (props: IProps) => {
191
184
  ) : (
192
185
  <S.ListWrapper>
193
186
  <S.Order>Most recent</S.Order>
194
- {state.site && !hasContentFromOtherSite && !state.showSelected && (
195
- <S.Note>
196
- You can only select content <strong>from 1 site</strong>.
197
- </S.Note>
198
- )}
199
- {hasContentFromOtherSite && (
200
- <S.Note>
201
- Select content from one site at a time. <strong>Remove previous selection</strong> to choose from other
202
- site.
203
- </S.Note>
204
- )}
205
187
  <S.ItemList>
206
188
  {showedItems &&
207
189
  showedItems.map((item: IStructuredDataContent) => {
@@ -216,8 +198,7 @@ const ManualPanel = (props: IProps) => {
216
198
  const disabled =
217
199
  (hasMaxItems && !isChecked) ||
218
200
  !!hasVersionInPageLanguage ||
219
- (maxItems && state.fixed.length >= maxItems && !isChecked) ||
220
- hasContentFromOtherSite;
201
+ (!!maxItems && state.fixed.length >= maxItems && !isChecked);
221
202
  return (
222
203
  <React.Fragment key={`${item.content.title}-${item.id}`}>
223
204
  {source && (
@@ -19,7 +19,7 @@ const StatusFilter = (props: IStatusFilterProps) => {
19
19
 
20
20
  const Header = () => (
21
21
  <S.Status isActive={sortedByDate} data-testid="status-filter-header">
22
- Status
22
+ Last update
23
23
  <S.IconsWrapper>
24
24
  {sortedByDate ? (
25
25
  <SortedStateArrow />
@@ -29,6 +29,7 @@ const CategoryItem = (props: ICategoryItemProps): JSX.Element => {
29
29
  icon,
30
30
  deleteCategoryGroup,
31
31
  hoverCheck,
32
+ isDragging,
32
33
  } = props;
33
34
 
34
35
  const { isOpen, toggleModal } = useModal();
@@ -52,7 +53,7 @@ const CategoryItem = (props: ICategoryItemProps): JSX.Element => {
52
53
  const { dataLanguages = [], content } = category;
53
54
  const isGroup = category.type === "group";
54
55
 
55
- const handleClick = () => toggleModal();
56
+ const handleClick = () => !isDragging && toggleModal();
56
57
 
57
58
  const handleCloseModal = () => {
58
59
  setTranslation(null);
@@ -61,6 +62,8 @@ const CategoryItem = (props: ICategoryItemProps): JSX.Element => {
61
62
 
62
63
  const handleOnChange = (value: ICheck) => onChange(value);
63
64
 
65
+ const handleCheckClick = (e: React.MouseEvent<HTMLDivElement>) => e.stopPropagation();
66
+
64
67
  const removeCategory = async () => {
65
68
  const categoryIDs = dataLanguages.length > 0 ? dataLanguages.map((lang: IDataLanguage) => lang.id) : category.id;
66
69
  const deleted = await deleteStructuredDataContent(categoryIDs);
@@ -186,17 +189,17 @@ const CategoryItem = (props: ICategoryItemProps): JSX.Element => {
186
189
 
187
190
  return (
188
191
  <>
189
- <S.CategoryRow role="rowgroup" selected={isSelected}>
192
+ <S.CategoryRow role="rowgroup" selected={isSelected} onClick={handleClick} {...dragHandleProps}>
190
193
  <S.HandleCell>
191
- <S.IconWrapperDrag role="cell" {...dragHandleProps}>
194
+ <S.IconWrapperDrag role="cell">
192
195
  <Icon name="drag" size="16" />
193
196
  </S.IconWrapperDrag>
194
197
  <S.IconWrapper>{icon}</S.IconWrapper>
195
198
  </S.HandleCell>
196
- <S.CheckCell role="cell">
199
+ <S.CheckCell role="cell" onClick={handleCheckClick}>
197
200
  <CheckField name="check" value={category.id} checked={isSelected || hoverCheck} onChange={handleOnChange} />
198
201
  </S.CheckCell>
199
- <S.NameCell role="cell" onClick={handleClick} clickable={allowedToEditTaxonomy} isGroup={isGroup}>
202
+ <S.NameCell role="cell" clickable={allowedToEditTaxonomy} isGroup={isGroup}>
200
203
  {isGroup && (
201
204
  <S.FolderWrapper>
202
205
  <Icon name="project" size="24" />
@@ -204,7 +207,7 @@ const CategoryItem = (props: ICategoryItemProps): JSX.Element => {
204
207
  )}
205
208
  <div>{content?.title || ""}</div>
206
209
  </S.NameCell>
207
- <S.CodeCell role="cell" onClick={handleClick} clickable={allowedToEditTaxonomy}>
210
+ <S.CodeCell role="cell" clickable={allowedToEditTaxonomy}>
208
211
  {isCategory(category) && category.content ? category.content.code : ""}
209
212
  </S.CodeCell>
210
213
  <S.SelectableCell role="cell">
@@ -265,6 +268,7 @@ interface IProps {
265
268
  icon: JSX.Element;
266
269
  dragHandleProps?: any;
267
270
  hoverCheck?: boolean;
271
+ isDragging: boolean;
268
272
  }
269
273
 
270
274
  interface IDispatchProps {
@@ -264,6 +264,7 @@ const CategoriesList = (props: IProps): JSX.Element => {
264
264
  const renderItem = ({ item, onExpand, onCollapse, provided }: RenderItemParams) => {
265
265
  const category = formatItem(item, tree);
266
266
  const isItemSelected = isSelected(category.id);
267
+ const isDragging = !!itemDragging && itemDragging !== category.id;
267
268
  return (
268
269
  <S.Draggable ref={provided.innerRef} {...provided.draggableProps}>
269
270
  <CategoryItem
@@ -279,6 +280,7 @@ const CategoriesList = (props: IProps): JSX.Element => {
279
280
  icon={getIcon(item, onExpand, onCollapse)}
280
281
  dragHandleProps={provided.dragHandleProps}
281
282
  hoverCheck={checkState.hoverCheck}
283
+ isDragging={isDragging}
282
284
  />
283
285
  </S.Draggable>
284
286
  );
@@ -127,6 +127,8 @@ const IntegrationItem = (props: IIntegrationItemProps): JSX.Element => {
127
127
  }
128
128
  };
129
129
 
130
+ const handleCheckClick = (e: React.MouseEvent<HTMLDivElement>) => e.stopPropagation();
131
+
130
132
  const isToggleDisabled =
131
133
  (integration.active && !isAllowedToDeactivateIntegrations) ||
132
134
  (!integration.active && !isAllowedToActivateIntegrations);
@@ -187,6 +189,8 @@ const IntegrationItem = (props: IIntegrationItemProps): JSX.Element => {
187
189
  />
188
190
  );
189
191
 
192
+ const dragProps = listLength < 2 ? {} : provided?.dragHandleProps;
193
+
190
194
  return (
191
195
  <>
192
196
  <S.ItemRow
@@ -195,14 +199,17 @@ const IntegrationItem = (props: IIntegrationItemProps): JSX.Element => {
195
199
  ref={innerRef}
196
200
  data-testid="integration-item-row"
197
201
  disabled={!integration.editable}
202
+ onClick={handleClick}
203
+ clickable={isAllowedToManageIntegrations}
198
204
  {...provided?.draggableProps}
205
+ {...dragProps}
199
206
  >
200
- <S.HandleWrapper {...provided?.dragHandleProps} hidden={listLength < 2} data-testid="handle-wrapper">
207
+ <S.HandleWrapper hidden={listLength < 2} data-testid="handle-wrapper">
201
208
  <S.IconHandleWrapper>
202
209
  <Icon name="drag" size="16" />
203
210
  </S.IconHandleWrapper>
204
211
  </S.HandleWrapper>
205
- <S.CheckCell role="cell" hasHandle={listLength >= 2}>
212
+ <S.CheckCell role="cell" hasHandle={listLength >= 2} onClick={handleCheckClick}>
206
213
  {!integration.editable ? (
207
214
  <Tooltip content="This cannot be selected. You can only reorder it" left={60}>
208
215
  {checkBox}
@@ -211,24 +218,20 @@ const IntegrationItem = (props: IIntegrationItemProps): JSX.Element => {
211
218
  <>{checkBox}</>
212
219
  )}
213
220
  </S.CheckCell>
214
- <S.NameCell role="cell" onClick={handleClick} clickable={isAllowedToManageIntegrations}>
221
+ <S.NameCell role="cell">
215
222
  <S.Order>#{integration.correlativeScriptOrder}</S.Order>
216
223
  <div>{integration.name}</div>
217
224
  </S.NameCell>
218
- <S.DescriptionCell role="cell" onClick={handleClick} clickable={isAllowedToManageIntegrations}>
219
- {getIntegrationDescription()}
220
- </S.DescriptionCell>
225
+ <S.DescriptionCell role="cell">{getIntegrationDescription()}</S.DescriptionCell>
221
226
  {integration.type === "addon" && (
222
227
  <>
223
- <S.AppliedOnCell role="cell" onClick={handleClick} clickable={isAllowedToManageIntegrations}>
228
+ <S.AppliedOnCell role="cell">
224
229
  <div>
225
230
  Applied on: <S.ContentPresence>{getContentPresence(integration.contentPresence)}</S.ContentPresence>
226
231
  </div>
227
232
  </S.AppliedOnCell>
228
- <S.CodeCell role="cell" onClick={handleClick} clickable={isAllowedToManageIntegrations}>
229
- {getIntegrationTag()}
230
- </S.CodeCell>
231
- <S.StateCell role="cell">
233
+ <S.CodeCell role="cell">{getIntegrationTag()}</S.CodeCell>
234
+ <S.StateCell role="cell" onClick={handleCheckClick}>
232
235
  <ToggleField
233
236
  name="state"
234
237
  value={integration.active}
@@ -12,9 +12,8 @@ const CheckCell = styled(Cell)<{ hasHandle: boolean }>`
12
12
  }
13
13
  `;
14
14
 
15
- const NameCell = styled(Cell)<{ clickable: boolean }>`
15
+ const NameCell = styled(Cell)`
16
16
  ${(p) => p.theme.textStyle.uiM};
17
- pointer-events: ${(p) => (p.clickable ? "auto" : "none")};
18
17
  color: ${(p) => p.theme.color.textHighEmphasis};
19
18
  flex: 0 0 350px;
20
19
  flex-flow: row wrap;
@@ -27,9 +26,8 @@ const Order = styled.div`
27
26
  margin-right: ${(p) => p.theme.spacing.xxs};
28
27
  `;
29
28
 
30
- const DescriptionCell = styled(Cell)<{ clickable: boolean }>`
29
+ const DescriptionCell = styled(Cell)`
31
30
  ${(p) => p.theme.textStyle.uiXS};
32
- pointer-events: ${(p) => (p.clickable ? "auto" : "none")};
33
31
  color: ${(p) => p.theme.color.textMediumEmphasis};
34
32
  flex: 1;
35
33
  a {
@@ -38,15 +36,13 @@ const DescriptionCell = styled(Cell)<{ clickable: boolean }>`
38
36
  }
39
37
  `;
40
38
 
41
- const AppliedOnCell = styled(Cell)<{ clickable: boolean }>`
39
+ const AppliedOnCell = styled(Cell)`
42
40
  ${(p) => p.theme.textStyle.uiXS};
43
- pointer-events: ${(p) => (p.clickable ? "auto" : "none")};
44
41
  color: ${(p) => p.theme.color.textMediumEmphasis};
45
42
  flex: 0 0 200px;
46
43
  `;
47
44
 
48
- const CodeCell = styled(Cell)<{ clickable: boolean }>`
49
- pointer-events: ${(p) => (p.clickable ? "auto" : "none")};
45
+ const CodeCell = styled(Cell)`
50
46
  flex: 0 0 130px;
51
47
  align-items: center;
52
48
  `;
@@ -80,9 +76,11 @@ const StyledActionMenu = styled(ActionMenu)`
80
76
  margin-left: auto;
81
77
  `;
82
78
 
83
- const ItemRow = styled(Row)<{ disabled: boolean }>`
79
+ const ItemRow = styled(Row)<{ disabled: boolean; clickable: boolean }>`
84
80
  cursor: ${(p) => (p.disabled ? "default" : "pointer")};
81
+ pointer-events: ${(p) => (p.clickable ? "auto" : "none")};
85
82
  &:hover {
83
+ cursor: pointer;
86
84
  ${StyledActionMenu} {
87
85
  opacity: 1;
88
86
  }
@@ -93,6 +91,9 @@ const HandleWrapper = styled.div<{ hidden?: boolean }>`
93
91
  padding-left: ${(p) => p.theme.spacing.xs};
94
92
  display: ${(p) => (p.hidden ? "none" : "flex")};
95
93
  align-items: center;
94
+ :hover {
95
+ cursor: grab;
96
+ }
96
97
  `;
97
98
 
98
99
  const IconHandleWrapper = styled.div`