Remove Admin option from header profile dropdown
User management is now centralized in AuthGuard's webui, so the per-project Admin dialog (user CRUD + require-login toggle) is redundant. The require-login toggle will move to ProjectConfigurator in the future. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
72c3ba028c
commit
07cf3308da
5 files changed
+4
-167
No files matched your search
@@ -5,21 +5,12 @@
|
||||
import AuthPage from '$lib/components/AuthPage.svelte'
|
||||
import ProjectIcon from '$lib/components/ProjectIcon.svelte'
|
||||
import AboutWorkspace from '$lib/features/AboutWorkspace.svelte'
|
||||
import { AboutDialog, AdminDialog, Header, NotificationStack, PageHeader, ProfileDialog } from '@gabriel20xx/web-ui'
|
||||
import type {
|
||||
AuthLoginInput,
|
||||
AuthSetupInput,
|
||||
ManagedUser,
|
||||
ProfileUpdateInput,
|
||||
UserCreateInput,
|
||||
UserId,
|
||||
UserRole,
|
||||
UserUpdateInput,
|
||||
} from '@gabriel20xx/web-ui'
|
||||
import { AboutDialog, Header, NotificationStack, PageHeader, ProfileDialog } from '@gabriel20xx/web-ui'
|
||||
import type { AuthLoginInput, AuthSetupInput, ProfileUpdateInput } from '@gabriel20xx/web-ui'
|
||||
import SettingsDialog from '$lib/components/SettingsDialog.svelte'
|
||||
import { getPanelForPath } from '$lib/app-config'
|
||||
import { pageActions } from '$lib/stores/page-actions.svelte'
|
||||
import { del, get, post, put } from '$lib/api'
|
||||
import { get, post, put } from '$lib/api'
|
||||
import '$lib/language.svelte'
|
||||
import type { AppConfig, AuthState, AuthUser } from '$lib/types'
|
||||
import type { Snippet } from 'svelte'
|
||||
@@ -36,7 +27,6 @@
|
||||
let settingsOpen = $state(false)
|
||||
let aboutOpen = $state(false)
|
||||
let profileOpen = $state(false)
|
||||
let adminOpen = $state(false)
|
||||
|
||||
// Header only renders its profile/settings menu when username is truthy - with login not
|
||||
// required and nobody signed in, auth.user is legitimately null (there's no session to read
|
||||
@@ -56,11 +46,6 @@
|
||||
const activeNavItem = $derived(
|
||||
app.nav.find((item) => item.panel === getPanelForPath(app, page.url.pathname)) || app.nav[0],
|
||||
)
|
||||
const currentRole = $derived<UserRole>(
|
||||
auth.user?.role === 'superadmin' || auth.user?.role === 'admin' ? auth.user.role : 'user',
|
||||
)
|
||||
const currentUserId = $derived<UserId | undefined>(auth.user?.id)
|
||||
const isAdmin = $derived(currentRole === 'admin' || currentRole === 'superadmin')
|
||||
|
||||
function openSettings() {
|
||||
settingsOpen = true
|
||||
@@ -74,10 +59,6 @@
|
||||
profileOpen = true
|
||||
}
|
||||
|
||||
function openAdmin() {
|
||||
adminOpen = true
|
||||
}
|
||||
|
||||
function closeSettings() {
|
||||
settingsOpen = false
|
||||
if (page.url.pathname === '/settings') void goto(homePath)
|
||||
@@ -153,27 +134,6 @@
|
||||
auth = { ...auth, user: data.user, error: null }
|
||||
}
|
||||
|
||||
async function listUsers(): Promise<ManagedUser[]> {
|
||||
return get<ManagedUser[]>('/api/auth/users')
|
||||
}
|
||||
|
||||
async function createUser(input: UserCreateInput): Promise<void | ManagedUser> {
|
||||
return post<ManagedUser>('/api/auth/users', input)
|
||||
}
|
||||
|
||||
async function updateUser(id: UserId, input: UserUpdateInput): Promise<void | ManagedUser> {
|
||||
return put<ManagedUser>(`/api/auth/users/${encodeURIComponent(String(id))}`, input)
|
||||
}
|
||||
|
||||
async function deleteUser(id: UserId): Promise<void> {
|
||||
await del<{ ok: boolean }>(`/api/auth/users/${encodeURIComponent(String(id))}`)
|
||||
}
|
||||
|
||||
async function updateLoginRequired(loginRequired: boolean) {
|
||||
await put<{ loginRequired: boolean }>('/api/auth/access', { loginRequired })
|
||||
auth = { ...auth, authRequired: loginRequired }
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
void loadAuth()
|
||||
})
|
||||
@@ -204,7 +164,6 @@
|
||||
faviconHref="/favicon.svg"
|
||||
{navItems}
|
||||
onAbout={openAbout}
|
||||
onAdmin={isAdmin ? openAdmin : undefined}
|
||||
onLogout={logout}
|
||||
onProfile={openProfile}
|
||||
onSettings={openSettings}
|
||||
@@ -223,17 +182,6 @@
|
||||
{/if}
|
||||
|
||||
<SettingsDialog bind:open={settingsOpen} onClose={closeSettings} />
|
||||
<AdminDialog
|
||||
bind:open={adminOpen}
|
||||
{currentRole}
|
||||
{currentUserId}
|
||||
onListUsers={listUsers}
|
||||
onCreateUser={createUser}
|
||||
onUpdateUser={updateUser}
|
||||
onDeleteUser={deleteUser}
|
||||
loginRequired={auth.authRequired}
|
||||
onLoginRequiredChange={updateLoginRequired}
|
||||
/>
|
||||
<AboutDialog bind:open={aboutOpen} brand={app.name} description={app.description} onClose={closeAbout}>
|
||||
{#snippet icon()}
|
||||
<ProjectIcon icon={app.icon} class="size-8 text-primary" />
|
||||
|
||||
Reference in new issue
Block a user