strapi-plugin-cm-subnav-stacker 0.0.3 → 1.0.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 +0 -15
- package/dist/admin/index.js +13 -5
- package/dist/admin/index.mjs +13 -5
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -76,21 +76,6 @@ GroupName | ItemName
|
|
|
76
76
|
|
|
77
77
|
These will be automatically grouped under "Blog" and "Product" respectively.
|
|
78
78
|
|
|
79
|
-
#### Ordering
|
|
80
|
-
|
|
81
|
-
To control the order of items within a group, prefix the title with `[<number>]`:
|
|
82
|
-
|
|
83
|
-
```
|
|
84
|
-
GroupName | [<number>] ItemName
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
**Examples:**
|
|
88
|
-
- `[1] Blog | Category`
|
|
89
|
-
- `[2] Blog | Post`
|
|
90
|
-
- `[3] Blog | Tag`
|
|
91
|
-
|
|
92
|
-
Items will be sorted numerically based on the number prefix within each group.
|
|
93
|
-
|
|
94
79
|
## Environment Variables
|
|
95
80
|
|
|
96
81
|
You can configure the plugin using environment variables in your `.env` file:
|
package/dist/admin/index.js
CHANGED
|
@@ -64,7 +64,9 @@ const getPluginConfig = async () => {
|
|
|
64
64
|
const formatContentTypes = (delimiter, data) => {
|
|
65
65
|
if (!data || !data.data) return [];
|
|
66
66
|
const defaultSortOrder = data.data.length + 1e3;
|
|
67
|
-
return data.data.filter((ct) =>
|
|
67
|
+
return data.data.filter((ct) => {
|
|
68
|
+
return ct.uid.startsWith("api::") || ct.uid.startsWith("plugin::");
|
|
69
|
+
}).map((ct) => {
|
|
68
70
|
const displayName = ct.schema.displayName || ct.apiID;
|
|
69
71
|
const kind = ct.schema.kind;
|
|
70
72
|
const { sortOrder, cleanDisplayName } = extractSortOrder(displayName, defaultSortOrder);
|
|
@@ -530,6 +532,7 @@ const NavigationApp = () => {
|
|
|
530
532
|
try {
|
|
531
533
|
const { get } = admin.getFetchClient();
|
|
532
534
|
const { data } = await get("/admin/users/me/permissions");
|
|
535
|
+
console.log(data);
|
|
533
536
|
const list = Array.isArray(data) ? data : data?.data ?? data?.permissions ?? [];
|
|
534
537
|
window.strapiPermissions = list;
|
|
535
538
|
console.log("Successfully fetched permissions:", list.length);
|
|
@@ -560,11 +563,16 @@ const NavigationApp = () => {
|
|
|
560
563
|
console.log("Permissions:", permissions.length);
|
|
561
564
|
let allowedContentTypes;
|
|
562
565
|
if (permissions.length > 0) {
|
|
563
|
-
allowedContentTypes = contentTypes.filter(
|
|
564
|
-
|
|
566
|
+
allowedContentTypes = contentTypes.filter((ct) => {
|
|
567
|
+
const hasContentManagerRead = permissions.some(
|
|
565
568
|
(p) => p.action === "plugin::content-manager.explorer.read" && p.subject === ct.uid
|
|
566
|
-
)
|
|
567
|
-
|
|
569
|
+
);
|
|
570
|
+
const isPluginContentType = ct.uid.startsWith("plugin::");
|
|
571
|
+
const hasPluginRead = isPluginContentType && permissions.some(
|
|
572
|
+
(p) => p.subject === ct.uid && (p.action?.includes("read") || p.action?.includes("find") || p.action === "plugin::content-manager.explorer.read")
|
|
573
|
+
);
|
|
574
|
+
return hasContentManagerRead || hasPluginRead;
|
|
575
|
+
});
|
|
568
576
|
console.log("Allowed content types after permission filter:", allowedContentTypes.length, allowedContentTypes);
|
|
569
577
|
} else {
|
|
570
578
|
console.warn("No permissions available, showing all content types as fallback");
|
package/dist/admin/index.mjs
CHANGED
|
@@ -45,7 +45,9 @@ const getPluginConfig = async () => {
|
|
|
45
45
|
const formatContentTypes = (delimiter, data) => {
|
|
46
46
|
if (!data || !data.data) return [];
|
|
47
47
|
const defaultSortOrder = data.data.length + 1e3;
|
|
48
|
-
return data.data.filter((ct) =>
|
|
48
|
+
return data.data.filter((ct) => {
|
|
49
|
+
return ct.uid.startsWith("api::") || ct.uid.startsWith("plugin::");
|
|
50
|
+
}).map((ct) => {
|
|
49
51
|
const displayName = ct.schema.displayName || ct.apiID;
|
|
50
52
|
const kind = ct.schema.kind;
|
|
51
53
|
const { sortOrder, cleanDisplayName } = extractSortOrder(displayName, defaultSortOrder);
|
|
@@ -511,6 +513,7 @@ const NavigationApp = () => {
|
|
|
511
513
|
try {
|
|
512
514
|
const { get } = getFetchClient();
|
|
513
515
|
const { data } = await get("/admin/users/me/permissions");
|
|
516
|
+
console.log(data);
|
|
514
517
|
const list = Array.isArray(data) ? data : data?.data ?? data?.permissions ?? [];
|
|
515
518
|
window.strapiPermissions = list;
|
|
516
519
|
console.log("Successfully fetched permissions:", list.length);
|
|
@@ -541,11 +544,16 @@ const NavigationApp = () => {
|
|
|
541
544
|
console.log("Permissions:", permissions.length);
|
|
542
545
|
let allowedContentTypes;
|
|
543
546
|
if (permissions.length > 0) {
|
|
544
|
-
allowedContentTypes = contentTypes.filter(
|
|
545
|
-
|
|
547
|
+
allowedContentTypes = contentTypes.filter((ct) => {
|
|
548
|
+
const hasContentManagerRead = permissions.some(
|
|
546
549
|
(p) => p.action === "plugin::content-manager.explorer.read" && p.subject === ct.uid
|
|
547
|
-
)
|
|
548
|
-
|
|
550
|
+
);
|
|
551
|
+
const isPluginContentType = ct.uid.startsWith("plugin::");
|
|
552
|
+
const hasPluginRead = isPluginContentType && permissions.some(
|
|
553
|
+
(p) => p.subject === ct.uid && (p.action?.includes("read") || p.action?.includes("find") || p.action === "plugin::content-manager.explorer.read")
|
|
554
|
+
);
|
|
555
|
+
return hasContentManagerRead || hasPluginRead;
|
|
556
|
+
});
|
|
549
557
|
console.log("Allowed content types after permission filter:", allowedContentTypes.length, allowedContentTypes);
|
|
550
558
|
} else {
|
|
551
559
|
console.warn("No permissions available, showing all content types as fallback");
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0
|
|
2
|
+
"version": "1.0.0",
|
|
3
3
|
"keywords": [],
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"exports": {
|
|
@@ -83,5 +83,6 @@
|
|
|
83
83
|
"url": "https://github.com/patiparnne/strapi-plugin-cm-subnav-stacker/issues"
|
|
84
84
|
},
|
|
85
85
|
"homepage": "https://github.com/patiparnne/strapi-plugin-cm-subnav-stacker#readme",
|
|
86
|
+
"buy_me_a_coffee": "patiparnne",
|
|
86
87
|
"author": "Patiparnne <partyparti@gmail.com>"
|
|
87
88
|
}
|