adminforth 1.2.89 → 1.2.91

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.
@@ -158,11 +158,14 @@ export default class AdminForthRestAPI {
158
158
  }
159
159
  };
160
160
  function processMenuItem(menuItem) {
161
- if (menuItem.badge) {
162
- if (typeof menuItem.badge === 'function') {
163
- menuItem.badge = menuItem.badge(adminUser);
161
+ return __awaiter(this, void 0, void 0, function* () {
162
+ if (menuItem.badge) {
163
+ // if it is promise, wait for it
164
+ if (menuItem.badge && menuItem.badge.then || typeof menuItem.badge === 'function') {
165
+ menuItem.badge = yield menuItem.badge(adminUser);
166
+ }
164
167
  }
165
- }
168
+ });
166
169
  }
167
170
  let newMenu = [];
168
171
  for (let menuItem of this.adminforth.config.menu) {
@@ -187,10 +187,11 @@ export default class AdminForthRestAPI {
187
187
 
188
188
  }
189
189
 
190
- function processMenuItem(menuItem) {
190
+ async function processMenuItem(menuItem) {
191
191
  if (menuItem.badge) {
192
- if (typeof menuItem.badge === 'function') {
193
- menuItem.badge = menuItem.badge(adminUser);
192
+ // if it is promise, wait for it
193
+ if (menuItem.badge && menuItem.badge.then || typeof menuItem.badge === 'function') {
194
+ menuItem.badge = await menuItem.badge(adminUser);
194
195
  }
195
196
  }
196
197
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "1.2.89",
3
+ "version": "1.2.91",
4
4
  "description": "OpenSource Vue3 powered forth-generation admin panel",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/spa/src/App.vue CHANGED
@@ -84,9 +84,15 @@
84
84
  :aria-controls="`dropdown-example${i}`"
85
85
  :data-collapse-toggle="`dropdown-example${i}`"
86
86
  >
87
+
87
88
  <component v-if="item.icon" :is="getIcon(item.icon)" class="w-5 h-5 text-lightSidebarIcons group-hover:text-lightSidebarIconsHover transition duration-75 dark:group-hover:text-darkSidebarIconsHover dark:text-darkSidebarIcons" ></component>
88
89
 
89
- <span class="flex-1 ms-3 text-left rtl:text-right whitespace-nowrap">{{ item.label }}</span>
90
+ <span class="flex-1 ms-3 text-left rtl:text-right whitespace-nowrap">{{ item.label }}
91
+
92
+ <span v-if="item.badge" class="inline-flex items-center justify-center w-3 h-3 p-3 ms-3 text-sm font-medium rounded-full bg-lightAnnouncementBG dark:bg-darkAnnouncementBG
93
+ fill-lightAnnouncementText dark:fill-darkAccent text-lightAnnouncementText dark:text-darkAccent">{{ item.badge }}</span>
94
+ </span>
95
+
90
96
  <svg :class="{'rotate-180': opened.includes(i) }" class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 6">
91
97
  <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 4 4 4-4"/>
92
98
  </svg>
@@ -95,12 +101,12 @@
95
101
  <ul :id="`dropdown-example${i}`" role="none" class="pt-1 space-y-1" :class="{ 'hidden': !opened.includes(i) }">
96
102
  <template v-for="(child, j) in item.children" :key="`menu-${i}-${j}`">
97
103
  <li>
98
- <MenuLink :item="child" isChild="true" />
99
- </li>
104
+ <MenuLink :item="child" isChild="true" />
105
+ </li>
100
106
  </template>
101
- </ul>
102
- </li>
103
- <li v-else>
107
+ </ul>
108
+ </li>
109
+ <li v-else>
104
110
  <MenuLink :item="item" />
105
111
  </li>
106
112
  </template>
@@ -474,7 +474,7 @@ export type AdminForthConfigMenuItem = {
474
474
  * Optional callback which will be called before rendering the menu for each item.
475
475
  * Result of callback if not null will be used as a small badge near the menu item.
476
476
  */
477
- badge?: string | ((user: AdminUser) => string),
477
+ badge?: string | ((user: AdminUser) => Promise<string>),
478
478
  }
479
479
 
480
480