strapi-plugin-navigation 1.1.1 → 2.0.0-beta.3

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 (129) hide show
  1. package/README.md +36 -15
  2. package/admin/src/components/EmptyView/index.js +7 -16
  3. package/admin/src/components/Item/ItemCardBadge/index.js +8 -0
  4. package/admin/src/components/Item/ItemCardHeader/Wrapper.js +21 -0
  5. package/admin/src/components/Item/ItemCardHeader/index.js +59 -0
  6. package/admin/src/components/Item/Wrapper.js +39 -0
  7. package/admin/src/components/Item/index.js +76 -124
  8. package/admin/src/components/NavigationItemList/Wrapper.js +22 -0
  9. package/admin/src/components/NavigationItemList/index.js +54 -0
  10. package/admin/src/components/PluginIcon/index.js +6 -0
  11. package/admin/src/index.js +49 -45
  12. package/admin/src/pages/App/index.js +31 -0
  13. package/admin/src/{containers → pages}/DataManagerProvider/actions.js +0 -0
  14. package/admin/src/{containers → pages}/DataManagerProvider/index.js +77 -84
  15. package/admin/src/{containers → pages}/DataManagerProvider/init.js +0 -0
  16. package/admin/src/pages/DataManagerProvider/reducer.js +125 -0
  17. package/admin/src/pages/View/components/NavigationContentHeader/index.js +18 -0
  18. package/admin/src/pages/View/components/NavigationHeader/index.js +60 -0
  19. package/admin/src/pages/View/components/NavigationItemForm/index.js +403 -0
  20. package/admin/src/{containers → pages}/View/components/NavigationItemForm/utils/form.js +2 -2
  21. package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupFooter.js +40 -0
  22. package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupHeader.js +20 -0
  23. package/admin/src/{containers → pages}/View/components/NavigationItemPopup/index.js +16 -16
  24. package/admin/src/pages/View/index.js +209 -0
  25. package/admin/src/{containers → pages}/View/utils/enums.js +0 -0
  26. package/admin/src/{containers → pages}/View/utils/form.js +1 -1
  27. package/admin/src/{containers → pages}/View/utils/index.js +0 -0
  28. package/admin/src/{containers → pages}/View/utils/parsers.js +13 -12
  29. package/admin/src/pluginId.js +3 -2
  30. package/admin/src/translations/en.json +47 -38
  31. package/admin/src/translations/fr.json +7 -1
  32. package/admin/src/utils/getTrad.js +2 -2
  33. package/package.json +14 -6
  34. package/server/bootstrap.js +41 -0
  35. package/server/config.js +8 -0
  36. package/server/content-types/audience/index.js +9 -0
  37. package/{models/audience.js → server/content-types/audience/lifecycle.js} +0 -0
  38. package/{models/audience.settings.json → server/content-types/audience/schema.json} +4 -2
  39. package/server/content-types/index.js +13 -0
  40. package/server/content-types/navigation/index.js +9 -0
  41. package/{models/navigation.js → server/content-types/navigation/lifecycle.js} +0 -0
  42. package/server/content-types/navigation/schema.js +45 -0
  43. package/server/content-types/navigation-item/index.js +9 -0
  44. package/{models/navigationItem.js → server/content-types/navigation-item/lifecycle.js} +0 -0
  45. package/{models/navigationItem.settings.json → server/content-types/navigation-item/schema.json} +16 -12
  46. package/server/content-types/navigations-items-related/index.js +9 -0
  47. package/{models/navigations_items_related.js → server/content-types/navigations-items-related/lifecycle.js} +0 -0
  48. package/{models/navigations_items_related.settings.json → server/content-types/navigations-items-related/schema.json} +4 -2
  49. package/server/controllers/index.js +7 -0
  50. package/{controllers → server/controllers}/navigation.js +7 -39
  51. package/server/routes/admin.js +38 -0
  52. package/server/routes/index.js +3 -0
  53. package/{services → server/services}/__tests__/navigation.test.js +0 -0
  54. package/server/services/index.js +7 -0
  55. package/server/services/navigation.js +463 -0
  56. package/{services → server/services}/utils/constant.js +3 -1
  57. package/server/services/utils/functions.js +103 -0
  58. package/strapi-admin.js +1 -0
  59. package/strapi-server.js +18 -0
  60. package/__mocks__/helpers/another-plugin/blog-post.settings.json +0 -31
  61. package/__mocks__/helpers/another-plugin/pages.settings.json +0 -28
  62. package/__mocks__/helpers/blog-post.settings.json +0 -31
  63. package/__mocks__/helpers/home-page.settings.json +0 -4
  64. package/__mocks__/helpers/my-homepage.settings.json +0 -27
  65. package/__mocks__/helpers/pages.settings.json +0 -27
  66. package/__mocks__/helpers/strapi.js +0 -101
  67. package/admin/src/assets/images/icon-cross-blue.svg +0 -1
  68. package/admin/src/assets/images/icon_remove.svg +0 -19
  69. package/admin/src/components/Container/index.js +0 -7
  70. package/admin/src/components/Input/index.js +0 -41
  71. package/admin/src/components/Item/CardItem.js +0 -46
  72. package/admin/src/components/Item/CardItemLevelAdd.js +0 -41
  73. package/admin/src/components/Item/CardItemLevelWrapper.js +0 -27
  74. package/admin/src/components/Item/CardItemPath.js +0 -9
  75. package/admin/src/components/Item/CardItemRestore.js +0 -19
  76. package/admin/src/components/Item/CardItemTitle.js +0 -5
  77. package/admin/src/components/Item/CardWrapper.js +0 -78
  78. package/admin/src/components/ItemFooter/CardItemError.js +0 -11
  79. package/admin/src/components/ItemFooter/CardItemRelation.js +0 -18
  80. package/admin/src/components/ItemFooter/CardItemRelationStatus.js +0 -17
  81. package/admin/src/components/ItemFooter/CardItemType.js +0 -18
  82. package/admin/src/components/ItemFooter/Wrapper.js +0 -26
  83. package/admin/src/components/ItemFooter/index.js +0 -66
  84. package/admin/src/components/ItemOrdering/CardOrderingButton.js +0 -24
  85. package/admin/src/components/ItemOrdering/Wrapper.js +0 -24
  86. package/admin/src/components/ItemOrdering/index.js +0 -36
  87. package/admin/src/components/List/Container.js +0 -34
  88. package/admin/src/components/List/ListLevelRoot.js +0 -18
  89. package/admin/src/components/List/index.js +0 -81
  90. package/admin/src/components/Option/OptionButton.js +0 -18
  91. package/admin/src/components/Option/OptionSet.js +0 -14
  92. package/admin/src/components/Option/Wrapper.js +0 -15
  93. package/admin/src/components/Option/index.js +0 -47
  94. package/admin/src/components/Search/index.js +0 -86
  95. package/admin/src/components/Select/ClearIndicator.js +0 -15
  96. package/admin/src/components/Select/DropdownIndicator.js +0 -39
  97. package/admin/src/components/Select/ErrorMessage.js +0 -10
  98. package/admin/src/components/Select/IndicatorSeparator.js +0 -3
  99. package/admin/src/components/Select/MultiValueContainer.js +0 -43
  100. package/admin/src/components/Select/StyledOption.js +0 -11
  101. package/admin/src/components/Select/index.js +0 -68
  102. package/admin/src/components/Select/utils/styles.js +0 -92
  103. package/admin/src/containers/App/Wrapper.js +0 -14
  104. package/admin/src/containers/App/index.js +0 -34
  105. package/admin/src/containers/DataManagerProvider/reducer.js +0 -136
  106. package/admin/src/containers/DetailsView/Wrapper.js +0 -21
  107. package/admin/src/containers/DetailsView/index.js +0 -111
  108. package/admin/src/containers/Initializer/index.js +0 -26
  109. package/admin/src/containers/ListView/Footer.js +0 -56
  110. package/admin/src/containers/ListView/components.js +0 -138
  111. package/admin/src/containers/ListView/index.js +0 -54
  112. package/admin/src/containers/View/FadedWrapper.js +0 -51
  113. package/admin/src/containers/View/HeaderForm.js +0 -9
  114. package/admin/src/containers/View/HeaderFormCell.js +0 -25
  115. package/admin/src/containers/View/Wrapper.js +0 -17
  116. package/admin/src/containers/View/components/NavigationItemForm/ModalFooter.js +0 -45
  117. package/admin/src/containers/View/components/NavigationItemForm/index.js +0 -427
  118. package/admin/src/containers/View/components/NavigationItemPopup/MediumPopup.js +0 -6
  119. package/admin/src/containers/View/index.js +0 -240
  120. package/admin/src/lifecycles.js +0 -3
  121. package/admin/src/permissions.js +0 -14
  122. package/config/functions/bootstrap.js +0 -138
  123. package/config/routes.json +0 -60
  124. package/config/schema.graphql.js +0 -204
  125. package/examples/audit-log-integrations.js.md +0 -38
  126. package/models/navigation.settings.json +0 -43
  127. package/public/assets/preview.png +0 -0
  128. package/services/navigation.js +0 -730
  129. package/services/utils/functions.js +0 -186
@@ -1,39 +0,0 @@
1
- import React from 'react';
2
- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
3
- import { Flex } from '@buffetjs/core';
4
- import styled from 'styled-components';
5
- import PropTypes from 'prop-types';
6
-
7
- const Wrapper = styled(Flex)`
8
- height: 100%;
9
- width: 32px;
10
- background: #fafafb;
11
- > svg {
12
- align-self: center;
13
- font-size: 11px;
14
- color: #b3b5b9;
15
- }
16
- `;
17
-
18
- const DropdownIndicator = ({ selectProps: { menuIsOpen } }) => {
19
- const icon = menuIsOpen ? 'caret-up' : 'caret-down';
20
-
21
- return (
22
- <Wrapper>
23
- <FontAwesomeIcon icon={icon} />
24
- </Wrapper>
25
- );
26
- };
27
-
28
- DropdownIndicator.propTypes = {
29
- selectProps: PropTypes.shape({
30
- menuIsOpen: PropTypes.bool.isRequired,
31
- }).isRequired,
32
- };
33
-
34
- Wrapper.defaultProps = {
35
- flexDirection: 'column',
36
- justifyContent: 'center',
37
- };
38
-
39
- export default DropdownIndicator;
@@ -1,10 +0,0 @@
1
- import styled from 'styled-components';
2
- import { ErrorMessage as Base } from '@buffetjs/styles';
3
-
4
- const ErrorMessage = styled(Base)`
5
- padding-top: 11px;
6
- padding-bottom: 0;
7
- margin-bottom: 17px;
8
- `;
9
-
10
- export default ErrorMessage;
@@ -1,3 +0,0 @@
1
- const IndicatorSeparator = () => null;
2
-
3
- export default IndicatorSeparator;
@@ -1,43 +0,0 @@
1
- import React from 'react';
2
- import { components } from 'react-select';
3
- import PropTypes from 'prop-types';
4
- import StyledOption from './StyledOption';
5
-
6
- const MultiValueContainer = ({ data, selectProps }) => {
7
- const Component = components.MultiValueContainer;
8
-
9
- const handleClick = () => {
10
- const newValue = selectProps.value.filter(option => option.value !== data.value);
11
-
12
- selectProps.onChange(newValue);
13
- };
14
-
15
- return (
16
- <Component {...data} {...selectProps}>
17
- <StyledOption
18
- label={data.label || data.name}
19
- height="24px"
20
- lineHeight="26px"
21
- margin="2px 5px 0px 0"
22
- onClick={handleClick}
23
- />
24
- </Component>
25
- );
26
- };
27
-
28
- MultiValueContainer.defaultProps = {
29
- data: {},
30
- selectProps: {
31
- value: [],
32
- },
33
- };
34
-
35
- MultiValueContainer.propTypes = {
36
- data: PropTypes.object,
37
- selectProps: PropTypes.shape({
38
- onChange: PropTypes.func.isRequired,
39
- value: PropTypes.array,
40
- }),
41
- };
42
-
43
- export default MultiValueContainer;
@@ -1,11 +0,0 @@
1
- import styled from 'styled-components';
2
- import { Option } from '@buffetjs/core';
3
-
4
- const StyledOption = styled(Option)`
5
- > span {
6
- display: block !important;
7
- color: #007eff !important;
8
- }
9
- `;
10
-
11
- export default StyledOption;
@@ -1,68 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import ReactSelect from 'react-select';
4
- import { Padded } from '@buffetjs/core';
5
- import styles from './utils/styles';
6
- import ClearIndicator from './ClearIndicator';
7
- import DropdownIndicator from './DropdownIndicator';
8
- import ErrorMessage from './ErrorMessage';
9
- import IndicatorSeparator from './IndicatorSeparator';
10
- import MultiValueContainer from './MultiValueContainer';
11
- import { useIntl } from 'react-intl';
12
-
13
- const Select = ({ error, isDisabled, isMulti, isLoading, name, onChange, onInputChange, value, inputValue, defaultValue, options }) => {
14
- const { formatMessage } = useIntl();
15
- const translatedError = error && error.id ? formatMessage(error) : null;
16
-
17
- return (
18
- <>
19
- <ReactSelect
20
- components={{
21
- ClearIndicator,
22
- DropdownIndicator,
23
- IndicatorSeparator,
24
- MultiValueContainer,
25
- }}
26
- error={error}
27
- getOptionLabel={option => option ? option.label : undefined}
28
- getOptionValue={option => option ? option.value : undefined}
29
- onChange={data => {
30
- onChange({ target: { name, value: data } });
31
- }}
32
- onInputChange={onInputChange}
33
- isClearable
34
- isDisabled={isDisabled}
35
- isLoading={isLoading}
36
- isMulti={isMulti}
37
- options={isLoading ? [] : options}
38
- styles={styles}
39
- defaultValue={defaultValue}
40
- inputValue={inputValue}
41
- value={isLoading ? undefined : value}
42
- />
43
- {error && (!value || value.length === 0) ? (
44
- <ErrorMessage>{translatedError}</ErrorMessage>
45
- ) : (
46
- <Padded top size="11px" />
47
- )}
48
- </>
49
- );
50
- };
51
-
52
- Select.defaultProps = {
53
- error: null,
54
- isDisabled: false,
55
- value: [],
56
- };
57
-
58
- Select.propTypes = {
59
- error: PropTypes.shape({
60
- id: PropTypes.string,
61
- }),
62
- isDisabled: PropTypes.bool,
63
- name: PropTypes.string.isRequired,
64
- onChange: PropTypes.func.isRequired,
65
- value: PropTypes.array,
66
- };
67
-
68
- export default Select;
@@ -1,92 +0,0 @@
1
- /* eslint-disable indent */
2
- /* eslint-disable no-nested-ternary */
3
-
4
- const styles = {
5
- control: (base, state) => {
6
- const borderRadiusStyle = state.selectProps.menuIsOpen
7
- ? {
8
- borderBottomLeftRadius: '0 !important',
9
- borderBottomRightRadius: '0 !important',
10
- }
11
- : {};
12
-
13
- const {
14
- selectProps: { error, value },
15
- } = state;
16
-
17
- let border;
18
- let borderBottom;
19
- let backgroundColor;
20
-
21
- if (state.isFocused) {
22
- border = '1px solid #78caff !important';
23
- } else if (error && (!value || value.length === 0)) {
24
- border = '1px solid #f64d0a !important';
25
- } else {
26
- border = '1px solid #e3e9f3 !important';
27
- }
28
-
29
- if (state.menuIsOpen === true) {
30
- borderBottom = '1px solid #e3e9f3 !important';
31
- }
32
-
33
- if (state.isDisabled) {
34
- backgroundColor = '#fafafb !important';
35
- }
36
-
37
- return {
38
- ...base,
39
- fontSize: 13,
40
- minHeight: 34,
41
- border,
42
- outline: 0,
43
- boxShadow: 0,
44
- borderRadius: '2px !important',
45
- ...borderRadiusStyle,
46
- borderBottom,
47
- backgroundColor,
48
- };
49
- },
50
- menu: base => {
51
- return {
52
- ...base,
53
- width: 'calc(100% - 0px)',
54
- margin: '0',
55
- paddingTop: 0,
56
- borderRadius: '2px !important',
57
- borderTopLeftRadius: '0 !important',
58
- borderTopRightRadius: '0 !important',
59
- border: '1px solid #78caff !important',
60
- boxShadow: 0,
61
- borderTop: '0 !important',
62
- fontSize: '13px',
63
- };
64
- },
65
- menuList: base => ({
66
- ...base,
67
- maxHeight: '112px',
68
- paddingTop: 2,
69
- }),
70
- option: (base, state) => {
71
- return {
72
- ...base,
73
- height: 36,
74
- backgroundColor: state.isSelected ? '#fff' : base.backgroundColor,
75
- color: state.isSelected ? '#007eff' : '#333740',
76
- fontWeight: state.isSelected ? '600' : '400',
77
- };
78
- },
79
- placeholder: base => ({
80
- ...base,
81
- marginTop: 0,
82
- marginLeft: 8,
83
- color: '#aaa',
84
- }),
85
- valueContainer: base => ({
86
- ...base,
87
- padding: '2px 4px 4px 4px',
88
- lineHeight: '18px',
89
- }),
90
- };
91
-
92
- export default styles;
@@ -1,14 +0,0 @@
1
- import styled from "styled-components";
2
-
3
- import { sizes } from "strapi-helper-plugin";
4
-
5
- const Wrapper = styled.div`
6
- min-height: calc(100vh - ${sizes.header.height});
7
- .centered {
8
- position: fixed;
9
- top: calc(50% - 13px);
10
- right: calc(50% - 13px);
11
- }
12
- `;
13
-
14
- export default Wrapper;
@@ -1,34 +0,0 @@
1
- /**
2
- *
3
- * This component is the skeleton around the actual pages, and should only
4
- * contain code that should be seen on all pages. (e.g. navigation bar)
5
- *
6
- */
7
-
8
- import React, { Suspense, lazy } from "react";
9
- import { Switch, Route } from "react-router-dom";
10
- import { NotFound, LoadingIndicatorPage } from "strapi-helper-plugin";
11
- import Wrapper from "./Wrapper";
12
- // Utils
13
- import pluginId from "../../pluginId";
14
- import DataManagerProvider from "../DataManagerProvider";
15
- // Containers
16
-
17
- const View = lazy(() => import("../View"));
18
-
19
- const App = () => {
20
- return (
21
- <Wrapper>
22
- <DataManagerProvider>
23
- <Suspense fallback={<LoadingIndicatorPage />}>
24
- <Switch>
25
- <Route path={`/plugins/${pluginId}`} component={View} exact />
26
- <Route component={NotFound} />
27
- </Switch>
28
- </Suspense>
29
- </DataManagerProvider>
30
- </Wrapper>
31
- );
32
- };
33
-
34
- export default App;
@@ -1,136 +0,0 @@
1
- import { fromJS } from "immutable";
2
- import {
3
- GET_LIST_DATA,
4
- GET_LIST_DATA_SUCCEEDED,
5
- GET_NAVIGATION_DATA,
6
- GET_NAVIGATION_DATA_SUCCEEDED,
7
- RELOAD_PLUGIN,
8
- RESET_NAVIGATION_DATA,
9
- CHANGE_NAVIGATION_POPUP_VISIBILITY,
10
- CHANGE_NAVIGATION_ITEM_POPUP_VISIBILITY,
11
- CHANGE_NAVIGATION_DATA,
12
- GET_CONFIG,
13
- GET_CONFIG_SUCCEEDED,
14
- GET_CONTENT_TYPE_ITEMS,
15
- GET_CONTENT_TYPE_ITEMS_SUCCEEDED,
16
- SUBMIT_NAVIGATION_SUCCEEDED,
17
- SUBMIT_NAVIGATION,
18
- SUBMIT_NAVIGATION_ERROR,
19
- } from './actions';
20
-
21
- const initialState = fromJS({
22
- items: [],
23
- activeItem: undefined,
24
- changedActiveItem: undefined,
25
- navigationPopupOpened: false,
26
- navigationItemPopupOpened: false,
27
- config: {},
28
- isLoading: true,
29
- isLoadingForDataToBeSet: false,
30
- isLoadingForDetailsDataToBeSet: false,
31
- isLoadingForAdditionalDataToBeSet: false,
32
- isLoadingForSubmit: false,
33
- error: undefined,
34
- });
35
-
36
- const reducer = (state, action) => {
37
- switch (action.type) {
38
- case GET_CONFIG: {
39
- return state
40
- .update("isLoadingForAdditionalDataToBeSet", () => true)
41
- .removeIn("config");
42
- }
43
- case GET_CONFIG_SUCCEEDED: {
44
- return state
45
- .update("isLoadingForAdditionalDataToBeSet", () => false)
46
- .update("config", () => fromJS(action.config));
47
- }
48
- case GET_LIST_DATA: {
49
- return state
50
- .removeIn("items")
51
- .update("isLoadingForDataToBeSet", () => true);
52
- }
53
- case GET_LIST_DATA_SUCCEEDED: {
54
- return state
55
- .update("items", () => fromJS(action.items))
56
- .update("isLoading", () => false)
57
- .update("isLoadingForDataToBeSet", () => false);
58
- }
59
- case GET_NAVIGATION_DATA: {
60
- return state
61
- .removeIn("activeItem")
62
- .removeIn("changedActiveItem")
63
- .update("isLoadingForDetailsDataToBeSet", () => true);
64
- }
65
- case GET_NAVIGATION_DATA_SUCCEEDED: {
66
- const { activeItem = {} } = action;
67
- return state
68
- .update("activeItem", () => fromJS(activeItem))
69
- .update("changedActiveItem", () => fromJS(activeItem))
70
- .update("isLoadingForDetailsDataToBeSet", () => false);
71
- }
72
- case CHANGE_NAVIGATION_DATA: {
73
- return state
74
- .update("changedActiveItem", () => action.changedActiveItem)
75
- .update("navigationPopupOpened", () =>
76
- action.forceClosePopups ? false : state.navigationPopupOpened,
77
- )
78
- .update("navigationItemPopupOpened", () =>
79
- action.forceClosePopups ? false : state.navigationItemPopupOpened,
80
- );
81
- }
82
- case RESET_NAVIGATION_DATA: {
83
- const { activeItem = {} } = action;
84
- return state.update("changedActiveItem", () => activeItem);
85
- }
86
- case GET_CONTENT_TYPE_ITEMS: {
87
- return state.update("isLoadingForAdditionalDataToBeSet", () => true);
88
- }
89
- case GET_CONTENT_TYPE_ITEMS_SUCCEEDED: {
90
- return state
91
- .update("isLoadingForAdditionalDataToBeSet", () => false)
92
- .updateIn(["config", "contentTypeItems"], () =>
93
- fromJS(action.contentTypeItems),
94
- );
95
- }
96
- case CHANGE_NAVIGATION_POPUP_VISIBILITY: {
97
- return state.update(
98
- "navigationPopupOpened",
99
- () => action.navigationPopupOpened,
100
- );
101
- }
102
- case CHANGE_NAVIGATION_ITEM_POPUP_VISIBILITY: {
103
- return state.update(
104
- "navigationItemPopupOpened",
105
- () => action.navigationItemPopupOpened,
106
- );
107
- }
108
- case SUBMIT_NAVIGATION: {
109
- return state
110
- .update('isLoadingForSubmit', () => true)
111
- .update('error', () => undefined);
112
- }
113
- case SUBMIT_NAVIGATION_SUCCEEDED: {
114
- const { navigation = {} } = action;
115
- return state
116
- .update("activeItem", () => fromJS(navigation))
117
- .update("changedActiveItem", () => fromJS(navigation))
118
- .update(
119
- 'isLoadingForSubmit',
120
- () => false,
121
- );
122
- }
123
- case SUBMIT_NAVIGATION_ERROR: {
124
- return state
125
- .update('isLoadingForSubmit', () => false)
126
- .update('error', () => action.error);
127
- }
128
- case RELOAD_PLUGIN:
129
- return initialState;
130
- default:
131
- return state;
132
- }
133
- };
134
-
135
- export default reducer;
136
- export { initialState };
@@ -1,21 +0,0 @@
1
- import styled from "styled-components";
2
-
3
- import { colors, sizes } from "strapi-helper-plugin";
4
-
5
- const Wrapper = styled.div`
6
- display: flex;
7
- flex-direction: column;
8
- width: 100%;
9
- height: calc(100vh - ${sizes.header.height});
10
- min-height: calc(100vh - ${sizes.header.height});
11
- max-height: calc(100vh - ${sizes.header.height});
12
- background-color: ${colors.leftMenu.mediumGrey};
13
- padding-top: 1.8rem;
14
- padding-left: 2rem;
15
- padding-right: 2rem;
16
-
17
- overflow-x: hidden;
18
- overflow-y: auto;
19
- `;
20
-
21
- export default Wrapper;
@@ -1,111 +0,0 @@
1
- /*
2
- *
3
- * DetailsView
4
- *
5
- */
6
-
7
- import React from "react";
8
- import { useHistory } from "react-router-dom";
9
- import { FormattedMessage } from "react-intl";
10
- import { useGlobalContext, LoadingIndicatorPage } from "strapi-helper-plugin";
11
- import useDataManager from "../../hooks/useDataManager";
12
- import { Header } from "@buffetjs/custom";
13
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
14
- import { faComments } from "@fortawesome/free-solid-svg-icons";
15
- import pluginId from "../../pluginId";
16
- import ItemDetails from "../../components/ItemDetails";
17
- import Wrapper from "./Wrapper";
18
- import CardWrapper from "../../components/ItemDetails/CardWrapper";
19
- import CardLevelWrapper from "../../components/ItemDetails/CardLevelWrapper";
20
- import EmptyView from "../../components/EmptyView";
21
- import { isNil } from "lodash";
22
- import { getTrad, getTradId } from "../../translations";
23
-
24
- const DetailsView = () => {
25
- const {
26
- activeItem,
27
- isLoadingForDetailsDataToBeSet,
28
- blockComment,
29
- blockCommentThread,
30
- resolveAbuseReport,
31
- } = useDataManager();
32
-
33
- const { formatMessage } = useGlobalContext();
34
- const { push } = useHistory();
35
-
36
- const onCommentClick = (e, id) => {
37
- e.preventDefault();
38
- e.stopPropagation();
39
- push(`/plugins/${pluginId}/display/${id}`);
40
- };
41
-
42
- const renderCommentsTree = (selected, items) => {
43
- return (
44
- <CardLevelWrapper>
45
- {items.map((item, n) => {
46
- const active = item.id === selected.id;
47
- const threadsCount = item.children && item.children.length;
48
- const hasThreads = threadsCount > 0;
49
- const clickable = !active && hasThreads && !isNil(selected.threadOf);
50
- return (
51
- <ItemDetails
52
- key={`list-item-details-${item.id || n}`}
53
- {...item}
54
- active={active}
55
- root={selected.threadOf === null}
56
- clickable={clickable}
57
- threadsCount={threadsCount}
58
- onAbuseReportResolve={resolveAbuseReport}
59
- onBlockClick={blockComment}
60
- onBlockThreadClick={blockCommentThread}
61
- onClick={(e) =>
62
- onCommentClick(e, hasThreads ? item.children[0].id : item.id)
63
- }
64
- />
65
- );
66
- })}
67
- </CardLevelWrapper>
68
- );
69
- };
70
-
71
- const { selected, level } = activeItem || {};
72
-
73
- return (
74
- <Wrapper className="col-md-8">
75
- <Header
76
- title={{
77
- label: formatMessage(getTrad('moderation.header.title')),
78
- }}
79
- content={formatMessage(getTrad('moderation.header.description'))}
80
- />
81
- {isLoadingForDetailsDataToBeSet && <LoadingIndicatorPage />}
82
- {!isLoadingForDetailsDataToBeSet && !activeItem && (
83
- <EmptyView fixPosition>
84
- <FontAwesomeIcon icon={faComments} size="5x" />
85
- <FormattedMessage id={getTradId('moderation.content.empty')} />
86
- </EmptyView>
87
- )}
88
- {activeItem && (
89
- <>
90
- {selected.threadOf && (
91
- <CardLevelWrapper>
92
- <ItemDetails
93
- {...selected.threadOf}
94
- clickable={true}
95
- root={true}
96
- onAbuseReportResolve={resolveAbuseReport}
97
- onClick={(e) => onCommentClick(e, selected.threadOf.id)}
98
- />
99
- <CardWrapper root={true}>
100
- {renderCommentsTree(selected, level)}
101
- </CardWrapper>
102
- </CardLevelWrapper>
103
- )}
104
- {!selected.threadOf && renderCommentsTree(selected, level)}
105
- </>
106
- )}
107
- </Wrapper>
108
- );
109
- };
110
-
111
- export default DetailsView;
@@ -1,26 +0,0 @@
1
- /**
2
- *
3
- * Initializer
4
- *
5
- */
6
-
7
- import { useEffect, useRef } from "react";
8
- import PropTypes from "prop-types";
9
- import pluginId from "../../pluginId";
10
-
11
- const Initializer = ({ updatePlugin }) => {
12
- const ref = useRef();
13
- ref.current = updatePlugin;
14
-
15
- useEffect(() => {
16
- ref.current(pluginId, "isReady", true);
17
- }, []);
18
-
19
- return null;
20
- };
21
-
22
- Initializer.propTypes = {
23
- updatePlugin: PropTypes.func.isRequired,
24
- };
25
-
26
- export default Initializer;
@@ -1,56 +0,0 @@
1
- import React, { memo } from "react";
2
- import { FormattedMessage } from "react-intl";
3
- import { GlobalPagination, InputSelect, sizes } from "strapi-helper-plugin";
4
- import useDataManager from "../../hooks/useDataManager";
5
- import { FooterWrapper, SelectWrapper, Label } from "./components";
6
-
7
- function Footer() {
8
- const {
9
- search: { _limit, _page },
10
- itemsTotal,
11
- handleChangeParams,
12
- } = useDataManager();
13
-
14
- return (
15
- <FooterWrapper className="row">
16
- <div className="col-6">
17
- <SelectWrapper style={{ marginBottom: `${2 * sizes.margin}px` }}>
18
- <InputSelect
19
- style={{ width: "75px", height: "32px", marginTop: "-1px" }}
20
- name="_limit"
21
- onChange={handleChangeParams}
22
- selectOptions={["10", "20", "50", "100"]}
23
- value={_limit}
24
- />
25
- <Label
26
- htmlFor="_limit"
27
- style={{
28
- textOverflow: "ellipsis",
29
- overflow: "hidden",
30
- display: "inline-block",
31
- whiteSpace: "nowrap",
32
- }}
33
- >
34
- <FormattedMessage id="components.PageFooter.select" />
35
- </Label>
36
- </SelectWrapper>
37
- </div>
38
- <div className="col-6">
39
- <GlobalPagination
40
- style={{ marginBottom: `${2 * sizes.margin}px` }}
41
- count={itemsTotal}
42
- onChangeParams={({ target: { value } }) => {
43
- handleChangeParams({ target: { name: "_page", value } });
44
- }}
45
- params={{
46
- currentPage: parseInt(_page, 10),
47
- _limit: parseInt(_limit, 10),
48
- _page: parseInt(_page, 10),
49
- }}
50
- />
51
- </div>
52
- </FooterWrapper>
53
- );
54
- }
55
-
56
- export default memo(Footer);