strapi-plugin-navigation 3.0.0-beta.2 → 3.0.0-beta.3
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 +7 -7
- package/dist/_chunks/{ca-DIZHA0OL.mjs → ca-Catou0wg.mjs} +4 -0
- package/dist/_chunks/{ca-Bjfh0w36.js → ca-DtaqQvTI.js} +4 -0
- package/dist/admin/index.js +64 -28
- package/dist/admin/index.mjs +65 -29
- package/dist/admin/src/api/client.d.ts +3 -1
- package/dist/admin/src/api/validators.d.ts +3 -3
- package/dist/admin/src/pages/HomePage/components/NavigationItemForm/index.d.ts +1 -1
- package/dist/admin/src/pages/HomePage/components/NavigationItemPopup/index.d.ts +1 -1
- package/dist/admin/src/pages/HomePage/components/NavigationManager/types.d.ts +1 -1
- package/dist/admin/src/pages/HomePage/hooks/index.d.ts +3 -3
- package/dist/admin/src/pages/SettingsPage/hooks/index.d.ts +1 -1
- package/dist/admin/src/translations/ca.d.ts +4 -0
- package/dist/server/index.js +98 -92
- package/dist/server/index.mjs +98 -92
- package/dist/server/src/content-types/index.d.ts +0 -4
- package/dist/server/src/content-types/navigation/index.d.ts +0 -4
- package/dist/server/src/content-types/navigation/schema.d.ts +0 -4
- package/dist/server/src/controllers/admin.d.ts +10 -10
- package/dist/server/src/controllers/client.d.ts +2 -2
- package/dist/server/src/controllers/validators.d.ts +2 -2
- package/dist/server/src/index.d.ts +7 -11
- package/dist/server/src/repositories/navigation-item.d.ts +8 -4
- package/dist/server/src/repositories/navigation.d.ts +12 -8
- package/dist/server/src/schemas/navigation.d.ts +8 -8
- package/dist/server/src/services/admin/admin.d.ts +2 -2
- package/dist/server/src/services/admin/types.d.ts +2 -2
- package/dist/server/src/services/admin/utils.d.ts +1 -1
- package/dist/server/src/services/client/client.d.ts +1 -1
- package/dist/server/src/services/index.d.ts +7 -7
- package/package.json +6 -7
|
@@ -17,6 +17,6 @@ type NavigationItemFormProps = {
|
|
|
17
17
|
permissions?: Partial<{
|
|
18
18
|
canUpdate: boolean;
|
|
19
19
|
}>;
|
|
20
|
-
currentNavigation: Pick<NavigationSchema, 'id' | 'documentId' | '
|
|
20
|
+
currentNavigation: Pick<NavigationSchema, 'id' | 'documentId' | 'locale'>;
|
|
21
21
|
};
|
|
22
22
|
export declare const NavigationItemForm: React.FC<NavigationItemFormProps>;
|
|
@@ -13,7 +13,7 @@ interface Props {
|
|
|
13
13
|
permissions?: {
|
|
14
14
|
canUpdate?: boolean;
|
|
15
15
|
};
|
|
16
|
-
currentNavigation: Pick<NavigationSchema, 'id' | 'documentId' | '
|
|
16
|
+
currentNavigation: Pick<NavigationSchema, 'id' | 'documentId' | 'locale'>;
|
|
17
17
|
}
|
|
18
18
|
declare const NavigationItemPopUp: FC<Props>;
|
|
19
19
|
export default NavigationItemPopUp;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Dispatch, SetStateAction } from 'react';
|
|
2
2
|
import { NavigationSchema } from '../../../../api/validators';
|
|
3
|
-
export type Navigation = Pick<NavigationSchema, 'id' | 'items' | 'name' | '
|
|
3
|
+
export type Navigation = Pick<NavigationSchema, 'id' | 'items' | 'name' | 'locale' | 'visible' | 'documentId' | 'slug'>;
|
|
4
4
|
export type NewNavigation = Omit<Navigation, 'id' | 'documentId' | 'slug'>;
|
|
5
5
|
export type State = InitialState | ListState | EditState | CreateState | DeleteState | PurgeCacheState | ErrorState;
|
|
6
6
|
export type SetState = Dispatch<SetStateAction<State>>;
|
|
@@ -35,7 +35,7 @@ export declare const useNavigations: () => import("@tanstack/react-query").UseQu
|
|
|
35
35
|
documentId: string;
|
|
36
36
|
items: NavigationItemSchema[];
|
|
37
37
|
slug: string;
|
|
38
|
-
|
|
38
|
+
locale: string;
|
|
39
39
|
visible: boolean;
|
|
40
40
|
}[], Error>;
|
|
41
41
|
export declare const useHardReset: () => () => void;
|
|
@@ -63,7 +63,7 @@ export declare const useCreateNavigation: () => import("@tanstack/react-query").
|
|
|
63
63
|
documentId: string;
|
|
64
64
|
items: NavigationItemSchema[];
|
|
65
65
|
slug: string;
|
|
66
|
-
|
|
66
|
+
locale: string;
|
|
67
67
|
visible: boolean;
|
|
68
68
|
}, "id" | "documentId" | "slug">, unknown>;
|
|
69
69
|
export declare const useUpdateNavigation: (onSuccess?: Effect<void>) => import("@tanstack/react-query").UseMutationResult<import("@strapi/strapi/admin").FetchResponse<any>, Error, {
|
|
@@ -72,7 +72,7 @@ export declare const useUpdateNavigation: (onSuccess?: Effect<void>) => import("
|
|
|
72
72
|
documentId: string;
|
|
73
73
|
items: NavigationItemSchema[];
|
|
74
74
|
slug: string;
|
|
75
|
-
|
|
75
|
+
locale: string;
|
|
76
76
|
visible: boolean;
|
|
77
77
|
}, unknown>;
|
|
78
78
|
export declare const usePurgeNavigation: () => import("@tanstack/react-query").UseMutationResult<unknown, Error, string[] | undefined, unknown>;
|
|
@@ -46,7 +46,7 @@ export declare const useConfig: () => import("@tanstack/react-query").UseQueryRe
|
|
|
46
46
|
isCacheEnabled?: boolean | undefined;
|
|
47
47
|
isCachePluginEnabled?: boolean | undefined;
|
|
48
48
|
}, Error>;
|
|
49
|
-
export declare const useRestart: () => import("@tanstack/react-query").UseMutationResult<
|
|
49
|
+
export declare const useRestart: () => import("@tanstack/react-query").UseMutationResult<import("@tanstack/react-query").QueryObserverResult<import("@strapi/strapi/admin").FetchResponse<any>, Error>, Error, void, unknown>;
|
|
50
50
|
export declare const useRestoreConfig: () => import("@tanstack/react-query").UseMutationResult<void, Error, void, unknown>;
|
|
51
51
|
export declare const useContentTypes: () => import("@tanstack/react-query").UseQueryResult<{
|
|
52
52
|
kind: "collectionType" | "singleType";
|
package/dist/server/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const z = require("zod");
|
|
3
3
|
const ___default = require("lodash");
|
|
4
|
-
const cuid2 = require("@paralleldrive/cuid2");
|
|
5
4
|
const fp = require("lodash/fp");
|
|
6
5
|
const require$$1 = require("crypto");
|
|
7
6
|
const require$$0$1 = require("child_process");
|
|
@@ -260,7 +259,7 @@ const navigationDBSchema = (withItems) => z__namespace.object({
|
|
|
260
259
|
documentId: z__namespace.string(),
|
|
261
260
|
name: z__namespace.string(),
|
|
262
261
|
slug: z__namespace.string(),
|
|
263
|
-
|
|
262
|
+
locale: z__namespace.string(),
|
|
264
263
|
visible: z__namespace.boolean(),
|
|
265
264
|
items: withItems ? z__namespace.array(navigationItemDBSchema) : navigationItemDBSchema.array().optional()
|
|
266
265
|
});
|
|
@@ -269,7 +268,7 @@ const createNavigationSchema = navigationDBSchema(false).omit({
|
|
|
269
268
|
id: true,
|
|
270
269
|
documentId: true,
|
|
271
270
|
slug: true,
|
|
272
|
-
|
|
271
|
+
locale: true
|
|
273
272
|
}).extend({
|
|
274
273
|
documentId: z__namespace.string().optional(),
|
|
275
274
|
id: z__namespace.undefined().optional()
|
|
@@ -527,15 +526,15 @@ const getNavigationItemRepository = ___default.once((context) => ({
|
|
|
527
526
|
save(item) {
|
|
528
527
|
const { itemModel } = getPluginModels(context);
|
|
529
528
|
if (typeof item.documentId === "string") {
|
|
530
|
-
const { documentId,
|
|
531
|
-
return context.strapi.
|
|
529
|
+
const { documentId, ...rest } = item;
|
|
530
|
+
return context.strapi.documents(itemModel.uid).update({ documentId: item.documentId, data: { ...rest } });
|
|
532
531
|
} else {
|
|
533
|
-
return context.strapi.
|
|
532
|
+
return context.strapi.documents(itemModel.uid).create({ data: item });
|
|
534
533
|
}
|
|
535
534
|
},
|
|
536
|
-
find({
|
|
535
|
+
find({ filters: filters2, locale: locale2, limit, order, populate: populate2 }) {
|
|
537
536
|
const { itemModel } = getPluginModels(context);
|
|
538
|
-
return context.strapi.
|
|
537
|
+
return context.strapi.documents(itemModel.uid).findMany({ filters: filters2, locale: locale2, limit, populate: populate2, orderBy: order }).then(navigationItemsDBSchema.parse);
|
|
539
538
|
},
|
|
540
539
|
count(where) {
|
|
541
540
|
const { itemModel } = getPluginModels(context);
|
|
@@ -584,31 +583,33 @@ const calculateItemsRequirement = (populate2) => {
|
|
|
584
583
|
return populate2 === true ? true : Array.isArray(populate2) ? populate2.includes("items") : false;
|
|
585
584
|
};
|
|
586
585
|
const getNavigationRepository = ___default.once((context) => ({
|
|
587
|
-
find({
|
|
586
|
+
find({ filters: filters2, locale: locale2, limit, orderBy, populate: populate2 }) {
|
|
588
587
|
const { masterModel } = getPluginModels(context);
|
|
589
|
-
return context.strapi.
|
|
588
|
+
return context.strapi.documents(masterModel.uid).findMany({ filters: filters2, locale: locale2, limit, populate: populate2, orderBy }).then((data) => {
|
|
590
589
|
return navigationDBSchema(calculateItemsRequirement(populate2)).array().parse(data);
|
|
591
590
|
});
|
|
592
591
|
},
|
|
593
|
-
findOne({
|
|
592
|
+
findOne({ locale: locale2, filters: filters2, populate: populate2 }) {
|
|
594
593
|
const { masterModel } = getPluginModels(context);
|
|
595
|
-
return context.strapi.
|
|
594
|
+
return context.strapi.documents(masterModel.uid).findOne({ documentId: filters2.documentId, locale: locale2, populate: populate2 }).then((data) => {
|
|
596
595
|
return navigationDBSchema(calculateItemsRequirement(populate2)).parse(data);
|
|
597
596
|
});
|
|
598
597
|
},
|
|
599
|
-
save(navigation2) {
|
|
598
|
+
async save(navigation2) {
|
|
600
599
|
const { masterModel } = getPluginModels(context);
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
600
|
+
const { documentId, locale: locale2, ...rest } = navigation2;
|
|
601
|
+
if (documentId) {
|
|
602
|
+
return context.strapi.documents(masterModel.uid).update({
|
|
603
|
+
locale: locale2,
|
|
604
|
+
documentId,
|
|
605
|
+
data: ___default.omit(rest, ["id", "documentId"]),
|
|
605
606
|
populate: ["items"]
|
|
606
607
|
}).then(navigationDBSchema(false).parse);
|
|
607
608
|
} else {
|
|
608
|
-
return context.strapi.
|
|
609
|
+
return context.strapi.documents(masterModel.uid).create({
|
|
610
|
+
locale: locale2,
|
|
609
611
|
data: {
|
|
610
|
-
...
|
|
611
|
-
documentId: navigation2.documentId ?? cuid2.createId(),
|
|
612
|
+
...rest,
|
|
612
613
|
populate: ["items"]
|
|
613
614
|
}
|
|
614
615
|
}).then((x) => {
|
|
@@ -632,31 +633,32 @@ const navigationSetup = async (context) => {
|
|
|
632
633
|
const navigationRepository = getNavigationRepository(context);
|
|
633
634
|
const navigations = await navigationRepository.find({
|
|
634
635
|
limit: Number.MAX_SAFE_INTEGER,
|
|
635
|
-
|
|
636
|
+
filters: {},
|
|
637
|
+
locale: "*"
|
|
636
638
|
});
|
|
637
639
|
if (navigations.length === 0) {
|
|
638
640
|
navigations.push(
|
|
639
641
|
await navigationRepository.save({
|
|
640
642
|
name: DEFAULT_NAVIGATION_NAME,
|
|
641
|
-
localeCode: defaultLocale,
|
|
642
643
|
visible: true,
|
|
644
|
+
locale: defaultLocale,
|
|
643
645
|
slug: `${DEFAULT_NAVIGATION_SLUG}-${defaultLocale}`
|
|
644
646
|
})
|
|
645
647
|
);
|
|
646
648
|
}
|
|
647
649
|
const defaultLocaleNavigations = navigations.filter(
|
|
648
|
-
({
|
|
650
|
+
({ locale: locale2 }) => locale2 === defaultLocale
|
|
649
651
|
);
|
|
650
652
|
for (const defaultLocaleNavigation of defaultLocaleNavigations) {
|
|
651
653
|
for (const otherLocale of restLocale) {
|
|
652
654
|
const otherLocaleMissing = !navigations.find(
|
|
653
|
-
({
|
|
655
|
+
({ locale: locale2, documentId }) => documentId === defaultLocaleNavigation.documentId && otherLocale === locale2
|
|
654
656
|
);
|
|
655
657
|
if (otherLocaleMissing) {
|
|
656
658
|
await navigationRepository.save({
|
|
657
659
|
documentId: defaultLocaleNavigation.documentId,
|
|
658
660
|
name: defaultLocaleNavigation.name,
|
|
659
|
-
|
|
661
|
+
locale: otherLocale,
|
|
660
662
|
visible: defaultLocaleNavigation.visible,
|
|
661
663
|
slug: `${defaultLocaleNavigation.slug.replace(`-${defaultLocale}`, "")}-${otherLocale}`
|
|
662
664
|
});
|
|
@@ -1090,10 +1092,6 @@ const schema$2 = {
|
|
|
1090
1092
|
target: "plugin::navigation.navigation-item",
|
|
1091
1093
|
configurable: false,
|
|
1092
1094
|
mappedBy: "master"
|
|
1093
|
-
},
|
|
1094
|
-
localeCode: {
|
|
1095
|
-
type: "string",
|
|
1096
|
-
configurable: false
|
|
1097
1095
|
}
|
|
1098
1096
|
}
|
|
1099
1097
|
};
|
|
@@ -14773,7 +14771,7 @@ const processItems = (context) => async (item) => {
|
|
|
14773
14771
|
const entity = context.entities.get(related);
|
|
14774
14772
|
const localeVersion = await strapi.documents(entity.uid).findOne({
|
|
14775
14773
|
documentId: entity.documentId,
|
|
14776
|
-
locale: context.
|
|
14774
|
+
locale: context.locale,
|
|
14777
14775
|
status: "published"
|
|
14778
14776
|
});
|
|
14779
14777
|
if (localeVersion) {
|
|
@@ -14961,16 +14959,14 @@ const adminService = (context) => ({
|
|
|
14961
14959
|
return acc;
|
|
14962
14960
|
}, []);
|
|
14963
14961
|
},
|
|
14964
|
-
async get({ ids,
|
|
14965
|
-
let
|
|
14962
|
+
async get({ ids, locale: locale2 }) {
|
|
14963
|
+
let filters2 = {};
|
|
14966
14964
|
if (ids && ids.length) {
|
|
14967
|
-
|
|
14968
|
-
}
|
|
14969
|
-
if (localeCode) {
|
|
14970
|
-
where.localeCode = localeCode;
|
|
14965
|
+
filters2.id = { $in: ids };
|
|
14971
14966
|
}
|
|
14972
14967
|
const dbResults = await getNavigationRepository(context).find({
|
|
14973
|
-
|
|
14968
|
+
filters: filters2,
|
|
14969
|
+
locale: locale2 || "*",
|
|
14974
14970
|
limit: Number.MAX_SAFE_INTEGER,
|
|
14975
14971
|
populate: ["items", "items.parent", "items.audience"]
|
|
14976
14972
|
});
|
|
@@ -14979,7 +14975,7 @@ const adminService = (context) => ({
|
|
|
14979
14975
|
item,
|
|
14980
14976
|
parent
|
|
14981
14977
|
}) => {
|
|
14982
|
-
const children = allItems.filter((child) => child.parent?.
|
|
14978
|
+
const children = allItems.filter((child) => child.parent?.documentId === item.documentId);
|
|
14983
14979
|
return {
|
|
14984
14980
|
...item,
|
|
14985
14981
|
parent,
|
|
@@ -14999,22 +14995,22 @@ const adminService = (context) => ({
|
|
|
14999
14995
|
allItems: navigation2.items ?? [],
|
|
15000
14996
|
item
|
|
15001
14997
|
})
|
|
15002
|
-
)
|
|
14998
|
+
).sort((a, b) => a.order - b.order)
|
|
15003
14999
|
}));
|
|
15004
15000
|
},
|
|
15005
|
-
async getById({ documentId,
|
|
15001
|
+
async getById({ documentId, locale: locale2 }) {
|
|
15006
15002
|
const commonService2 = getPluginService(context, "common");
|
|
15007
|
-
const
|
|
15003
|
+
const { defaultLocale } = await commonService2.readLocale();
|
|
15004
|
+
const filters2 = {
|
|
15008
15005
|
documentId
|
|
15009
15006
|
};
|
|
15010
|
-
if (localeCode) {
|
|
15011
|
-
where.localeCode = localeCode;
|
|
15012
|
-
}
|
|
15013
15007
|
const navigation2 = await getNavigationRepository(context).findOne({
|
|
15014
|
-
|
|
15008
|
+
filters: filters2,
|
|
15009
|
+
locale: locale2 || defaultLocale
|
|
15015
15010
|
});
|
|
15016
15011
|
const dbNavigationItems = await getNavigationItemRepository(context).find({
|
|
15017
|
-
|
|
15012
|
+
filters: { master: navigation2.id },
|
|
15013
|
+
locale: locale2 || defaultLocale,
|
|
15018
15014
|
limit: Number.MAX_SAFE_INTEGER,
|
|
15019
15015
|
order: [{ order: "asc" }],
|
|
15020
15016
|
populate: ["parent", "audience"]
|
|
@@ -15037,15 +15033,15 @@ const adminService = (context) => ({
|
|
|
15037
15033
|
const mainNavigation = await repository.save({
|
|
15038
15034
|
name,
|
|
15039
15035
|
visible,
|
|
15040
|
-
|
|
15041
|
-
slug
|
|
15036
|
+
locale: defaultLocale,
|
|
15037
|
+
slug: `${slug}-${defaultLocale}`
|
|
15042
15038
|
});
|
|
15043
15039
|
navigationSummary.push(await this.getById({ documentId: mainNavigation.documentId }));
|
|
15044
15040
|
for (const localeCode of restLocale) {
|
|
15045
15041
|
const newLocaleNavigation = await repository.save({
|
|
15046
15042
|
name,
|
|
15047
15043
|
visible,
|
|
15048
|
-
localeCode,
|
|
15044
|
+
locale: localeCode,
|
|
15049
15045
|
slug: `${slug}-${localeCode}`,
|
|
15050
15046
|
documentId: mainNavigation.documentId
|
|
15051
15047
|
});
|
|
@@ -15075,26 +15071,28 @@ const adminService = (context) => ({
|
|
|
15075
15071
|
const repository = getNavigationRepository(context);
|
|
15076
15072
|
const { name, visible, items } = payload;
|
|
15077
15073
|
const currentNavigation = await repository.findOne({
|
|
15078
|
-
|
|
15079
|
-
|
|
15074
|
+
filters: { documentId: payload.documentId },
|
|
15075
|
+
locale: payload.locale,
|
|
15076
|
+
populate: "*"
|
|
15080
15077
|
});
|
|
15081
15078
|
const currentNavigationAsDTO = await this.getById({
|
|
15082
15079
|
documentId: payload.documentId,
|
|
15083
|
-
|
|
15080
|
+
locale: payload.locale
|
|
15084
15081
|
});
|
|
15085
15082
|
const detailsHaveChanged = currentNavigation.name !== name || currentNavigation.visible !== visible;
|
|
15086
15083
|
if (detailsHaveChanged) {
|
|
15087
15084
|
const allNavigations = await repository.find({
|
|
15088
|
-
|
|
15085
|
+
filters: { documentId: currentNavigation.documentId }
|
|
15089
15086
|
});
|
|
15090
15087
|
for (const navigation2 of allNavigations) {
|
|
15091
15088
|
const newSlug = name ? await commonService2.getSlug({
|
|
15092
|
-
query: `${name}${navigation2.
|
|
15089
|
+
query: `${name}${navigation2.locale !== defaultLocale ? ` ${navigation2.locale}` : ""}`
|
|
15093
15090
|
}) : currentNavigation.slug;
|
|
15094
15091
|
await repository.save({
|
|
15095
15092
|
documentId: navigation2.documentId,
|
|
15096
15093
|
id: navigation2.id,
|
|
15097
15094
|
slug: newSlug,
|
|
15095
|
+
locale: navigation2.locale,
|
|
15098
15096
|
name,
|
|
15099
15097
|
visible
|
|
15100
15098
|
});
|
|
@@ -15115,8 +15113,8 @@ const adminService = (context) => ({
|
|
|
15115
15113
|
});
|
|
15116
15114
|
await commonService2.emitEvent({
|
|
15117
15115
|
entity: await repository.findOne({
|
|
15118
|
-
|
|
15119
|
-
populate:
|
|
15116
|
+
filters: { documentId: payload.documentId },
|
|
15117
|
+
populate: "*"
|
|
15120
15118
|
}),
|
|
15121
15119
|
event: "entry.update",
|
|
15122
15120
|
uid: masterModel.uid
|
|
@@ -15143,12 +15141,12 @@ const adminService = (context) => ({
|
|
|
15143
15141
|
);
|
|
15144
15142
|
};
|
|
15145
15143
|
const navigation2 = await navigationRepository.findOne({
|
|
15146
|
-
|
|
15147
|
-
populate:
|
|
15144
|
+
filters: { documentId },
|
|
15145
|
+
populate: "*"
|
|
15148
15146
|
});
|
|
15149
15147
|
const allNavigations = await navigationRepository.find({
|
|
15150
|
-
|
|
15151
|
-
populate:
|
|
15148
|
+
filters: { documentId: navigation2.documentId },
|
|
15149
|
+
populate: "*"
|
|
15152
15150
|
});
|
|
15153
15151
|
await cleanNavigationItems(
|
|
15154
15152
|
allNavigations.map(({ documentId: documentId2 }) => documentId2)
|
|
@@ -15175,7 +15173,6 @@ const adminService = (context) => ({
|
|
|
15175
15173
|
key: "config"
|
|
15176
15174
|
}).then(configSchema.parse);
|
|
15177
15175
|
validateAdditionalFields(newConfig.additionalFields);
|
|
15178
|
-
console.log({ newConfig });
|
|
15179
15176
|
await pluginStore.set({ key: "config", value: newConfig });
|
|
15180
15177
|
const removedFields = ___default.differenceBy(
|
|
15181
15178
|
config2.additionalFields,
|
|
@@ -15198,11 +15195,11 @@ const adminService = (context) => ({
|
|
|
15198
15195
|
target,
|
|
15199
15196
|
documentId
|
|
15200
15197
|
}) {
|
|
15201
|
-
const targetEntity = await this.getById({ documentId,
|
|
15198
|
+
const targetEntity = await this.getById({ documentId, locale: target });
|
|
15202
15199
|
return await this.i18nNavigationContentsCopy({
|
|
15203
|
-
source: await this.getById({ documentId,
|
|
15200
|
+
source: await this.getById({ documentId, locale: source }),
|
|
15204
15201
|
target: targetEntity
|
|
15205
|
-
}).then(() => this.getById({ documentId,
|
|
15202
|
+
}).then(() => this.getById({ documentId, locale: target })).then((newEntity) => {
|
|
15206
15203
|
sendAuditLog(auditLog, "onChangeNavigation", {
|
|
15207
15204
|
actionType: "UPDATE",
|
|
15208
15205
|
oldEntity: targetEntity,
|
|
@@ -15221,7 +15218,7 @@ const adminService = (context) => ({
|
|
|
15221
15218
|
if (target.items?.length) {
|
|
15222
15219
|
throw new FillNavigationError("Current navigation is non-empty");
|
|
15223
15220
|
}
|
|
15224
|
-
if (!target.
|
|
15221
|
+
if (!target.locale) {
|
|
15225
15222
|
throw new FillNavigationError("Current navigation does not have specified locale");
|
|
15226
15223
|
}
|
|
15227
15224
|
if (!sourceItems.length) {
|
|
@@ -15230,15 +15227,16 @@ const adminService = (context) => ({
|
|
|
15230
15227
|
const entities = /* @__PURE__ */ new Map();
|
|
15231
15228
|
const itemProcessor = processItems({
|
|
15232
15229
|
master: target,
|
|
15233
|
-
|
|
15230
|
+
locale: target.locale,
|
|
15234
15231
|
strapi,
|
|
15235
15232
|
entities
|
|
15236
15233
|
});
|
|
15237
15234
|
await commonService2.createBranch({
|
|
15238
15235
|
action: { create: true },
|
|
15239
15236
|
masterEntity: await navigationRepository.findOne({
|
|
15240
|
-
|
|
15241
|
-
|
|
15237
|
+
filters: { documentId: target.documentId },
|
|
15238
|
+
locale: target.locale,
|
|
15239
|
+
populate: "*"
|
|
15242
15240
|
}),
|
|
15243
15241
|
navigationItems: await Promise.all(sourceItems.map(itemProcessor)),
|
|
15244
15242
|
parentItem: void 0
|
|
@@ -15311,7 +15309,7 @@ const adminService = (context) => ({
|
|
|
15311
15309
|
},
|
|
15312
15310
|
async purgeNavigationCache(documentId, clearLocalisations) {
|
|
15313
15311
|
const navigationRepository = getNavigationRepository(context);
|
|
15314
|
-
const entity = await navigationRepository.findOne({
|
|
15312
|
+
const entity = await navigationRepository.findOne({ filters: { documentId } });
|
|
15315
15313
|
if (!entity) {
|
|
15316
15314
|
throw new errors.NotFoundError("Navigation is not defined");
|
|
15317
15315
|
}
|
|
@@ -15319,7 +15317,7 @@ const adminService = (context) => ({
|
|
|
15319
15317
|
let regexps = [mapToRegExp(entity.documentId)];
|
|
15320
15318
|
if (clearLocalisations) {
|
|
15321
15319
|
const navigations = await navigationRepository.find({
|
|
15322
|
-
|
|
15320
|
+
filters: {
|
|
15323
15321
|
documentId: entity.documentId
|
|
15324
15322
|
}
|
|
15325
15323
|
});
|
|
@@ -15410,9 +15408,7 @@ const clientService = (context) => ({
|
|
|
15410
15408
|
async readAll({ locale: locale2, orderBy = "createdAt", orderDirection = "DESC" }) {
|
|
15411
15409
|
const repository = getNavigationRepository(context);
|
|
15412
15410
|
const navigations = repository.find({
|
|
15413
|
-
|
|
15414
|
-
localeCode: locale2
|
|
15415
|
-
} : {},
|
|
15411
|
+
locale: locale2,
|
|
15416
15412
|
orderBy: { [orderBy]: orderDirection }
|
|
15417
15413
|
});
|
|
15418
15414
|
return navigations;
|
|
@@ -15589,26 +15585,34 @@ const clientService = (context) => ({
|
|
|
15589
15585
|
};
|
|
15590
15586
|
const navigationRepository = getNavigationRepository(context);
|
|
15591
15587
|
const navigationItemRepository = getNavigationItemRepository(context);
|
|
15592
|
-
let navigation2
|
|
15593
|
-
|
|
15594
|
-
|
|
15595
|
-
|
|
15596
|
-
|
|
15597
|
-
|
|
15598
|
-
|
|
15599
|
-
|
|
15600
|
-
}
|
|
15588
|
+
let navigation2;
|
|
15589
|
+
if (locale2) {
|
|
15590
|
+
navigation2 = await navigationRepository.find({
|
|
15591
|
+
filters: {
|
|
15592
|
+
...entityWhereClause
|
|
15593
|
+
},
|
|
15594
|
+
locale: locale2,
|
|
15595
|
+
limit: 1
|
|
15601
15596
|
});
|
|
15597
|
+
} else {
|
|
15598
|
+
navigation2 = await navigationRepository.find({
|
|
15599
|
+
filters: entityWhereClause,
|
|
15600
|
+
limit: 1
|
|
15601
|
+
});
|
|
15602
|
+
}
|
|
15603
|
+
if (___default.isArray(navigation2)) {
|
|
15604
|
+
navigation2 = ___default.first(navigation2);
|
|
15602
15605
|
}
|
|
15603
15606
|
if (navigation2 && navigation2.documentId) {
|
|
15604
15607
|
const navigationItems = await navigationItemRepository.find({
|
|
15605
|
-
|
|
15608
|
+
filters: {
|
|
15606
15609
|
master: navigation2,
|
|
15607
15610
|
...itemCriteria
|
|
15608
15611
|
},
|
|
15612
|
+
locale: locale2,
|
|
15609
15613
|
limit: Number.MAX_SAFE_INTEGER,
|
|
15610
15614
|
order: [{ order: "asc" }],
|
|
15611
|
-
populate: ["
|
|
15615
|
+
populate: ["audience", "parent"]
|
|
15612
15616
|
});
|
|
15613
15617
|
const mappedItems = await commonService2.mapToNavigationItemDTO({
|
|
15614
15618
|
navigationItems,
|
|
@@ -15838,7 +15842,7 @@ const commonService = (context) => ({
|
|
|
15838
15842
|
documentId,
|
|
15839
15843
|
___default.isNil(populate2) ? config2.contentTypesPopulate[uid] || [] : parsePopulateQuery(populate2),
|
|
15840
15844
|
"published",
|
|
15841
|
-
{ locale: master?.
|
|
15845
|
+
{ locale: master?.locale }
|
|
15842
15846
|
);
|
|
15843
15847
|
if (relatedItem) {
|
|
15844
15848
|
entities.set(related, {
|
|
@@ -15935,7 +15939,7 @@ const commonService = (context) => ({
|
|
|
15935
15939
|
}) {
|
|
15936
15940
|
const navigationActions = [];
|
|
15937
15941
|
for (const navigationItem2 of navigationItems) {
|
|
15938
|
-
if (!navigationItem2.
|
|
15942
|
+
if (!navigationItem2.documentId) {
|
|
15939
15943
|
continue;
|
|
15940
15944
|
}
|
|
15941
15945
|
action.remove = true;
|
|
@@ -15961,14 +15965,16 @@ const commonService = (context) => ({
|
|
|
15961
15965
|
let navigationActions = [];
|
|
15962
15966
|
for (const navigationItem2 of navigationItems) {
|
|
15963
15967
|
action.create = true;
|
|
15964
|
-
const { parent, master, items, id, ...params } = navigationItem2;
|
|
15965
|
-
const insertDetails = id ? {
|
|
15968
|
+
const { parent, master, items, documentId, id, ...params } = navigationItem2;
|
|
15969
|
+
const insertDetails = documentId && id ? {
|
|
15966
15970
|
...params,
|
|
15971
|
+
documentId,
|
|
15967
15972
|
id,
|
|
15968
15973
|
master: masterEntity ? masterEntity.id : void 0,
|
|
15969
15974
|
parent: parentItem ? parentItem.id : void 0
|
|
15970
15975
|
} : {
|
|
15971
15976
|
...params,
|
|
15977
|
+
documentId: void 0,
|
|
15972
15978
|
id: void 0,
|
|
15973
15979
|
master: masterEntity ? masterEntity.id : void 0,
|
|
15974
15980
|
parent: parentItem ? parentItem.id : void 0
|
|
@@ -15997,11 +16003,11 @@ const commonService = (context) => ({
|
|
|
15997
16003
|
const result = [];
|
|
15998
16004
|
for (const updateDetails of navigationItems) {
|
|
15999
16005
|
action.update = true;
|
|
16000
|
-
const {
|
|
16006
|
+
const { documentId, updated, parent, master, items, ...params } = updateDetails;
|
|
16001
16007
|
let currentItem;
|
|
16002
16008
|
if (updated) {
|
|
16003
16009
|
currentItem = await getNavigationItemRepository(context).save({
|
|
16004
|
-
|
|
16010
|
+
documentId,
|
|
16005
16011
|
...params
|
|
16006
16012
|
});
|
|
16007
16013
|
} else {
|
|
@@ -16046,7 +16052,7 @@ const commonService = (context) => ({
|
|
|
16046
16052
|
const removedFieldsKeys = removedFields.map(({ name }) => `additionalFields.${name}`);
|
|
16047
16053
|
const removedFieldsNames = removedFields.map(({ name }) => name);
|
|
16048
16054
|
const navigationItems = await getNavigationItemRepository(context).find({
|
|
16049
|
-
|
|
16055
|
+
filters: {
|
|
16050
16056
|
additionalFields: {
|
|
16051
16057
|
$contains: [removedFieldsNames]
|
|
16052
16058
|
}
|
|
@@ -16130,7 +16136,7 @@ const migrationService = (context) => ({
|
|
|
16130
16136
|
async migrateRelatedIdToDocumentId() {
|
|
16131
16137
|
console.log("Navigation plugin :: Migrations :: Relared id to document id - START");
|
|
16132
16138
|
const navigationItemRepository = getNavigationItemRepository(context);
|
|
16133
|
-
const all = await navigationItemRepository.find({
|
|
16139
|
+
const all = await navigationItemRepository.find({ filters: {}, limit: Number.MAX_SAFE_INTEGER });
|
|
16134
16140
|
await Promise.all(
|
|
16135
16141
|
all.map(async (item) => {
|
|
16136
16142
|
if (item.related) {
|