@strapi/admin 4.6.0 → 4.6.1

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 (144) hide show
  1. package/.browserslistrc +2 -1
  2. package/admin/src/components/AuthenticatedApp/utils/api.js +5 -4
  3. package/admin/src/components/LeftMenu/index.js +9 -3
  4. package/admin/src/content-manager/components/CollectionTypeFormWrapper/index.js +20 -16
  5. package/admin/src/content-manager/components/DynamicTable/CellContent/RelationMultiple/index.js +5 -5
  6. package/admin/src/content-manager/components/EditViewDataManagerProvider/utils/findLeafByPathAndReplace.js +1 -3
  7. package/admin/src/content-manager/components/EditViewDataManagerProvider/utils/schema.js +6 -5
  8. package/admin/src/content-manager/components/InputUID/index.js +4 -4
  9. package/admin/src/content-manager/components/Inputs/index.js +0 -2
  10. package/admin/src/content-manager/components/SingleTypeFormWrapper/index.js +35 -14
  11. package/admin/src/content-manager/hooks/useFetchContentTypeLayout/index.js +4 -3
  12. package/admin/src/content-manager/hooks/useLazyComponents/index.js +9 -13
  13. package/admin/src/content-manager/hooks/useRelation/useRelation.js +4 -4
  14. package/admin/src/content-manager/pages/App/useModels.js +8 -3
  15. package/admin/src/content-manager/pages/App/utils/getContentTypeLinks.js +3 -2
  16. package/admin/src/content-manager/pages/ComponentSetttingsView/index.js +4 -4
  17. package/admin/src/content-manager/pages/EditSettingsView/utils/api.js +4 -2
  18. package/admin/src/content-manager/pages/ListSettingsView/utils/api.js +4 -2
  19. package/admin/src/content-manager/pages/ListView/index.js +9 -9
  20. package/admin/src/core/utils/index.js +0 -1
  21. package/admin/src/hooks/useFetchEnabledPlugins/utils/api.js +3 -2
  22. package/admin/src/hooks/useInjectReducer/index.js +1 -0
  23. package/admin/src/hooks/useInjectReducer/useInjectReducer.js +19 -0
  24. package/admin/src/hooks/useRegenerate/index.js +3 -3
  25. package/admin/src/hooks/useRolesList/index.js +5 -3
  26. package/admin/src/index.js +4 -3
  27. package/admin/src/pages/ProfilePage/utils/api.js +5 -3
  28. package/admin/src/pages/SettingsPage/{pages/Users/ListPage → components}/Filters/index.js +0 -0
  29. package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/index.js +6 -5
  30. package/admin/src/pages/SettingsPage/pages/ApiTokens/ListView/index.js +4 -3
  31. package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/utils/api.js +5 -3
  32. package/admin/src/pages/SettingsPage/pages/Users/EditPage/utils/api.js +6 -3
  33. package/admin/src/pages/SettingsPage/pages/Users/ListPage/ModalForm/index.js +9 -3
  34. package/admin/src/pages/SettingsPage/pages/Users/ListPage/index.js +1 -1
  35. package/admin/src/pages/SettingsPage/pages/Users/ListPage/utils/api.js +6 -3
  36. package/admin/src/pages/SettingsPage/pages/Users/components/SelectRoles/index.js +3 -2
  37. package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/index.js +3 -2
  38. package/admin/src/translations/en.json +7 -5
  39. package/admin/src/translations/eu.json +796 -0
  40. package/admin/src/translations/languageNativeNames.js +1 -0
  41. package/admin/src/translations/ru.json +9 -9
  42. package/build/1412.936ed920.chunk.js +159 -0
  43. package/build/1683.c8aa7b7c.chunk.js +268 -0
  44. package/build/2607.2e48dbf8.chunk.js +66 -0
  45. package/build/2743.6d1632f9.chunk.js +45 -0
  46. package/build/3075.dc3894fe.chunk.js +108 -0
  47. package/build/3632.0317b618.chunk.js +138 -0
  48. package/build/4318.f96a9d4d.chunk.js +30 -0
  49. package/build/{5910.a5374848.chunk.js → 4855.bd092921.chunk.js} +65 -65
  50. package/build/8633.00ccd382.chunk.js +1 -0
  51. package/build/9707.7290fd92.chunk.js +96 -0
  52. package/build/Admin-authenticatedApp.ce646f66.chunk.js +75 -0
  53. package/build/{Admin_homePage.79ab880c.chunk.js → Admin_homePage.b1730882.chunk.js} +1 -1
  54. package/build/{Admin_marketplace.eabf21b2.chunk.js → Admin_marketplace.ea0316c2.chunk.js} +2 -2
  55. package/build/Admin_pluginsPage.5c24f963.chunk.js +6 -0
  56. package/build/Admin_profilePage.59af1978.chunk.js +15 -0
  57. package/build/Admin_settingsPage.d1493824.chunk.js +178 -0
  58. package/build/admin-app.25934eaa.chunk.js +112 -0
  59. package/build/admin-edit-roles-page.446b69dc.chunk.js +1 -0
  60. package/build/admin-edit-users.2ed69bfd.chunk.js +10 -0
  61. package/build/admin-users.fc003b10.chunk.js +11 -0
  62. package/build/{api-tokens-create-page.0e686c30.chunk.js → api-tokens-create-page.d248362d.chunk.js} +1 -1
  63. package/build/{api-tokens-edit-page.d6c7487b.chunk.js → api-tokens-edit-page.8516fa20.chunk.js} +1 -1
  64. package/build/api-tokens-list-page.44a79fda.chunk.js +16 -0
  65. package/build/audit-logs-settings-page.c3dce30d.chunk.js +1 -0
  66. package/build/content-manager.35ff9726.chunk.js +1139 -0
  67. package/build/{content-type-builder-list-view.4243b2b1.chunk.js → content-type-builder-list-view.79e84b36.chunk.js} +1 -6
  68. package/build/{content-type-builder.365b6bf4.chunk.js → content-type-builder.855db321.chunk.js} +16 -15
  69. package/build/{email-settings-page.379552b1.chunk.js → email-settings-page.d1fcc7a3.chunk.js} +4 -9
  70. package/build/en-json.1f137a90.chunk.js +1 -0
  71. package/build/eu-json.fceecd8b.chunk.js +1 -0
  72. package/build/i18n-settings-page.b8d8753e.chunk.js +60 -0
  73. package/build/index.html +1 -1
  74. package/build/main.7b151630.js +4377 -0
  75. package/build/ru-json.aa5cd123.chunk.js +1 -0
  76. package/build/runtime~main.a20d633b.js +2 -0
  77. package/build/sso-settings-page.b85ad080.chunk.js +41 -0
  78. package/build/upload-settings.ef64bbf9.chunk.js +84 -0
  79. package/build/upload.c5730dfa.chunk.js +33 -0
  80. package/build/users-advanced-settings-page.fce9908e.chunk.js +8 -0
  81. package/build/users-email-settings-page.343d0ad2.chunk.js +23 -0
  82. package/build/users-providers-settings-page.e5a9a3f1.chunk.js +99 -0
  83. package/build/users-roles-settings-page.66312f31.chunk.js +30 -0
  84. package/build/webhook-edit-page.73e51e64.chunk.js +75 -0
  85. package/build/{webhook-list-page.f75ba3f2.chunk.js → webhook-list-page.1134f130.chunk.js} +1 -1
  86. package/ee/admin/pages/SettingsPage/pages/AuditLogs/ListView/ComboboxFilter/index.js +41 -0
  87. package/ee/admin/pages/SettingsPage/pages/AuditLogs/ListView/Modal/ActionBody.js +1 -3
  88. package/ee/admin/pages/SettingsPage/pages/AuditLogs/ListView/TableRows/index.js +1 -1
  89. package/ee/admin/pages/SettingsPage/pages/AuditLogs/ListView/hooks/useAuditLogsData.js +47 -0
  90. package/ee/admin/pages/SettingsPage/pages/AuditLogs/ListView/index.js +30 -31
  91. package/ee/admin/pages/SettingsPage/pages/AuditLogs/ListView/utils/getActionTypesDefaultMessages.js +7 -9
  92. package/ee/admin/pages/SettingsPage/pages/AuditLogs/ListView/utils/getDisplayedFilters.js +88 -0
  93. package/ee/admin/pages/SettingsPage/pages/Roles/ListPage/index.js +4 -2
  94. package/ee/server/migrations/audit-logs-table.js +45 -0
  95. package/ee/server/register.js +2 -0
  96. package/ee/server/services/audit-logs.js +11 -1
  97. package/package.json +27 -27
  98. package/server/controllers/admin.js +16 -0
  99. package/admin/src/content-manager/components/InputJSON/FieldWrapper.js +0 -40
  100. package/admin/src/content-manager/components/InputJSON/Label.js +0 -35
  101. package/admin/src/content-manager/components/InputJSON/components.js +0 -36
  102. package/admin/src/content-manager/components/InputJSON/index.js +0 -223
  103. package/admin/src/content-manager/components/InputJSON/jsonlint.js +0 -680
  104. package/admin/src/core/utils/axiosInstance.js +0 -40
  105. package/build/2607.ce06608e.chunk.js +0 -66
  106. package/build/2743.dea372fb.chunk.js +0 -42
  107. package/build/3075.03ebe93d.chunk.js +0 -115
  108. package/build/3632.963ac97d.chunk.js +0 -138
  109. package/build/4318.8cb388a5.chunk.js +0 -30
  110. package/build/4656.a0d43cca.chunk.js +0 -159
  111. package/build/8633.4af74a50.chunk.js +0 -1
  112. package/build/9641.a311b612.chunk.js +0 -276
  113. package/build/9707.62831b4d.chunk.js +0 -101
  114. package/build/Admin-authenticatedApp.50dc27f9.chunk.js +0 -75
  115. package/build/Admin_pluginsPage.953e796b.chunk.js +0 -6
  116. package/build/Admin_profilePage.5c2efda5.chunk.js +0 -15
  117. package/build/Admin_settingsPage.19cfb9ca.chunk.js +0 -178
  118. package/build/admin-app.34295b50.chunk.js +0 -112
  119. package/build/admin-edit-roles-page.d50d9654.chunk.js +0 -1
  120. package/build/admin-edit-users.912b856d.chunk.js +0 -10
  121. package/build/admin-users.e36e7111.chunk.js +0 -11
  122. package/build/api-tokens-list-page.1cd86136.chunk.js +0 -16
  123. package/build/audit-logs-settings-page.308a6250.chunk.js +0 -1
  124. package/build/codemirror-addon-closebrackets.71aa4bbd.chunk.js +0 -2
  125. package/build/codemirror-addon-lint-js.405f70fb.chunk.js +0 -1
  126. package/build/codemirror-addon-lint.8487ad3d.chunk.js +0 -1
  127. package/build/codemirror-addon-mark-selection.1928c849.chunk.js +0 -1
  128. package/build/codemirror-css.359a2a4b.chunk.js +0 -345
  129. package/build/codemirror-javacript.af237b68.chunk.js +0 -1
  130. package/build/codemirror-theme.2fe63a16.chunk.js +0 -33
  131. package/build/content-manager.851f40ce.chunk.js +0 -1170
  132. package/build/en-json.38d182e5.chunk.js +0 -1
  133. package/build/i18n-settings-page.3ab28b1a.chunk.js +0 -65
  134. package/build/main.9f31732e.js +0 -4454
  135. package/build/ru-json.3b411a39.chunk.js +0 -1
  136. package/build/runtime~main.2b8e2318.js +0 -2
  137. package/build/sso-settings-page.b64a44e8.chunk.js +0 -41
  138. package/build/upload-settings.6c26ff37.chunk.js +0 -89
  139. package/build/upload.2c69d238.chunk.js +0 -38
  140. package/build/users-advanced-settings-page.c4270682.chunk.js +0 -13
  141. package/build/users-email-settings-page.60422a2f.chunk.js +0 -28
  142. package/build/users-providers-settings-page.e1834060.chunk.js +0 -104
  143. package/build/users-roles-settings-page.3ef35132.chunk.js +0 -30
  144. package/build/webhook-edit-page.c0080dc1.chunk.js +0 -75
@@ -0,0 +1,47 @@
1
+ import { useQuery } from 'react-query';
2
+ import { useNotification, useFetchClient } from '@strapi/helper-plugin';
3
+ import { useLocation } from 'react-router-dom';
4
+
5
+ const useAuditLogsData = ({ canRead }) => {
6
+ const { get } = useFetchClient();
7
+ const { search } = useLocation();
8
+ const toggleNotification = useNotification();
9
+
10
+ const fetchAuditLogsPage = async ({ queryKey }) => {
11
+ const search = queryKey[1];
12
+ const { data } = await get(`/admin/audit-logs${search}`);
13
+
14
+ return data;
15
+ };
16
+
17
+ const fetchAllUsers = async () => {
18
+ const { data } = await get(`/admin/users`);
19
+
20
+ return data;
21
+ };
22
+
23
+ const queryOptions = {
24
+ enabled: canRead,
25
+ keepPreviousData: true,
26
+ retry: false,
27
+ staleTime: 1000 * 20, // 20 seconds
28
+ onError: (error) => toggleNotification({ type: 'warning', message: error.message }),
29
+ };
30
+
31
+ const {
32
+ data: auditLogs,
33
+ isLoading,
34
+ isError: isAuditLogsError,
35
+ } = useQuery(['auditLogs', search], fetchAuditLogsPage, queryOptions);
36
+
37
+ const { data: users, isError: isUsersError } = useQuery(['auditLogsUsers'], fetchAllUsers, {
38
+ ...queryOptions,
39
+ staleTime: 2 * (1000 * 60), // 2 minutes
40
+ });
41
+
42
+ const hasError = isAuditLogsError || isUsersError;
43
+
44
+ return { auditLogs, users: users?.data, isLoading, hasError };
45
+ };
46
+
47
+ export default useAuditLogsData;
@@ -4,52 +4,38 @@ import {
4
4
  SettingsPageTitle,
5
5
  DynamicTable,
6
6
  useRBAC,
7
- useNotification,
8
7
  useFocusWhenNavigate,
9
- useFetchClient,
10
8
  useQueryParams,
9
+ AnErrorOccurred,
11
10
  } from '@strapi/helper-plugin';
12
- import { HeaderLayout, ContentLayout } from '@strapi/design-system/Layout';
13
- import { Main } from '@strapi/design-system/Main';
14
- import { useLocation } from 'react-router-dom';
15
- import { useQuery } from 'react-query';
11
+ import {
12
+ Box,
13
+ HeaderLayout,
14
+ ContentLayout,
15
+ ActionLayout,
16
+ Layout,
17
+ Main,
18
+ } from '@strapi/design-system';
16
19
  import adminPermissions from '../../../../../../../admin/src/permissions';
17
20
  import TableRows from './TableRows';
18
21
  import tableHeaders from './utils/tableHeaders';
19
22
  import PaginationFooter from './PaginationFooter';
20
23
  import Modal from './Modal';
24
+ import Filters from '../../../../../../../admin/src/pages/SettingsPage/components/Filters';
25
+ import getDisplayedFilters from './utils/getDisplayedFilters';
26
+ import useAuditLogsData from './hooks/useAuditLogsData';
21
27
 
22
28
  const ListView = () => {
23
29
  const { formatMessage } = useIntl();
24
- const toggleNotification = useNotification();
25
30
  const {
26
31
  allowedActions: { canRead },
27
32
  } = useRBAC(adminPermissions.settings.auditLogs);
28
- const { get } = useFetchClient();
29
- const { search } = useLocation();
30
33
  const [{ query }, setQuery] = useQueryParams();
34
+ const { auditLogs, users, isLoading, hasError } = useAuditLogsData({ canRead });
31
35
 
32
36
  useFocusWhenNavigate();
33
37
 
34
- const fetchAuditLogsPage = async ({ queryKey }) => {
35
- const search = queryKey[1];
36
- const { data } = await get(`/admin/audit-logs${search}`);
37
-
38
- return data;
39
- };
40
-
41
- const { data, isLoading } = useQuery(['auditLogs', search], fetchAuditLogsPage, {
42
- enabled: canRead,
43
- keepPreviousData: true,
44
- retry: false,
45
- staleTime: 1000 * 10,
46
- onError() {
47
- toggleNotification({
48
- type: 'warning',
49
- message: { id: 'notification.error', defaultMessage: 'An error occured' },
50
- });
51
- },
52
- });
38
+ const displayedFilters = getDisplayedFilters({ formatMessage, users });
53
39
 
54
40
  const title = formatMessage({
55
41
  id: 'global.auditLogs',
@@ -64,6 +50,18 @@ const ListView = () => {
64
50
  },
65
51
  }));
66
52
 
53
+ if (hasError) {
54
+ return (
55
+ <Layout>
56
+ <ContentLayout>
57
+ <Box paddingTop={8}>
58
+ <AnErrorOccurred />
59
+ </Box>
60
+ </ContentLayout>
61
+ </Layout>
62
+ );
63
+ }
64
+
67
65
  return (
68
66
  <Main aria-busy={isLoading}>
69
67
  <SettingsPageTitle name={title} />
@@ -74,21 +72,22 @@ const ListView = () => {
74
72
  defaultMessage: 'Logs of all the activities that happened in your environment',
75
73
  })}
76
74
  />
75
+ <ActionLayout startActions={<Filters displayedFilters={displayedFilters} />} />
77
76
  <ContentLayout canRead={canRead}>
78
77
  <DynamicTable
79
78
  contentType="Audit logs"
80
79
  headers={headers}
81
- rows={data?.results || []}
80
+ rows={auditLogs?.results || []}
82
81
  withBulkActions
83
82
  isLoading={isLoading}
84
83
  >
85
84
  <TableRows
86
85
  headers={headers}
87
- rows={data?.results || []}
86
+ rows={auditLogs?.results || []}
88
87
  onOpenModal={(id) => setQuery({ id })}
89
88
  />
90
89
  </DynamicTable>
91
- <PaginationFooter pagination={data?.pagination} />
90
+ <PaginationFooter pagination={auditLogs?.pagination} />
92
91
  </ContentLayout>
93
92
  {query?.id && <Modal handleClose={() => setQuery({ id: null }, 'remove')} logId={query.id} />}
94
93
  </Main>
@@ -1,9 +1,9 @@
1
- const actionTypes = {
2
- 'entry.create': 'Create entry ({model})',
3
- 'entry.update': 'Update entry ({model})',
4
- 'entry.delete': 'Delete entry ({model})',
5
- 'entry.publish': 'Publish entry ({model})',
6
- 'entry.unpublish': 'Unpublish entry ({model})',
1
+ export const actionTypes = {
2
+ 'entry.create': 'Create entry{model, select, undefined {} other { ({model})}}',
3
+ 'entry.update': 'Update entry{model, select, undefined {} other { ({model})}}',
4
+ 'entry.delete': 'Delete entry{model, select, undefined {} other { ({model})}}',
5
+ 'entry.publish': 'Publish entry{model, select, undefined {} other { ({model})}}',
6
+ 'entry.unpublish': 'Unpublish entry{model, select, undefined {} other { ({model})}}',
7
7
  'media.create': 'Create media',
8
8
  'media.update': 'Update media',
9
9
  'media.delete': 'Delete media',
@@ -29,8 +29,6 @@ const actionTypes = {
29
29
  'permission.delete': 'Delete permission',
30
30
  };
31
31
 
32
- const getDefaultMessage = (value) => {
32
+ export const getDefaultMessage = (value) => {
33
33
  return actionTypes[value] || value;
34
34
  };
35
-
36
- export default getDefaultMessage;
@@ -0,0 +1,88 @@
1
+ import ComboboxFilter from '../ComboboxFilter';
2
+ import { getDefaultMessage, actionTypes } from './getActionTypesDefaultMessages';
3
+
4
+ const customOperators = [
5
+ {
6
+ intlLabel: { id: 'components.FilterOptions.FILTER_TYPES.$eq', defaultMessage: 'is' },
7
+ value: '$eq',
8
+ },
9
+ {
10
+ intlLabel: { id: 'components.FilterOptions.FILTER_TYPES.$ne', defaultMessage: 'is not' },
11
+ value: '$ne',
12
+ },
13
+ ];
14
+
15
+ const getDisplayedFilters = ({ formatMessage, users }) => {
16
+ const actionOptions = Object.keys(actionTypes).map((action) => {
17
+ return {
18
+ label: formatMessage(
19
+ {
20
+ id: `Settings.permissions.auditLogs.${action}`,
21
+ defaultMessage: getDefaultMessage(action),
22
+ },
23
+ { model: undefined }
24
+ ),
25
+ customValue: action,
26
+ };
27
+ });
28
+
29
+ const userOptions =
30
+ users &&
31
+ users.results.map((user) => {
32
+ return {
33
+ label: formatMessage(
34
+ {
35
+ id: 'Settings.permissions.auditLogs.user.fullname',
36
+ defaultMessage: '{firstname} {lastname}',
37
+ },
38
+ {
39
+ firstname: user.firstname,
40
+ lastname: user.lastname,
41
+ }
42
+ ),
43
+ // Combobox expects a string value
44
+ customValue: user.id.toString(),
45
+ };
46
+ });
47
+
48
+ return [
49
+ {
50
+ name: 'action',
51
+ metadatas: {
52
+ customOperators,
53
+ label: formatMessage({
54
+ id: 'Settings.permissions.auditLogs.action',
55
+ defaultMessage: 'Action',
56
+ }),
57
+ options: actionOptions,
58
+ customInput: ComboboxFilter,
59
+ },
60
+ fieldSchema: { type: 'enumeration' },
61
+ },
62
+ {
63
+ name: 'date',
64
+ metadatas: {
65
+ label: formatMessage({
66
+ id: 'Settings.permissions.auditLogs.date',
67
+ defaultMessage: 'Date',
68
+ }),
69
+ },
70
+ fieldSchema: { type: 'datetime' },
71
+ },
72
+ {
73
+ name: 'user',
74
+ metadatas: {
75
+ customOperators,
76
+ label: formatMessage({
77
+ id: 'Settings.permissions.auditLogs.user',
78
+ defaultMessage: 'User',
79
+ }),
80
+ options: userOptions,
81
+ customInput: ComboboxFilter,
82
+ },
83
+ fieldSchema: { type: 'relation', mainField: { name: 'id' } },
84
+ },
85
+ ];
86
+ };
87
+
88
+ export default getDisplayedFilters;
@@ -4,6 +4,7 @@ import {
4
4
  LoadingIndicatorPage,
5
5
  SearchURLQuery,
6
6
  SettingsPageTitle,
7
+ getFetchClient,
7
8
  useNotification,
8
9
  useQueryParams,
9
10
  useRBAC,
@@ -23,7 +24,6 @@ import { get } from 'lodash';
23
24
  import matchSorter from 'match-sorter';
24
25
  import { useIntl } from 'react-intl';
25
26
  import { useHistory } from 'react-router-dom';
26
- import { axiosInstance } from '../../../../../../../admin/src/core/utils';
27
27
  import { useRolesList } from '../../../../../../../admin/src/hooks';
28
28
  import adminPermissions from '../../../../../../../admin/src/permissions';
29
29
  import EmptyRole from '../../../../../../../admin/src/pages/SettingsPage/pages/Roles/ListPage/components/EmptyRole';
@@ -72,13 +72,15 @@ const useRoleActions = ({ getData, canCreate, canDelete, canUpdate }) => {
72
72
  initialState
73
73
  );
74
74
 
75
+ const { post } = getFetchClient();
76
+
75
77
  const handleDeleteData = async () => {
76
78
  try {
77
79
  dispatch({
78
80
  type: 'ON_REMOVE_ROLES',
79
81
  });
80
82
 
81
- await axiosInstance.post('/admin/roles/batch-delete', {
83
+ await post('/admin/roles/batch-delete', {
82
84
  ids: [roleToDelete],
83
85
  });
84
86
 
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Migrate the audit logs table name for users coming from v4.6.0
5
+ */
6
+ async function migrateAuditLogsTable({ oldContentTypes, contentTypes }) {
7
+ // Check if the audit logs table name was changed
8
+ const oldName = oldContentTypes?.['admin::audit-log']?.collectionName;
9
+ const newName = contentTypes['admin::audit-log']?.collectionName;
10
+ const hasRenamedAuditLogsTable = oldName === 'audit_logs' && newName === 'strapi_audit_logs';
11
+
12
+ if (!hasRenamedAuditLogsTable) {
13
+ return;
14
+ }
15
+
16
+ // Check if the previous audit log tables exist
17
+ const hasAuditLogsTable = await strapi.db.getSchemaConnection().hasTable('audit_logs');
18
+ const hasLinkTable = await strapi.db.getSchemaConnection().hasTable('audit_logs_user_links');
19
+
20
+ if (!hasAuditLogsTable || !hasLinkTable) {
21
+ return;
22
+ }
23
+
24
+ // Check if the existing tables match the expected schema
25
+ const auditLogsColumnInfo = await strapi.db.connection('audit_logs').columnInfo();
26
+ const linkColumnInfo = await strapi.db.connection('audit_logs_user_links').columnInfo();
27
+
28
+ if (
29
+ !auditLogsColumnInfo.action ||
30
+ !auditLogsColumnInfo.date ||
31
+ !auditLogsColumnInfo.payload ||
32
+ !linkColumnInfo.audit_log_id ||
33
+ !linkColumnInfo.user_id
34
+ ) {
35
+ return;
36
+ }
37
+
38
+ // Do the actual migrations
39
+ await strapi.db.getSchemaConnection().renameTable('audit_logs', 'strapi_audit_logs');
40
+ await strapi.db
41
+ .getSchemaConnection()
42
+ .renameTable('audit_logs_user_links', 'strapi_audit_logs_user_links');
43
+ }
44
+
45
+ module.exports = migrateAuditLogsTable;
@@ -2,10 +2,12 @@
2
2
 
3
3
  const { features } = require('@strapi/strapi/lib/utils/ee');
4
4
  const executeCERegister = require('../../server/register');
5
+ const migrateAuditLogsTable = require('./migrations/audit-logs-table');
5
6
  const createAuditLogsService = require('./services/audit-logs');
6
7
 
7
8
  module.exports = async ({ strapi }) => {
8
9
  if (features.isEnabled('audit-logs')) {
10
+ strapi.hook('strapi::content-types.beforeSync').register(migrateAuditLogsTable);
9
11
  const auditLogsService = createAuditLogsService(strapi);
10
12
  strapi.container.register('audit-logs', auditLogsService);
11
13
  await auditLogsService.register();
@@ -58,6 +58,16 @@ const createAuditLogsService = (strapi) => {
58
58
  const eventMap = getEventMap(defaultEvents);
59
59
 
60
60
  const processEvent = (name, ...args) => {
61
+ const state = strapi.requestContext.get()?.state;
62
+
63
+ // Ignore events with auth strategies different from admin
64
+ const isUsingAdminAuth = state?.auth?.strategy.name === 'admin';
65
+ const user = state?.user;
66
+
67
+ if (!isUsingAdminAuth || !user) {
68
+ return null;
69
+ }
70
+
61
71
  const getPayload = eventMap[name];
62
72
 
63
73
  // Ignore the event if it's not in the map
@@ -75,7 +85,7 @@ const createAuditLogsService = (strapi) => {
75
85
  action: name,
76
86
  date: new Date().toISOString(),
77
87
  payload: getPayload(...args) || {},
78
- userId: strapi.requestContext.get()?.state?.user?.id,
88
+ userId: user.id,
79
89
  };
80
90
  };
81
91
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/admin",
3
- "version": "4.6.0",
3
+ "version": "4.6.1",
4
4
  "description": "Strapi Admin",
5
5
  "repository": {
6
6
  "type": "git",
@@ -38,25 +38,25 @@
38
38
  "test:front:ce:cov": "cross-env IS_EE=false jest --config ./jest.config.front.js --coverage"
39
39
  },
40
40
  "dependencies": {
41
- "@babel/core": "7.18.10",
42
- "@babel/plugin-transform-runtime": "7.18.10",
43
- "@babel/preset-env": "7.18.10",
44
- "@babel/preset-react": "7.18.6",
45
- "@babel/runtime": "7.18.9",
41
+ "@babel/core": "^7.20.12",
42
+ "@babel/plugin-transform-runtime": "^7.19.6",
43
+ "@babel/preset-env": "^7.20.2",
44
+ "@babel/preset-react": "^7.18.6",
45
+ "@babel/runtime": "^7.20.13",
46
46
  "@casl/ability": "^5.4.3",
47
47
  "@fingerprintjs/fingerprintjs": "3.3.6",
48
48
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
49
- "@strapi/babel-plugin-switch-ee-ce": "4.6.0",
50
- "@strapi/data-transfer": "4.6.0",
51
- "@strapi/design-system": "1.6.1",
52
- "@strapi/helper-plugin": "4.6.0",
53
- "@strapi/icons": "1.6.1",
54
- "@strapi/permissions": "4.6.0",
55
- "@strapi/provider-audit-logs-local": "4.6.0",
56
- "@strapi/typescript-utils": "4.6.0",
57
- "@strapi/utils": "4.6.0",
49
+ "@strapi/babel-plugin-switch-ee-ce": "4.6.1",
50
+ "@strapi/data-transfer": "4.6.1",
51
+ "@strapi/design-system": "1.6.3",
52
+ "@strapi/helper-plugin": "4.6.1",
53
+ "@strapi/icons": "1.6.3",
54
+ "@strapi/permissions": "4.6.1",
55
+ "@strapi/provider-audit-logs-local": "4.6.1",
56
+ "@strapi/typescript-utils": "4.6.1",
57
+ "@strapi/utils": "4.6.1",
58
58
  "axios": "1.2.2",
59
- "babel-loader": "8.2.5",
59
+ "babel-loader": "^9.1.2",
60
60
  "babel-plugin-styled-components": "2.0.2",
61
61
  "bcryptjs": "2.4.3",
62
62
  "browserslist-to-esbuild": "1.2.0",
@@ -64,10 +64,10 @@
64
64
  "chokidar": "^3.5.1",
65
65
  "codemirror": "^5.65.11",
66
66
  "cross-env": "^7.0.3",
67
- "css-loader": "6.7.2",
67
+ "css-loader": "^6.7.3",
68
68
  "date-fns": "2.29.3",
69
69
  "dotenv": "8.5.1",
70
- "esbuild-loader": "^2.20.0",
70
+ "esbuild-loader": "^2.21.0",
71
71
  "execa": "^1.0.0",
72
72
  "fast-deep-equal": "3.1.3",
73
73
  "find-root": "1.1.0",
@@ -77,9 +77,9 @@
77
77
  "highlight.js": "^10.4.1",
78
78
  "history": "^4.9.0",
79
79
  "hoist-non-react-statics": "^3.3.0",
80
- "html-loader": "3.1.2",
80
+ "html-loader": "^4.2.0",
81
81
  "html-webpack-plugin": "5.5.0",
82
- "immer": "9.0.15",
82
+ "immer": "9.0.19",
83
83
  "invariant": "^2.2.4",
84
84
  "js-cookie": "2.2.1",
85
85
  "jsonwebtoken": "9.0.0",
@@ -99,7 +99,7 @@
99
99
  "markdown-it-sub": "^1.0.0",
100
100
  "markdown-it-sup": "1.0.0",
101
101
  "match-sorter": "^4.0.2",
102
- "mini-css-extract-plugin": "2.4.4",
102
+ "mini-css-extract-plugin": "2.7.2",
103
103
  "msw": "0.49.1",
104
104
  "node-polyfill-webpack-plugin": "2.0.1",
105
105
  "node-schedule": "2.1.0",
@@ -115,7 +115,7 @@
115
115
  "react-error-boundary": "3.1.4",
116
116
  "react-fast-compare": "^3.2.0",
117
117
  "react-helmet": "^6.1.0",
118
- "react-intl": "5.25.1",
118
+ "react-intl": "6.2.7",
119
119
  "react-is": "^17.0.2",
120
120
  "react-query": "3.24.3",
121
121
  "react-redux": "7.2.8",
@@ -132,9 +132,9 @@
132
132
  "style-loader": "3.3.1",
133
133
  "styled-components": "5.3.3",
134
134
  "typescript": "4.6.2",
135
- "webpack": "^5.74.0",
136
- "webpack-cli": "^4.10.0",
137
- "webpack-dev-server": "^4.9.3",
135
+ "webpack": "^5.75.0",
136
+ "webpack-cli": "^5.0.1",
137
+ "webpack-dev-server": "^4.11.1",
138
138
  "webpackbar": "^5.0.2",
139
139
  "yup": "^0.32.9"
140
140
  },
@@ -147,7 +147,7 @@
147
147
  "glob": "8.0.3",
148
148
  "react-test-renderer": "^17.0.2",
149
149
  "speed-measure-webpack-plugin": "1.5.0",
150
- "webpack-bundle-analyzer": "^4.6.1"
150
+ "webpack-bundle-analyzer": "^4.7.0"
151
151
  },
152
152
  "peerDependencies": {
153
153
  "@strapi/strapi": "^4.3.4"
@@ -165,5 +165,5 @@
165
165
  }
166
166
  }
167
167
  },
168
- "gitHead": "a9e55435c489f3379d88565bf3f729deb29bfb45"
168
+ "gitHead": "17a7845e3d453ea2e7911bda6ec25ed196dd5f16"
169
169
  }
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  const path = require('path');
4
+
5
+ const { map, values, sumBy, pipe, flatMap, propEq } = require('lodash/fp');
4
6
  const execa = require('execa');
5
7
  const _ = require('lodash');
6
8
  const { exists } = require('fs-extra');
@@ -97,11 +99,25 @@ module.exports = {
97
99
  );
98
100
  const isHostedOnStrapiCloud = env('STRAPI_HOSTING', null) === 'strapi.cloud';
99
101
 
102
+ const numberOfAllContentTypes = _.size(strapi.contentTypes);
103
+ const numberOfComponents = _.size(strapi.components);
104
+
105
+ const getNumberOfDynamicZones = () => {
106
+ return pipe(
107
+ map('attributes'),
108
+ flatMap(values),
109
+ sumBy(propEq('type', 'dynamiczone'))
110
+ )(strapi.contentTypes);
111
+ };
112
+
100
113
  return {
101
114
  data: {
102
115
  useTypescriptOnServer,
103
116
  useTypescriptOnAdmin,
104
117
  isHostedOnStrapiCloud,
118
+ numberOfAllContentTypes, // TODO: V5: This event should be renamed numberOfContentTypes in V5 as the name is already taken to describe the number of content types using i18n.
119
+ numberOfComponents,
120
+ numberOfDynamicZones: getNumberOfDynamicZones(),
105
121
  },
106
122
  };
107
123
  },
@@ -1,40 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { useIntl } from 'react-intl';
4
- import { Field } from '@strapi/design-system/Field';
5
-
6
- const FieldWrapper = ({ name, hint, error, children, required }) => {
7
- const { formatMessage } = useIntl();
8
- const errorMessage = error ? formatMessage({ id: error, defaultMessage: error }) : '';
9
-
10
- return (
11
- <Field
12
- name={name}
13
- hint={hint && formatMessage(hint)}
14
- error={errorMessage}
15
- id={name}
16
- required={required}
17
- >
18
- {children}
19
- </Field>
20
- );
21
- };
22
-
23
- FieldWrapper.defaultProps = {
24
- hint: undefined,
25
- error: '',
26
- required: false,
27
- };
28
-
29
- FieldWrapper.propTypes = {
30
- name: PropTypes.string.isRequired,
31
- hint: PropTypes.shape({
32
- id: PropTypes.string,
33
- defaultMessage: PropTypes.string,
34
- }),
35
- error: PropTypes.string,
36
- children: PropTypes.node.isRequired,
37
- required: PropTypes.bool,
38
- };
39
-
40
- export default FieldWrapper;
@@ -1,35 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { useIntl } from 'react-intl';
4
- import { FieldLabel } from '@strapi/design-system/Field';
5
-
6
- const Label = ({ intlLabel, labelAction, name }) => {
7
- const { formatMessage } = useIntl();
8
- const label = intlLabel?.id
9
- ? formatMessage(
10
- { id: intlLabel.id, defaultMessage: intlLabel.defaultMessage },
11
- { ...intlLabel.values }
12
- )
13
- : name;
14
-
15
- return <FieldLabel action={labelAction}>{label}</FieldLabel>;
16
- };
17
-
18
- Label.defaultProps = {
19
- id: undefined,
20
- intlLabel: undefined,
21
- labelAction: undefined,
22
- };
23
-
24
- Label.propTypes = {
25
- id: PropTypes.string,
26
- intlLabel: PropTypes.shape({
27
- id: PropTypes.string.isRequired,
28
- defaultMessage: PropTypes.string.isRequired,
29
- values: PropTypes.object,
30
- }),
31
- labelAction: PropTypes.element,
32
- name: PropTypes.string.isRequired,
33
- };
34
-
35
- export default Label;
@@ -1,36 +0,0 @@
1
- import styled from 'styled-components';
2
- import { Box } from '@strapi/design-system/Box';
3
-
4
- /* eslint-disable */
5
- /* stylelint-disable */
6
- const EditorWrapper = styled.div`
7
- cursor: ${({ disabled }) => (disabled ? 'not-allowed !important' : 'auto')};
8
- /* BASICS */
9
-
10
- .colored {
11
- background-color: yellow;
12
- color: black !important;
13
- }
14
-
15
- > div {
16
- border-radius: 3px;
17
- > div:last-of-type {
18
- min-height: 253px;
19
- max-height: 506px;
20
- }
21
- }
22
-
23
- .CodeMirror {
24
- /* Set height, width, borders, and global font properties here */
25
- font-size: ${14 / 16}rem;
26
- direction: ltr;
27
- z-index: 0;
28
- }
29
- `;
30
-
31
- const StyledBox = styled(Box)`
32
- border-radius: ${({ theme }) => theme.borderRadius};
33
- border: 1px solid ${({ theme, error }) => (error ? theme.colors.danger600 : 'transparent')};
34
- `;
35
-
36
- export { EditorWrapper, StyledBox };