Skip to content

Commit ceab266

Browse files
committed
Merge branch 'next' of github.com:devforth/adminforth into next
2 parents d9ca7c1 + 5dc8293 commit ceab266

File tree

6 files changed

+45
-9
lines changed

6 files changed

+45
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,4 @@ This will always run latest version of adminforth package.
136136

137137
## Star History
138138

139-
[![Star History Chart](https://api.star-history.com/svg?repos=adminforth/adminforth&type=date&legend=top-left)](https://www.star-history.com/#adminforth/adminforth&type=date&legend=top-left)
139+
[![Star History Chart](https://api.star-history.com/svg?repos=devforth/adminforth&type=date&legend=top-left)](https://www.star-history.com/#devforth/adminforth&type=date&legend=top-left)

adminforth/documentation/docs/tutorial/03-Customization/10-menuConfiguration.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,23 @@ auth: {
278278
This syntax can be use to get unique avatar for each user of hardcode avatar, but it makes more sense to use it with [upload plugin](https://adminforth.dev/docs/tutorial/Plugins/upload/#using-plugin-for-uploading-avatar)
279279

280280

281+
## Custom URL
282+
You can use the url property to override default navigation. This is useful for linking to pre-filtered lists or external sites.
283+
284+
285+
```ts title='./index.ts'
286+
287+
menu: [
288+
{
289+
label: 'Posts',
290+
icon: 'flowbite:book-open-outline',
291+
resourceId: 'posts',
292+
//diff-add
293+
url: '/resource/aparts?filter__country__in=["DE"]',
294+
//diff-add
295+
isOpenInNewTab: true // You can also add isOpenInNewTab: true to open the link in a new browser tab
296+
},
297+
],
298+
299+
```
300+
> 👆 Please note start internal URLs with a leading / to ensure correct routing.

adminforth/modules/codeInjector.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ class CodeInjector implements ICodeInjector {
946946

947947
// 🚫 Skip big files or files which might be dynamic
948948
if (file.name === 'node_modules' || file.name === 'dist' ||
949-
file.name === 'i18n-messages.json' || file.name === 'i18n-empty.json') {
949+
file.name === 'i18n-messages.json' || file.name === 'i18n-empty.json' || file.name === 'hashes.json') {
950950
return '';
951951
}
952952

@@ -1037,7 +1037,7 @@ class CodeInjector implements ICodeInjector {
10371037

10381038
const buildHash = await this.tryReadFile(path.join(serveDir, '.adminforth_build_hash'));
10391039
const messagesHash = await this.tryReadFile(path.join(serveDir, '.adminforth_messages_hash'));
1040-
console.log({buildHash, sourcesHash});
1040+
10411041
const skipBuild = buildHash === sourcesHash;
10421042
const skipExtract = messagesHash === sourcesHash;
10431043

@@ -1072,7 +1072,7 @@ class CodeInjector implements ICodeInjector {
10721072

10731073
if (!hotReload) {
10741074
if (!skipBuild) {
1075-
console.log(`🪲 Build cache miss, building SPA...`);
1075+
console.log(`🪲 Build cache miss or outdated, building SPA...`);
10761076
let oldHashForFiles = null;
10771077
try {
10781078
oldHashForFiles = await fs.promises.readFile(path.join(this.spaTmpPath(), 'hashes.json'), 'utf-8');

adminforth/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"build": "rm -rf dist && tsc && pnpm prepareDist",
1919
"--comment-prepareDist": "-rl allows supply the spa without symlinks which allows to not include source code in the package",
2020
"prepareDist": "cp -rL spa dist/",
21-
"rollout-doc": "cd documentation && pnpm build && pnpm run deploy",
21+
"rollout-doc": "cd documentation && npm run build && npm run deploy",
2222
"docs": "typedoc",
2323
"--comment_postinstall": "postinstall executed after package installed in other project package and when we do pnpm i in the package",
2424
"postinstall": "node scripts/postinstall.js"

adminforth/spa/src/components/MenuLink.vue

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
<template>
22
<RouterLink
3-
:to="{name: item.resourceId ? 'resource-list' : item.path, params: item.resourceId ? { resourceId: item.resourceId }: {}}"
3+
:to="item.url || { name: item.resourceId ? 'resource-list' : item.path, params: item.resourceId ? { resourceId: item.resourceId }: {}}"
4+
:target="item.isOpenInNewTab ? '_blank' : '_self'"
45
class="af-menu-link flex group relative items-center w-full py-2 text-lightSidebarText dark:text-darkSidebarText rounded-default transition-all duration-200 ease-in-out"
56
:class="{
67
'hover:bg-lightSidebarItemHover hover:text-lightSidebarTextHover dark:hover:bg-darkSidebarItemHover dark:hover:text-darkSidebarTextHover active:bg-lightSidebarActive dark:active:bg-darkSidebarHover': !['divider', 'gap', 'heading'].includes(item.type),
78
'pl-6 pr-3.5': (isChild && !isSidebarIconOnly && !isSidebarHovering) || (isChild && isSidebarIconOnly && isSidebarHovering),
89
'px-3.5 ': !isChild || (isSidebarIconOnly && !isSidebarHovering),
910
'max-w-12': isSidebarIconOnly && !isSidebarHovering,
10-
'bg-lightSidebarItemActive dark:bg-darkSidebarItemActive': item.resourceId ?
11-
($route.params.resourceId === item.resourceId && $route.name === 'resource-list') :
12-
($route.name === item.path)
11+
'bg-lightSidebarItemActive dark:bg-darkSidebarItemActive': isItemActive(item)
1312
}"
1413
>
1514
<component v-if="item.icon" :is="getIcon(item.icon)"
@@ -61,6 +60,21 @@ import { Tooltip } from '@/afcl';
6160
import { ref, watch, computed } from 'vue';
6261
import { useCoreStore } from '@/stores/core';
6362
import { IconFileImageOutline } from '@iconify-prerendered/vue-flowbite';
63+
import { useRoute } from 'vue-router';
64+
65+
const route = useRoute();
66+
67+
const isItemActive = (item: any) => {
68+
if (item.url) {
69+
return route.fullPath === item.url;
70+
}
71+
72+
if (item.resourceId) {
73+
return route.params.resourceId === item.resourceId && route.name === 'resource-list';
74+
}
75+
76+
return route.name === item.path;
77+
};
6478
6579
const props = defineProps(['item', 'isChild', 'isSidebarIconOnly', 'isSidebarHovering']);
6680

adminforth/types/Common.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,8 @@ export interface AdminForthConfigMenuItem {
11221122
* Item id will be automatically generated from hashed resourceId+Path+label
11231123
*/
11241124
itemId?: string, // todo move to runtime type
1125+
1126+
url?: string
11251127
}
11261128

11271129

0 commit comments

Comments
 (0)