Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

feat(webv2): move user management to home screen

joshistoastf72e11666fac
diff --git a/invokeai/frontend/webv2/src/router.tsx b/invokeai/frontend/webv2/src/router.tsx
index 8447683dd7..90cef57060 100644
--- a/invokeai/frontend/webv2/src/router.tsx
+++ b/invokeai/frontend/webv2/src/router.tsx
@@ -63,6 +63,18 @@ const homeRoute = createRoute({
path: '/',
});
+const projectsHomeRoute = createRoute({
+ component: HomeScreen,
+ getParentRoute: () => authenticatedRoute,
+ path: 'projects',
+});
+
+const usersHomeRoute = createRoute({
+ component: HomeScreen,
+ getParentRoute: () => authenticatedRoute,
+ path: 'users',
+});
+
const workbenchRoute = createRoute({
beforeLoad: async ({ cause, search }) => {
// Photoshop semantics: the editor without documents is Home. A definite
@@ -135,7 +147,7 @@ export const router = createRouter({
defaultPreload: 'intent',
history: createHashHistory(),
routeTree: rootRoute.addChildren([
- authenticatedRoute.addChildren([homeRoute, workbenchRoute]),
+ authenticatedRoute.addChildren([homeRoute, projectsHomeRoute, usersHomeRoute, workbenchRoute]),
loginRoute,
setupRoute,
]),
diff --git a/invokeai/frontend/webv2/src/workbench/auth/components/AccountMenu.tsx b/invokeai/frontend/webv2/src/workbench/auth/components/AccountMenu.tsx
index ec377df8ec..a9864531b6 100644
--- a/invokeai/frontend/webv2/src/workbench/auth/components/AccountMenu.tsx
+++ b/invokeai/frontend/webv2/src/workbench/auth/components/AccountMenu.tsx
@@ -28,13 +28,11 @@ export const AccountMenu = () => {
const label = user.display_name?.trim() || user.email;
const openUserManagement = () => {
- const activeProject = workbench?.activeProject;
-
- if (!activeProject || !workbench) {
+ if (!workbench?.activeProject) {
return;
}
- const centerRegion = activeProject.widgetRegions.center;
+ const centerRegion = workbench.activeProject.widgetRegions.center;
if (centerRegion.enabledWidgetIds.includes('users')) {
workbench.dispatch({ region: 'center', type: 'selectRegionWidget', widgetId: 'users' });
diff --git a/invokeai/frontend/webv2/src/workbench/home/HomeScreen.tsx b/invokeai/frontend/webv2/src/workbench/home/HomeScreen.tsx
index 4d681db3cb..16030fd9c3 100644
--- a/invokeai/frontend/webv2/src/workbench/home/HomeScreen.tsx
+++ b/invokeai/frontend/webv2/src/workbench/home/HomeScreen.tsx
@@ -1,8 +1,8 @@
import type { SystemStyleObject } from '@chakra-ui/react';
-import { Box, Flex, Heading, HStack, Stack, Text } from '@chakra-ui/react';
-import { Link, useNavigate } from '@tanstack/react-router';
-import { useEffect } from 'react';
-import { FileUpIcon, PlusIcon } from 'lucide-react';
+import { Box, Flex, Heading, HStack, Icon, Stack, Tabs, Text } from '@chakra-ui/react';
+import { Link, useLocation, useNavigate } from '@tanstack/react-router';
+import { useEffect, type ReactNode } from 'react';
+import { FileUpIcon, FolderIcon, PlusIcon, UsersIcon, type LucideIcon } from 'lucide-react';
import { Button } from '../components/ui/Button';
import { HomeTopBar } from './HomeTopBar';
@@ -12,6 +12,7 @@ import { toaster } from '../components/ui/toaster';
import { refreshProjectLibrary } from '../projects/library';
import { useAuthSession } from '../auth/session';
import { importProjectFile, pickProjectFile } from '../projects/projectFile';
+import { UsersManagementPanel } from '../users';
const HOME_SCREEN_CONTENT_WRAPPER_SX: SystemStyleObject = {
flex: 1,
@@ -21,12 +22,51 @@ const HOME_SCREEN_CONTENT_WRAPPER_SX: SystemStyleObject = {
w: 'full',
};
+type HomeTabId = 'projects' | 'users';
+
+interface HomeTabDefinition {
+ id: HomeTabId;
+ label: string;
+ icon: LucideIcon;
+ children: ReactNode;
+ condition?: boolean;
+}
+
+const DEFAULT_HOME_TAB_ID: HomeTabId = 'projects';
+
+const isHomeTabId = (value: string): value is HomeTabId => value === 'projects' || value === 'users';
+
+const normalizeHomeTabId = (value: string): HomeTabId | null => {
+ const id = value.replace(/^\/+/, '');
+
+ return isHomeTabId(id) ? id : null;
+};
+
+const getRequestedHomeTabId = (pathname: string, hash: string): HomeTabId | null =>
+ normalizeHomeTabId(pathname) ?? normalizeHomeTabId(hash);
+
+const getActiveHomeTabId = (tabs: HomeTabDefinition[], requestedTabId: HomeTabId | null): HomeTabId =>
+ requestedTabId && tabs.some((tab) => tab.id === requestedTabId) ? requestedTabId : DEFAULT_HOME_TAB_ID;
+
+const replaceHomeTabHash = (tabId: HomeTabId): void => {
+ window.history.replaceState(
+ window.history.state,
+ '',
+ `${window.location.pathname}${window.location.search}#${tabId}`
+ );
+};
+
+const pushHomeTabHash = (tabId: HomeTabId): void => {
+ if (window.location.hash !== `#${tabId}`) {
+ window.location.hash = tabId;
+ }
+};
+
/**
- * The landing surface at `/`: your project library, profile, and pointers to
- * docs and community — the editor equivalent of Photoshop's home screen. It
- * deliberately mounts none of the workbench providers or runtimes, so it
- * stays on the light side of the route-level code split; everything here
- * works against the library store and the auth session alone.
+ * The landing surface at `/`: your project library, profile/admin controls,
+ * and pointers to docs and community — the editor equivalent of Photoshop's
+ * home screen. It deliberately mounts none of the workbench providers or
+ * runtimes, so it stays on the light side of the route-level code split.
*/
export const HomeScreen = () => {
const session = useAuthSession();
@@ -38,6 +78,7 @@ export const HomeScreen = () => {
const displayName = session.user?.display_name?.trim();
const greeting = displayName ? `Welcome back, ${displayName}` : 'Welcome to Invoke';
+ const canManageUsers = session.multiuserEnabled && session.user?.is_admin === true;
const handleImport = async () => {
const file = await pickProjectFile();
@@ -59,41 +100,114 @@ export const HomeScreen = () => {
}
};
+ const allTabs: HomeTabDefinition[] = [
+ {
+ label: 'Projects',
+ icon: FolderIcon,
+ id: 'projects',
+ children: <ProjectsPanel greeting={greeting} onImport={handleImport} />,
+ },
+ {
+ label: 'Manage Users',
+ icon: UsersIcon,
+ id: 'users',
+ children: <UsersPanel />,
+ condition: canManageUsers,
+ },
+ ];
+ const tabs = allTabs.filter((tab) => tab.condition ?? true);
+
return (
<Flex bg="bg" color="fg" direction="column" minH="100dvh">
<HomeTopBar />
<Box css={HOME_SCREEN_CONTENT_WRAPPER_SX}>
- <Flex direction={{ base: 'column', md: 'row' }} gap={{ base: '8', md: '10' }}>
- <Stack flex="1" gap="5" minW="0">
- <Flex align="center" gap="3" justify="space-between" wrap="wrap">
- <Stack gap="0.5">
- <Heading fontSize="xl" fontWeight="700">
- {greeting}
- </Heading>
- <Text color="fg.muted" fontSize="xs">
- Pick up where you left off, or start something new.
- </Text>
- </Stack>
- <HStack gap="2">
- <Button size="xs" variant="outline" onClick={() => void handleImport()}>
- <FileUpIcon />
- Import…
- </Button>
- <Button asChild size="xs" variant="solid">
- <Link search={{ new: true }} to="/app">
- <PlusIcon />
- New project
- </Link>
- </Button>
- </HStack>
- </Flex>
- <ProjectsGrid />
- </Stack>
- <Box flexShrink={0} w={{ base: 'full', md: '60' }}>
- <ResourceLinks />
- </Box>
- </Flex>
+ <HomeTabs tabs={tabs} />
</Box>
</Flex>
);
};
+
+const HomeTabs = ({ tabs }: { tabs: HomeTabDefinition[] }) => {
+ const location = useLocation();
+ const requestedTabId = getRequestedHomeTabId(location.pathname, location.hash);
+ const activeTabId = getActiveHomeTabId(tabs, requestedTabId);
+
+ useEffect(() => {
+ if (window.location.hash !== `#${activeTabId}`) {
+ replaceHomeTabHash(activeTabId);
+ }
+ }, [activeTabId]);
+
+ return (
+ <Tabs.Root
+ display="flex"
+ flexDirection={{ base: 'column', md: 'row' }}
+ gap={{ base: '6', md: '10' }}
+ minH="0"
+ orientation="vertical"
+ value={activeTabId}
+ variant="subtle"
+ onValueChange={(details) => {
+ if (isHomeTabId(details.value)) {
+ pushHomeTabHash(details.value);
+ }
+ }}
+ >
+ <Stack flexShrink={0} gap="4" w={{ base: 'full', md: '60' }}>
+ {tabs.length > 1 ? (
+ <Tabs.List>
+ {tabs.map((tab) => (
+ <Tabs.Trigger key={tab.id} value={tab.id}>
+ <Icon as={tab.icon} boxSize="3.5" flexShrink={0} />
+ <Text truncate>{tab.label}</Text>
+ </Tabs.Trigger>
+ ))}
+ </Tabs.List>
+ ) : null}
+
+ <ResourceLinks />
+ </Stack>
+ <Box flex="1" minW="0">
+ {tabs.map((tab) => (
+ <Tabs.Content key={tab.id} m="0" p="0" value={tab.id}>
+ {tab.children}
+ </Tabs.Content>
+ ))}
+ </Box>
+ </Tabs.Root>
+ );
+};
+
+const UsersPanel = () => (
+ <Box flex="1" minW={0}>
+ <UsersManagementPanel />
+ </Box>
+);
+
+const ProjectsPanel = ({ greeting, onImport }: { greeting: string; onImport: () => Promise<void> }) => (
+ <Stack flex="1" gap="5" minW="0">
+ <Flex align="center" gap="3" justify="space-between" wrap="wrap">
+ <Stack gap="0.5">
+ <Heading fontSize="xl" fontWeight="700">
+ {greeting}
+ </Heading>
+ <Text color="fg.muted" fontSize="xs">
+ Pick up where you left off, or start something new.
+ </Text>
+ </Stack>
+ <HStack gap="2" wrap="wrap">
+ <Button size="xs" variant="outline" onClick={() => void onImport()}>
+ <FileUpIcon />
+ Import…
+ </Button>
+ <Button asChild size="xs" variant="solid">
+ <Link search={{ new: true }} to="/app">
+ <PlusIcon />
+ New project
+ </Link>
+ </Button>
+ </HStack>
+ </Flex>
+ <ProjectsGrid />
+ </Stack>
+);
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/users/UserFormDialog.tsx b/invokeai/frontend/webv2/src/workbench/users/UserFormDialog.tsx
similarity index 93%
rename from invokeai/frontend/webv2/src/workbench/widgets/users/UserFormDialog.tsx
rename to invokeai/frontend/webv2/src/workbench/users/UserFormDialog.tsx
index 8cea9b590b..461d333978 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/users/UserFormDialog.tsx
+++ b/invokeai/frontend/webv2/src/workbench/users/UserFormDialog.tsx
@@ -2,16 +2,16 @@ import { Dialog, HStack, Input, Portal, Stack, Switch, Text } from '@chakra-ui/r
import { useMemo, useState } from 'react';
import { WandSparklesIcon } from 'lucide-react';
-import { createUser, generatePassword, updateUser, type UserDTO, type UserUpdateRequest } from '../../auth/api';
-import { AuthFormAlert } from '../../auth/components/AuthScreen';
-import { PasswordInput, PasswordStrengthMeter } from '../../auth/components/PasswordInput';
-import { createUserFormSchema, PASSWORD_RULES_HINT, type UserFormValues } from '../../auth/schemas';
-import { useAuthSession } from '../../auth/session';
-import { getApiErrorMessage } from '../../backend/http';
-import { Button, CloseButton } from '../../components/ui/Button';
-import { Field } from '../../components/ui/Field';
-import { useZodForm } from '../../models/useZodForm';
-import { useNotify } from '../../useNotify';
+import { createUser, generatePassword, updateUser, type UserDTO, type UserUpdateRequest } from '../auth/api';
+import { AuthFormAlert } from '../auth/components/AuthScreen';
+import { PasswordInput, PasswordStrengthMeter } from '../auth/components/PasswordInput';
+import { createUserFormSchema, PASSWORD_RULES_HINT, type UserFormValues } from '../auth/schemas';
+import { useAuthSession } from '../auth/session';
+import { getApiErrorMessage } from '../backend/http';
+import { Button, CloseButton } from '../components/ui/Button';
+import { Field } from '../components/ui/Field';
+import { useZodForm } from '../models/useZodForm';
+import { useNotify } from '../useNotify';
export type UserFormTarget = { mode: 'create' } | { mode: 'edit'; user: UserDTO };
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/users/UsersWidgetView.tsx b/invokeai/frontend/webv2/src/workbench/users/UserManagement.tsx
similarity index 62%
rename from invokeai/frontend/webv2/src/workbench/widgets/users/UsersWidgetView.tsx
rename to invokeai/frontend/webv2/src/workbench/users/UserManagement.tsx
index a8e87fef42..e58287d713 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/users/UsersWidgetView.tsx
+++ b/invokeai/frontend/webv2/src/workbench/users/UserManagement.tsx
@@ -2,14 +2,14 @@ import { Avatar, Badge, Box, Center, Flex, HStack, Spinner, Stack, Switch, Table
import { useCallback, useEffect, useState } from 'react';
import { PencilIcon, Trash2Icon, UserPlusIcon } from 'lucide-react';
-import { deleteUser, listUsers, updateUser, type UserDTO } from '../../auth/api';
-import { useAuthSession } from '../../auth/session';
-import { getApiErrorMessage } from '../../backend/http';
-import { Button, IconButton } from '../../components/ui/Button';
-import { ConfirmDialog } from '../../components/ui/ConfirmDialog';
-import { Scrollable } from '../../components/ui/Scrollable';
-import { Tooltip } from '../../components/ui/Tooltip';
-import { useNotify } from '../../useNotify';
+import { deleteUser, listUsers, updateUser, type UserDTO } from '../auth/api';
+import { useAuthSession } from '../auth/session';
+import { getApiErrorMessage } from '../backend/http';
+import { Button, IconButton } from '../components/ui/Button';
+import { ConfirmDialog } from '../components/ui/ConfirmDialog';
+import { Scrollable } from '../components/ui/Scrollable';
+import { Tooltip } from '../components/ui/Tooltip';
+import { useNotify } from '../useNotify';
import { UserFormDialog, type UserFormTarget } from './UserFormDialog';
/**
@@ -18,7 +18,15 @@ import { UserFormDialog, type UserFormTarget } from './UserFormDialog';
* non-admins via `requiresAdmin`; the inline guard covers stale persisted
* layouts that still point at it.
*/
-export const UsersWidgetView = () => {
+export const UserManagement = () => {
+ return (
+ <Scrollable flex="1" h="full" label="User management">
+ <UsersManagementPanel />
+ </Scrollable>
+ );
+};
+
+export const UsersManagementPanel = () => {
const session = useAuthSession();
if (!session.multiuserEnabled || session.user?.is_admin !== true) {
@@ -82,78 +90,76 @@ const UsersDirectory = ({ currentUserId }: { currentUserId: string }) => {
return (
<>
- <Scrollable flex="1" h="full" label="User management">
- <Flex justify="center" px="4" py="6" w="full">
- <Stack gap="4" w="full">
- <HStack align="flex-start" justify="space-between">
- <Stack gap="0.5">
- <Text fontSize="md" fontWeight="700">
- Users
- </Text>
- <Text color="fg.subtle" fontSize="xs">
- {users
- ? `${users.length} ${users.length === 1 ? 'account' : 'accounts'} in this workspace.`
- : 'Manage workspace accounts and roles.'}
- </Text>
- </Stack>
- <Button size="xs" variant="solid" onClick={() => setFormTarget({ mode: 'create' })}>
- <UserPlusIcon />
- Add user
- </Button>
- </HStack>
- <Box bg="bg.subtle" borderColor="border.subtle" borderWidth="1px" overflow="hidden" rounded="lg">
- {users === null ? (
- <Center minH="40">
- {loadError ? (
- <Stack align="center" gap="2" p="4">
- <Text color="fg.error" fontSize="xs" textAlign="center">
- {loadError}
- </Text>
- <Button size="xs" variant="outline" onClick={() => void refresh()}>
- Retry
- </Button>
- </Stack>
- ) : (
- <Spinner color="fg.muted" size="sm" />
- )}
- </Center>
- ) : (
- <Table.Root size="sm">
- <Table.Header>
- <Table.Row bg="bg.muted">
- <Table.ColumnHeader borderColor="border.subtle" color="fg.muted" ps="4">
- User
- </Table.ColumnHeader>
- <Table.ColumnHeader borderColor="border.subtle" color="fg.muted">
- Role
- </Table.ColumnHeader>
- <Table.ColumnHeader borderColor="border.subtle" color="fg.muted">
- Last sign-in
- </Table.ColumnHeader>
- <Table.ColumnHeader borderColor="border.subtle" color="fg.muted">
- Active
- </Table.ColumnHeader>
- <Table.ColumnHeader borderColor="border.subtle" pe="4" />
- </Table.Row>
- </Table.Header>
- <Table.Body>
- {users.map((user) => (
- <UserRow
- key={user.user_id}
- isSelf={user.user_id === currentUserId}
- user={user}
- onDelete={() => setDeleteTarget(user)}
- onEdit={() => setFormTarget({ mode: 'edit', user })}
- onSetActive={(isActive) => void setUserActive(user, isActive)}
- />
- ))}
- </Table.Body>
- </Table.Root>
- )}
- </Box>
- </Stack>
- </Flex>
- </Scrollable>
+ <Flex justify="center" px="4" py="6" w="full">
+ <Stack gap="4" w="full">
+ <HStack align="flex-start" justify="space-between">
+ <Stack gap="0.5">
+ <Text fontSize="md" fontWeight="700">
+ Users
+ </Text>
+ <Text color="fg.subtle" fontSize="xs">
+ {users
+ ? `${users.length} ${users.length === 1 ? 'account' : 'accounts'} in this workspace.`
+ : 'Manage workspace accounts and roles.'}
+ </Text>
+ </Stack>
+ <Button size="xs" variant="solid" onClick={() => setFormTarget({ mode: 'create' })}>
+ <UserPlusIcon />
+ Add user
+ </Button>
+ </HStack>
+ <Box bg="bg.subtle" borderColor="border.subtle" borderWidth="1px" overflowX="auto" rounded="lg">
+ {users === null ? (
+ <Center minH="40">
+ {loadError ? (
+ <Stack align="center" gap="2" p="4">
+ <Text color="fg.error" fontSize="xs" textAlign="center">
+ {loadError}
+ </Text>
+ <Button size="xs" variant="outline" onClick={() => void refresh()}>
+ Retry
+ </Button>
+ </Stack>
+ ) : (
+ <Spinner color="fg.muted" size="sm" />
+ )}
+ </Center>
+ ) : (
+ <Table.Root minW="42rem" size="sm">
+ <Table.Header>
+ <Table.Row bg="bg.muted">
+ <Table.ColumnHeader borderColor="border.subtle" color="fg.muted" ps="4">
+ User
+ </Table.ColumnHeader>
+ <Table.ColumnHeader borderColor="border.subtle" color="fg.muted">
+ Role
+ </Table.ColumnHeader>
+ <Table.ColumnHeader borderColor="border.subtle" color="fg.muted">
+ Last sign-in
+ </Table.ColumnHeader>
+ <Table.ColumnHeader borderColor="border.subtle" color="fg.muted">
+ Active
+ </Table.ColumnHeader>
+ <Table.ColumnHeader borderColor="border.subtle" pe="4" />
+ </Table.Row>
+ </Table.Header>
+ <Table.Body>
+ {users.map((user) => (
+ <UserRow
+ key={user.user_id}
+ isSelf={user.user_id === currentUserId}
+ user={user}
+ onDelete={() => setDeleteTarget(user)}
+ onEdit={() => setFormTarget({ mode: 'edit', user })}
+ onSetActive={(isActive) => void setUserActive(user, isActive)}
+ />
+ ))}
+ </Table.Body>
+ </Table.Root>
+ )}
+ </Box>
+ </Stack>
+ </Flex>
<UserFormDialog target={formTarget} onClose={() => setFormTarget(null)} onSaved={() => void refresh()} />
<ConfirmDialog
body={`Delete ${deleteTarget ? getUserLabel(deleteTarget) : 'this user'}? Their account is removed permanently.`}
diff --git a/invokeai/frontend/webv2/src/workbench/users/index.ts b/invokeai/frontend/webv2/src/workbench/users/index.ts
new file mode 100644
index 0000000000..1d4eea7229
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/users/index.ts
@@ -0,0 +1,2 @@
+export * from './UserFormDialog';
+export * from './UserManagement';
diff --git a/invokeai/frontend/webv2/src/workbench/widgetRegistry.ts b/invokeai/frontend/webv2/src/workbench/widgetRegistry.ts
index 618de2db45..cc665b6199 100644
--- a/invokeai/frontend/webv2/src/workbench/widgetRegistry.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgetRegistry.ts
@@ -15,7 +15,6 @@ import { previewWidgetManifest } from './widgets/preview';
import { projectWidgetManifest } from './widgets/project';
import { queueWidgetManifest } from './widgets/queue';
import { serverStatusWidgetManifest } from './widgets/server-status';
-import { usersWidgetManifest } from './widgets/users';
import { versionStatusWidgetManifest } from './widgets/version-status';
import { workflowWidgetManifest } from './widgets/workflow';
@@ -36,7 +35,6 @@ const firstPartyWidgetManifests: WidgetManifest[] = [
historyControlsWidgetManifest,
layoutActionsWidgetManifest,
versionStatusWidgetManifest,
- usersWidgetManifest,
];
const createFailure = (widgetId: WidgetId, error: unknown): WidgetFailure => ({
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/users/index.ts b/invokeai/frontend/webv2/src/workbench/widgets/users/index.ts
deleted file mode 100644
index ea68091baa..0000000000
--- a/invokeai/frontend/webv2/src/workbench/widgets/users/index.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import type { WidgetManifest } from '../../types';
-import { UsersWidgetView } from './UsersWidgetView';
-
-export const usersWidgetManifest: WidgetManifest = {
- failurePolicy: { isolateRenderFailure: true, onRegistrationFailure: 'disable' },
- icon: 'lucide-react:users',
- id: 'users',
- label: 'Users',
- labelText: 'Users',
- regions: ['center'],
- requiresAdmin: true,
- version: 1,
- view: UsersWidgetView,
-};