@aphexcms/cms-core 11.2.1 → 12.0.0-next.20261109083516
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/client-auth.svelte.d.ts +120 -0
- package/dist/admin/client-auth.svelte.d.ts.map +1 -0
- package/dist/admin/client-auth.svelte.js +14 -0
- package/dist/admin/client-config.d.ts +72 -0
- package/dist/admin/client-config.d.ts.map +1 -0
- package/dist/admin/client-config.js +1 -0
- package/dist/admin/settings-header-actions.d.ts +12 -0
- package/dist/admin/settings-header-actions.d.ts.map +1 -0
- package/dist/admin/settings-header-actions.js +1 -0
- package/dist/admin/view-data.d.ts +189 -0
- package/dist/admin/view-data.d.ts.map +1 -0
- package/dist/admin/view-data.js +1 -0
- package/dist/admin.css +6 -0
- package/dist/api/invitations.d.ts +2 -2
- package/dist/api/invitations.d.ts.map +1 -1
- package/dist/api/organizations.d.ts +13 -3
- package/dist/api/organizations.d.ts.map +1 -1
- package/dist/api/organizations.js +11 -1
- package/dist/api/user.d.ts +6 -1
- package/dist/api/user.d.ts.map +1 -1
- package/dist/api/user.js +7 -0
- package/dist/app-augment.d.ts +2 -3
- package/dist/app-augment.d.ts.map +1 -1
- package/dist/app.d.ts +1 -1
- package/dist/auth/auth-errors.d.ts +6 -0
- package/dist/auth/auth-errors.d.ts.map +1 -1
- package/dist/auth/auth-errors.js +8 -0
- package/dist/auth/auth-hooks.d.ts.map +1 -1
- package/dist/auth/auth-hooks.js +36 -17
- package/dist/auth/invitation-email.d.ts +9 -0
- package/dist/auth/invitation-email.d.ts.map +1 -0
- package/dist/auth/invitation-email.js +49 -0
- package/dist/auth/pages.d.ts +16 -0
- package/dist/auth/pages.d.ts.map +1 -0
- package/dist/auth/pages.js +23 -0
- package/dist/auth/provider.d.ts +31 -1
- package/dist/auth/provider.d.ts.map +1 -1
- package/dist/client/index.d.ts +5 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +9 -0
- package/dist/client/ui.d.ts +17 -0
- package/dist/client/ui.d.ts.map +1 -1
- package/dist/client/ui.js +27 -0
- package/dist/components/AdminApp.svelte +7 -4
- package/dist/components/AdminApp.svelte.d.ts.map +1 -1
- package/dist/components/AphexStudio.svelte +268 -0
- package/dist/components/AphexStudio.svelte.d.ts +16 -0
- package/dist/components/AphexStudio.svelte.d.ts.map +1 -0
- package/dist/components/admin/AccountSettings.svelte +339 -0
- package/dist/components/admin/AccountSettings.svelte.d.ts +8 -0
- package/dist/components/admin/AccountSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/AccountSettingsView.svelte +61 -0
- package/dist/components/admin/AccountSettingsView.svelte.d.ts +19 -0
- package/dist/components/admin/AccountSettingsView.svelte.d.ts.map +1 -0
- package/dist/components/admin/ApiKeysSettings.svelte +435 -0
- package/dist/components/admin/ApiKeysSettings.svelte.d.ts +15 -0
- package/dist/components/admin/ApiKeysSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/AuthPageShell.svelte +32 -0
- package/dist/components/admin/AuthPageShell.svelte.d.ts +16 -0
- package/dist/components/admin/AuthPageShell.svelte.d.ts.map +1 -0
- package/dist/components/admin/CreateOrganization.svelte +158 -0
- package/dist/components/admin/CreateOrganization.svelte.d.ts +11 -0
- package/dist/components/admin/CreateOrganization.svelte.d.ts.map +1 -0
- package/dist/components/admin/DeleteAccountSettings.svelte +124 -0
- package/dist/components/admin/DeleteAccountSettings.svelte.d.ts +7 -0
- package/dist/components/admin/DeleteAccountSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/DeleteOrganizationSettings.svelte +123 -0
- package/dist/components/admin/DeleteOrganizationSettings.svelte.d.ts +11 -0
- package/dist/components/admin/DeleteOrganizationSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/DocumentEditor.svelte +108 -36
- package/dist/components/admin/DocumentEditor.svelte.d.ts.map +1 -1
- package/dist/components/admin/GeneralSettings.svelte +45 -0
- package/dist/components/admin/GeneralSettings.svelte.d.ts +10 -0
- package/dist/components/admin/GeneralSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/GodModeView.svelte +112 -0
- package/dist/components/admin/GodModeView.svelte.d.ts +9 -0
- package/dist/components/admin/GodModeView.svelte.d.ts.map +1 -0
- package/dist/components/admin/InvitationsView.svelte +277 -0
- package/dist/components/admin/InvitationsView.svelte.d.ts +11 -0
- package/dist/components/admin/InvitationsView.svelte.d.ts.map +1 -0
- package/dist/components/admin/InviteView.svelte +98 -0
- package/dist/components/admin/InviteView.svelte.d.ts +9 -0
- package/dist/components/admin/InviteView.svelte.d.ts.map +1 -0
- package/dist/components/admin/LoginView.svelte +478 -0
- package/dist/components/admin/LoginView.svelte.d.ts +5 -0
- package/dist/components/admin/LoginView.svelte.d.ts.map +1 -0
- package/dist/components/admin/MembersSettings.svelte +661 -0
- package/dist/components/admin/MembersSettings.svelte.d.ts +8 -0
- package/dist/components/admin/MembersSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/OrganizationSettings.svelte +367 -0
- package/dist/components/admin/OrganizationSettings.svelte.d.ts +9 -0
- package/dist/components/admin/OrganizationSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/OrganizationsList.svelte +92 -0
- package/dist/components/admin/OrganizationsList.svelte.d.ts +8 -0
- package/dist/components/admin/OrganizationsList.svelte.d.ts.map +1 -0
- package/dist/components/admin/OrganizationsView.svelte +31 -0
- package/dist/components/admin/OrganizationsView.svelte.d.ts +9 -0
- package/dist/components/admin/OrganizationsView.svelte.d.ts.map +1 -0
- package/dist/components/admin/PasswordInput.svelte +43 -0
- package/dist/components/admin/PasswordInput.svelte.d.ts +8 -0
- package/dist/components/admin/PasswordInput.svelte.d.ts.map +1 -0
- package/dist/components/admin/PasswordSettings.svelte +179 -0
- package/dist/components/admin/PasswordSettings.svelte.d.ts +4 -0
- package/dist/components/admin/PasswordSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/PreferencesSettings.svelte +80 -0
- package/dist/components/admin/PreferencesSettings.svelte.d.ts +20 -0
- package/dist/components/admin/PreferencesSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/ResetPasswordView.svelte +117 -0
- package/dist/components/admin/ResetPasswordView.svelte.d.ts +9 -0
- package/dist/components/admin/ResetPasswordView.svelte.d.ts.map +1 -0
- package/dist/components/admin/RolesSettings.svelte +360 -0
- package/dist/components/admin/RolesSettings.svelte.d.ts +11 -0
- package/dist/components/admin/RolesSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/SchemaField.svelte +12 -2
- package/dist/components/admin/SchemaField.svelte.d.ts.map +1 -1
- package/dist/components/admin/SettingsHeaderActions.svelte +25 -0
- package/dist/components/admin/SettingsHeaderActions.svelte.d.ts +8 -0
- package/dist/components/admin/SettingsHeaderActions.svelte.d.ts.map +1 -0
- package/dist/components/admin/SettingsShell.svelte +136 -0
- package/dist/components/admin/SettingsShell.svelte.d.ts +9 -0
- package/dist/components/admin/SettingsShell.svelte.d.ts.map +1 -0
- package/dist/components/admin/TwoFactorChallengeView.svelte +377 -0
- package/dist/components/admin/TwoFactorChallengeView.svelte.d.ts +11 -0
- package/dist/components/admin/TwoFactorChallengeView.svelte.d.ts.map +1 -0
- package/dist/components/admin/TwoFactorSettings.svelte +436 -0
- package/dist/components/admin/TwoFactorSettings.svelte.d.ts +7 -0
- package/dist/components/admin/TwoFactorSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/fields/ImageField.svelte +4 -2
- package/dist/components/admin/fields/SlugField.svelte +3 -1
- package/dist/components/admin/fields/SlugField.svelte.d.ts.map +1 -1
- package/dist/components/admin/fields/richtext/PortableTextImageView.svelte +3 -2
- package/dist/components/admin/fields/richtext/RichtextField.svelte +54 -7
- package/dist/components/admin/fields/richtext/RichtextField.svelte.d.ts.map +1 -1
- package/dist/components/layout/sidebar/NavUser.svelte +2 -2
- package/dist/config.d.ts +2 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/db/interfaces/document.d.ts +15 -2
- package/dist/db/interfaces/document.d.ts.map +1 -1
- package/dist/db/interfaces/index.d.ts +1 -1
- package/dist/db/interfaces/index.d.ts.map +1 -1
- package/dist/email/index.d.ts +1 -0
- package/dist/email/index.d.ts.map +1 -1
- package/dist/email/index.js +2 -0
- package/dist/email/interfaces/email.d.ts +2 -0
- package/dist/email/interfaces/email.d.ts.map +1 -1
- package/dist/email/link-email.d.ts +15 -0
- package/dist/email/link-email.d.ts.map +1 -0
- package/dist/email/link-email.js +30 -0
- package/dist/field-validation/date-utils.d.ts.map +1 -1
- package/dist/field-validation/date-utils.js +4 -2
- package/dist/field-validation/utils.d.ts +42 -2
- package/dist/field-validation/utils.d.ts.map +1 -1
- package/dist/field-validation/utils.js +176 -14
- package/dist/graphql/index.d.ts.map +1 -1
- package/dist/graphql/index.js +1 -1
- package/dist/hooks.d.ts +6 -3
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +53 -17
- package/dist/jobs/recurring.d.ts +4 -1
- package/dist/jobs/recurring.d.ts.map +1 -1
- package/dist/jobs/recurring.js +28 -0
- package/dist/local-api/auth-helpers.d.ts +4 -4
- package/dist/local-api/auth-helpers.js +4 -4
- package/dist/local-api/collection-api.d.ts +10 -1
- package/dist/local-api/collection-api.d.ts.map +1 -1
- package/dist/local-api/collection-api.js +40 -12
- package/dist/local-api/index.d.ts +1 -1
- package/dist/local-api/index.d.ts.map +1 -1
- package/dist/local-api/index.js +12 -6
- package/dist/local-api/types.d.ts +1 -1
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +3 -1
- package/dist/preview/perspective.d.ts +1 -1
- package/dist/preview/perspective.js +1 -1
- package/dist/resolve-config.d.ts +22 -0
- package/dist/resolve-config.d.ts.map +1 -0
- package/dist/resolve-config.js +106 -0
- package/dist/routes/assets-cdn.d.ts +7 -2
- package/dist/routes/assets-cdn.d.ts.map +1 -1
- package/dist/routes/assets-cdn.js +11 -5
- package/dist/server/api/index.d.ts +1 -2
- package/dist/server/api/index.d.ts.map +1 -1
- package/dist/server/api/index.js +12 -3
- package/dist/server/api/openapi/registry.d.ts.map +1 -1
- package/dist/server/api/openapi/registry.js +70 -0
- package/dist/server/api/routes/api-keys.d.ts +4 -0
- package/dist/server/api/routes/api-keys.d.ts.map +1 -0
- package/dist/server/api/routes/api-keys.js +88 -0
- package/dist/server/api/routes/documents-by-id.d.ts.map +1 -1
- package/dist/server/api/routes/documents-by-id.js +16 -1
- package/dist/server/api/routes/documents-publish.d.ts.map +1 -1
- package/dist/server/api/routes/documents-publish.js +11 -1
- package/dist/server/api/routes/documents.d.ts.map +1 -1
- package/dist/server/api/routes/documents.js +16 -2
- package/dist/server/api/routes/instance-settings.d.ts +4 -0
- package/dist/server/api/routes/instance-settings.d.ts.map +1 -0
- package/dist/server/api/routes/instance-settings.js +47 -0
- package/dist/server/api/routes/invitations.d.ts +9 -0
- package/dist/server/api/routes/invitations.d.ts.map +1 -0
- package/dist/server/api/routes/invitations.js +79 -0
- package/dist/server/api/routes/organizations-invitations.d.ts +0 -6
- package/dist/server/api/routes/organizations-invitations.d.ts.map +1 -1
- package/dist/server/api/routes/organizations-invitations.js +6 -7
- package/dist/server/api/routes/organizations-team.d.ts +14 -0
- package/dist/server/api/routes/organizations-team.d.ts.map +1 -0
- package/dist/server/api/routes/organizations-team.js +36 -0
- package/dist/server/api/routes/organizations.d.ts.map +1 -1
- package/dist/server/api/routes/organizations.js +35 -9
- package/dist/server/core-routes.d.ts +8 -0
- package/dist/server/core-routes.d.ts.map +1 -0
- package/dist/server/core-routes.js +67 -0
- package/dist/server/index.d.ts +5 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +7 -1
- package/dist/server/pages/admin.d.ts +24 -0
- package/dist/server/pages/admin.d.ts.map +1 -0
- package/dist/server/pages/admin.js +468 -0
- package/dist/server/queries/organization-team.d.ts +14 -0
- package/dist/server/queries/organization-team.d.ts.map +1 -0
- package/dist/server/queries/organization-team.js +65 -0
- package/dist/server/queries/pending-invitations.d.ts +8 -0
- package/dist/server/queries/pending-invitations.d.ts.map +1 -0
- package/dist/server/queries/pending-invitations.js +24 -0
- package/dist/types/api-key.d.ts +18 -0
- package/dist/types/api-key.d.ts.map +1 -0
- package/dist/types/api-key.js +1 -0
- package/dist/types/auth.d.ts +35 -0
- package/dist/types/auth.d.ts.map +1 -1
- package/dist/types/capabilities.d.ts +1 -2
- package/dist/types/capabilities.d.ts.map +1 -1
- package/dist/types/config.d.ts +124 -4
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/filters.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/organization.d.ts +30 -0
- package/dist/types/organization.d.ts.map +1 -1
- package/dist/utils/preview.d.ts +8 -1
- package/dist/utils/preview.d.ts.map +1 -1
- package/dist/utils/preview.js +35 -0
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +46 -39
- package/package.json +19 -29
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Roles & access settings panel: list roles, create/edit with a grouped
|
|
4
|
+
* capability checklist, delete custom roles. Core-owned — the embedded
|
|
5
|
+
* `/admin/settings/roles` catch-all SSR's its data (`roles`, the capability
|
|
6
|
+
* catalog, and per-role member counts) via `createAdminLoad`.
|
|
7
|
+
*
|
|
8
|
+
* Member counts arrive pre-computed (a plain `{ roleName: count }` map) so this
|
|
9
|
+
* panel needs no org/user join — just the CMS role + member data.
|
|
10
|
+
*/
|
|
11
|
+
import * as Card from '@aphexcms/ui/shadcn/card';
|
|
12
|
+
import * as Sheet from '@aphexcms/ui/shadcn/sheet';
|
|
13
|
+
import { Button } from '@aphexcms/ui/shadcn/button';
|
|
14
|
+
import { Input } from '@aphexcms/ui/shadcn/input';
|
|
15
|
+
import { Textarea } from '@aphexcms/ui/shadcn/textarea';
|
|
16
|
+
import { Label } from '@aphexcms/ui/shadcn/label';
|
|
17
|
+
import { Checkbox } from '@aphexcms/ui/shadcn/checkbox';
|
|
18
|
+
import { Badge } from '@aphexcms/ui/shadcn/badge';
|
|
19
|
+
import { Separator } from '@aphexcms/ui/shadcn/separator';
|
|
20
|
+
import { invalidateAll } from '$app/navigation';
|
|
21
|
+
import { toast } from 'svelte-sonner';
|
|
22
|
+
import { Pencil, Plus, Trash2 } from '@lucide/svelte';
|
|
23
|
+
import type { CapabilityDefinition, Role } from '../../types/capabilities';
|
|
24
|
+
import { roles as rolesApi } from '../../api/roles';
|
|
25
|
+
import { usePermissions } from '../../permissions-context.svelte';
|
|
26
|
+
import { confirmDialog } from './confirm-dialog/confirm-dialog.svelte';
|
|
27
|
+
import SettingsHeaderActions from './SettingsHeaderActions.svelte';
|
|
28
|
+
|
|
29
|
+
interface Props {
|
|
30
|
+
roles: Role[];
|
|
31
|
+
capabilityCatalog: CapabilityDefinition[];
|
|
32
|
+
/** Count of members per role name, pre-computed server-side. */
|
|
33
|
+
roleMemberCounts: Record<string, number>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let { roles: rolesInput, capabilityCatalog, roleMemberCounts }: Props = $props();
|
|
37
|
+
|
|
38
|
+
const roles = $derived(rolesInput);
|
|
39
|
+
// Read from the shared permissions context instead of a separate server
|
|
40
|
+
// flag — single source of truth, stays in sync if the role changes.
|
|
41
|
+
const perms = usePermissions();
|
|
42
|
+
const canManageRoles = $derived(perms.can('role.manage'));
|
|
43
|
+
|
|
44
|
+
type EditorState = { kind: 'closed' } | { kind: 'create' } | { kind: 'edit'; role: Role };
|
|
45
|
+
|
|
46
|
+
let editor = $state<EditorState>({ kind: 'closed' });
|
|
47
|
+
let form = $state({
|
|
48
|
+
name: '',
|
|
49
|
+
description: '',
|
|
50
|
+
capabilities: new Set<string>()
|
|
51
|
+
});
|
|
52
|
+
let saving = $state(false);
|
|
53
|
+
|
|
54
|
+
// The capability registry (built-in + plugin-declared), resolved server-side and
|
|
55
|
+
// passed via load. Replaces the previously-hardcoded list, so plugin capabilities
|
|
56
|
+
// appear here automatically.
|
|
57
|
+
const catalog = $derived(capabilityCatalog);
|
|
58
|
+
const totalCapabilities = $derived(catalog.length);
|
|
59
|
+
|
|
60
|
+
// Group by each definition's `group` (falling back to "Other"), preserving the
|
|
61
|
+
// catalog's order within each group and first-seen order of the groups.
|
|
62
|
+
function groupedCapabilities() {
|
|
63
|
+
const groups = new Map<string, CapabilityDefinition[]>();
|
|
64
|
+
for (const def of catalog) {
|
|
65
|
+
const title = def.group ?? 'Other';
|
|
66
|
+
(groups.get(title) ?? groups.set(title, []).get(title)!).push(def);
|
|
67
|
+
}
|
|
68
|
+
return [...groups.entries()].map(([title, items]) => ({ title, items }));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function roleMemberCount(roleName: string): number {
|
|
72
|
+
return roleMemberCounts[roleName] ?? 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function openCreate() {
|
|
76
|
+
form = { name: '', description: '', capabilities: new Set() };
|
|
77
|
+
editor = { kind: 'create' };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function openEdit(role: Role) {
|
|
81
|
+
form = {
|
|
82
|
+
name: role.name,
|
|
83
|
+
description: role.description ?? '',
|
|
84
|
+
capabilities: new Set(role.capabilities)
|
|
85
|
+
};
|
|
86
|
+
editor = { kind: 'edit', role };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function closeEditor() {
|
|
90
|
+
editor = { kind: 'closed' };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Write caps imply their matching read on the same resource family. Mirror
|
|
94
|
+
// the server-side normalization visually so users see the read checkbox
|
|
95
|
+
// light up instead of being surprised by it reappearing post-save.
|
|
96
|
+
// Built-in read/write implications only — plugin caps aren't in these maps, so a
|
|
97
|
+
// plugin capability is simply toggled on its own (correct: it implies nothing).
|
|
98
|
+
const READ_IMPLIED_BY: Record<string, string> = {
|
|
99
|
+
'document.create': 'document.read',
|
|
100
|
+
'document.update': 'document.read',
|
|
101
|
+
'document.delete': 'document.read',
|
|
102
|
+
'document.publish': 'document.read',
|
|
103
|
+
'document.unpublish': 'document.read',
|
|
104
|
+
'asset.upload': 'asset.read',
|
|
105
|
+
'asset.delete': 'asset.read'
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const WRITES_NEEDING: Record<string, string[]> = Object.entries(READ_IMPLIED_BY).reduce(
|
|
109
|
+
(acc, [write, read]) => {
|
|
110
|
+
(acc[read] ??= []).push(write);
|
|
111
|
+
return acc;
|
|
112
|
+
},
|
|
113
|
+
{} as Record<string, string[]>
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
function toggleCapability(cap: string, next: boolean) {
|
|
117
|
+
const updated = new Set(form.capabilities);
|
|
118
|
+
if (next) {
|
|
119
|
+
updated.add(cap);
|
|
120
|
+
const implied = READ_IMPLIED_BY[cap];
|
|
121
|
+
if (implied) updated.add(implied);
|
|
122
|
+
} else {
|
|
123
|
+
// Don't allow unchecking a read cap while a dependent write is selected —
|
|
124
|
+
// the server would re-add it anyway.
|
|
125
|
+
const dependents = WRITES_NEEDING[cap] ?? [];
|
|
126
|
+
if (dependents.some((w) => updated.has(w))) return;
|
|
127
|
+
updated.delete(cap);
|
|
128
|
+
}
|
|
129
|
+
form.capabilities = updated;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function isImpliedRead(cap: string): boolean {
|
|
133
|
+
const dependents = WRITES_NEEDING[cap] ?? [];
|
|
134
|
+
return dependents.some((w) => form.capabilities.has(w));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async function save() {
|
|
138
|
+
saving = true;
|
|
139
|
+
try {
|
|
140
|
+
const capabilities = Array.from(form.capabilities);
|
|
141
|
+
if (editor.kind === 'create') {
|
|
142
|
+
if (!form.name.trim()) {
|
|
143
|
+
toast.error('Name is required');
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const result = await rolesApi.create({
|
|
147
|
+
name: form.name.trim(),
|
|
148
|
+
description: form.description.trim() || null,
|
|
149
|
+
capabilities
|
|
150
|
+
});
|
|
151
|
+
if (!result.success) throw new Error(result.error || 'Failed to create role');
|
|
152
|
+
toast.success(`Role "${form.name.trim()}" created`);
|
|
153
|
+
} else if (editor.kind === 'edit') {
|
|
154
|
+
const result = await rolesApi.update(editor.role.name, {
|
|
155
|
+
description: form.description.trim() || null,
|
|
156
|
+
capabilities
|
|
157
|
+
});
|
|
158
|
+
if (!result.success) throw new Error(result.error || 'Failed to update role');
|
|
159
|
+
toast.success(`Role "${editor.role.name}" updated`);
|
|
160
|
+
}
|
|
161
|
+
closeEditor();
|
|
162
|
+
await invalidateAll();
|
|
163
|
+
} catch (err) {
|
|
164
|
+
toast.error(err instanceof Error ? err.message : 'Failed to save role');
|
|
165
|
+
} finally {
|
|
166
|
+
saving = false;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async function remove(role: Role) {
|
|
171
|
+
const confirmed = await confirmDialog({
|
|
172
|
+
title: `Delete role "${role.name}"?`,
|
|
173
|
+
description:
|
|
174
|
+
'This cannot be undone. Members and pending invitations using this role will block the deletion.',
|
|
175
|
+
confirmText: 'Delete',
|
|
176
|
+
variant: 'destructive'
|
|
177
|
+
});
|
|
178
|
+
if (!confirmed) return;
|
|
179
|
+
|
|
180
|
+
try {
|
|
181
|
+
const result = await rolesApi.remove(role.name);
|
|
182
|
+
if (!result.success) throw new Error(result.error || 'Failed to delete role');
|
|
183
|
+
toast.success(`Role "${role.name}" deleted`);
|
|
184
|
+
await invalidateAll();
|
|
185
|
+
} catch (err) {
|
|
186
|
+
toast.error(err instanceof Error ? err.message : 'Failed to delete role');
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
</script>
|
|
190
|
+
|
|
191
|
+
{#if canManageRoles}
|
|
192
|
+
<SettingsHeaderActions>
|
|
193
|
+
<Button onclick={openCreate} class="shrink-0">
|
|
194
|
+
<Plus class="mr-1 h-4 w-4" /> New role
|
|
195
|
+
</Button>
|
|
196
|
+
</SettingsHeaderActions>
|
|
197
|
+
{/if}
|
|
198
|
+
|
|
199
|
+
<div class="grid gap-6">
|
|
200
|
+
<div class="grid gap-4 xl:grid-cols-2">
|
|
201
|
+
{#each roles as role (role.id)}
|
|
202
|
+
<Card.Root class="overflow-hidden">
|
|
203
|
+
<Card.Content class="p-4">
|
|
204
|
+
<div class="flex items-start justify-between gap-4">
|
|
205
|
+
<div class="min-w-0">
|
|
206
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
207
|
+
<h2 class="truncate text-lg font-semibold capitalize">{role.name}</h2>
|
|
208
|
+
{#if role.isBuiltIn}
|
|
209
|
+
<Badge variant="secondary" class="text-[10px]">System</Badge>
|
|
210
|
+
{/if}
|
|
211
|
+
<span class="text-muted-foreground text-xs">
|
|
212
|
+
{roleMemberCount(role.name)} member{roleMemberCount(role.name) === 1 ? '' : 's'}
|
|
213
|
+
</span>
|
|
214
|
+
</div>
|
|
215
|
+
{#if role.description}
|
|
216
|
+
<p class="text-muted-foreground mt-1 text-sm">{role.description}</p>
|
|
217
|
+
{/if}
|
|
218
|
+
</div>
|
|
219
|
+
|
|
220
|
+
{#if canManageRoles}
|
|
221
|
+
<div class="flex shrink-0 items-center gap-2">
|
|
222
|
+
<Button variant="outline" size="sm" onclick={() => openEdit(role)}>
|
|
223
|
+
<Pencil class="mr-1 h-3.5 w-3.5" /> Edit
|
|
224
|
+
</Button>
|
|
225
|
+
{#if !role.isBuiltIn}
|
|
226
|
+
<Button variant="outline" size="sm" onclick={() => remove(role)}>
|
|
227
|
+
<Trash2 class="text-destructive h-3.5 w-3.5" />
|
|
228
|
+
<span class="sr-only">Delete</span>
|
|
229
|
+
</Button>
|
|
230
|
+
{/if}
|
|
231
|
+
</div>
|
|
232
|
+
{/if}
|
|
233
|
+
</div>
|
|
234
|
+
|
|
235
|
+
<Separator class="my-4" />
|
|
236
|
+
|
|
237
|
+
<div class="grid gap-4 sm:grid-cols-2">
|
|
238
|
+
{#each groupedCapabilities() as group (group.title)}
|
|
239
|
+
<div class="space-y-2">
|
|
240
|
+
<p class="text-muted-foreground text-xs font-medium">{group.title}</p>
|
|
241
|
+
<div class="flex flex-wrap gap-1.5">
|
|
242
|
+
{#each group.items as def (def.id)}
|
|
243
|
+
{@const enabled = role.capabilities.includes(def.id)}
|
|
244
|
+
<Badge
|
|
245
|
+
variant={enabled ? 'secondary' : 'outline'}
|
|
246
|
+
class={enabled
|
|
247
|
+
? 'bg-primary/10 text-primary border-primary/20 text-xs font-normal'
|
|
248
|
+
: 'bg-muted/20 text-muted-foreground/60 text-xs font-normal'}
|
|
249
|
+
>
|
|
250
|
+
{def.title}
|
|
251
|
+
</Badge>
|
|
252
|
+
{/each}
|
|
253
|
+
</div>
|
|
254
|
+
</div>
|
|
255
|
+
{/each}
|
|
256
|
+
</div>
|
|
257
|
+
</Card.Content>
|
|
258
|
+
</Card.Root>
|
|
259
|
+
{/each}
|
|
260
|
+
</div>
|
|
261
|
+
</div>
|
|
262
|
+
|
|
263
|
+
<Sheet.Root
|
|
264
|
+
open={editor.kind !== 'closed'}
|
|
265
|
+
onOpenChange={(o) => {
|
|
266
|
+
if (!o) closeEditor();
|
|
267
|
+
}}
|
|
268
|
+
>
|
|
269
|
+
<Sheet.Content class="flex w-full flex-col gap-0 p-0 sm:max-w-lg">
|
|
270
|
+
<Sheet.Header class="border-b p-6">
|
|
271
|
+
<Sheet.Title>
|
|
272
|
+
{editor.kind === 'create'
|
|
273
|
+
? 'Create role'
|
|
274
|
+
: `Edit "${editor.kind === 'edit' ? editor.role.name : ''}"`}
|
|
275
|
+
</Sheet.Title>
|
|
276
|
+
<Sheet.Description>
|
|
277
|
+
{#if editor.kind === 'edit' && editor.role.isBuiltIn}
|
|
278
|
+
Built-in role. Capabilities can be tuned; the name is fixed.
|
|
279
|
+
{:else}
|
|
280
|
+
Pick the capabilities this role grants. Members assigned to this role will gain every
|
|
281
|
+
checked permission.
|
|
282
|
+
{/if}
|
|
283
|
+
</Sheet.Description>
|
|
284
|
+
</Sheet.Header>
|
|
285
|
+
|
|
286
|
+
<div class="flex-1 space-y-6 overflow-y-auto p-6">
|
|
287
|
+
<div class="space-y-2">
|
|
288
|
+
<Label for="role-name">Name</Label>
|
|
289
|
+
<Input
|
|
290
|
+
id="role-name"
|
|
291
|
+
bind:value={form.name}
|
|
292
|
+
disabled={editor.kind === 'edit'}
|
|
293
|
+
placeholder="e.g. translator"
|
|
294
|
+
/>
|
|
295
|
+
{#if editor.kind === 'create'}
|
|
296
|
+
<p class="text-muted-foreground text-xs">
|
|
297
|
+
Letters, numbers, spaces, hyphens, or underscores. Used when assigning members.
|
|
298
|
+
</p>
|
|
299
|
+
{/if}
|
|
300
|
+
</div>
|
|
301
|
+
|
|
302
|
+
<div class="space-y-2">
|
|
303
|
+
<Label for="role-description">Description</Label>
|
|
304
|
+
<Textarea
|
|
305
|
+
id="role-description"
|
|
306
|
+
bind:value={form.description}
|
|
307
|
+
placeholder="What does this role do?"
|
|
308
|
+
rows={2}
|
|
309
|
+
/>
|
|
310
|
+
</div>
|
|
311
|
+
|
|
312
|
+
<Separator />
|
|
313
|
+
|
|
314
|
+
<div class="space-y-4">
|
|
315
|
+
<div class="flex items-center justify-between">
|
|
316
|
+
<Label>Capabilities</Label>
|
|
317
|
+
<span class="text-muted-foreground text-xs">
|
|
318
|
+
{form.capabilities.size} of {totalCapabilities} selected
|
|
319
|
+
</span>
|
|
320
|
+
</div>
|
|
321
|
+
|
|
322
|
+
{#each groupedCapabilities() as group (group.title)}
|
|
323
|
+
<div class="space-y-2">
|
|
324
|
+
<p class="text-muted-foreground text-xs font-semibold tracking-wider uppercase">
|
|
325
|
+
{group.title}
|
|
326
|
+
</p>
|
|
327
|
+
<div class="grid gap-2">
|
|
328
|
+
{#each group.items as def (def.id)}
|
|
329
|
+
{@const implied = isImpliedRead(def.id)}
|
|
330
|
+
<label
|
|
331
|
+
class="hover:bg-muted flex cursor-pointer items-center gap-3 rounded-md border px-3 py-2"
|
|
332
|
+
>
|
|
333
|
+
<Checkbox
|
|
334
|
+
checked={form.capabilities.has(def.id)}
|
|
335
|
+
disabled={implied}
|
|
336
|
+
onCheckedChange={(v) => toggleCapability(def.id, v === true)}
|
|
337
|
+
/>
|
|
338
|
+
<div class="flex-1">
|
|
339
|
+
<p class="text-sm font-medium">{def.title}</p>
|
|
340
|
+
{#if def.description}
|
|
341
|
+
<p class="text-muted-foreground text-xs">{def.description}</p>
|
|
342
|
+
{/if}
|
|
343
|
+
<p class="text-muted-foreground/70 font-mono text-[10px]">{def.id}</p>
|
|
344
|
+
</div>
|
|
345
|
+
</label>
|
|
346
|
+
{/each}
|
|
347
|
+
</div>
|
|
348
|
+
</div>
|
|
349
|
+
{/each}
|
|
350
|
+
</div>
|
|
351
|
+
</div>
|
|
352
|
+
|
|
353
|
+
<div class="flex items-center justify-end gap-2 border-t p-6">
|
|
354
|
+
<Button variant="outline" onclick={closeEditor} disabled={saving}>Cancel</Button>
|
|
355
|
+
<Button onclick={save} disabled={saving}>
|
|
356
|
+
{saving ? 'Saving...' : editor.kind === 'create' ? 'Create role' : 'Save changes'}
|
|
357
|
+
</Button>
|
|
358
|
+
</div>
|
|
359
|
+
</Sheet.Content>
|
|
360
|
+
</Sheet.Root>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CapabilityDefinition, Role } from '../../types/capabilities.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
roles: Role[];
|
|
4
|
+
capabilityCatalog: CapabilityDefinition[];
|
|
5
|
+
/** Count of members per role name, pre-computed server-side. */
|
|
6
|
+
roleMemberCounts: Record<string, number>;
|
|
7
|
+
}
|
|
8
|
+
declare const RolesSettings: import("svelte").Component<Props, {}, "">;
|
|
9
|
+
type RolesSettings = ReturnType<typeof RolesSettings>;
|
|
10
|
+
export default RolesSettings;
|
|
11
|
+
//# sourceMappingURL=RolesSettings.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RolesSettings.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/admin/RolesSettings.svelte.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAO1E,UAAU,KAAK;IACd,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,iBAAiB,EAAE,oBAAoB,EAAE,CAAC;IAC1C,gEAAgE;IAChE,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC;AAqUF,QAAA,MAAM,aAAa,2CAAwC,CAAC;AAC5D,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACtD,eAAe,aAAa,CAAC"}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
isFieldRequired,
|
|
13
13
|
validateField,
|
|
14
14
|
getValidationClasses,
|
|
15
|
+
humanizeValidationMessage,
|
|
15
16
|
type ValidationError
|
|
16
17
|
} from '../../field-validation/utils';
|
|
17
18
|
import { isFieldVisible } from '../../schema-utils/visibility';
|
|
@@ -154,10 +155,19 @@
|
|
|
154
155
|
* branch can't block a save with an error nobody can see.
|
|
155
156
|
*/
|
|
156
157
|
const visible = $derived(isFieldVisible(field, scope, documentData));
|
|
158
|
+
|
|
159
|
+
// Validate once focus leaves the field, not only on load and after save, so a
|
|
160
|
+
// required field an editor tabs through is flagged immediately rather than
|
|
161
|
+
// staying unflagged until publish.
|
|
162
|
+
function validateOnLeave(event: FocusEvent) {
|
|
163
|
+
const wrapper = event.currentTarget as HTMLElement;
|
|
164
|
+
if (event.relatedTarget instanceof Node && wrapper.contains(event.relatedTarget)) return;
|
|
165
|
+
void performValidation(value, documentData ?? {});
|
|
166
|
+
}
|
|
157
167
|
</script>
|
|
158
168
|
|
|
159
169
|
{#if visible}
|
|
160
|
-
<div class="space-y-2" data-field-path={fieldPath}>
|
|
170
|
+
<div class="space-y-2" data-field-path={fieldPath} onfocusout={validateOnLeave}>
|
|
161
171
|
<div class="flex items-center justify-between">
|
|
162
172
|
<div class="flex items-center gap-1.5">
|
|
163
173
|
<Label for={field.name}>
|
|
@@ -213,7 +223,7 @@
|
|
|
213
223
|
: 'default'}
|
|
214
224
|
>
|
|
215
225
|
<Alert.Description class="text-xs">
|
|
216
|
-
{error.message}
|
|
226
|
+
{humanizeValidationMessage(error.message, { field, value })}
|
|
217
227
|
</Alert.Description>
|
|
218
228
|
</Alert.Root>
|
|
219
229
|
{/each}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaField.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/admin/SchemaField.svelte.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,KAAK,EAGL,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"SchemaField.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/admin/SchemaField.svelte.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,KAAK,EAGL,MAAM,qBAAqB,CAAC;AAmB9B,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAG9C,UAAU,KAAK;IACd,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,GAAG,CAAC;IACX,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACnC;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAClC,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/B,eAAe,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACrE,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CACvC;AA4NF,QAAA,MAAM,WAAW;sCA1KgC,GAAG,YAAW,GAAG;MA0KT,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Teleports its children into the settings header's action slot (provided by
|
|
4
|
+
* SettingsShell's context). A panel renders `<SettingsHeaderActions>` with a
|
|
5
|
+
* button inside; the shell displays it beside the page title. Cleared on
|
|
6
|
+
* unmount so a panel's actions don't linger on the next tab.
|
|
7
|
+
*/
|
|
8
|
+
import { getContext } from 'svelte';
|
|
9
|
+
import type { Snippet } from 'svelte';
|
|
10
|
+
import {
|
|
11
|
+
settingsHeaderActionContextKey,
|
|
12
|
+
type SettingsHeaderActionContext
|
|
13
|
+
} from '../../admin/settings-header-actions';
|
|
14
|
+
|
|
15
|
+
let { children }: { children: Snippet } = $props();
|
|
16
|
+
|
|
17
|
+
const context = getContext<SettingsHeaderActionContext | undefined>(
|
|
18
|
+
settingsHeaderActionContextKey
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
$effect(() => {
|
|
22
|
+
context?.setActions(children);
|
|
23
|
+
return () => context?.setActions(null);
|
|
24
|
+
});
|
|
25
|
+
</script>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
children: Snippet;
|
|
4
|
+
};
|
|
5
|
+
declare const SettingsHeaderActions: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
6
|
+
type SettingsHeaderActions = ReturnType<typeof SettingsHeaderActions>;
|
|
7
|
+
export default SettingsHeaderActions;
|
|
8
|
+
//# sourceMappingURL=SettingsHeaderActions.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SettingsHeaderActions.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/admin/SettingsHeaderActions.svelte.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAMrC,KAAK,gBAAgB,GAAI;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC;AAqBhD,QAAA,MAAM,qBAAqB,sDAAwC,CAAC;AACpE,KAAK,qBAAqB,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACtE,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* SettingsShell — the chrome shared by every settings panel: the section
|
|
4
|
+
* tab bar, the page title/description, and a header-action slot panels can
|
|
5
|
+
* fill. Rendered by `AphexStudio` for `view === 'settings'`, so the embedded
|
|
6
|
+
* admin owns settings navigation instead of each host carrying a
|
|
7
|
+
* `settings/+layout.svelte`.
|
|
8
|
+
*
|
|
9
|
+
* Capabilities come from the permissions context `AphexStudio` publishes.
|
|
10
|
+
*/
|
|
11
|
+
import { page } from '$app/state';
|
|
12
|
+
import { setContext } from 'svelte';
|
|
13
|
+
import type { Snippet } from 'svelte';
|
|
14
|
+
import type { Capability } from '../../types/capabilities';
|
|
15
|
+
import { usePermissions } from '../../permissions-context.svelte';
|
|
16
|
+
import {
|
|
17
|
+
settingsHeaderActionContextKey,
|
|
18
|
+
type SettingsHeaderActionContext
|
|
19
|
+
} from '../../admin/settings-header-actions';
|
|
20
|
+
|
|
21
|
+
let {
|
|
22
|
+
children,
|
|
23
|
+
organizationName = 'Organization'
|
|
24
|
+
}: { children: Snippet; organizationName?: string } = $props();
|
|
25
|
+
|
|
26
|
+
let headerActions = $state<Snippet | null>(null);
|
|
27
|
+
setContext<SettingsHeaderActionContext>(settingsHeaderActionContextKey, {
|
|
28
|
+
setActions(actions) {
|
|
29
|
+
headerActions = actions;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const basePath = '/admin/settings';
|
|
34
|
+
|
|
35
|
+
const perms = usePermissions();
|
|
36
|
+
function has(cap: Capability): boolean {
|
|
37
|
+
return perms?.can(cap) ?? false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// `requires: null` means any session (e.g. Profile, Members); a capability
|
|
41
|
+
// hides the tab from users who lack it. Mutation controls on each panel are
|
|
42
|
+
// capability-gated server-side regardless.
|
|
43
|
+
type Tab = { label: string; href: string; requires: Capability | null };
|
|
44
|
+
|
|
45
|
+
const orgTabs: Tab[] = $derived(
|
|
46
|
+
(
|
|
47
|
+
[
|
|
48
|
+
{ label: 'General', href: basePath, requires: 'org.settings' as Capability },
|
|
49
|
+
{ label: 'Members', href: `${basePath}/members`, requires: null },
|
|
50
|
+
{
|
|
51
|
+
label: 'Roles & access',
|
|
52
|
+
href: `${basePath}/roles`,
|
|
53
|
+
requires: 'role.manage' as Capability
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
label: 'Plugins',
|
|
57
|
+
href: `${basePath}/plugins`,
|
|
58
|
+
requires: 'plugin.settings.manage' as Capability
|
|
59
|
+
}
|
|
60
|
+
] satisfies Tab[]
|
|
61
|
+
).filter((t) => t.requires === null || has(t.requires))
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const accountTabs: Tab[] = $derived(
|
|
65
|
+
(
|
|
66
|
+
[
|
|
67
|
+
{ label: 'Profile', href: `${basePath}/account`, requires: null },
|
|
68
|
+
{
|
|
69
|
+
label: 'API tokens',
|
|
70
|
+
href: `${basePath}/api-keys`,
|
|
71
|
+
requires: 'apiKey.manage' as Capability
|
|
72
|
+
}
|
|
73
|
+
] satisfies Tab[]
|
|
74
|
+
).filter((t) => t.requires === null || has(t.requires))
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
function isActive(href: string) {
|
|
78
|
+
if (href === basePath) return page.url.pathname === basePath;
|
|
79
|
+
return page.url.pathname.startsWith(href);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const currentTitle = $derived.by(() => {
|
|
83
|
+
const tab = [...orgTabs, ...accountTabs].find((item) => isActive(item.href));
|
|
84
|
+
if (tab?.label === 'General') return 'Organization settings';
|
|
85
|
+
if (tab?.label === 'Profile') return 'Profile settings';
|
|
86
|
+
return tab ? `${tab.label} settings` : 'Settings';
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const currentDescription = $derived.by(() => {
|
|
90
|
+
const p = page.url.pathname;
|
|
91
|
+
if (p === basePath) return `Profile, defaults and preferences for ${organizationName}.`;
|
|
92
|
+
if (p.startsWith(`${basePath}/account`)) return 'Personal identity and account preferences.';
|
|
93
|
+
if (p.startsWith(`${basePath}/members`)) return 'Manage members and invitations.';
|
|
94
|
+
if (p.startsWith(`${basePath}/roles`)) return 'Manage role capabilities and access.';
|
|
95
|
+
if (p.startsWith(`${basePath}/api-keys`)) return 'Create and manage programmatic access.';
|
|
96
|
+
return 'Manage your organization and account.';
|
|
97
|
+
});
|
|
98
|
+
</script>
|
|
99
|
+
|
|
100
|
+
<div class="bg-background flex flex-1 flex-col overflow-y-auto">
|
|
101
|
+
<div class="mx-auto w-full max-w-7xl px-4 py-6 md:px-8">
|
|
102
|
+
<div class="min-w-0">
|
|
103
|
+
<div class="mb-5 border-b">
|
|
104
|
+
<div class="flex flex-col gap-4 pb-4 sm:flex-row sm:items-start sm:justify-between">
|
|
105
|
+
<div>
|
|
106
|
+
<h1 class="text-2xl font-semibold tracking-tight">{currentTitle}</h1>
|
|
107
|
+
<p class="text-muted-foreground mt-1 text-sm">{currentDescription}</p>
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
{#if headerActions}
|
|
111
|
+
<div class="flex shrink-0 flex-wrap items-center gap-2 sm:justify-end">
|
|
112
|
+
{@render headerActions()}
|
|
113
|
+
</div>
|
|
114
|
+
{/if}
|
|
115
|
+
</div>
|
|
116
|
+
|
|
117
|
+
<nav class="flex gap-5 overflow-x-auto text-sm" aria-label="Settings sections">
|
|
118
|
+
{#each [...orgTabs, ...accountTabs] as tab}
|
|
119
|
+
<a
|
|
120
|
+
href={tab.href}
|
|
121
|
+
class="border-b-2 px-0 pb-2.5 font-medium whitespace-nowrap transition-colors {isActive(
|
|
122
|
+
tab.href
|
|
123
|
+
)
|
|
124
|
+
? 'border-foreground text-foreground'
|
|
125
|
+
: 'text-muted-foreground hover:text-foreground border-transparent'}"
|
|
126
|
+
>
|
|
127
|
+
{tab.label}
|
|
128
|
+
</a>
|
|
129
|
+
{/each}
|
|
130
|
+
</nav>
|
|
131
|
+
</div>
|
|
132
|
+
|
|
133
|
+
{@render children()}
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
children: Snippet;
|
|
4
|
+
organizationName?: string;
|
|
5
|
+
};
|
|
6
|
+
declare const SettingsShell: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
|
+
type SettingsShell = ReturnType<typeof SettingsShell>;
|
|
8
|
+
export default SettingsShell;
|
|
9
|
+
//# sourceMappingURL=SettingsShell.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SettingsShell.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/admin/SettingsShell.svelte.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAarC,KAAK,gBAAgB,GAAI;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AA0H3E,QAAA,MAAM,aAAa,sDAAwC,CAAC;AAC5D,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACtD,eAAe,aAAa,CAAC"}
|