@strapi/admin 4.4.0-rc.1 → 4.5.0-alpha.0
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/admin/src/StrapiApp.js +12 -4
- package/admin/src/components/Providers/index.js +10 -14
- package/admin/src/content-manager/components/CollectionTypeFormWrapper/index.js +11 -1
- package/admin/src/content-manager/components/DynamicTable/CellContent/RelationMultiple/index.js +11 -7
- package/admin/src/content-manager/components/DynamicTable/CellContent/index.js +6 -5
- package/admin/src/content-manager/components/DynamicTable/TableRows/index.js +5 -0
- package/admin/src/content-manager/components/DynamicTable/index.js +1 -1
- package/admin/src/content-manager/components/EditViewDataManagerProvider/index.js +23 -17
- package/admin/src/content-manager/components/EditViewDataManagerProvider/reducer.js +123 -24
- package/admin/src/content-manager/components/EditViewDataManagerProvider/utils/cleanData.js +17 -1
- package/admin/src/content-manager/components/FieldTypeIcon/index.js +1 -31
- package/admin/src/content-manager/components/Inputs/index.js +22 -36
- package/admin/src/content-manager/components/RelationInput/RelationInput.js +364 -0
- package/admin/src/content-manager/components/{SelectWrapper → RelationInput/components}/Option.js +15 -25
- package/admin/src/content-manager/components/RelationInput/components/Relation.js +48 -0
- package/admin/src/content-manager/components/RelationInput/components/RelationItem.js +52 -0
- package/admin/src/content-manager/components/RelationInput/components/RelationList.js +52 -0
- package/admin/src/content-manager/components/RelationInput/constants.js +1 -0
- package/admin/src/content-manager/components/RelationInput/index.js +1 -0
- package/admin/src/content-manager/components/RelationInputDataManager/RelationInputDataManager.js +250 -0
- package/admin/src/content-manager/components/RelationInputDataManager/constants.js +8 -0
- package/admin/src/content-manager/components/RelationInputDataManager/index.js +1 -0
- package/admin/src/content-manager/components/{SelectWrapper → RelationInputDataManager}/utils/connect.js +0 -1
- package/admin/src/content-manager/components/RelationInputDataManager/utils/getRelationLink.js +5 -0
- package/admin/src/content-manager/components/{SelectWrapper → RelationInputDataManager}/utils/index.js +1 -0
- package/admin/src/content-manager/components/RelationInputDataManager/utils/normalizeRelations.js +58 -0
- package/admin/src/content-manager/components/{SelectWrapper → RelationInputDataManager}/utils/select.js +31 -1
- package/admin/src/content-manager/components/SingleTypeFormWrapper/index.js +19 -2
- package/admin/src/content-manager/hooks/useFetchContentTypeLayout/utils/formatLayouts.js +7 -69
- package/admin/src/content-manager/hooks/useRelation/index.js +1 -0
- package/admin/src/content-manager/hooks/useRelation/useRelation.js +73 -0
- package/admin/src/content-manager/pages/EditSettingsView/components/DisplayedFields.js +4 -4
- package/admin/src/content-manager/pages/EditSettingsView/components/FormModal.js +2 -7
- package/admin/src/content-manager/pages/EditSettingsView/index.js +22 -51
- package/admin/src/content-manager/pages/EditSettingsView/reducer.js +0 -25
- package/admin/src/content-manager/pages/EditView/Header/index.js +3 -90
- package/admin/src/content-manager/pages/EditView/Header/utils/index.js +0 -1
- package/admin/src/content-manager/pages/EditView/Header/utils/select.js +0 -2
- package/admin/src/content-manager/pages/EditView/index.js +93 -155
- package/admin/src/content-manager/pages/ListView/FieldPicker/index.js +0 -1
- package/admin/src/content-manager/pages/ListView/index.js +0 -1
- package/admin/src/content-manager/pages/ListViewLayoutManager/index.js +0 -1
- package/admin/src/content-manager/utils/formatLayoutToApi.js +1 -3
- package/admin/src/core/apis/index.js +0 -1
- package/admin/src/hooks/index.js +0 -1
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/index.js +197 -215
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/utils/schema.js +1 -2
- package/admin/src/pages/SettingsPage/pages/ApiTokens/ListView/DynamicTable/DeleteButton/index.js +0 -1
- package/admin/src/pages/SettingsPage/pages/ApiTokens/ListView/DynamicTable/UpdateButton/index.js +36 -3
- package/admin/src/pages/SettingsPage/pages/ApiTokens/ListView/DynamicTable/index.js +11 -13
- package/admin/src/pages/SettingsPage/pages/ApiTokens/ListView/index.js +2 -3
- package/admin/src/pages/SettingsPage/pages/ApiTokens/ListView/utils/tableHeaders.js +8 -8
- package/admin/src/pages/SettingsPage/pages/ApiTokens/ProtectedEditView/index.js +1 -1
- package/admin/src/permissions/defaultPermissions.js +6 -2
- package/admin/src/translations/ar.json +0 -1
- package/admin/src/translations/ca.json +0 -9
- package/admin/src/translations/cs.json +0 -2
- package/admin/src/translations/de.json +0 -11
- package/admin/src/translations/dk.json +0 -11
- package/admin/src/translations/en.json +0 -28
- package/admin/src/translations/es.json +0 -11
- package/admin/src/translations/fr.json +0 -11
- package/admin/src/translations/gu.json +0 -11
- package/admin/src/translations/hi.json +0 -11
- package/admin/src/translations/hu.json +0 -10
- package/admin/src/translations/id.json +0 -10
- package/admin/src/translations/it.json +0 -10
- package/admin/src/translations/ja.json +0 -11
- package/admin/src/translations/ko.json +0 -11
- package/admin/src/translations/ml.json +0 -11
- package/admin/src/translations/ms.json +0 -2
- package/admin/src/translations/nl.json +0 -11
- package/admin/src/translations/pl.json +0 -11
- package/admin/src/translations/pt-BR.json +0 -11
- package/admin/src/translations/pt.json +0 -1
- package/admin/src/translations/ru.json +0 -10
- package/admin/src/translations/sa.json +0 -11
- package/admin/src/translations/sk.json +0 -10
- package/admin/src/translations/sv.json +0 -9
- package/admin/src/translations/th.json +0 -2
- package/admin/src/translations/tr.json +0 -1
- package/admin/src/translations/uk.json +0 -2
- package/admin/src/translations/vi.json +0 -1
- package/admin/src/translations/zh-Hans.json +0 -12
- package/admin/src/translations/zh.json +0 -11
- package/build/7098.40dcd7bf.chunk.js +1 -0
- package/build/8851.e4ac62f2.chunk.js +158 -0
- package/build/{8773.c06c24c0.chunk.js → 9311.7cc03f29.chunk.js} +291 -108
- package/build/{Admin-authenticatedApp.99b4868f.chunk.js → Admin-authenticatedApp.e39f36c9.chunk.js} +3 -3
- package/build/{Admin_homePage.6d5e3236.chunk.js → Admin_homePage.118926e0.chunk.js} +1 -1
- package/build/{Admin_profilePage.da32abbc.chunk.js → Admin_profilePage.9d50ac44.chunk.js} +1 -1
- package/build/{Admin_settingsPage.98e2a62b.chunk.js → Admin_settingsPage.98a711e5.chunk.js} +16 -16
- package/build/admin-app.4f7618a9.chunk.js +112 -0
- package/build/admin-edit-roles-page.554ba3fa.chunk.js +1 -0
- package/build/api-tokens-create-page.4c262d6e.chunk.js +1 -0
- package/build/api-tokens-edit-page.10a9d368.chunk.js +1 -0
- package/build/api-tokens-list-page.442c9f3c.chunk.js +15 -0
- package/build/{ar-json.d4cb26d9.chunk.js → ar-json.3489463d.chunk.js} +1 -1
- package/build/{ca-json.d16c1d28.chunk.js → ca-json.a16899ae.chunk.js} +1 -1
- package/build/content-manager.7d57c9d1.chunk.js +1200 -0
- package/build/content-type-builder-list-view.8cc534e0.chunk.js +194 -0
- package/build/content-type-builder-translation-en-json.201bfb78.chunk.js +1 -0
- package/build/content-type-builder.684df7a4.chunk.js +142 -0
- package/build/{cs-json.c8f28ba8.chunk.js → cs-json.ce49da5c.chunk.js} +1 -1
- package/build/{de-json.a9b514dc.chunk.js → de-json.aa6026b3.chunk.js} +1 -1
- package/build/{dk-json.09e8d145.chunk.js → dk-json.fac2bcfb.chunk.js} +1 -1
- package/build/en-json.0c69c7d7.chunk.js +1 -0
- package/build/{es-json.3a9c7c09.chunk.js → es-json.d672e181.chunk.js} +1 -1
- package/build/{fr-json.4ed1fc2c.chunk.js → fr-json.71a16175.chunk.js} +1 -1
- package/build/{gu-json.d8311297.chunk.js → gu-json.ca345cd1.chunk.js} +1 -1
- package/build/{hi-json.0edb8d29.chunk.js → hi-json.50c7e6d4.chunk.js} +1 -1
- package/build/{hu-json.7855529a.chunk.js → hu-json.e0521dcc.chunk.js} +1 -1
- package/build/{id-json.df9618f2.chunk.js → id-json.4b1ff8d6.chunk.js} +1 -1
- package/build/index.html +1 -1
- package/build/{it-json.a21bf078.chunk.js → it-json.86bac220.chunk.js} +1 -1
- package/build/{ja-json.7b0d9067.chunk.js → ja-json.4e44e36b.chunk.js} +1 -1
- package/build/{ko-json.983c1f8f.chunk.js → ko-json.1003756e.chunk.js} +1 -1
- package/build/main.b47db1a3.js +9337 -0
- package/build/{ml-json.8dd021c8.chunk.js → ml-json.c7774425.chunk.js} +1 -1
- package/build/{ms-json.836ed013.chunk.js → ms-json.ed51e902.chunk.js} +1 -1
- package/build/{nl-json.29d2eb37.chunk.js → nl-json.f58ea235.chunk.js} +1 -1
- package/build/{pl-json.1f04f00c.chunk.js → pl-json.fed96aba.chunk.js} +1 -1
- package/build/{pt-BR-json.b4bc8efe.chunk.js → pt-BR-json.073799ab.chunk.js} +1 -1
- package/build/{pt-json.c23020ab.chunk.js → pt-json.3161ca22.chunk.js} +1 -1
- package/build/{ru-json.7ab40ccf.chunk.js → ru-json.7ad2cbbf.chunk.js} +1 -1
- package/build/{runtime~main.4ee06902.js → runtime~main.feeac6d3.js} +1 -1
- package/build/{sa-json.c5a9f4ea.chunk.js → sa-json.f0f704f0.chunk.js} +1 -1
- package/build/{sk-json.e4c24c4e.chunk.js → sk-json.a848961b.chunk.js} +1 -1
- package/build/sso-settings-page.445184e0.chunk.js +1 -0
- package/build/{sv-json.c3f471ae.chunk.js → sv-json.b038acbe.chunk.js} +1 -1
- package/build/{th-json.a59ffb32.chunk.js → th-json.72e8de3d.chunk.js} +1 -1
- package/build/{tr-json.276e59fe.chunk.js → tr-json.9c44ea0c.chunk.js} +1 -1
- package/build/{uk-json.5b5b9c27.chunk.js → uk-json.c4cd2e24.chunk.js} +1 -1
- package/build/{vi-json.bf3424be.chunk.js → vi-json.f7890025.chunk.js} +1 -1
- package/build/{webhook-edit-page.9e46fc3f.chunk.js → webhook-edit-page.d2ea3351.chunk.js} +1 -1
- package/build/{zh-Hans-json.9c99f8d4.chunk.js → zh-Hans-json.03d2bda1.chunk.js} +1 -1
- package/build/{zh-json.451a0271.chunk.js → zh-json.3d0cc664.chunk.js} +1 -1
- package/package.json +7 -8
- package/server/bootstrap.js +1 -19
- package/server/config/admin-actions.js +0 -20
- package/server/content-types/api-token.js +1 -25
- package/server/content-types/index.js +0 -1
- package/server/controllers/api-token.js +1 -24
- package/server/controllers/index.js +0 -1
- package/server/routes/api-tokens.js +0 -11
- package/server/routes/index.js +0 -2
- package/server/services/api-token.js +29 -310
- package/server/services/constants.js +0 -10
- package/server/services/permission/engine-hooks.js +82 -0
- package/server/services/permission/engine.js +226 -36
- package/server/services/permission.js +1 -4
- package/server/strategies/admin.js +1 -7
- package/server/strategies/api-token.js +11 -71
- package/server/validation/api-tokens.js +2 -12
- package/admin/src/content-manager/components/SelectMany/ListItem.js +0 -102
- package/admin/src/content-manager/components/SelectMany/index.js +0 -148
- package/admin/src/content-manager/components/SelectOne/SingleValue.js +0 -67
- package/admin/src/content-manager/components/SelectOne/index.js +0 -97
- package/admin/src/content-manager/components/SelectWrapper/Label.js +0 -60
- package/admin/src/content-manager/components/SelectWrapper/index.js +0 -356
- package/admin/src/content-manager/pages/EditSettingsView/components/RelationalFieldButton.js +0 -135
- package/admin/src/content-manager/pages/EditSettingsView/components/RelationalFields.js +0 -103
- package/admin/src/content-manager/pages/EditView/Header/utils/getDraftRelations.js +0 -62
- package/admin/src/contexts/ApiTokenPermissions/index.js +0 -24
- package/admin/src/core/apis/CustomFields.js +0 -80
- package/admin/src/hooks/useRegenerate/index.js +0 -34
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/ActionBoundRoutes/index.js +0 -56
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/BoundRoute/getMethodColor.js +0 -41
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/BoundRoute/index.js +0 -72
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/CollapsableContentType/CheckBoxWrapper.js +0 -30
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/CollapsableContentType/index.js +0 -150
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/ContenTypesSection/index.js +0 -37
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/FormApiTokenContainer/index.js +0 -254
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/FormBody/index.js +0 -77
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/FormHead/index.js +0 -85
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/Permissions/index.js +0 -40
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/Regenerate/index.js +0 -68
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/init.js +0 -13
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/reducer.js +0 -72
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/utils/getDateOfExpiration.js +0 -16
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/utils/index.js +0 -5
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/utils/transformPermissionsData.js +0 -36
- package/admin/src/pages/SettingsPage/pages/ApiTokens/ListView/DynamicTable/DefaultButton/index.js +0 -63
- package/admin/src/pages/SettingsPage/pages/ApiTokens/ListView/DynamicTable/ReadButton/index.js +0 -19
- package/build/1669.d1b29c28.chunk.js +0 -1
- package/build/4318.7d167b58.chunk.js +0 -30
- package/build/524.40377968.chunk.js +0 -644
- package/build/7379.d246dd38.chunk.js +0 -1
- package/build/admin-app.a61d5c2e.chunk.js +0 -112
- package/build/admin-edit-roles-page.4dd6bcb9.chunk.js +0 -1
- package/build/api-tokens-create-page.93dd0689.chunk.js +0 -1
- package/build/api-tokens-edit-page.b0adac81.chunk.js +0 -1
- package/build/api-tokens-list-page.bb36535f.chunk.js +0 -16
- package/build/content-manager.feb0d540.chunk.js +0 -1178
- package/build/content-type-builder-list-view.5b3cd768.chunk.js +0 -194
- package/build/content-type-builder-translation-en-json.f985c9c4.chunk.js +0 -1
- package/build/content-type-builder.a684b2e8.chunk.js +0 -145
- package/build/en-json.a9918c93.chunk.js +0 -1
- package/build/main.e4065f58.js +0 -9337
- package/build/sso-settings-page.9ceb0140.chunk.js +0 -1
- package/server/content-types/api-token-permission.js +0 -36
- package/server/controllers/content-api.js +0 -15
- package/server/routes/content-api.js +0 -20
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import invariant from 'invariant';
|
|
2
|
-
|
|
3
|
-
const ALLOWED_TYPES = [
|
|
4
|
-
'biginteger',
|
|
5
|
-
'boolean',
|
|
6
|
-
'date',
|
|
7
|
-
'datetime',
|
|
8
|
-
'decimal',
|
|
9
|
-
'email',
|
|
10
|
-
'enumeration',
|
|
11
|
-
'float',
|
|
12
|
-
'integer',
|
|
13
|
-
'json',
|
|
14
|
-
'password',
|
|
15
|
-
'richtext',
|
|
16
|
-
'string',
|
|
17
|
-
'text',
|
|
18
|
-
'time',
|
|
19
|
-
'timestamp',
|
|
20
|
-
'uid',
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
class CustomFields {
|
|
24
|
-
constructor() {
|
|
25
|
-
this.customFields = {};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
register(customFields) {
|
|
29
|
-
if (Array.isArray(customFields)) {
|
|
30
|
-
// If several custom fields are passed, register them one by one
|
|
31
|
-
customFields.forEach((customField) => {
|
|
32
|
-
this.register(customField);
|
|
33
|
-
});
|
|
34
|
-
} else {
|
|
35
|
-
// Handle individual custom field
|
|
36
|
-
const { name, pluginId, type, intlLabel, intlDescription, components } = customFields;
|
|
37
|
-
|
|
38
|
-
// Ensure required attributes are provided
|
|
39
|
-
invariant(name, 'A name must be provided');
|
|
40
|
-
invariant(type, 'A type must be provided');
|
|
41
|
-
invariant(intlLabel, 'An intlLabel must be provided');
|
|
42
|
-
invariant(intlDescription, 'An intlDescription must be provided');
|
|
43
|
-
invariant(components, 'A components object must be provided');
|
|
44
|
-
invariant(components.Input, 'An Input component must be provided');
|
|
45
|
-
|
|
46
|
-
// Ensure the type is valid
|
|
47
|
-
invariant(
|
|
48
|
-
ALLOWED_TYPES.includes(type),
|
|
49
|
-
`Custom field type: '${type}' is not a valid Strapi type or it can't be used with a Custom Field`
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
// Ensure name has no special characters
|
|
53
|
-
const isValidObjectKey = /^(?![0-9])[a-zA-Z0-9$_-]+$/g;
|
|
54
|
-
invariant(
|
|
55
|
-
isValidObjectKey.test(name),
|
|
56
|
-
`Custom field name: '${name}' is not a valid object key`
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
// When no plugin is specified, default to the global namespace
|
|
60
|
-
const uid = pluginId ? `plugin::${pluginId}.${name}` : `global::${name}`;
|
|
61
|
-
|
|
62
|
-
// Ensure the uid is unique
|
|
63
|
-
const uidAlreadyUsed = Object.prototype.hasOwnProperty.call(this.customFields, uid);
|
|
64
|
-
invariant(!uidAlreadyUsed, `Custom field: '${uid}' has already been registered`);
|
|
65
|
-
|
|
66
|
-
this.customFields[uid] = customFields;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
getAll() {
|
|
71
|
-
return this.customFields;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
get(uid) {
|
|
75
|
-
return this.customFields[uid];
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Export an instance since it's a singleton
|
|
80
|
-
export default new CustomFields();
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { get } from 'lodash';
|
|
3
|
-
import { useNotification } from '@strapi/helper-plugin';
|
|
4
|
-
import { axiosInstance } from '../../core/utils';
|
|
5
|
-
|
|
6
|
-
const useRegenerate = (id, onRegenerate) => {
|
|
7
|
-
const [isLoadingConfirmation, setIsLoadingConfirmation] = useState(false);
|
|
8
|
-
const toggleNotification = useNotification();
|
|
9
|
-
|
|
10
|
-
const regenerateData = async () => {
|
|
11
|
-
try {
|
|
12
|
-
const {
|
|
13
|
-
data: {
|
|
14
|
-
data: { accessKey },
|
|
15
|
-
},
|
|
16
|
-
} = await axiosInstance.post(`/admin/api-tokens/${id}/regenerate`);
|
|
17
|
-
setIsLoadingConfirmation(false);
|
|
18
|
-
onRegenerate(accessKey);
|
|
19
|
-
} catch (error) {
|
|
20
|
-
setIsLoadingConfirmation(false);
|
|
21
|
-
toggleNotification({
|
|
22
|
-
type: 'warning',
|
|
23
|
-
message: get(error, 'response.data.message', 'notification.error'),
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
regenerateData,
|
|
30
|
-
isLoadingConfirmation,
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export default useRegenerate;
|
package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/ActionBoundRoutes/index.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { useIntl } from 'react-intl';
|
|
3
|
-
import { Typography } from '@strapi/design-system/Typography';
|
|
4
|
-
import { Stack } from '@strapi/design-system/Stack';
|
|
5
|
-
import { GridItem } from '@strapi/design-system/Grid';
|
|
6
|
-
import BoundRoute from '../BoundRoute';
|
|
7
|
-
import { useApiTokenPermissionsContext } from '../../../../../../../contexts/ApiTokenPermissions';
|
|
8
|
-
|
|
9
|
-
const ActionBoundRoutes = () => {
|
|
10
|
-
const {
|
|
11
|
-
value: { selectedAction, routes },
|
|
12
|
-
} = useApiTokenPermissionsContext();
|
|
13
|
-
const { formatMessage } = useIntl();
|
|
14
|
-
const actionSection = selectedAction?.split('.')[0];
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<GridItem
|
|
18
|
-
col={5}
|
|
19
|
-
background="neutral150"
|
|
20
|
-
paddingTop={6}
|
|
21
|
-
paddingBottom={6}
|
|
22
|
-
paddingLeft={7}
|
|
23
|
-
paddingRight={7}
|
|
24
|
-
style={{ minHeight: '100%' }}
|
|
25
|
-
>
|
|
26
|
-
{selectedAction ? (
|
|
27
|
-
<Stack spacing={2}>
|
|
28
|
-
{routes[actionSection]?.map((route) => {
|
|
29
|
-
return route.config.auth?.scope?.includes(selectedAction) ||
|
|
30
|
-
route.handler === selectedAction ? (
|
|
31
|
-
<BoundRoute key={route.handler} route={route} />
|
|
32
|
-
) : null;
|
|
33
|
-
})}
|
|
34
|
-
</Stack>
|
|
35
|
-
) : (
|
|
36
|
-
<Stack spacing={2}>
|
|
37
|
-
<Typography variant="delta" as="h3">
|
|
38
|
-
{formatMessage({
|
|
39
|
-
id: 'Settings.apiTokens.createPage.permissions.header.title',
|
|
40
|
-
defaultMessage: 'Advanced settings',
|
|
41
|
-
})}
|
|
42
|
-
</Typography>
|
|
43
|
-
<Typography as="p" textColor="neutral600">
|
|
44
|
-
{formatMessage({
|
|
45
|
-
id: 'Settings.apiTokens.createPage.permissions.header.hint',
|
|
46
|
-
defaultMessage:
|
|
47
|
-
"Select the application's actions or the plugin's actions and click on the cog icon to display the bound route",
|
|
48
|
-
})}
|
|
49
|
-
</Typography>
|
|
50
|
-
</Stack>
|
|
51
|
-
)}
|
|
52
|
-
</GridItem>
|
|
53
|
-
);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export default ActionBoundRoutes;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
const getMethodColor = (verb) => {
|
|
2
|
-
switch (verb) {
|
|
3
|
-
case 'POST': {
|
|
4
|
-
return {
|
|
5
|
-
text: 'success600',
|
|
6
|
-
border: 'success200',
|
|
7
|
-
background: 'success100',
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
case 'GET': {
|
|
11
|
-
return {
|
|
12
|
-
text: 'secondary600',
|
|
13
|
-
border: 'secondary200',
|
|
14
|
-
background: 'secondary100',
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
case 'PUT': {
|
|
18
|
-
return {
|
|
19
|
-
text: 'warning600',
|
|
20
|
-
border: 'warning200',
|
|
21
|
-
background: 'warning100',
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
case 'DELETE': {
|
|
25
|
-
return {
|
|
26
|
-
text: 'danger600',
|
|
27
|
-
border: 'danger200',
|
|
28
|
-
background: 'danger100',
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
default: {
|
|
32
|
-
return {
|
|
33
|
-
text: 'neutral600',
|
|
34
|
-
border: 'neutral200',
|
|
35
|
-
background: 'neutral100',
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export default getMethodColor;
|
package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/BoundRoute/index.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import styled from 'styled-components';
|
|
3
|
-
import { Stack } from '@strapi/design-system/Stack';
|
|
4
|
-
import { Box } from '@strapi/design-system/Box';
|
|
5
|
-
import { Typography } from '@strapi/design-system/Typography';
|
|
6
|
-
import map from 'lodash/map';
|
|
7
|
-
import tail from 'lodash/tail';
|
|
8
|
-
import { useIntl } from 'react-intl';
|
|
9
|
-
import PropTypes from 'prop-types';
|
|
10
|
-
import getMethodColor from './getMethodColor';
|
|
11
|
-
|
|
12
|
-
const MethodBox = styled(Box)`
|
|
13
|
-
margin: -1px;
|
|
14
|
-
border-radius: ${({ theme }) => theme.spaces[1]} 0 0 ${({ theme }) => theme.spaces[1]};
|
|
15
|
-
`;
|
|
16
|
-
|
|
17
|
-
function BoundRoute({ route }) {
|
|
18
|
-
const { formatMessage } = useIntl();
|
|
19
|
-
|
|
20
|
-
const { method, handler: title, path } = route;
|
|
21
|
-
const formattedRoute = path ? tail(path.split('/')) : [];
|
|
22
|
-
const [controller = '', action = ''] = title ? title.split('.') : [];
|
|
23
|
-
const colors = getMethodColor(route.method);
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<Stack spacing={2}>
|
|
27
|
-
<Typography variant="delta" as="h3">
|
|
28
|
-
{formatMessage({
|
|
29
|
-
id: 'Settings.apiTokens.createPage.BoundRoute.title',
|
|
30
|
-
defaultMessage: 'Bound route to',
|
|
31
|
-
})}
|
|
32
|
-
|
|
33
|
-
<span>{controller}</span>
|
|
34
|
-
<Typography variant="delta" textColor="primary600">
|
|
35
|
-
.{action}
|
|
36
|
-
</Typography>
|
|
37
|
-
</Typography>
|
|
38
|
-
<Stack horizontal hasRadius background="neutral0" borderColor="neutral200" spacing={0}>
|
|
39
|
-
<MethodBox background={colors.background} borderColor={colors.border} padding={2}>
|
|
40
|
-
<Typography fontWeight="bold" textColor={colors.text}>
|
|
41
|
-
{method}
|
|
42
|
-
</Typography>
|
|
43
|
-
</MethodBox>
|
|
44
|
-
<Box paddingLeft={2} paddingRight={2}>
|
|
45
|
-
{map(formattedRoute, (value) => (
|
|
46
|
-
<Typography key={value} textColor={value.includes(':') ? 'neutral600' : 'neutral900'}>
|
|
47
|
-
/{value}
|
|
48
|
-
</Typography>
|
|
49
|
-
))}
|
|
50
|
-
</Box>
|
|
51
|
-
</Stack>
|
|
52
|
-
</Stack>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
BoundRoute.defaultProps = {
|
|
57
|
-
route: {
|
|
58
|
-
handler: 'Nocontroller.error',
|
|
59
|
-
method: 'GET',
|
|
60
|
-
path: '/there-is-no-path',
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
BoundRoute.propTypes = {
|
|
65
|
-
route: PropTypes.shape({
|
|
66
|
-
handler: PropTypes.string,
|
|
67
|
-
method: PropTypes.string,
|
|
68
|
-
path: PropTypes.string,
|
|
69
|
-
}),
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export default BoundRoute;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import styled, { css } from 'styled-components';
|
|
2
|
-
import { Box } from '@strapi/design-system/Box';
|
|
3
|
-
|
|
4
|
-
const activeCheckboxWrapperStyles = css`
|
|
5
|
-
background: ${(props) => props.theme.colors.primary100};
|
|
6
|
-
svg {
|
|
7
|
-
opacity: 1;
|
|
8
|
-
}
|
|
9
|
-
`;
|
|
10
|
-
|
|
11
|
-
const CheckboxWrapper = styled(Box)`
|
|
12
|
-
display: flex;
|
|
13
|
-
justify-content: space-between;
|
|
14
|
-
align-items: center;
|
|
15
|
-
|
|
16
|
-
svg {
|
|
17
|
-
opacity: 0;
|
|
18
|
-
path {
|
|
19
|
-
fill: ${(props) => props.theme.colors.primary600};
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/* Show active style both on hover and when the action is selected */
|
|
24
|
-
${(props) => props.isActive && activeCheckboxWrapperStyles}
|
|
25
|
-
&:hover {
|
|
26
|
-
${activeCheckboxWrapperStyles}
|
|
27
|
-
}
|
|
28
|
-
`;
|
|
29
|
-
|
|
30
|
-
export default CheckboxWrapper;
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import { capitalize } from 'lodash';
|
|
3
|
-
import { Accordion, AccordionToggle, AccordionContent } from '@strapi/design-system/Accordion';
|
|
4
|
-
import { Checkbox } from '@strapi/design-system/Checkbox';
|
|
5
|
-
import { Grid, GridItem } from '@strapi/design-system/Grid';
|
|
6
|
-
import { Typography } from '@strapi/design-system/Typography';
|
|
7
|
-
import { Box } from '@strapi/design-system/Box';
|
|
8
|
-
import { Flex } from '@strapi/design-system/Flex';
|
|
9
|
-
import CogIcon from '@strapi/icons/Cog';
|
|
10
|
-
import styled from 'styled-components';
|
|
11
|
-
import PropTypes from 'prop-types';
|
|
12
|
-
import { useApiTokenPermissionsContext } from '../../../../../../../contexts/ApiTokenPermissions';
|
|
13
|
-
import CheckboxWrapper from './CheckBoxWrapper';
|
|
14
|
-
|
|
15
|
-
const Border = styled.div`
|
|
16
|
-
flex: 1;
|
|
17
|
-
align-self: center;
|
|
18
|
-
border-top: 1px solid ${({ theme }) => theme.colors.neutral150};
|
|
19
|
-
`;
|
|
20
|
-
|
|
21
|
-
const CollapsableContentType = ({
|
|
22
|
-
controllers,
|
|
23
|
-
label,
|
|
24
|
-
orderNumber,
|
|
25
|
-
disabled,
|
|
26
|
-
onExpanded,
|
|
27
|
-
indexExpandendCollapsedContent,
|
|
28
|
-
}) => {
|
|
29
|
-
const {
|
|
30
|
-
value: { onChangeSelectAll, onChange, selectedActions, setSelectedAction, selectedAction },
|
|
31
|
-
} = useApiTokenPermissionsContext();
|
|
32
|
-
const [expanded, setExpanded] = useState(false);
|
|
33
|
-
|
|
34
|
-
const handleExpandedAccordion = () => {
|
|
35
|
-
setExpanded((s) => !s);
|
|
36
|
-
onExpanded(orderNumber);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
if (
|
|
41
|
-
indexExpandendCollapsedContent !== null &&
|
|
42
|
-
indexExpandendCollapsedContent !== orderNumber &&
|
|
43
|
-
expanded
|
|
44
|
-
) {
|
|
45
|
-
setExpanded(false);
|
|
46
|
-
}
|
|
47
|
-
}, [indexExpandendCollapsedContent, orderNumber, expanded]);
|
|
48
|
-
|
|
49
|
-
const isActionSelected = (actionId) => actionId === selectedAction;
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<Accordion
|
|
53
|
-
expanded={expanded}
|
|
54
|
-
onToggle={handleExpandedAccordion}
|
|
55
|
-
variant={orderNumber % 2 ? 'primary' : 'secondary'}
|
|
56
|
-
>
|
|
57
|
-
<AccordionToggle title={capitalize(label)} />
|
|
58
|
-
<AccordionContent>
|
|
59
|
-
{controllers?.map((controller) => {
|
|
60
|
-
const allActionsSelected = controller.actions.every((action) =>
|
|
61
|
-
selectedActions.includes(action.actionId)
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
const someActionsSelected = controller.actions.some((action) =>
|
|
65
|
-
selectedActions.includes(action.actionId)
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<Box key={`${label}.${controller?.controller}`}>
|
|
70
|
-
<Flex justifyContent="space-between" alignItems="center" padding={4}>
|
|
71
|
-
<Box paddingRight={4}>
|
|
72
|
-
<Typography variant="sigma" textColor="neutral600">
|
|
73
|
-
{controller?.controller}
|
|
74
|
-
</Typography>
|
|
75
|
-
</Box>
|
|
76
|
-
<Border />
|
|
77
|
-
<Box paddingLeft={4}>
|
|
78
|
-
<Checkbox
|
|
79
|
-
value={allActionsSelected}
|
|
80
|
-
indeterminate={!allActionsSelected && someActionsSelected}
|
|
81
|
-
onValueChange={() => {
|
|
82
|
-
onChangeSelectAll({ target: { value: [...controller.actions] } });
|
|
83
|
-
}}
|
|
84
|
-
disabled={disabled}
|
|
85
|
-
>
|
|
86
|
-
Select all
|
|
87
|
-
</Checkbox>
|
|
88
|
-
</Box>
|
|
89
|
-
</Flex>
|
|
90
|
-
<Grid gap={4} padding={4}>
|
|
91
|
-
{controller?.actions &&
|
|
92
|
-
controller?.actions.map((action) => {
|
|
93
|
-
return (
|
|
94
|
-
<GridItem col={6} key={action.actionId}>
|
|
95
|
-
<CheckboxWrapper
|
|
96
|
-
isActive={isActionSelected(action.actionId)}
|
|
97
|
-
padding={2}
|
|
98
|
-
hasRadius
|
|
99
|
-
>
|
|
100
|
-
<Checkbox
|
|
101
|
-
value={selectedActions.includes(action.actionId)}
|
|
102
|
-
name={action.actionId}
|
|
103
|
-
onValueChange={() => {
|
|
104
|
-
onChange({ target: { value: action.actionId } });
|
|
105
|
-
}}
|
|
106
|
-
disabled={disabled}
|
|
107
|
-
>
|
|
108
|
-
{action.action}
|
|
109
|
-
</Checkbox>
|
|
110
|
-
<button
|
|
111
|
-
type="button"
|
|
112
|
-
data-testid="action-cog"
|
|
113
|
-
onClick={() =>
|
|
114
|
-
setSelectedAction({ target: { value: action.actionId } })
|
|
115
|
-
}
|
|
116
|
-
style={{ display: 'inline-flex', alignItems: 'center' }}
|
|
117
|
-
>
|
|
118
|
-
<CogIcon />
|
|
119
|
-
</button>
|
|
120
|
-
</CheckboxWrapper>
|
|
121
|
-
</GridItem>
|
|
122
|
-
);
|
|
123
|
-
})}
|
|
124
|
-
</Grid>
|
|
125
|
-
</Box>
|
|
126
|
-
);
|
|
127
|
-
})}
|
|
128
|
-
</AccordionContent>
|
|
129
|
-
</Accordion>
|
|
130
|
-
);
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
CollapsableContentType.defaultProps = {
|
|
134
|
-
controllers: [],
|
|
135
|
-
orderNumber: 0,
|
|
136
|
-
disabled: false,
|
|
137
|
-
onExpanded: () => null,
|
|
138
|
-
indexExpandendCollapsedContent: null,
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
CollapsableContentType.propTypes = {
|
|
142
|
-
controllers: PropTypes.array,
|
|
143
|
-
orderNumber: PropTypes.number,
|
|
144
|
-
label: PropTypes.string.isRequired,
|
|
145
|
-
disabled: PropTypes.bool,
|
|
146
|
-
onExpanded: PropTypes.func,
|
|
147
|
-
indexExpandendCollapsedContent: PropTypes.number,
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
export default CollapsableContentType;
|
package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/ContenTypesSection/index.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { Box } from '@strapi/design-system/Box';
|
|
4
|
-
import CollapsableContentType from '../CollapsableContentType';
|
|
5
|
-
|
|
6
|
-
const ContentTypesSection = ({ section, ...props }) => {
|
|
7
|
-
const [indexExpandedCollpsedContent, setIndexExpandedCollpsedContent] = useState(null);
|
|
8
|
-
const handleExpandedCollpsedContentIndex = (index) => setIndexExpandedCollpsedContent(index);
|
|
9
|
-
|
|
10
|
-
return (
|
|
11
|
-
<Box padding={4} background="neutral0">
|
|
12
|
-
{section &&
|
|
13
|
-
section.map((api, index) => (
|
|
14
|
-
<CollapsableContentType
|
|
15
|
-
key={api.apiId}
|
|
16
|
-
label={api.label}
|
|
17
|
-
controllers={api.controllers}
|
|
18
|
-
orderNumber={index}
|
|
19
|
-
indexExpandendCollapsedContent={indexExpandedCollpsedContent}
|
|
20
|
-
onExpanded={handleExpandedCollpsedContentIndex}
|
|
21
|
-
name={api.apiId}
|
|
22
|
-
{...props}
|
|
23
|
-
/>
|
|
24
|
-
))}
|
|
25
|
-
</Box>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
ContentTypesSection.defaultProps = {
|
|
30
|
-
section: null,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
ContentTypesSection.propTypes = {
|
|
34
|
-
section: PropTypes.arrayOf(PropTypes.object),
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export default ContentTypesSection;
|