@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,148 +0,0 @@
|
|
|
1
|
-
import React, { memo } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { useIntl } from 'react-intl';
|
|
4
|
-
import isEmpty from 'lodash/isEmpty';
|
|
5
|
-
import { createFilter } from 'react-select';
|
|
6
|
-
import { ReactSelect as Select } from '@strapi/helper-plugin';
|
|
7
|
-
import { Box } from '@strapi/design-system/Box';
|
|
8
|
-
import { Stack } from '@strapi/design-system/Stack';
|
|
9
|
-
import { Typography } from '@strapi/design-system/Typography';
|
|
10
|
-
import ListItem from './ListItem';
|
|
11
|
-
|
|
12
|
-
function SelectMany({
|
|
13
|
-
addRelation,
|
|
14
|
-
components,
|
|
15
|
-
displayNavigationLink,
|
|
16
|
-
mainField,
|
|
17
|
-
name,
|
|
18
|
-
isDisabled,
|
|
19
|
-
isLoading,
|
|
20
|
-
loadingMessage,
|
|
21
|
-
onInputChange,
|
|
22
|
-
onMenuClose,
|
|
23
|
-
onMenuOpen,
|
|
24
|
-
onMenuScrollToBottom,
|
|
25
|
-
onRemove,
|
|
26
|
-
options,
|
|
27
|
-
placeholder,
|
|
28
|
-
searchToPersist,
|
|
29
|
-
targetModel,
|
|
30
|
-
value,
|
|
31
|
-
description,
|
|
32
|
-
}) {
|
|
33
|
-
const { formatMessage } = useIntl();
|
|
34
|
-
|
|
35
|
-
const filterConfig = {
|
|
36
|
-
ignoreCase: true,
|
|
37
|
-
ignoreAccents: true,
|
|
38
|
-
trim: false,
|
|
39
|
-
matchFrom: 'any',
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<Stack spacing={1}>
|
|
44
|
-
<Select
|
|
45
|
-
components={components}
|
|
46
|
-
isDisabled={isDisabled}
|
|
47
|
-
id={name}
|
|
48
|
-
filterOption={(candidate, input) => {
|
|
49
|
-
if (!isEmpty(value)) {
|
|
50
|
-
const isSelected = value.findIndex((item) => item.id === candidate.value.id) !== -1;
|
|
51
|
-
|
|
52
|
-
if (isSelected) {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (input) {
|
|
58
|
-
return createFilter(filterConfig)(candidate, input);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return true;
|
|
62
|
-
}}
|
|
63
|
-
mainField={mainField}
|
|
64
|
-
isLoading={isLoading}
|
|
65
|
-
loadingMessage={loadingMessage}
|
|
66
|
-
isMulti
|
|
67
|
-
isSearchable
|
|
68
|
-
options={options}
|
|
69
|
-
onChange={addRelation}
|
|
70
|
-
onInputChange={onInputChange}
|
|
71
|
-
onMenuClose={onMenuClose}
|
|
72
|
-
onMenuOpen={onMenuOpen}
|
|
73
|
-
onMenuScrollToBottom={onMenuScrollToBottom}
|
|
74
|
-
placeholder={formatMessage(
|
|
75
|
-
placeholder || { id: 'global.select', defaultMessage: 'Select...' }
|
|
76
|
-
)}
|
|
77
|
-
value={[]}
|
|
78
|
-
/>
|
|
79
|
-
<Box paddingTop={3} style={{ overflow: 'auto' }}>
|
|
80
|
-
<Stack as="ul" spacing={4} style={{ maxHeight: '128px', overflowX: 'hidden' }}>
|
|
81
|
-
{value?.map((data, index) => {
|
|
82
|
-
return (
|
|
83
|
-
<ListItem
|
|
84
|
-
key={data.id}
|
|
85
|
-
data={data}
|
|
86
|
-
displayNavigationLink={displayNavigationLink}
|
|
87
|
-
isDisabled={isDisabled}
|
|
88
|
-
mainField={mainField}
|
|
89
|
-
onRemove={() => {
|
|
90
|
-
if (!isDisabled) {
|
|
91
|
-
onRemove(`${name}.${index}`);
|
|
92
|
-
}
|
|
93
|
-
}}
|
|
94
|
-
searchToPersist={searchToPersist}
|
|
95
|
-
targetModel={targetModel}
|
|
96
|
-
/>
|
|
97
|
-
);
|
|
98
|
-
})}
|
|
99
|
-
</Stack>
|
|
100
|
-
</Box>
|
|
101
|
-
{description && (
|
|
102
|
-
<Typography variant="pi" textColor="neutral600">
|
|
103
|
-
{description}
|
|
104
|
-
</Typography>
|
|
105
|
-
)}
|
|
106
|
-
</Stack>
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
SelectMany.defaultProps = {
|
|
111
|
-
description: '',
|
|
112
|
-
components: {},
|
|
113
|
-
placeholder: null,
|
|
114
|
-
searchToPersist: null,
|
|
115
|
-
value: null,
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
SelectMany.propTypes = {
|
|
119
|
-
addRelation: PropTypes.func.isRequired,
|
|
120
|
-
components: PropTypes.object,
|
|
121
|
-
displayNavigationLink: PropTypes.bool.isRequired,
|
|
122
|
-
isDisabled: PropTypes.bool.isRequired,
|
|
123
|
-
isLoading: PropTypes.bool.isRequired,
|
|
124
|
-
loadingMessage: PropTypes.func.isRequired,
|
|
125
|
-
mainField: PropTypes.shape({
|
|
126
|
-
name: PropTypes.string.isRequired,
|
|
127
|
-
schema: PropTypes.shape({
|
|
128
|
-
type: PropTypes.string.isRequired,
|
|
129
|
-
}).isRequired,
|
|
130
|
-
}).isRequired,
|
|
131
|
-
name: PropTypes.string.isRequired,
|
|
132
|
-
onInputChange: PropTypes.func.isRequired,
|
|
133
|
-
onMenuClose: PropTypes.func.isRequired,
|
|
134
|
-
onMenuOpen: PropTypes.func.isRequired,
|
|
135
|
-
onMenuScrollToBottom: PropTypes.func.isRequired,
|
|
136
|
-
onRemove: PropTypes.func.isRequired,
|
|
137
|
-
options: PropTypes.array.isRequired,
|
|
138
|
-
placeholder: PropTypes.shape({
|
|
139
|
-
id: PropTypes.string.isRequired,
|
|
140
|
-
defaultMessage: PropTypes.string.isRequired,
|
|
141
|
-
}),
|
|
142
|
-
searchToPersist: PropTypes.string,
|
|
143
|
-
targetModel: PropTypes.string.isRequired,
|
|
144
|
-
value: PropTypes.array,
|
|
145
|
-
description: PropTypes.string,
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
export default memo(SelectMany);
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { components } from 'react-select';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import styled from 'styled-components';
|
|
5
|
-
import { useIntl } from 'react-intl';
|
|
6
|
-
import { pxToRem } from '@strapi/helper-plugin';
|
|
7
|
-
import { Flex } from '@strapi/design-system/Flex';
|
|
8
|
-
import { Typography } from '@strapi/design-system/Typography';
|
|
9
|
-
import get from 'lodash/get';
|
|
10
|
-
import has from 'lodash/has';
|
|
11
|
-
import isEmpty from 'lodash/isEmpty';
|
|
12
|
-
import { getTrad } from '../../utils';
|
|
13
|
-
|
|
14
|
-
const StyledBullet = styled.div`
|
|
15
|
-
flex-shrink: 0;
|
|
16
|
-
width: ${pxToRem(6)};
|
|
17
|
-
height: ${pxToRem(6)};
|
|
18
|
-
margin-right: ${({ theme }) => theme.spaces[2]};
|
|
19
|
-
background-color: ${({ theme, isDraft }) =>
|
|
20
|
-
theme.colors[isDraft ? 'secondary600' : 'success600']};
|
|
21
|
-
border-radius: 50%;
|
|
22
|
-
cursor: pointer;
|
|
23
|
-
`;
|
|
24
|
-
|
|
25
|
-
const SingleValue = (props) => {
|
|
26
|
-
const { formatMessage } = useIntl();
|
|
27
|
-
const Component = components.SingleValue;
|
|
28
|
-
const hasDraftAndPublish = has(get(props, 'data.value'), 'publishedAt');
|
|
29
|
-
const isDraft = isEmpty(get(props, 'data.value.publishedAt'));
|
|
30
|
-
|
|
31
|
-
if (hasDraftAndPublish) {
|
|
32
|
-
const draftMessage = {
|
|
33
|
-
id: getTrad('components.Select.draft-info-title'),
|
|
34
|
-
defaultMessage: 'State: Draft',
|
|
35
|
-
};
|
|
36
|
-
const publishedMessage = {
|
|
37
|
-
id: getTrad('components.Select.publish-info-title'),
|
|
38
|
-
defaultMessage: 'State: Published',
|
|
39
|
-
};
|
|
40
|
-
const title = isDraft ? formatMessage(draftMessage) : formatMessage(publishedMessage);
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<Component {...props}>
|
|
44
|
-
<Flex>
|
|
45
|
-
<StyledBullet title={title} isDraft={isDraft} />
|
|
46
|
-
<Typography ellipsis>{props.data.label ?? '-'}</Typography>
|
|
47
|
-
</Flex>
|
|
48
|
-
</Component>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return <Component {...props}>{props.data.label ?? '-'}</Component>;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
SingleValue.propTypes = {
|
|
56
|
-
data: PropTypes.object.isRequired,
|
|
57
|
-
selectProps: PropTypes.shape({
|
|
58
|
-
mainField: PropTypes.shape({
|
|
59
|
-
name: PropTypes.string.isRequired,
|
|
60
|
-
schema: PropTypes.shape({
|
|
61
|
-
type: PropTypes.string.isRequired,
|
|
62
|
-
}).isRequired,
|
|
63
|
-
}).isRequired,
|
|
64
|
-
}).isRequired,
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export default SingleValue;
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import React, { memo } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { useIntl } from 'react-intl';
|
|
4
|
-
import { Stack } from '@strapi/design-system/Stack';
|
|
5
|
-
import { Typography } from '@strapi/design-system/Typography';
|
|
6
|
-
import get from 'lodash/get';
|
|
7
|
-
import isNull from 'lodash/isNull';
|
|
8
|
-
import { ReactSelect as Select } from '@strapi/helper-plugin';
|
|
9
|
-
import SingleValue from './SingleValue';
|
|
10
|
-
|
|
11
|
-
function SelectOne({
|
|
12
|
-
components,
|
|
13
|
-
mainField,
|
|
14
|
-
name,
|
|
15
|
-
isDisabled,
|
|
16
|
-
isLoading,
|
|
17
|
-
loadingMessage,
|
|
18
|
-
onChange,
|
|
19
|
-
onInputChange,
|
|
20
|
-
onMenuClose,
|
|
21
|
-
onMenuOpen,
|
|
22
|
-
onMenuScrollToBottom,
|
|
23
|
-
options,
|
|
24
|
-
placeholder,
|
|
25
|
-
value,
|
|
26
|
-
description,
|
|
27
|
-
}) {
|
|
28
|
-
const { formatMessage } = useIntl();
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<Stack spacing={1}>
|
|
32
|
-
<Select
|
|
33
|
-
components={{
|
|
34
|
-
...components,
|
|
35
|
-
SingleValue,
|
|
36
|
-
}}
|
|
37
|
-
id={name}
|
|
38
|
-
isClearable
|
|
39
|
-
isDisabled={isDisabled}
|
|
40
|
-
isLoading={isLoading}
|
|
41
|
-
loadingMessage={loadingMessage}
|
|
42
|
-
mainField={mainField}
|
|
43
|
-
options={options}
|
|
44
|
-
onChange={onChange}
|
|
45
|
-
onInputChange={onInputChange}
|
|
46
|
-
onMenuClose={onMenuClose}
|
|
47
|
-
onMenuOpen={onMenuOpen}
|
|
48
|
-
onMenuScrollToBottom={onMenuScrollToBottom}
|
|
49
|
-
placeholder={formatMessage(
|
|
50
|
-
placeholder || { id: 'global.select', defaultMessage: 'Select...' }
|
|
51
|
-
)}
|
|
52
|
-
value={isNull(value) ? null : { label: get(value, [mainField.name], ''), value }}
|
|
53
|
-
/>
|
|
54
|
-
|
|
55
|
-
{description && (
|
|
56
|
-
<Typography variant="pi" textColor="neutral600">
|
|
57
|
-
{description}
|
|
58
|
-
</Typography>
|
|
59
|
-
)}
|
|
60
|
-
</Stack>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
SelectOne.defaultProps = {
|
|
65
|
-
description: '',
|
|
66
|
-
components: {},
|
|
67
|
-
placeholder: null,
|
|
68
|
-
value: null,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
SelectOne.propTypes = {
|
|
72
|
-
components: PropTypes.object,
|
|
73
|
-
isDisabled: PropTypes.bool.isRequired,
|
|
74
|
-
isLoading: PropTypes.bool.isRequired,
|
|
75
|
-
loadingMessage: PropTypes.func.isRequired,
|
|
76
|
-
mainField: PropTypes.shape({
|
|
77
|
-
name: PropTypes.string.isRequired,
|
|
78
|
-
schema: PropTypes.shape({
|
|
79
|
-
type: PropTypes.string.isRequired,
|
|
80
|
-
}).isRequired,
|
|
81
|
-
}).isRequired,
|
|
82
|
-
name: PropTypes.string.isRequired,
|
|
83
|
-
onChange: PropTypes.func.isRequired,
|
|
84
|
-
onInputChange: PropTypes.func.isRequired,
|
|
85
|
-
onMenuClose: PropTypes.func.isRequired,
|
|
86
|
-
onMenuOpen: PropTypes.func.isRequired,
|
|
87
|
-
onMenuScrollToBottom: PropTypes.func.isRequired,
|
|
88
|
-
options: PropTypes.array.isRequired,
|
|
89
|
-
placeholder: PropTypes.shape({
|
|
90
|
-
id: PropTypes.string.isRequired,
|
|
91
|
-
defaultMessage: PropTypes.string.isRequired,
|
|
92
|
-
}),
|
|
93
|
-
value: PropTypes.object,
|
|
94
|
-
description: PropTypes.string,
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export default memo(SelectOne);
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { useIntl } from 'react-intl';
|
|
4
|
-
import styled from 'styled-components';
|
|
5
|
-
import { Box } from '@strapi/design-system/Box';
|
|
6
|
-
import { Flex } from '@strapi/design-system/Flex';
|
|
7
|
-
import { Typography } from '@strapi/design-system/Typography';
|
|
8
|
-
|
|
9
|
-
const LabelAction = styled(Box)`
|
|
10
|
-
svg path {
|
|
11
|
-
fill: ${({ theme }) => theme.colors.neutral500};
|
|
12
|
-
}
|
|
13
|
-
`;
|
|
14
|
-
|
|
15
|
-
const Label = ({ intlLabel, id, labelAction, link, name, numberOfEntries, isSingle }) => {
|
|
16
|
-
const { formatMessage } = useIntl();
|
|
17
|
-
const label = intlLabel?.id ? formatMessage(intlLabel) : name;
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<Flex justifyContent="space-between">
|
|
21
|
-
<Flex>
|
|
22
|
-
<Typography
|
|
23
|
-
textColor="neutral800"
|
|
24
|
-
htmlFor={id || name}
|
|
25
|
-
variant="pi"
|
|
26
|
-
fontWeight="bold"
|
|
27
|
-
as="label"
|
|
28
|
-
>
|
|
29
|
-
{label}
|
|
30
|
-
{!isSingle && <> ({numberOfEntries})</>}
|
|
31
|
-
</Typography>
|
|
32
|
-
{labelAction && <LabelAction paddingLeft={1}>{labelAction}</LabelAction>}
|
|
33
|
-
</Flex>
|
|
34
|
-
{link}
|
|
35
|
-
</Flex>
|
|
36
|
-
);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
Label.defaultProps = {
|
|
40
|
-
id: undefined,
|
|
41
|
-
labelAction: undefined,
|
|
42
|
-
link: null,
|
|
43
|
-
numberOfEntries: 0,
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
Label.propTypes = {
|
|
47
|
-
id: PropTypes.string,
|
|
48
|
-
intlLabel: PropTypes.shape({
|
|
49
|
-
id: PropTypes.string.isRequired,
|
|
50
|
-
defaultMessage: PropTypes.string.isRequired,
|
|
51
|
-
values: PropTypes.object,
|
|
52
|
-
}).isRequired,
|
|
53
|
-
isSingle: PropTypes.bool.isRequired,
|
|
54
|
-
labelAction: PropTypes.element,
|
|
55
|
-
link: PropTypes.element,
|
|
56
|
-
name: PropTypes.string.isRequired,
|
|
57
|
-
numberOfEntries: PropTypes.number,
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export default Label;
|