@strapi/admin 4.5.0-alpha.0 → 4.5.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 +21 -18
- package/admin/src/assets/images/hot-air-balloon.png +0 -0
- package/admin/src/assets/images/icon_offline-cloud.svg +3 -3
- package/admin/src/assets/images/logo-strapi-2022.svg +7 -0
- package/admin/src/assets/images/upgrade-details.png +0 -0
- 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/CellContent/CellValue.js +1 -1
- package/admin/src/content-manager/components/DynamicTable/CellContent/RelationMultiple/index.js +5 -4
- package/admin/src/content-manager/components/DynamicTable/CellContent/index.js +10 -0
- package/admin/src/content-manager/components/DynamicTable/TableRows/index.js +20 -15
- package/admin/src/content-manager/components/DynamicTable/index.js +21 -4
- package/admin/src/content-manager/components/DynamicZone/components/Component/index.js +19 -9
- package/admin/src/content-manager/components/DynamicZone/index.js +6 -2
- package/admin/src/content-manager/components/EditViewDataManagerProvider/index.js +153 -63
- package/admin/src/content-manager/components/EditViewDataManagerProvider/reducer.js +180 -132
- package/admin/src/content-manager/components/EditViewDataManagerProvider/utils/cleanData.js +70 -16
- package/admin/src/content-manager/components/EditViewDataManagerProvider/utils/findLeafByPathAndReplace.js +52 -0
- package/admin/src/content-manager/components/EditViewDataManagerProvider/utils/index.js +2 -0
- package/admin/src/content-manager/components/EditViewDataManagerProvider/utils/recursivelyFindPathsBasedOnCondition.js +72 -0
- package/admin/src/content-manager/components/FieldComponent/index.js +9 -2
- 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/PreviewWysiwyg/index.js +1 -1
- package/admin/src/content-manager/components/RelationInput/RelationInput.js +163 -96
- 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 +116 -73
- package/admin/src/content-manager/components/RelationInputDataManager/utils/diffRelations.js +24 -0
- package/admin/src/content-manager/components/RelationInputDataManager/utils/index.js +3 -1
- package/admin/src/content-manager/components/RelationInputDataManager/utils/normalizeRelations.js +17 -31
- package/admin/src/content-manager/components/RelationInputDataManager/utils/normalizeSearchResults.js +16 -0
- package/admin/src/content-manager/components/RelationInputDataManager/utils/select.js +35 -11
- package/admin/src/content-manager/components/RepeatableComponent/DraggedItem/index.js +5 -0
- package/admin/src/content-manager/components/RepeatableComponent/index.js +4 -3
- package/admin/src/content-manager/components/SingleTypeFormWrapper/index.js +23 -0
- package/admin/src/content-manager/hooks/__test__/usePrev.test.js +26 -0
- package/admin/src/content-manager/hooks/index.js +1 -0
- package/admin/src/content-manager/hooks/useFetchContentTypeLayout/utils/formatLayouts.js +19 -48
- package/admin/src/content-manager/hooks/usePrev.js +14 -0
- package/admin/src/content-manager/hooks/useRelation/useRelation.js +116 -15
- package/admin/src/content-manager/pages/App/reducer.js +3 -0
- 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/ListSettingsView/components/DraggableCard.js +3 -3
- package/admin/src/content-manager/pages/ListSettingsView/components/Settings.js +2 -2
- package/admin/src/content-manager/pages/ListSettingsView/components/SortDisplayedFields.js +1 -1
- 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 +79 -0
- package/admin/src/core/apis/index.js +1 -0
- package/admin/src/core/store/configureStore.js +17 -2
- package/admin/src/favicon.png +0 -0
- package/admin/src/hooks/index.js +1 -0
- package/admin/src/hooks/useFetchMarketplacePlugins/index.js +2 -2
- package/admin/src/hooks/useFetchMarketplacePlugins/utils/api.js +4 -2
- package/admin/src/hooks/useFetchMarketplaceProviders/index.js +3 -3
- package/admin/src/hooks/useFetchMarketplaceProviders/utils/api.js +5 -3
- package/admin/src/hooks/useRegenerate/index.js +34 -0
- package/admin/src/index.js +1 -0
- package/admin/src/pages/App/index.js +1 -1
- package/admin/src/pages/HomePage/SocialLinks.js +1 -1
- package/admin/src/pages/HomePage/assets/corner-ornament.svg +48 -0
- package/admin/src/pages/HomePage/index.js +3 -2
- package/admin/src/pages/MarketplacePage/components/NpmPackageCard/CardButton.js +110 -0
- package/admin/src/pages/MarketplacePage/components/NpmPackageCard/InstallPluginButton.js +32 -21
- package/admin/src/pages/MarketplacePage/components/NpmPackageCard/PackageStats.js +79 -0
- package/admin/src/pages/MarketplacePage/components/NpmPackageCard/index.js +28 -11
- package/admin/src/pages/MarketplacePage/components/NpmPackagesFilters/FilterSelect.js +41 -0
- package/admin/src/pages/MarketplacePage/components/NpmPackagesFilters/FiltersPopover.js +96 -0
- package/admin/src/pages/MarketplacePage/components/NpmPackagesFilters/index.js +106 -0
- package/admin/src/pages/MarketplacePage/components/NpmPackagesGrid/index.js +4 -0
- package/admin/src/pages/MarketplacePage/components/SortSelect/index.js +70 -0
- package/admin/src/pages/MarketplacePage/index.js +68 -8
- 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 +255 -0
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/FormBody/index.js +78 -0
- package/admin/src/pages/SettingsPage/pages/ApiTokens/EditView/components/FormHead/index.js +89 -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 +216 -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/Roles/EditPage/components/ConditionsModal/ActionRow/index.js +7 -38
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/ConditionsModal/ActionRow/utils/options.js +31 -0
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/ConditionsModal/index.js +32 -43
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/ContentTypeCollapse/Collapse/index.js +1 -1
- package/admin/src/pages/SettingsPage/pages/Roles/ListPage/components/RoleRow/index.js +3 -1
- package/admin/src/pages/SettingsPage/pages/Roles/ListPage/index.js +2 -1
- package/admin/src/pages/SettingsPage/pages/Users/ListPage/ModalForm/index.js +2 -2
- package/admin/src/pages/SettingsPage/pages/Webhooks/EditView/components/EventInput/index.js +2 -2
- package/admin/src/permissions/defaultPermissions.js +2 -6
- package/admin/src/translations/ca.json +4 -2
- package/admin/src/translations/de.json +5 -2
- package/admin/src/translations/dk.json +4 -1
- package/admin/src/translations/en.json +38 -3
- package/admin/src/translations/es.json +157 -158
- package/admin/src/translations/fr.json +4 -1
- package/admin/src/translations/gu.json +608 -606
- package/admin/src/translations/he.json +1 -1
- package/admin/src/translations/hi.json +689 -687
- package/admin/src/translations/hu.json +3 -1
- package/admin/src/translations/id.json +3 -1
- package/admin/src/translations/it.json +3 -1
- package/admin/src/translations/ja.json +3 -1
- package/admin/src/translations/ko.json +3 -1
- package/admin/src/translations/ml.json +689 -687
- package/admin/src/translations/nl.json +4 -1
- package/admin/src/translations/no.json +1 -1
- package/admin/src/translations/pl.json +3 -1
- package/admin/src/translations/pt-BR.json +4 -1
- package/admin/src/translations/ru.json +489 -491
- package/admin/src/translations/sa.json +86 -83
- package/admin/src/translations/sk.json +4 -1
- package/admin/src/translations/sv.json +4 -1
- package/admin/src/translations/th.json +1 -1
- package/admin/src/translations/zh-Hans.json +5 -2
- package/admin/src/translations/zh.json +4 -1
- package/build/1856.172d5fa0.chunk.js +174 -0
- package/build/2077.058590f4.chunk.js +206 -0
- package/build/2912.2c42c07b.chunk.js +259 -0
- package/build/4318.5e670740.chunk.js +30 -0
- package/build/4715.22747b59.chunk.js +387 -0
- package/build/{4800.d09f1225.chunk.js → 4800.a6935af6.chunk.js} +1 -1
- package/build/4982.1b75ddb1.chunk.js +325 -0
- package/build/617f9c948fa79e6d73bd.png +0 -0
- package/build/6d21938306785f176538.png +0 -0
- package/build/70674f63fc3904c20de0.svg +7 -0
- package/build/7379.d246dd38.chunk.js +1 -0
- package/build/7692.a36fb2c2.chunk.js +470 -0
- package/build/7841.c50e9509.chunk.js +259 -0
- package/build/7866.ba215f99.chunk.js +505 -0
- package/build/7e9af4fb7e723fcebf1f.svg +48 -0
- package/build/8380.e53e7207.chunk.js +299 -0
- package/build/8549.832ed79d.chunk.js +159 -0
- package/build/8738.0fe8a61e.chunk.js +463 -0
- package/build/{9066.08049eb1.chunk.js → 9066.eaf76ff3.chunk.js} +5 -5
- package/build/{9166.037339e0.chunk.js → 9166.90876521.chunk.js} +16 -15
- package/build/{9420.43a86e7c.chunk.js → 9420.5292d1d2.chunk.js} +38 -37
- package/build/9649.468667d9.chunk.js +199 -0
- package/build/9d5d788027e86620c234.svg +5 -0
- package/build/{Admin-authenticatedApp.e39f36c9.chunk.js → Admin-authenticatedApp.c4f68103.chunk.js} +3 -3
- package/build/{Admin_homePage.118926e0.chunk.js → Admin_homePage.26d32e30.chunk.js} +6 -5
- package/build/Admin_marketplace.32375885.chunk.js +22 -0
- package/build/{Admin_profilePage.9d50ac44.chunk.js → Admin_profilePage.da32abbc.chunk.js} +1 -1
- package/build/Admin_settingsPage.bf2234e1.chunk.js +178 -0
- package/build/admin-app.9049056c.chunk.js +112 -0
- package/build/admin-edit-roles-page.69d9fcb2.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.07ae0f2c.chunk.js +1 -0
- package/build/content-manager.ff998bed.chunk.js +1204 -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-translation-sv-json.6deff030.chunk.js +1 -0
- package/build/content-type-builder.16af63a6.chunk.js +145 -0
- package/build/de-json.6b3e1894.chunk.js +1 -0
- package/build/dk-json.144c6a8e.chunk.js +1 -0
- package/build/{email-settings-page.64037147.chunk.js → email-settings-page.c3469093.chunk.js} +6 -6
- package/build/en-json.4a269f6b.chunk.js +1 -0
- package/build/es-json.6d123a82.chunk.js +1 -0
- package/build/fr-json.28ab54cb.chunk.js +1 -0
- package/build/gu-json.9a50ea64.chunk.js +1 -0
- package/build/he-json.72f18790.chunk.js +1 -0
- package/build/hi-json.0301b7ba.chunk.js +1 -0
- package/build/hu-json.c4b641bb.chunk.js +1 -0
- package/build/{i18n-settings-page.0b73785d.chunk.js → i18n-settings-page.46d894ff.chunk.js} +5 -5
- package/build/id-json.86035797.chunk.js +1 -0
- package/build/index.html +1 -1
- package/build/it-json.bbdc8993.chunk.js +1 -0
- package/build/ja-json.1c9eeeec.chunk.js +1 -0
- package/build/ko-json.e1f66398.chunk.js +1 -0
- package/build/main.91328e7a.js +9381 -0
- package/build/ml-json.963c889f.chunk.js +1 -0
- package/build/nl-json.2b8cc3a0.chunk.js +1 -0
- package/build/no-json.a58c28bd.chunk.js +1 -0
- package/build/pl-json.249626b3.chunk.js +1 -0
- package/build/pt-BR-json.7852f808.chunk.js +1 -0
- package/build/ru-json.d7cfc2ff.chunk.js +1 -0
- package/build/runtime~main.c9c319c0.js +2 -0
- package/build/sa-json.44e95991.chunk.js +1 -0
- package/build/sk-json.7ba4b330.chunk.js +1 -0
- package/build/sso-settings-page.9ceb0140.chunk.js +1 -0
- package/build/sv-json.8e5a7911.chunk.js +1 -0
- package/build/th-json.a67309b1.chunk.js +1 -0
- package/build/{upload-settings.80ff0974.chunk.js → upload-settings.53b690f3.chunk.js} +5 -5
- 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.3f4ee86e.chunk.js} +5 -5
- package/build/{webhook-edit-page.d2ea3351.chunk.js → webhook-edit-page.dc9442ce.chunk.js} +2 -2
- package/build/webhook-list-page.02191138.chunk.js +134 -0
- package/build/zh-Hans-json.21617c24.chunk.js +1 -0
- package/build/zh-json.608aaf24.chunk.js +1 -0
- package/ee/admin/pages/SettingsPage/pages/Roles/ListPage/index.js +3 -2
- package/ee/server/controllers/user.js +5 -3
- package/env.js +1 -0
- package/package.json +13 -11
- package/scripts/build.js +11 -0
- 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/create-plugins-exclude-path.js +40 -0
- package/utils/get-custom-app-config-file.js +5 -0
- package/webpack.alias.js +0 -13
- package/webpack.config.js +4 -1
- package/admin/src/assets/images/banner_strapi-rocket.png +0 -0
- package/admin/src/assets/images/big-logo-home.png +0 -0
- package/admin/src/assets/images/homepage-logo.png +0 -0
- package/admin/src/assets/images/icon_made-by-strapi.svg +0 -5
- package/admin/src/assets/images/logo_strapi_auth.png +0 -0
- package/admin/src/assets/images/logo_strapi_auth_v4.png +0 -0
- package/admin/src/assets/images/logo_strapi_menu.png +0 -0
- package/admin/src/assets/images/oops.png +0 -0
- package/admin/src/content-manager/components/State/index.js +0 -37
- package/admin/src/favicon.ico +0 -0
- package/build/15026a3d58aeb2828134.png +0 -0
- package/build/1856.47226450.chunk.js +0 -173
- package/build/2077.c935ee42.chunk.js +0 -205
- package/build/2912.a015078a.chunk.js +0 -258
- package/build/4715.58cd558f.chunk.js +0 -387
- package/build/4982.05eda880.chunk.js +0 -324
- package/build/7098.40dcd7bf.chunk.js +0 -1
- package/build/7841.91f793dc.chunk.js +0 -258
- package/build/7866.1201afbd.chunk.js +0 -504
- package/build/8380.8789ff76.chunk.js +0 -284
- package/build/8549.133c4473.chunk.js +0 -158
- package/build/8851.e4ac62f2.chunk.js +0 -158
- package/build/90f49a385afb000fb1d4.svg +0 -5
- package/build/9311.7cc03f29.chunk.js +0 -508
- package/build/Admin_marketplace.82c0570b.chunk.js +0 -11
- package/build/Admin_settingsPage.98a711e5.chunk.js +0 -178
- package/build/a6b842e0b6d2b61135d1.svg +0 -5
- 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/b997a22a2e0b87ef1fa2.ico +0 -0
- package/build/bd81ba6c07827282255d.png +0 -0
- package/build/c3de6118ef47086ad05c.png +0 -0
- package/build/ca-json.a16899ae.chunk.js +0 -1
- 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/de-json.aa6026b3.chunk.js +0 -1
- package/build/dk-json.fac2bcfb.chunk.js +0 -1
- package/build/en-json.0c69c7d7.chunk.js +0 -1
- package/build/es-json.d672e181.chunk.js +0 -1
- package/build/fb376b132d18bf4522ca.png +0 -0
- package/build/fde9b1ad0670d29a2516.png +0 -0
- package/build/fr-json.71a16175.chunk.js +0 -1
- package/build/gu-json.ca345cd1.chunk.js +0 -1
- package/build/he-json.3b825d80.chunk.js +0 -1
- package/build/hi-json.50c7e6d4.chunk.js +0 -1
- package/build/hu-json.e0521dcc.chunk.js +0 -1
- package/build/id-json.4b1ff8d6.chunk.js +0 -1
- package/build/it-json.86bac220.chunk.js +0 -1
- package/build/ja-json.4e44e36b.chunk.js +0 -1
- package/build/ko-json.1003756e.chunk.js +0 -1
- package/build/main.b47db1a3.js +0 -9337
- package/build/ml-json.c7774425.chunk.js +0 -1
- package/build/nl-json.f58ea235.chunk.js +0 -1
- package/build/no-json.40386397.chunk.js +0 -1
- package/build/pl-json.fed96aba.chunk.js +0 -1
- package/build/pt-BR-json.073799ab.chunk.js +0 -1
- package/build/ru-json.7ad2cbbf.chunk.js +0 -1
- package/build/runtime~main.feeac6d3.js +0 -2
- package/build/sa-json.f0f704f0.chunk.js +0 -1
- package/build/sk-json.a848961b.chunk.js +0 -1
- package/build/sso-settings-page.445184e0.chunk.js +0 -1
- package/build/sv-json.b038acbe.chunk.js +0 -1
- package/build/th-json.72e8de3d.chunk.js +0 -1
- package/build/webhook-list-page.2775a683.chunk.js +0 -134
- package/build/zh-Hans-json.03d2bda1.chunk.js +0 -1
- package/build/zh-json.3d0cc664.chunk.js +0 -1
- package/server/services/permission/engine-hooks.js +0 -82
|
@@ -0,0 +1,150 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
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;
|
|
@@ -0,0 +1,255 @@
|
|
|
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 !== null ? values.lifespan : '0'}
|
|
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="0">
|
|
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.oneOfType([PropTypes.number, 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
|
+
}),
|
|
246
|
+
onDispatch: PropTypes.func.isRequired,
|
|
247
|
+
setHasChangedPermissions: PropTypes.func.isRequired,
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
FormApiTokenContainer.defaultProps = {
|
|
251
|
+
errors: {},
|
|
252
|
+
apiToken: {},
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
export default FormApiTokenContainer;
|
|
@@ -0,0 +1,78 @@
|
|
|
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.oneOfType([PropTypes.number, 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
|
+
}),
|
|
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
|
+
apiToken: {},
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export default FormBody;
|
|
@@ -0,0 +1,89 @@
|
|
|
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.oneOfType([PropTypes.number, 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
|
+
}),
|
|
79
|
+
canEditInputs: PropTypes.bool.isRequired,
|
|
80
|
+
canRegenerate: PropTypes.bool.isRequired,
|
|
81
|
+
setApiToken: PropTypes.func.isRequired,
|
|
82
|
+
isSubmitting: PropTypes.bool.isRequired,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
FormHead.defaultProps = {
|
|
86
|
+
apiToken: undefined,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
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);
|