@jskit-ai/users-web 0.1.52 → 0.1.54

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 (73) hide show
  1. package/package.descriptor.mjs +14 -96
  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 -49
  31. package/test/theme.test.js +0 -56
  32. package/src/client/components/ConsoleSettingsClientElement.vue +0 -24
  33. package/src/client/components/MembersAdminClientElement.vue +0 -400
  34. package/src/client/components/UsersProfileSurfaceSwitchMenuItem.vue +0 -39
  35. package/src/client/components/UsersWorkspaceMembersMenuItem.vue +0 -36
  36. package/src/client/components/UsersWorkspacePermissionMenuItem.vue +0 -90
  37. package/src/client/components/UsersWorkspaceSelector.vue +0 -248
  38. package/src/client/components/UsersWorkspaceSettingsMenuItem.vue +0 -39
  39. package/src/client/components/UsersWorkspaceToolsWidget.vue +0 -12
  40. package/src/client/components/WorkspaceMembersClientElement.vue +0 -655
  41. package/src/client/components/WorkspaceProfileClientElement.vue +0 -116
  42. package/src/client/components/WorkspaceSettingsClientElement.vue +0 -102
  43. package/src/client/components/WorkspaceSettingsFieldsClientElement.vue +0 -265
  44. package/src/client/components/WorkspacesClientElement.vue +0 -509
  45. package/src/client/composables/account-settings/accountSettingsInvitesRuntime.js +0 -88
  46. package/src/client/composables/useBootstrapQuery.js +0 -52
  47. package/src/client/composables/useWorkspaceRouteContext.js +0 -28
  48. package/src/client/composables/useWorkspaceSurfaceId.js +0 -43
  49. package/src/client/lib/menuIcons.js +0 -210
  50. package/src/client/lib/profileSurfaceMenuLinks.js +0 -142
  51. package/src/client/lib/surfaceAccessPolicy.js +0 -350
  52. package/src/client/lib/workspaceLinkResolver.js +0 -207
  53. package/src/client/lib/workspaceSurfaceContext.js +0 -82
  54. package/src/client/lib/workspaceSurfacePaths.js +0 -163
  55. package/src/client/providers/UsersWorkspacesClientProvider.js +0 -24
  56. package/src/client/runtime/bootstrapPlacementRouteGuards.js +0 -371
  57. package/src/client/runtime/bootstrapPlacementRuntime.js +0 -463
  58. package/src/client/runtime/bootstrapPlacementRuntimeConstants.js +0 -28
  59. package/src/client/runtime/bootstrapPlacementRuntimeHelpers.js +0 -147
  60. package/src/client/support/menuLinkTarget.js +0 -93
  61. package/src/client/support/realtimeWorkspace.js +0 -21
  62. package/src/client/support/runtimeNormalization.js +0 -27
  63. package/src/client/support/workspaceQueryKeys.js +0 -15
  64. package/templates/src/components/account/settings/AccountSettingsInvitesSection.vue +0 -77
  65. package/templates/src/pages/console/settings/index.vue +0 -8
  66. package/templates/src/pages/console/settings.vue +0 -32
  67. package/test/bootstrapPlacementRuntime.test.js +0 -1095
  68. package/test/menuIcons.test.js +0 -35
  69. package/test/menuLinkTarget.test.js +0 -116
  70. package/test/profileSurfaceMenuLinks.test.js +0 -207
  71. package/test/surfaceAccessPolicy.test.js +0 -129
  72. package/test/workspaceLinkResolver.test.js +0 -61
  73. package/test/workspaceSurfacePaths.test.js +0 -39
@@ -1,90 +0,0 @@
1
- <script setup>
2
- import { computed } from "vue";
3
- import { useSurfaceRouteContext } from "../composables/useSurfaceRouteContext.js";
4
- import { hasPermission, normalizePermissionList } from "../lib/permissions.js";
5
- import { usePaths } from "../composables/usePaths.js";
6
-
7
- const props = defineProps({
8
- label: {
9
- type: String,
10
- default: ""
11
- },
12
- to: {
13
- type: String,
14
- default: ""
15
- },
16
- icon: {
17
- type: String,
18
- default: ""
19
- },
20
- surface: {
21
- type: String,
22
- default: "*"
23
- },
24
- path: {
25
- type: String,
26
- default: "/"
27
- },
28
- permissions: {
29
- type: [Array, String],
30
- default: () => []
31
- }
32
- });
33
-
34
- const { placementContext, currentSurfaceId } = useSurfaceRouteContext();
35
- const paths = usePaths();
36
-
37
- function normalizeRequiredPermissions(value) {
38
- if (Array.isArray(value)) {
39
- return value
40
- .map((entry) => String(entry || "").trim())
41
- .filter(Boolean);
42
- }
43
-
44
- const normalized = String(value || "").trim();
45
- if (!normalized) {
46
- return [];
47
- }
48
-
49
- return [normalized];
50
- }
51
-
52
- const requiredPermissions = computed(() => normalizeRequiredPermissions(props.permissions));
53
-
54
- const canView = computed(() => {
55
- if (requiredPermissions.value.length < 1) {
56
- return true;
57
- }
58
-
59
- const permissions = normalizePermissionList(placementContext.value?.permissions);
60
- return requiredPermissions.value.some((permission) => hasPermission(permissions, permission));
61
- });
62
-
63
- const resolvedTo = computed(() => {
64
- const explicitTo = String(props.to || "").trim();
65
- if (explicitTo) {
66
- return explicitTo;
67
- }
68
-
69
- const explicitSurface = String(props.surface || "").trim().toLowerCase();
70
- const targetSurfaceId =
71
- explicitSurface && explicitSurface !== "*"
72
- ? explicitSurface
73
- : String(currentSurfaceId.value || "").trim().toLowerCase();
74
- const targetPath = String(props.path || "/").trim() || "/";
75
-
76
- return paths.page(targetPath, {
77
- surface: targetSurfaceId,
78
- mode: "auto"
79
- });
80
- });
81
- </script>
82
-
83
- <template>
84
- <v-list-item
85
- v-if="canView && resolvedTo"
86
- :title="props.label"
87
- :to="resolvedTo"
88
- :prepend-icon="props.icon || undefined"
89
- />
90
- </template>
@@ -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>