Skip to content

Commit e592b4b

Browse files
committed
Merge branch 'next' of github.com:devforth/adminforth into next
2 parents 80d01b2 + f351678 commit e592b4b

6 files changed

Lines changed: 91 additions & 8 deletions

File tree

Taskfile.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
version: '3'
2+
3+
tasks:
4+
update-adminforth-version:
5+
desc: "Update adminforth peer/dev dependency version in all plugins and adapters"
6+
vars:
7+
VERSION: '{{.VERSION | default ""}}'
8+
preconditions:
9+
- sh: '[ -n "{{.VERSION}}" ]'
10+
msg: "VERSION is required. Run: task update-adminforth-version VERSION=1.2.3"
11+
cmds:
12+
- |
13+
for dir in plugins/*/ adapters/*/; do
14+
pkg="$dir/package.json"
15+
[ -f "$pkg" ] || continue
16+
node -e "
17+
const fs = require('fs');
18+
const p = JSON.parse(fs.readFileSync('$pkg'));
19+
let changed = false;
20+
if (p.peerDependencies?.adminforth) { p.peerDependencies.adminforth = '^{{.VERSION}}'; changed = true; }
21+
if (p.devDependencies?.adminforth) { p.devDependencies.adminforth = '^{{.VERSION}}'; changed = true; }
22+
if (changed) {
23+
fs.writeFileSync('$pkg', JSON.stringify(p, null, 2) + '\n');
24+
console.log('updated: $pkg');
25+
}
26+
"
27+
done

adminforth/spa/src/components/MenuLink.vue

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
<template>
2-
<RouterLink
3-
:to="item.url || { name: item.resourceId ? 'resource-list' : item.path, params: item.resourceId ? { resourceId: item.resourceId }: {}}"
2+
<component
3+
:is="isExternalUrl(item.url) ? 'a' : RouterLink"
4+
v-bind="isExternalUrl(item.url)
5+
? { href: item.url }
6+
: { to: item.url || { name: item.resourceId ? 'resource-list' : item.path, params: item.resourceId ? { resourceId: item.resourceId }: {} } }"
47
:target="item.isOpenInNewTab ? '_blank' : '_self'"
5-
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"
6-
:class="{
8+
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"
9+
:class="{
710
'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),
811
'pl-6 pr-3.5': (isChild && !isSidebarIconOnly && !isSidebarHovering) || (isChild && isSidebarIconOnly && isSidebarHovering),
912
'px-3.5 ': !isChild || (isSidebarIconOnly && !isSidebarHovering),
@@ -51,7 +54,7 @@
5154
<div v-if="(item.badge || item.badge === 0) && isSidebarIconOnly && !isSidebarHovering" class="af-badge absolute right-0.5 bottom-1 -translate-y-1/2 inline-flex items-center justify-center h-2 w-2 text-sm font-medium rounded-full bg-lightAnnouncementBG dark:bg-darkAnnouncementBG
5255
fill-lightAnnouncementText dark:fill-darkAccent text-lightAnnouncementText dark:text-darkAccent">
5356
</div>
54-
</RouterLink>
57+
</component>
5558
</template>
5659

5760
<script setup lang="ts">
@@ -60,13 +63,15 @@ import { Tooltip } from '@/afcl';
6063
import { ref, watch, computed } from 'vue';
6164
import { useCoreStore } from '@/stores/core';
6265
import { IconFileImageOutline } from '@iconify-prerendered/vue-flowbite';
63-
import { useRoute } from 'vue-router';
66+
import { useRoute, RouterLink } from 'vue-router';
67+
68+
const isExternalUrl = (url: string ) => /^https?:\/\//.test(url || '');
6469
6570
const route = useRoute();
6671
6772
const isItemActive = (item: any) => {
6873
if (item.url) {
69-
return route.fullPath === item.url;
74+
return !isExternalUrl(item.url) && route.fullPath === item.url;
7075
}
7176
7277
if (item.resourceId) {

adminforth/types/Common.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,23 @@ export interface AdminForthConfigMenuItem {
11771177
* Item id will be automatically generated from hashed resourceId+Path+label
11781178
*/
11791179
itemId?: string, // todo move to runtime type
1180+
1181+
1182+
/**
1183+
* If set, menu item will be rendered as external link with this URL. Supported for AdminForthMenuTypes.PAGE and AdminForthMenuTypes.RESOURCE only!
1184+
* If URL starts with `http://` or `https://`, it will be treated as absolute URL. Otherwise, it will be treated as relative to admin panel base URL.
1185+
* Example of absolute URL:
1186+
*
1187+
* ```ts
1188+
* url: 'https://google.com',
1189+
* ```
1190+
*
1191+
* Example of relative URL:
1192+
*
1193+
* ```ts
1194+
* url: '/custom-page',
1195+
* ```
1196+
*/
11801197

11811198
url?: string
11821199

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- AlterTable
2+
ALTER TABLE "translations" ADD COLUMN "listed" BOOLEAN;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
Warnings:
3+
4+
- You are about to drop the column `listed` on the `translations` table. All the data in the column will be lost.
5+
6+
*/
7+
-- AlterTable
8+
ALTER TABLE "adminuser" ADD COLUMN "cars" TEXT;
9+
10+
-- RedefineTables
11+
PRAGMA defer_foreign_keys=ON;
12+
PRAGMA foreign_keys=OFF;
13+
CREATE TABLE "new_translations" (
14+
"id" TEXT NOT NULL PRIMARY KEY,
15+
"en_string" TEXT NOT NULL,
16+
"created_at" DATETIME NOT NULL,
17+
"uk_string" TEXT,
18+
"ja_string" TEXT,
19+
"fr_string" TEXT,
20+
"es_string" TEXT,
21+
"ptBR_string" TEXT,
22+
"category" TEXT NOT NULL,
23+
"source" TEXT,
24+
"completedLangs" TEXT
25+
);
26+
INSERT INTO "new_translations" ("category", "completedLangs", "created_at", "en_string", "es_string", "fr_string", "id", "ja_string", "ptBR_string", "source", "uk_string") SELECT "category", "completedLangs", "created_at", "en_string", "es_string", "fr_string", "id", "ja_string", "ptBR_string", "source", "uk_string" FROM "translations";
27+
DROP TABLE "translations";
28+
ALTER TABLE "new_translations" RENAME TO "translations";
29+
CREATE INDEX "translations_en_string_category_idx" ON "translations"("en_string", "category");
30+
CREATE INDEX "translations_category_idx" ON "translations"("category");
31+
CREATE INDEX "translations_completedLangs_idx" ON "translations"("completedLangs");
32+
PRAGMA foreign_keys=ON;
33+
PRAGMA defer_foreign_keys=OFF;

dev-demo/resources/adminuser.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import AdminForthAdapterGoogleOauth2 from '../../adapters/adminforth-oauth-adapt
1010
import OpenSignupPlugin from '../../plugins/adminforth-open-signup/index.js';
1111
import OAuthPlugin from '../../plugins/adminforth-oauth/index.js';
1212
import KeyValueAdapterRam from '../../adapters/adminforth-key-value-adapter-ram/index.js';
13-
import AdminForthAgent from '../../plugins/adminforth-agent/index.js';
1413
import CompletionAdapterOpenAIChatGPT from '../../adapters/adminforth-completion-adapter-open-ai-chat-gpt/index.js';
1514

1615
async function allowedForSuperAdmin({ adminUser }: { adminUser: AdminUser }): Promise<boolean> {

0 commit comments

Comments
 (0)