The left rail is back to the three places you actually go — Garage, Charging, Settings — and user management moves inside Settings as an admin-only tab, next to a new Organization tab that used to be a card buried in the personal settings. Tab order is Personal settings, Users, Organization, Integrations. /admin redirects to /settings?tab=users so old links keep working, and ?tab= picks the starting tab in general. AdminUsers moves from views/ to components/ since it is a panel now, not a route, and its page header becomes a section header like its neighbours. The personal panel was split in two around the integrations markup, which left no gap between the Profile and Privacy cards; it is one block again. Creating a user gets an organization picker for superadmins, defaulting to "no organization" so an org-less account stays a deliberate choice. Admins see no picker: the server pins their members to their own org regardless, which users_test.go now covers along with both superadmin paths. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
35 lines
1.2 KiB
JavaScript
35 lines
1.2 KiB
JavaScript
import { createRouter, createWebHistory } from "vue-router";
|
|
import Dashboard from "./views/Dashboard.vue";
|
|
import CarDetail from "./views/CarDetail.vue";
|
|
import Charging from "./views/Charging.vue";
|
|
import Login from "./views/Login.vue";
|
|
import Settings from "./views/Settings.vue";
|
|
import { isAuthenticated } from "./auth";
|
|
|
|
const routes = [
|
|
{ path: "/login", name: "login", component: Login, meta: { public: true } },
|
|
{ path: "/", name: "dashboard", component: Dashboard },
|
|
{ path: "/charging", name: "charging", component: Charging },
|
|
{ path: "/cars/:id", name: "car", component: CarDetail, props: true },
|
|
{ path: "/settings", name: "settings", component: Settings },
|
|
// User management moved into Settings; keep old links working.
|
|
{ path: "/admin", redirect: { name: "settings", query: { tab: "users" } } },
|
|
];
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory(),
|
|
routes,
|
|
});
|
|
|
|
// Guard: protected routes require a token; visiting /login while authed bounces home.
|
|
router.beforeEach((to) => {
|
|
if (!to.meta.public && !isAuthenticated.value) {
|
|
return { name: "login", query: { redirect: to.fullPath } };
|
|
}
|
|
if (to.name === "login" && isAuthenticated.value) {
|
|
return { name: "dashboard" };
|
|
}
|
|
});
|
|
|
|
export default router;
|