@strapi/admin 4.5.0-alpha.0 → 4.5.0-beta.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 +4 -12
- package/admin/src/components/Providers/index.js +14 -10
- package/admin/src/content-manager/components/CollectionTypeFormWrapper/index.js +24 -0
- package/admin/src/content-manager/components/DynamicTable/TableRows/index.js +20 -15
- package/admin/src/content-manager/components/DynamicZone/components/Component/index.js +19 -9
- package/admin/src/content-manager/components/EditViewDataManagerProvider/index.js +50 -3
- package/admin/src/content-manager/components/EditViewDataManagerProvider/reducer.js +50 -9
- package/admin/src/content-manager/components/FieldTypeIcon/index.js +31 -1
- package/admin/src/content-manager/components/Inputs/index.js +36 -14
- package/admin/src/content-manager/components/NonRepeatableComponent/index.js +2 -0
- package/admin/src/content-manager/components/RelationInput/RelationInput.js +95 -32
- package/admin/src/content-manager/components/RelationInput/components/RelationItem.js +2 -2
- package/admin/src/content-manager/components/RelationInput/constants.js +1 -1
- package/admin/src/content-manager/components/RelationInputDataManager/RelationInputDataManager.js +33 -22
- package/admin/src/content-manager/components/RelationInputDataManager/utils/index.js +1 -0
- package/admin/src/content-manager/components/RelationInputDataManager/utils/normalizeRelations.js +10 -3
- package/admin/src/content-manager/components/RelationInputDataManager/utils/normalizeSearchResults.js +12 -0
- package/admin/src/content-manager/components/RelationInputDataManager/utils/select.js +34 -11
- package/admin/src/content-manager/components/RepeatableComponent/DraggedItem/index.js +5 -0
- package/admin/src/content-manager/components/SingleTypeFormWrapper/index.js +23 -0
- package/admin/src/content-manager/hooks/useRelation/useRelation.js +17 -9
- package/admin/src/content-manager/pages/EditSettingsView/components/FormModal.js +7 -2
- package/admin/src/content-manager/pages/EditSettingsView/index.js +2 -1
- package/admin/src/content-manager/pages/EditView/Header/index.js +118 -50
- package/admin/src/content-manager/pages/EditView/Header/utils/select.js +4 -0
- package/admin/src/content-manager/pages/EditView/index.js +102 -93
- package/admin/src/content-manager/pages/ListView/index.js +24 -15
- package/admin/src/content-manager/pages/ListView/utils/buildQueryString.js +14 -2
- package/admin/src/contexts/ApiTokenPermissions/index.js +24 -0
- package/admin/src/core/apis/CustomFields.js +80 -0
- package/admin/src/core/apis/index.js +1 -0
- package/admin/src/hooks/index.js +1 -0
- package/admin/src/hooks/useRegenerate/index.js +34 -0
- package/admin/src/pages/HomePage/SocialLinks.js +1 -1
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/ActionBoundRoutes/index.js +56 -0
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/BoundRoute/getMethodColor.js +41 -0
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/BoundRoute/index.js +72 -0
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/CollapsableContentType/CheckBoxWrapper.js +30 -0
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/CollapsableContentType/index.js +150 -0
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/ContenTypesSection/index.js +37 -0
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/FormApiTokenContainer/index.js +254 -0
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/FormBody/index.js +77 -0
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/FormHead/index.js +85 -0
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/Permissions/index.js +40 -0
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/Regenerate/index.js +68 -0
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/index.js +215 -197
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/init.js +13 -0
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/reducer.js +72 -0
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/utils/getDateOfExpiration.js +16 -0
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/utils/index.js +5 -0
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/utils/schema.js +2 -1
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/utils/transformPermissionsData.js +36 -0
- package/admin/src/pages/SettingsPage/pages/ApiTokens/ListView/DynamicTable/DefaultButton/index.js +63 -0
- package/admin/src/pages/SettingsPage/pages/ApiTokens/ListView/DynamicTable/DeleteButton/index.js +1 -0
- package/admin/src/pages/SettingsPage/pages/ApiTokens/ListView/DynamicTable/ReadButton/index.js +19 -0
- package/admin/src/pages/SettingsPage/pages/ApiTokens/ListView/DynamicTable/UpdateButton/index.js +3 -36
- package/admin/src/pages/SettingsPage/pages/ApiTokens/ListView/DynamicTable/index.js +13 -11
- package/admin/src/pages/SettingsPage/pages/ApiTokens/ListView/index.js +3 -2
- 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/pages/SettingsPage/pages/Users/ListPage/ModalForm/index.js +2 -2
- package/admin/src/permissions/defaultPermissions.js +2 -6
- package/admin/src/translations/ca.json +3 -1
- package/admin/src/translations/de.json +4 -1
- package/admin/src/translations/dk.json +3 -0
- package/admin/src/translations/en.json +22 -1
- package/admin/src/translations/es.json +156 -157
- package/admin/src/translations/fr.json +3 -0
- package/admin/src/translations/gu.json +608 -606
- package/admin/src/translations/hi.json +689 -687
- package/admin/src/translations/hu.json +2 -0
- package/admin/src/translations/id.json +2 -0
- package/admin/src/translations/it.json +2 -0
- package/admin/src/translations/ja.json +2 -0
- package/admin/src/translations/ko.json +2 -0
- package/admin/src/translations/ml.json +689 -687
- package/admin/src/translations/nl.json +3 -0
- package/admin/src/translations/pl.json +2 -0
- package/admin/src/translations/pt-BR.json +3 -0
- package/admin/src/translations/ru.json +489 -491
- package/admin/src/translations/sa.json +85 -82
- package/admin/src/translations/sk.json +3 -0
- package/admin/src/translations/sv.json +3 -0
- package/admin/src/translations/zh-Hans.json +4 -1
- package/admin/src/translations/zh.json +3 -0
- package/build/1856.d8f13391.chunk.js +173 -0
- package/build/{9311.7cc03f29.chunk.js → 1939.e3c87653.chunk.js} +108 -291
- package/build/{2077.c935ee42.chunk.js → 2077.31a2d91e.chunk.js} +4 -4
- package/build/{2912.a015078a.chunk.js → 2912.ab68a736.chunk.js} +8 -8
- package/build/4318.7d167b58.chunk.js +30 -0
- package/build/4715.44b1ef9b.chunk.js +386 -0
- package/build/{4982.05eda880.chunk.js → 4982.c2a311b7.chunk.js} +9 -9
- package/build/7379.d246dd38.chunk.js +1 -0
- package/build/{7841.91f793dc.chunk.js → 7841.4b67af3f.chunk.js} +8 -8
- package/build/{7866.1201afbd.chunk.js → 7866.5fbeb7e5.chunk.js} +10 -10
- package/build/{8380.8789ff76.chunk.js → 8380.9b53a31d.chunk.js} +7 -7
- package/build/{8549.133c4473.chunk.js → 8549.cf10b5d1.chunk.js} +4 -4
- package/build/8738.a30a2160.chunk.js +461 -0
- package/build/{9066.08049eb1.chunk.js → 9066.26faf397.chunk.js} +4 -4
- package/build/{9166.037339e0.chunk.js → 9166.8fcb3019.chunk.js} +5 -5
- package/build/{9420.43a86e7c.chunk.js → 9420.0fe11290.chunk.js} +6 -6
- package/build/962.8651ba3f.chunk.js +184 -0
- package/build/Admin-authenticatedApp.883449a5.chunk.js +80 -0
- package/build/{Admin_homePage.118926e0.chunk.js → Admin_homePage.4b2be829.chunk.js} +2 -2
- package/build/{Admin_profilePage.9d50ac44.chunk.js → Admin_profilePage.da32abbc.chunk.js} +1 -1
- package/build/{Admin_settingsPage.98a711e5.chunk.js → Admin_settingsPage.98e2a62b.chunk.js} +16 -16
- package/build/admin-app.a61d5c2e.chunk.js +112 -0
- package/build/admin-edit-roles-page.4dd6bcb9.chunk.js +1 -0
- package/build/{admin-users.97a08630.chunk.js → admin-users.d71f198a.chunk.js} +3 -3
- package/build/api-tokens-create-page.93dd0689.chunk.js +1 -0
- package/build/api-tokens-edit-page.b0adac81.chunk.js +1 -0
- package/build/api-tokens-list-page.bb36535f.chunk.js +16 -0
- package/build/{ca-json.a16899ae.chunk.js → ca-json.82df6eab.chunk.js} +1 -1
- package/build/content-manager.933dc286.chunk.js +1201 -0
- package/build/content-type-builder-list-view.5b3cd768.chunk.js +194 -0
- package/build/content-type-builder-translation-en-json.f985c9c4.chunk.js +1 -0
- package/build/content-type-builder.a6e29716.chunk.js +145 -0
- package/build/{de-json.aa6026b3.chunk.js → de-json.0ad554eb.chunk.js} +1 -1
- package/build/{dk-json.fac2bcfb.chunk.js → dk-json.e195ea1a.chunk.js} +1 -1
- package/build/{email-settings-page.64037147.chunk.js → email-settings-page.bfe6227f.chunk.js} +4 -4
- package/build/en-json.1889403c.chunk.js +1 -0
- package/build/{es-json.d672e181.chunk.js → es-json.09f80f6e.chunk.js} +1 -1
- package/build/{fr-json.71a16175.chunk.js → fr-json.606d056b.chunk.js} +1 -1
- package/build/{gu-json.ca345cd1.chunk.js → gu-json.9881264f.chunk.js} +1 -1
- package/build/{hi-json.50c7e6d4.chunk.js → hi-json.83dcf48f.chunk.js} +1 -1
- package/build/{hu-json.e0521dcc.chunk.js → hu-json.6f328bce.chunk.js} +1 -1
- package/build/{i18n-settings-page.0b73785d.chunk.js → i18n-settings-page.18166125.chunk.js} +4 -4
- package/build/{id-json.4b1ff8d6.chunk.js → id-json.1f3c4303.chunk.js} +1 -1
- package/build/index.html +1 -1
- package/build/{it-json.86bac220.chunk.js → it-json.494ac432.chunk.js} +1 -1
- package/build/{ja-json.4e44e36b.chunk.js → ja-json.6f262117.chunk.js} +1 -1
- package/build/{ko-json.1003756e.chunk.js → ko-json.36dc3b9a.chunk.js} +1 -1
- package/build/main.63e7ea0a.js +9338 -0
- package/build/{ml-json.c7774425.chunk.js → ml-json.9566bf9a.chunk.js} +1 -1
- package/build/{nl-json.f58ea235.chunk.js → nl-json.94c3a289.chunk.js} +1 -1
- package/build/{pl-json.fed96aba.chunk.js → pl-json.ccc6ef23.chunk.js} +1 -1
- package/build/{pt-BR-json.073799ab.chunk.js → pt-BR-json.744f024d.chunk.js} +1 -1
- package/build/{ru-json.7ad2cbbf.chunk.js → ru-json.d22ea13c.chunk.js} +1 -1
- package/build/{runtime~main.feeac6d3.js → runtime~main.3a5e1b07.js} +1 -1
- package/build/{sa-json.f0f704f0.chunk.js → sa-json.8fb1c04d.chunk.js} +1 -1
- package/build/{sk-json.a848961b.chunk.js → sk-json.6c7335d4.chunk.js} +1 -1
- package/build/sso-settings-page.9ceb0140.chunk.js +1 -0
- package/build/{sv-json.b038acbe.chunk.js → sv-json.2e589a7d.chunk.js} +1 -1
- package/build/{upload-settings.80ff0974.chunk.js → upload-settings.3d613216.chunk.js} +4 -4
- package/build/{upload-translation-en-json.004a86c1.chunk.js → upload-translation-en-json.86da7b0a.chunk.js} +1 -1
- package/build/{users-advanced-settings-page.a02f4806.chunk.js → users-advanced-settings-page.f4051d92.chunk.js} +4 -4
- package/build/{webhook-edit-page.d2ea3351.chunk.js → webhook-edit-page.9e46fc3f.chunk.js} +1 -1
- package/build/{webhook-list-page.2775a683.chunk.js → webhook-list-page.a712ae40.chunk.js} +4 -4
- package/build/{zh-Hans-json.03d2bda1.chunk.js → zh-Hans-json.a4d7dc69.chunk.js} +1 -1
- package/build/{zh-json.3d0cc664.chunk.js → zh-json.66aa2ae1.chunk.js} +1 -1
- package/ee/server/controllers/user.js +5 -3
- package/package.json +9 -8
- package/server/bootstrap.js +19 -1
- package/server/config/admin-actions.js +20 -0
- package/server/content-types/api-token-permission.js +36 -0
- package/server/content-types/api-token.js +25 -1
- package/server/content-types/index.js +1 -0
- package/server/controllers/admin.js +3 -0
- package/server/controllers/api-token.js +24 -1
- package/server/controllers/content-api.js +15 -0
- package/server/controllers/index.js +1 -0
- package/server/controllers/user.js +3 -2
- package/server/routes/api-tokens.js +11 -0
- package/server/routes/content-api.js +20 -0
- package/server/routes/index.js +2 -0
- package/server/services/api-token.js +309 -29
- package/server/services/constants.js +10 -0
- package/server/services/permission/engine.js +36 -226
- package/server/services/permission.js +4 -1
- package/server/strategies/admin.js +7 -1
- package/server/strategies/api-token.js +72 -11
- package/server/validation/api-tokens.js +12 -2
- package/utils/get-custom-app-config-file.js +5 -0
- package/build/1856.47226450.chunk.js +0 -173
- package/build/4715.58cd558f.chunk.js +0 -387
- package/build/7098.40dcd7bf.chunk.js +0 -1
- package/build/8851.e4ac62f2.chunk.js +0 -158
- package/build/Admin-authenticatedApp.e39f36c9.chunk.js +0 -80
- package/build/admin-app.4f7618a9.chunk.js +0 -112
- package/build/admin-edit-roles-page.554ba3fa.chunk.js +0 -1
- package/build/api-tokens-create-page.4c262d6e.chunk.js +0 -1
- package/build/api-tokens-edit-page.10a9d368.chunk.js +0 -1
- package/build/api-tokens-list-page.442c9f3c.chunk.js +0 -15
- package/build/content-manager.7d57c9d1.chunk.js +0 -1200
- package/build/content-type-builder-list-view.8cc534e0.chunk.js +0 -194
- package/build/content-type-builder-translation-en-json.201bfb78.chunk.js +0 -1
- package/build/content-type-builder.684df7a4.chunk.js +0 -142
- package/build/en-json.0c69c7d7.chunk.js +0 -1
- package/build/main.b47db1a3.js +0 -9337
- package/build/sso-settings-page.445184e0.chunk.js +0 -1
- package/server/services/permission/engine-hooks.js +0 -82
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { usePersistentState } from '@strapi/helper-plugin';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import { Box } from '@strapi/design-system/Box';
|
|
6
|
+
import { Grid, GridItem } from '@strapi/design-system/Grid';
|
|
7
|
+
import { Select, Option } from '@strapi/design-system/Select';
|
|
8
|
+
import { Stack } from '@strapi/design-system/Stack';
|
|
9
|
+
import { Textarea } from '@strapi/design-system/Textarea';
|
|
10
|
+
import { TextInput } from '@strapi/design-system/TextInput';
|
|
11
|
+
import { Typography } from '@strapi/design-system/Typography';
|
|
12
|
+
import { getDateOfExpiration } from '../../utils';
|
|
13
|
+
|
|
14
|
+
const FormApiTokenContainer = ({
|
|
15
|
+
errors,
|
|
16
|
+
onChange,
|
|
17
|
+
canEditInputs,
|
|
18
|
+
isCreating,
|
|
19
|
+
values,
|
|
20
|
+
apiToken,
|
|
21
|
+
onDispatch,
|
|
22
|
+
setHasChangedPermissions,
|
|
23
|
+
}) => {
|
|
24
|
+
const { formatMessage } = useIntl();
|
|
25
|
+
const [lang] = usePersistentState('strapi-admin-language', 'en');
|
|
26
|
+
|
|
27
|
+
const handleChangeSelectApiTokenType = ({ target: { value } }) => {
|
|
28
|
+
setHasChangedPermissions(false);
|
|
29
|
+
|
|
30
|
+
if (value === 'full-access') {
|
|
31
|
+
onDispatch({
|
|
32
|
+
type: 'SELECT_ALL_ACTIONS',
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (value === 'read-only') {
|
|
36
|
+
onDispatch({
|
|
37
|
+
type: 'ON_CHANGE_READ_ONLY',
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Box
|
|
44
|
+
background="neutral0"
|
|
45
|
+
hasRadius
|
|
46
|
+
shadow="filterShadow"
|
|
47
|
+
paddingTop={6}
|
|
48
|
+
paddingBottom={6}
|
|
49
|
+
paddingLeft={7}
|
|
50
|
+
paddingRight={7}
|
|
51
|
+
>
|
|
52
|
+
<Stack spacing={4}>
|
|
53
|
+
<Typography variant="delta" as="h2">
|
|
54
|
+
{formatMessage({
|
|
55
|
+
id: 'global.details',
|
|
56
|
+
defaultMessage: 'Details',
|
|
57
|
+
})}
|
|
58
|
+
</Typography>
|
|
59
|
+
<Grid gap={5}>
|
|
60
|
+
<GridItem key="name" col={6} xs={12}>
|
|
61
|
+
<TextInput
|
|
62
|
+
name="name"
|
|
63
|
+
error={
|
|
64
|
+
errors.name
|
|
65
|
+
? formatMessage(
|
|
66
|
+
errors.name?.id
|
|
67
|
+
? errors.name
|
|
68
|
+
: { id: errors.name, defaultMessage: errors.name }
|
|
69
|
+
)
|
|
70
|
+
: null
|
|
71
|
+
}
|
|
72
|
+
label={formatMessage({
|
|
73
|
+
id: 'Settings.apiTokens.form.name',
|
|
74
|
+
defaultMessage: 'Name',
|
|
75
|
+
})}
|
|
76
|
+
onChange={onChange}
|
|
77
|
+
value={values.name}
|
|
78
|
+
disabled={!canEditInputs}
|
|
79
|
+
required
|
|
80
|
+
/>
|
|
81
|
+
</GridItem>
|
|
82
|
+
<GridItem key="description" col={6} xs={12}>
|
|
83
|
+
<Textarea
|
|
84
|
+
label={formatMessage({
|
|
85
|
+
id: 'Settings.apiTokens.form.description',
|
|
86
|
+
defaultMessage: 'Description',
|
|
87
|
+
})}
|
|
88
|
+
name="description"
|
|
89
|
+
error={
|
|
90
|
+
errors.description
|
|
91
|
+
? formatMessage(
|
|
92
|
+
errors.description?.id
|
|
93
|
+
? errors.description
|
|
94
|
+
: {
|
|
95
|
+
id: errors.description,
|
|
96
|
+
defaultMessage: errors.description,
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
: null
|
|
100
|
+
}
|
|
101
|
+
onChange={onChange}
|
|
102
|
+
disabled={!canEditInputs}
|
|
103
|
+
>
|
|
104
|
+
{values.description}
|
|
105
|
+
</Textarea>
|
|
106
|
+
</GridItem>
|
|
107
|
+
<GridItem key="lifespan" col={6} xs={12}>
|
|
108
|
+
<Select
|
|
109
|
+
name="lifespan"
|
|
110
|
+
label={formatMessage({
|
|
111
|
+
id: 'Settings.apiTokens.form.duration',
|
|
112
|
+
defaultMessage: 'Token duration',
|
|
113
|
+
})}
|
|
114
|
+
value={values.lifespan}
|
|
115
|
+
error={
|
|
116
|
+
errors.lifespan
|
|
117
|
+
? formatMessage(
|
|
118
|
+
errors.lifespan?.id
|
|
119
|
+
? errors.lifespan
|
|
120
|
+
: { id: errors.lifespan, defaultMessage: errors.lifespan }
|
|
121
|
+
)
|
|
122
|
+
: null
|
|
123
|
+
}
|
|
124
|
+
onChange={(value) => {
|
|
125
|
+
onChange({ target: { name: 'lifespan', value } });
|
|
126
|
+
}}
|
|
127
|
+
required
|
|
128
|
+
disabled={!isCreating}
|
|
129
|
+
placeholder="Select"
|
|
130
|
+
>
|
|
131
|
+
<Option value="604800000">
|
|
132
|
+
{formatMessage({
|
|
133
|
+
id: 'Settings.apiTokens.duration.7-days',
|
|
134
|
+
defaultMessage: '7 days',
|
|
135
|
+
})}
|
|
136
|
+
</Option>
|
|
137
|
+
<Option value="2592000000">
|
|
138
|
+
{formatMessage({
|
|
139
|
+
id: 'Settings.apiTokens.duration.30-days',
|
|
140
|
+
defaultMessage: '30 days',
|
|
141
|
+
})}
|
|
142
|
+
</Option>
|
|
143
|
+
<Option value="7776000000">
|
|
144
|
+
{formatMessage({
|
|
145
|
+
id: 'Settings.apiTokens.duration.90-days',
|
|
146
|
+
defaultMessage: '90 days',
|
|
147
|
+
})}
|
|
148
|
+
</Option>
|
|
149
|
+
<Option value={null}>
|
|
150
|
+
{formatMessage({
|
|
151
|
+
id: 'Settings.apiTokens.duration.unlimited',
|
|
152
|
+
defaultMessage: 'Unlimited',
|
|
153
|
+
})}
|
|
154
|
+
</Option>
|
|
155
|
+
</Select>
|
|
156
|
+
<Typography variant="pi" textColor="neutral600">
|
|
157
|
+
{!isCreating &&
|
|
158
|
+
`${formatMessage({
|
|
159
|
+
id: 'Settings.apiTokens.duration.expiration-date',
|
|
160
|
+
defaultMessage: 'Expiration date',
|
|
161
|
+
})}: ${getDateOfExpiration(
|
|
162
|
+
apiToken?.createdAt,
|
|
163
|
+
parseInt(values.lifespan, 10),
|
|
164
|
+
lang
|
|
165
|
+
)}`}
|
|
166
|
+
</Typography>
|
|
167
|
+
</GridItem>
|
|
168
|
+
|
|
169
|
+
<GridItem key="type" col={6} xs={12}>
|
|
170
|
+
<Select
|
|
171
|
+
name="type"
|
|
172
|
+
label={formatMessage({
|
|
173
|
+
id: 'Settings.apiTokens.form.type',
|
|
174
|
+
defaultMessage: 'Token type',
|
|
175
|
+
})}
|
|
176
|
+
value={values?.type}
|
|
177
|
+
error={
|
|
178
|
+
errors.type
|
|
179
|
+
? formatMessage(
|
|
180
|
+
errors.type?.id
|
|
181
|
+
? errors.type
|
|
182
|
+
: { id: errors.type, defaultMessage: errors.type }
|
|
183
|
+
)
|
|
184
|
+
: null
|
|
185
|
+
}
|
|
186
|
+
onChange={(value) => {
|
|
187
|
+
handleChangeSelectApiTokenType({ target: { value } });
|
|
188
|
+
onChange({ target: { name: 'type', value } });
|
|
189
|
+
}}
|
|
190
|
+
placeholder="Select"
|
|
191
|
+
required
|
|
192
|
+
disabled={!canEditInputs}
|
|
193
|
+
>
|
|
194
|
+
<Option value="read-only">
|
|
195
|
+
{formatMessage({
|
|
196
|
+
id: 'Settings.apiTokens.types.read-only',
|
|
197
|
+
defaultMessage: 'Read-only',
|
|
198
|
+
})}
|
|
199
|
+
</Option>
|
|
200
|
+
<Option value="full-access">
|
|
201
|
+
{formatMessage({
|
|
202
|
+
id: 'Settings.apiTokens.types.full-access',
|
|
203
|
+
defaultMessage: 'Full access',
|
|
204
|
+
})}
|
|
205
|
+
</Option>
|
|
206
|
+
<Option value="custom">
|
|
207
|
+
{formatMessage({
|
|
208
|
+
id: 'Settings.apiTokens.types.custom',
|
|
209
|
+
defaultMessage: 'Custom',
|
|
210
|
+
})}
|
|
211
|
+
</Option>
|
|
212
|
+
</Select>
|
|
213
|
+
</GridItem>
|
|
214
|
+
</Grid>
|
|
215
|
+
</Stack>
|
|
216
|
+
</Box>
|
|
217
|
+
);
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
FormApiTokenContainer.propTypes = {
|
|
221
|
+
errors: PropTypes.shape({
|
|
222
|
+
name: PropTypes.string,
|
|
223
|
+
description: PropTypes.string,
|
|
224
|
+
lifespan: PropTypes.string,
|
|
225
|
+
type: PropTypes.string,
|
|
226
|
+
}),
|
|
227
|
+
onChange: PropTypes.func.isRequired,
|
|
228
|
+
canEditInputs: PropTypes.bool.isRequired,
|
|
229
|
+
values: PropTypes.shape({
|
|
230
|
+
name: PropTypes.string,
|
|
231
|
+
description: PropTypes.string,
|
|
232
|
+
lifespan: PropTypes.string,
|
|
233
|
+
type: PropTypes.string,
|
|
234
|
+
}).isRequired,
|
|
235
|
+
isCreating: PropTypes.bool.isRequired,
|
|
236
|
+
apiToken: PropTypes.shape({
|
|
237
|
+
id: PropTypes.string,
|
|
238
|
+
type: PropTypes.string,
|
|
239
|
+
lifespan: PropTypes.number,
|
|
240
|
+
name: PropTypes.string,
|
|
241
|
+
accessKey: PropTypes.string,
|
|
242
|
+
permissions: PropTypes.array,
|
|
243
|
+
description: PropTypes.string,
|
|
244
|
+
createdAt: PropTypes.string,
|
|
245
|
+
}).isRequired,
|
|
246
|
+
onDispatch: PropTypes.func.isRequired,
|
|
247
|
+
setHasChangedPermissions: PropTypes.func.isRequired,
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
FormApiTokenContainer.defaultProps = {
|
|
251
|
+
errors: {},
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
export default FormApiTokenContainer;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { ContentLayout } from '@strapi/design-system/Layout';
|
|
4
|
+
import { Stack } from '@strapi/design-system/Stack';
|
|
5
|
+
import HeaderContentBox from '../ContentBox';
|
|
6
|
+
import FormApiTokenContainer from '../FormApiTokenContainer';
|
|
7
|
+
import Permissions from '../Permissions';
|
|
8
|
+
|
|
9
|
+
const FormBody = ({
|
|
10
|
+
apiToken,
|
|
11
|
+
errors,
|
|
12
|
+
onChange,
|
|
13
|
+
canEditInputs,
|
|
14
|
+
isCreating,
|
|
15
|
+
values,
|
|
16
|
+
onDispatch,
|
|
17
|
+
setHasChangedPermissions,
|
|
18
|
+
}) => {
|
|
19
|
+
return (
|
|
20
|
+
<ContentLayout>
|
|
21
|
+
<Stack spacing={6}>
|
|
22
|
+
{Boolean(apiToken?.name) && <HeaderContentBox apiToken={apiToken.accessKey} />}
|
|
23
|
+
<FormApiTokenContainer
|
|
24
|
+
errors={errors}
|
|
25
|
+
onChange={onChange}
|
|
26
|
+
canEditInputs={canEditInputs}
|
|
27
|
+
isCreating={isCreating}
|
|
28
|
+
values={values}
|
|
29
|
+
apiToken={apiToken}
|
|
30
|
+
onDispatch={onDispatch}
|
|
31
|
+
setHasChangedPermissions={setHasChangedPermissions}
|
|
32
|
+
/>
|
|
33
|
+
<Permissions
|
|
34
|
+
disabled={
|
|
35
|
+
!canEditInputs || values?.type === 'read-only' || values?.type === 'full-access'
|
|
36
|
+
}
|
|
37
|
+
/>
|
|
38
|
+
</Stack>
|
|
39
|
+
</ContentLayout>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
FormBody.propTypes = {
|
|
44
|
+
errors: PropTypes.shape({
|
|
45
|
+
name: PropTypes.string,
|
|
46
|
+
description: PropTypes.string,
|
|
47
|
+
lifespan: PropTypes.string,
|
|
48
|
+
type: PropTypes.string,
|
|
49
|
+
}),
|
|
50
|
+
apiToken: PropTypes.shape({
|
|
51
|
+
id: PropTypes.string,
|
|
52
|
+
type: PropTypes.string,
|
|
53
|
+
lifespan: PropTypes.number,
|
|
54
|
+
name: PropTypes.string,
|
|
55
|
+
accessKey: PropTypes.string,
|
|
56
|
+
permissions: PropTypes.array,
|
|
57
|
+
description: PropTypes.string,
|
|
58
|
+
createdAt: PropTypes.string,
|
|
59
|
+
}).isRequired,
|
|
60
|
+
onChange: PropTypes.func.isRequired,
|
|
61
|
+
canEditInputs: PropTypes.bool.isRequired,
|
|
62
|
+
isCreating: PropTypes.bool.isRequired,
|
|
63
|
+
values: PropTypes.shape({
|
|
64
|
+
name: PropTypes.string,
|
|
65
|
+
description: PropTypes.string,
|
|
66
|
+
lifespan: PropTypes.string,
|
|
67
|
+
type: PropTypes.string,
|
|
68
|
+
}).isRequired,
|
|
69
|
+
onDispatch: PropTypes.func.isRequired,
|
|
70
|
+
setHasChangedPermissions: PropTypes.func.isRequired,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
FormBody.defaultProps = {
|
|
74
|
+
errors: {},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export default FormBody;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { Link } from '@strapi/helper-plugin';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import ArrowLeft from '@strapi/icons/ArrowLeft';
|
|
6
|
+
import Check from '@strapi/icons/Check';
|
|
7
|
+
import { Button } from '@strapi/design-system/Button';
|
|
8
|
+
import { HeaderLayout } from '@strapi/design-system/Layout';
|
|
9
|
+
import { Stack } from '@strapi/design-system/Stack';
|
|
10
|
+
import Regenerate from '../Regenerate';
|
|
11
|
+
|
|
12
|
+
const FormHead = ({ apiToken, setApiToken, canEditInputs, canRegenerate, isSubmitting }) => {
|
|
13
|
+
const { formatMessage } = useIntl();
|
|
14
|
+
const handleRegenerate = (newKey) => {
|
|
15
|
+
setApiToken({
|
|
16
|
+
...apiToken,
|
|
17
|
+
accessKey: newKey,
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<HeaderLayout
|
|
23
|
+
title={
|
|
24
|
+
apiToken?.name ||
|
|
25
|
+
formatMessage({
|
|
26
|
+
id: 'Settings.apiTokens.createPage.title',
|
|
27
|
+
defaultMessage: 'Create API Token',
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
primaryAction={
|
|
31
|
+
canEditInputs ? (
|
|
32
|
+
<Stack horizontal spacing={2}>
|
|
33
|
+
{canRegenerate && apiToken?.id && (
|
|
34
|
+
<Regenerate onRegenerate={handleRegenerate} idToRegenerate={apiToken?.id} />
|
|
35
|
+
)}
|
|
36
|
+
<Button
|
|
37
|
+
disabled={isSubmitting}
|
|
38
|
+
loading={isSubmitting}
|
|
39
|
+
startIcon={<Check />}
|
|
40
|
+
type="submit"
|
|
41
|
+
size="S"
|
|
42
|
+
>
|
|
43
|
+
{formatMessage({
|
|
44
|
+
id: 'global.save',
|
|
45
|
+
defaultMessage: 'Save',
|
|
46
|
+
})}
|
|
47
|
+
</Button>
|
|
48
|
+
</Stack>
|
|
49
|
+
) : (
|
|
50
|
+
canRegenerate &&
|
|
51
|
+
apiToken?.id && (
|
|
52
|
+
<Regenerate onRegenerate={handleRegenerate} idToRegenerate={apiToken?.id} />
|
|
53
|
+
)
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
navigationAction={
|
|
57
|
+
<Link startIcon={<ArrowLeft />} to="/settings/api-tokens">
|
|
58
|
+
{formatMessage({
|
|
59
|
+
id: 'global.back',
|
|
60
|
+
defaultMessage: 'Back',
|
|
61
|
+
})}
|
|
62
|
+
</Link>
|
|
63
|
+
}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
FormHead.propTypes = {
|
|
69
|
+
apiToken: PropTypes.shape({
|
|
70
|
+
id: PropTypes.string,
|
|
71
|
+
type: PropTypes.string,
|
|
72
|
+
lifespan: PropTypes.number,
|
|
73
|
+
name: PropTypes.string,
|
|
74
|
+
accessKey: PropTypes.string,
|
|
75
|
+
permissions: PropTypes.array,
|
|
76
|
+
description: PropTypes.string,
|
|
77
|
+
createdAt: PropTypes.string,
|
|
78
|
+
}).isRequired,
|
|
79
|
+
canEditInputs: PropTypes.bool.isRequired,
|
|
80
|
+
canRegenerate: PropTypes.bool.isRequired,
|
|
81
|
+
setApiToken: PropTypes.func.isRequired,
|
|
82
|
+
isSubmitting: PropTypes.bool.isRequired,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export default FormHead;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React, { memo } 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 { Grid, GridItem } from '@strapi/design-system/Grid';
|
|
6
|
+
import ContentTypesSection from '../ContenTypesSection';
|
|
7
|
+
import ActionBoundRoutes from '../ActionBoundRoutes';
|
|
8
|
+
import { useApiTokenPermissionsContext } from '../../../../../../../contexts/ApiTokenPermissions';
|
|
9
|
+
|
|
10
|
+
const Permissions = ({ ...props }) => {
|
|
11
|
+
const {
|
|
12
|
+
value: { data },
|
|
13
|
+
} = useApiTokenPermissionsContext();
|
|
14
|
+
const { formatMessage } = useIntl();
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Grid gap={0} shadow="filterShadow" hasRadius background="neutral0">
|
|
18
|
+
<GridItem col={7} paddingTop={6} paddingBottom={6} paddingLeft={7} paddingRight={7}>
|
|
19
|
+
<Stack spacing={2}>
|
|
20
|
+
<Typography variant="delta" as="h2">
|
|
21
|
+
{formatMessage({
|
|
22
|
+
id: 'Settings.apiTokens.createPage.permissions.title',
|
|
23
|
+
defaultMessage: 'Permissions',
|
|
24
|
+
})}
|
|
25
|
+
</Typography>
|
|
26
|
+
<Typography as="p" textColor="neutral600">
|
|
27
|
+
{formatMessage({
|
|
28
|
+
id: 'Settings.apiTokens.createPage.permissions.description',
|
|
29
|
+
defaultMessage: 'Only actions bound by a route are listed below.',
|
|
30
|
+
})}
|
|
31
|
+
</Typography>
|
|
32
|
+
</Stack>
|
|
33
|
+
{data?.permissions && <ContentTypesSection section={data?.permissions} {...props} />}
|
|
34
|
+
</GridItem>
|
|
35
|
+
<ActionBoundRoutes />
|
|
36
|
+
</Grid>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default memo(Permissions);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
4
|
+
import { Button } from '@strapi/design-system/Button';
|
|
5
|
+
import Refresh from '@strapi/icons/Refresh';
|
|
6
|
+
import { ConfirmDialog } from '@strapi/helper-plugin';
|
|
7
|
+
import { useRegenerate } from '../../../../../../../hooks';
|
|
8
|
+
|
|
9
|
+
export const Regenerate = ({ onRegenerate, idToRegenerate }) => {
|
|
10
|
+
const { formatMessage } = useIntl();
|
|
11
|
+
const [showConfirmDialog, setShowConfirmDialog] = useState(false);
|
|
12
|
+
const { regenerateData, isLoadingConfirmation } = useRegenerate(idToRegenerate, onRegenerate);
|
|
13
|
+
const handleConfirmRegeneration = async () => {
|
|
14
|
+
regenerateData();
|
|
15
|
+
setShowConfirmDialog(false);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<>
|
|
20
|
+
<Button
|
|
21
|
+
startIcon={<Refresh />}
|
|
22
|
+
type="button"
|
|
23
|
+
size="S"
|
|
24
|
+
variant="tertiary"
|
|
25
|
+
onClick={() => setShowConfirmDialog(true)}
|
|
26
|
+
name="regenerate"
|
|
27
|
+
>
|
|
28
|
+
{formatMessage({
|
|
29
|
+
id: 'Settings.apiTokens.regenerate',
|
|
30
|
+
defaultMessage: 'Regenerate',
|
|
31
|
+
})}
|
|
32
|
+
</Button>
|
|
33
|
+
|
|
34
|
+
<ConfirmDialog
|
|
35
|
+
bodyText={{
|
|
36
|
+
id: 'Settings.apiTokens.popUpWarning.message',
|
|
37
|
+
defaultMessage: 'Are you sure you want to regenerate this token?',
|
|
38
|
+
}}
|
|
39
|
+
iconRightButton={<Refresh />}
|
|
40
|
+
isConfirmButtonLoading={isLoadingConfirmation}
|
|
41
|
+
isOpen={showConfirmDialog}
|
|
42
|
+
onToggleDialog={() => setShowConfirmDialog(false)}
|
|
43
|
+
onConfirm={handleConfirmRegeneration}
|
|
44
|
+
leftButtonText={{
|
|
45
|
+
id: 'Settings.apiTokens.Button.cancel',
|
|
46
|
+
defaultMessage: 'Cancel',
|
|
47
|
+
}}
|
|
48
|
+
rightButtonText={{
|
|
49
|
+
id: 'Settings.apiTokens.Button.regenerate',
|
|
50
|
+
defaultMessage: 'Regenerate',
|
|
51
|
+
}}
|
|
52
|
+
title={{
|
|
53
|
+
id: 'Settings.apiTokens.RegenerateDialog.title',
|
|
54
|
+
defaultMessage: 'Regenerate token',
|
|
55
|
+
}}
|
|
56
|
+
/>
|
|
57
|
+
</>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
Regenerate.defaultProps = { onRegenerate() {} };
|
|
62
|
+
|
|
63
|
+
Regenerate.propTypes = {
|
|
64
|
+
onRegenerate: PropTypes.func,
|
|
65
|
+
idToRegenerate: PropTypes.string.isRequired,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export default Regenerate;
|