@aphexcms/cms-core 11.3.0 → 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 +5 -4
- package/dist/api/organizations.d.ts.map +1 -1
- package/dist/api/organizations.js +2 -3
- 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 +16 -0
- package/dist/client/ui.d.ts.map +1 -1
- package/dist/client/ui.js +26 -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 +92 -22
- 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 +25 -3
- package/dist/components/admin/MembersSettings.svelte.d.ts +5 -1
- package/dist/components/admin/MembersSettings.svelte.d.ts.map +1 -1
- 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 +2 -1
- 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/richtext/PortableTextImageView.svelte +3 -2
- package/dist/components/admin/fields/richtext/RichtextField.svelte +48 -6
- 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/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/utils.d.ts +29 -0
- package/dist/field-validation/utils.d.ts.map +1 -1
- package/dist/field-validation/utils.js +138 -5
- 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 +25 -7
- 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 +7 -5
- package/dist/local-api/types.d.ts +1 -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 +1 -1
- 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 +10 -3
- package/dist/server/api/openapi/registry.d.ts.map +1 -1
- package/dist/server/api/openapi/registry.js +62 -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.map +1 -1
- package/dist/server/api/routes/organizations-team.js +2 -52
- 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 +1 -1
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +46 -39
- package/package.json +19 -29
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AdminPageData } from '../admin/view-data.js';
|
|
2
|
+
import type { AphexClientConfig } from '../admin/client-config.js';
|
|
3
|
+
interface Props {
|
|
4
|
+
/** SSR payload from `createAdminLoad`, discriminated by `view`. */
|
|
5
|
+
data: AdminPageData;
|
|
6
|
+
/**
|
|
7
|
+
* The client-side customization seam — schemas, plugins, block previews,
|
|
8
|
+
* the auth adapter, branding. A host exports this as `aphex.client.ts` and
|
|
9
|
+
* passes it here; the mount route file itself stays a frozen re-export.
|
|
10
|
+
*/
|
|
11
|
+
config: AphexClientConfig;
|
|
12
|
+
}
|
|
13
|
+
declare const AphexStudio: import("svelte").Component<Props, {}, "">;
|
|
14
|
+
type AphexStudio = ReturnType<typeof AphexStudio>;
|
|
15
|
+
export default AphexStudio;
|
|
16
|
+
//# sourceMappingURL=AphexStudio.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AphexStudio.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/components/AphexStudio.svelte.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAsB/D,UAAU,KAAK;IACd,mEAAmE;IACnE,IAAI,EAAE,aAAa,CAAC;IACpB;;;;OAIG;IACH,MAAM,EAAE,iBAAiB,CAAC;CAC1B;AA+MF,QAAA,MAAM,WAAW,2CAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Button } from '@aphexcms/ui/shadcn/button';
|
|
3
|
+
import { Input } from '@aphexcms/ui/shadcn/input';
|
|
4
|
+
import { Label } from '@aphexcms/ui/shadcn/label';
|
|
5
|
+
import { Badge } from '@aphexcms/ui/shadcn/badge';
|
|
6
|
+
import * as Card from '@aphexcms/ui/shadcn/card';
|
|
7
|
+
import * as Avatar from '@aphexcms/ui/shadcn/avatar';
|
|
8
|
+
import { invalidateAll } from '$app/navigation';
|
|
9
|
+
import type { CMSUser } from '../../types/user';
|
|
10
|
+
import { assets, user as userApi } from '../../api';
|
|
11
|
+
import { Lock, Upload } from '@lucide/svelte';
|
|
12
|
+
import { toast } from 'svelte-sonner';
|
|
13
|
+
|
|
14
|
+
type Props = {
|
|
15
|
+
user: CMSUser;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
let { user }: Props = $props();
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Mirrors the server's limit in `updateUserRequest` so the field stops taking
|
|
22
|
+
* input rather than failing on save. The server bound is the real one — this
|
|
23
|
+
* is only here so you find out before the round-trip.
|
|
24
|
+
*/
|
|
25
|
+
const NAME_MAX_LENGTH = 80;
|
|
26
|
+
|
|
27
|
+
let userName = $state('');
|
|
28
|
+
let userImage = $state('');
|
|
29
|
+
let isUpdating = $state(false);
|
|
30
|
+
let isUploadingImage = $state(false);
|
|
31
|
+
let isRemovingImage = $state(false);
|
|
32
|
+
let isDraggingImage = $state(false);
|
|
33
|
+
let imageDragDepth = 0;
|
|
34
|
+
let imageInput: HTMLInputElement | null = $state(null);
|
|
35
|
+
|
|
36
|
+
$effect(() => {
|
|
37
|
+
userName = user.name || '';
|
|
38
|
+
userImage = user.image || '';
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
/** Initials so an empty avatar reads as "no picture yet" rather than as a broken one. */
|
|
42
|
+
const initials = $derived(
|
|
43
|
+
(userName.trim() || user.email)
|
|
44
|
+
.split(/[\s@._-]+/)
|
|
45
|
+
.filter(Boolean)
|
|
46
|
+
.slice(0, 2)
|
|
47
|
+
.map((part) => part[0]?.toUpperCase() ?? '')
|
|
48
|
+
.join('')
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
function getRoleBadgeVariant(role: string): 'default' | 'secondary' | 'outline' | 'destructive' {
|
|
52
|
+
switch (role) {
|
|
53
|
+
case 'super_admin':
|
|
54
|
+
return 'default';
|
|
55
|
+
case 'admin':
|
|
56
|
+
return 'secondary';
|
|
57
|
+
default:
|
|
58
|
+
return 'outline';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function formatRole(role: string): string {
|
|
63
|
+
return role.replace(/_/g, ' ');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function updateProfile() {
|
|
67
|
+
if (!userName.trim()) {
|
|
68
|
+
toast.error('Please enter your name');
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
isUpdating = true;
|
|
73
|
+
try {
|
|
74
|
+
const result = await userApi.updateProfile({
|
|
75
|
+
name: userName.trim(),
|
|
76
|
+
image: userImage || null
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
if (!result.success) {
|
|
80
|
+
throw new Error(result.error || result.message || 'Failed to update profile');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
toast.success('Profile updated successfully');
|
|
84
|
+
await invalidateAll();
|
|
85
|
+
} catch (error) {
|
|
86
|
+
toast.error(error instanceof Error ? error.message : 'Failed to update profile');
|
|
87
|
+
} finally {
|
|
88
|
+
isUpdating = false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Avatars are stored as the CDN path `/media/<id>/<filename>` rather than the
|
|
94
|
+
* storage adapter's direct URL. Two reasons: the asset id stays recoverable
|
|
95
|
+
* from the profile field, which is what makes replace and remove able to
|
|
96
|
+
* clean up after themselves instead of orphaning images in object storage;
|
|
97
|
+
* and reads go through the asset route, so tightening access later is a
|
|
98
|
+
* change there rather than a migration of every stored URL.
|
|
99
|
+
*/
|
|
100
|
+
function avatarPath(asset: { id: string; originalFilename: string }): string {
|
|
101
|
+
return `/media/${asset.id}/${encodeURIComponent(asset.originalFilename)}`;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function uploadProfileImage(file: File) {
|
|
105
|
+
if (!file.type.startsWith('image/')) {
|
|
106
|
+
toast.error('Please choose an image file');
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const previous = userImage;
|
|
111
|
+
|
|
112
|
+
isUploadingImage = true;
|
|
113
|
+
try {
|
|
114
|
+
const formData = new FormData();
|
|
115
|
+
formData.append('file', file);
|
|
116
|
+
formData.append('title', `${user.name || user.email} avatar`);
|
|
117
|
+
formData.append('fieldPath', 'user.image');
|
|
118
|
+
formData.append('system', 'true');
|
|
119
|
+
formData.append('usage', 'user-avatar');
|
|
120
|
+
formData.append(
|
|
121
|
+
'allowedMimeTypes',
|
|
122
|
+
JSON.stringify(['image/jpeg', 'image/png', 'image/webp', 'image/gif'])
|
|
123
|
+
);
|
|
124
|
+
formData.append('maxSize', String(5 * 1024 * 1024));
|
|
125
|
+
|
|
126
|
+
const upload = await assets.upload(formData);
|
|
127
|
+
if (!upload.success || !upload.data) {
|
|
128
|
+
throw new Error(upload.error || upload.message || 'Failed to upload avatar');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
userImage = avatarPath(upload.data);
|
|
132
|
+
// The server reaps the avatar this replaces, so there's nothing to clean up
|
|
133
|
+
// here on success. On failure the *new* asset is the orphan — the profile
|
|
134
|
+
// never moved, so the server has no idea it exists.
|
|
135
|
+
const result = await userApi.updateProfile({ image: userImage });
|
|
136
|
+
if (!result.success) {
|
|
137
|
+
await assets.delete(upload.data.id).catch(() => {});
|
|
138
|
+
userImage = previous;
|
|
139
|
+
throw new Error(result.error || result.message || 'Failed to save avatar');
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
toast.success('Avatar updated');
|
|
143
|
+
await invalidateAll();
|
|
144
|
+
} catch (error) {
|
|
145
|
+
toast.error(error instanceof Error ? error.message : 'Failed to upload avatar');
|
|
146
|
+
} finally {
|
|
147
|
+
isUploadingImage = false;
|
|
148
|
+
if (imageInput) imageInput.value = '';
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async function removeProfileImage() {
|
|
153
|
+
if (!userImage) return;
|
|
154
|
+
|
|
155
|
+
isRemovingImage = true;
|
|
156
|
+
try {
|
|
157
|
+
const result = await userApi.updateProfile({ image: null });
|
|
158
|
+
if (!result.success) {
|
|
159
|
+
throw new Error(result.error || result.message || 'Failed to remove avatar');
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
userImage = '';
|
|
163
|
+
toast.success('Avatar removed');
|
|
164
|
+
await invalidateAll();
|
|
165
|
+
} catch (error) {
|
|
166
|
+
toast.error(error instanceof Error ? error.message : 'Failed to remove avatar');
|
|
167
|
+
} finally {
|
|
168
|
+
isRemovingImage = false;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function handleImageDragEnter(event: DragEvent) {
|
|
173
|
+
event.preventDefault();
|
|
174
|
+
if (isUploadingImage || isRemovingImage || isUpdating) return;
|
|
175
|
+
imageDragDepth += 1;
|
|
176
|
+
isDraggingImage = true;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function handleImageDragOver(event: DragEvent) {
|
|
180
|
+
event.preventDefault();
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function handleImageDragLeave(event: DragEvent) {
|
|
184
|
+
event.preventDefault();
|
|
185
|
+
imageDragDepth = Math.max(0, imageDragDepth - 1);
|
|
186
|
+
if (imageDragDepth === 0) isDraggingImage = false;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function handleImageDrop(event: DragEvent) {
|
|
190
|
+
event.preventDefault();
|
|
191
|
+
imageDragDepth = 0;
|
|
192
|
+
isDraggingImage = false;
|
|
193
|
+
const file = event.dataTransfer?.files?.[0];
|
|
194
|
+
if (file) uploadProfileImage(file);
|
|
195
|
+
}
|
|
196
|
+
</script>
|
|
197
|
+
|
|
198
|
+
<div class="space-y-6">
|
|
199
|
+
<!-- Profile Information -->
|
|
200
|
+
<Card.Root>
|
|
201
|
+
<Card.Header class="flex flex-row items-start justify-between gap-4">
|
|
202
|
+
<div class="space-y-1.5">
|
|
203
|
+
<Card.Title>Identity</Card.Title>
|
|
204
|
+
<Card.Description>Your public profile inside this workspace.</Card.Description>
|
|
205
|
+
</div>
|
|
206
|
+
<Badge
|
|
207
|
+
variant={getRoleBadgeVariant(user.role)}
|
|
208
|
+
class="shrink-0 px-2.5 py-1 text-xs font-medium capitalize"
|
|
209
|
+
>
|
|
210
|
+
{formatRole(user.role)}
|
|
211
|
+
</Badge>
|
|
212
|
+
</Card.Header>
|
|
213
|
+
|
|
214
|
+
<Card.Content>
|
|
215
|
+
<!--
|
|
216
|
+
Avatar left, fields stacked right. The picture and the name are one
|
|
217
|
+
answer to "who am I here", so they sit on one row; the avatar's own
|
|
218
|
+
controls live under it rather than beside the fields, where they read
|
|
219
|
+
as actions on whatever they were nearest to.
|
|
220
|
+
-->
|
|
221
|
+
<div class="flex flex-col gap-6 sm:flex-row sm:items-start">
|
|
222
|
+
<div class="flex w-[130px] shrink-0 flex-col gap-2">
|
|
223
|
+
<button
|
|
224
|
+
type="button"
|
|
225
|
+
class="border-border bg-muted/30 group relative flex h-[130px] w-[130px] shrink-0 items-center justify-center overflow-hidden rounded-xl border transition-colors {isDraggingImage
|
|
226
|
+
? 'border-primary bg-primary/10'
|
|
227
|
+
: 'hover:bg-muted/50'}"
|
|
228
|
+
onclick={() => imageInput?.click()}
|
|
229
|
+
ondragenter={handleImageDragEnter}
|
|
230
|
+
ondragover={handleImageDragOver}
|
|
231
|
+
ondragleave={handleImageDragLeave}
|
|
232
|
+
ondrop={handleImageDrop}
|
|
233
|
+
disabled={isUploadingImage || isRemovingImage || isUpdating}
|
|
234
|
+
aria-label={userImage ? 'Replace avatar' : 'Upload avatar'}
|
|
235
|
+
>
|
|
236
|
+
<Avatar.Root class="h-full w-full rounded-xl">
|
|
237
|
+
{#if userImage}
|
|
238
|
+
<Avatar.Image src={userImage} alt={user.name || user.email} class="object-cover" />
|
|
239
|
+
{/if}
|
|
240
|
+
<Avatar.Fallback
|
|
241
|
+
class="bg-muted text-muted-foreground rounded-xl text-2xl font-medium"
|
|
242
|
+
>
|
|
243
|
+
{initials}
|
|
244
|
+
</Avatar.Fallback>
|
|
245
|
+
</Avatar.Root>
|
|
246
|
+
<div
|
|
247
|
+
class="absolute inset-0 flex items-center justify-center bg-black/45 text-xs font-medium text-white opacity-0 transition-opacity group-hover:opacity-100"
|
|
248
|
+
>
|
|
249
|
+
<span class="flex flex-col items-center gap-1.5">
|
|
250
|
+
<Upload class="h-4 w-4" />
|
|
251
|
+
{userImage ? 'Replace' : 'Upload'}
|
|
252
|
+
</span>
|
|
253
|
+
</div>
|
|
254
|
+
{#if isDraggingImage || isUploadingImage}
|
|
255
|
+
<div
|
|
256
|
+
class="bg-background/80 absolute inset-0 flex items-center justify-center text-xs font-medium"
|
|
257
|
+
>
|
|
258
|
+
{isUploadingImage ? 'Uploading...' : 'Drop image'}
|
|
259
|
+
</div>
|
|
260
|
+
{/if}
|
|
261
|
+
</button>
|
|
262
|
+
|
|
263
|
+
<input
|
|
264
|
+
bind:this={imageInput}
|
|
265
|
+
type="file"
|
|
266
|
+
accept="image/*"
|
|
267
|
+
class="hidden"
|
|
268
|
+
onchange={(event) => {
|
|
269
|
+
const file = (event.currentTarget as HTMLInputElement).files?.[0];
|
|
270
|
+
if (file) uploadProfileImage(file);
|
|
271
|
+
}}
|
|
272
|
+
/>
|
|
273
|
+
|
|
274
|
+
<Button
|
|
275
|
+
type="button"
|
|
276
|
+
variant="outline"
|
|
277
|
+
size="sm"
|
|
278
|
+
class="w-full"
|
|
279
|
+
onclick={() => imageInput?.click()}
|
|
280
|
+
disabled={isUploadingImage || isRemovingImage || isUpdating}
|
|
281
|
+
>
|
|
282
|
+
<Upload class="mr-2 h-3.5 w-3.5" />
|
|
283
|
+
{isUploadingImage ? 'Uploading…' : userImage ? 'Replace' : 'Upload'}
|
|
284
|
+
</Button>
|
|
285
|
+
{#if userImage}
|
|
286
|
+
<Button
|
|
287
|
+
type="button"
|
|
288
|
+
variant="ghost"
|
|
289
|
+
size="sm"
|
|
290
|
+
class="text-muted-foreground hover:text-destructive w-full"
|
|
291
|
+
onclick={removeProfileImage}
|
|
292
|
+
disabled={isUploadingImage || isRemovingImage || isUpdating}
|
|
293
|
+
>
|
|
294
|
+
{isRemovingImage ? 'Removing…' : 'Remove'}
|
|
295
|
+
</Button>
|
|
296
|
+
{/if}
|
|
297
|
+
</div>
|
|
298
|
+
|
|
299
|
+
<!--
|
|
300
|
+
No name/email heading beside the avatar: both are editable fields in
|
|
301
|
+
this column, and showing them twice made the card look like it was
|
|
302
|
+
reporting two things when it was reporting one thing twice.
|
|
303
|
+
-->
|
|
304
|
+
<div class="max-w-sm min-w-0 flex-1 space-y-4">
|
|
305
|
+
<div>
|
|
306
|
+
<Label for="user-name">Display Name</Label>
|
|
307
|
+
<Input
|
|
308
|
+
id="user-name"
|
|
309
|
+
bind:value={userName}
|
|
310
|
+
placeholder="Your name"
|
|
311
|
+
maxlength={NAME_MAX_LENGTH}
|
|
312
|
+
class="mt-2"
|
|
313
|
+
/>
|
|
314
|
+
</div>
|
|
315
|
+
<div>
|
|
316
|
+
<Label for="user-email">Email</Label>
|
|
317
|
+
<div class="relative mt-2">
|
|
318
|
+
<Input id="user-email" type="email" value={user.email} disabled class="pr-9" />
|
|
319
|
+
<Lock
|
|
320
|
+
class="text-muted-foreground absolute top-1/2 right-3 h-3.5 w-3.5 -translate-y-1/2"
|
|
321
|
+
/>
|
|
322
|
+
</div>
|
|
323
|
+
<p class="text-muted-foreground mt-1.5 text-xs">
|
|
324
|
+
Managed by your authentication provider
|
|
325
|
+
</p>
|
|
326
|
+
</div>
|
|
327
|
+
<p class="text-muted-foreground text-xs">
|
|
328
|
+
Drag an image onto the avatar, or choose a file. JPG, PNG, WebP, or GIF. Max 5MB.
|
|
329
|
+
</p>
|
|
330
|
+
</div>
|
|
331
|
+
</div>
|
|
332
|
+
</Card.Content>
|
|
333
|
+
<Card.Footer class="flex justify-end border-t px-6 py-4">
|
|
334
|
+
<Button onclick={updateProfile} disabled={isUpdating}>
|
|
335
|
+
{isUpdating ? 'Saving...' : 'Save changes'}
|
|
336
|
+
</Button>
|
|
337
|
+
</Card.Footer>
|
|
338
|
+
</Card.Root>
|
|
339
|
+
</div>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CMSUser } from '../../types/user.js';
|
|
2
|
+
type Props = {
|
|
3
|
+
user: CMSUser;
|
|
4
|
+
};
|
|
5
|
+
declare const AccountSettings: import("svelte").Component<Props, {}, "">;
|
|
6
|
+
type AccountSettings = ReturnType<typeof AccountSettings>;
|
|
7
|
+
export default AccountSettings;
|
|
8
|
+
//# sourceMappingURL=AccountSettings.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountSettings.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/admin/AccountSettings.svelte.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAM/C,KAAK,KAAK,GAAG;IACZ,IAAI,EAAE,OAAO,CAAC;CACd,CAAC;AA4RH,QAAA,MAAM,eAAe,2CAAwC,CAAC;AAC9D,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AAC1D,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Profile (account) settings view: identity + preferences, security (password,
|
|
4
|
+
* two-factor), and the danger zone (delete account). Core-owned; the embedded
|
|
5
|
+
* `/admin/settings/account` catch-all SSR's the profile/preferences and the
|
|
6
|
+
* `totpAvailable` flag. The password / 2FA / delete panels perform their auth
|
|
7
|
+
* mutations through the host-provided admin auth client (client-auth seam).
|
|
8
|
+
*/
|
|
9
|
+
import type { CMSUser } from '../../types/user';
|
|
10
|
+
import type { UserSessionPreferences } from '../../types/organization';
|
|
11
|
+
import AccountSettings from './AccountSettings.svelte';
|
|
12
|
+
import PreferencesSettings from './PreferencesSettings.svelte';
|
|
13
|
+
import PasswordSettings from './PasswordSettings.svelte';
|
|
14
|
+
import TwoFactorSettings from './TwoFactorSettings.svelte';
|
|
15
|
+
import DeleteAccountSettings from './DeleteAccountSettings.svelte';
|
|
16
|
+
|
|
17
|
+
interface Props {
|
|
18
|
+
user: CMSUser;
|
|
19
|
+
userPreferences: UserSessionPreferences | null;
|
|
20
|
+
hasChildOrganizations: boolean;
|
|
21
|
+
totpAvailable: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let { user, userPreferences, hasChildOrganizations, totpAvailable }: Props = $props();
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<!--
|
|
28
|
+
Only Security carries a heading. The page's own tab title already says this is
|
|
29
|
+
Profile, so repeating it would label the top section twice and the bottom one
|
|
30
|
+
once — Security earns its heading because it's the break in subject, not
|
|
31
|
+
because every group needs a title.
|
|
32
|
+
-->
|
|
33
|
+
<div class="grid gap-10">
|
|
34
|
+
<section class="grid gap-4">
|
|
35
|
+
<AccountSettings {user} />
|
|
36
|
+
<PreferencesSettings {userPreferences} {hasChildOrganizations} />
|
|
37
|
+
</section>
|
|
38
|
+
|
|
39
|
+
<section class="grid gap-4">
|
|
40
|
+
<header>
|
|
41
|
+
<h2 class="text-base font-semibold">Security</h2>
|
|
42
|
+
<p class="text-muted-foreground text-sm">How you sign in and prove it's you.</p>
|
|
43
|
+
</header>
|
|
44
|
+
|
|
45
|
+
<PasswordSettings />
|
|
46
|
+
<TwoFactorSettings {totpAvailable} />
|
|
47
|
+
</section>
|
|
48
|
+
|
|
49
|
+
<!--
|
|
50
|
+
Its own section, and last. A destructive action shouldn't sit in the same
|
|
51
|
+
visual group as the settings above it — the heading is the pause.
|
|
52
|
+
-->
|
|
53
|
+
<section class="grid gap-4">
|
|
54
|
+
<header>
|
|
55
|
+
<h2 class="text-base font-semibold">Danger zone</h2>
|
|
56
|
+
<p class="text-muted-foreground text-sm">Irreversible, and only for you.</p>
|
|
57
|
+
</header>
|
|
58
|
+
|
|
59
|
+
<DeleteAccountSettings email={user.email} />
|
|
60
|
+
</section>
|
|
61
|
+
</div>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profile (account) settings view: identity + preferences, security (password,
|
|
3
|
+
* two-factor), and the danger zone (delete account). Core-owned; the embedded
|
|
4
|
+
* `/admin/settings/account` catch-all SSR's the profile/preferences and the
|
|
5
|
+
* `totpAvailable` flag. The password / 2FA / delete panels perform their auth
|
|
6
|
+
* mutations through the host-provided admin auth client (client-auth seam).
|
|
7
|
+
*/
|
|
8
|
+
import type { CMSUser } from '../../types/user.js';
|
|
9
|
+
import type { UserSessionPreferences } from '../../types/organization.js';
|
|
10
|
+
interface Props {
|
|
11
|
+
user: CMSUser;
|
|
12
|
+
userPreferences: UserSessionPreferences | null;
|
|
13
|
+
hasChildOrganizations: boolean;
|
|
14
|
+
totpAvailable: boolean;
|
|
15
|
+
}
|
|
16
|
+
declare const AccountSettingsView: import("svelte").Component<Props, {}, "">;
|
|
17
|
+
type AccountSettingsView = ReturnType<typeof AccountSettingsView>;
|
|
18
|
+
export default AccountSettingsView;
|
|
19
|
+
//# sourceMappingURL=AccountSettingsView.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountSettingsView.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/admin/AccountSettingsView.svelte.ts"],"names":[],"mappings":"AAGA;;;;;;OAMI;AACJ,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAQtE,UAAU,KAAK;IACd,IAAI,EAAE,OAAO,CAAC;IACd,eAAe,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAC/C,qBAAqB,EAAE,OAAO,CAAC;IAC/B,aAAa,EAAE,OAAO,CAAC;CACvB;AA6CF,QAAA,MAAM,mBAAmB,2CAAwC,CAAC;AAClE,KAAK,mBAAmB,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAClE,eAAe,mBAAmB,CAAC"}
|