strapi-plugin-navigation 2.5.4 → 3.0.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/README.md +21 -43
- package/admin/api/client.js +107 -0
- package/admin/api/index.js +1 -0
- package/admin/api/validators.js +248 -0
- package/admin/components/ConfirmationDialog/index.js +21 -0
- package/admin/components/Initializer.js +10 -0
- package/admin/components/RestartAlert/index.js +7 -0
- package/admin/components/TextArrayInput/index.js +18 -0
- package/admin/components/icons/index.js +1 -0
- package/admin/components/icons/navigation.js +9 -0
- package/admin/components/icons/pluginIcon.js +9 -0
- package/admin/index.js +48 -0
- package/admin/pages/App.js +10 -0
- package/admin/pages/HomePage/components/AdditionalFieldInput/index.js +58 -0
- package/admin/pages/HomePage/components/CollapseButton/index.js +15 -0
- package/admin/{src → pages/HomePage}/components/DragButton/index.js +9 -16
- package/admin/pages/HomePage/components/I18nCopyNavigationItems/index.js +9 -0
- package/admin/pages/HomePage/components/NavigationContentHeader/index.js +5 -0
- package/admin/pages/HomePage/components/NavigationHeader/hooks.js +14 -0
- package/admin/pages/HomePage/components/NavigationHeader/index.js +29 -0
- package/admin/pages/HomePage/components/NavigationHeader/styles.js +11 -0
- package/admin/pages/HomePage/components/NavigationItemForm/index.js +277 -0
- package/admin/pages/HomePage/components/NavigationItemForm/types.js +1 -0
- package/admin/pages/HomePage/components/NavigationItemForm/utils/form.js +105 -0
- package/admin/pages/HomePage/components/NavigationItemForm/utils/hooks.js +12 -0
- package/admin/pages/HomePage/components/NavigationItemForm/utils/properties.js +51 -0
- package/admin/pages/HomePage/components/NavigationItemList/Wrapper.js +21 -0
- package/admin/pages/HomePage/components/NavigationItemList/index.js +6 -0
- package/admin/pages/HomePage/components/NavigationItemListItem/ItemCardBadge/index.js +20 -0
- package/admin/pages/HomePage/components/NavigationItemListItem/ItemCardHeader/Wrapper.js +14 -0
- package/admin/pages/HomePage/components/NavigationItemListItem/ItemCardHeader/icons.js +6 -0
- package/admin/pages/HomePage/components/NavigationItemListItem/ItemCardHeader/index.js +19 -0
- package/admin/pages/HomePage/components/NavigationItemListItem/ItemCardRemovedOverlay/index.js +11 -0
- package/admin/pages/HomePage/components/NavigationItemListItem/Wrapper.js +38 -0
- package/admin/pages/HomePage/components/NavigationItemListItem/index.js +165 -0
- package/admin/pages/HomePage/components/NavigationItemPopup/NavigationItemPopupFooter.js +11 -0
- package/admin/pages/HomePage/components/NavigationItemPopup/NavigationItemPopupHeader.js +12 -0
- package/admin/pages/HomePage/components/NavigationItemPopup/index.js +34 -0
- package/admin/pages/HomePage/components/NavigationManager/AllNavigations/icons.js +5 -0
- package/admin/pages/HomePage/components/NavigationManager/AllNavigations/index.js +79 -0
- package/admin/pages/HomePage/components/NavigationManager/DeletionConfirm/index.js +25 -0
- package/admin/pages/HomePage/components/NavigationManager/ErrorDetails/index.js +29 -0
- package/admin/pages/HomePage/components/NavigationManager/Footer/index.js +6 -0
- package/admin/pages/HomePage/components/NavigationManager/Form/hooks.js +19 -0
- package/admin/pages/HomePage/components/NavigationManager/Form/index.js +26 -0
- package/admin/pages/HomePage/components/NavigationManager/NavigationUpdate/index.js +32 -0
- package/admin/pages/HomePage/components/NavigationManager/NewNavigation/index.js +35 -0
- package/admin/pages/HomePage/components/NavigationManager/PurgeCacheConfirm/index.js +25 -0
- package/admin/pages/HomePage/components/NavigationManager/index.js +236 -0
- package/admin/pages/HomePage/components/NavigationManager/types.js +1 -0
- package/admin/pages/HomePage/components/Search/index.js +58 -0
- package/admin/pages/HomePage/components/index.js +1 -0
- package/admin/pages/HomePage/hooks/index.js +165 -0
- package/admin/pages/HomePage/index.js +231 -0
- package/admin/pages/HomePage/utils/index.js +16 -0
- package/admin/pages/HomePage/utils/parsers.js +187 -0
- package/admin/pages/SettingsPage/common/const.js +1 -0
- package/admin/pages/SettingsPage/common/index.js +1 -0
- package/admin/pages/SettingsPage/components/CustomFieldForm/hooks/index.js +10 -0
- package/admin/pages/SettingsPage/components/CustomFieldForm/index.js +36 -0
- package/admin/pages/SettingsPage/components/CustomFieldModal/index.js +16 -0
- package/admin/pages/SettingsPage/components/CustomFieldTable/index.js +45 -0
- package/admin/pages/SettingsPage/hooks/index.js +111 -0
- package/admin/pages/SettingsPage/index.js +189 -0
- package/admin/pages/SettingsPage/types.js +1 -0
- package/admin/pages/SettingsPage/utils/index.js +25 -0
- package/admin/pluginId.js +1 -0
- package/admin/schemas/config.js +53 -0
- package/admin/schemas/content-type.js +14 -0
- package/admin/schemas/index.js +2 -0
- package/admin/{src/translations → translations}/en.json +7 -9
- package/admin/translations/index.js +15 -0
- package/admin/types.js +1 -0
- package/admin/utils/constants.js +1 -0
- package/admin/utils/getTranslation.js +4 -0
- package/admin/utils/permissions.js +16 -0
- package/admin/utils/prefixPluginTranslations.js +3 -0
- package/package.json +13 -11
- package/server/app-errors.js +20 -0
- package/server/bootstrap.js +13 -0
- package/server/cache/index.js +34 -15
- package/server/config/index.js +7 -5
- package/server/config/{setupStrategy.js → setup.js} +30 -26
- package/server/content-types/audience/index.js +0 -1
- package/server/content-types/audience/schema.js +0 -1
- package/server/content-types/index.js +4 -7
- package/server/content-types/navigation/index.js +0 -1
- package/server/content-types/navigation/lifecycles.js +1 -2
- package/server/content-types/navigation/schema.js +29 -32
- package/server/content-types/navigation-item/index.js +0 -1
- package/server/content-types/navigation-item/lifecycles.js +1 -2
- package/server/content-types/navigation-item/schema.js +51 -58
- package/server/controllers/admin.js +119 -158
- package/server/controllers/client.js +71 -60
- package/server/controllers/index.js +1 -3
- package/server/controllers/utils.js +22 -0
- package/{admin/src/hooks/useNavigationManager.js → server/controllers/validators.js} +23 -16
- package/server/destroy.js +3 -2
- package/{types/i18n.js → server/dtos/config.js} +0 -1
- package/server/{navigation → dtos}/index.js +3 -2
- package/server/dtos/navigation-item.js +2 -0
- package/{admin/src/pages/SettingsPage/types.js → server/dtos/navigation.js} +0 -1
- package/server/graphql/config.js +14 -16
- package/server/graphql/index.js +1 -2
- package/server/graphql/queries/index.js +8 -4
- package/server/graphql/queries/render-navigation-child.js +19 -8
- package/server/graphql/queries/render-navigation.js +30 -14
- package/server/graphql/resolvers-config.js +4 -2
- package/server/graphql/{setupStrategy.js → setup.js} +4 -5
- package/server/graphql/types/content-types-name-fields.js +10 -9
- package/server/graphql/types/content-types.js +15 -15
- package/server/graphql/types/create-navigation-item.js +16 -16
- package/server/graphql/types/create-navigation-related.js +7 -7
- package/server/graphql/types/create-navigation.js +6 -6
- package/server/graphql/types/index.js +35 -15
- package/server/graphql/types/navigation-config.js +8 -8
- package/server/graphql/types/navigation-details.js +2 -2
- package/server/graphql/types/navigation-item-additional-field-media.js +10 -10
- package/server/graphql/types/navigation-item-related-data.js +6 -6
- package/server/graphql/types/navigation-item-related.js +3 -3
- package/server/graphql/types/navigation-item.js +30 -27
- package/server/graphql/types/navigation-render-type.js +4 -5
- package/server/graphql/types/navigation.js +8 -8
- package/server/i18n/index.js +29 -20
- package/server/index.js +15 -8
- package/server/middlewares/index.js +3 -0
- package/server/permissions/index.js +10 -0
- package/{permissions.js → server/permissions/permissions.js} +0 -1
- package/server/permissions/setup.js +32 -0
- package/server/permissions.js +39 -0
- package/server/policies/index.js +3 -0
- package/server/register.js +6 -0
- package/server/repositories/audience.js +12 -0
- package/server/repositories/generic.js +20 -0
- package/server/repositories/index.js +11 -0
- package/server/repositories/navigation-item.js +51 -0
- package/server/repositories/navigation.js +65 -0
- package/server/routes/admin.js +86 -79
- package/server/routes/client.js +0 -1
- package/server/routes/index.js +0 -1
- package/server/schemas/config.js +68 -0
- package/server/schemas/content-type.js +140 -0
- package/{admin/src/pages/SettingsPage/common → server/schemas}/index.js +3 -2
- package/server/schemas/navigation.js +107 -0
- package/server/services/admin/admin.js +483 -0
- package/server/{content-types/navigations-items-related → services/admin}/index.js +2 -5
- package/{admin/src/pages/View/components/NavigationItemForm → server/services/admin}/types.js +0 -1
- package/server/services/admin/utils.js +84 -0
- package/server/services/client/client.js +397 -0
- package/server/services/client/index.js +7 -0
- package/{admin/src/pages/View/components/NavigationManager → server/services/client}/types.js +0 -1
- package/server/services/client/utils.js +88 -0
- package/server/services/common/common.js +307 -0
- package/server/services/common/index.js +7 -0
- package/{admin/src/components/AdditionalFieldInput → server/services/common}/types.js +0 -1
- package/server/services/common/utils.js +24 -0
- package/server/services/index.js +4 -6
- package/server/types.js +2 -0
- package/server/utils/constants.js +35 -0
- package/server/utils/functions.js +71 -299
- package/server/utils/index.js +1 -2
- package/strapi-admin.js +5 -8
- package/strapi-server.js +3 -7
- package/tsconfig.tsbuildinfo +1 -1
- package/admin/src/components/AdditionalFieldInput/index.d.ts +0 -5
- package/admin/src/components/AdditionalFieldInput/index.js +0 -99
- package/admin/src/components/AdditionalFieldInput/types.d.ts +0 -15
- package/admin/src/components/Alert/styles.d.ts +0 -2
- package/admin/src/components/Alert/styles.js +0 -14
- package/admin/src/components/CollapseButton/index.d.ts +0 -7
- package/admin/src/components/CollapseButton/index.js +0 -30
- package/admin/src/components/ConfirmationDialog/index.d.ts +0 -28
- package/admin/src/components/ConfirmationDialog/index.js +0 -34
- package/admin/src/components/DragButton/index.d.ts +0 -6
- package/admin/src/components/EmptyView/index.d.ts +0 -3
- package/admin/src/components/EmptyView/index.js +0 -30
- package/admin/src/components/Item/ItemCardBadge/index.d.ts +0 -3
- package/admin/src/components/Item/ItemCardBadge/index.js +0 -26
- package/admin/src/components/Item/ItemCardHeader/Wrapper.d.ts +0 -3
- package/admin/src/components/Item/ItemCardHeader/Wrapper.js +0 -21
- package/admin/src/components/Item/ItemCardHeader/icons.d.ts +0 -5
- package/admin/src/components/Item/ItemCardHeader/icons.js +0 -13
- package/admin/src/components/Item/ItemCardHeader/index.d.ts +0 -17
- package/admin/src/components/Item/ItemCardHeader/index.js +0 -38
- package/admin/src/components/Item/ItemCardRemovedOverlay/index.d.ts +0 -2
- package/admin/src/components/Item/ItemCardRemovedOverlay/index.js +0 -18
- package/admin/src/components/Item/Wrapper.d.ts +0 -3
- package/admin/src/components/Item/Wrapper.js +0 -43
- package/admin/src/components/Item/index.d.ts +0 -31
- package/admin/src/components/Item/index.js +0 -188
- package/admin/src/components/NavigationItemList/Wrapper.d.ts +0 -3
- package/admin/src/components/NavigationItemList/Wrapper.js +0 -26
- package/admin/src/components/NavigationItemList/index.d.ts +0 -36
- package/admin/src/components/NavigationItemList/index.js +0 -32
- package/admin/src/components/RestartAlert/index.d.ts +0 -3
- package/admin/src/components/RestartAlert/index.js +0 -13
- package/admin/src/components/Search/index.d.ts +0 -12
- package/admin/src/components/Search/index.js +0 -97
- package/admin/src/components/TextArrayInput/index.d.ts +0 -15
- package/admin/src/components/TextArrayInput/index.js +0 -45
- package/admin/src/components/icons/navigation.d.ts +0 -6
- package/admin/src/components/icons/navigation.js +0 -12
- package/admin/src/contexts/DataManagerContext.d.ts +0 -3
- package/admin/src/contexts/DataManagerContext.js +0 -6
- package/admin/src/hooks/useAllContentTypes.d.ts +0 -3
- package/admin/src/hooks/useAllContentTypes.js +0 -8
- package/admin/src/hooks/useDataManager.d.ts +0 -3
- package/admin/src/hooks/useDataManager.js +0 -10
- package/admin/src/hooks/useI18nCopyNavigationItemsModal.d.ts +0 -9
- package/admin/src/hooks/useI18nCopyNavigationItemsModal.js +0 -51
- package/admin/src/hooks/useNavigationConfig.d.ts +0 -10
- package/admin/src/hooks/useNavigationConfig.js +0 -54
- package/admin/src/hooks/useNavigationManager.d.ts +0 -6
- package/admin/src/index.d.ts +0 -14
- package/admin/src/index.js +0 -87
- package/admin/src/pages/App/index.d.ts +0 -3
- package/admin/src/pages/App/index.js +0 -43
- package/admin/src/pages/DataManagerProvider/actions.d.ts +0 -21
- package/admin/src/pages/DataManagerProvider/actions.js +0 -24
- package/admin/src/pages/DataManagerProvider/index.d.ts +0 -12
- package/admin/src/pages/DataManagerProvider/index.js +0 -382
- package/admin/src/pages/DataManagerProvider/init.d.ts +0 -3
- package/admin/src/pages/DataManagerProvider/init.js +0 -7
- package/admin/src/pages/DataManagerProvider/reducer.d.ts +0 -20
- package/admin/src/pages/DataManagerProvider/reducer.js +0 -132
- package/admin/src/pages/NoAccessPage/index.d.ts +0 -3
- package/admin/src/pages/NoAccessPage/index.js +0 -31
- package/admin/src/pages/SettingsPage/common/const.d.ts +0 -2
- package/admin/src/pages/SettingsPage/common/const.js +0 -5
- package/admin/src/pages/SettingsPage/common/index.d.ts +0 -2
- package/admin/src/pages/SettingsPage/components/CustomFieldForm/index.d.ts +0 -12
- package/admin/src/pages/SettingsPage/components/CustomFieldForm/index.js +0 -129
- package/admin/src/pages/SettingsPage/components/CustomFieldModal/index.d.ts +0 -12
- package/admin/src/pages/SettingsPage/components/CustomFieldModal/index.js +0 -20
- package/admin/src/pages/SettingsPage/components/CustomFieldTable/index.d.ts +0 -11
- package/admin/src/pages/SettingsPage/components/CustomFieldTable/index.js +0 -105
- package/admin/src/pages/SettingsPage/components/DisableI18nModal/index.d.ts +0 -23
- package/admin/src/pages/SettingsPage/components/DisableI18nModal/index.js +0 -86
- package/admin/src/pages/SettingsPage/index.d.ts +0 -3
- package/admin/src/pages/SettingsPage/index.js +0 -321
- package/admin/src/pages/SettingsPage/types.d.ts +0 -35
- package/admin/src/pages/SettingsPage/utils/form.d.ts +0 -20
- package/admin/src/pages/SettingsPage/utils/form.js +0 -37
- package/admin/src/pages/SettingsPage/utils/functions.d.ts +0 -3
- package/admin/src/pages/SettingsPage/utils/functions.js +0 -26
- package/admin/src/pages/View/components/I18nCopyNavigationItems/index.d.ts +0 -14
- package/admin/src/pages/View/components/I18nCopyNavigationItems/index.js +0 -15
- package/admin/src/pages/View/components/NavigationContentHeader/index.d.ts +0 -6
- package/admin/src/pages/View/components/NavigationContentHeader/index.js +0 -14
- package/admin/src/pages/View/components/NavigationHeader/index.d.ts +0 -14
- package/admin/src/pages/View/components/NavigationHeader/index.js +0 -92
- package/admin/src/pages/View/components/NavigationHeader/styles.d.ts +0 -2
- package/admin/src/pages/View/components/NavigationHeader/styles.js +0 -18
- package/admin/src/pages/View/components/NavigationItemForm/index.d.ts +0 -5
- package/admin/src/pages/View/components/NavigationItemForm/index.js +0 -470
- package/admin/src/pages/View/components/NavigationItemForm/types.d.ts +0 -99
- package/admin/src/pages/View/components/NavigationItemForm/utils/form.d.ts +0 -28
- package/admin/src/pages/View/components/NavigationItemForm/utils/form.js +0 -123
- package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupFooter.d.ts +0 -25
- package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupFooter.js +0 -31
- package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupHeader.d.ts +0 -5
- package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupHeader.js +0 -20
- package/admin/src/pages/View/components/NavigationItemPopup/index.d.ts +0 -33
- package/admin/src/pages/View/components/NavigationItemPopup/index.js +0 -90
- package/admin/src/pages/View/components/NavigationManager/AllNavigations/icons.d.ts +0 -4
- package/admin/src/pages/View/components/NavigationManager/AllNavigations/icons.js +0 -12
- package/admin/src/pages/View/components/NavigationManager/AllNavigations/index.d.ts +0 -8
- package/admin/src/pages/View/components/NavigationManager/AllNavigations/index.js +0 -151
- package/admin/src/pages/View/components/NavigationManager/DeletionConfirm/index.d.ts +0 -8
- package/admin/src/pages/View/components/NavigationManager/DeletionConfirm/index.js +0 -34
- package/admin/src/pages/View/components/NavigationManager/ErrorDetails/index.d.ts +0 -8
- package/admin/src/pages/View/components/NavigationManager/ErrorDetails/index.js +0 -53
- package/admin/src/pages/View/components/NavigationManager/Footer/index.d.ts +0 -24
- package/admin/src/pages/View/components/NavigationManager/Footer/index.js +0 -13
- package/admin/src/pages/View/components/NavigationManager/Form/index.d.ts +0 -19
- package/admin/src/pages/View/components/NavigationManager/Form/index.js +0 -103
- package/admin/src/pages/View/components/NavigationManager/NavigationUpdate/index.d.ts +0 -8
- package/admin/src/pages/View/components/NavigationManager/NavigationUpdate/index.js +0 -59
- package/admin/src/pages/View/components/NavigationManager/NewNavigation/index.d.ts +0 -9
- package/admin/src/pages/View/components/NavigationManager/NewNavigation/index.js +0 -62
- package/admin/src/pages/View/components/NavigationManager/PurgeCacheConfirm/index.d.ts +0 -8
- package/admin/src/pages/View/components/NavigationManager/PurgeCacheConfirm/index.js +0 -34
- package/admin/src/pages/View/components/NavigationManager/index.d.ts +0 -10
- package/admin/src/pages/View/components/NavigationManager/index.js +0 -203
- package/admin/src/pages/View/components/NavigationManager/types.d.ts +0 -44
- package/admin/src/pages/View/index.d.ts +0 -4
- package/admin/src/pages/View/index.js +0 -269
- package/admin/src/pages/View/utils/form.d.ts +0 -2
- package/admin/src/pages/View/utils/form.js +0 -16
- package/admin/src/pages/View/utils/index.d.ts +0 -2
- package/admin/src/pages/View/utils/index.js +0 -11
- package/admin/src/pages/View/utils/parsers.d.ts +0 -51
- package/admin/src/pages/View/utils/parsers.js +0 -272
- package/admin/src/pages/View/utils/types.d.ts +0 -3
- package/admin/src/pages/View/utils/types.js +0 -3
- package/admin/src/permissions.d.ts +0 -16
- package/admin/src/permissions.js +0 -13
- package/admin/src/pluginId.d.ts +0 -3
- package/admin/src/pluginId.js +0 -5
- package/admin/src/translations/index.d.ts +0 -15
- package/admin/src/translations/index.js +0 -21
- package/admin/src/utils/api.d.ts +0 -9
- package/admin/src/utils/api.js +0 -20
- package/admin/src/utils/enums.d.ts +0 -25
- package/admin/src/utils/enums.js +0 -30
- package/admin/src/utils/functions.d.ts +0 -16
- package/admin/src/utils/functions.js +0 -46
- package/admin/src/utils/index.d.ts +0 -4
- package/admin/src/utils/index.js +0 -20
- package/permissions.d.ts +0 -10
- package/server/bootstrap/index.d.ts +0 -4
- package/server/bootstrap/index.js +0 -50
- package/server/cache/index.d.ts +0 -2
- package/server/cache/serviceEnhancers.d.ts +0 -3
- package/server/cache/serviceEnhancers.js +0 -16
- package/server/cache/setupStrategy.d.ts +0 -3
- package/server/cache/setupStrategy.js +0 -38
- package/server/cache/types.d.ts +0 -11
- package/server/cache/types.js +0 -3
- package/server/cache/utils.d.ts +0 -11
- package/server/cache/utils.js +0 -19
- package/server/config/index.d.ts +0 -5
- package/server/config/setupStrategy.d.ts +0 -3
- package/server/content-types/audience/index.d.ts +0 -27
- package/server/content-types/audience/schema.d.ts +0 -25
- package/server/content-types/index.d.ts +0 -244
- package/server/content-types/navigation/index.d.ts +0 -59
- package/server/content-types/navigation/lifecycles.d.ts +0 -3
- package/server/content-types/navigation/schema.d.ts +0 -56
- package/server/content-types/navigation-item/index.d.ts +0 -111
- package/server/content-types/navigation-item/lifecycles.d.ts +0 -3
- package/server/content-types/navigation-item/schema.d.ts +0 -108
- package/server/content-types/navigations-items-related/index.d.ts +0 -51
- package/server/content-types/navigations-items-related/schema.d.ts +0 -49
- package/server/content-types/navigations-items-related/schema.js +0 -50
- package/server/controllers/admin.d.ts +0 -4
- package/server/controllers/client.d.ts +0 -4
- package/server/controllers/index.d.ts +0 -4
- package/server/destroy.d.ts +0 -3
- package/server/graphql/config.d.ts +0 -4
- package/server/graphql/index.d.ts +0 -2
- package/server/graphql/queries/index.d.ts +0 -3
- package/server/graphql/queries/render-navigation-child.d.ts +0 -15
- package/server/graphql/queries/render-navigation.d.ts +0 -21
- package/server/graphql/resolvers-config.d.ts +0 -10
- package/server/graphql/setupStrategy.d.ts +0 -3
- package/server/graphql/types/content-types-name-fields.d.ts +0 -6
- package/server/graphql/types/content-types.d.ts +0 -5
- package/server/graphql/types/create-navigation-item.d.ts +0 -5
- package/server/graphql/types/create-navigation-related.d.ts +0 -5
- package/server/graphql/types/create-navigation.d.ts +0 -5
- package/server/graphql/types/index.d.ts +0 -3
- package/server/graphql/types/navigation-config.d.ts +0 -5
- package/server/graphql/types/navigation-details.d.ts +0 -5
- package/server/graphql/types/navigation-item-additional-field-media.d.ts +0 -5
- package/server/graphql/types/navigation-item-related-data.d.ts +0 -5
- package/server/graphql/types/navigation-item-related.d.ts +0 -7
- package/server/graphql/types/navigation-item.d.ts +0 -6
- package/server/graphql/types/navigation-render-type.d.ts +0 -5
- package/server/graphql/types/navigation.d.ts +0 -5
- package/server/i18n/constant.d.ts +0 -2
- package/server/i18n/constant.js +0 -5
- package/server/i18n/errors.d.ts +0 -7
- package/server/i18n/errors.js +0 -14
- package/server/i18n/graphQLEnhancers.d.ts +0 -10
- package/server/i18n/graphQLEnhancers.js +0 -10
- package/server/i18n/index.d.ts +0 -8
- package/server/i18n/navigationSetupStrategy.d.ts +0 -3
- package/server/i18n/navigationSetupStrategy.js +0 -147
- package/server/i18n/serviceEnhancers.d.ts +0 -13
- package/server/i18n/serviceEnhancers.js +0 -156
- package/server/i18n/types.d.ts +0 -60
- package/server/i18n/types.js +0 -3
- package/server/i18n/utils.d.ts +0 -13
- package/server/i18n/utils.js +0 -33
- package/server/index.d.ts +0 -262
- package/server/navigation/index.d.ts +0 -2
- package/server/navigation/setupStrategy.d.ts +0 -3
- package/server/navigation/setupStrategy.js +0 -39
- package/server/register/index.d.ts +0 -3
- package/server/register/index.js +0 -4
- package/server/routes/admin.d.ts +0 -4
- package/server/routes/client.d.ts +0 -4
- package/server/routes/index.d.ts +0 -6
- package/server/services/admin.d.ts +0 -5
- package/server/services/admin.js +0 -347
- package/server/services/client.d.ts +0 -5
- package/server/services/client.js +0 -335
- package/server/services/common.d.ts +0 -5
- package/server/services/common.js +0 -385
- package/server/services/index.d.ts +0 -7
- package/server/utils/constant.d.ts +0 -27
- package/server/utils/constant.js +0 -43
- package/server/utils/functions.d.ts +0 -157
- package/server/utils/index.d.ts +0 -3
- package/strapi-admin.d.ts +0 -3
- package/strapi-server.d.ts +0 -262
- package/types/bootstrap.d.ts +0 -16
- package/types/bootstrap.js +0 -3
- package/types/config.d.ts +0 -27
- package/types/config.js +0 -3
- package/types/contentTypes.d.ts +0 -112
- package/types/contentTypes.js +0 -3
- package/types/controllers.d.ts +0 -65
- package/types/controllers.js +0 -5
- package/types/graphQL.d.ts +0 -3
- package/types/graphQL.js +0 -3
- package/types/i18n.d.ts +0 -9
- package/types/index.d.ts +0 -10
- package/types/index.js +0 -26
- package/types/lifecycle.d.ts +0 -22
- package/types/lifecycle.js +0 -3
- package/types/services.d.ts +0 -106
- package/types/services.js +0 -3
- package/types/utils.d.ts +0 -72
- package/types/utils.js +0 -41
- package/utils/InvalidParamNavigationError.d.ts +0 -4
- package/utils/InvalidParamNavigationError.js +0 -8
- package/utils/NavigationError.d.ts +0 -5
- package/utils/NavigationError.js +0 -11
- /package/admin/{src/translations → translations}/ca.json +0 -0
- /package/admin/{src/translations → translations}/fr.json +0 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { first, isEmpty } from 'lodash';
|
|
2
|
+
import { extractRelatedItemLabel } from '../../../../HomePage/utils';
|
|
3
|
+
export const generateUiRouterKey = async ({ slugify, title, config, related, relatedType, contentTypeItems, }) => {
|
|
4
|
+
if (title) {
|
|
5
|
+
return title ? await slugify(title) : undefined;
|
|
6
|
+
}
|
|
7
|
+
else if (related) {
|
|
8
|
+
const relationTitle = extractRelatedItemLabel({
|
|
9
|
+
...(contentTypeItems?.find((_) => _.id === related) ?? {
|
|
10
|
+
id: -1,
|
|
11
|
+
}),
|
|
12
|
+
__collectionUid: relatedType,
|
|
13
|
+
}, config);
|
|
14
|
+
return relationTitle ? await slugify(relationTitle) : undefined;
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
};
|
|
18
|
+
export const getDefaultPath = ({ currentType, config, contentTypeItems, currentRelated, currentRelatedType, isSingleSelected, }) => {
|
|
19
|
+
if (currentType !== 'INTERNAL')
|
|
20
|
+
return '';
|
|
21
|
+
if (!currentRelatedType) {
|
|
22
|
+
return '';
|
|
23
|
+
}
|
|
24
|
+
const pathDefaultFields = config?.pathDefaultFields[currentRelatedType] ?? [];
|
|
25
|
+
if (isEmpty(currentType) && !isEmpty(pathDefaultFields)) {
|
|
26
|
+
const selectedEntity = isSingleSelected
|
|
27
|
+
? first(contentTypeItems ?? [])
|
|
28
|
+
: contentTypeItems?.find(({ id }) => id === currentRelated);
|
|
29
|
+
const pathDefaultValues = pathDefaultFields
|
|
30
|
+
.map((field) => selectedEntity?.[field] ?? '')
|
|
31
|
+
.filter((value) => !!value.toString().trim());
|
|
32
|
+
return pathDefaultValues[0] ?? '';
|
|
33
|
+
}
|
|
34
|
+
return '';
|
|
35
|
+
};
|
|
36
|
+
export const generatePreviewPath = ({ currentPath, isExternal, current, currentType, config, contentTypeItems, currentRelated, currentRelatedType, isSingleSelected, }) => {
|
|
37
|
+
if (!isExternal) {
|
|
38
|
+
const itemPath = isEmpty(currentPath) || currentPath === '/'
|
|
39
|
+
? getDefaultPath({
|
|
40
|
+
currentType,
|
|
41
|
+
config,
|
|
42
|
+
contentTypeItems,
|
|
43
|
+
currentRelated,
|
|
44
|
+
currentRelatedType,
|
|
45
|
+
isSingleSelected,
|
|
46
|
+
})
|
|
47
|
+
: currentPath || '';
|
|
48
|
+
return `${current.levelPath !== '/' ? `${current.levelPath}` : ''}/${itemPath}`;
|
|
49
|
+
}
|
|
50
|
+
return undefined;
|
|
51
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
const Wrapper = styled.div `
|
|
3
|
+
position: relative;
|
|
4
|
+
${({ level, theme }) => level &&
|
|
5
|
+
`
|
|
6
|
+
&::before {
|
|
7
|
+
content: "";
|
|
8
|
+
display: block;
|
|
9
|
+
height: ${theme.spaces[3]};
|
|
10
|
+
width: 19px;
|
|
11
|
+
|
|
12
|
+
position: absolute;
|
|
13
|
+
top: -${theme.spaces[2]};
|
|
14
|
+
left: 30px;
|
|
15
|
+
|
|
16
|
+
border: 0px solid transparent;
|
|
17
|
+
border-left: 4px solid ${theme.colors.neutral300};
|
|
18
|
+
}
|
|
19
|
+
`};
|
|
20
|
+
`;
|
|
21
|
+
export default Wrapper;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Item, } from '../NavigationItemListItem';
|
|
3
|
+
import Wrapper from './Wrapper';
|
|
4
|
+
export const List = ({ isParentAttachedToMenu = false, items, level = 0, levelPath = '', onItemEdit, onItemLevelAdd, onItemRemove, onItemRestore, onItemReOrder, onItemToggleCollapse, displayFlat, permissions, structurePrefix, viewParentId, }) => (_jsx(Wrapper, { "data-level": level, children: items?.map((item, index) => {
|
|
5
|
+
return (_jsx(Item, { item: item, isLast: index === items.length - 1, level: level, levelPath: levelPath, isParentAttachedToMenu: isParentAttachedToMenu, onItemRestore: onItemRestore, onItemLevelAdd: onItemLevelAdd, onItemRemove: onItemRemove, onItemEdit: onItemEdit, onItemReOrder: onItemReOrder, onItemToggleCollapse: onItemToggleCollapse, displayChildren: displayFlat, permissions: permissions, structureId: structurePrefix ? `${structurePrefix}.${index}` : index.toString(), viewParentId: viewParentId }, `list-item-${item.viewId || index}`));
|
|
6
|
+
}) }));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Badge } from '@strapi/design-system';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
export const ItemCardBadge = styled(Badge) `
|
|
4
|
+
border: 1px solid ${({ theme, borderColor }) => theme.colors[borderColor]};
|
|
5
|
+
|
|
6
|
+
${({ small, theme }) => small &&
|
|
7
|
+
`
|
|
8
|
+
padding: ${theme.spaces[1]} ${theme.spaces[2]};
|
|
9
|
+
margin: 0px ${theme.spaces[3]};
|
|
10
|
+
vertical-align: middle;
|
|
11
|
+
|
|
12
|
+
cursor: default;
|
|
13
|
+
|
|
14
|
+
span {
|
|
15
|
+
font-size: .65rem;
|
|
16
|
+
line-height: 1;
|
|
17
|
+
vertical-align: middle;
|
|
18
|
+
}
|
|
19
|
+
`}
|
|
20
|
+
`;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CardTitle } from '@strapi/design-system';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
export const CardItemTitle = styled(CardTitle) `
|
|
4
|
+
width: 100%;
|
|
5
|
+
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: row;
|
|
8
|
+
justify-content: space-between;
|
|
9
|
+
align-items: center;
|
|
10
|
+
|
|
11
|
+
> div > * {
|
|
12
|
+
margin: 0px ${({ theme }) => theme.spaces[1]};
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Eye, Pencil, Trash, Typhoon } from '@strapi/icons';
|
|
3
|
+
export const pencilIcon = _jsx(Pencil, {});
|
|
4
|
+
export const refreshIcon = _jsx(Typhoon, {});
|
|
5
|
+
export const trashIcon = _jsx(Trash, {});
|
|
6
|
+
export const eyeIcon = _jsx(Eye, {});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { IconButton as BaseIconButton, Flex, Typography } from '@strapi/design-system';
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
import { getTrad } from '../../../../../translations';
|
|
6
|
+
import DragButton from '../../DragButton';
|
|
7
|
+
import { ItemCardBadge } from '../ItemCardBadge';
|
|
8
|
+
import { CardItemTitle } from './Wrapper';
|
|
9
|
+
import { eyeIcon, pencilIcon, refreshIcon, trashIcon } from './icons';
|
|
10
|
+
const wrapperStyle = { zIndex: 2 };
|
|
11
|
+
const pathWrapperStyle = { maxWidth: '425px' };
|
|
12
|
+
export const ItemCardHeader = ({ title, path, icon, removed, canUpdate, onItemRemove, onItemEdit, onItemRestore, dragRef, isSearchActive, }) => {
|
|
13
|
+
const { formatMessage } = useIntl();
|
|
14
|
+
return (_jsxs(CardItemTitle, { children: [_jsxs(Flex, { alignItems: "center", children: [canUpdate && _jsx(DragButton, { ref: dragRef, isActive: isSearchActive }), _jsx(Typography, { variant: "omega", fontWeight: "bold", children: title }), _jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "neutral500", ellipsis: true, style: pathWrapperStyle, children: path }), _jsx(Flex, { children: icon })] }), _jsxs(Flex, { alignItems: "center", style: wrapperStyle, children: [removed && (_jsx(ItemCardBadge, { borderColor: "danger200", backgroundColor: "danger100", textColor: "danger600", children: formatMessage(getTrad('components.navigationItem.badge.removed')) })), _jsx(IconButton, { isActive: isSearchActive, disabled: removed, onClick: onItemEdit, label: formatMessage(getTrad(`components.navigationItem.action.${canUpdate ? 'edit' : 'view'}`, canUpdate ? 'Edit' : 'View')), children: canUpdate ? pencilIcon : eyeIcon }), canUpdate && (_jsx(_Fragment, { children: removed ? (_jsx(IconButton, { isActive: isSearchActive, onClick: onItemRestore, label: formatMessage(getTrad('components.navigationItem.action.restore', 'Restore')), children: refreshIcon })) : (_jsx(IconButton, { isActive: isSearchActive, onClick: onItemRemove, label: formatMessage(getTrad('components.navigationItem.action.remove', 'Remove')), children: trashIcon })) }))] })] }));
|
|
15
|
+
};
|
|
16
|
+
const IconButton = styled(BaseIconButton) `
|
|
17
|
+
transition: background-color 0.3s ease-in;
|
|
18
|
+
${({ isActive, theme }) => (isActive ? `background-color: ${theme.colors.neutral150} ;` : '')}
|
|
19
|
+
`;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
const Wrapper = styled.div `
|
|
3
|
+
position: relative;
|
|
4
|
+
margin-top: ${({ theme }) => theme.spaces[2]};
|
|
5
|
+
margin-left: ${({ level }) => level && '54px'};
|
|
6
|
+
|
|
7
|
+
${({ level, theme, isLast }) => level &&
|
|
8
|
+
`
|
|
9
|
+
&::before {
|
|
10
|
+
${!isLast && 'content: "";'}
|
|
11
|
+
display: block;
|
|
12
|
+
top: ${theme.spaces[1]};
|
|
13
|
+
left: -24px;
|
|
14
|
+
position: absolute;
|
|
15
|
+
height: calc(100% + ${theme.spaces[2]});
|
|
16
|
+
width: 19px;
|
|
17
|
+
border: 0px solid transparent;
|
|
18
|
+
border-left: 4px solid ${theme.colors.neutral300};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&::after {
|
|
22
|
+
content: "";
|
|
23
|
+
display: block;
|
|
24
|
+
height: 22px;
|
|
25
|
+
width: 19px;
|
|
26
|
+
position: absolute;
|
|
27
|
+
top: ${theme.spaces[1]};
|
|
28
|
+
left: -${theme.spaces[6]};
|
|
29
|
+
|
|
30
|
+
background: transparent;
|
|
31
|
+
border: 4px solid ${theme.colors.neutral300};
|
|
32
|
+
border-top: transparent;
|
|
33
|
+
border-right: transparent;
|
|
34
|
+
border-radius: 0 0 0 100%;
|
|
35
|
+
}
|
|
36
|
+
`};
|
|
37
|
+
`;
|
|
38
|
+
export default Wrapper;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Card, CardBody, Divider, Flex, Link, TextButton, Typography } from '@strapi/design-system';
|
|
3
|
+
import { ArrowRight, Earth, Link as LinkIcon, Plus } from '@strapi/icons';
|
|
4
|
+
import { isEmpty, isNumber } from 'lodash';
|
|
5
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
6
|
+
import { useDrag, useDrop } from 'react-dnd';
|
|
7
|
+
import { useIntl } from 'react-intl';
|
|
8
|
+
import { useTheme } from 'styled-components';
|
|
9
|
+
import { getTrad } from '../../../../translations';
|
|
10
|
+
import { RELATED_ITEM_SEPARATOR } from '../../../../utils/constants';
|
|
11
|
+
import { useConfig, useContentTypeItems, useContentTypes } from '../../hooks';
|
|
12
|
+
import { extractRelatedItemLabel, mapServerNavigationItem } from '../../utils';
|
|
13
|
+
import { CollapseButton } from '../CollapseButton';
|
|
14
|
+
import { List } from '../NavigationItemList';
|
|
15
|
+
import { ItemCardBadge } from './ItemCardBadge';
|
|
16
|
+
import { ItemCardHeader } from './ItemCardHeader';
|
|
17
|
+
import { ItemCardRemovedOverlay } from './ItemCardRemovedOverlay';
|
|
18
|
+
import Wrapper from './Wrapper';
|
|
19
|
+
export const Item = ({ item, isLast = false, level = 0, levelPath = '', isParentAttachedToMenu, onItemLevelAdd, onItemRemove, onItemRestore, onItemEdit, onItemReOrder, onItemToggleCollapse, displayChildren, permissions, structureId, viewParentId, }) => {
|
|
20
|
+
const { viewId, type, path, removed, externalPath, menuAttached, collapsed, items = [], isSearchActive, related, relatedType, } = mapServerNavigationItem(item, true);
|
|
21
|
+
const { formatMessage } = useIntl();
|
|
22
|
+
const configQuery = useConfig();
|
|
23
|
+
const isExternal = type === 'EXTERNAL';
|
|
24
|
+
// TODO: is handled by publish flow
|
|
25
|
+
const isHandledByPublishFlow = true;
|
|
26
|
+
const isNextMenuAllowedLevel = isNumber(configQuery.data?.allowedLevels)
|
|
27
|
+
? level < configQuery.data.allowedLevels - 1
|
|
28
|
+
: true;
|
|
29
|
+
const isMenuAllowedLevel = isNumber(configQuery.data?.allowedLevels)
|
|
30
|
+
? level < configQuery.data.allowedLevels
|
|
31
|
+
: true;
|
|
32
|
+
const hasChildren = !isEmpty(item.items) && !isExternal && !displayChildren;
|
|
33
|
+
const absolutePath = isExternal
|
|
34
|
+
? undefined
|
|
35
|
+
: `${levelPath === '/' ? '' : levelPath}/${path === '/' ? '' : path}`;
|
|
36
|
+
const contentTypeItemsQuery = useContentTypeItems({
|
|
37
|
+
uid: relatedType ?? '',
|
|
38
|
+
});
|
|
39
|
+
const contentTypesQuery = useContentTypes();
|
|
40
|
+
const contentType = contentTypesQuery.data?.find((_) => _.uid === relatedType);
|
|
41
|
+
const relatedItem = contentTypeItemsQuery.data?.find((contentTypeItem) => contentTypeItem.id === related) ?? { id: -1 };
|
|
42
|
+
const isPublished = !!relatedItem.publishedAt;
|
|
43
|
+
const relatedItemLabel = !isExternal
|
|
44
|
+
? extractRelatedItemLabel(relatedItem, configQuery.data)
|
|
45
|
+
: '';
|
|
46
|
+
const relatedTypeLabel = contentType?.info.displayName ?? '';
|
|
47
|
+
const relatedBadgeColor = isPublished ? 'success' : 'secondary';
|
|
48
|
+
const canUpdate = permissions.canUpdate;
|
|
49
|
+
const dragRef = useRef(null);
|
|
50
|
+
const dropRef = useRef(null);
|
|
51
|
+
const previewRef = useRef(null);
|
|
52
|
+
const [, drop] = useDrop({
|
|
53
|
+
accept: `navigation-item_${levelPath}`,
|
|
54
|
+
hover(hoveringItem, monitor) {
|
|
55
|
+
const dragIndex = hoveringItem.order ?? 0;
|
|
56
|
+
const dropIndex = item.order ?? 0;
|
|
57
|
+
// Don't replace items with themselves
|
|
58
|
+
if (dragIndex === dropIndex) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const hoverBoundingRect = dropRef.current.getBoundingClientRect();
|
|
62
|
+
const hoverMiddleY = (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;
|
|
63
|
+
const clientOffset = monitor.getClientOffset();
|
|
64
|
+
if (!clientOffset) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const hoverClientY = clientOffset.y - hoverBoundingRect.top;
|
|
68
|
+
// Place the hovering item before or after the drop target
|
|
69
|
+
const isAfter = hoverClientY > hoverMiddleY;
|
|
70
|
+
const newOrder = isAfter ? (item.order ?? 0) + 0.5 : (item.order ?? 0) - 0.5;
|
|
71
|
+
if (dragIndex < dropIndex && hoverClientY < hoverMiddleY) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
// Dragging upwards
|
|
75
|
+
if (dragIndex > dropIndex && hoverClientY > hoverMiddleY) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
onItemReOrder({
|
|
79
|
+
item: mapServerNavigationItem(hoveringItem, true),
|
|
80
|
+
newOrder,
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
collect: (monitor) => ({
|
|
84
|
+
isOverCurrent: monitor.isOver({ shallow: true }),
|
|
85
|
+
}),
|
|
86
|
+
});
|
|
87
|
+
const [{ isDragging }, drag, dragPreview] = useDrag({
|
|
88
|
+
type: `navigation-item_${levelPath}`,
|
|
89
|
+
item: () => item,
|
|
90
|
+
collect: (monitor) => ({
|
|
91
|
+
isDragging: monitor.isDragging(),
|
|
92
|
+
}),
|
|
93
|
+
});
|
|
94
|
+
const refs = {
|
|
95
|
+
dragRef: drag(dragRef),
|
|
96
|
+
dropRef: drop(dropRef),
|
|
97
|
+
previewRef: dragPreview(previewRef),
|
|
98
|
+
};
|
|
99
|
+
const generatePreviewUrl = (entity) => {
|
|
100
|
+
const isSingle = contentType?.kind === 'singleType';
|
|
101
|
+
const entityLocale = entity?.locale ? `?plugins[i18n][locale]=${entity?.locale}` : '';
|
|
102
|
+
return `/content-manager/${isSingle ? 'single-types' : 'collection-types'}/${contentType?.uid}${!isSingle ? '/' + entity?.id : ''}${entityLocale}`;
|
|
103
|
+
};
|
|
104
|
+
const onNewItemClick = useCallback((event) => canUpdate &&
|
|
105
|
+
onItemLevelAdd(event, viewId, isNextMenuAllowedLevel, absolutePath, menuAttached, `${structureId}.${items.length}`, Math.max(...items.map(({ order }) => order))), [viewId, isNextMenuAllowedLevel, absolutePath, menuAttached, structureId, items, canUpdate]);
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
if (isSearchActive) {
|
|
108
|
+
refs.dropRef?.current?.scrollIntoView?.({
|
|
109
|
+
behavior: 'smooth',
|
|
110
|
+
block: 'center',
|
|
111
|
+
inline: 'center',
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}, [isSearchActive, refs.dropRef.current]);
|
|
115
|
+
const theme = useTheme();
|
|
116
|
+
return (_jsxs(Wrapper, { level: level, isLast: isLast, style: { opacity: isDragging ? 0.2 : 1 }, ref: refs ? refs.dropRef : undefined, children: [_jsxs(Card, { style: {
|
|
117
|
+
width: '728px',
|
|
118
|
+
zIndex: 1,
|
|
119
|
+
position: 'relative',
|
|
120
|
+
overflow: 'hidden',
|
|
121
|
+
backgroundColor: isSearchActive ? theme.colors.neutral150 : undefined,
|
|
122
|
+
borderColor: isSearchActive ? theme.colors.neutral300 : undefined,
|
|
123
|
+
transition: 'background-color 0.3s ease-in',
|
|
124
|
+
}, children: [removed && _jsx(ItemCardRemovedOverlay, {}), _jsxs("div", { ref: refs.previewRef, children: [_jsx(CardBody, { children: _jsx(ItemCardHeader, { title: item.title ?? '', path: isExternal ? externalPath : absolutePath, icon: isExternal ? _jsx(Earth, {}) : _jsx(LinkIcon, {}), onItemRemove: () => onItemRemove({ ...item, viewParentId }), onItemEdit: () => {
|
|
125
|
+
const [relatedType, related] = item.related?.split(RELATED_ITEM_SEPARATOR) ?? [];
|
|
126
|
+
if (item.type !== 'EXTERNAL' && item.type !== 'INTERNAL') {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
onItemEdit({
|
|
130
|
+
item: item.type === 'INTERNAL'
|
|
131
|
+
? {
|
|
132
|
+
...item,
|
|
133
|
+
type: 'INTERNAL',
|
|
134
|
+
isMenuAllowedLevel,
|
|
135
|
+
isParentAttachedToMenu,
|
|
136
|
+
isSearchActive: false,
|
|
137
|
+
relatedType,
|
|
138
|
+
related: related ? parseInt(related, 10) : undefined,
|
|
139
|
+
additionalFields: item.additionalFields ?? {},
|
|
140
|
+
items: item.items ?? [],
|
|
141
|
+
autoSync: item.autoSync ?? true,
|
|
142
|
+
externalPath: undefined,
|
|
143
|
+
viewParentId,
|
|
144
|
+
audience: item.audience?.map(({ id }) => id) ?? [],
|
|
145
|
+
}
|
|
146
|
+
: {
|
|
147
|
+
...item,
|
|
148
|
+
type: 'EXTERNAL',
|
|
149
|
+
isMenuAllowedLevel,
|
|
150
|
+
isParentAttachedToMenu,
|
|
151
|
+
isSearchActive: false,
|
|
152
|
+
relatedType: undefined,
|
|
153
|
+
related: undefined,
|
|
154
|
+
additionalFields: item.additionalFields ?? {},
|
|
155
|
+
items: item.items ?? [],
|
|
156
|
+
autoSync: item.autoSync ?? true,
|
|
157
|
+
externalPath: item.externalPath ?? '',
|
|
158
|
+
viewParentId,
|
|
159
|
+
audience: item.audience?.map(({ id }) => id) ?? [],
|
|
160
|
+
},
|
|
161
|
+
levelPath,
|
|
162
|
+
isParentAttachedToMenu,
|
|
163
|
+
});
|
|
164
|
+
}, onItemRestore: () => onItemRestore({ ...item, viewParentId }), dragRef: refs.dragRef, removed: removed, canUpdate: canUpdate, isSearchActive: isSearchActive }) }), _jsx(Divider, {}), !isExternal && (_jsx(CardBody, { style: { padding: '8px' }, children: _jsxs(Flex, { style: { width: '100%' }, direction: "row", alignItems: "center", justifyContent: "space-between", children: [_jsxs(Flex, { children: [!isEmpty(item.items) && (_jsx(CollapseButton, { toggle: () => onItemToggleCollapse({ ...item, viewParentId }), collapsed: collapsed, itemsCount: item.items?.length ?? 0 })), canUpdate && isNextMenuAllowedLevel && (_jsx(TextButton, { disabled: removed, startIcon: _jsx(Plus, {}), onClick: onNewItemClick, children: _jsx(Typography, { variant: "pi", fontWeight: "bold", textColor: removed ? 'neutral600' : 'primary600', children: formatMessage(getTrad('components.navigationItem.action.newItem')) }) }))] }), relatedItemLabel && (_jsxs(Flex, { justifyContent: "center", alignItems: "center", children: [isHandledByPublishFlow && (_jsx(ItemCardBadge, { borderColor: `${relatedBadgeColor}200`, backgroundColor: `${relatedBadgeColor}100`, textColor: `${relatedBadgeColor}600`, className: "action", small: true, children: formatMessage(getTrad(`components.navigationItem.badge.${isPublished ? 'published' : 'draft'}`)) })), _jsxs(Typography, { variant: "omega", textColor: "neutral600", children: [relatedTypeLabel, "\u00A0/\u00A0"] }), _jsx(Typography, { variant: "omega", textColor: "neutral800", children: relatedItemLabel }), _jsx(Link, { to: generatePreviewUrl(relatedItem ?? undefined), endIcon: _jsx(ArrowRight, {}), children: "\u00A0" })] }))] }) }))] })] }), hasChildren && !removed && !collapsed && (_jsx(List, { onItemLevelAdd: onItemLevelAdd, onItemRemove: onItemRemove, onItemEdit: onItemEdit, onItemRestore: onItemRestore, onItemReOrder: onItemReOrder, onItemToggleCollapse: onItemToggleCollapse, isParentAttachedToMenu: menuAttached, items: item.items ?? [], level: level + 1, levelPath: absolutePath, permissions: permissions, structurePrefix: structureId, viewParentId: viewId }))] }));
|
|
165
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Modal } from '@strapi/design-system';
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
4
|
+
import { getTrad } from '../../../../translations';
|
|
5
|
+
export const NavigationItemPopupFooter = ({ handleCancel, handleSubmit, submitDisabled, canUpdate, }) => {
|
|
6
|
+
const { formatMessage } = useIntl();
|
|
7
|
+
if (!canUpdate) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
return (_jsxs(Modal.Footer, { children: [_jsx(Modal.Close, { children: _jsx(Button, { onClick: handleCancel, variant: "tertiary", children: formatMessage(getTrad('popup.item.form.button.cancel')) }) }), _jsx(Button, { onClick: handleSubmit, disabled: submitDisabled, children: formatMessage(getTrad('popup.item.form.button.save')) })] }));
|
|
11
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Modal, Typography } from '@strapi/design-system';
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
4
|
+
import { getTrad } from '../../../../translations';
|
|
5
|
+
export const NavigationItemPopupHeader = ({ isNewItem, canUpdate, }) => {
|
|
6
|
+
const { formatMessage } = useIntl();
|
|
7
|
+
let modalType = 'view';
|
|
8
|
+
if (canUpdate) {
|
|
9
|
+
modalType = isNewItem ? 'new' : 'edit';
|
|
10
|
+
}
|
|
11
|
+
return (_jsx(Modal.Header, { children: _jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "neutral800", as: "h2", id: "asset-dialog-title", children: formatMessage(getTrad(`popup.item.header.${modalType}`)) }) }));
|
|
12
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Modal } from '@strapi/design-system';
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
4
|
+
import { getTrad } from '../../../../translations';
|
|
5
|
+
import { isRelationPublished } from '../../utils';
|
|
6
|
+
import { NavigationItemForm } from '../NavigationItemForm';
|
|
7
|
+
import { NavigationItemPopupHeader } from './NavigationItemPopupHeader';
|
|
8
|
+
const NavigationItemPopUp = ({ availableLocale, isOpen, isLoading, currentItem = {}, onSubmit, onClose, locale, permissions, currentNavigation, }) => {
|
|
9
|
+
const { formatMessage } = useIntl();
|
|
10
|
+
const handleOnSubmit = (payload) => {
|
|
11
|
+
onSubmit(payload);
|
|
12
|
+
};
|
|
13
|
+
const appendLabelPublicationStatus = (label, item, isCollection) => {
|
|
14
|
+
const appendix = isRelationPublished({
|
|
15
|
+
relatedRef: item,
|
|
16
|
+
type: item.isSingle ? 'INTERNAL' : item.type,
|
|
17
|
+
isCollection,
|
|
18
|
+
})
|
|
19
|
+
? ''
|
|
20
|
+
: `[${formatMessage(getTrad('notification.navigation.item.relation.status.draft'))}] `.toUpperCase();
|
|
21
|
+
return `${appendix}${label}`;
|
|
22
|
+
};
|
|
23
|
+
const hasViewId = !!currentItem.viewId;
|
|
24
|
+
return (_jsx(Modal.Root, { labelledBy: "condition-modal-breadcrumbs", onOpenChange: (isOpen) => {
|
|
25
|
+
if (!isOpen) {
|
|
26
|
+
onClose({
|
|
27
|
+
preventDefault() { },
|
|
28
|
+
stopPropagation() { },
|
|
29
|
+
target: {},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}, open: isOpen, children: _jsxs(Modal.Content, { children: [_jsx(NavigationItemPopupHeader, { isNewItem: !hasViewId, canUpdate: permissions?.canUpdate }), _jsx(NavigationItemForm, { availableLocale: availableLocale, current: currentItem, isLoading: isLoading, onSubmit: handleOnSubmit, onCancel: onClose, appendLabelPublicationStatus: appendLabelPublicationStatus, locale: locale, permissions: permissions, currentNavigation: currentNavigation })] }) }));
|
|
33
|
+
};
|
|
34
|
+
export default NavigationItemPopUp;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Button, Checkbox, Flex, Grid, IconButton, Table, Tbody, Td, Th, Thead, Tr, Typography, } from '@strapi/design-system';
|
|
3
|
+
import { prop } from 'lodash/fp';
|
|
4
|
+
import { useCallback, useMemo } from 'react';
|
|
5
|
+
import { useIntl } from 'react-intl';
|
|
6
|
+
import { getTrad } from '../../../../../translations';
|
|
7
|
+
import { useConfig, useLocale } from '../../../hooks';
|
|
8
|
+
import { FooterBase } from '../Footer';
|
|
9
|
+
import { INITIAL_NAVIGATION } from '../NewNavigation';
|
|
10
|
+
import * as icons from './icons';
|
|
11
|
+
export const AllNavigations = ({ navigations, selected, setState }) => {
|
|
12
|
+
const configQuery = useConfig();
|
|
13
|
+
const hasAnySelected = !!selected.length;
|
|
14
|
+
const { formatMessage } = useIntl();
|
|
15
|
+
const localeQuery = useLocale();
|
|
16
|
+
const toggleSelected = useCallback(() => setState({
|
|
17
|
+
navigations,
|
|
18
|
+
selected: hasAnySelected ? [] : navigations.map((n) => n),
|
|
19
|
+
view: 'LIST',
|
|
20
|
+
}), [setState, navigations, hasAnySelected]);
|
|
21
|
+
const currentlySelectedSet = useMemo(() => new Set(selected.map(prop('id'))), [selected]);
|
|
22
|
+
const handleSelect = (navigation, isSelected) => () => {
|
|
23
|
+
setState({
|
|
24
|
+
navigations,
|
|
25
|
+
selected: isSelected
|
|
26
|
+
? selected.filter(({ id }) => id !== navigation.id)
|
|
27
|
+
: selected.concat([navigation]),
|
|
28
|
+
view: 'LIST',
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
const edit = (navigation) => () => {
|
|
32
|
+
setState({
|
|
33
|
+
view: 'EDIT',
|
|
34
|
+
current: navigation,
|
|
35
|
+
navigation,
|
|
36
|
+
alreadyUsedNames: navigations.reduce((acc, { name }) => (name !== navigation.name ? acc.concat([name]) : acc), []),
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
const _delete = (navigations) => () => {
|
|
40
|
+
setState({
|
|
41
|
+
view: 'DELETE',
|
|
42
|
+
navigations,
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
const purgeCache = (navigations) => () => {
|
|
46
|
+
setState({
|
|
47
|
+
view: 'CACHE_PURGE',
|
|
48
|
+
navigations,
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
const deleteSelected = useCallback(_delete(selected), [_delete]);
|
|
52
|
+
const purgeSelected = useCallback(purgeCache(selected), [purgeCache]);
|
|
53
|
+
const getLocalizations = (focused) => [focused].concat(navigations.filter((navigation) => navigation.documentId === focused.documentId && navigation.id !== focused.id));
|
|
54
|
+
return (_jsxs(_Fragment, { children: [_jsx(Grid.Root, { children: _jsx(Grid.Item, { col: 12, paddingBottom: 3, children: hasAnySelected ? (_jsxs(Flex, { direction: "row", gap: 1, children: [_jsx(Box, { paddingRight: 3, children: formatMessage(getTrad('popup.navigation.manage.table.hasSelected'), {
|
|
55
|
+
count: selected.length,
|
|
56
|
+
}) }), _jsx(Button, { onClick: deleteSelected, variant: "tertiary", children: formatMessage(getTrad('popup.navigation.manage.button.delete')) }), configQuery.data?.isCacheEnabled ? (_jsx(Button, { onClick: purgeSelected, variant: "tertiary", children: formatMessage(getTrad('popup.navigation.manage.button.purge')) })) : null] })) : null }) }), _jsxs(Table, { rowCount: navigations.length, colCount: 6, children: [_jsx(Thead, { children: _jsxs(Tr, { children: [_jsx(Th, { children: _jsx(Checkbox, { onCheckedChange: toggleSelected, check: hasAnySelected }) }), _jsx(Th, { children: _jsx(Typography, { textColor: "neutral800", children: formatMessage(getTrad('popup.navigation.manage.table.id')) }) }), _jsx(Th, { children: _jsx(Typography, { textColor: "neutral800", children: formatMessage(getTrad('popup.navigation.manage.table.name')) }) }), _jsx(Th, { children: _jsx(Typography, { textColor: "neutral800", children: formatMessage(getTrad('popup.navigation.manage.table.locale')) }) }), _jsx(Th, { children: _jsx(Typography, { textColor: "neutral800", children: formatMessage(getTrad('popup.navigation.manage.table.visibility')) }) }), _jsx(Th, { children: configQuery.data?.isCacheEnabled ? (_jsx(Flex, { direction: "row", children: _jsx(Box, { paddingLeft: 1, children: _jsx(IconButton, { onClick: purgeCache([]), label: formatMessage(getTrad('popup.navigation.manage.button.purge')), noBorder: true, children: icons.featherIcon }) }) })) : null })] }) }), _jsx(Tbody, { children: navigations
|
|
57
|
+
.filter(({ localeCode }) => localeCode === localeQuery.data?.defaultLocale)
|
|
58
|
+
.map((navigation) => (_jsxs(Tr, { children: [_jsx(Td, { children: _jsx(Checkbox, { onCheckedChange: handleSelect(navigation, currentlySelectedSet.has(navigation.id)), checked: currentlySelectedSet.has(navigation.id) }) }), _jsx(Td, { children: _jsx(Typography, { textColor: "neutral800", children: navigation.id }) }), _jsx(Td, { children: _jsx(Typography, { textColor: "neutral800", children: navigation.name }) }), _jsx(Td, { children: _jsx(Typography, { textColor: "neutral800", children: getLocalizations(navigation).map(prop('localeCode')).join(', ') }) }), _jsx(Td, { children: _jsx(Typography, { textColor: "neutral800", children: navigation.visible
|
|
59
|
+
? formatMessage(getTrad('popup.navigation.manage.navigation.visible'))
|
|
60
|
+
: formatMessage(getTrad('popup.navigation.manage.navigation.hidden')) }) }), _jsx(Td, { children: _jsxs(Flex, { width: "100%", direction: "row", alignItems: "center", justifyContent: "flex-end", children: [_jsx(Box, { paddingLeft: 1, children: _jsx(IconButton, { onClick: edit(navigation), label: formatMessage(getTrad('popup.navigation.manage.button.edit')), noBorder: true, children: icons.edit }) }), _jsx(Box, { paddingLeft: 1, children: _jsx(IconButton, { onClick: _delete([navigation]), label: formatMessage(getTrad('popup.navigation.manage.button.delete')), noBorder: true, children: icons.deleteIcon }) }), configQuery.data?.isCacheEnabled ? (_jsx(Box, { paddingLeft: 1, children: _jsx(IconButton, { onClick: purgeCache([navigation]), label: formatMessage(getTrad('popup.navigation.manage.button.purge')), noBorder: true, children: icons.featherIcon }) })) : null] }) })] }, navigation.id))) })] })] }));
|
|
61
|
+
};
|
|
62
|
+
export const AllNavigationsFooter = ({ onClose, state, setState, navigations, isLoading, }) => {
|
|
63
|
+
const { formatMessage } = useIntl();
|
|
64
|
+
return (_jsx(FooterBase, { start: {
|
|
65
|
+
onClick: onClose,
|
|
66
|
+
variant: 'tertiary',
|
|
67
|
+
disabled: isLoading,
|
|
68
|
+
children: formatMessage(getTrad('popup.item.form.button.cancel')),
|
|
69
|
+
}, end: {
|
|
70
|
+
onClick: () => setState({
|
|
71
|
+
view: 'CREATE',
|
|
72
|
+
alreadyUsedNames: navigations.map(({ name }) => name),
|
|
73
|
+
current: INITIAL_NAVIGATION,
|
|
74
|
+
}),
|
|
75
|
+
variant: 'default',
|
|
76
|
+
disabled: isLoading,
|
|
77
|
+
children: formatMessage(getTrad('popup.navigation.manage.button.create')),
|
|
78
|
+
} }));
|
|
79
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Flex, Grid, Typography } from '@strapi/design-system';
|
|
3
|
+
import { prop } from 'lodash/fp';
|
|
4
|
+
import { useIntl } from 'react-intl';
|
|
5
|
+
import { getTrad } from '../../../../../translations';
|
|
6
|
+
import { FooterBase } from '../Footer';
|
|
7
|
+
export const DeletionConfirm = ({ navigations }) => {
|
|
8
|
+
const { formatMessage } = useIntl();
|
|
9
|
+
return (_jsxs(Grid.Root, { children: [_jsx(Grid.Item, { col: 12, paddingBottom: 1, children: _jsx(Flex, { children: _jsx(Typography, { variant: "beta", children: formatMessage(getTrad('popup.navigation.manage.delete.header')) }) }) }), _jsx(Grid.Item, { col: 12, paddingBottom: 1, children: _jsx(Typography, { variant: "omega", fontWeight: "semiBold", children: renderItems(navigations) }) })] }));
|
|
10
|
+
};
|
|
11
|
+
export const DeleteConfirmFooter = ({ state, onSubmit, onReset, isLoading }) => {
|
|
12
|
+
const { formatMessage } = useIntl();
|
|
13
|
+
return (_jsx(FooterBase, { start: {
|
|
14
|
+
children: formatMessage(getTrad('popup.item.form.button.cancel')),
|
|
15
|
+
disabled: isLoading,
|
|
16
|
+
onClick: onReset,
|
|
17
|
+
variant: 'tertiary',
|
|
18
|
+
}, end: {
|
|
19
|
+
children: formatMessage(getTrad('popup.navigation.manage.button.delete')),
|
|
20
|
+
disabled: isLoading,
|
|
21
|
+
onClick: onSubmit,
|
|
22
|
+
variant: 'danger',
|
|
23
|
+
} }));
|
|
24
|
+
};
|
|
25
|
+
const renderItems = (navigations) => navigations.map(prop('name')).join(', ');
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Grid } from '@strapi/design-system';
|
|
3
|
+
import { useNotification } from '@strapi/strapi/admin';
|
|
4
|
+
import { useEffect } from 'react';
|
|
5
|
+
import { useIntl } from 'react-intl';
|
|
6
|
+
import { getTrad } from '../../../../../translations';
|
|
7
|
+
import { FooterBase } from '../Footer';
|
|
8
|
+
export const ErrorDetails = ({ errors }) => {
|
|
9
|
+
const { formatMessage } = useIntl();
|
|
10
|
+
const { toggleNotification } = useNotification();
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
errors.map((error) => {
|
|
13
|
+
toggleNotification({
|
|
14
|
+
type: 'warning',
|
|
15
|
+
message: formatMessage({ id: '', defaultMessage: error.message }),
|
|
16
|
+
});
|
|
17
|
+
console.error(error);
|
|
18
|
+
});
|
|
19
|
+
}, []);
|
|
20
|
+
return (_jsx(Grid.Root, { children: _jsx(Grid.Item, { col: 12, children: formatMessage(getTrad('popup.navigation.manage.error.message')) }) }));
|
|
21
|
+
};
|
|
22
|
+
export const ErrorDetailsFooter = ({ onReset }) => {
|
|
23
|
+
const { formatMessage } = useIntl();
|
|
24
|
+
return (_jsx(FooterBase, { end: {
|
|
25
|
+
children: formatMessage(getTrad('popup.navigation.manage.button.goBack')),
|
|
26
|
+
onClick: onReset,
|
|
27
|
+
variant: 'secondary',
|
|
28
|
+
} }));
|
|
29
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Modal } from '@strapi/design-system';
|
|
3
|
+
export const FooterBase = ({ start, end }) => {
|
|
4
|
+
return (_jsxs(Modal.Footer, { children: [_jsx(Modal.Close, { children: renderActions(start) }), renderActions(end)] }));
|
|
5
|
+
};
|
|
6
|
+
const renderActions = (actions) => actions ? (_jsx(Button, { onClick: actions.onClick, variant: actions.variant, disabled: actions.disabled, children: actions.children })) : null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
2
|
+
import { useForm } from 'react-hook-form';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
const formSchema = ({ alreadyUsedNames }) => z.object({
|
|
5
|
+
name: z
|
|
6
|
+
.string()
|
|
7
|
+
.min(2)
|
|
8
|
+
.and(z.string().refine((name) => !alreadyUsedNames.includes(name), 'name already used')),
|
|
9
|
+
visible: z.boolean(),
|
|
10
|
+
});
|
|
11
|
+
export const useNavigationForm = ({ alreadyUsedNames, navigation: { name, visible }, }) => {
|
|
12
|
+
return useForm({
|
|
13
|
+
resolver: zodResolver(formSchema({ alreadyUsedNames })),
|
|
14
|
+
defaultValues: {
|
|
15
|
+
name: name ?? '',
|
|
16
|
+
visible: visible ?? false,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Field } from '@strapi/design-system';
|
|
3
|
+
import { debounce } from 'lodash';
|
|
4
|
+
import { useEffect } from 'react';
|
|
5
|
+
import { Controller } from 'react-hook-form';
|
|
6
|
+
import { useIntl } from 'react-intl';
|
|
7
|
+
import { Checkbox, Grid } from '@strapi/design-system';
|
|
8
|
+
import { getTrad } from '../../../../../translations';
|
|
9
|
+
import { useNavigationForm } from './hooks';
|
|
10
|
+
import { TextInput } from '@strapi/design-system';
|
|
11
|
+
export const Form = ({ navigation, onChange, alreadyUsedNames = [], isLoading, }) => {
|
|
12
|
+
const { control, watch } = useNavigationForm({ alreadyUsedNames, navigation });
|
|
13
|
+
const [name, visible] = watch(['name', 'visible']);
|
|
14
|
+
const onChangeLimited = debounce(onChange, 300);
|
|
15
|
+
const { formatMessage } = useIntl();
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (`${name}-${visible}` !== `${navigation.name}-${navigation.visible}`) {
|
|
18
|
+
onChangeLimited({
|
|
19
|
+
...navigation,
|
|
20
|
+
name,
|
|
21
|
+
visible,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}, [name, visible, navigation]);
|
|
25
|
+
return (_jsxs(Grid.Root, { gap: 5, children: [_jsx(Grid.Item, { col: 6, children: _jsx(Controller, { control: control, name: "name", render: ({ field: { value, onChange }, fieldState }) => (_jsxs(Field.Root, { width: "100%", error: fieldState.error?.message, children: [_jsx(Field.Label, { children: formatMessage(getTrad('popup.navigation.form.name.label', 'Name')) }), _jsx(TextInput, { name: "name", type: "string", placeholder: formatMessage(getTrad('popup.navigation.form.name.placeholder', "Navigations's name")), onChange: onChange, value: value, disabled: isLoading }), _jsx(Field.Error, {})] })) }) }), _jsx(Grid.Item, { col: 6, children: _jsx(Controller, { control: control, name: "visible", render: ({ field: { onChange, value }, fieldState }) => (_jsxs(Field.Root, { error: fieldState.error?.message, children: [_jsx(Field.Label, { children: formatMessage(getTrad('popup.navigation.form.visible.label', 'Visibility')) }), _jsx(Checkbox, { name: "visible", checked: value, onCheckedChange: onChange, disabled: isLoading }), _jsx(Field.Hint, { children: formatMessage(getTrad('popup.item.form.visible.label')) }), _jsx(Field.Error, {})] })) }) })] }));
|
|
26
|
+
};
|