@jskit-ai/workspaces-web 0.2.9 → 0.2.11
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/fixtures/workspaces-components/index.html +2 -0
- package/fixtures/workspaces-components/main.js +90 -0
- package/fixtures/workspaces-components/vite.config.mjs +9 -0
- package/package.json +8 -8
- package/patterns/workspace-surfaces/example/src/composables/useWorkspaceNotFoundState.js +2 -2
- package/src/client/account-settings/accountSettingsInvitesRuntime.js +25 -7
- package/src/client/account-settings/useAccountSettingsInvitesSectionRuntime.js +11 -54
- package/src/client/browser.js +54 -0
- package/src/client/components/MembersAdminClientElement.vue +41 -111
- package/src/client/components/WorkspaceMembersClientElement.vue +17 -701
- package/src/client/components/WorkspaceSelector.vue +4 -18
- package/src/client/components/WorkspacesClientElement.vue +21 -392
- package/src/client/composables/useWorkspaceMembersActions.js +309 -0
- package/src/client/composables/useWorkspaceMembersPage.js +401 -0
- package/src/client/composables/useWorkspaceRouteContext.js +8 -3
- package/src/client/composables/useWorkspaceSurfaceId.js +15 -17
- package/src/client/composables/useWorkspacesLanding.js +386 -0
- package/src/client/lib/bootstrap.js +4 -9
- package/src/client/lib/lastWorkspace.js +7 -19
- package/src/client/lib/pendingInvites.js +53 -0
- package/src/client/lib/profileSurfaceMenuLinks.js +6 -5
- package/src/client/lib/surfaceAccessPolicy.js +18 -32
- package/src/client/lib/theme.js +8 -69
- package/src/client/lib/workspaceLinkResolver.js +9 -2
- package/src/client/lib/workspaceMembersPayloads.js +98 -0
- package/src/client/lib/workspaceSurfacePaths.js +3 -8
- package/src/client/providers/WorkspacesWebClientProvider.js +23 -22
- package/src/client/runtime/bootstrapPlacementRouteGuards.js +44 -41
- package/src/client/runtime/bootstrapPlacementRuntime.js +49 -76
- package/src/client/runtime/bootstrapPlacementRuntimeHelpers.js +6 -12
- package/src/client/support/realtimeWorkspace.js +6 -2
- package/src/client/support/runtimeNormalization.js +1 -8
- package/src/client/support/workspaceScopeSupport.js +10 -7
- package/src/client/types.js +168 -0
- package/test/bootstrapPlacementRuntime.test.js +25 -1
- package/test/pendingInvites.test.js +34 -0
- package/test/settingsPlacementContract.test.js +7 -3
- package/test/workspaceMembersPayloads.test.js +52 -0
- package/test/workspacesComponents.browser.test.js +285 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { normalizeLowerText } from "@jskit-ai/kernel/shared/support/normalize";
|
|
1
2
|
import {
|
|
2
3
|
findWorkspaceBySlug,
|
|
3
4
|
normalizeWorkspaceList
|
|
@@ -22,7 +23,6 @@ import {
|
|
|
22
23
|
import {
|
|
23
24
|
countPendingInvites,
|
|
24
25
|
normalizeWorkspaceBootstrapStatus,
|
|
25
|
-
normalizeWorkspaceSlugKey,
|
|
26
26
|
resolveRequestedWorkspaceBootstrapStatus,
|
|
27
27
|
resolveRouteState
|
|
28
28
|
} from "./bootstrapPlacementRuntimeHelpers.js";
|
|
@@ -30,42 +30,33 @@ import { resolveErrorStatusCode } from "../support/runtimeNormalization.js";
|
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* @param {object} options
|
|
33
|
-
* @param {
|
|
34
|
-
* @param {
|
|
35
|
-
* @param {
|
|
36
|
-
* @param {
|
|
37
|
-
* @param {
|
|
38
|
-
* @param {import("@jskit-ai/kernel/
|
|
33
|
+
* @param {import("../types.js").ShellBootstrapRuntime} options.bootstrapRuntime
|
|
34
|
+
* @param {import("../types.js").WorkspacePlacementRuntime} options.placementRuntime
|
|
35
|
+
* @param {import("../types.js").WorkspaceRealtime | null} options.realtime Null in an application without `client.realtime`.
|
|
36
|
+
* @param {import("@jskit-ai/kernel/client/types").ClientRouter} options.router
|
|
37
|
+
* @param {import("@jskit-ai/kernel/client/types").ClientVueApp} options.vueApp
|
|
38
|
+
* @param {import("@jskit-ai/kernel/client/types").ClientLogger} options.logger
|
|
39
39
|
*/
|
|
40
40
|
function createBootstrapPlacementRuntime({
|
|
41
41
|
bootstrapRuntime,
|
|
42
42
|
placementRuntime,
|
|
43
|
-
realtime
|
|
44
|
-
router
|
|
45
|
-
vueApp
|
|
43
|
+
realtime,
|
|
44
|
+
router,
|
|
45
|
+
vueApp,
|
|
46
46
|
logger
|
|
47
47
|
}) {
|
|
48
|
-
if (!placementRuntime || typeof placementRuntime.getContext !== "function") {
|
|
49
|
-
throw new Error("createBootstrapPlacementRuntime requires shell-web placement runtime.");
|
|
50
|
-
}
|
|
51
|
-
if (!bootstrapRuntime || typeof bootstrapRuntime.refresh !== "function") {
|
|
52
|
-
throw new Error("createBootstrapPlacementRuntime requires shell-web bootstrap runtime.");
|
|
53
|
-
}
|
|
54
|
-
|
|
55
48
|
let vuetifyThemeController = resolveVuetifyThemeController(vueApp);
|
|
56
|
-
const socket = realtime?.socket || null;
|
|
57
49
|
const cleanup = [];
|
|
58
50
|
let shutdownRequested = false;
|
|
59
51
|
let lastRouteWorkspaceSlug = resolveRouteState(placementRuntime, router).workspaceSlug;
|
|
60
52
|
let initialized = false;
|
|
61
53
|
const workspaceBootstrapStatusBySlug = new Map();
|
|
62
54
|
const workspaceBootstrapStatusListeners = new Set();
|
|
63
|
-
const root = typeof globalThis === "object" && globalThis ? globalThis : null;
|
|
64
55
|
|
|
65
56
|
const routeGuards = createBootstrapPlacementRouteGuards({
|
|
66
57
|
placementRuntime,
|
|
67
58
|
router,
|
|
68
|
-
root,
|
|
59
|
+
root: globalThis,
|
|
69
60
|
getWorkspaceBootstrapStatus: (workspaceSlug) => getWorkspaceBootstrapStatus(workspaceSlug)
|
|
70
61
|
});
|
|
71
62
|
|
|
@@ -77,7 +68,7 @@ function createBootstrapPlacementRuntime({
|
|
|
77
68
|
return String(source || "workspaces-web.bootstrap-placement").trim() || "workspaces-web.bootstrap-placement";
|
|
78
69
|
}
|
|
79
70
|
|
|
80
|
-
function shouldApplyWorkspaceColorForContextUpdate(event
|
|
71
|
+
function shouldApplyWorkspaceColorForContextUpdate(event) {
|
|
81
72
|
if (event?.type !== "context.updated") {
|
|
82
73
|
return false;
|
|
83
74
|
}
|
|
@@ -91,7 +82,7 @@ function createBootstrapPlacementRuntime({
|
|
|
91
82
|
}
|
|
92
83
|
|
|
93
84
|
function setWorkspaceBootstrapStatus(workspaceSlug = "", status = "", source = "workspaces-web.bootstrap-placement") {
|
|
94
|
-
const workspaceSlugKey =
|
|
85
|
+
const workspaceSlugKey = normalizeLowerText(workspaceSlug);
|
|
95
86
|
const normalizedStatus = normalizeWorkspaceBootstrapStatus(status);
|
|
96
87
|
if (!workspaceSlugKey || !normalizedStatus) {
|
|
97
88
|
return;
|
|
@@ -126,7 +117,7 @@ function createBootstrapPlacementRuntime({
|
|
|
126
117
|
}
|
|
127
118
|
|
|
128
119
|
function getWorkspaceBootstrapStatus(workspaceSlug = "") {
|
|
129
|
-
const workspaceSlugKey =
|
|
120
|
+
const workspaceSlugKey = normalizeLowerText(workspaceSlug);
|
|
130
121
|
if (!workspaceSlugKey) {
|
|
131
122
|
return "";
|
|
132
123
|
}
|
|
@@ -134,16 +125,13 @@ function createBootstrapPlacementRuntime({
|
|
|
134
125
|
}
|
|
135
126
|
|
|
136
127
|
function subscribeWorkspaceBootstrapStatus(listener) {
|
|
137
|
-
if (typeof listener !== "function") {
|
|
138
|
-
return () => {};
|
|
139
|
-
}
|
|
140
128
|
workspaceBootstrapStatusListeners.add(listener);
|
|
141
129
|
return () => {
|
|
142
130
|
workspaceBootstrapStatusListeners.delete(listener);
|
|
143
131
|
};
|
|
144
132
|
}
|
|
145
133
|
|
|
146
|
-
function writeWorkspacePlacementContext(payload
|
|
134
|
+
function writeWorkspacePlacementContext(payload, state = {}, source = "workspaces-web.bootstrap-placement") {
|
|
147
135
|
const availableWorkspaces = normalizeWorkspaceList(payload?.workspaces);
|
|
148
136
|
const currentWorkspace = findWorkspaceBySlug(availableWorkspaces, state.workspaceSlug);
|
|
149
137
|
const workspaceSettings =
|
|
@@ -236,8 +224,8 @@ function createBootstrapPlacementRuntime({
|
|
|
236
224
|
if (!workspace) {
|
|
237
225
|
return null;
|
|
238
226
|
}
|
|
239
|
-
const workspaceSlug =
|
|
240
|
-
if (!workspaceSlug || workspaceSlug !==
|
|
227
|
+
const workspaceSlug = normalizeLowerText(workspace.slug);
|
|
228
|
+
if (!workspaceSlug || workspaceSlug !== normalizeLowerText(routeState.workspaceSlug)) {
|
|
241
229
|
return null;
|
|
242
230
|
}
|
|
243
231
|
|
|
@@ -274,12 +262,12 @@ function createBootstrapPlacementRuntime({
|
|
|
274
262
|
);
|
|
275
263
|
}
|
|
276
264
|
|
|
277
|
-
function normalizeBootstrapRequestContext(request
|
|
265
|
+
function normalizeBootstrapRequestContext(request) {
|
|
278
266
|
const meta = request?.meta && typeof request.meta === "object" ? request.meta : {};
|
|
279
267
|
const query = request?.query && typeof request.query === "object" ? request.query : {};
|
|
280
268
|
return Object.freeze({
|
|
281
269
|
path: String(meta.path || "").trim(),
|
|
282
|
-
workspaceSlug:
|
|
270
|
+
workspaceSlug: normalizeLowerText(meta.workspaceSlug || query.workspaceSlug)
|
|
283
271
|
});
|
|
284
272
|
}
|
|
285
273
|
|
|
@@ -289,12 +277,12 @@ function createBootstrapPlacementRuntime({
|
|
|
289
277
|
if (requested.path && requested.path !== currentState.path) {
|
|
290
278
|
return false;
|
|
291
279
|
}
|
|
292
|
-
return requested.workspaceSlug ===
|
|
280
|
+
return requested.workspaceSlug === normalizeLowerText(currentState.workspaceSlug);
|
|
293
281
|
}
|
|
294
282
|
|
|
295
283
|
function resolveBootstrapRequest() {
|
|
296
284
|
const state = resolveRouteState(placementRuntime, router);
|
|
297
|
-
const workspaceSlug =
|
|
285
|
+
const workspaceSlug = normalizeLowerText(state.workspaceSlug);
|
|
298
286
|
return Object.freeze({
|
|
299
287
|
query: workspaceSlug ? Object.freeze({ workspaceSlug }) : Object.freeze({}),
|
|
300
288
|
meta: Object.freeze({
|
|
@@ -304,7 +292,7 @@ function createBootstrapPlacementRuntime({
|
|
|
304
292
|
});
|
|
305
293
|
}
|
|
306
294
|
|
|
307
|
-
async function applyBootstrapPayload({ payload
|
|
295
|
+
async function applyBootstrapPayload({ payload, reason = "manual", source = "", request = {} } = {}) {
|
|
308
296
|
if (!isCurrentRequestTarget(request)) {
|
|
309
297
|
return null;
|
|
310
298
|
}
|
|
@@ -336,7 +324,7 @@ function createBootstrapPlacementRuntime({
|
|
|
336
324
|
return payload;
|
|
337
325
|
}
|
|
338
326
|
|
|
339
|
-
async function handleBootstrapError({ error, reason = "manual", source = "", request = {} }
|
|
327
|
+
async function handleBootstrapError({ error, reason = "manual", source = "", request = {} }) {
|
|
340
328
|
if (!isCurrentRequestTarget(request)) {
|
|
341
329
|
return null;
|
|
342
330
|
}
|
|
@@ -429,48 +417,35 @@ function createBootstrapPlacementRuntime({
|
|
|
429
417
|
routeGuards.enforceSurfaceAccessForCurrentRoute();
|
|
430
418
|
enforceCurrentWorkspaceStatus();
|
|
431
419
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
if (nextWorkspaceSlug === lastRouteWorkspaceSlug) {
|
|
453
|
-
return;
|
|
454
|
-
}
|
|
455
|
-
lastRouteWorkspaceSlug = nextWorkspaceSlug;
|
|
456
|
-
void refresh("route");
|
|
457
|
-
});
|
|
458
|
-
cleanup.push(() => {
|
|
459
|
-
if (typeof removeAfterEach === "function") {
|
|
460
|
-
removeAfterEach();
|
|
461
|
-
}
|
|
462
|
-
});
|
|
463
|
-
}
|
|
420
|
+
const unsubscribePlacement = placementRuntime.subscribe((event = {}) => {
|
|
421
|
+
if (!shouldApplyWorkspaceColorForContextUpdate(event)) {
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
applyWorkspaceColorFromPlacementContext("context");
|
|
425
|
+
});
|
|
426
|
+
cleanup.push(unsubscribePlacement);
|
|
427
|
+
|
|
428
|
+
const removeAfterEach = router.afterEach(() => {
|
|
429
|
+
routeGuards.enforceSurfaceAccessForCurrentRoute();
|
|
430
|
+
applyWorkspaceColorFromPlacementContext("route");
|
|
431
|
+
enforceCurrentWorkspaceStatus();
|
|
432
|
+
const nextWorkspaceSlug = resolveRouteState(placementRuntime, router).workspaceSlug;
|
|
433
|
+
if (nextWorkspaceSlug === lastRouteWorkspaceSlug) {
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
lastRouteWorkspaceSlug = nextWorkspaceSlug;
|
|
437
|
+
void refresh("route");
|
|
438
|
+
});
|
|
439
|
+
cleanup.push(removeAfterEach);
|
|
464
440
|
|
|
465
|
-
if (
|
|
441
|
+
if (realtime) {
|
|
442
|
+
const { socket } = realtime;
|
|
466
443
|
const handleBootstrapChanged = () => {
|
|
467
444
|
void refresh("realtime");
|
|
468
445
|
};
|
|
469
446
|
socket.on("users.bootstrap.changed", handleBootstrapChanged);
|
|
470
447
|
cleanup.push(() => {
|
|
471
|
-
|
|
472
|
-
socket.off("users.bootstrap.changed", handleBootstrapChanged);
|
|
473
|
-
}
|
|
448
|
+
socket.off("users.bootstrap.changed", handleBootstrapChanged);
|
|
474
449
|
});
|
|
475
450
|
}
|
|
476
451
|
}
|
|
@@ -478,11 +453,9 @@ function createBootstrapPlacementRuntime({
|
|
|
478
453
|
function shutdown() {
|
|
479
454
|
shutdownRequested = true;
|
|
480
455
|
for (const release of cleanup.splice(0, cleanup.length)) {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
} catch {}
|
|
485
|
-
}
|
|
456
|
+
try {
|
|
457
|
+
release();
|
|
458
|
+
} catch {}
|
|
486
459
|
}
|
|
487
460
|
}
|
|
488
461
|
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
resolveRuntimePathname,
|
|
3
3
|
resolveSurfaceIdFromPlacementPathname
|
|
4
4
|
} from "@jskit-ai/shell-web/client/placement";
|
|
5
|
+
import { normalizeLowerText } from "@jskit-ai/kernel/shared/support/normalize";
|
|
5
6
|
import { parseWorkspacePathname } from "@jskit-ai/workspaces-core/shared/support/workspacePathModel";
|
|
6
7
|
import { extractWorkspaceSlugFromSurfacePathname } from "../lib/workspaceSurfacePaths.js";
|
|
7
8
|
import { httpWebClient } from "@jskit-ai/http-web/client/lib/httpClient";
|
|
@@ -13,7 +14,7 @@ import { WORKSPACE_BOOTSTRAP_STATUSES } from "./bootstrapPlacementRuntimeConstan
|
|
|
13
14
|
|
|
14
15
|
function resolveRouteState(placementRuntime, router) {
|
|
15
16
|
const context = placementRuntime.getContext();
|
|
16
|
-
const path = resolveRuntimePathname(router
|
|
17
|
+
const path = resolveRuntimePathname(router.currentRoute.value.path);
|
|
17
18
|
const surfaceId = String(resolveSurfaceIdFromPlacementPathname(context, path) || "")
|
|
18
19
|
.trim()
|
|
19
20
|
.toLowerCase();
|
|
@@ -58,18 +59,12 @@ function isGuardDenied(outcome) {
|
|
|
58
59
|
return outcome.allow === false;
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
function normalizeWorkspaceSlugKey(workspaceSlug = "") {
|
|
62
|
-
return String(workspaceSlug || "")
|
|
63
|
-
.trim()
|
|
64
|
-
.toLowerCase();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
62
|
function normalizeWorkspaceBootstrapStatus(status = "") {
|
|
68
63
|
return normalizeWorkspaceBootstrapStatusValue(status, WORKSPACE_BOOTSTRAP_STATUSES);
|
|
69
64
|
}
|
|
70
65
|
|
|
71
|
-
function resolveRequestedWorkspaceBootstrapStatus(payload
|
|
72
|
-
const normalizedWorkspaceSlug =
|
|
66
|
+
function resolveRequestedWorkspaceBootstrapStatus(payload, workspaceSlug = "") {
|
|
67
|
+
const normalizedWorkspaceSlug = normalizeLowerText(workspaceSlug);
|
|
73
68
|
if (!normalizedWorkspaceSlug) {
|
|
74
69
|
return "";
|
|
75
70
|
}
|
|
@@ -80,7 +75,7 @@ function resolveRequestedWorkspaceBootstrapStatus(payload = {}, workspaceSlug =
|
|
|
80
75
|
return "";
|
|
81
76
|
}
|
|
82
77
|
|
|
83
|
-
const requestedWorkspaceSlug =
|
|
78
|
+
const requestedWorkspaceSlug = normalizeLowerText(requestedWorkspace.slug);
|
|
84
79
|
if (!requestedWorkspaceSlug || requestedWorkspaceSlug !== normalizedWorkspaceSlug) {
|
|
85
80
|
return "";
|
|
86
81
|
}
|
|
@@ -88,7 +83,7 @@ function resolveRequestedWorkspaceBootstrapStatus(payload = {}, workspaceSlug =
|
|
|
88
83
|
return normalizeWorkspaceBootstrapStatus(requestedWorkspace.status);
|
|
89
84
|
}
|
|
90
85
|
|
|
91
|
-
function resolveAuthSignature(context
|
|
86
|
+
function resolveAuthSignature(context) {
|
|
92
87
|
const auth = context?.auth && typeof context.auth === "object" ? context.auth : {};
|
|
93
88
|
const authenticated = auth.authenticated === true ? "1" : "0";
|
|
94
89
|
const oauthDefaultProvider = String(auth.oauthDefaultProvider || "")
|
|
@@ -131,7 +126,6 @@ export {
|
|
|
131
126
|
isGuardDenied,
|
|
132
127
|
normalizeSearch,
|
|
133
128
|
normalizeWorkspaceBootstrapStatus,
|
|
134
|
-
normalizeWorkspaceSlugKey,
|
|
135
129
|
resolveAuthSignature,
|
|
136
130
|
resolveRequestedWorkspaceBootstrapStatus,
|
|
137
131
|
resolveRouteState,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { unref } from "vue";
|
|
2
2
|
|
|
3
|
-
function matchesCurrentWorkspaceEvent(payload
|
|
3
|
+
function matchesCurrentWorkspaceEvent(payload, workspaceSlug = "") {
|
|
4
4
|
const payloadWorkspaceSlug = String(payload?.workspaceSlug || "").trim();
|
|
5
5
|
if (!payloadWorkspaceSlug) {
|
|
6
6
|
return true;
|
|
@@ -9,8 +9,12 @@ function matchesCurrentWorkspaceEvent(payload = {}, workspaceSlug = "") {
|
|
|
9
9
|
return payloadWorkspaceSlug === String(workspaceSlug || "").trim();
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* What a workspace page listens with: an event for another workspace is not for it.
|
|
14
|
+
* @param {import("vue").MaybeRef<string>} workspaceSlugRef
|
|
15
|
+
*/
|
|
12
16
|
function createWorkspaceRealtimeMatcher(workspaceSlugRef) {
|
|
13
|
-
return function matchesWorkspaceRealtimeEvent({ payload
|
|
17
|
+
return function matchesWorkspaceRealtimeEvent({ payload }) {
|
|
14
18
|
return matchesCurrentWorkspaceEvent(payload, unref(workspaceSlugRef));
|
|
15
19
|
};
|
|
16
20
|
}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
function normalizeRecord(value) {
|
|
2
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
3
|
-
return {};
|
|
4
|
-
}
|
|
5
|
-
return value;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
1
|
function resolveErrorStatusCode(error) {
|
|
9
2
|
const statusCode = Number(error?.statusCode || error?.status || 0);
|
|
10
3
|
return Number.isInteger(statusCode) && statusCode > 0 ? statusCode : 0;
|
|
@@ -20,4 +13,4 @@ function normalizeWorkspaceBootstrapStatusValue(status = "", allowedStatuses = n
|
|
|
20
13
|
return allowedStatuses.has(normalizedStatus) ? normalizedStatus : "";
|
|
21
14
|
}
|
|
22
15
|
|
|
23
|
-
export {
|
|
16
|
+
export { normalizeWorkspaceBootstrapStatusValue, resolveErrorStatusCode };
|
|
@@ -7,10 +7,15 @@ import {
|
|
|
7
7
|
|
|
8
8
|
const WORKSPACES_WEB_SCOPE_SUPPORT_INJECTION_KEY = "jskit.workspaces.web.scope-support";
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The workspace a route names.
|
|
12
|
+
* @param {import("../types.js").WorkspaceRouteScopeContext} routeContext
|
|
13
|
+
* @returns {{ workspaceSlug: string }}
|
|
14
|
+
*/
|
|
15
|
+
function readWorkspaceRouteScope(routeContext) {
|
|
16
|
+
const placementContext = unref(routeContext.placementContext);
|
|
17
|
+
const currentSurfaceId = normalizeText(unref(routeContext.currentSurfaceId)).toLowerCase();
|
|
18
|
+
const routePath = normalizeText(unref(routeContext.routePath));
|
|
14
19
|
const workspaceSlug = extractWorkspaceSlugFromSurfacePathname(
|
|
15
20
|
placementContext,
|
|
16
21
|
currentSurfaceId,
|
|
@@ -28,9 +33,7 @@ function createWorkspaceScopeSupport() {
|
|
|
28
33
|
|
|
29
34
|
return Object.freeze({
|
|
30
35
|
available: tenancyMode === "personal" || tenancyMode === "workspaces",
|
|
31
|
-
readRouteScope
|
|
32
|
-
return readWorkspaceRouteScope(routeContext);
|
|
33
|
-
}
|
|
36
|
+
readRouteScope: readWorkspaceRouteScope
|
|
34
37
|
});
|
|
35
38
|
}
|
|
36
39
|
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// The values workspaces-web's client hands out and receives across files.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The placement context the shell keeps and workspaces-web writes its workspace values into.
|
|
5
|
+
* @typedef {Record<string, any>} WorkspacePlacementContext
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The part of shell-web's placement runtime workspaces-web uses.
|
|
10
|
+
* @typedef {object} WorkspacePlacementRuntime
|
|
11
|
+
* @property {() => WorkspacePlacementContext} getContext
|
|
12
|
+
* @property {(patch: object, options: { source: string }) => WorkspacePlacementContext} setContext
|
|
13
|
+
* @property {(listener: (event: { type?: string, source?: string }) => void) => () => void} subscribe Returns the unsubscribe.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The part of shell-web's bootstrap runtime workspaces-web uses.
|
|
18
|
+
* @typedef {object} ShellBootstrapRuntime
|
|
19
|
+
* @property {(reason: string) => Promise<unknown>} refresh
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The part of shell-web's `client.shell` capability workspaces-web uses.
|
|
24
|
+
* @typedef {object} WorkspaceShell
|
|
25
|
+
* @property {ShellBootstrapRuntime} bootstrap
|
|
26
|
+
* @property {{ register: (handler: object) => void }} bootstrapHandlers
|
|
27
|
+
* @property {WorkspacePlacementRuntime} placement
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The part of realtime's `client.realtime` capability workspaces-web uses.
|
|
32
|
+
* @typedef {object} WorkspaceRealtime
|
|
33
|
+
* @property {{ on: (event: string, listener: () => void) => unknown, off: (event: string, listener: () => void) => unknown }} socket
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* What decides whether the shell lets a route open: true or nothing allows it, false or `{ allow: false }` denies it.
|
|
38
|
+
* @typedef {(input: { guard?: unknown, phase?: string, context?: object }) => unknown} ShellGuardEvaluator
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* What a route's workspace is read from, as `useSurfaceRouteContext()` returns it.
|
|
43
|
+
* @typedef {object} WorkspaceRouteScopeContext
|
|
44
|
+
* @property {import("vue").MaybeRef<WorkspacePlacementContext>} placementContext
|
|
45
|
+
* @property {import("vue").MaybeRef<string>} currentSurfaceId
|
|
46
|
+
* @property {import("vue").MaybeRef<string>} routePath
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/** @typedef {ReturnType<typeof import("./runtime/bootstrapPlacementRuntime.js").createBootstrapPlacementRuntime>} WorkspaceBootstrapRuntime */
|
|
50
|
+
/** @typedef {ReturnType<typeof import("./support/workspaceScopeSupport.js").createWorkspaceScopeSupport>} WorkspaceScopeSupport */
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The `client.workspaces` capability.
|
|
54
|
+
* @typedef {object} WorkspacesClient
|
|
55
|
+
* @property {WorkspaceBootstrapRuntime} bootstrap
|
|
56
|
+
* @property {WorkspaceScopeSupport} scopeSupport
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
/** @typedef {ReturnType<typeof import("./composables/useWorkspaceRouteContext.js").useWorkspaceRouteContext>} WorkspaceRouteContext */
|
|
60
|
+
/** @typedef {ReturnType<typeof import("./composables/useWorkspaceSurfaceId.js").useWorkspaceSurfaceId>} WorkspaceSurfaceIds */
|
|
61
|
+
/** @typedef {ReturnType<typeof import("./composables/useWorkspaceMembersPage.js").useWorkspaceMembersPage>} WorkspaceMembersPage */
|
|
62
|
+
/** @typedef {ReturnType<typeof import("./composables/useWorkspaceMembersActions.js").useWorkspaceMembersActions>} WorkspaceMembersActions */
|
|
63
|
+
/** @typedef {ReturnType<typeof import("./composables/useWorkspacesLanding.js").useWorkspacesLanding>} WorkspacesLanding */
|
|
64
|
+
/** @typedef {ReturnType<typeof import("./account-settings/useAccountSettingsInvitesSectionRuntime.js").useAccountSettingsInvitesSectionRuntime>} AccountSettingsInvites */
|
|
65
|
+
/** @typedef {ReturnType<typeof import("./lib/workspaceLinkResolver.js").useWorkspaceLinkResolver>} WorkspaceLinkResolver */
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* An invitation the person can answer.
|
|
69
|
+
* @typedef {object} PendingInvite
|
|
70
|
+
* @property {string} id
|
|
71
|
+
* @property {string} token
|
|
72
|
+
* @property {string} workspaceId
|
|
73
|
+
* @property {string} workspaceSlug
|
|
74
|
+
* @property {string} workspaceName
|
|
75
|
+
* @property {string} workspaceAvatarUrl
|
|
76
|
+
* @property {string} roleSid
|
|
77
|
+
* @property {string} roleLabel
|
|
78
|
+
* @property {string} status
|
|
79
|
+
* @property {string} expiresAt
|
|
80
|
+
*/
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The answer being given to an invitation; both empty when there is none.
|
|
84
|
+
* @typedef {object} InviteAction
|
|
85
|
+
* @property {string} token
|
|
86
|
+
* @property {string} decision
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* One message the account page shows through the shell.
|
|
91
|
+
* @typedef {object} WorkspaceFeedback
|
|
92
|
+
* @property {string} message
|
|
93
|
+
* @property {string} [severity]
|
|
94
|
+
* @property {string} [channel]
|
|
95
|
+
* @property {string} [dedupeKey]
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The members page's forms.
|
|
100
|
+
* @typedef {object} MembersAdminForms
|
|
101
|
+
* @property {{ email: string, roleSid: string }} invite
|
|
102
|
+
* @property {{ invitesEnabled: boolean, invitesAvailable: boolean }} workspace
|
|
103
|
+
*/
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The members page's role choices and formatters.
|
|
107
|
+
* @typedef {object} MembersAdminOptions
|
|
108
|
+
* @property {{ title: string, value: string }[]} inviteRoleOptions
|
|
109
|
+
* @property {{ title: string, value: string }[]} memberRoleOptions
|
|
110
|
+
* @property {Record<string, string>} roleLabels
|
|
111
|
+
* @property {(roleSid: string, fallback?: string) => string} formatRole
|
|
112
|
+
* @property {(value: string) => string} formatDateTime
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* A workspace member as the members page lists it.
|
|
117
|
+
* @typedef {ReturnType<typeof import("./lib/workspaceMembersPayloads.js").normalizeMembers>[number]} WorkspaceMember
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* An invitation as the members page lists it.
|
|
122
|
+
* @typedef {ReturnType<typeof import("./lib/workspaceMembersPayloads.js").normalizeInvites>[number]} WorkspaceMemberInvite
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The members page's rows.
|
|
127
|
+
* @typedef {object} MembersAdminCollections
|
|
128
|
+
* @property {WorkspaceMember[]} members
|
|
129
|
+
* @property {WorkspaceMemberInvite[]} invites
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* What the person may do on the members page.
|
|
134
|
+
* @typedef {object} MembersAdminPermissions
|
|
135
|
+
* @property {boolean} canViewMembers
|
|
136
|
+
* @property {boolean} canInviteMembers
|
|
137
|
+
* @property {boolean} canManageMembers
|
|
138
|
+
* @property {boolean} canRevokeInvites
|
|
139
|
+
*/
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* What the members page is doing and has loaded.
|
|
143
|
+
* @typedef {object} MembersAdminStatus
|
|
144
|
+
* @property {boolean} isCreatingInvite
|
|
145
|
+
* @property {boolean} isRevokingInvite
|
|
146
|
+
* @property {boolean} isRemovingMember
|
|
147
|
+
* @property {boolean} isCopyingInviteLink
|
|
148
|
+
* @property {string} createdInviteUrl
|
|
149
|
+
* @property {string} createdInviteDeliveryStatus
|
|
150
|
+
* @property {boolean} hasLoadedWorkspaceSettings
|
|
151
|
+
* @property {boolean} hasLoadedMembersList
|
|
152
|
+
* @property {boolean} hasLoadedInviteList
|
|
153
|
+
* @property {boolean} isRefreshingWorkspaceSettings
|
|
154
|
+
* @property {boolean} isRefreshingMembersList
|
|
155
|
+
* @property {boolean} isRefreshingInviteList
|
|
156
|
+
*/
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* What the members page lets a person do.
|
|
160
|
+
* @typedef {object} MembersAdminActions
|
|
161
|
+
* @property {() => Promise<void>} submitInvite
|
|
162
|
+
* @property {() => Promise<void>} copyCreatedInviteLink
|
|
163
|
+
* @property {(inviteId: string) => Promise<void>} submitRevokeInvite
|
|
164
|
+
* @property {(member: WorkspaceMember, roleSid: string) => Promise<void>} submitMemberRoleUpdate
|
|
165
|
+
* @property {(member: WorkspaceMember) => Promise<void>} submitRemoveMember
|
|
166
|
+
*/
|
|
167
|
+
|
|
168
|
+
export {};
|
|
@@ -190,7 +190,7 @@ function createTestRuntime({
|
|
|
190
190
|
router,
|
|
191
191
|
bootstrapRuntime = createBootstrapRuntimeStub(),
|
|
192
192
|
socket = null,
|
|
193
|
-
vueApp =
|
|
193
|
+
vueApp = createVueAppWithThemeController(undefined)
|
|
194
194
|
} = {}) {
|
|
195
195
|
return createBootstrapPlacementRuntime({
|
|
196
196
|
placementRuntime,
|
|
@@ -763,6 +763,30 @@ test("bootstrap placement runtime guard wrapper preserves delegated deny outcome
|
|
|
763
763
|
assert.deepEqual(outcome, delegatedOutcome);
|
|
764
764
|
});
|
|
765
765
|
|
|
766
|
+
test("bootstrap placement runtime guard wrapper treats anything but a function in the shell slot as no guard", async () => {
|
|
767
|
+
globalThis[SHELL_GUARD_EVALUATOR_KEY] = "not a function";
|
|
768
|
+
|
|
769
|
+
const runtime = createTestRuntime({
|
|
770
|
+
placementRuntime: createPlacementRuntimeStub(),
|
|
771
|
+
router: createRouterStub("/home")
|
|
772
|
+
});
|
|
773
|
+
|
|
774
|
+
await runtime.initialize();
|
|
775
|
+
|
|
776
|
+
const evaluator = globalThis[SHELL_GUARD_EVALUATOR_KEY];
|
|
777
|
+
assert.equal(typeof evaluator, "function");
|
|
778
|
+
assert.equal(
|
|
779
|
+
evaluator({
|
|
780
|
+
guard: {},
|
|
781
|
+
context: {
|
|
782
|
+
to: { path: "/home", fullPath: "/home" },
|
|
783
|
+
location: { pathname: "/home", search: "" }
|
|
784
|
+
}
|
|
785
|
+
}),
|
|
786
|
+
true
|
|
787
|
+
);
|
|
788
|
+
});
|
|
789
|
+
|
|
766
790
|
test("bootstrap placement runtime guard wrapper blocks forbidden workspace routes and redirects nested workspace paths", async () => {
|
|
767
791
|
const placementRuntime = createPlacementRuntimeStub();
|
|
768
792
|
const router = createRouterStub("/w/acme/admin/workspace/settings?tab=general");
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { readPendingInvites } from "../src/client/lib/pendingInvites.js";
|
|
4
|
+
|
|
5
|
+
const entry = { id: "1", workspaceId: "2", workspaceSlug: "acme", token: "secret" };
|
|
6
|
+
|
|
7
|
+
test("readPendingInvites offers nothing while invitations are switched off", () => {
|
|
8
|
+
assert.deepEqual(readPendingInvites({ pendingInvites: [entry] }, false), []);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("readPendingInvites fills what a listed invitation leaves out", () => {
|
|
12
|
+
assert.deepEqual(readPendingInvites({ pendingInvites: [entry] }, true), [
|
|
13
|
+
{
|
|
14
|
+
id: "1",
|
|
15
|
+
token: "secret",
|
|
16
|
+
workspaceId: "2",
|
|
17
|
+
workspaceSlug: "acme",
|
|
18
|
+
workspaceName: "acme",
|
|
19
|
+
workspaceAvatarUrl: "",
|
|
20
|
+
roleSid: "member",
|
|
21
|
+
roleLabel: "",
|
|
22
|
+
status: "pending",
|
|
23
|
+
expiresAt: ""
|
|
24
|
+
}
|
|
25
|
+
]);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test("readPendingInvites drops an invitation nobody could answer", () => {
|
|
29
|
+
const unanswerable = [null, "text", { ...entry, id: "" }, { ...entry, workspaceSlug: " " }, { ...entry, token: "" }];
|
|
30
|
+
|
|
31
|
+
assert.deepEqual(readPendingInvites({ pendingInvites: unanswerable }, true), []);
|
|
32
|
+
assert.deepEqual(readPendingInvites({}, true), []);
|
|
33
|
+
assert.deepEqual(readPendingInvites(null, true), []);
|
|
34
|
+
});
|
|
@@ -68,11 +68,15 @@ test("workspace resource load states expose local retry actions", async () => {
|
|
|
68
68
|
test("workspace command loading follows the http-web proxyRefs contract", async () => {
|
|
69
69
|
const expectations = new Map([
|
|
70
70
|
[
|
|
71
|
-
"src/client/
|
|
72
|
-
[/isCreatingInvite: Boolean\(inviteCreateCommand\.isRunning\)
|
|
71
|
+
"src/client/composables/useWorkspaceMembersPage.js",
|
|
72
|
+
[/isCreatingInvite: Boolean\(inviteCreateCommand\.isRunning\)/]
|
|
73
73
|
],
|
|
74
74
|
[
|
|
75
|
-
"src/client/
|
|
75
|
+
"src/client/composables/useWorkspaceMembersActions.js",
|
|
76
|
+
[/inviteCreateCommand\.isRunning \|\| !canInviteMembers\.value/]
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
"src/client/composables/useWorkspacesLanding.js",
|
|
76
80
|
[/const isCreatingWorkspace = computed\(\(\) => Boolean\(createWorkspaceCommand\.isRunning\)\)/]
|
|
77
81
|
],
|
|
78
82
|
[
|