@urga-panel/ur-panels-core 1.0.18 → 1.0.19

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.
@@ -38,7 +38,7 @@ export declare abstract class ProjectInfoService extends Service {
38
38
  getMenuPages(userGroup?: string): {
39
39
  [key: string]: ProjectsPages[string];
40
40
  };
41
- getMobilePages(limit?: number): {
41
+ getMobilePages(userGroup?: string, limit?: number): {
42
42
  [key: string]: ProjectsPages[string];
43
43
  };
44
44
  }
@@ -65,13 +65,30 @@ export class ProjectInfoService extends Service {
65
65
  });
66
66
  return result;
67
67
  }
68
- getMobilePages(limit = 4) {
68
+ getMobilePages(userGroup, limit = 4) {
69
69
  const result = {};
70
70
  let count = 0;
71
71
  for (const [key, page] of Object.entries(this.pages)) {
72
72
  if (page.showInMobile) {
73
- result[key] = page;
74
- count++;
73
+ // Apply the same group access control logic as getMenuPages
74
+ if (userGroup && userGroup == 'admin') {
75
+ // If onlyForGroup is true, admin cannot see this page
76
+ if (page.onlyForGroup !== true) {
77
+ result[key] = page;
78
+ count++;
79
+ }
80
+ }
81
+ else if (userGroup) {
82
+ // Check if the page is accessible by the user group
83
+ if (page.userGroup === userGroup) {
84
+ result[key] = page;
85
+ count++;
86
+ }
87
+ }
88
+ else {
89
+ result[key] = page;
90
+ count++;
91
+ }
75
92
  if (count >= limit)
76
93
  break;
77
94
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@urga-panel/ur-panels-core",
3
- "version": "1.0.18",
3
+ "version": "1.0.19",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -107,13 +107,28 @@ export abstract class ProjectInfoService extends Service {
107
107
  return result;
108
108
  }
109
109
 
110
- getMobilePages(limit: number = 4): { [key: string]: ProjectsPages[string] } {
110
+ getMobilePages(userGroup?: string, limit: number = 4): { [key: string]: ProjectsPages[string] } {
111
111
  const result: { [key: string]: ProjectsPages[string] } = {};
112
112
  let count = 0;
113
113
  for (const [key, page] of Object.entries(this.pages)) {
114
114
  if (page.showInMobile) {
115
- result[key] = page;
116
- count++;
115
+ // Apply the same group access control logic as getMenuPages
116
+ if (userGroup && userGroup == 'admin') {
117
+ // If onlyForGroup is true, admin cannot see this page
118
+ if (page.onlyForGroup !== true) {
119
+ result[key] = page;
120
+ count++;
121
+ }
122
+ } else if (userGroup) {
123
+ // Check if the page is accessible by the user group
124
+ if (page.userGroup === userGroup) {
125
+ result[key] = page;
126
+ count++;
127
+ }
128
+ } else {
129
+ result[key] = page;
130
+ count++;
131
+ }
117
132
  if (count >= limit) break;
118
133
  }
119
134
  }