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,32 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useMemo } from 'react';
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
4
|
+
import { getTrad } from '../../../../../translations';
|
|
5
|
+
import { FooterBase } from '../Footer';
|
|
6
|
+
import { Form } from '../Form';
|
|
7
|
+
export const NavigationUpdate = ({ alreadyUsedNames, current, isLoading, navigation: initialValue, setState, }) => {
|
|
8
|
+
const navigation = useMemo(() => current ?? initialValue, [current]);
|
|
9
|
+
const onChange = useCallback((updated) => {
|
|
10
|
+
setState({
|
|
11
|
+
view: 'EDIT',
|
|
12
|
+
alreadyUsedNames,
|
|
13
|
+
current: updated,
|
|
14
|
+
navigation: initialValue,
|
|
15
|
+
});
|
|
16
|
+
}, [setState, initialValue, alreadyUsedNames]);
|
|
17
|
+
return (_jsx(Form, { navigation: navigation, onChange: onChange, isLoading: isLoading, alreadyUsedNames: alreadyUsedNames }));
|
|
18
|
+
};
|
|
19
|
+
export const NavigationUpdateFooter = ({ onSubmit, onReset, isLoading }) => {
|
|
20
|
+
const { formatMessage } = useIntl();
|
|
21
|
+
return (_jsx(FooterBase, { start: {
|
|
22
|
+
children: formatMessage(getTrad('popup.item.form.button.cancel')),
|
|
23
|
+
disabled: isLoading,
|
|
24
|
+
onClick: onReset,
|
|
25
|
+
variant: 'tertiary',
|
|
26
|
+
}, end: {
|
|
27
|
+
children: formatMessage(getTrad('popup.navigation.manage.button.save')),
|
|
28
|
+
disabled: isLoading,
|
|
29
|
+
onClick: onSubmit,
|
|
30
|
+
variant: 'secondary',
|
|
31
|
+
} }));
|
|
32
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
4
|
+
import { getTrad } from '../../../../../translations';
|
|
5
|
+
import { FooterBase } from '../Footer';
|
|
6
|
+
import { Form } from '../Form';
|
|
7
|
+
export const INITIAL_NAVIGATION = {
|
|
8
|
+
name: 'Navigation',
|
|
9
|
+
items: [],
|
|
10
|
+
visible: true,
|
|
11
|
+
};
|
|
12
|
+
export const NewNavigation = ({ setState, current, isLoading, alreadyUsedNames }) => {
|
|
13
|
+
const onSubmit = useCallback((updated) => {
|
|
14
|
+
setState({
|
|
15
|
+
view: 'CREATE',
|
|
16
|
+
current: updated,
|
|
17
|
+
alreadyUsedNames,
|
|
18
|
+
});
|
|
19
|
+
}, [setState]);
|
|
20
|
+
return (_jsx(Form, { alreadyUsedNames: alreadyUsedNames, navigation: current, onChange: onSubmit, isLoading: isLoading }));
|
|
21
|
+
};
|
|
22
|
+
export const NewNavigationFooter = ({ onSubmit, onReset, isLoading }) => {
|
|
23
|
+
const { formatMessage } = useIntl();
|
|
24
|
+
return (_jsx(FooterBase, { start: {
|
|
25
|
+
children: formatMessage(getTrad('popup.item.form.button.cancel')),
|
|
26
|
+
variant: 'tertiary',
|
|
27
|
+
disabled: isLoading,
|
|
28
|
+
onClick: onReset,
|
|
29
|
+
}, end: {
|
|
30
|
+
children: formatMessage(getTrad('popup.navigation.manage.button.save')),
|
|
31
|
+
variant: 'default',
|
|
32
|
+
disabled: isLoading,
|
|
33
|
+
onClick: onSubmit,
|
|
34
|
+
} }));
|
|
35
|
+
};
|
|
@@ -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 PurgeCacheConfirm = ({ 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.purge.header')) }) }) }), _jsx(Grid.Item, { col: 12, paddingBottom: 1, children: _jsx(Typography, { variant: "omega", fontWeight: "semiBold", children: renderItems(navigations) }) })] }));
|
|
10
|
+
};
|
|
11
|
+
export const PurgeCacheConfirmFooter = ({ 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.footer.button.purge')),
|
|
20
|
+
disabled: isLoading,
|
|
21
|
+
onClick: onSubmit,
|
|
22
|
+
variant: 'danger',
|
|
23
|
+
} }));
|
|
24
|
+
};
|
|
25
|
+
const renderItems = (navigations) => navigations.map(prop('name')).join(', ');
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Flex, Loader, Modal } from '@strapi/design-system';
|
|
3
|
+
import { useNotification } from '@strapi/strapi/admin';
|
|
4
|
+
import { sortBy } from 'lodash';
|
|
5
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
6
|
+
import { useIntl } from 'react-intl';
|
|
7
|
+
import { getTrad } from '../../../../translations';
|
|
8
|
+
import { useCreateNavigation, useDeleteNavigations, useHardReset, useLocale, useNavigations, usePurgeNavigation, useUpdateNavigation, } from '../../hooks';
|
|
9
|
+
import { getPendingAction } from '../../utils';
|
|
10
|
+
import { AllNavigations, AllNavigationsFooter } from './AllNavigations';
|
|
11
|
+
import { DeleteConfirmFooter, DeletionConfirm } from './DeletionConfirm';
|
|
12
|
+
import { ErrorDetails, ErrorDetailsFooter } from './ErrorDetails';
|
|
13
|
+
import { NavigationUpdate, NavigationUpdateFooter } from './NavigationUpdate';
|
|
14
|
+
import { NewNavigation, NewNavigationFooter } from './NewNavigation';
|
|
15
|
+
import { PurgeCacheConfirm, PurgeCacheConfirmFooter } from './PurgeCacheConfirm';
|
|
16
|
+
import { Typography } from '@strapi/design-system';
|
|
17
|
+
export const NavigationManager = ({ initialState, isOpened, onClose }) => {
|
|
18
|
+
const { formatMessage } = useIntl();
|
|
19
|
+
const [state, setState] = useState(initialState);
|
|
20
|
+
const { toggleNotification } = useNotification();
|
|
21
|
+
const hardReset = useHardReset();
|
|
22
|
+
const deleteNavigationsMutation = useDeleteNavigations();
|
|
23
|
+
const createNavigationMutation = useCreateNavigation();
|
|
24
|
+
const updateNavigationMutation = useUpdateNavigation();
|
|
25
|
+
const purgeNavigationsMutation = usePurgeNavigation();
|
|
26
|
+
const navigationsQuery = useNavigations();
|
|
27
|
+
const localeQuery = useLocale();
|
|
28
|
+
const navigations = useMemo(() => sortBy(navigationsQuery.data ?? [], 'id'), [navigationsQuery.data]);
|
|
29
|
+
const pending = getPendingAction([
|
|
30
|
+
deleteNavigationsMutation,
|
|
31
|
+
navigationsQuery,
|
|
32
|
+
createNavigationMutation,
|
|
33
|
+
updateNavigationMutation,
|
|
34
|
+
purgeNavigationsMutation,
|
|
35
|
+
localeQuery,
|
|
36
|
+
]);
|
|
37
|
+
const onReset = useCallback(() => setState({ view: 'INITIAL' }), [setState]);
|
|
38
|
+
const onSubmit = useCallback(async () => {
|
|
39
|
+
const performAction = state.view === 'DELETE'
|
|
40
|
+
? () => {
|
|
41
|
+
deleteNavigationsMutation.mutate(state.navigations.reduce((acc, navigation) => {
|
|
42
|
+
if (navigation.id) {
|
|
43
|
+
acc.push(navigation.id);
|
|
44
|
+
}
|
|
45
|
+
return acc;
|
|
46
|
+
}, []), {
|
|
47
|
+
onSuccess: hardReset,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
: state.view === 'EDIT'
|
|
51
|
+
? () => {
|
|
52
|
+
updateNavigationMutation.mutate(state.current, {
|
|
53
|
+
onSuccess() {
|
|
54
|
+
hardReset();
|
|
55
|
+
toggleNotification({
|
|
56
|
+
type: 'success',
|
|
57
|
+
message: formatMessage(getTrad('notification.navigation.submit')),
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
onError(error) {
|
|
61
|
+
// TODO: handle errors
|
|
62
|
+
console.warn(error);
|
|
63
|
+
toggleNotification({
|
|
64
|
+
type: 'warning',
|
|
65
|
+
message: formatMessage(getTrad('notification.navigation.error'), {
|
|
66
|
+
errorTitles: '',
|
|
67
|
+
}),
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
: state.view === 'CREATE' && state.current
|
|
73
|
+
? () => {
|
|
74
|
+
createNavigationMutation.mutate(state.current, {
|
|
75
|
+
onSuccess() {
|
|
76
|
+
hardReset();
|
|
77
|
+
toggleNotification({
|
|
78
|
+
type: 'success',
|
|
79
|
+
message: formatMessage(getTrad('notification.navigation.submit')),
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
onError(error) {
|
|
83
|
+
// TODO: handle errors
|
|
84
|
+
console.warn(error);
|
|
85
|
+
toggleNotification({
|
|
86
|
+
type: 'warning',
|
|
87
|
+
message: formatMessage(getTrad('notification.navigation.error'), {
|
|
88
|
+
errorTitles: '',
|
|
89
|
+
}),
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
: state.view === 'CACHE_PURGE'
|
|
95
|
+
? () => {
|
|
96
|
+
purgeNavigationsMutation.mutate(state.navigations.reduce((acc, navigation) => {
|
|
97
|
+
if (navigation.id) {
|
|
98
|
+
acc.push(navigation.id);
|
|
99
|
+
}
|
|
100
|
+
return acc;
|
|
101
|
+
}, []), {
|
|
102
|
+
onSuccess: hardReset,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
: () => { };
|
|
106
|
+
try {
|
|
107
|
+
performAction();
|
|
108
|
+
setState({ view: 'INITIAL' });
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
setState({
|
|
112
|
+
view: 'ERROR',
|
|
113
|
+
errors: error instanceof Error ? [error] : [],
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}, [
|
|
117
|
+
state,
|
|
118
|
+
setState,
|
|
119
|
+
hardReset,
|
|
120
|
+
createNavigationMutation,
|
|
121
|
+
purgeNavigationsMutation,
|
|
122
|
+
updateNavigationMutation,
|
|
123
|
+
deleteNavigationsMutation,
|
|
124
|
+
toggleNotification,
|
|
125
|
+
formatMessage,
|
|
126
|
+
getTrad,
|
|
127
|
+
]);
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
if (state.view === 'INITIAL' || state.view === 'LIST') {
|
|
130
|
+
setState({
|
|
131
|
+
view: 'LIST',
|
|
132
|
+
navigations,
|
|
133
|
+
selected: [],
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}, [state.view, navigations]);
|
|
137
|
+
const header = renderHeader(state, formatMessage, !!pending);
|
|
138
|
+
const content = renderContent(state, setState, !!pending);
|
|
139
|
+
const footer = renderFooter({
|
|
140
|
+
state,
|
|
141
|
+
setState,
|
|
142
|
+
onClose,
|
|
143
|
+
onSubmit,
|
|
144
|
+
onReset,
|
|
145
|
+
navigations,
|
|
146
|
+
isLoading: !!pending,
|
|
147
|
+
});
|
|
148
|
+
return (_jsx(Modal.Root, { labelledBy: "condition-modal-breadcrumbs", onOpenChange: (isOpen) => {
|
|
149
|
+
if (!isOpen) {
|
|
150
|
+
onClose?.();
|
|
151
|
+
}
|
|
152
|
+
}, open: isOpened, children: _jsxs(Modal.Content, { children: [_jsx(Modal.Header, { children: _jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "neutral800", as: "h2", children: header }) }), _jsx(Modal.Body, { children: content }), footer] }) }));
|
|
153
|
+
};
|
|
154
|
+
const renderHeader = (state, formatMessage, isLoading) => {
|
|
155
|
+
switch (state.view) {
|
|
156
|
+
case 'LIST':
|
|
157
|
+
case 'CREATE':
|
|
158
|
+
case 'ERROR':
|
|
159
|
+
case 'CACHE_PURGE':
|
|
160
|
+
case 'DELETE': {
|
|
161
|
+
return (_jsxs(Flex, { direction: "row", children: [isLoading ? _jsx(Loader, { small: true }) : null, formatMessage(getTrad(`popup.navigation.manage.header.${state.view}`))] }));
|
|
162
|
+
}
|
|
163
|
+
case 'EDIT': {
|
|
164
|
+
return (_jsxs(Flex, { direction: "row", children: [isLoading ? _jsx(Loader, { small: true }) : null, formatMessage(getTrad('popup.navigation.manage.header.EDIT'), {
|
|
165
|
+
name: state.navigation.name,
|
|
166
|
+
})] }));
|
|
167
|
+
}
|
|
168
|
+
case 'INITIAL': {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
default:
|
|
172
|
+
return handleUnknownState(state);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
const renderContent = (state, setState, isLoading) => {
|
|
176
|
+
const commonProps = {
|
|
177
|
+
setState,
|
|
178
|
+
isLoading,
|
|
179
|
+
};
|
|
180
|
+
switch (state.view) {
|
|
181
|
+
case 'LIST': {
|
|
182
|
+
return _jsx(AllNavigations, { ...state, ...commonProps });
|
|
183
|
+
}
|
|
184
|
+
case 'EDIT': {
|
|
185
|
+
return _jsx(NavigationUpdate, { ...state, ...commonProps });
|
|
186
|
+
}
|
|
187
|
+
case 'CREATE': {
|
|
188
|
+
return _jsx(NewNavigation, { ...state, ...commonProps });
|
|
189
|
+
}
|
|
190
|
+
case 'DELETE': {
|
|
191
|
+
return _jsx(DeletionConfirm, { ...state, ...commonProps });
|
|
192
|
+
}
|
|
193
|
+
case 'CACHE_PURGE': {
|
|
194
|
+
return _jsx(PurgeCacheConfirm, { ...state, ...commonProps });
|
|
195
|
+
}
|
|
196
|
+
case 'INITIAL': {
|
|
197
|
+
return _jsx(Loader, { small: true });
|
|
198
|
+
}
|
|
199
|
+
case 'ERROR': {
|
|
200
|
+
return _jsx(ErrorDetails, { ...state, ...commonProps });
|
|
201
|
+
}
|
|
202
|
+
default:
|
|
203
|
+
return handleUnknownState(state);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
const renderFooter = (props) => {
|
|
207
|
+
switch (props.state.view) {
|
|
208
|
+
case 'LIST': {
|
|
209
|
+
return _jsx(AllNavigationsFooter, { ...props });
|
|
210
|
+
}
|
|
211
|
+
case 'CREATE': {
|
|
212
|
+
return _jsx(NewNavigationFooter, { ...props });
|
|
213
|
+
}
|
|
214
|
+
case 'EDIT': {
|
|
215
|
+
return _jsx(NavigationUpdateFooter, { ...props });
|
|
216
|
+
}
|
|
217
|
+
case 'DELETE': {
|
|
218
|
+
return _jsx(DeleteConfirmFooter, { ...props });
|
|
219
|
+
}
|
|
220
|
+
case 'CACHE_PURGE': {
|
|
221
|
+
return _jsx(PurgeCacheConfirmFooter, { ...props });
|
|
222
|
+
}
|
|
223
|
+
case 'ERROR': {
|
|
224
|
+
return _jsx(ErrorDetailsFooter, { ...props });
|
|
225
|
+
}
|
|
226
|
+
case 'INITIAL': {
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
default:
|
|
230
|
+
return handleUnknownState(props.state);
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
const handleUnknownState = (state) => {
|
|
234
|
+
console.warn(`Unknown state "${state?.view}". (${JSON.stringify(state)})`);
|
|
235
|
+
return null;
|
|
236
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { IconButton, Searchbar, Typography } from '@strapi/design-system';
|
|
3
|
+
import { Search as SearchIcon } from '@strapi/icons';
|
|
4
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { useIntl } from 'react-intl';
|
|
6
|
+
import { getTrad } from '../../../../translations';
|
|
7
|
+
const DEFAULT_INDEX = 0;
|
|
8
|
+
export const Search = ({ value, setValue, initialIndex = DEFAULT_INDEX }) => {
|
|
9
|
+
const [currentValue, setCurrentValue] = useState(value);
|
|
10
|
+
const [previousValue, setPreviousValue] = useState(value);
|
|
11
|
+
const [currentIndex, setCurrentIndex] = useState(initialIndex);
|
|
12
|
+
const [isOpen, setIsOpen] = useState(!!value);
|
|
13
|
+
const wrapperRef = useRef(null);
|
|
14
|
+
const { formatMessage } = useIntl();
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (isOpen) {
|
|
17
|
+
setTimeout(() => {
|
|
18
|
+
wrapperRef.current?.querySelector('input')?.focus();
|
|
19
|
+
}, 0);
|
|
20
|
+
}
|
|
21
|
+
}, [isOpen]);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (currentIndex && currentValue === previousValue) {
|
|
24
|
+
setValue({
|
|
25
|
+
value: currentValue,
|
|
26
|
+
index: currentIndex,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}, [currentIndex, currentValue, previousValue]);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (currentValue !== previousValue) {
|
|
32
|
+
setPreviousValue(currentValue);
|
|
33
|
+
setCurrentIndex(DEFAULT_INDEX);
|
|
34
|
+
setValue({
|
|
35
|
+
value: currentValue,
|
|
36
|
+
index: DEFAULT_INDEX,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}, [currentValue, previousValue]);
|
|
40
|
+
const onKeyDown = useCallback((e) => {
|
|
41
|
+
if (e.code.toLowerCase() === 'enter') {
|
|
42
|
+
setCurrentIndex((current) => current + 1);
|
|
43
|
+
}
|
|
44
|
+
}, []);
|
|
45
|
+
const onChange = useCallback((e) => {
|
|
46
|
+
setCurrentValue(e.target.value);
|
|
47
|
+
}, [setCurrentValue]);
|
|
48
|
+
const onClear = useCallback(() => {
|
|
49
|
+
setCurrentValue('');
|
|
50
|
+
setIsOpen(false);
|
|
51
|
+
}, [setCurrentValue, setIsOpen]);
|
|
52
|
+
if (isOpen) {
|
|
53
|
+
return (_jsxs("div", { ref: wrapperRef, children: [_jsx(Searchbar, { name: "searchbar", onClear: onClear, value: value, size: "S", onChange: onChange, clearLabel: "Clearing the search", placeholder: formatMessage(getTrad('pages.main.search.placeholder', 'Type to start searching...')), onKeyDown: onKeyDown, children: "Search for navigation items" }), _jsx(Typography, { variant: "pi", fontColor: "neutral150", style: { margin: '3px 0 0', display: 'inline-block' }, children: formatMessage(getTrad('pages.main.search.subLabel', 'press ENTER to highlight next item')) })] }));
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
return _jsx(IconButton, { children: _jsx(SearchIcon, {}), onClick: () => setIsOpen(!isOpen) });
|
|
57
|
+
}
|
|
58
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './NavigationHeader';
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { getFetchClient } from '@strapi/strapi/admin';
|
|
3
|
+
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
4
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
5
|
+
import { getApiClient } from '../../../api';
|
|
6
|
+
import { I18nCopyNavigationItemsModal } from '../components/I18nCopyNavigationItems';
|
|
7
|
+
export const useLocale = () => {
|
|
8
|
+
const fetch = getFetchClient();
|
|
9
|
+
const apiClient = getApiClient(fetch);
|
|
10
|
+
return useQuery({
|
|
11
|
+
queryKey: apiClient.readLocaleIndex(),
|
|
12
|
+
queryFn: apiClient.readLocale,
|
|
13
|
+
staleTime: Infinity,
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
export const useContentTypeItems = (input) => {
|
|
17
|
+
const fetch = getFetchClient();
|
|
18
|
+
const apiClient = getApiClient(fetch);
|
|
19
|
+
return useQuery({
|
|
20
|
+
queryKey: apiClient.readContentTypeItemsIndex(input),
|
|
21
|
+
queryFn: () => apiClient.readContentTypeItems(input),
|
|
22
|
+
staleTime: 1000 * 60 * 3,
|
|
23
|
+
enabled: !!input.uid,
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
export const useContentTypes = () => {
|
|
27
|
+
const fetch = getFetchClient();
|
|
28
|
+
const apiClient = getApiClient(fetch);
|
|
29
|
+
return useQuery({
|
|
30
|
+
queryKey: apiClient.readContentTypeIndex(),
|
|
31
|
+
queryFn: () => apiClient.readContentType(),
|
|
32
|
+
staleTime: 1000 * 60 * 3,
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
export const useNavigations = () => {
|
|
36
|
+
const fetch = getFetchClient();
|
|
37
|
+
const apiClient = getApiClient(fetch);
|
|
38
|
+
return useQuery({
|
|
39
|
+
queryKey: apiClient.readAllIndex(),
|
|
40
|
+
queryFn() {
|
|
41
|
+
return apiClient.readAll().then((navigations) => navigations.map((navigation) => ({
|
|
42
|
+
...navigation,
|
|
43
|
+
items: navigation.items.map(appendViewId),
|
|
44
|
+
})));
|
|
45
|
+
},
|
|
46
|
+
staleTime: 1000 * 60 * 5,
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
export const useHardReset = () => {
|
|
50
|
+
const client = useQueryClient();
|
|
51
|
+
const fetch = getFetchClient();
|
|
52
|
+
const apiClient = getApiClient(fetch);
|
|
53
|
+
return useCallback(() => {
|
|
54
|
+
client.invalidateQueries({
|
|
55
|
+
queryKey: apiClient.getIndexPrefix(),
|
|
56
|
+
});
|
|
57
|
+
}, [client, fetch, apiClient]);
|
|
58
|
+
};
|
|
59
|
+
export const useDeleteNavigations = () => {
|
|
60
|
+
const fetch = getFetchClient();
|
|
61
|
+
const apiClient = getApiClient(fetch);
|
|
62
|
+
return useMutation({
|
|
63
|
+
mutationFn(ids) {
|
|
64
|
+
return Promise.all(ids.map(apiClient.delete));
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
export const useCopyNavigationItemI18n = () => {
|
|
69
|
+
const fetch = getFetchClient();
|
|
70
|
+
const apiClient = getApiClient(fetch);
|
|
71
|
+
return useMutation({
|
|
72
|
+
mutationFn: apiClient.copyNavigationItemLocale,
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
export const useCopyNavigationI18n = () => {
|
|
76
|
+
const fetch = getFetchClient();
|
|
77
|
+
const apiClient = getApiClient(fetch);
|
|
78
|
+
// TODO: nicer cache update
|
|
79
|
+
const queryClient = useQueryClient();
|
|
80
|
+
return useMutation({
|
|
81
|
+
mutationFn: apiClient.copyNavigationLocale,
|
|
82
|
+
onSuccess() {
|
|
83
|
+
queryClient.invalidateQueries({
|
|
84
|
+
queryKey: apiClient.readAllIndex(),
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
export const useCreateNavigation = () => {
|
|
90
|
+
const fetch = getFetchClient();
|
|
91
|
+
const apiClient = getApiClient(fetch);
|
|
92
|
+
// TODO: nicer cache update
|
|
93
|
+
const queryClient = useQueryClient();
|
|
94
|
+
return useMutation({
|
|
95
|
+
mutationFn: apiClient.create,
|
|
96
|
+
onSuccess() {
|
|
97
|
+
queryClient.invalidateQueries({
|
|
98
|
+
queryKey: apiClient.readAllIndex(),
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
export const useUpdateNavigation = (onSuccess) => {
|
|
104
|
+
const fetch = getFetchClient();
|
|
105
|
+
const apiClient = getApiClient(fetch);
|
|
106
|
+
// TODO: nicer cache update
|
|
107
|
+
const queryClient = useQueryClient();
|
|
108
|
+
return useMutation({
|
|
109
|
+
mutationFn: apiClient.update,
|
|
110
|
+
onSuccess() {
|
|
111
|
+
queryClient.invalidateQueries({
|
|
112
|
+
queryKey: apiClient.readAllIndex(),
|
|
113
|
+
});
|
|
114
|
+
onSuccess?.();
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
export const usePurgeNavigation = () => {
|
|
119
|
+
const fetch = getFetchClient();
|
|
120
|
+
const apiClient = getApiClient(fetch);
|
|
121
|
+
return useMutation({
|
|
122
|
+
mutationFn(ids) {
|
|
123
|
+
if (!ids?.length) {
|
|
124
|
+
return apiClient.purge({});
|
|
125
|
+
}
|
|
126
|
+
return Promise.all(ids.map((id) => apiClient.purge({ id, withLangVersions: true })));
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
export const useConfig = () => {
|
|
131
|
+
const fetch = getFetchClient();
|
|
132
|
+
const apiClient = getApiClient(fetch);
|
|
133
|
+
return useQuery({
|
|
134
|
+
queryKey: apiClient.readConfigIndex(),
|
|
135
|
+
queryFn: apiClient.readConfig,
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
export const useI18nCopyNavigationItemsModal = (onConfirm) => {
|
|
139
|
+
const [isOpened, setIsOpened] = useState(false);
|
|
140
|
+
const [sourceLocale, setSourceLocale] = useState(undefined);
|
|
141
|
+
const onCancel = useCallback(() => {
|
|
142
|
+
setIsOpened(false);
|
|
143
|
+
}, [setIsOpened]);
|
|
144
|
+
const onConfirmWithModalClose = useCallback(() => {
|
|
145
|
+
if (!sourceLocale) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
onConfirm(sourceLocale);
|
|
149
|
+
setIsOpened(false);
|
|
150
|
+
}, [onConfirm, sourceLocale]);
|
|
151
|
+
const modal = useMemo(() => isOpened ? (_jsx(I18nCopyNavigationItemsModal, { onConfirm: onConfirmWithModalClose, onCancel: onCancel })) : null, [isOpened, onConfirmWithModalClose, onCancel]);
|
|
152
|
+
return useMemo(() => ({
|
|
153
|
+
setI18nCopyModalOpened: setIsOpened,
|
|
154
|
+
setI18nCopySourceLocale: setSourceLocale,
|
|
155
|
+
i18nCopyItemsModal: modal,
|
|
156
|
+
i18nCopySourceLocale: sourceLocale,
|
|
157
|
+
}), [setSourceLocale, setIsOpened, modal, sourceLocale]);
|
|
158
|
+
};
|
|
159
|
+
const appendViewId = (item) => {
|
|
160
|
+
return {
|
|
161
|
+
...item,
|
|
162
|
+
viewId: Math.floor(Math.random() * 1520000),
|
|
163
|
+
items: item.items?.map(appendViewId),
|
|
164
|
+
};
|
|
165
|
+
};
|