@jskit-ai/users-web 0.1.53 → 0.1.55

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.
Files changed (70) hide show
  1. package/package.descriptor.mjs +15 -53
  2. package/package.json +16 -11
  3. package/src/client/account-settings/sections.js +74 -0
  4. package/src/client/composables/account-settings/accountSettingsRuntimeHelpers.js +2 -38
  5. package/src/client/composables/crud/crudLookupFieldRuntime.js +2 -2
  6. package/src/client/composables/internal/crudListParentTitleSupport.js +1 -1
  7. package/src/client/composables/internal/useOperationScope.js +12 -12
  8. package/src/client/composables/records/useAddEdit.js +2 -2
  9. package/src/client/composables/records/useList.js +3 -3
  10. package/src/client/composables/records/useView.js +2 -2
  11. package/src/client/composables/support/scopeHelpers.js +19 -19
  12. package/src/client/composables/useAccess.js +3 -3
  13. package/src/client/composables/useAccountSettingsRuntime.js +8 -156
  14. package/src/client/composables/useCommand.js +2 -2
  15. package/src/client/composables/useCrudListParentTitle.js +2 -2
  16. package/src/client/composables/usePaths.js +50 -38
  17. package/src/client/composables/useScopeRuntime.js +55 -27
  18. package/src/client/composables/useSurfaceRouteContext.js +1 -7
  19. package/src/client/index.js +0 -1
  20. package/src/client/lib/bootstrap.js +0 -63
  21. package/src/client/lib/httpClient.js +2 -59
  22. package/src/client/lib/theme.js +12 -189
  23. package/src/client/providers/UsersWebClientProvider.js +2 -25
  24. package/src/client/providers/bootUsersWebClientProvider.js +28 -0
  25. package/src/shared/toolsOutletContracts.js +1 -8
  26. package/templates/src/components/account/settings/AccountSettingsClientElement.vue +33 -21
  27. package/test/accountSettingsSections.test.js +79 -0
  28. package/test/exportsContract.test.js +2 -2
  29. package/test/scopeHelpers.test.js +6 -6
  30. package/test/settingsPlacementContract.test.js +4 -11
  31. package/test/theme.test.js +0 -56
  32. package/src/client/components/MembersAdminClientElement.vue +0 -400
  33. package/src/client/components/UsersProfileSurfaceSwitchMenuItem.vue +0 -39
  34. package/src/client/components/UsersWorkspaceMembersMenuItem.vue +0 -36
  35. package/src/client/components/UsersWorkspacePermissionMenuItem.vue +0 -90
  36. package/src/client/components/UsersWorkspaceSelector.vue +0 -248
  37. package/src/client/components/UsersWorkspaceSettingsMenuItem.vue +0 -39
  38. package/src/client/components/UsersWorkspaceToolsWidget.vue +0 -12
  39. package/src/client/components/WorkspaceMembersClientElement.vue +0 -655
  40. package/src/client/components/WorkspaceProfileClientElement.vue +0 -116
  41. package/src/client/components/WorkspaceSettingsClientElement.vue +0 -102
  42. package/src/client/components/WorkspaceSettingsFieldsClientElement.vue +0 -265
  43. package/src/client/components/WorkspacesClientElement.vue +0 -509
  44. package/src/client/composables/account-settings/accountSettingsInvitesRuntime.js +0 -88
  45. package/src/client/composables/useBootstrapQuery.js +0 -52
  46. package/src/client/composables/useWorkspaceRouteContext.js +0 -28
  47. package/src/client/composables/useWorkspaceSurfaceId.js +0 -43
  48. package/src/client/lib/menuIcons.js +0 -201
  49. package/src/client/lib/profileSurfaceMenuLinks.js +0 -142
  50. package/src/client/lib/surfaceAccessPolicy.js +0 -350
  51. package/src/client/lib/workspaceLinkResolver.js +0 -207
  52. package/src/client/lib/workspaceSurfaceContext.js +0 -82
  53. package/src/client/lib/workspaceSurfacePaths.js +0 -163
  54. package/src/client/providers/UsersWorkspacesClientProvider.js +0 -24
  55. package/src/client/runtime/bootstrapPlacementRouteGuards.js +0 -371
  56. package/src/client/runtime/bootstrapPlacementRuntime.js +0 -463
  57. package/src/client/runtime/bootstrapPlacementRuntimeConstants.js +0 -28
  58. package/src/client/runtime/bootstrapPlacementRuntimeHelpers.js +0 -147
  59. package/src/client/support/menuLinkTarget.js +0 -93
  60. package/src/client/support/realtimeWorkspace.js +0 -21
  61. package/src/client/support/runtimeNormalization.js +0 -27
  62. package/src/client/support/workspaceQueryKeys.js +0 -15
  63. package/templates/src/components/account/settings/AccountSettingsInvitesSection.vue +0 -77
  64. package/test/bootstrapPlacementRuntime.test.js +0 -1095
  65. package/test/menuIcons.test.js +0 -34
  66. package/test/menuLinkTarget.test.js +0 -116
  67. package/test/profileSurfaceMenuLinks.test.js +0 -208
  68. package/test/surfaceAccessPolicy.test.js +0 -129
  69. package/test/workspaceLinkResolver.test.js +0 -61
  70. package/test/workspaceSurfacePaths.test.js +0 -39
@@ -1,248 +0,0 @@
1
- <script setup>
2
- import { computed, ref } from "vue";
3
- import { useRoute, useRouter } from "vue-router";
4
- import {
5
- useWebPlacementContext,
6
- resolveSurfaceIdFromPlacementPathname,
7
- resolveSurfaceNavigationTargetFromPlacementContext
8
- } from "@jskit-ai/shell-web/client/placement";
9
- import { TENANCY_MODE_NONE } from "@jskit-ai/users-core/shared/tenancyProfile";
10
- import { mdiBriefcaseOutline } from "@mdi/js";
11
- import { findWorkspaceBySlug, normalizeWorkspaceEntry, normalizeWorkspaceList } from "../lib/bootstrap.js";
12
- import { usePaths } from "../composables/usePaths.js";
13
- import {
14
- resolveSurfaceSwitchTargetsFromPlacementContext,
15
- surfaceRequiresWorkspaceFromPlacementContext
16
- } from "../lib/workspaceSurfaceContext.js";
17
- import {
18
- resolveWorkspaceSurfaceIdFromPlacementPathname,
19
- extractWorkspaceSlugFromSurfacePathname
20
- } from "../lib/workspaceSurfacePaths.js";
21
-
22
- const props = defineProps({
23
- surface: {
24
- type: String,
25
- default: "*"
26
- },
27
- allowOnNonWorkspaceSurface: {
28
- type: Boolean,
29
- default: false
30
- },
31
- targetSurfaceId: {
32
- type: String,
33
- default: ""
34
- }
35
- });
36
-
37
- const navigatingToWorkspace = ref("");
38
- const errorMessage = ref("");
39
- const route = useRoute();
40
- const router = useRouter();
41
- const { context: placementContext } = useWebPlacementContext();
42
- const paths = usePaths();
43
-
44
- function resolveBrowserPath() {
45
- if (typeof window !== "object" || !window || !window.location) {
46
- return "/";
47
- }
48
- const pathname = String(window.location.pathname || "").trim();
49
- return pathname || "/";
50
- }
51
-
52
- const currentPath = computed(() => {
53
- const routePath = String(route?.path || "").trim();
54
- if (routePath) {
55
- return routePath;
56
- }
57
- return resolveBrowserPath();
58
- });
59
-
60
- const currentSurfaceId = computed(() => {
61
- return (
62
- resolveWorkspaceSurfaceIdFromPlacementPathname(placementContext.value, currentPath.value) ||
63
- resolveSurfaceIdFromPlacementPathname(placementContext.value, currentPath.value) ||
64
- props.surface
65
- );
66
- });
67
-
68
- const targetSurfaceId = computed(() => String(props.targetSurfaceId || "").trim().toLowerCase());
69
- const workspaceSwitchSurfaceId = computed(() => {
70
- const normalizedCurrentSurfaceId = String(currentSurfaceId.value || "").trim().toLowerCase();
71
- if (
72
- normalizedCurrentSurfaceId &&
73
- surfaceRequiresWorkspaceFromPlacementContext(placementContext.value, normalizedCurrentSurfaceId)
74
- ) {
75
- return normalizedCurrentSurfaceId;
76
- }
77
-
78
- if (targetSurfaceId.value) {
79
- return targetSurfaceId.value;
80
- }
81
-
82
- const targets = resolveSurfaceSwitchTargetsFromPlacementContext(placementContext.value, normalizedCurrentSurfaceId);
83
- return String(targets.workspaceSurfaceId || "").trim().toLowerCase();
84
- });
85
-
86
- const routeWorkspaceSlug = computed(() => {
87
- return String(
88
- extractWorkspaceSlugFromSurfacePathname(
89
- placementContext.value,
90
- currentSurfaceId.value,
91
- currentPath.value
92
- ) || ""
93
- ).trim();
94
- });
95
-
96
- const authenticated = computed(() => Boolean(placementContext.value?.auth?.authenticated));
97
- const workspaces = computed(() => normalizeWorkspaceList(placementContext.value?.workspaces));
98
- const activeWorkspace = computed(() => {
99
- const workspaceFromRoute = findWorkspaceBySlug(workspaces.value, routeWorkspaceSlug.value);
100
- if (workspaceFromRoute) {
101
- return workspaceFromRoute;
102
- }
103
-
104
- return normalizeWorkspaceEntry(placementContext.value?.workspace);
105
- });
106
-
107
- async function navigateToWorkspace(slug) {
108
- const normalizedSlug = String(slug || "").trim();
109
- if (!normalizedSlug) {
110
- return;
111
- }
112
- if (navigatingToWorkspace.value) {
113
- return;
114
- }
115
- if (!workspaceSwitchSurfaceId.value) {
116
- errorMessage.value = "Workspace selector target surface is not configured.";
117
- return;
118
- }
119
- if (!workspaceSwitchSurfaceRequiresWorkspace.value) {
120
- errorMessage.value = "Workspace selector target surface must require a workspace.";
121
- return;
122
- }
123
-
124
- const targetPath = paths.page("/", {
125
- surface: workspaceSwitchSurfaceId.value,
126
- workspaceSlug: normalizedSlug,
127
- mode: "workspace"
128
- });
129
- if (!targetPath) {
130
- errorMessage.value = "Workspace selector target surface is not configured.";
131
- return;
132
- }
133
- const navigationTarget = resolveSurfaceNavigationTargetFromPlacementContext(placementContext.value, {
134
- path: targetPath,
135
- surfaceId: workspaceSwitchSurfaceId.value
136
- });
137
-
138
- navigatingToWorkspace.value = normalizedSlug;
139
- errorMessage.value = "";
140
-
141
- try {
142
- if (currentPath.value !== targetPath || !navigationTarget.sameOrigin) {
143
- if (navigationTarget.sameOrigin && router && typeof router.push === "function") {
144
- await router.push(navigationTarget.href);
145
- } else if (typeof window === "object" && window && window.location) {
146
- window.location.assign(navigationTarget.href);
147
- return;
148
- } else {
149
- throw new Error("Router is unavailable.");
150
- }
151
- }
152
- } catch (error) {
153
- const message = String(error?.message || "Unable to switch workspace.").trim();
154
- errorMessage.value = message;
155
- } finally {
156
- navigatingToWorkspace.value = "";
157
- }
158
- }
159
-
160
- const tenancyMode = computed(() => String(placementContext.value?.surfaceConfig?.tenancyMode || "").trim().toLowerCase());
161
- const tenancyAllowsWorkspaceRouting = computed(() => tenancyMode.value !== TENANCY_MODE_NONE);
162
-
163
- const surfaceRequiresWorkspace = computed(() =>
164
- surfaceRequiresWorkspaceFromPlacementContext(placementContext.value, currentSurfaceId.value)
165
- );
166
- const workspaceSwitchSurfaceRequiresWorkspace = computed(() =>
167
- surfaceRequiresWorkspaceFromPlacementContext(placementContext.value, workspaceSwitchSurfaceId.value)
168
- );
169
- const selectorSurfaceAllowed = computed(() => {
170
- if (surfaceRequiresWorkspace.value) {
171
- return true;
172
- }
173
- return props.allowOnNonWorkspaceSurface === true;
174
- });
175
-
176
- const isVisible = computed(
177
- () =>
178
- Boolean(workspaceSwitchSurfaceId.value) &&
179
- workspaceSwitchSurfaceRequiresWorkspace.value &&
180
- selectorSurfaceAllowed.value &&
181
- tenancyAllowsWorkspaceRouting.value &&
182
- authenticated.value &&
183
- workspaces.value.length > 0
184
- );
185
-
186
- const activeWorkspaceLabel = computed(() => {
187
- const active = activeWorkspace.value || null;
188
- if (active?.name) {
189
- return active.name;
190
- }
191
- return "Workspace";
192
- });
193
-
194
- function workspaceAvatarStyle(workspace) {
195
- const color = String(workspace?.color || "").trim();
196
- if (!/^#[0-9a-fA-F]{6}$/.test(color)) {
197
- return {};
198
- }
199
-
200
- return {
201
- backgroundColor: color
202
- };
203
- }
204
-
205
- </script>
206
-
207
- <template>
208
- <v-menu v-if="isVisible" location="bottom start" offset="8">
209
- <template #activator="{ props: activatorProps }">
210
- <v-btn
211
- v-bind="activatorProps"
212
- variant="text"
213
- class="text-none"
214
- :prepend-icon="mdiBriefcaseOutline"
215
- >
216
- {{ activeWorkspaceLabel }}
217
- </v-btn>
218
- </template>
219
-
220
- <v-list density="comfortable" min-width="280">
221
- <v-list-subheader>Workspaces</v-list-subheader>
222
- <v-list-item
223
- v-for="workspace in workspaces"
224
- :key="workspace.id"
225
- :title="workspace.name"
226
- :subtitle="`/${workspace.slug}`"
227
- :active="workspace.slug === activeWorkspace?.slug"
228
- :disabled="Boolean(navigatingToWorkspace)"
229
- @click="navigateToWorkspace(workspace.slug)"
230
- >
231
- <template #prepend>
232
- <v-avatar size="24" color="primary" variant="tonal" :style="workspaceAvatarStyle(workspace)">
233
- <span class="text-caption">{{ String(workspace.name || "W").slice(0, 1).toUpperCase() }}</span>
234
- </v-avatar>
235
- </template>
236
- <template #append>
237
- <v-progress-circular
238
- v-if="navigatingToWorkspace === workspace.slug"
239
- indeterminate
240
- size="16"
241
- width="2"
242
- />
243
- </template>
244
- </v-list-item>
245
- <v-list-item v-if="errorMessage" :subtitle="errorMessage" />
246
- </v-list>
247
- </v-menu>
248
- </template>
@@ -1,39 +0,0 @@
1
- <script setup>
2
- import { mdiCogOutline } from "@mdi/js";
3
- import UsersWorkspacePermissionMenuItem from "./UsersWorkspacePermissionMenuItem.vue";
4
-
5
- const props = defineProps({
6
- label: {
7
- type: String,
8
- default: "Workspace settings"
9
- },
10
- to: {
11
- type: String,
12
- default: ""
13
- },
14
- icon: {
15
- type: String,
16
- default: mdiCogOutline
17
- },
18
- surface: {
19
- type: String,
20
- default: "*"
21
- }
22
- });
23
-
24
- const WORKSPACE_SETTINGS_MENU_PERMISSIONS = Object.freeze([
25
- "workspace.settings.view",
26
- "workspace.settings.update"
27
- ]);
28
- </script>
29
-
30
- <template>
31
- <UsersWorkspacePermissionMenuItem
32
- :label="props.label"
33
- :to="props.to"
34
- :icon="props.icon"
35
- :surface="props.surface"
36
- path="/workspace/settings"
37
- :permissions="WORKSPACE_SETTINGS_MENU_PERMISSIONS"
38
- />
39
- </template>
@@ -1,12 +0,0 @@
1
- <script setup>
2
- import ShellOutletMenuWidget from "@jskit-ai/shell-web/client/components/ShellOutletMenuWidget";
3
- import { WORKSPACE_TOOLS_OUTLET } from "../../shared/toolsOutletContracts.js";
4
- </script>
5
-
6
- <template>
7
- <ShellOutletMenuWidget
8
- :target="WORKSPACE_TOOLS_OUTLET.target"
9
- :default-link-component-token="WORKSPACE_TOOLS_OUTLET.defaultLinkComponentToken"
10
- :aria-label="WORKSPACE_TOOLS_OUTLET.ariaLabel"
11
- />
12
- </template>