zidane-ui 9.5.3 → 9.6.1
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/adapters/index.d.ts +2 -1
- package/dist/adapters/index.js +2 -1
- package/dist/adapters/server-git-host.js +67 -0
- package/dist/adapters/server-host.js +9 -0
- package/dist/adapters/server-oauth-flow.d.ts +2 -2
- package/dist/adapters/server-oauth-flow.js +1 -1
- package/dist/adapters/server-projects.d.ts +53 -2
- package/dist/adapters/server-projects.js +4 -3
- package/dist/adapters/server-session-host.js +112 -4
- package/dist/channels/BindingEditorDialog.js +1 -1
- package/dist/channels/ChannelDefaultsSection.js +1 -1
- package/dist/channels/ChannelsSettingsSection.js +1 -1
- package/dist/channels/ConnectionSetupDialog.js +1 -1
- package/dist/channels/HeldRepliesList.js +1 -1
- package/dist/channels/ProjectChannelsSection.js +1 -1
- package/dist/chat/HostTranscript.js +1 -0
- package/dist/chat/SessionGroupHeader.js +2 -2
- package/dist/chat/composer/ComposerBadges.d.ts +27 -1
- package/dist/chat/composer/ComposerBadges.js +41 -5
- package/dist/chat/composer/ConversationBadges.d.ts +6 -0
- package/dist/chat/composer/ConversationBadges.js +70 -3
- package/dist/chat/composer/DraftPickers.js +4 -0
- package/dist/chat/composer/ServerScopeToggle.d.ts +16 -1
- package/dist/chat/composer/ServerScopeToggle.js +90 -47
- package/dist/chat/composer/index.d.ts +2 -2
- package/dist/chat/composer/use-draft-target.d.ts +18 -2
- package/dist/chat/composer/use-draft-target.js +74 -7
- package/dist/chat/composer/use-new-session-defaults.d.ts +3 -1
- package/dist/chat/composer/use-new-session-defaults.js +19 -14
- package/dist/chat/composer/use-send-prompt.js +2 -2
- package/dist/chat/headless/composer/index.d.ts +2 -2
- package/dist/chat/headless/composer/index.js +2 -2
- package/dist/chat/headless/composer/labels-chrome.d.ts +7 -0
- package/dist/chat/headless/composer/labels-chrome.js +7 -0
- package/dist/chat/headless/composer/labels-editor.d.ts +4 -0
- package/dist/chat/headless/composer/labels-editor.js +4 -0
- package/dist/chat/headless/composer/models.d.ts +2 -0
- package/dist/chat/headless/composer/new-session-defaults.d.ts +12 -1
- package/dist/chat/headless/composer/new-session-defaults.js +30 -1
- package/dist/chat/headless/draft-target.d.ts +27 -6
- package/dist/chat/headless/draft-target.js +36 -3
- package/dist/chat/headless/host.d.ts +7 -0
- package/dist/chat/headless/index.d.ts +4 -4
- package/dist/chat/headless/index.js +26 -26
- package/dist/chat/headless/labels.d.ts +4 -0
- package/dist/chat/headless/send-flow.d.ts +2 -0
- package/dist/chat/headless/send-flow.js +2 -1
- package/dist/chat/headless/session-list.d.ts +4 -0
- package/dist/chat/headless/sidebar/index.d.ts +2 -2
- package/dist/chat/headless/sidebar/labels.d.ts +9 -1
- package/dist/chat/headless/sidebar/labels.js +4 -0
- package/dist/chat/headless/sidebar/rows.d.ts +48 -7
- package/dist/chat/headless/sidebar/rows.js +121 -22
- package/dist/chat/headless/sidebar/types.d.ts +5 -0
- package/dist/chat/headless/transcript/fold-actions.d.ts +8 -3
- package/dist/chat/headless/transcript/fold-actions.js +29 -1
- package/dist/chat/index.d.ts +2 -2
- package/dist/chat/index.js +2 -2
- package/dist/chat/rich-composer/RichComposer.js +58 -11
- package/dist/chat/rich-composer/composer-controls.d.ts +5 -1
- package/dist/chat/rich-composer/composer-controls.js +4 -4
- package/dist/chat/rich-composer/composer-keys.js +2 -2
- package/dist/chat/rich-composer/draft-collab.d.ts +91 -0
- package/dist/chat/rich-composer/draft-collab.js +310 -0
- package/dist/chat/rich-composer/use-composer-editor.d.ts +2 -0
- package/dist/chat/rich-composer/use-draft-collab.d.ts +53 -0
- package/dist/chat/rich-composer/use-draft-collab.js +92 -0
- package/dist/chat/rich-composer/use-draft-mirror.d.ts +11 -0
- package/dist/chat/rich-composer/use-draft-mirror.js +38 -9
- package/dist/chat/sidebar/InboxList.js +1 -1
- package/dist/chat/sidebar/ProjectIcon.d.ts +6 -2
- package/dist/chat/sidebar/ProjectIcon.js +7 -3
- package/dist/chat/sidebar/SessionSidebar.d.ts +30 -1
- package/dist/chat/sidebar/SessionSidebar.js +79 -7
- package/dist/chat/sidebar/SidebarGroupHeader.d.ts +12 -4
- package/dist/chat/sidebar/SidebarGroupHeader.js +70 -28
- package/dist/chat/sidebar/index.d.ts +2 -2
- package/dist/chat/transcript/actions.d.ts +6 -0
- package/dist/chat/transcript/fold.d.ts +2 -1
- package/dist/chat/transcript/fold.js +26 -1
- package/dist/chat/transcript/index.js +3 -3
- package/dist/chat/transcript/notices.d.ts +5 -2
- package/dist/chat/transcript/notices.js +23 -3
- package/dist/chat/transcript/script-input.d.ts +1 -1
- package/dist/components/Avatar.d.ts +36 -0
- package/dist/components/Avatar.js +56 -0
- package/dist/components/AvatarStack.d.ts +58 -0
- package/dist/components/AvatarStack.js +187 -0
- package/dist/components/Tabs.d.ts +6 -1
- package/dist/components/Tabs.js +43 -39
- package/dist/core.css +19 -1
- package/dist/dist/{index-BsoTsm0E.d.ts → index-ChabiHpR.d.ts} +1 -1
- package/dist/dist/index.d.ts +1 -1
- package/dist/git/headless/environment.d.ts +15 -0
- package/dist/git/headless/environment.js +18 -1
- package/dist/git/headless/github.d.ts +11 -0
- package/dist/git/headless/github.js +15 -0
- package/dist/git/headless/host.d.ts +109 -0
- package/dist/git/headless/index.d.ts +5 -4
- package/dist/git/headless/index.js +4 -3
- package/dist/git/headless/labels.d.ts +16 -1
- package/dist/git/headless/labels.js +25 -1
- package/dist/git/testing/contract.d.ts +22 -4
- package/dist/git/testing/contract.js +173 -3
- package/dist/git/testing/index.d.ts +22 -1
- package/dist/git/testing/index.js +135 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/labels.d.ts +4 -0
- package/dist/labels.js +4 -0
- package/dist/onboarding/headless/labels.d.ts +4 -0
- package/dist/session/DraftPeopleStack.d.ts +24 -0
- package/dist/session/DraftPeopleStack.js +48 -0
- package/dist/session/NewProjectDialog.d.ts +28 -8
- package/dist/session/NewProjectDialog.js +225 -40
- package/dist/session/PersonCard.d.ts +29 -0
- package/dist/session/PersonCard.js +199 -0
- package/dist/session/ProjectArtifactsSection.d.ts +4 -1
- package/dist/session/ProjectArtifactsSection.js +149 -34
- package/dist/session/ProjectHome.d.ts +1 -1
- package/dist/session/ProjectHome.js +23 -4
- package/dist/session/ProjectName.d.ts +11 -6
- package/dist/session/ProjectName.js +27 -13
- package/dist/session/ProjectPeopleStack.d.ts +26 -0
- package/dist/session/ProjectPeopleStack.js +56 -0
- package/dist/session/ProjectPublishDialog.js +9 -3
- package/dist/session/ProjectSettingsDialog.d.ts +1 -1
- package/dist/session/ProjectSettingsDialog.js +171 -66
- package/dist/session/ProjectShareDialog.d.ts +1 -1
- package/dist/session/ProjectShareDialog.js +16 -6
- package/dist/session/ProjectToolsSection.js +88 -96
- package/dist/session/ProjectUsage.d.ts +4 -1
- package/dist/session/ProjectUsage.js +13 -4
- package/dist/session/SessionDetailsDialog.d.ts +5 -1
- package/dist/session/SessionDetailsDialog.js +67 -10
- package/dist/session/SessionPeopleStack.js +19 -37
- package/dist/session/SessionProjectPicker.d.ts +54 -0
- package/dist/session/SessionProjectPicker.js +175 -0
- package/dist/session/SessionProvider.d.ts +15 -1
- package/dist/session/SessionProvider.js +28 -6
- package/dist/session/UsageSection.d.ts +2 -4
- package/dist/session/UsageSection.js +57 -55
- package/dist/session/headless/draft-collab.d.ts +55 -0
- package/dist/session/headless/draft-collab.js +127 -0
- package/dist/session/headless/draft-room.d.ts +124 -0
- package/dist/session/headless/draft-room.js +340 -0
- package/dist/session/headless/drafts.d.ts +93 -0
- package/dist/session/headless/drafts.js +79 -0
- package/dist/session/headless/fixture-drafts.d.ts +54 -0
- package/dist/session/headless/fixture-drafts.js +286 -0
- package/dist/session/headless/fixture-host.d.ts +18 -2
- package/dist/session/headless/fixture-host.js +41 -7
- package/dist/session/headless/fixture-projects.d.ts +6 -4
- package/dist/session/headless/fixture-projects.js +25 -4
- package/dist/session/headless/host.d.ts +34 -6
- package/dist/session/headless/index.d.ts +6 -3
- package/dist/session/headless/index.js +6 -3
- package/dist/session/headless/labels.d.ts +47 -2
- package/dist/session/headless/labels.js +17 -1
- package/dist/session/headless/people.d.ts +27 -3
- package/dist/session/headless/people.js +38 -20
- package/dist/session/headless/project-artifact-labels.d.ts +7 -0
- package/dist/session/headless/project-artifact-labels.js +7 -0
- package/dist/session/headless/project-artifacts.d.ts +8 -0
- package/dist/session/headless/project-artifacts.js +15 -1
- package/dist/session/headless/project-labels.d.ts +25 -0
- package/dist/session/headless/project-labels.js +25 -0
- package/dist/session/headless/shared-with.d.ts +28 -0
- package/dist/session/headless/shared-with.js +51 -0
- package/dist/session/host-context.d.ts +11 -0
- package/dist/session/host-context.js +14 -0
- package/dist/session/index.d.ts +7 -3
- package/dist/session/index.js +6 -2
- package/dist/session/new-project-parts.d.ts +67 -0
- package/dist/session/new-project-parts.js +470 -0
- package/dist/session/project-artifact-parts.d.ts +2 -1
- package/dist/session/project-artifact-parts.js +5 -2
- package/dist/session/project-people.d.ts +14 -0
- package/dist/session/project-people.js +86 -0
- package/dist/session/share-people.d.ts +12 -0
- package/dist/session/share-people.js +1 -1
- package/dist/session/testing/contract.d.ts +6 -3
- package/dist/session/testing/contract.js +24 -3
- package/dist/session/testing/drafts.contract.d.ts +30 -0
- package/dist/session/testing/drafts.contract.js +126 -0
- package/dist/session/testing/index.d.ts +2 -1
- package/dist/session/testing/index.js +2 -1
- package/dist/session/use-home-projects.d.ts +11 -2
- package/dist/session/use-home-projects.js +142 -5
- package/dist/session/useDraftCollab.d.ts +24 -0
- package/dist/session/useDraftCollab.js +78 -0
- package/dist/settings/headless/search.d.ts +1 -1
- package/dist/settings/index.js +3 -3
- package/dist/settings/sections/providers/CredentialSources.d.ts +5 -5
- package/dist/settings/sections/providers/CredentialSources.js +5 -22
- package/dist/settings/sections/providers/labels.d.ts +1 -9
- package/dist/settings/sections/providers/labels.js +1 -9
- package/dist/styles.css +20 -9
- package/package.json +4 -3
- package/src/styles/sidebar.css +2 -3
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* The facts come resolved from the app (`session`: names, labels, colors);
|
|
11
11
|
* the actions are the host's (`details.generateTitle`, `export`, `compact`,
|
|
12
|
-
* `setFolder`, `titleStatus`) and the session list's (`onRename`,
|
|
12
|
+
* `setFolder`, `setProject`, `titleStatus`) and the session list's (`onRename`,
|
|
13
13
|
* `onDelete`, `onMoveToSpace`). What a host or the app leaves out is not
|
|
14
14
|
* offered.
|
|
15
15
|
*/
|
|
@@ -30,6 +30,8 @@ export type SessionFolderLocation = {
|
|
|
30
30
|
export interface SessionDetailsFacts {
|
|
31
31
|
/** The session id, shown and copied. */
|
|
32
32
|
id: string;
|
|
33
|
+
/** The session as the host's actions and its projects name it (the window's key of a server's session). Default: `id`. */
|
|
34
|
+
key?: string;
|
|
33
35
|
/** The title. */
|
|
34
36
|
title: string;
|
|
35
37
|
/** The run state. */
|
|
@@ -76,6 +78,8 @@ export interface SessionDetailsFacts {
|
|
|
76
78
|
projectRoot?: string;
|
|
77
79
|
/** The saved server the session runs on. Absent: this computer (its project shows). */
|
|
78
80
|
hostId?: string;
|
|
81
|
+
/** The project its host files it in (`SessionRow.projectId`); `null`: none on purpose, even in a project's home. Absent: the host does not say. */
|
|
82
|
+
projectId?: string | null;
|
|
79
83
|
/** The orchestration main: titled Main, folderless, everywhere. */
|
|
80
84
|
isMain?: boolean;
|
|
81
85
|
/** Where the folder is when this computer's picker can't choose it. */
|
|
@@ -5,14 +5,17 @@ import { IconButton } from "../components/IconButton.js";
|
|
|
5
5
|
import { Notice } from "../components/Notice.js";
|
|
6
6
|
import { errorMessage } from "../components/report-error.js";
|
|
7
7
|
import { Tray } from "../components/Surface.js";
|
|
8
|
+
import { Tooltip } from "../components/Tooltip.js";
|
|
8
9
|
import { useDisplayPath } from "../hooks/useDisplayPath.js";
|
|
9
10
|
import { useHydrated } from "../hooks/useHydrated.js";
|
|
10
11
|
import { SwapIcon } from "../motion/SwapIcon.js";
|
|
11
12
|
import { useSettings } from "../settings/SettingsProvider.js";
|
|
12
13
|
import { ProjectBadge, useSessionProject } from "./ProjectName.js";
|
|
13
14
|
import { useProjectSettings } from "./ProjectSettingsDialog.js";
|
|
14
|
-
import {
|
|
15
|
+
import { ProjectChoice, ProjectPicker, useFiledOrigin, useProjectChoices, useServerView } from "./SessionProjectPicker.js";
|
|
16
|
+
import { useHostProjects, useSessionHost, useSessionProjects } from "./SessionProvider.js";
|
|
15
17
|
import { ShellFrame } from "./SessionShell.js";
|
|
18
|
+
import { useProjectHomeOn } from "./use-project-home-on.js";
|
|
16
19
|
import { useSessionLabels } from "./useSessionLabels.js";
|
|
17
20
|
import { useEffect, useState } from "react";
|
|
18
21
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -32,9 +35,23 @@ const STATUS_DOT = {
|
|
|
32
35
|
function SessionDetailsDialog({ session, onRename, confirmDelete, onDelete, spaces = null, spaceId: spaceProp, onMoveToSpace, onRevealFolder, onPickFolder, folderPicker, onChanged, cache, formatError = errorMessage, onClose, renderShell, className, style }) {
|
|
33
36
|
const labels = useSessionLabels();
|
|
34
37
|
const details = useSessionHost().details;
|
|
35
|
-
const
|
|
38
|
+
const ref = session.key ?? session.id;
|
|
39
|
+
const filedProject = useSessionProject(ref, session.cwd ? session.projectRoot || session.cwd : null, session.isMain !== true, session.hostId, session.projectId);
|
|
40
|
+
const [moved, setMoved] = useState(null);
|
|
41
|
+
const setProject = details?.setProject;
|
|
42
|
+
const homeOn = useProjectHomeOn();
|
|
43
|
+
const ownProjects = useSessionProjects();
|
|
44
|
+
const serverProjects = useHostProjects(session.hostId ?? null);
|
|
45
|
+
const projectsHost = session.hostId ? serverProjects : ownProjects;
|
|
46
|
+
const choices = useProjectChoices(setProject && homeOn ? projectsHost : void 0, session.hostId !== void 0);
|
|
47
|
+
const server = useServerView(session.hostId);
|
|
48
|
+
const project = moved ? moved.projectId === null ? null : choices?.find((p) => p.id === moved.projectId) ?? filedProject : filedProject;
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (moved && (filedProject?.id ?? null) === moved.projectId) setMoved(null);
|
|
51
|
+
}, [moved, filedProject?.id]);
|
|
36
52
|
const openProjectSettings = useProjectSettings();
|
|
37
53
|
const projectId = project?.id ?? null;
|
|
54
|
+
const origin = useFiledOrigin(choices ? projectsHost : void 0, projectId, ref);
|
|
38
55
|
const [title, setTitle] = useState(session.title);
|
|
39
56
|
const [busy, setBusy] = useState(null);
|
|
40
57
|
const [error, setError] = useState(null);
|
|
@@ -47,7 +64,7 @@ function SessionDetailsDialog({ session, onRename, confirmDelete, onDelete, spac
|
|
|
47
64
|
useEffect(() => {
|
|
48
65
|
if (!titleStatusOf) return void 0;
|
|
49
66
|
let cancelled = false;
|
|
50
|
-
titleStatusOf(
|
|
67
|
+
titleStatusOf(ref).then((line) => {
|
|
51
68
|
if (!cancelled) setTitleStatus(line);
|
|
52
69
|
}).catch(() => {
|
|
53
70
|
if (!cancelled) setTitleStatus(null);
|
|
@@ -57,7 +74,7 @@ function SessionDetailsDialog({ session, onRename, confirmDelete, onDelete, spac
|
|
|
57
74
|
};
|
|
58
75
|
}, [
|
|
59
76
|
titleStatusOf,
|
|
60
|
-
|
|
77
|
+
ref,
|
|
61
78
|
session.title,
|
|
62
79
|
session.updatedAt
|
|
63
80
|
]);
|
|
@@ -84,21 +101,21 @@ function SessionDetailsDialog({ session, onRename, confirmDelete, onDelete, spac
|
|
|
84
101
|
};
|
|
85
102
|
const generate = details?.generateTitle;
|
|
86
103
|
const generateTitle = () => run("generating", async () => {
|
|
87
|
-
setTitle(await generate(
|
|
104
|
+
setTitle(await generate(ref));
|
|
88
105
|
await onChanged?.();
|
|
89
106
|
});
|
|
90
107
|
const exportTo = details?.export;
|
|
91
108
|
const exportAs = (format) => run(`exporting-${format}`, async () => {
|
|
92
|
-
setExportedPath(await exportTo(
|
|
109
|
+
setExportedPath(await exportTo(ref, format));
|
|
93
110
|
});
|
|
94
111
|
const compact = details?.compact;
|
|
95
112
|
const compactNow = () => run("compacting", async () => {
|
|
96
|
-
await compact(
|
|
113
|
+
await compact(ref);
|
|
97
114
|
await onChanged?.();
|
|
98
115
|
});
|
|
99
116
|
const setFolder = details?.setFolder;
|
|
100
117
|
const attachFolder = (picked) => run("folder", async () => {
|
|
101
|
-
await setFolder(
|
|
118
|
+
await setFolder(ref, picked);
|
|
102
119
|
await onChanged?.();
|
|
103
120
|
});
|
|
104
121
|
const changeFolder = async () => {
|
|
@@ -106,9 +123,15 @@ function SessionDetailsDialog({ session, onRename, confirmDelete, onDelete, spac
|
|
|
106
123
|
if (picked) await attachFolder(picked);
|
|
107
124
|
};
|
|
108
125
|
const detachFolder = () => run("folder", async () => {
|
|
109
|
-
await setFolder(
|
|
126
|
+
await setFolder(ref, null);
|
|
127
|
+
await onChanged?.();
|
|
128
|
+
});
|
|
129
|
+
const moveToProject = (next) => run("project", async () => {
|
|
130
|
+
await setProject(ref, next);
|
|
131
|
+
setMoved({ projectId: next });
|
|
110
132
|
await onChanged?.();
|
|
111
133
|
});
|
|
134
|
+
const projectBlocked = isMain || origin === "main" ? labels.detailsMainStays : origin === "channel" ? labels.detailsChannelStays : running ? labels.detailsStopToMove : null;
|
|
112
135
|
const revealFolder = async () => {
|
|
113
136
|
setError(null);
|
|
114
137
|
if (!await onRevealFolder?.().catch(() => false)) setError({ message: labels.detailsFolderGone(session.cwd) });
|
|
@@ -142,7 +165,7 @@ function SessionDetailsDialog({ session, onRename, confirmDelete, onDelete, spac
|
|
|
142
165
|
description: isMain ? labels.detailsMainDescription : project ? /* @__PURE__ */ jsx(ProjectBadge, {
|
|
143
166
|
name: project.name,
|
|
144
167
|
...project.icon ? { icon: project.icon } : {},
|
|
145
|
-
...projectId && openProjectSettings ? {
|
|
168
|
+
...projectId && openProjectSettings && !session.hostId ? {
|
|
146
169
|
label: labels.detailsProjectSettings(project.name),
|
|
147
170
|
onClick: () => {
|
|
148
171
|
onClose();
|
|
@@ -350,6 +373,40 @@ function SessionDetailsDialog({ session, onRename, confirmDelete, onDelete, spac
|
|
|
350
373
|
]
|
|
351
374
|
})]
|
|
352
375
|
})
|
|
376
|
+
}),
|
|
377
|
+
choices && /* @__PURE__ */ jsx(Fact, {
|
|
378
|
+
label: labels.detailsProject,
|
|
379
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
380
|
+
className: "flex flex-col gap-1.5 min-w-0",
|
|
381
|
+
children: [project && projectId && /* @__PURE__ */ jsx("span", {
|
|
382
|
+
"data-testid": "session-details-project",
|
|
383
|
+
className: "flex items-center min-h-7 min-w-0",
|
|
384
|
+
children: /* @__PURE__ */ jsx(ProjectChoice, {
|
|
385
|
+
project,
|
|
386
|
+
server
|
|
387
|
+
})
|
|
388
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
389
|
+
className: "flex flex-wrap items-center gap-2",
|
|
390
|
+
children: [/* @__PURE__ */ jsx(ProjectPicker, {
|
|
391
|
+
choices,
|
|
392
|
+
current: projectId,
|
|
393
|
+
server,
|
|
394
|
+
label: projectId ? labels.detailsChange : labels.detailsSetProject,
|
|
395
|
+
blocked: projectBlocked,
|
|
396
|
+
busy: busy === "project",
|
|
397
|
+
onPick: (next) => void moveToProject(next)
|
|
398
|
+
}), projectId && /* @__PURE__ */ jsx(Tooltip, {
|
|
399
|
+
label: projectBlocked ?? labels.detailsProjectDetachHint,
|
|
400
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
401
|
+
type: "button",
|
|
402
|
+
disabled: projectBlocked !== null || busy === "project",
|
|
403
|
+
onClick: () => void moveToProject(null),
|
|
404
|
+
className: "zg-press inline-flex items-center justify-center gap-1.5 shrink-0 whitespace-nowrap rounded-zg-md cursor-pointer transition-colors disabled:opacity-zg-disabled disabled:cursor-default zg-focus-ring h-7 px-2.5 text-zg-label zg-raised border text-[var(--zg-text-muted)] hover:text-[var(--zg-text)]",
|
|
405
|
+
children: labels.detailsDetach
|
|
406
|
+
})
|
|
407
|
+
})]
|
|
408
|
+
})]
|
|
409
|
+
})
|
|
353
410
|
})
|
|
354
411
|
] }),
|
|
355
412
|
cache && /* @__PURE__ */ jsx(FactGroup, { children: /* @__PURE__ */ jsx(Fact, {
|
|
@@ -1,37 +1,13 @@
|
|
|
1
|
+
import { Avatar } from "../components/Avatar.js";
|
|
2
|
+
import { AvatarStack } from "../components/AvatarStack.js";
|
|
1
3
|
import { HoverCard } from "../components/floating/HoverCard.js";
|
|
4
|
+
import { LabelsProvider } from "../labels.js";
|
|
2
5
|
import { useSessionHost } from "./SessionProvider.js";
|
|
3
6
|
import { useSessionLabels } from "./useSessionLabels.js";
|
|
4
|
-
import { useEffect, useState } from "react";
|
|
7
|
+
import { useEffect, useMemo, useState } from "react";
|
|
5
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
9
|
// src/session/SessionPeopleStack.tsx
|
|
7
|
-
/** The most avatars drawn; more show as "+N". */
|
|
8
|
-
const SHOWN = 3;
|
|
9
10
|
const NOBODY = [];
|
|
10
|
-
/** The first letter of a name, whole even outside the Basic Multilingual Plane (an emoji, a CJK extension). */
|
|
11
|
-
function initialOf(name) {
|
|
12
|
-
return (Array.from(name.trim())[0] ?? "?").toLocaleUpperCase();
|
|
13
|
-
}
|
|
14
|
-
/** One person: their photo, else their initial, ringed in the header's color so the stack reads as separate faces. */
|
|
15
|
-
function PersonAvatar({ person, size = "sm" }) {
|
|
16
|
-
const [failed, setFailed] = useState(false);
|
|
17
|
-
const ring = size === "sm" ? "ring-2 ring-[var(--zg-bg)]" : "";
|
|
18
|
-
const box = size === "sm" ? "size-5 text-zg-badge" : "size-7 text-zg-label";
|
|
19
|
-
if (person.avatar && !failed) return /* @__PURE__ */ jsx("img", {
|
|
20
|
-
src: person.avatar,
|
|
21
|
-
alt: "",
|
|
22
|
-
width: size === "sm" ? 20 : 28,
|
|
23
|
-
height: size === "sm" ? 20 : 28,
|
|
24
|
-
decoding: "async",
|
|
25
|
-
referrerPolicy: "no-referrer",
|
|
26
|
-
onError: () => setFailed(true),
|
|
27
|
-
className: `${box} shrink-0 rounded-full object-cover bg-[var(--zg-track)] ${ring}`
|
|
28
|
-
});
|
|
29
|
-
return /* @__PURE__ */ jsx("span", {
|
|
30
|
-
"aria-hidden": true,
|
|
31
|
-
className: `${box} shrink-0 rounded-full inline-flex items-center justify-center bg-[var(--zg-track)] font-semibold leading-none text-[var(--zg-text-muted)] select-none ${ring}`,
|
|
32
|
-
children: initialOf(person.name)
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
11
|
/**
|
|
36
12
|
* Renders who else has `sessionId` open, or nothing.
|
|
37
13
|
*
|
|
@@ -46,6 +22,12 @@ function SessionPeopleStack(props) {
|
|
|
46
22
|
if (!people) return void 0;
|
|
47
23
|
return people.watch(sessionId, setHere);
|
|
48
24
|
}, [people, sessionId]);
|
|
25
|
+
const faces = useMemo(() => here.map((person) => ({
|
|
26
|
+
id: person.userId,
|
|
27
|
+
name: person.name,
|
|
28
|
+
...person.avatar ? { avatar: person.avatar } : {}
|
|
29
|
+
})), [here]);
|
|
30
|
+
const more = useMemo(() => ({ avatarMore: labels.peopleMore }), [labels.peopleMore]);
|
|
49
31
|
if (!people || here.length === 0) return null;
|
|
50
32
|
const names = here.map((person) => person.name.trim() || labels.peopleUnnamed);
|
|
51
33
|
const line = labels.peopleHere(names);
|
|
@@ -55,18 +37,17 @@ function SessionPeopleStack(props) {
|
|
|
55
37
|
align: "end",
|
|
56
38
|
width: 280,
|
|
57
39
|
testId: "session-people-card",
|
|
58
|
-
trigger: (triggerProps) => /* @__PURE__ */
|
|
40
|
+
trigger: (triggerProps) => /* @__PURE__ */ jsx("button", {
|
|
59
41
|
type: "button",
|
|
60
42
|
...triggerProps,
|
|
61
43
|
"aria-label": line,
|
|
62
44
|
"data-testid": "session-people",
|
|
63
|
-
className: `zg-no-drag zg-focus-ring shrink-0 flex items-center
|
|
45
|
+
className: `zg-no-drag zg-focus-ring shrink-0 flex items-center px-1 rounded-full bg-transparent border-0 cursor-default ${className}`.trimEnd(),
|
|
64
46
|
style,
|
|
65
|
-
children:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
})]
|
|
47
|
+
children: /* @__PURE__ */ jsx(LabelsProvider, {
|
|
48
|
+
labels: more,
|
|
49
|
+
children: /* @__PURE__ */ jsx(AvatarStack, { people: faces })
|
|
50
|
+
})
|
|
70
51
|
}),
|
|
71
52
|
children: /* @__PURE__ */ jsxs("div", {
|
|
72
53
|
className: "p-1.5",
|
|
@@ -78,8 +59,9 @@ function SessionPeopleStack(props) {
|
|
|
78
59
|
"data-testid": "session-people-list",
|
|
79
60
|
children: here.map((person, i) => /* @__PURE__ */ jsxs("li", {
|
|
80
61
|
className: "flex items-center gap-2.5 px-2 py-1.5 min-w-0",
|
|
81
|
-
children: [/* @__PURE__ */ jsx(
|
|
82
|
-
person,
|
|
62
|
+
children: [/* @__PURE__ */ jsx(Avatar, {
|
|
63
|
+
name: person.name,
|
|
64
|
+
...person.avatar ? { avatar: person.avatar } : {},
|
|
83
65
|
size: "md"
|
|
84
66
|
}), /* @__PURE__ */ jsxs("span", {
|
|
85
67
|
className: "flex-1 min-w-0",
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { HostView } from "../chat/headless/hosts.js";
|
|
2
|
+
import { SessionProjects } from "./headless/host.js";
|
|
3
|
+
import { SessionProjectRef } from "./ProjectName.js";
|
|
4
|
+
/** A project a session can move to: a record, so it has an id. */
|
|
5
|
+
export type ProjectChoiceRef = SessionProjectRef & {
|
|
6
|
+
id: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* The projects of a session's host, named and with their icons as the sidebar shows them: `null` until read, and while
|
|
10
|
+
* `projects` is absent.
|
|
11
|
+
*
|
|
12
|
+
* @param projects - The host's projects.
|
|
13
|
+
* @param server - A server's: the window's folder icons are not theirs.
|
|
14
|
+
*/
|
|
15
|
+
export declare function useProjectChoices(projects: SessionProjects | undefined, server: boolean): readonly ProjectChoiceRef[] | null;
|
|
16
|
+
/**
|
|
17
|
+
* Where a session filed in a project came from, as its Sessions list reads it (`main`, `channel`, …): what keeps a
|
|
18
|
+
* Main or a channel thread in its project. `undefined` while unknown.
|
|
19
|
+
*
|
|
20
|
+
* @param projects - The host's projects.
|
|
21
|
+
* @param projectId - The project it is filed in.
|
|
22
|
+
* @param sessionId - The session as the host's projects name it.
|
|
23
|
+
*/
|
|
24
|
+
export declare function useFiledOrigin(projects: SessionProjects | undefined, projectId: string | null, sessionId: string): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* A saved server as its badge shows it. `undefined` for this host, or a server the app does not list.
|
|
27
|
+
*
|
|
28
|
+
* @param hostId - The server's id.
|
|
29
|
+
*/
|
|
30
|
+
export declare function useServerView(hostId: string | undefined): HostView | undefined;
|
|
31
|
+
/** A project as the row names it: its icon, its name, and its server's badge. */
|
|
32
|
+
export declare function ProjectChoice({ project, server }: {
|
|
33
|
+
project: SessionProjectRef;
|
|
34
|
+
server?: HostView | undefined;
|
|
35
|
+
}): import("react").JSX.Element;
|
|
36
|
+
interface ProjectPickerProps {
|
|
37
|
+
/** The projects to move to. */
|
|
38
|
+
choices: readonly ProjectChoiceRef[];
|
|
39
|
+
/** The project it is in, checked. */
|
|
40
|
+
current: string | null;
|
|
41
|
+
/** The server the projects are on. Absent: this host. */
|
|
42
|
+
server?: HostView | undefined;
|
|
43
|
+
/** What the button says. */
|
|
44
|
+
label: string;
|
|
45
|
+
/** Why it can't move now, in the button's tooltip; the button is then disabled. */
|
|
46
|
+
blocked?: string | null;
|
|
47
|
+
/** A move is under way. */
|
|
48
|
+
busy?: boolean;
|
|
49
|
+
/** Moves the session to a project. */
|
|
50
|
+
onPick: (projectId: string) => void;
|
|
51
|
+
}
|
|
52
|
+
/** The button that opens the menu of projects, with its filter field. */
|
|
53
|
+
export declare function ProjectPicker({ choices, current, server, label, blocked, busy, onPick }: ProjectPickerProps): import("react").JSX.Element;
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { constant, useReadable } from "../chat/headless/store.js";
|
|
2
|
+
import { HostBadge } from "../chat/HostBadge.js";
|
|
3
|
+
import { ProjectIconGlyph, useProjectIcons } from "../chat/sidebar/ProjectIcon.js";
|
|
4
|
+
import { BTN_SECONDARY } from "../components/button.js";
|
|
5
|
+
import { Popover } from "../components/floating/Popover.js";
|
|
6
|
+
import { Menu, MenuNote, MenuRow, focusMenuRow, handleMenuKeyDown } from "../components/Menu.js";
|
|
7
|
+
import { Tooltip } from "../components/Tooltip.js";
|
|
8
|
+
import { useMachinesHost } from "../machines/MachinesProvider.js";
|
|
9
|
+
import { projectIconOf } from "./ProjectName.js";
|
|
10
|
+
import { useSessionLabels } from "./useSessionLabels.js";
|
|
11
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
// src/session/SessionProjectPicker.tsx
|
|
14
|
+
const NO_PROJECTS = constant(null);
|
|
15
|
+
const NO_ROWS = constant(null);
|
|
16
|
+
const NO_HOSTS = constant({
|
|
17
|
+
enabled: false,
|
|
18
|
+
hosts: []
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* The projects of a session's host, named and with their icons as the sidebar shows them: `null` until read, and while
|
|
22
|
+
* `projects` is absent.
|
|
23
|
+
*
|
|
24
|
+
* @param projects - The host's projects.
|
|
25
|
+
* @param server - A server's: the window's folder icons are not theirs.
|
|
26
|
+
*/
|
|
27
|
+
function useProjectChoices(projects, server) {
|
|
28
|
+
useEffect(() => projects?.ensure(), [projects]);
|
|
29
|
+
const list = useReadable(projects?.list ?? NO_PROJECTS);
|
|
30
|
+
const { icons } = useProjectIcons(projects !== void 0 && !server);
|
|
31
|
+
return useMemo(() => list?.map((p) => {
|
|
32
|
+
const icon = projectIconOf(p, icons);
|
|
33
|
+
return {
|
|
34
|
+
id: p.id,
|
|
35
|
+
home: p.home ?? null,
|
|
36
|
+
name: p.name,
|
|
37
|
+
...icon ? { icon } : {}
|
|
38
|
+
};
|
|
39
|
+
}) ?? null, [list, icons]);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Where a session filed in a project came from, as its Sessions list reads it (`main`, `channel`, …): what keeps a
|
|
43
|
+
* Main or a channel thread in its project. `undefined` while unknown.
|
|
44
|
+
*
|
|
45
|
+
* @param projects - The host's projects.
|
|
46
|
+
* @param projectId - The project it is filed in.
|
|
47
|
+
* @param sessionId - The session as the host's projects name it.
|
|
48
|
+
*/
|
|
49
|
+
function useFiledOrigin(projects, projectId, sessionId) {
|
|
50
|
+
const sessions = projectId ? projects?.sessions : void 0;
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (sessions && projectId) sessions.ensure(projectId);
|
|
53
|
+
}, [sessions, projectId]);
|
|
54
|
+
return useReadable(sessions && projectId ? sessions.list(projectId) : NO_ROWS)?.find((row) => row.id === sessionId)?.origin.kind;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A saved server as its badge shows it. `undefined` for this host, or a server the app does not list.
|
|
58
|
+
*
|
|
59
|
+
* @param hostId - The server's id.
|
|
60
|
+
*/
|
|
61
|
+
function useServerView(hostId) {
|
|
62
|
+
const { hosts } = useReadable(useMachinesHost().hosts ?? NO_HOSTS);
|
|
63
|
+
return hostId === void 0 ? void 0 : hosts.find((h) => h.id === hostId && h.kind === "server");
|
|
64
|
+
}
|
|
65
|
+
/** A project as the row names it: its icon, its name, and its server's badge. */
|
|
66
|
+
function ProjectChoice({ project, server }) {
|
|
67
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
68
|
+
className: "inline-flex items-center gap-1.5 min-w-0",
|
|
69
|
+
children: [
|
|
70
|
+
/* @__PURE__ */ jsx(ProjectIconGlyph, {
|
|
71
|
+
...project.icon ? { icon: project.icon } : {},
|
|
72
|
+
server: server !== void 0,
|
|
73
|
+
className: "text-[var(--zg-text-muted)]"
|
|
74
|
+
}),
|
|
75
|
+
/* @__PURE__ */ jsx("span", {
|
|
76
|
+
dir: "auto",
|
|
77
|
+
className: "min-w-0 truncate",
|
|
78
|
+
children: project.name
|
|
79
|
+
}),
|
|
80
|
+
server && /* @__PURE__ */ jsx(HostBadge, {
|
|
81
|
+
host: server,
|
|
82
|
+
className: "min-w-0 shrink"
|
|
83
|
+
})
|
|
84
|
+
]
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/** The button that opens the menu of projects, with its filter field. */
|
|
88
|
+
function ProjectPicker({ choices, current, server, label, blocked = null, busy = false, onPick }) {
|
|
89
|
+
const labels = useSessionLabels();
|
|
90
|
+
return /* @__PURE__ */ jsx(Popover, {
|
|
91
|
+
role: "dialog",
|
|
92
|
+
ariaLabel: labels.detailsProjectMenu,
|
|
93
|
+
align: "start",
|
|
94
|
+
side: "bottom",
|
|
95
|
+
width: 300,
|
|
96
|
+
trigger: (props) => /* @__PURE__ */ jsx(Tooltip, {
|
|
97
|
+
label: blocked ?? "",
|
|
98
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
99
|
+
...props,
|
|
100
|
+
type: "button",
|
|
101
|
+
disabled: blocked !== null || busy,
|
|
102
|
+
className: BTN_SECONDARY,
|
|
103
|
+
children: label
|
|
104
|
+
})
|
|
105
|
+
}),
|
|
106
|
+
children: (close) => /* @__PURE__ */ jsx(ProjectMenu, {
|
|
107
|
+
choices,
|
|
108
|
+
current,
|
|
109
|
+
server,
|
|
110
|
+
onPick: (id) => {
|
|
111
|
+
close();
|
|
112
|
+
onPick(id);
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
function ProjectMenu({ choices, current, server, onPick }) {
|
|
118
|
+
const labels = useSessionLabels();
|
|
119
|
+
const [filter, setFilter] = useState("");
|
|
120
|
+
const rowsRef = useRef(null);
|
|
121
|
+
const needle = filter.trim().toLowerCase();
|
|
122
|
+
const shown = needle ? choices.filter((p) => p.name.toLowerCase().includes(needle)) : choices;
|
|
123
|
+
const onFilterKey = (event) => {
|
|
124
|
+
if (event.key === "ArrowDown") {
|
|
125
|
+
event.preventDefault();
|
|
126
|
+
if (rowsRef.current) focusMenuRow(rowsRef.current);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (event.key === "Enter" && shown.length === 1) {
|
|
130
|
+
event.preventDefault();
|
|
131
|
+
onPick(shown[0].id);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
return /* @__PURE__ */ jsxs(Menu, {
|
|
135
|
+
role: "group",
|
|
136
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
137
|
+
className: "p-1 pb-1.5",
|
|
138
|
+
children: /* @__PURE__ */ jsx("input", {
|
|
139
|
+
value: filter,
|
|
140
|
+
onChange: (e) => setFilter(e.target.value),
|
|
141
|
+
onKeyDown: onFilterKey,
|
|
142
|
+
placeholder: labels.detailsProjectFilter,
|
|
143
|
+
"aria-label": labels.detailsProjectFilter,
|
|
144
|
+
spellCheck: false,
|
|
145
|
+
className: "zg-well w-full h-7 px-2.5 text-zg-label placeholder:text-[var(--zg-text-subtle)]"
|
|
146
|
+
})
|
|
147
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
148
|
+
ref: rowsRef,
|
|
149
|
+
role: "menu",
|
|
150
|
+
"aria-label": labels.detailsProjectMenu,
|
|
151
|
+
tabIndex: -1,
|
|
152
|
+
onKeyDown: handleMenuKeyDown,
|
|
153
|
+
className: "flex flex-col max-h-80 overflow-y-auto",
|
|
154
|
+
children: shown.length === 0 ? /* @__PURE__ */ jsx(MenuNote, { children: labels.detailsNoProjects }) : shown.map((project) => /* @__PURE__ */ jsx(MenuRow, {
|
|
155
|
+
role: "menuitem",
|
|
156
|
+
icon: /* @__PURE__ */ jsx(ProjectIconGlyph, {
|
|
157
|
+
...project.icon ? { icon: project.icon } : {},
|
|
158
|
+
server: server !== void 0,
|
|
159
|
+
size: "xs"
|
|
160
|
+
}),
|
|
161
|
+
title: /* @__PURE__ */ jsx("span", {
|
|
162
|
+
dir: "auto",
|
|
163
|
+
children: project.name
|
|
164
|
+
}),
|
|
165
|
+
checked: project.id === current,
|
|
166
|
+
...server ? { trailing: /* @__PURE__ */ jsx(HostBadge, {
|
|
167
|
+
host: server,
|
|
168
|
+
className: "min-w-0"
|
|
169
|
+
}) } : {},
|
|
170
|
+
onClick: () => onPick(project.id)
|
|
171
|
+
}, project.id))
|
|
172
|
+
})]
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
export { ProjectChoice, ProjectPicker, useFiledOrigin, useProjectChoices, useServerView };
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* <TodosPanel sessionId={id} />
|
|
7
7
|
* </SessionProvider>
|
|
8
8
|
*/
|
|
9
|
-
import { PlansSnapshot, Project, QueuedMessage, RunningWorkItem, Schedule, SchedulesStatus, SessionArtifactGroup, SessionHost, SessionProjects, SessionSecretEntry } from "./headless/host.js";
|
|
9
|
+
import { PlansSnapshot, Project, QueuedMessage, RunningWorkItem, Schedule, SchedulesStatus, SessionArtifactGroup, SessionHost, SessionProjects, SessionSecretEntry, SessionSharingHost } from "./headless/host.js";
|
|
10
10
|
import { SessionLabels } from "./headless/labels.js";
|
|
11
11
|
import { ReactNode } from "react";
|
|
12
12
|
/** Props for {@link SessionProvider}. */
|
|
@@ -26,11 +26,25 @@ export interface SessionProviderProps {
|
|
|
26
26
|
export declare function SessionProvider({ host, labels, children }: SessionProviderProps): import("react").JSX.Element;
|
|
27
27
|
/** Returns the {@link SessionHost} from the nearest {@link SessionProvider}. Throws when called outside one. */
|
|
28
28
|
export declare function useSessionHost(): SessionHost;
|
|
29
|
+
/** The host's sharing (`SessionHost.sharing`): `undefined` without it, or outside a {@link SessionProvider}. */
|
|
30
|
+
export declare function useSessionSharing(): SessionSharingHost | undefined;
|
|
29
31
|
/**
|
|
30
32
|
* The host's projects (`SessionHost.projects`): `undefined` without them, or outside a {@link SessionProvider} (the
|
|
31
33
|
* project home then keeps its layout in the window).
|
|
32
34
|
*/
|
|
33
35
|
export declare function useSessionProjects(): SessionProjects | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* The projects of a host this window reaches (`SessionHost.projectsOf`): `undefined` for `null`, without
|
|
38
|
+
* `projectsOf`, outside a {@link SessionProvider}, and while that host offers none here.
|
|
39
|
+
*
|
|
40
|
+
* @param hostId - The host (a saved server's id), `null` for none.
|
|
41
|
+
*/
|
|
42
|
+
export declare function useHostProjects(hostId: string | null): SessionProjects | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* The host's `projectsOf` (another host's projects by its id): `undefined` without it, or outside a
|
|
45
|
+
* {@link SessionProvider}.
|
|
46
|
+
*/
|
|
47
|
+
export declare function useSessionProjectsOf(): SessionHost['projectsOf'];
|
|
34
48
|
/**
|
|
35
49
|
* The host's projects that are not archived: `null` until read, and while `enabled` is off. The first enabled call
|
|
36
50
|
* asks the host; off, nothing is read.
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { constant, useReadable } from "../chat/headless/store.js";
|
|
2
2
|
import { LabelsProvider } from "../labels.js";
|
|
3
|
-
import {
|
|
3
|
+
import { SessionHostContext } from "./host-context.js";
|
|
4
|
+
import { useContext, useEffect } from "react";
|
|
4
5
|
import { jsx } from "react/jsx-runtime";
|
|
5
6
|
// src/session/SessionProvider.tsx
|
|
6
|
-
const HostContext = createContext(null);
|
|
7
7
|
/**
|
|
8
8
|
* Provides a {@link SessionHost} and optional label overrides to the session panels below it.
|
|
9
9
|
*
|
|
10
10
|
* @param props - Provider props: the `host`, optional `labels`, and the `children` to render.
|
|
11
11
|
*/
|
|
12
12
|
function SessionProvider({ host, labels, children }) {
|
|
13
|
-
return /* @__PURE__ */ jsx(
|
|
13
|
+
return /* @__PURE__ */ jsx(SessionHostContext.Provider, {
|
|
14
14
|
value: host,
|
|
15
15
|
children: /* @__PURE__ */ jsx(LabelsProvider, {
|
|
16
16
|
labels,
|
|
@@ -20,16 +20,38 @@ function SessionProvider({ host, labels, children }) {
|
|
|
20
20
|
}
|
|
21
21
|
/** Returns the {@link SessionHost} from the nearest {@link SessionProvider}. Throws when called outside one. */
|
|
22
22
|
function useSessionHost() {
|
|
23
|
-
const host = useContext(
|
|
23
|
+
const host = useContext(SessionHostContext);
|
|
24
24
|
if (!host) throw new Error("zidane-ui/session: wrap the session panels in <SessionProvider host={…}>");
|
|
25
25
|
return host;
|
|
26
26
|
}
|
|
27
|
+
/** The host's sharing (`SessionHost.sharing`): `undefined` without it, or outside a {@link SessionProvider}. */
|
|
28
|
+
function useSessionSharing() {
|
|
29
|
+
return useContext(SessionHostContext)?.sharing;
|
|
30
|
+
}
|
|
27
31
|
/**
|
|
28
32
|
* The host's projects (`SessionHost.projects`): `undefined` without them, or outside a {@link SessionProvider} (the
|
|
29
33
|
* project home then keeps its layout in the window).
|
|
30
34
|
*/
|
|
31
35
|
function useSessionProjects() {
|
|
32
|
-
return useContext(
|
|
36
|
+
return useContext(SessionHostContext)?.projects;
|
|
37
|
+
}
|
|
38
|
+
const NO_HOST_PROJECTS = constant(void 0);
|
|
39
|
+
/**
|
|
40
|
+
* The projects of a host this window reaches (`SessionHost.projectsOf`): `undefined` for `null`, without
|
|
41
|
+
* `projectsOf`, outside a {@link SessionProvider}, and while that host offers none here.
|
|
42
|
+
*
|
|
43
|
+
* @param hostId - The host (a saved server's id), `null` for none.
|
|
44
|
+
*/
|
|
45
|
+
function useHostProjects(hostId) {
|
|
46
|
+
const projectsOf = useContext(SessionHostContext)?.projectsOf;
|
|
47
|
+
return useReadable(hostId !== null && projectsOf ? projectsOf(hostId) : NO_HOST_PROJECTS);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The host's `projectsOf` (another host's projects by its id): `undefined` without it, or outside a
|
|
51
|
+
* {@link SessionProvider}.
|
|
52
|
+
*/
|
|
53
|
+
function useSessionProjectsOf() {
|
|
54
|
+
return useContext(SessionHostContext)?.projectsOf;
|
|
33
55
|
}
|
|
34
56
|
const NO_PROJECTS = constant(null);
|
|
35
57
|
/**
|
|
@@ -136,4 +158,4 @@ function useSessionRunningWork(sessionId) {
|
|
|
136
158
|
}, [work, sessionId]);
|
|
137
159
|
return useReadable(sessionId && work ? work.items(sessionId) : NO_WORK);
|
|
138
160
|
}
|
|
139
|
-
export { SessionProvider, useAllSchedules, useProjectList, useSchedulesStatus, useSessionArtifacts, useSessionHost, useSessionPlans, useSessionProjects, useSessionQueue, useSessionRunningWork, useSessionSchedules, useSessionSecrets };
|
|
161
|
+
export { SessionProvider, useAllSchedules, useHostProjects, useProjectList, useSchedulesStatus, useSessionArtifacts, useSessionHost, useSessionPlans, useSessionProjects, useSessionProjectsOf, useSessionQueue, useSessionRunningWork, useSessionSchedules, useSessionSecrets, useSessionSharing };
|
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
import { CSSProperties } from "react";
|
|
10
10
|
/** Props for {@link UsageSection}. */
|
|
11
11
|
export interface UsageSectionProps {
|
|
12
|
-
/** The provider the active session runs on: its active credential's row is marked In use. */
|
|
13
|
-
activeProviderKey?: string | null;
|
|
14
12
|
/** Background probes are on (it words the empty state). Default `true`. */
|
|
15
13
|
autoLoad?: boolean;
|
|
16
14
|
/** Extra classes on the root. */
|
|
@@ -22,6 +20,6 @@ export interface UsageSectionProps {
|
|
|
22
20
|
* Renders the subscription windows of every signed-in provider and GitHub, with a Refresh: the body of
|
|
23
21
|
* Settings › Accounts › Usage (`panels.usage` of `SettingsRowsPage`).
|
|
24
22
|
*
|
|
25
|
-
* @param props - `
|
|
23
|
+
* @param props - `autoLoad`, `className` and `style`.
|
|
26
24
|
*/
|
|
27
|
-
export declare function UsageSection({
|
|
25
|
+
export declare function UsageSection({ autoLoad, className, style }: UsageSectionProps): import("react").JSX.Element;
|