strapi-plugin-navigation 2.0.7 → 2.0.8

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.
@@ -27,7 +27,7 @@ const ConfirmationDialog = ({
27
27
  }) => (
28
28
  <Dialog onClose={onCancel} title={header || getMessage('components.confirmation.dialog.header', 'Confirmation')} isOpen={isVisible}>
29
29
  <DialogBody icon={<ExclamationMarkCircle />}>
30
- <Stack size={2}>
30
+ <Stack spacing={2}>
31
31
  <Flex justifyContent="center">
32
32
  <Typography id="dialog-confirm-description">{children || getMessage('components.confirmation.dialog.description')}</Typography>
33
33
  </Flex>
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import styled from 'styled-components';
2
3
 
3
4
  import { Flex } from '@strapi/design-system/Flex';
4
5
  import { IconButton } from '@strapi/design-system/IconButton';
@@ -10,18 +11,41 @@ import Wrapper from './Wrapper';
10
11
  import ItemCardBadge from '../ItemCardBadge';
11
12
  import { getMessage } from '../../../utils';
12
13
 
14
+ const IconWrapper = styled.div`
15
+ display: flex;
16
+ align-items: center;
17
+ justify-content: center;
18
+ height: ${32 / 16}rem;
19
+ width: ${32 / 16}rem;
20
+
21
+ cursor: pointer;
22
+ padding: ${({ theme }) => theme.spaces[2]};
23
+ border-radius: ${({ theme }) => theme.borderRadius};
24
+ background: ${({ theme }) => theme.colors.neutral0};
25
+ border: 1px solid ${({ theme }) => theme.colors.neutral200};
26
+
27
+ svg {
28
+ > g,
29
+ path {
30
+ fill: ${({ theme }) => theme.colors.neutral500};
31
+ }
32
+ }
33
+ `
34
+
13
35
  const ItemCardHeader = ({ title, path, icon, removed, onItemRemove, onItemEdit, onItemRestore, dragRef }) => {
14
36
  return (
15
37
  <Wrapper>
16
38
  <Flex alignItems="center">
17
- <IconButton ref={dragRef} label="Drag" icon={<Drag />} />
39
+ <IconWrapper ref={dragRef}>
40
+ <Icon as={Drag} />
41
+ </IconWrapper>
18
42
  <Typography variant="omega" fontWeight="bold">
19
43
  {title}
20
44
  </Typography>
21
45
  <Typography variant="omega" fontWeight="bold" textColor='neutral500'>
22
46
  {path}
23
47
  </Typography>
24
- <Icon as={icon}/>
48
+ <Icon as={icon} />
25
49
  </Flex>
26
50
  <Flex alignItems="center" style={{ zIndex: 2 }}>
27
51
  {removed &&
@@ -1,10 +1,8 @@
1
- import React, { useRef, useEffect } from 'react';
1
+ import React, { useRef } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { useDrag, useDrop } from 'react-dnd';
4
- import { getEmptyImage } from 'react-dnd-html5-backend';
5
- import { drop, isEmpty, isNumber } from 'lodash';
4
+ import { isEmpty, isNumber } from 'lodash';
6
5
 
7
- import { Box } from '@strapi/design-system/Box';
8
6
  import { Card, CardBody } from '@strapi/design-system/Card';
9
7
  import { Divider } from '@strapi/design-system/Divider';
10
8
  import { Flex } from '@strapi/design-system/Flex';
@@ -91,7 +89,16 @@ const Item = (props) => {
91
89
  const isAfter = hoverClientY > hoverMiddleY;
92
90
  const newOrder = isAfter ? item.order + 0.5 : item.order - 0.5;
93
91
 
92
+ if (dragIndex < dropIndex && hoverClientY < hoverMiddleY) {
93
+ return;
94
+ }
95
+ // Dragging upwards
96
+ if (dragIndex > dropIndex && hoverClientY > hoverMiddleY) {
97
+ return;
98
+ }
99
+
94
100
  onItemReOrder({ ...hoveringItem }, newOrder);
101
+ hoveringItem.order = newOrder;
95
102
  },
96
103
  collect: monitor => ({
97
104
  isOverCurrent: monitor.isOver({ shallow: true }),
@@ -145,7 +145,7 @@ const SettingsPage = () => {
145
145
  }
146
146
  />
147
147
  <ContentLayout>
148
- <Stack size={7}>
148
+ <Stack spacing={7}>
149
149
  {isRestartRequired && (
150
150
  <RestartAlert
151
151
  closeLabel={getMessage('pages.settings.actions.restart.alert.cancel')}
@@ -155,7 +155,7 @@ const SettingsPage = () => {
155
155
  {getMessage('pages.settings.actions.restart.alert.description')}
156
156
  </RestartAlert>)}
157
157
  <Box {...boxDefaultProps} >
158
- <Stack size={4}>
158
+ <Stack spacing={4}>
159
159
  <Typography variant="delta" as="h2">
160
160
  {getMessage('pages.settings.general.title')}
161
161
  </Typography>
@@ -197,7 +197,7 @@ const SettingsPage = () => {
197
197
  <AccordionToggle title={displayName} togglePosition="left" />
198
198
  <AccordionContent>
199
199
  <Box padding={6}>
200
- <Stack size={4}>
200
+ <Stack spacing={4}>
201
201
  <Select
202
202
  name={`collectionSettings-${uid}-entryLabel`}
203
203
  label={getMessage('pages.settings.form.nameField.label')}
@@ -240,7 +240,7 @@ const SettingsPage = () => {
240
240
  </Stack>
241
241
  </Box>
242
242
  <Box {...boxDefaultProps} >
243
- <Stack size={4}>
243
+ <Stack spacing={4}>
244
244
  <Typography variant="delta" as="h2">
245
245
  {getMessage('pages.settings.additional.title')}
246
246
  </Typography>
@@ -272,7 +272,7 @@ const SettingsPage = () => {
272
272
  </Stack>
273
273
  </Box>
274
274
  <Box {...boxDefaultProps} >
275
- <Stack size={4}>
275
+ <Stack spacing={4}>
276
276
  <Typography variant="delta" as="h2">
277
277
  {getMessage('pages.settings.restoring.title')}
278
278
  </Typography>
@@ -22,7 +22,7 @@ const NavigationHeader = ({
22
22
  return (
23
23
  <HeaderLayout
24
24
  primaryAction={
25
- <Stack horizontal size={2}>
25
+ <Stack horizontal spacing={2}>
26
26
  <Box width="10vw">
27
27
  <Select
28
28
  type="select"
@@ -187,7 +187,7 @@ const NavigationItemForm = ({
187
187
  const pathSourceName = isExternal ? 'externalPath' : 'path';
188
188
 
189
189
  const submitDisabled =
190
- (form.type === navigationItemType.INTERNAL && isNil(get(form, `${inputsPrefix}related`))) ||
190
+ (form.type === navigationItemType.INTERNAL && !isSingleSelected && isNil(get(form, `${inputsPrefix}related`))) ||
191
191
  (form.type === navigationItemType.WRAPPER && isNil(get(form, `${inputsPrefix}title`)));
192
192
 
193
193
  const debouncedSearch = useCallback(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strapi-plugin-navigation",
3
- "version": "2.0.7",
3
+ "version": "2.0.8",
4
4
  "description": "Strapi - Navigation plugin",
5
5
  "strapi": {
6
6
  "name": "navigation",
@@ -7,7 +7,8 @@ const {
7
7
  isString,
8
8
  get,
9
9
  isNil,
10
- isArray
10
+ isArray,
11
+ first,
11
12
  } = require('lodash');
12
13
 
13
14
  const { type: itemType } = require('../../content-types/navigation-item/lifecycle');