refactor(web): rename Organisation to Instance
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
"use client";
|
||||
|
||||
import { createContext, useContext, useEffect, useState, ReactNode } from "react";
|
||||
import { auth, type Org, type Role, type SessionUser } from "@/lib/api";
|
||||
import { auth, type Instance, type Role, type SessionUser } from "@/lib/api";
|
||||
|
||||
export type { Org, Role, SessionUser };
|
||||
export type { Instance, Role, SessionUser };
|
||||
|
||||
interface AuthContextType {
|
||||
user: SessionUser | null;
|
||||
org: Org | null;
|
||||
/** True for owner and admin the roles the /api/settings and /api/org routes require. */
|
||||
instance: Instance | null;
|
||||
/** True for owner and admin the roles the /api/settings and /api/instance routes require. */
|
||||
isAdmin: boolean;
|
||||
}
|
||||
|
||||
const AuthContext = createContext<AuthContextType>({ user: null, org: null, isAdmin: false });
|
||||
const AuthContext = createContext<AuthContextType>({ user: null, instance: null, isAdmin: false });
|
||||
|
||||
export function useAuth() {
|
||||
return useContext(AuthContext);
|
||||
@@ -24,7 +24,7 @@ export function useAuth() {
|
||||
*/
|
||||
export function AuthProvider({ children }: { children: ReactNode }) {
|
||||
const [user, setUser] = useState<SessionUser | null>(null);
|
||||
const [org, setOrg] = useState<Org | null>(null);
|
||||
const [instance, setOrg] = useState<Instance | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
@@ -42,7 +42,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
||||
const me = await auth.me();
|
||||
if (cancelled) return;
|
||||
setUser(me.user);
|
||||
setOrg(me.org);
|
||||
setOrg(me.instance);
|
||||
setLoading(false);
|
||||
} catch (err) {
|
||||
if (cancelled) return;
|
||||
@@ -91,5 +91,5 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
||||
|
||||
const isAdmin = user.role === "owner" || user.role === "admin";
|
||||
|
||||
return <AuthContext.Provider value={{ user, org, isAdmin }}>{children}</AuthContext.Provider>;
|
||||
return <AuthContext.Provider value={{ user, instance, isAdmin }}>{children}</AuthContext.Provider>;
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ function StepsIcon() {
|
||||
);
|
||||
}
|
||||
|
||||
function OrgIcon() {
|
||||
function InstanceIcon() {
|
||||
return (
|
||||
<svg className="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={1.5}>
|
||||
<path
|
||||
@@ -128,13 +128,13 @@ const navItems: NavItem[] = [
|
||||
{ href: "/workflows", label: "Workflows", icon: <WorkflowIcon /> },
|
||||
{ href: "/steps", label: "Steps", icon: <StepsIcon /> },
|
||||
{ href: "/audit", label: "Audit Log", icon: <AuditIcon /> },
|
||||
{ href: "/settings/org", label: "Organization", icon: <OrgIcon />, adminOnly: true },
|
||||
{ href: "/settings/instance", label: "Instance", icon: <InstanceIcon />, adminOnly: true },
|
||||
{ href: "/settings", label: "Settings", icon: <SettingsIcon />, adminOnly: true },
|
||||
];
|
||||
|
||||
export function Sidebar() {
|
||||
const pathname = usePathname();
|
||||
const { user, org, isAdmin } = useAuth();
|
||||
const { user, instance, isAdmin } = useAuth();
|
||||
|
||||
const visibleItems = navItems.filter((item) => !item.adminOnly || isAdmin);
|
||||
|
||||
@@ -157,7 +157,7 @@ export function Sidebar() {
|
||||
<Logo className="h-8 w-8 text-text-primary" />
|
||||
<div className="min-w-0">
|
||||
<span className="block text-base font-semibold leading-tight text-text-primary">Vantage</span>
|
||||
{org && <span className="block truncate text-xs text-text-secondary">{org.name}</span>}
|
||||
{instance && <span className="block truncate text-xs text-text-secondary">{instance.name}</span>}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
{loading && (
|
||||
<svg
|
||||
className="animate-spin h-4 w-4"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.instance/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user