@strapi/admin 4.6.1 → 4.7.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/assets/images/onboarding-preview.png +0 -0
- package/admin/src/content-manager/components/CollectionTypeFormWrapper/index.js +0 -2
- package/admin/src/hooks/useRegenerate/index.js +2 -2
- package/admin/src/hooks/useSettingsMenu/utils/defaultGlobalLinks.js +7 -0
- package/admin/src/pages/Admin/Onboarding/constants.js +46 -0
- package/admin/src/pages/Admin/Onboarding/index.js +161 -89
- package/admin/src/pages/Admin/index.js +5 -2
- package/admin/src/pages/SettingsPage/{pages/ApiTokens/EditView/components → components/Tokens}/FormHead/index.js +36 -19
- package/admin/src/pages/SettingsPage/components/Tokens/FormiTokenContainer/LifeSpanInput.js +96 -0
- package/admin/src/pages/SettingsPage/components/Tokens/LifeSpanInput/index.js +98 -0
- package/admin/src/pages/SettingsPage/components/Tokens/Regenerate/index.js +73 -0
- package/admin/src/pages/SettingsPage/{pages/ApiTokens/ListView/DynamicTable → components/Tokens/Table}/DefaultButton/index.js +1 -1
- package/admin/src/pages/SettingsPage/{pages/ApiTokens/ListView/DynamicTable → components/Tokens/Table}/DeleteButton/index.js +1 -1
- package/admin/src/pages/SettingsPage/{pages/ApiTokens/ListView/DynamicTable → components/Tokens/Table}/ReadButton/index.js +0 -0
- package/admin/src/pages/SettingsPage/{pages/ApiTokens/ListView/DynamicTable → components/Tokens/Table}/UpdateButton/index.js +0 -0
- package/admin/src/pages/SettingsPage/components/Tokens/Table/index.js +135 -0
- package/admin/src/pages/SettingsPage/{pages/ApiTokens/EditView/components/ContentBox → components/Tokens/TokenBox}/index.js +17 -17
- package/admin/src/pages/SettingsPage/components/Tokens/TokenDescription/index.js +51 -0
- package/admin/src/pages/SettingsPage/components/Tokens/TokenName/index.js +46 -0
- package/admin/src/pages/SettingsPage/components/Tokens/TokenTypeSelect/index.js +69 -0
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/CollapsableContentType/index.js +5 -3
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/FormApiTokenContainer/index.js +52 -142
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/Regenerate/index.js +5 -1
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/index.js +37 -14
- package/admin/src/pages/SettingsPage/pages/ApiTokens/ListView/index.js +5 -13
- package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/components/FormTransferTokenContainer/index.js +105 -0
- package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/components/LoadingView/index.js +50 -0
- package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/index.js +201 -0
- package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/utils/getDateOfExpiration.js +16 -0
- package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/utils/index.js +4 -0
- package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/utils/schema.js +10 -0
- package/admin/src/pages/SettingsPage/pages/TransferTokens/ListView/index.js +182 -0
- package/admin/src/pages/SettingsPage/pages/TransferTokens/ListView/utils/tableHeaders.js +48 -0
- package/admin/src/pages/SettingsPage/pages/TransferTokens/ProtectedCreateView/index.js +14 -0
- package/admin/src/pages/SettingsPage/pages/TransferTokens/ProtectedEditView/index.js +14 -0
- package/admin/src/pages/SettingsPage/pages/TransferTokens/ProtectedListView/index.js +12 -0
- package/admin/src/pages/SettingsPage/utils/defaultRoutes.js +33 -0
- package/admin/src/permissions/defaultPermissions.js +8 -0
- package/admin/src/translations/en.json +18 -1
- package/build/19eb2dfcf2603eb55733.png +0 -0
- package/build/4649.15cc0afe.chunk.js +30 -0
- package/build/7259.aa68d808.chunk.js +1 -0
- package/build/7407.883fb1f5.chunk.js +1 -0
- package/build/Admin-authenticatedApp.f29f6021.chunk.js +79 -0
- package/build/{Admin_settingsPage.d1493824.chunk.js → Admin_settingsPage.178dc6e3.chunk.js} +25 -25
- package/build/{admin-app.25934eaa.chunk.js → admin-app.77a50e1f.chunk.js} +19 -19
- package/build/{api-tokens-create-page.d248362d.chunk.js → api-tokens-create-page.0db3aec1.chunk.js} +1 -1
- package/build/{api-tokens-edit-page.8516fa20.chunk.js → api-tokens-edit-page.671e0e26.chunk.js} +1 -1
- package/build/api-tokens-list-page.7387102c.chunk.js +16 -0
- package/build/{content-manager.35ff9726.chunk.js → content-manager.42b24d46.chunk.js} +77 -77
- package/build/en-json.b0748970.chunk.js +1 -0
- package/build/index.html +1 -1
- package/build/main.1022ed01.js +4393 -0
- package/build/runtime~main.84941a97.js +2 -0
- package/build/transfer-tokens-create-page.16e23791.chunk.js +1 -0
- package/build/transfer-tokens-edit-page.3886c973.chunk.js +1 -0
- package/build/transfer-tokens-list-page.e8010a89.chunk.js +16 -0
- package/package.json +12 -12
- package/server/bootstrap.js +2 -0
- package/server/config/admin-actions.js +48 -0
- package/server/content-types/index.js +2 -0
- package/server/content-types/transfer-token-permission.js +36 -0
- package/server/content-types/transfer-token.js +66 -0
- package/server/controllers/api-token.js +4 -5
- package/server/controllers/index.js +1 -0
- package/server/controllers/transfer/index.js +13 -0
- package/server/controllers/transfer/runner.js +24 -0
- package/server/controllers/transfer/token.js +131 -0
- package/server/register.js +2 -9
- package/server/routes/index.js +2 -0
- package/server/routes/transfer.js +95 -0
- package/server/services/api-token.js +2 -3
- package/server/services/constants.js +6 -0
- package/server/services/index.js +1 -0
- package/server/services/transfer/index.js +6 -0
- package/server/services/transfer/permission.js +22 -0
- package/server/services/transfer/token.js +409 -0
- package/server/strategies/api-token.js +4 -2
- package/server/strategies/data-transfer.js +107 -0
- package/server/strategies/index.js +1 -0
- package/server/utils/index.d.ts +2 -0
- package/server/validation/api-tokens.js +1 -6
- package/server/validation/transfer/index.js +5 -0
- package/server/validation/transfer/token.js +34 -0
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/FormBody/index.js +0 -78
- package/admin/src/pages/SettingsPage/pages/ApiTokens/ListView/DynamicTable/index.js +0 -112
- package/build/4318.f96a9d4d.chunk.js +0 -30
- package/build/8633.00ccd382.chunk.js +0 -1
- package/build/Admin-authenticatedApp.ce646f66.chunk.js +0 -75
- package/build/api-tokens-list-page.44a79fda.chunk.js +0 -16
- package/build/en-json.1f137a90.chunk.js +0 -1
- package/build/main.7b151630.js +0 -4377
- package/build/runtime~main.a20d633b.js +0 -2
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { Formik } from 'formik';
|
|
4
|
+
import { useRouteMatch, useHistory } from 'react-router-dom';
|
|
5
|
+
import { useQuery } from 'react-query';
|
|
6
|
+
import {
|
|
7
|
+
SettingsPageTitle,
|
|
8
|
+
useFocusWhenNavigate,
|
|
9
|
+
Form,
|
|
10
|
+
useOverlayBlocker,
|
|
11
|
+
useNotification,
|
|
12
|
+
useGuidedTour,
|
|
13
|
+
useRBAC,
|
|
14
|
+
useFetchClient,
|
|
15
|
+
} from '@strapi/helper-plugin';
|
|
16
|
+
import { Main } from '@strapi/design-system/Main';
|
|
17
|
+
import { Stack } from '@strapi/design-system/Stack';
|
|
18
|
+
import { ContentLayout } from '@strapi/design-system/Layout';
|
|
19
|
+
import { formatAPIErrors } from '../../../../../utils';
|
|
20
|
+
import { schema } from './utils';
|
|
21
|
+
import LoadingView from './components/LoadingView';
|
|
22
|
+
import adminPermissions from '../../../../../permissions';
|
|
23
|
+
import FormTransferTokenContainer from './components/FormTransferTokenContainer';
|
|
24
|
+
import TokenBox from '../../../components/Tokens/TokenBox';
|
|
25
|
+
import FormHead from '../../../components/Tokens/FormHead';
|
|
26
|
+
|
|
27
|
+
const MSG_ERROR_NAME_TAKEN = 'Name already taken';
|
|
28
|
+
|
|
29
|
+
const TransferTokenCreateView = () => {
|
|
30
|
+
useFocusWhenNavigate();
|
|
31
|
+
const { formatMessage } = useIntl();
|
|
32
|
+
const { lockApp, unlockApp } = useOverlayBlocker();
|
|
33
|
+
const toggleNotification = useNotification();
|
|
34
|
+
const history = useHistory();
|
|
35
|
+
const [transferToken, setTransferToken] = useState(
|
|
36
|
+
history.location.state?.transferToken.accessKey
|
|
37
|
+
? {
|
|
38
|
+
...history.location.state.transferToken,
|
|
39
|
+
}
|
|
40
|
+
: null
|
|
41
|
+
);
|
|
42
|
+
const { setCurrentStep } = useGuidedTour();
|
|
43
|
+
const {
|
|
44
|
+
allowedActions: { canCreate, canUpdate, canRegenerate },
|
|
45
|
+
} = useRBAC(adminPermissions.settings['transfer-tokens']);
|
|
46
|
+
const {
|
|
47
|
+
params: { id },
|
|
48
|
+
} = useRouteMatch('/settings/transfer-tokens/:id');
|
|
49
|
+
const { get, post, put } = useFetchClient();
|
|
50
|
+
|
|
51
|
+
const isCreating = id === 'create';
|
|
52
|
+
|
|
53
|
+
const { status } = useQuery(
|
|
54
|
+
['transfer-token', id],
|
|
55
|
+
async () => {
|
|
56
|
+
const {
|
|
57
|
+
data: { data },
|
|
58
|
+
} = await get(`/admin/transfer/tokens/${id}`);
|
|
59
|
+
|
|
60
|
+
setTransferToken({
|
|
61
|
+
...data,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
return data;
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
enabled: !isCreating && !transferToken,
|
|
68
|
+
onError() {
|
|
69
|
+
toggleNotification({
|
|
70
|
+
type: 'warning',
|
|
71
|
+
message: { id: 'notification.error', defaultMessage: 'An error occured' },
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const handleSubmit = async (body, actions) => {
|
|
78
|
+
lockApp();
|
|
79
|
+
const lifespanVal =
|
|
80
|
+
body.lifespan && parseInt(body.lifespan, 10) && body.lifespan !== '0'
|
|
81
|
+
? parseInt(body.lifespan, 10)
|
|
82
|
+
: null;
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
const {
|
|
86
|
+
data: { data: response },
|
|
87
|
+
} = isCreating
|
|
88
|
+
? await post(`/admin/transfer/tokens`, {
|
|
89
|
+
...body,
|
|
90
|
+
lifespan: lifespanVal,
|
|
91
|
+
permissions: ['push'],
|
|
92
|
+
})
|
|
93
|
+
: await put(`/admin/transfer/tokens/${id}`, {
|
|
94
|
+
name: body.name,
|
|
95
|
+
description: body.description,
|
|
96
|
+
type: body.type,
|
|
97
|
+
permissions: ['push'],
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
unlockApp();
|
|
101
|
+
|
|
102
|
+
if (isCreating) {
|
|
103
|
+
history.replace(`/settings/transfer-tokens/${response.id}`, { transferToken: response });
|
|
104
|
+
setCurrentStep('transferTokens.success');
|
|
105
|
+
}
|
|
106
|
+
setTransferToken({
|
|
107
|
+
...response,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
toggleNotification({
|
|
111
|
+
type: 'success',
|
|
112
|
+
message: isCreating
|
|
113
|
+
? formatMessage({
|
|
114
|
+
id: 'notification.success.transfertokencreated',
|
|
115
|
+
defaultMessage: 'Transfer Token successfully created',
|
|
116
|
+
})
|
|
117
|
+
: formatMessage({
|
|
118
|
+
id: 'notification.success.transfertokenedited',
|
|
119
|
+
defaultMessage: 'Transfer Token successfully edited',
|
|
120
|
+
}),
|
|
121
|
+
});
|
|
122
|
+
} catch (err) {
|
|
123
|
+
const errors = formatAPIErrors(err.response.data);
|
|
124
|
+
actions.setErrors(errors);
|
|
125
|
+
|
|
126
|
+
if (err?.response?.data?.error?.message === MSG_ERROR_NAME_TAKEN) {
|
|
127
|
+
toggleNotification({
|
|
128
|
+
type: 'warning',
|
|
129
|
+
message: err.response.data.message || 'notification.error.tokennamenotunique',
|
|
130
|
+
});
|
|
131
|
+
} else {
|
|
132
|
+
toggleNotification({
|
|
133
|
+
type: 'warning',
|
|
134
|
+
message: err?.response?.data?.message || 'notification.error',
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
unlockApp();
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const canEditInputs = (canUpdate && !isCreating) || (canCreate && isCreating);
|
|
142
|
+
const isLoading = !isCreating && !transferToken && status !== 'success';
|
|
143
|
+
|
|
144
|
+
if (isLoading) {
|
|
145
|
+
return <LoadingView transferTokenName={transferToken?.name} />;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return (
|
|
149
|
+
<Main>
|
|
150
|
+
<SettingsPageTitle name="Transfer Tokens" />
|
|
151
|
+
<Formik
|
|
152
|
+
validationSchema={schema}
|
|
153
|
+
validateOnChange={false}
|
|
154
|
+
initialValues={{
|
|
155
|
+
name: transferToken?.name || '',
|
|
156
|
+
description: transferToken?.description || '',
|
|
157
|
+
lifespan: transferToken?.lifespan
|
|
158
|
+
? transferToken.lifespan.toString()
|
|
159
|
+
: transferToken?.lifespan,
|
|
160
|
+
}}
|
|
161
|
+
enableReinitialize
|
|
162
|
+
onSubmit={(body, actions) => handleSubmit(body, actions)}
|
|
163
|
+
>
|
|
164
|
+
{({ errors, handleChange, isSubmitting, values }) => {
|
|
165
|
+
return (
|
|
166
|
+
<Form>
|
|
167
|
+
<FormHead
|
|
168
|
+
backUrl="/settings/transfer-tokens"
|
|
169
|
+
title={{
|
|
170
|
+
id: 'Settings.transferTokens.createPage.title',
|
|
171
|
+
defaultMessage: 'Create Transfer Token',
|
|
172
|
+
}}
|
|
173
|
+
token={transferToken}
|
|
174
|
+
setToken={setTransferToken}
|
|
175
|
+
canEditInputs={canEditInputs}
|
|
176
|
+
canRegenerate={canRegenerate}
|
|
177
|
+
isSubmitting={isSubmitting}
|
|
178
|
+
regenerateUrl="/admin/transfer/tokens/"
|
|
179
|
+
/>
|
|
180
|
+
<ContentLayout>
|
|
181
|
+
<Stack spacing={6}>
|
|
182
|
+
{Boolean(transferToken?.name) && <TokenBox token={transferToken?.accessKey} />}
|
|
183
|
+
<FormTransferTokenContainer
|
|
184
|
+
errors={errors}
|
|
185
|
+
onChange={handleChange}
|
|
186
|
+
canEditInputs={canEditInputs}
|
|
187
|
+
isCreating={isCreating}
|
|
188
|
+
values={values}
|
|
189
|
+
transferToken={transferToken}
|
|
190
|
+
/>
|
|
191
|
+
</Stack>
|
|
192
|
+
</ContentLayout>
|
|
193
|
+
</Form>
|
|
194
|
+
);
|
|
195
|
+
}}
|
|
196
|
+
</Formik>
|
|
197
|
+
</Main>
|
|
198
|
+
);
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
export default TransferTokenCreateView;
|
package/admin/src/pages/SettingsPage/pages/TransferTokens/EditView/utils/getDateOfExpiration.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { addDays, format } from 'date-fns';
|
|
2
|
+
import * as locales from 'date-fns/locale';
|
|
3
|
+
|
|
4
|
+
const getDateOfExpiration = (createdAt, duration, language = 'en') => {
|
|
5
|
+
if (duration && typeof duration === 'number') {
|
|
6
|
+
const durationInDays = duration / 24 / 60 / 60 / 1000;
|
|
7
|
+
|
|
8
|
+
return format(addDays(new Date(createdAt), durationInDays), 'PPP', {
|
|
9
|
+
locale: locales[language],
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return 'Unlimited';
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default getDateOfExpiration;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as yup from 'yup';
|
|
2
|
+
import { translatedErrors } from '@strapi/helper-plugin';
|
|
3
|
+
|
|
4
|
+
const schema = yup.object().shape({
|
|
5
|
+
name: yup.string(translatedErrors.string).required(translatedErrors.required),
|
|
6
|
+
description: yup.string().nullable(),
|
|
7
|
+
lifespan: yup.number().integer().min(0).nullable().defined(translatedErrors.required),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export default schema;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { useQuery, useMutation, useQueryClient } from 'react-query';
|
|
4
|
+
import { useHistory } from 'react-router-dom';
|
|
5
|
+
import qs from 'qs';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
SettingsPageTitle,
|
|
9
|
+
useFocusWhenNavigate,
|
|
10
|
+
useNotification,
|
|
11
|
+
NoPermissions,
|
|
12
|
+
useRBAC,
|
|
13
|
+
NoContent,
|
|
14
|
+
useGuidedTour,
|
|
15
|
+
LinkButton,
|
|
16
|
+
useFetchClient,
|
|
17
|
+
} from '@strapi/helper-plugin';
|
|
18
|
+
import { HeaderLayout, ContentLayout } from '@strapi/design-system/Layout';
|
|
19
|
+
import { Main } from '@strapi/design-system/Main';
|
|
20
|
+
import { Button } from '@strapi/design-system/Button';
|
|
21
|
+
import Plus from '@strapi/icons/Plus';
|
|
22
|
+
|
|
23
|
+
import adminPermissions from '../../../../../permissions';
|
|
24
|
+
import tableHeaders from './utils/tableHeaders';
|
|
25
|
+
import Table from '../../../components/Tokens/Table';
|
|
26
|
+
|
|
27
|
+
const TransferTokenListView = () => {
|
|
28
|
+
useFocusWhenNavigate();
|
|
29
|
+
const queryClient = useQueryClient();
|
|
30
|
+
const { formatMessage } = useIntl();
|
|
31
|
+
const toggleNotification = useNotification();
|
|
32
|
+
const {
|
|
33
|
+
allowedActions: { canCreate, canDelete, canUpdate, canRead },
|
|
34
|
+
} = useRBAC(adminPermissions.settings['transfer-tokens']);
|
|
35
|
+
const { push } = useHistory();
|
|
36
|
+
|
|
37
|
+
const { startSection } = useGuidedTour();
|
|
38
|
+
const startSectionRef = useRef(startSection);
|
|
39
|
+
const { get, del } = useFetchClient();
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (startSectionRef.current) {
|
|
43
|
+
startSectionRef.current('transferTokens');
|
|
44
|
+
}
|
|
45
|
+
}, []);
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
push({ search: qs.stringify({ sort: 'name:ASC' }, { encode: false }) });
|
|
49
|
+
}, [push]);
|
|
50
|
+
|
|
51
|
+
const headers = tableHeaders.map((header) => ({
|
|
52
|
+
...header,
|
|
53
|
+
metadatas: {
|
|
54
|
+
...header.metadatas,
|
|
55
|
+
label: formatMessage(header.metadatas.label),
|
|
56
|
+
},
|
|
57
|
+
}));
|
|
58
|
+
|
|
59
|
+
const {
|
|
60
|
+
data: transferTokens,
|
|
61
|
+
status,
|
|
62
|
+
isFetching,
|
|
63
|
+
} = useQuery(
|
|
64
|
+
['transfer-tokens'],
|
|
65
|
+
async () => {
|
|
66
|
+
const {
|
|
67
|
+
data: { data },
|
|
68
|
+
} = await get(`/admin/transfer/tokens`);
|
|
69
|
+
|
|
70
|
+
return data;
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
enabled: canRead,
|
|
74
|
+
onError() {
|
|
75
|
+
toggleNotification({
|
|
76
|
+
type: 'warning',
|
|
77
|
+
message: { id: 'notification.error', defaultMessage: 'An error occured' },
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const isLoading =
|
|
84
|
+
canRead &&
|
|
85
|
+
((status !== 'success' && status !== 'error') || (status === 'success' && isFetching));
|
|
86
|
+
|
|
87
|
+
const deleteMutation = useMutation(
|
|
88
|
+
async (id) => {
|
|
89
|
+
await del(`/admin/transfer/tokens/${id}`);
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
async onSuccess() {
|
|
93
|
+
await queryClient.invalidateQueries(['transfer-tokens']);
|
|
94
|
+
},
|
|
95
|
+
onError(err) {
|
|
96
|
+
if (err?.response?.data?.data) {
|
|
97
|
+
toggleNotification({ type: 'warning', message: err.response.data.data });
|
|
98
|
+
} else {
|
|
99
|
+
toggleNotification({
|
|
100
|
+
type: 'warning',
|
|
101
|
+
message: { id: 'notification.error', defaultMessage: 'An error occured' },
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const shouldDisplayDynamicTable = canRead && transferTokens;
|
|
109
|
+
const shouldDisplayNoContent = canRead && !transferTokens && !canCreate;
|
|
110
|
+
const shouldDisplayNoContentWithCreationButton = canRead && !transferTokens && canCreate;
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<Main aria-busy={isLoading}>
|
|
114
|
+
<SettingsPageTitle name="Transfer Tokens" />
|
|
115
|
+
<HeaderLayout
|
|
116
|
+
title={formatMessage({
|
|
117
|
+
id: 'Settings.transferTokens.title',
|
|
118
|
+
defaultMessage: 'Transfer Tokens',
|
|
119
|
+
})}
|
|
120
|
+
subtitle={formatMessage({
|
|
121
|
+
id: 'Settings.transferTokens.description',
|
|
122
|
+
defaultMessage: '"List of generated transfer tokens"', // TODO change this message
|
|
123
|
+
})}
|
|
124
|
+
primaryAction={
|
|
125
|
+
canCreate ? (
|
|
126
|
+
<LinkButton
|
|
127
|
+
data-testid="create-transfer-token-button"
|
|
128
|
+
startIcon={<Plus />}
|
|
129
|
+
size="S"
|
|
130
|
+
to="/settings/transfer-tokens/create"
|
|
131
|
+
>
|
|
132
|
+
{formatMessage({
|
|
133
|
+
id: 'Settings.transferTokens.create',
|
|
134
|
+
defaultMessage: 'Create new Transfer Token',
|
|
135
|
+
})}
|
|
136
|
+
</LinkButton>
|
|
137
|
+
) : undefined
|
|
138
|
+
}
|
|
139
|
+
/>
|
|
140
|
+
<ContentLayout>
|
|
141
|
+
{!canRead && <NoPermissions />}
|
|
142
|
+
{shouldDisplayDynamicTable && (
|
|
143
|
+
<Table
|
|
144
|
+
permissions={{ canRead, canDelete, canUpdate }}
|
|
145
|
+
headers={headers}
|
|
146
|
+
contentType="trasfer-tokens"
|
|
147
|
+
rows={transferTokens}
|
|
148
|
+
isLoading={isLoading}
|
|
149
|
+
onConfirmDelete={(id) => deleteMutation.mutateAsync(id)}
|
|
150
|
+
tokens={transferTokens}
|
|
151
|
+
/>
|
|
152
|
+
)}
|
|
153
|
+
{shouldDisplayNoContentWithCreationButton && (
|
|
154
|
+
<NoContent
|
|
155
|
+
content={{
|
|
156
|
+
id: 'Settings.transferTokens.addFirstToken',
|
|
157
|
+
defaultMessage: 'Add your first Transfer Token',
|
|
158
|
+
}}
|
|
159
|
+
action={
|
|
160
|
+
<Button variant="secondary" startIcon={<Plus />}>
|
|
161
|
+
{formatMessage({
|
|
162
|
+
id: 'Settings.transferTokens.addNewToken',
|
|
163
|
+
defaultMessage: 'Add new Transfer Token',
|
|
164
|
+
})}
|
|
165
|
+
</Button>
|
|
166
|
+
}
|
|
167
|
+
/>
|
|
168
|
+
)}
|
|
169
|
+
{shouldDisplayNoContent && (
|
|
170
|
+
<NoContent
|
|
171
|
+
content={{
|
|
172
|
+
id: 'Settings.transferTokens.emptyStateLayout',
|
|
173
|
+
defaultMessage: 'You don’t have any content yet...',
|
|
174
|
+
}}
|
|
175
|
+
/>
|
|
176
|
+
)}
|
|
177
|
+
</ContentLayout>
|
|
178
|
+
</Main>
|
|
179
|
+
);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
export default TransferTokenListView;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const tableHeaders = [
|
|
2
|
+
{
|
|
3
|
+
name: 'name',
|
|
4
|
+
key: 'name',
|
|
5
|
+
metadatas: {
|
|
6
|
+
label: {
|
|
7
|
+
id: 'Settings.transferTokens.ListView.headers.name',
|
|
8
|
+
defaultMessage: 'Name',
|
|
9
|
+
},
|
|
10
|
+
sortable: true,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'description',
|
|
15
|
+
key: 'description',
|
|
16
|
+
metadatas: {
|
|
17
|
+
label: {
|
|
18
|
+
id: 'Settings.transferTokens.ListView.headers.description',
|
|
19
|
+
defaultMessage: 'Description',
|
|
20
|
+
},
|
|
21
|
+
sortable: false,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'createdAt',
|
|
26
|
+
key: 'createdAt',
|
|
27
|
+
metadatas: {
|
|
28
|
+
label: {
|
|
29
|
+
id: 'Settings.transferTokens.ListView.headers.createdAt',
|
|
30
|
+
defaultMessage: 'Created at',
|
|
31
|
+
},
|
|
32
|
+
sortable: false,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'lastUsedAt',
|
|
37
|
+
key: 'lastUsedAt',
|
|
38
|
+
metadatas: {
|
|
39
|
+
label: {
|
|
40
|
+
id: 'Settings.transferTokens.ListView.headers.lastUsedAt',
|
|
41
|
+
defaultMessage: 'Last used',
|
|
42
|
+
},
|
|
43
|
+
sortable: false,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
export default tableHeaders;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CheckPagePermissions } from '@strapi/helper-plugin';
|
|
3
|
+
import adminPermissions from '../../../../../permissions';
|
|
4
|
+
import EditView from '../EditView';
|
|
5
|
+
|
|
6
|
+
const ProtectedTransferTokenCreateView = () => {
|
|
7
|
+
return (
|
|
8
|
+
<CheckPagePermissions permissions={adminPermissions.settings['transfer-tokens'].create}>
|
|
9
|
+
<EditView />
|
|
10
|
+
</CheckPagePermissions>
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default ProtectedTransferTokenCreateView;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CheckPagePermissions } from '@strapi/helper-plugin';
|
|
3
|
+
import adminPermissions from '../../../../../permissions';
|
|
4
|
+
import EditView from '../EditView';
|
|
5
|
+
|
|
6
|
+
const ProtectedTransferTokenCreateView = () => {
|
|
7
|
+
return (
|
|
8
|
+
<CheckPagePermissions permissions={adminPermissions.settings['transfer-tokens'].read}>
|
|
9
|
+
<EditView />
|
|
10
|
+
</CheckPagePermissions>
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default ProtectedTransferTokenCreateView;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CheckPagePermissions } from '@strapi/helper-plugin';
|
|
3
|
+
import adminPermissions from '../../../../../permissions';
|
|
4
|
+
import ListView from '../ListView';
|
|
5
|
+
|
|
6
|
+
const ProtectedTransferTokenListView = () => (
|
|
7
|
+
<CheckPagePermissions permissions={adminPermissions.settings['transfer-tokens'].main}>
|
|
8
|
+
<ListView />
|
|
9
|
+
</CheckPagePermissions>
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export default ProtectedTransferTokenListView;
|
|
@@ -123,6 +123,39 @@ const defaultRoutes = [
|
|
|
123
123
|
to: '/settings/api-tokens/:id',
|
|
124
124
|
exact: true,
|
|
125
125
|
},
|
|
126
|
+
{
|
|
127
|
+
async Component() {
|
|
128
|
+
const component = await import(
|
|
129
|
+
/* webpackChunkName: "transfer-tokens-create-page" */ '../pages/TransferTokens/ProtectedCreateView'
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
return component;
|
|
133
|
+
},
|
|
134
|
+
to: '/settings/transfer-tokens/create',
|
|
135
|
+
exact: true,
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
async Component() {
|
|
139
|
+
const component = await import(
|
|
140
|
+
/* webpackChunkName: "transfer-tokens-list-page" */ '../pages/TransferTokens/ProtectedListView'
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
return component;
|
|
144
|
+
},
|
|
145
|
+
to: '/settings/transfer-tokens',
|
|
146
|
+
exact: true,
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
async Component() {
|
|
150
|
+
const component = await import(
|
|
151
|
+
/* webpackChunkName: "transfer-tokens-edit-page" */ '../pages/TransferTokens/ProtectedEditView'
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
return component;
|
|
155
|
+
},
|
|
156
|
+
to: '/settings/transfer-tokens/:id',
|
|
157
|
+
exact: true,
|
|
158
|
+
},
|
|
126
159
|
];
|
|
127
160
|
|
|
128
161
|
export default defaultRoutes;
|
|
@@ -87,6 +87,14 @@ const permissions = {
|
|
|
87
87
|
update: [{ action: 'admin::api-tokens.update', subject: null }],
|
|
88
88
|
regenerate: [{ action: 'admin::api-tokens.regenerate', subject: null }],
|
|
89
89
|
},
|
|
90
|
+
'transfer-tokens': {
|
|
91
|
+
main: [{ action: 'admin::transfer.tokens.access', subject: null }],
|
|
92
|
+
create: [{ action: 'admin::transfer.tokens.create', subject: null }],
|
|
93
|
+
delete: [{ action: 'admin::transfer.tokens.delete', subject: null }],
|
|
94
|
+
read: [{ action: 'admin::transfer.tokens.read', subject: null }],
|
|
95
|
+
update: [{ action: 'admin::transfer.tokens.update', subject: null }],
|
|
96
|
+
regenerate: [{ action: 'admin::transfer.tokens.regenerate', subject: null }],
|
|
97
|
+
},
|
|
90
98
|
'project-settings': {
|
|
91
99
|
read: [{ action: 'admin::project-settings.read', subject: null }],
|
|
92
100
|
update: [{ action: 'admin::project-settings.update', subject: null }],
|
|
@@ -109,6 +109,17 @@
|
|
|
109
109
|
"Settings.apiTokens.popUpWarning.message": "Are you sure you want to regenerate this token?",
|
|
110
110
|
"Settings.apiTokens.Button.cancel": "Cancel",
|
|
111
111
|
"Settings.apiTokens.Button.regenerate": "Regenerate",
|
|
112
|
+
"Settings.transferTokens.title": "Transfer Tokens",
|
|
113
|
+
"Settings.transferTokens.description": "List of generated transfer tokens",
|
|
114
|
+
"Settings.transferTokens.create": "Create new Transfer Token",
|
|
115
|
+
"Settings.transferTokens.addFirstToken": "Add your first Transfer Token",
|
|
116
|
+
"Settings.transferTokens.addNewToken": "Add new Transfer Token",
|
|
117
|
+
"Settings.transferTokens.emptyStateLayout": "You don’t have any content yet...",
|
|
118
|
+
"Settings.transferTokens.ListView.headers.name": "Name",
|
|
119
|
+
"Settings.transferTokens.ListView.headers.description": "Description",
|
|
120
|
+
"Settings.transferTokens.ListView.headers.type": "Token type",
|
|
121
|
+
"Settings.transferTokens.ListView.headers.createdAt": "Created at",
|
|
122
|
+
"Settings.transferTokens.ListView.headers.lastUsedAt": "Last used",
|
|
112
123
|
"Settings.application.description": "Administration panel’s global information",
|
|
113
124
|
"Settings.application.edition-title": "current plan",
|
|
114
125
|
"Settings.application.get-help": "Get help",
|
|
@@ -433,7 +444,11 @@
|
|
|
433
444
|
"app.components.Official": "Official",
|
|
434
445
|
"app.components.Onboarding.help.button": "Help button",
|
|
435
446
|
"app.components.Onboarding.label.completed": "% completed",
|
|
436
|
-
"app.components.Onboarding.title": "Get
|
|
447
|
+
"app.components.Onboarding.title": "Get started videos",
|
|
448
|
+
"app.components.Onboarding.link.more-videos": "Watch more videos",
|
|
449
|
+
"app.components.Onboarding.link.build-content": "Build a content architecture",
|
|
450
|
+
"app.components.Onboarding.link.manage-content": "Add & manage content",
|
|
451
|
+
"app.components.Onboarding.link.manage-media": "Manage media",
|
|
437
452
|
"app.components.PluginCard.Button.label.download": "Download",
|
|
438
453
|
"app.components.PluginCard.Button.label.install": "Already installed",
|
|
439
454
|
"app.components.PluginCard.PopUpWarning.install.impossible.autoReload.needed": "The autoReload feature needs to be enabled. Please start your app with `yarn develop`.",
|
|
@@ -841,6 +856,8 @@
|
|
|
841
856
|
"notification.success.title": "Success:",
|
|
842
857
|
"notification.success.tokencreated": "API Token successfully created",
|
|
843
858
|
"notification.success.tokenedited": "API Token successfully edited",
|
|
859
|
+
"notification.success.transfertokencreated": "Transfer Token successfully created",
|
|
860
|
+
"notification.success.transfertokenedited": "Transfer Token successfully edited",
|
|
844
861
|
"notification.error.tokennamenotunique": "Name already assigned to another token",
|
|
845
862
|
"notification.version.update.message": "A new version of Strapi is available!",
|
|
846
863
|
"notification.warning.title": "Warning:",
|
|
Binary file
|