File tree Expand file tree Collapse file tree 6 files changed +21
-5
lines changed Expand file tree Collapse file tree 6 files changed +21
-5
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " strapi-plugin-navigation" ,
3- "version" : " 3.2.5 " ,
3+ "version" : " 3.2.6-beta.1 " ,
44 "description" : " Strapi - Navigation plugin" ,
55 "strapi" : {
66 "name" : " navigation" ,
Original file line number Diff line number Diff line change @@ -4,9 +4,10 @@ import { configSetup } from './config';
44import { navigationSetup } from './i18n' ;
55import { setupPermissions } from './permissions' ;
66import { graphQLSetup } from './graphql' ;
7- import { getPluginService } from './utils' ;
7+ import { getPluginService , removeNavigationsWithoutDefaultLocale } from './utils' ;
88
99const bootstrap = async ( context : { strapi : Core . Strapi } ) => {
10+ await removeNavigationsWithoutDefaultLocale ( context ) ;
1011 await configSetup ( context ) ;
1112 await navigationSetup ( context ) ;
1213 await setupPermissions ( context ) ;
Original file line number Diff line number Diff line change @@ -101,13 +101,13 @@ export const getNavigationRepository = once((context: { strapi: Core.Strapi }) =
101101 }
102102 } ,
103103
104- remove ( navigation : Partial < Pick < NavigationDBSchema , 'documentId' > > ) {
104+ remove ( navigation : Partial < Pick < NavigationDBSchema , 'documentId' | 'locale' > > ) {
105105 const { masterModel } = getPluginModels ( context ) ;
106106
107107 if ( ! navigation . documentId ) {
108108 throw new NavigationError ( 'Document id is required.' ) ;
109109 }
110110
111- return context . strapi . documents ( masterModel . uid ) . delete ( { documentId : navigation . documentId } ) ;
111+ return context . strapi . documents ( masterModel . uid ) . delete ( { documentId : navigation . documentId , locale : navigation . locale } ) ;
112112 } ,
113113} ) ) ;
Original file line number Diff line number Diff line change @@ -515,11 +515,12 @@ const adminService = (context: { strapi: Core.Strapi }) => ({
515515 } ) ;
516516 const allNavigations = await navigationRepository . find ( {
517517 filters : { documentId : navigation . documentId } ,
518+ locale : '*' ,
518519 populate : '*' ,
519520 } ) ;
520521
521522 await cleanNavigationItems ( allNavigations . map ( ( { id } : NavigationDBSchema ) => id ) ) ;
522- await navigationRepository . remove ( { documentId : navigation . documentId } ) ;
523+ await navigationRepository . remove ( { documentId : navigation . documentId , locale : '*' } ) ;
523524
524525 sendAuditLog ( auditLog , 'onNavigationDeletion' , {
525526 entity : navigationAsDTO ,
Original file line number Diff line number Diff line change 11export * from './constants' ;
22export * from './functions' ;
3+ export * from './migration' ;
Original file line number Diff line number Diff line change 1+ import { Core } from "@strapi/types" ;
2+ import { getNavigationRepository } from "../repositories" ;
3+
4+ export const removeNavigationsWithoutDefaultLocale = async ( context : { strapi : Core . Strapi } ) => {
5+ const allNavigations = await getNavigationRepository ( context ) . find ( { locale : '*' , limit : Number . MAX_SAFE_INTEGER } ) ;
6+ const defaultLocale = context . strapi . plugin ( 'i18n' ) . service ( 'locales' ) . getDefaultLocale ( ) . code ;
7+ await Promise . all ( allNavigations . map ( async ( navigation ) => {
8+ const root = allNavigations . find ( ( { documentId, locale } ) => documentId === navigation . documentId && locale === defaultLocale ) ;
9+ if ( ! root ) {
10+ await getNavigationRepository ( context ) . remove ( { documentId : navigation . documentId , locale : navigation . locale } ) ;
11+ }
12+ } ) ) ;
13+ }
You can’t perform that action at this time.
0 commit comments