@kortix/ui 0.16.0 → 0.16.2
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/_vendor/kortix-shared.js +157 -51
- package/dist/_vendor/shared/index.d.ts +1 -0
- package/dist/_vendor/shared/space-icon.d.ts +30 -0
- package/dist/_vendor/shared/space-slug.d.ts +12 -0
- package/dist/access/access/access-dialog.js +2 -2
- package/dist/access/share-dialog.d.ts +77 -0
- package/dist/access/share-dialog.js +160 -0
- package/dist/access/sharing-picker.d.ts +8 -1
- package/dist/access/sharing-picker.js +2 -2
- package/dist/changes/change-list.js +3 -3
- package/dist/customize/connectors/catalog/catalog-paging.d.ts +1 -1
- package/dist/customize/connectors/catalog/catalog-paging.js +1 -1
- package/dist/customize/providers/provider-sheet.js +17 -7
- package/dist/customize/sections/component/manifest-copy-block.js +1 -1
- package/dist/customize/sections/component/section-wrapper.d.ts +1 -8
- package/dist/customize/sections/component/section-wrapper.js +3 -3
- package/dist/customize/sections/llm-provider/model-capability-icons.js +1 -1
- package/dist/customize/sections/view/gateway/generation-controls.js +1 -1
- package/dist/customize/sections/view/git-view.js +1 -1
- package/dist/customize/settings/settings-tabs.js +0 -5
- package/dist/customize/settings/tabs/general-tab.js +2 -2
- package/dist/customize/shared/capability-page-shell.d.ts +2 -2
- package/dist/customize/shared/capability-page-shell.js +7 -5
- package/dist/customize/shared/capability-scroll-root.js +1 -2
- package/dist/customize/shared/catalog/catalog-card.js +1 -1
- package/dist/files/project/components/change-requests-panel.js +2 -2
- package/dist/files/project/components/checkpoint-detail-dialog.js +4 -4
- package/dist/files/project/components/checkpoints-panel.js +2 -2
- package/dist/files/project/components/drive-explorer.js +2 -2
- package/dist/files/project/components/file-breadcrumbs.js +1 -1
- package/dist/files/project/components/file-history-popover.js +2 -2
- package/dist/files/project/components/file-thumbnail.js +1 -1
- package/dist/files/project/components/open-change-request-dialog.js +1 -1
- package/dist/files/renderers/mermaid/mermaid-diagram.js +2 -2
- package/dist/files/renderers/show-content-renderer.js +6 -6
- package/dist/files/renderers/sqlite-renderer.js +8 -8
- package/dist/files/renderers/zip/zip-renderer.js +2 -2
- package/dist/files/viewer/file-content-renderer.js +5 -5
- package/dist/files/viewer/json-tree-view.js +3 -3
- package/dist/i18n/en.d.ts +133 -8
- package/dist/i18n/en.js +170 -45
- package/dist/i18n/ui-catalog/remaining-ui-translation-keys.generated.js +0 -3
- package/dist/internal/billing/use-cost-explorer.d.ts +9 -2
- package/dist/internal/billing/use-cost-explorer.js +22 -0
- package/dist/internal/billing/use-session-costs.d.ts +7 -2
- package/dist/internal/billing/use-session-costs.js +6 -0
- package/dist/internal/chrome/use-chrome-offered.d.ts +3 -3
- package/dist/internal/chrome/use-chrome-offered.js +3 -3
- package/dist/internal/components/nav-rail.d.ts +1 -20
- package/dist/internal/components/nav-rail.js +1 -15
- package/dist/internal/layout/project-page-header.d.ts +13 -9
- package/dist/internal/layout/project-page-header.js +14 -10
- package/dist/internal/lib/browser-noise/evidence.d.ts +2 -0
- package/dist/internal/lib/browser-noise/rules/injected-scripts.js +16 -1
- package/dist/internal/lib/error-handler.js +0 -9
- package/dist/internal/lib/interface-theme-defaults.js +2 -2
- package/dist/internal/lib/project-actions.d.ts +4 -5
- package/dist/internal/lib/project-actions.js +3 -5
- package/dist/internal/lib/project-preamble.d.ts +42 -4
- package/dist/internal/lib/project-preamble.js +49 -5
- package/dist/internal/lib/web-notifications.js +17 -29
- package/dist/internal/outcomes/outcome-vocabulary.js +1 -1
- package/dist/internal/stores/session-filter-store.d.ts +1 -1
- package/dist/internal/stores/user-preferences-store.d.ts +2 -2
- package/dist/internal/stores/workspace-settings-rail-store.d.ts +0 -8
- package/dist/internal/stores/workspace-settings-rail-store.js +0 -2
- package/dist/lib/routes.d.ts +7 -0
- package/dist/lib/routes.js +6 -1
- package/dist/markdown/doc-editor/doc-extensions.js +2 -0
- package/dist/markdown/doc-editor/doc-paste.d.ts +13 -0
- package/dist/markdown/doc-editor/doc-paste.js +67 -0
- package/dist/markdown/markdown-frontmatter.js +3 -3
- package/dist/markdown/markdown-policy.d.ts +1 -1
- package/dist/markdown/ordered-list.js +1 -1
- package/dist/primitives/context-menu.d.ts +1 -0
- package/dist/primitives/definition-list.js +1 -1
- package/dist/primitives/dropdown-menu.d.ts +1 -0
- package/dist/primitives/emoji-picker.js +1 -1
- package/dist/primitives/expandable-search.d.ts +57 -0
- package/dist/primitives/expandable-search.js +58 -0
- package/dist/primitives/favicon-avatar.js +1 -1
- package/dist/primitives/file-tree.d.ts +1 -1
- package/dist/primitives/file-tree.js +1 -1
- package/dist/primitives/glyph-picker.js +2 -2
- package/dist/primitives/input-group.js +1 -1
- package/dist/primitives/menu-base.d.ts +10 -0
- package/dist/primitives/menu-base.js +7 -2
- package/dist/primitives/phone-input.js +1 -1
- package/dist/primitives/profile-hover-card.d.ts +28 -0
- package/dist/primitives/profile-hover-card.js +22 -0
- package/dist/primitives/settings-section-header.d.ts +5 -5
- package/dist/primitives/settings-section-header.js +5 -5
- package/dist/primitives/sort-menu.d.ts +23 -0
- package/dist/primitives/sort-menu.js +54 -0
- package/dist/primitives/tabs.js +1 -1
- package/dist/primitives/toast-clearance.d.ts +12 -28
- package/dist/primitives/toast-clearance.js +23 -45
- package/dist/primitives/user-avatar.js +2 -3
- package/dist/session/agents/subagent-dialog-content.js +28 -70
- package/dist/session/composer/ComposerCard.d.ts +4 -1
- package/dist/session/composer/ComposerCard.js +51 -7
- package/dist/session/composer/composer-chat-input.js +3 -1
- package/dist/session/composer/composer-toolbar.d.ts +3 -1
- package/dist/session/composer/composer-toolbar.js +6 -2
- package/dist/session/composer/composer-underbar.d.ts +3 -1
- package/dist/session/composer/composer-underbar.js +2 -2
- package/dist/session/composer/composer.d.ts +12 -0
- package/dist/session/composer/composer.js +112 -6
- package/dist/session/composer/draft/composer-draft.d.ts +1 -0
- package/dist/session/composer/draft/composer-draft.js +10 -2
- package/dist/session/composer/draft/draft-uploads.js +13 -2
- package/dist/session/composer/draft/use-composer-draft.d.ts +2 -0
- package/dist/session/composer/draft/use-composer-draft.js +41 -6
- package/dist/session/composer/drive-mentions.d.ts +34 -0
- package/dist/session/composer/drive-mentions.js +98 -0
- package/dist/session/composer/editor/composer-editor.d.ts +3 -0
- package/dist/session/composer/editor/composer-editor.js +3 -1
- package/dist/session/composer/editor/serialize.js +3 -4
- package/dist/session/composer/menus/mention-controller.d.ts +3 -0
- package/dist/session/composer/menus/mention-controller.js +5 -0
- package/dist/session/composer/menus/mention-menu.d.ts +20 -3
- package/dist/session/composer/menus/mention-menu.js +33 -6
- package/dist/session/composer/menus/menu-items.d.ts +16 -1
- package/dist/session/composer/menus/menu-items.js +21 -1
- package/dist/session/composer/submit-latch.d.ts +3 -1
- package/dist/session/composer/submit-latch.js +5 -1
- package/dist/session/composer/types.d.ts +9 -2
- package/dist/session/header/session-changes-indicator.js +1 -1
- package/dist/session/header/session-site-header.js +2 -2
- package/dist/session/media/sandbox-url-detector.js +3 -3
- package/dist/session/models/model-connection-gate.d.ts +5 -0
- package/dist/session/models/model-connection-gate.js +12 -3
- package/dist/session/models/model-connection-layout.d.ts +7 -0
- package/dist/session/models/model-connection-layout.js +7 -0
- package/dist/session/models/provider-failure-recovery.js +1 -1
- package/dist/session/models/subscription-offer.d.ts +6 -5
- package/dist/session/models/subscription-offer.js +6 -6
- package/dist/session/panel/advanced/advanced-panel.js +1 -1
- package/dist/session/panel/session-detail-panel.js +1 -1
- package/dist/session/panel/session-diff-viewer.js +1 -1
- package/dist/session/panel/session-files-explorer.js +1 -1
- package/dist/session/panel/session-files-panel.js +3 -3
- package/dist/session/panel/shared/action-navigator.js +1 -1
- package/dist/session/status/provisioning-failure.d.ts +4 -4
- package/dist/session/status/provisioning-failure.js +4 -4
- package/dist/session/status/session-busy-indicator.js +1 -1
- package/dist/session/status/session-error-banner.js +6 -1
- package/dist/session/thread/mention-chip.d.ts +1 -1
- package/dist/session/thread/mention-segments.d.ts +4 -2
- package/dist/session/thread/mention-segments.js +28 -1
- package/dist/session/thread/message-parsing.d.ts +11 -0
- package/dist/session/thread/message-parsing.js +22 -3
- package/dist/session/thread/optimistic-turn.d.ts +4 -2
- package/dist/session/thread/optimistic-turn.js +13 -11
- package/dist/session/thread/session-chat.js +6 -1
- package/dist/session/thread/session-context-message-explorer.js +1 -1
- package/dist/session/thread/session-older-autoload.d.ts +2 -3
- package/dist/session/thread/session-older-autoload.js +2 -3
- package/dist/session/thread/transcript.js +8 -10
- package/dist/session/tool/shared/error-and-connector.js +1 -1
- package/dist/session/tool/shared/file-list.js +2 -2
- package/dist/session/tool/shared/infrastructure-parts.js +1 -1
- package/dist/session/tool/shared/infrastructure-preview.js +1 -1
- package/dist/session/tool/shared/infrastructure-row-header.js +3 -3
- package/dist/session/tool/shared/infrastructure-rows.js +2 -2
- package/dist/session/tool/shared/output-block.js +4 -4
- package/dist/session/tool/shared/session-helpers.js +3 -3
- package/dist/session/tool/shared/structured-output.js +3 -3
- package/dist/session/tool/shared/todo-helpers.js +1 -1
- package/dist/session/tool/tool-error.js +2 -2
- package/dist/session/tool/tools/agent-spawn-tool.js +3 -3
- package/dist/session/tool/tools/agent-status-tool.js +1 -1
- package/dist/session/tool/tools/apply-patch-tool.js +1 -1
- package/dist/session/tool/tools/connector-get-tool.js +1 -1
- package/dist/session/tool/tools/connector-list-tool.js +1 -1
- package/dist/session/tool/tools/connector-tools.js +1 -1
- package/dist/session/tool/tools/edit-tool.js +1 -1
- package/dist/session/tool/tools/get-mem-tool.js +1 -1
- package/dist/session/tool/tools/glob-tool.js +1 -1
- package/dist/session/tool/tools/image-search-tool.js +1 -1
- package/dist/session/tool/tools/memory-search-tool.js +1 -1
- package/dist/session/tool/tools/memory-tool.js +4 -4
- package/dist/session/tool/tools/presentation-gen-tool.js +2 -2
- package/dist/session/tool/tools/project-delete-tool.js +1 -1
- package/dist/session/tool/tools/project-list-tool.js +1 -1
- package/dist/session/tool/tools/pty-read-tool.js +1 -1
- package/dist/session/tool/tools/pty-spawn-tool.js +1 -1
- package/dist/session/tool/tools/pty-write-tool.js +1 -1
- package/dist/session/tool/tools/read-tool.js +1 -1
- package/dist/session/tool/tools/removed-connector-tool.js +1 -1
- package/dist/session/tool/tools/scrape-webpage-tool.js +1 -1
- package/dist/session/tool/tools/session-get-tool.js +3 -3
- package/dist/session/tool/tools/session-list-background-tool.js +1 -1
- package/dist/session/tool/tools/session-read-tool.js +1 -1
- package/dist/session/tool/tools/session-search-tool.js +1 -1
- package/dist/session/tool/tools/session-spawn-tool.js +1 -1
- package/dist/session/tool/tools/skill-tool.js +1 -1
- package/dist/session/tool/tools/todo-write-tool.js +1 -1
- package/dist/session/tool/tools/web-fetch-tool.js +1 -1
- package/dist/session/tool/tools/write-tool.js +1 -1
- package/dist/session/turn/activity-file-chips.js +7 -3
- package/dist/session/turn/activity-step.js +1 -1
- package/dist/session/turn/burst-summary-trigger.js +3 -3
- package/dist/session/turn/chain-step-trigger.js +1 -1
- package/dist/session/turn/plan-card.js +1 -1
- package/dist/session/turn/thought-chain-step.js +1 -1
- package/dist/session/turn/turn-work-accordion.js +1 -1
- package/dist/session/turn/user-message.js +13 -6
- package/dist/session/voice/use-call-card-position.d.ts +30 -0
- package/dist/session/voice/use-call-card-position.js +126 -0
- package/dist/session/voice/voice-call-card.js +10 -3
- package/dist/styles/theme.css +12 -0
- package/dist/styles/tokens.css +12 -6
- package/dist/styles.css +1 -1
- package/dist/terminal/session-terminal-panel.js +1 -1
- package/dist/test-utils/intl.d.ts +133 -8
- package/dist/workspace/admin/project-admin-dashboard.js +7 -24
- package/dist/workspace/calendar/calendar-page.js +1 -1
- package/dist/workspace/home/first-chat.d.ts +4 -3
- package/dist/workspace/home/first-chat.js +6 -6
- package/dist/workspace/home/welcome-body.js +2 -2
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/layout/project-home.js +11 -4
- package/dist/workspace/layout/use-project-home-send.d.ts +3 -1
- package/dist/workspace/layout/use-project-home-send.js +6 -2
- package/dist/workspace/memory/company-memory-page.js +2 -4
- package/dist/workspace/new/github-source.js +0 -1
- package/dist/workspace/new/new-workspace-form.d.ts +0 -1
- package/dist/workspace/new/new-workspace-form.js +0 -3
- package/dist/workspace/new/use-create-workspace.d.ts +1 -1
- package/dist/workspace/new/use-create-workspace.js +1 -2
- package/dist/workspace/session-spaces/space-detail-page.d.ts +35 -0
- package/dist/workspace/session-spaces/space-detail-page.js +307 -0
- package/dist/workspace/session-spaces/space-form-modal.d.ts +16 -0
- package/dist/workspace/session-spaces/space-form-modal.js +92 -0
- package/dist/workspace/session-spaces/space-icon.d.ts +36 -0
- package/dist/workspace/session-spaces/space-icon.js +52 -0
- package/dist/workspace/session-spaces/space-people.d.ts +51 -0
- package/dist/workspace/session-spaces/space-people.js +91 -0
- package/dist/workspace/session-spaces/space-picker.d.ts +11 -0
- package/dist/workspace/session-spaces/space-picker.js +42 -0
- package/dist/workspace/session-spaces/space-share-modal.d.ts +14 -0
- package/dist/workspace/session-spaces/space-share-modal.js +93 -0
- package/dist/workspace/session-spaces/spaces-page.d.ts +8 -0
- package/dist/workspace/session-spaces/spaces-page.js +125 -0
- package/dist/workspace/sessions/session-owner-filters.d.ts +2 -0
- package/dist/workspace/sessions/session-owner-filters.js +2 -0
- package/dist/workspace/setup/setup-banner.d.ts +4 -0
- package/dist/workspace/setup/setup-banner.js +57 -0
- package/dist/workspace/setup/setup-steps.d.ts +14 -0
- package/dist/workspace/setup/setup-steps.js +15 -0
- package/dist/workspace/setup/use-setup-steps.d.ts +18 -0
- package/dist/workspace/setup/use-setup-steps.js +57 -0
- package/dist/workspace/setup/workspace-setup-page.js +8 -41
- package/dist/workspace/sidebar/footer/project-artifacts-nav.js +1 -1
- package/dist/workspace/sidebar/footer/project-promo-cards.d.ts +7 -2
- package/dist/workspace/sidebar/footer/project-promo-cards.js +4 -3
- package/dist/workspace/sidebar/footer/project-sandbox-alert.js +1 -1
- package/dist/workspace/sidebar/footer/promo-card.d.ts +10 -1
- package/dist/workspace/sidebar/footer/promo-card.js +31 -2
- package/dist/workspace/sidebar/footer/sandbox-health.js +1 -1
- package/dist/workspace/sidebar/modal/session-people-picker.d.ts +13 -0
- package/dist/workspace/sidebar/modal/session-people-picker.js +72 -0
- package/dist/workspace/sidebar/modal/share-session-modal.js +2 -1
- package/dist/workspace/sidebar/project-nav-items.d.ts +1 -3
- package/dist/workspace/sidebar/project-nav-items.js +3 -8
- package/dist/workspace/sidebar/project-session-list.js +19 -12
- package/dist/workspace/sidebar/project-sidebar.js +13 -13
- package/dist/workspace/sidebar/project-spaces-nav.js +1 -2
- package/dist/workspace/sidebar/session-filter-menu.js +19 -13
- package/dist/workspace/sidebar/session-group-sections.d.ts +12 -12
- package/dist/workspace/sidebar/session-group-sections.js +56 -75
- package/dist/workspace/sidebar/sidebar-more-group.js +1 -1
- package/dist/workspace/sidebar/workspace-settings-sidebar-nav.js +2 -2
- package/dist/workspace/spaces/space-tabs.d.ts +26 -6
- package/dist/workspace/spaces/space-tabs.js +19 -8
- package/package.json +27 -31
- package/skills/kortix-ui/references/modules.md +2 -2
- package/dist/workspace/new/clone-param.d.ts +0 -11
- package/dist/workspace/new/clone-param.js +0 -15
- package/dist/workspace/new/provision-new-workspace.d.ts +0 -14
- package/dist/workspace/new/provision-new-workspace.js +0 -14
- package/dist/workspace/sidebar/footer/project-inbox-nav.d.ts +0 -8
- package/dist/workspace/sidebar/footer/project-inbox-nav.js +0 -29
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { listProjectAccess } from '@kortix/sdk';
|
|
4
|
+
import { contract, qk } from '@kortix/sdk/react';
|
|
5
|
+
import { LockSimpleIcon, UsersThreeIcon } from '@phosphor-icons/react';
|
|
6
|
+
import { useQuery } from '@tanstack/react-query';
|
|
7
|
+
import { useTranslations } from '../../i18n/index.js';
|
|
8
|
+
import { cn } from '../../lib/utils.js';
|
|
9
|
+
import { UserAvatar } from '../../primitives/user-avatar.js';
|
|
10
|
+
export function spaceAudience(space) {
|
|
11
|
+
if (space.visibility === 'project')
|
|
12
|
+
return { kind: 'everyone' };
|
|
13
|
+
const members = space.member_ids ?? [];
|
|
14
|
+
if (members.length === 0)
|
|
15
|
+
return { kind: 'private' };
|
|
16
|
+
return { kind: 'people', ids: [space.created_by, ...members].filter((id) => !!id) };
|
|
17
|
+
}
|
|
18
|
+
/** The audience in words: "Everyone in this workspace", "Only you", "Shared with 3 people". */
|
|
19
|
+
export function useSpaceAudienceLabel(space) {
|
|
20
|
+
const t = useTranslations('sessionSpaces');
|
|
21
|
+
const audience = spaceAudience(space);
|
|
22
|
+
if (audience.kind === 'everyone')
|
|
23
|
+
return t('visibility');
|
|
24
|
+
if (audience.kind === 'private')
|
|
25
|
+
return space.can_manage === true ? t('onlyYou') : t('private');
|
|
26
|
+
return t('sharedWith', { count: audience.ids.length - 1 });
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The space's own people (creator, then members) with their profiles, as the
|
|
30
|
+
* API returns them on the space: every viewer of the space can read these,
|
|
31
|
+
* unlike the workspace access list, which only managers can.
|
|
32
|
+
*/
|
|
33
|
+
export function spacePeople(space) {
|
|
34
|
+
const out = new Map();
|
|
35
|
+
for (const person of space.people ?? []) {
|
|
36
|
+
out.set(person.user_id, { email: person.email ?? '', name: person.name?.trim() || null, avatarUrl: person.avatar_url });
|
|
37
|
+
}
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
/** The workspace's people by id, for avatars: email, name and picture. A viewer who may not read the list gets an empty map. */
|
|
41
|
+
export function useWorkspacePeople(projectId, enabled) {
|
|
42
|
+
const access = useQuery({
|
|
43
|
+
queryKey: qk.project.access(projectId),
|
|
44
|
+
queryFn: () => listProjectAccess(projectId),
|
|
45
|
+
enabled,
|
|
46
|
+
retry: false,
|
|
47
|
+
...contract('inventory'),
|
|
48
|
+
});
|
|
49
|
+
const people = new Map();
|
|
50
|
+
for (const member of access.data?.members ?? []) {
|
|
51
|
+
people.set(member.user_id, { email: member.email ?? '', name: member.name?.trim() || null, avatarUrl: member.avatar_url ?? null });
|
|
52
|
+
}
|
|
53
|
+
return people;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Who sees the space, drawn small: up to `max` avatars and "+N", the people
|
|
57
|
+
* glyph for the whole workspace, a lock for its creator alone. A viewer who
|
|
58
|
+
* may not read the people list sees the count beside the people glyph, never
|
|
59
|
+
* a "?" avatar.
|
|
60
|
+
*/
|
|
61
|
+
export function SpaceAudienceMark({ space, max = 4, className }) {
|
|
62
|
+
const audience = spaceAudience(space);
|
|
63
|
+
const people = spacePeople(space);
|
|
64
|
+
if (audience.kind === 'everyone')
|
|
65
|
+
return _jsx(UsersThreeIcon, { "aria-hidden": true, className: cn('text-muted-foreground size-4 shrink-0', className) });
|
|
66
|
+
if (audience.kind === 'private')
|
|
67
|
+
return _jsx(LockSimpleIcon, { "aria-hidden": true, className: cn('text-muted-foreground size-4 shrink-0', className) });
|
|
68
|
+
const shown = audience.ids.slice(0, max);
|
|
69
|
+
if (!shown.every((id) => people.has(id))) {
|
|
70
|
+
return (_jsxs("span", { "aria-hidden": true, className: cn('text-muted-foreground flex items-center gap-1 text-xs tabular-nums', className), children: [_jsx(UsersThreeIcon, { className: "size-4 shrink-0" }), audience.ids.length] }));
|
|
71
|
+
}
|
|
72
|
+
return (_jsxs("span", { "aria-hidden": true, className: cn('flex items-center', className), children: [shown.map((id, index) => {
|
|
73
|
+
const person = people.get(id);
|
|
74
|
+
return (_jsx("span", { className: cn('ring-background rounded-sm ring-2', index > 0 && '-ml-1.5'), children: _jsx(UserAvatar, { email: person.email, name: person.name ?? person.email, avatarUrl: person.avatarUrl, colorKey: id, size: "xs" }) }, id));
|
|
75
|
+
}), audience.ids.length > max ? _jsxs("span", { className: "text-muted-foreground ml-1.5 text-xs tabular-nums", children: ["+", audience.ids.length - max] }) : null] }));
|
|
76
|
+
}
|
|
77
|
+
/** A space's people in the shape of the session header's avatar stack (`SessionParticipantStack`), creator first. */
|
|
78
|
+
export function spaceParticipants(space) {
|
|
79
|
+
const people = space.people ?? [];
|
|
80
|
+
return {
|
|
81
|
+
participants: people.map((person) => ({
|
|
82
|
+
user_id: person.user_id,
|
|
83
|
+
name: person.name,
|
|
84
|
+
email: person.email,
|
|
85
|
+
avatar_url: person.avatar_url,
|
|
86
|
+
is_viewer: false,
|
|
87
|
+
})),
|
|
88
|
+
total: people.length,
|
|
89
|
+
multi_user: people.length > 1,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The composer's Space chip (flag `session_groups`): the space a new session
|
|
3
|
+
* is filed in. "No space" files it in none. "New space" creates one and picks
|
|
4
|
+
* it. Renders nothing while the flag is off.
|
|
5
|
+
*/
|
|
6
|
+
export declare function SpacePicker({ projectId, value, onChange, }: {
|
|
7
|
+
projectId: string;
|
|
8
|
+
/** The picked space's id; null for no space. */
|
|
9
|
+
value: string | null;
|
|
10
|
+
onChange: (groupId: string | null) => void;
|
|
11
|
+
}): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useFeatureFlag, useWorkspaceSessionGroups } from '@kortix/sdk/react';
|
|
4
|
+
import { CaretDownIcon, CheckIcon, PlusIcon, StackIcon } from '@phosphor-icons/react';
|
|
5
|
+
import { useState } from 'react';
|
|
6
|
+
import { useTranslations } from '../../i18n/index.js';
|
|
7
|
+
import { cn } from '../../lib/utils.js';
|
|
8
|
+
import { Button } from '../../primitives/button.js';
|
|
9
|
+
import { CommandGroup, CommandInput, CommandItem, CommandList, CommandPopover, CommandPopoverContent, CommandPopoverTrigger, CommandSeparator, } from '../../primitives/command.js';
|
|
10
|
+
import { SpaceFormModal } from './space-form-modal.js';
|
|
11
|
+
import { SpaceIcon } from './space-icon.js';
|
|
12
|
+
/** Spaces on screen before the popover shows its search field (it stays mounted for the arrow keys). */
|
|
13
|
+
const SEARCH_THRESHOLD = 8;
|
|
14
|
+
/**
|
|
15
|
+
* The composer's Space chip (flag `session_groups`): the space a new session
|
|
16
|
+
* is filed in. "No space" files it in none. "New space" creates one and picks
|
|
17
|
+
* it. Renders nothing while the flag is off.
|
|
18
|
+
*/
|
|
19
|
+
export function SpacePicker({ projectId, value, onChange, }) {
|
|
20
|
+
const t = useTranslations('sessionSpaces');
|
|
21
|
+
const enabled = useFeatureFlag(projectId, 'session_groups').enabled;
|
|
22
|
+
const groups = useWorkspaceSessionGroups(enabled ? projectId : null);
|
|
23
|
+
const [open, setOpen] = useState(false);
|
|
24
|
+
const [creating, setCreating] = useState(false);
|
|
25
|
+
const [search, setSearch] = useState('');
|
|
26
|
+
if (!enabled)
|
|
27
|
+
return null;
|
|
28
|
+
const spaces = groups.data ?? [];
|
|
29
|
+
const picked = value ? (spaces.find((space) => space.group_id === value) ?? null) : null;
|
|
30
|
+
const query = search.trim().toLowerCase();
|
|
31
|
+
const shown = query ? spaces.filter((space) => space.name.toLowerCase().includes(query)) : spaces;
|
|
32
|
+
const pick = (groupId) => {
|
|
33
|
+
onChange(groupId);
|
|
34
|
+
setOpen(false);
|
|
35
|
+
setSearch('');
|
|
36
|
+
};
|
|
37
|
+
const row = (space) => (_jsxs(CommandItem, { value: `space-${space.group_id}`, className: "gap-2", onSelect: () => pick(space.group_id), children: [_jsx(SpaceIcon, { space: space, size: "sm", className: "size-5 rounded-[calc(var(--radius)-3px)]" }), _jsx("span", { className: "min-w-0 flex-1 truncate", children: space.name }), space.group_id === value ? _jsx(CheckIcon, { className: "text-foreground size-4 shrink-0" }) : null] }, space.group_id));
|
|
38
|
+
return (_jsxs(_Fragment, { children: [_jsxs(CommandPopover, { open: open, onOpenChange: setOpen, children: [_jsx(CommandPopoverTrigger, { children: _jsxs(Button, { type: "button", variant: "ghost", size: "sm", "aria-label": picked ? `${t('picker')}: ${picked.name}` : t('picker'), className: cn('rounded-lg hit-area-y-3', picked ? 'text-foreground' : 'text-muted-foreground'), children: [picked ? _jsx(SpaceIcon, { space: picked, size: "sm", className: "size-5 rounded-[calc(var(--radius)-3px)]" }) : _jsx(StackIcon, { className: "size-4 shrink-0" }), _jsx("span", { className: "max-w-[140px] truncate", children: picked ? picked.name : t('picker') }), _jsx(CaretDownIcon, { className: cn('size-3 transition-transform duration-moderate ease-out', open && 'rotate-180') })] }) }), _jsxs(CommandPopoverContent, { side: "top", align: "start", sideOffset: 8, className: "w-[min(300px,calc(100vw-1.5rem))]", children: [_jsx("div", { className: spaces.length > SEARCH_THRESHOLD ? undefined : 'sr-only', children: _jsx(CommandInput, { compact: true, placeholder: t('pickerSearch'), value: search, onValueChange: setSearch }) }), _jsx(CommandList, { className: "max-h-[320px]", children: _jsxs(CommandGroup, { forceMount: true, className: "[&_[cmdk-group-items]]:flex [&_[cmdk-group-items]]:flex-col [&_[cmdk-group-items]]:gap-px", children: [query ? null : (_jsxs(CommandItem, { value: "space-none", className: "gap-2", onSelect: () => pick(null), children: [_jsx("span", { className: "text-muted-foreground min-w-0 flex-1 truncate", children: t('pickerNone') }), value === null ? _jsx(CheckIcon, { className: "text-foreground size-4 shrink-0" }) : null] })), shown.map(row), query && shown.length === 0 ? (_jsx("div", { className: "text-muted-foreground py-6 text-center text-xs", children: t('pickerEmpty') })) : null, _jsx(CommandSeparator, { className: "my-1" }), _jsxs(CommandItem, { value: "space-new", className: "gap-2", onSelect: () => {
|
|
39
|
+
setOpen(false);
|
|
40
|
+
setCreating(true);
|
|
41
|
+
}, children: [_jsx(PlusIcon, { className: "size-4 shrink-0" }), _jsx("span", { className: "min-w-0 flex-1 truncate", children: t('newSpace') })] })] }) })] })] }), _jsx(SpaceFormModal, { projectId: projectId, space: null, open: creating, onOpenChange: setCreating, onSaved: (space) => onChange(space.group_id) })] }));
|
|
42
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ProjectSessionGroup } from '@kortix/sdk';
|
|
2
|
+
/**
|
|
3
|
+
* Share a space. Every change saves at once; there is no Save button.
|
|
4
|
+
* Add people, the people with access (the creator is Owner, the rest can be
|
|
5
|
+
* removed after a confirm), general access (only the people added, or the
|
|
6
|
+
* whole workspace: "everyone" clears the list) and the space's link.
|
|
7
|
+
* Whoever it is shared with sees every session in it and its Files folder.
|
|
8
|
+
*/
|
|
9
|
+
export declare function SpaceShareModal({ projectId, space, open, onOpenChange, }: {
|
|
10
|
+
projectId: string;
|
|
11
|
+
space: ProjectSessionGroup;
|
|
12
|
+
open: boolean;
|
|
13
|
+
onOpenChange: (open: boolean) => void;
|
|
14
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { ApiError } from '@kortix/sdk';
|
|
4
|
+
import { useSetWorkspaceSessionGroupSharing } from '@kortix/sdk/react';
|
|
5
|
+
import { LockSimpleIcon, TrashIcon, UsersThreeIcon } from '@phosphor-icons/react';
|
|
6
|
+
import { useMemo, useState } from 'react';
|
|
7
|
+
import { SHARE_GROUP, ShareAddField, ShareGeneralAccess, ShareLinkField, ShareRole, ShareRoleMenu, ShareRow, ShareSection, } from '../../access/share-dialog.js';
|
|
8
|
+
import { useTranslations } from '../../i18n/index.js';
|
|
9
|
+
import { uiRoutes } from '../../lib/routes.js';
|
|
10
|
+
import { ConfirmDialog } from '../../primitives/confirm-dialog.js';
|
|
11
|
+
import { Modal, ModalBody, ModalContent, ModalHeader, ModalTitle } from '../../primitives/modal.js';
|
|
12
|
+
import { errorToast, successToast } from '../../primitives/toast.js';
|
|
13
|
+
import { spacePeople, useWorkspacePeople } from './space-people.js';
|
|
14
|
+
function sharingOf(space) {
|
|
15
|
+
return { visibility: space.visibility === 'project' ? 'project' : 'private', member_ids: [...(space.member_ids ?? [])] };
|
|
16
|
+
}
|
|
17
|
+
function candidateOf(id, person) {
|
|
18
|
+
return {
|
|
19
|
+
id,
|
|
20
|
+
kind: 'member',
|
|
21
|
+
label: person?.name ?? person?.email ?? id,
|
|
22
|
+
sublabel: person?.name ? person.email : null,
|
|
23
|
+
email: person?.email ?? null,
|
|
24
|
+
avatarUrl: person?.avatarUrl ?? null,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Share a space. Every change saves at once; there is no Save button.
|
|
29
|
+
* Add people, the people with access (the creator is Owner, the rest can be
|
|
30
|
+
* removed after a confirm), general access (only the people added, or the
|
|
31
|
+
* whole workspace: "everyone" clears the list) and the space's link.
|
|
32
|
+
* Whoever it is shared with sees every session in it and its Files folder.
|
|
33
|
+
*/
|
|
34
|
+
export function SpaceShareModal({ projectId, space, open, onOpenChange, }) {
|
|
35
|
+
const t = useTranslations('sessionSpaces');
|
|
36
|
+
const share = useSetWorkspaceSessionGroupSharing(projectId);
|
|
37
|
+
const people = useWorkspacePeople(projectId, open);
|
|
38
|
+
// Rows read the space's own people first: they carry profiles even before the workspace list loads.
|
|
39
|
+
const own = spacePeople(space);
|
|
40
|
+
const personOf = (id) => own.get(id) ?? people.get(id);
|
|
41
|
+
const [removing, setRemoving] = useState(null);
|
|
42
|
+
// The pending write is what the dialog shows, so a change never flickers back.
|
|
43
|
+
const sharing = share.isPending && share.variables?.groupId === space.group_id
|
|
44
|
+
? { visibility: share.variables.input.visibility, member_ids: share.variables.input.member_ids ?? [] }
|
|
45
|
+
: sharingOf(space);
|
|
46
|
+
const everyone = sharing.visibility === 'project';
|
|
47
|
+
const creator = space.created_by;
|
|
48
|
+
const save = async (next) => {
|
|
49
|
+
try {
|
|
50
|
+
await share.mutateAsync({
|
|
51
|
+
groupId: space.group_id,
|
|
52
|
+
input: next.visibility === 'project' ? { visibility: 'project' } : { visibility: 'private', member_ids: next.member_ids },
|
|
53
|
+
});
|
|
54
|
+
successToast(t('shared'));
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
const code = error instanceof ApiError ? error.code : undefined;
|
|
59
|
+
errorToast(code === 'not_a_member' ? t('shareNotMember') : t('shareFailed'));
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const candidates = useMemo(() => [...people].map(([id, person]) => candidateOf(id, person)), [people]);
|
|
64
|
+
const excludeIds = useMemo(() => new Set([creator, ...sharing.member_ids].filter((id) => !!id)), [creator, sharing.member_ids]);
|
|
65
|
+
const href = uiRoutes().sessionSpace?.(projectId, space.group_id);
|
|
66
|
+
const link = href && typeof window !== 'undefined' ? `${window.location.origin}${href}` : null;
|
|
67
|
+
const copy = async () => {
|
|
68
|
+
if (!link)
|
|
69
|
+
return;
|
|
70
|
+
try {
|
|
71
|
+
await navigator.clipboard.writeText(link);
|
|
72
|
+
successToast(t('linkCopied'));
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
errorToast(t('linkCopyFailed'));
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const removingPerson = removing ? personOf(removing) : undefined;
|
|
79
|
+
return (_jsxs(_Fragment, { children: [_jsx(Modal, { open: open, onOpenChange: onOpenChange, children: _jsxs(ModalContent, { className: "lg:max-w-lg", children: [_jsx(ModalHeader, { children: _jsx(ModalTitle, { children: t('shareTitle', { name: space.name }) }) }), _jsxs(ModalBody, { className: "space-y-5", children: [_jsx(ShareAddField, { candidates: candidates, excludeIds: excludeIds, onShare: (picked) => save({ visibility: 'private', member_ids: [...sharing.member_ids, ...picked.map((candidate) => candidate.id)] }), pending: share.isPending, disabled: everyone, placeholder: everyone ? t('shareEveryoneHint') : t('shareAddPlaceholder'), shareLabel: t('share'), removeLabel: t('shareRemove'), onUnknownEmails: () => errorToast(t('shareNotMember')) }), _jsx(ShareSection, { label: t('sharePeopleWithAccess'), children: _jsxs("ul", { className: SHARE_GROUP, children: [creator ? _jsx(ShareRow, { candidate: candidateOf(creator, personOf(creator)), trailing: _jsx(ShareRole, { children: t('shareOwner') }) }) : null, everyone
|
|
80
|
+
? null
|
|
81
|
+
: sharing.member_ids.map((id) => (_jsx(ShareRow, { candidate: candidateOf(id, personOf(id)), trailing: _jsx(ShareRoleMenu, { label: t('roleMember'), removeLabel: t('shareRemove'), removeIcon: _jsx(TrashIcon, {}), onRemove: () => setRemoving(id), disabled: share.isPending }) }, id)))] }) }), _jsx(ShareSection, { label: t('shareGeneralAccess'), children: _jsx(ShareGeneralAccess, { value: sharing.visibility, changeLabel: t('shareChange'), disabled: share.isPending, onChange: (next) => void save({ visibility: next, member_ids: [] }), options: [
|
|
82
|
+
{ value: 'private', label: t('shareRestricted'), hint: t('shareRestrictedHint'), icon: _jsx(LockSimpleIcon, {}) },
|
|
83
|
+
{ value: 'project', label: t('shareEveryone'), hint: t('shareEveryoneHint'), icon: _jsx(UsersThreeIcon, {}) },
|
|
84
|
+
] }) }), link ? _jsx(ShareLinkField, { link: link, copyLabel: t('copyLink'), onCopy: () => void copy() }) : null] })] }) }), _jsx(ConfirmDialog, { open: removing !== null, onOpenChange: (next) => {
|
|
85
|
+
if (!next)
|
|
86
|
+
setRemoving(null);
|
|
87
|
+
}, title: t('shareRemoveTitle'), description: t('shareRemoveDescription', { name: removingPerson?.name ?? removingPerson?.email ?? '' }), confirmLabel: t('shareRemove'), confirmVariant: "destructive", isPending: share.isPending, onConfirm: () => {
|
|
88
|
+
const id = removing;
|
|
89
|
+
if (!id)
|
|
90
|
+
return;
|
|
91
|
+
void save({ visibility: 'private', member_ids: sharing.member_ids.filter((other) => other !== id) }).then(() => setRemoving(null));
|
|
92
|
+
} })] }));
|
|
93
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The workspace's Spaces (flag `session_groups`) as one list: a header bar
|
|
3
|
+
* (sort, search, New space), then the spaces the viewer made and the spaces
|
|
4
|
+
* shared with them, each a collapsible group of one-line rows.
|
|
5
|
+
*/
|
|
6
|
+
export declare function SpacesPage({ projectId }: {
|
|
7
|
+
projectId: string;
|
|
8
|
+
}): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useFeatureFlag, useWorkspaceSessionGroups } from '@kortix/sdk/react';
|
|
4
|
+
import { CaretDownIcon, DotsThreeIcon, LockSimpleIcon, MagnifyingGlassIcon, PlusIcon, StackIcon, UsersIcon, UsersThreeIcon, } from '@phosphor-icons/react';
|
|
5
|
+
import { formatDistanceToNowStrict } from 'date-fns';
|
|
6
|
+
import { useState } from 'react';
|
|
7
|
+
import { FeatureGateScreen } from '../../customize/shared/feature-gate-screen.js';
|
|
8
|
+
import { useTranslations } from '../../i18n/index.js';
|
|
9
|
+
import { ProjectPageHeader } from '../../internal/layout/project-page-header.js';
|
|
10
|
+
import { uiRoutes } from '../../lib/routes.js';
|
|
11
|
+
import { Button } from '../../primitives/button.js';
|
|
12
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '../../primitives/collapsible.js';
|
|
13
|
+
import { EmptyArt } from '../../primitives/empty-art.js';
|
|
14
|
+
import { EmptyState } from '../../primitives/empty-state.js';
|
|
15
|
+
import { ErrorState } from '../../primitives/error-state.js';
|
|
16
|
+
import { ExpandableSearch } from '../../primitives/expandable-search.js';
|
|
17
|
+
import { Skeleton } from '../../primitives/skeleton.js';
|
|
18
|
+
import { SortMenu, useStoredSort } from '../../primitives/sort-menu.js';
|
|
19
|
+
import { UiLink as Link, useUiRouter, useUiViewerId } from '../../providers/ui-provider.js';
|
|
20
|
+
import { SpaceSettingsMenu } from './space-detail-page.js';
|
|
21
|
+
import { SpaceFormModal } from './space-form-modal.js';
|
|
22
|
+
import { SpaceIconBare } from './space-icon.js';
|
|
23
|
+
import { spaceAudience, spaceParticipants } from './space-people.js';
|
|
24
|
+
import { SessionParticipantStack } from '../../session/participants/session-participants.js';
|
|
25
|
+
const SORTS = ['activity', 'name', 'created'];
|
|
26
|
+
const SORT_STORAGE_KEY = 'kortix:spaces-sort';
|
|
27
|
+
const SKELETON_KEYS = ['a', 'b', 'c', 'd', 'e'];
|
|
28
|
+
/**
|
|
29
|
+
* The workspace's Spaces (flag `session_groups`) as one list: a header bar
|
|
30
|
+
* (sort, search, New space), then the spaces the viewer made and the spaces
|
|
31
|
+
* shared with them, each a collapsible group of one-line rows.
|
|
32
|
+
*/
|
|
33
|
+
export function SpacesPage({ projectId }) {
|
|
34
|
+
const t = useTranslations('sessionSpaces');
|
|
35
|
+
const flag = useFeatureFlag(projectId, 'session_groups');
|
|
36
|
+
const groups = useWorkspaceSessionGroups(flag.enabled ? projectId : null);
|
|
37
|
+
const viewerId = useUiViewerId();
|
|
38
|
+
const router = useUiRouter();
|
|
39
|
+
const [search, setSearch] = useState('');
|
|
40
|
+
const [sort, setSort] = useStoredSort(SORT_STORAGE_KEY, SORTS, 'activity');
|
|
41
|
+
const [creating, setCreating] = useState(false);
|
|
42
|
+
const [editing, setEditing] = useState(null);
|
|
43
|
+
if (flag.isLoading)
|
|
44
|
+
return null;
|
|
45
|
+
if (!flag.enabled) {
|
|
46
|
+
return _jsx(FeatureGateScreen, { featureKey: "session_groups", featureName: t('title'), description: t('gateDescription') });
|
|
47
|
+
}
|
|
48
|
+
const spaces = groups.data ?? [];
|
|
49
|
+
const query = search.trim().toLowerCase();
|
|
50
|
+
const shown = sortSpaces(query
|
|
51
|
+
? spaces.filter((space) => space.name.toLowerCase().includes(query) || (space.description ?? '').toLowerCase().includes(query))
|
|
52
|
+
: spaces, sort);
|
|
53
|
+
// Without a known viewer every space counts as theirs: one group, no empty "Shared" header.
|
|
54
|
+
const mine = shown.filter((space) => !viewerId || space.created_by === viewerId);
|
|
55
|
+
const shared = shown.filter((space) => viewerId && space.created_by !== viewerId);
|
|
56
|
+
const open = (space) => {
|
|
57
|
+
const href = uiRoutes().sessionSpace?.(projectId, space.group_id);
|
|
58
|
+
if (href)
|
|
59
|
+
router.push(href);
|
|
60
|
+
};
|
|
61
|
+
const sortLabel = { activity: t('sortActivity'), name: t('sortName'), created: t('sortCreated') };
|
|
62
|
+
let body;
|
|
63
|
+
if (groups.isLoading) {
|
|
64
|
+
body = (_jsx("ul", { "aria-hidden": true, className: "space-y-1 px-3", children: SKELETON_KEYS.map((key) => (_jsxs("li", { className: "flex h-11 items-center gap-3", children: [_jsx(Skeleton, { className: "size-6 shrink-0 rounded-md py-0" }), _jsx(Skeleton, { className: "h-3.5 w-40 py-0" })] }, key))) }));
|
|
65
|
+
}
|
|
66
|
+
else if (groups.isError) {
|
|
67
|
+
body = (_jsx(ErrorState, { size: "sm", title: t('loadFailed'), action: _jsx(Button, { variant: "outline", size: "sm", onClick: () => void groups.refetch(), children: t('tryAgain') }) }));
|
|
68
|
+
}
|
|
69
|
+
else if (spaces.length === 0) {
|
|
70
|
+
body = _jsx(EmptyState, { media: _jsx(EmptyArt, { icon: StackIcon }), title: t('emptyTitle'), description: t('emptyDescription') });
|
|
71
|
+
}
|
|
72
|
+
else if (shown.length === 0) {
|
|
73
|
+
body = (_jsx(EmptyState, { media: _jsx(EmptyArt, { icon: MagnifyingGlassIcon }), title: t('noResultsTitle'), description: t('noResultsDescription') }));
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
body = (_jsxs("div", { className: "space-y-1", children: [mine.length > 0 ? (_jsx(SpaceGroup, { label: t('yourSpaces'), spaces: mine, projectId: projectId, onEdit: setEditing })) : null, shared.length > 0 ? (_jsx(SpaceGroup, { label: t('sharedWithYou'), spaces: shared, projectId: projectId, onEdit: setEditing })) : null] }));
|
|
77
|
+
}
|
|
78
|
+
return (
|
|
79
|
+
// Capped at the screen height so the header bar stays put and only the list scrolls.
|
|
80
|
+
_jsxs("div", { className: "bg-background flex h-svh max-h-svh min-h-0 flex-1 flex-col overflow-clip", children: [_jsxs(ProjectPageHeader, { title: t('title'), children: [spaces.length > 0 ? (_jsxs(_Fragment, { children: [_jsx(ExpandableSearch, { value: search, onValueChange: setSearch, label: t('searchPlaceholder'), size: "sm", buttonVariant: "outline", className: "w-40 sm:w-56" }), _jsx(SortMenu, { value: sort, onValueChange: setSort, options: SORTS.map((mode) => ({ value: mode, label: sortLabel[mode] })), label: t('sortBy', { mode: sortLabel[sort] }) })] })) : null, _jsxs(Button, { size: "sm", className: "gap-1.5", onClick: () => setCreating(true), children: [_jsx(PlusIcon, { className: "size-3.5 shrink-0" }), _jsx("span", { className: "hidden sm:inline", children: t('newSpace') })] })] }), _jsx("div", { className: "min-h-0 flex-1 overflow-y-auto px-2 py-2 sm:px-3", children: body }), _jsx(SpaceFormModal, { projectId: projectId, space: null, open: creating, onOpenChange: setCreating, onSaved: open }), _jsx(SpaceFormModal, { projectId: projectId, space: editing, open: editing !== null, onOpenChange: (next) => {
|
|
81
|
+
if (!next)
|
|
82
|
+
setEditing(null);
|
|
83
|
+
} })] }));
|
|
84
|
+
}
|
|
85
|
+
/** A filled header that folds its rows away, with how many it holds. */
|
|
86
|
+
function SpaceGroup({ label, spaces, projectId, onEdit, }) {
|
|
87
|
+
return (_jsxs(Collapsible, { defaultOpen: true, children: [_jsxs(CollapsibleTrigger, { className: "group/trigger bg-muted/60 text-muted-foreground hover:text-foreground duration-fast flex h-9 w-full items-center gap-2 rounded-md px-3 text-sm transition-colors", children: [_jsx("span", { className: "truncate", children: label }), _jsx("span", { className: "text-muted-foreground tabular-nums", children: spaces.length }), _jsx(CaretDownIcon, { "aria-hidden": true, className: "duration-fast ml-auto size-3.5 shrink-0 transition-transform ease-out group-data-[state=closed]/trigger:-rotate-90" })] }), _jsx(CollapsibleContent, { children: _jsx("ul", { className: "py-1", children: spaces.map((space) => (_jsx(SpaceRow, { projectId: projectId, space: space, onEdit: () => onEdit(space) }, space.group_id))) }) })] }));
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* One space on one line: its icon and name, then fixed columns on the right
|
|
91
|
+
* (who is in it, who can open it, when it last moved, its menu) so every row
|
|
92
|
+
* lines up. The menu shows on hover or focus, and always on touch.
|
|
93
|
+
*/
|
|
94
|
+
function SpaceRow({ projectId, space, onEdit }) {
|
|
95
|
+
const t = useTranslations('sessionSpaces');
|
|
96
|
+
const href = uiRoutes().sessionSpace?.(projectId, space.group_id);
|
|
97
|
+
const audience = spaceAudience(space);
|
|
98
|
+
const when = relativeTime(space.last_activity_at ?? space.updated_at);
|
|
99
|
+
if (!href)
|
|
100
|
+
return null;
|
|
101
|
+
let access;
|
|
102
|
+
if (audience.kind === 'everyone')
|
|
103
|
+
access = { icon: _jsx(UsersThreeIcon, { className: "size-3.5" }), label: t('everyone') };
|
|
104
|
+
else if (audience.kind === 'private')
|
|
105
|
+
access = { icon: _jsx(LockSimpleIcon, { className: "size-3.5" }), label: t('private') };
|
|
106
|
+
else
|
|
107
|
+
access = { icon: _jsx(UsersIcon, { className: "size-3.5" }), label: t('sharedShort') };
|
|
108
|
+
return (_jsxs("li", { className: "group/row hover:bg-hover focus-within:bg-hover duration-fast flex items-center rounded-md pr-2 transition-colors", children: [_jsxs(Link, { href: href, prefetch: true, className: "focus-visible:ring-ring flex h-11 min-w-0 flex-1 items-center gap-3 rounded-md px-3 outline-none focus-visible:ring-2", children: [_jsx(SpaceIconBare, { space: space, className: "size-5 text-base" }), _jsx("span", { className: "text-foreground min-w-0 flex-1 truncate text-sm first-letter:uppercase", children: space.name }), audience.kind === 'people' ? (_jsx("span", { className: "hidden sm:flex", children: _jsx(SessionParticipantStack, { participants: spaceParticipants(space), label: t('peopleCount', { count: space.people?.length ?? 0 }) }) })) : null, _jsxs("span", { className: "text-muted-foreground hidden w-24 shrink-0 items-center gap-1.5 text-xs sm:flex", children: [access.icon, _jsx("span", { className: "truncate", children: access.label })] }), _jsx("span", { className: "text-muted-foreground w-28 shrink-0 text-right text-xs whitespace-nowrap tabular-nums", children: when })] }), _jsx("span", { className: "ml-1 flex w-7 shrink-0 items-center justify-center", children: space.can_manage === true ? (_jsx(SpaceSettingsMenu, { projectId: projectId, space: space, onEdit: onEdit, trigger: _jsx(Button, { variant: "ghost", size: "icon-xs", "aria-label": t('options'), className: "text-muted-foreground hover:text-foreground duration-fast opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-within/row:opacity-100 pointer-coarse:opacity-100 data-[state=open]:opacity-100", children: _jsx(DotsThreeIcon, { weight: "bold", className: "size-4" }) }) })) : null })] }));
|
|
109
|
+
}
|
|
110
|
+
function sortSpaces(spaces, sort) {
|
|
111
|
+
const sorted = [...spaces];
|
|
112
|
+
if (sort === 'name')
|
|
113
|
+
return sorted.sort((a, b) => a.name.localeCompare(b.name, undefined, { sensitivity: 'base' }));
|
|
114
|
+
if (sort === 'created')
|
|
115
|
+
return sorted.sort((a, b) => b.created_at.localeCompare(a.created_at));
|
|
116
|
+
const moved = (space) => space.last_activity_at ?? space.updated_at;
|
|
117
|
+
return sorted.sort((a, b) => moved(b).localeCompare(moved(a)));
|
|
118
|
+
}
|
|
119
|
+
/** "3h ago" from an ISO time; empty when it does not parse. */
|
|
120
|
+
function relativeTime(iso) {
|
|
121
|
+
const at = new Date(iso);
|
|
122
|
+
if (Number.isNaN(at.getTime()))
|
|
123
|
+
return null;
|
|
124
|
+
return formatDistanceToNowStrict(at, { addSuffix: true });
|
|
125
|
+
}
|
|
@@ -23,6 +23,8 @@ export interface SessionOwnerFacetOption {
|
|
|
23
23
|
value: string;
|
|
24
24
|
name: string | null;
|
|
25
25
|
email: string | null;
|
|
26
|
+
/** Their profile picture; null when they have none. */
|
|
27
|
+
avatarUrl?: string | null;
|
|
26
28
|
/** The viewer's own sessions. Rendered as "You" and listed first. */
|
|
27
29
|
isViewer: boolean;
|
|
28
30
|
count: number;
|
|
@@ -50,12 +50,14 @@ export function resolveOwnerFacetOptions(sessions, activeOwners) {
|
|
|
50
50
|
existing.count += 1;
|
|
51
51
|
existing.name ??= session.owner_name ?? null;
|
|
52
52
|
existing.email ??= session.owner_email ?? null;
|
|
53
|
+
existing.avatarUrl ??= session.owner_avatar_url ?? null;
|
|
53
54
|
continue;
|
|
54
55
|
}
|
|
55
56
|
byOwner.set(key, {
|
|
56
57
|
value: key,
|
|
57
58
|
name: session.owner_name ?? null,
|
|
58
59
|
email: session.owner_email ?? null,
|
|
60
|
+
avatarUrl: session.owner_avatar_url ?? null,
|
|
59
61
|
isViewer: key !== UNKNOWN_OWNER_KEY && session.is_owner === true,
|
|
60
62
|
count: 1,
|
|
61
63
|
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* The way back to `/workspaces/<id>/setup`. The workspace home shows it while
|
|
5
|
+
* the setup page has an open step the viewer can finish: a connector to sign
|
|
6
|
+
* in, a required secret, Slack. It counts the same steps as the page. A viewer
|
|
7
|
+
* can dismiss it; the dismissal stays in this browser and holds until a step
|
|
8
|
+
* opens that was not open then.
|
|
9
|
+
*/
|
|
10
|
+
import { useProjectAccountId } from '@kortix/sdk/react';
|
|
11
|
+
import { XIcon } from '@phosphor-icons/react';
|
|
12
|
+
import { useState } from 'react';
|
|
13
|
+
import { useTranslations } from '../../i18n/index.js';
|
|
14
|
+
import { cn } from '../../lib/utils.js';
|
|
15
|
+
import { PROJECT_ACTIONS } from '../../internal/lib/project-actions.js';
|
|
16
|
+
import { useProjectCan } from '../../internal/lib/use-project-can.js';
|
|
17
|
+
import { Alert, AlertActions, AlertTitle } from '../../primitives/alert.js';
|
|
18
|
+
import { Button } from '../../primitives/button.js';
|
|
19
|
+
import { UiLink as Link } from '../../providers/ui-provider.js';
|
|
20
|
+
import { openStepsFor, setupBannerDismissed } from './setup-steps.js';
|
|
21
|
+
import { useSetupSteps } from './use-setup-steps.js';
|
|
22
|
+
const DISMISS_KEY = (projectId) => `kortix.setupBanner.dismissed.${projectId}`;
|
|
23
|
+
/** The step ids that were open when the viewer dismissed the banner, or null. */
|
|
24
|
+
function readDismissed(projectId) {
|
|
25
|
+
try {
|
|
26
|
+
const raw = window.localStorage.getItem(DISMISS_KEY(projectId));
|
|
27
|
+
const ids = raw ? JSON.parse(raw) : null;
|
|
28
|
+
return Array.isArray(ids) ? ids.filter((id) => typeof id === 'string') : null;
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function SetupBanner({ projectId, className }) {
|
|
35
|
+
const t = useTranslations('workspaceSetup');
|
|
36
|
+
const accountId = useProjectAccountId(projectId);
|
|
37
|
+
const canConnect = useProjectCan(projectId, PROJECT_ACTIONS.PROJECT_CONNECTOR_WRITE, { accountId }).allowed === true;
|
|
38
|
+
const canSetSecrets = useProjectCan(projectId, PROJECT_ACTIONS.PROJECT_SECRET_WRITE).allowed === true;
|
|
39
|
+
const { steps } = useSetupSteps(projectId, { enabled: canConnect || canSetSecrets });
|
|
40
|
+
const open = openStepsFor(steps, { connect: canConnect, setSecrets: canSetSecrets });
|
|
41
|
+
const [dismissed, setDismissed] = useState(() => (typeof window === 'undefined' ? null : readDismissed(projectId)));
|
|
42
|
+
if (open.length === 0 || setupBannerDismissed(open, dismissed))
|
|
43
|
+
return null;
|
|
44
|
+
const dismiss = () => {
|
|
45
|
+
const ids = open.map((step) => step.id);
|
|
46
|
+
try {
|
|
47
|
+
window.localStorage.setItem(DISMISS_KEY(projectId), JSON.stringify(ids));
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// Private mode: the banner hides for this view only.
|
|
51
|
+
}
|
|
52
|
+
setDismissed(ids);
|
|
53
|
+
};
|
|
54
|
+
return (
|
|
55
|
+
// One line: the title centers on the button, not on the alert's first line.
|
|
56
|
+
_jsxs(Alert, { variant: "default", className: cn('items-center', className), "data-testid": "setup-banner", children: [_jsx(AlertTitle, { children: t('bannerTitle', { left: open.length }) }), _jsxs(AlertActions, { children: [_jsx(Button, { asChild: true, variant: "outline", size: "sm", children: _jsx(Link, { href: `/workspaces/${projectId}/setup`, children: t('title') }) }), _jsx(Button, { variant: "ghost", size: "icon-xs", "aria-label": t('bannerDismiss'), onClick: dismiss, children: _jsx(XIcon, { className: "size-3.5" }) })] })] }));
|
|
57
|
+
}
|
|
@@ -41,3 +41,17 @@ export declare function setupSteps({ connectors, secrets, slack, slackName, }: {
|
|
|
41
41
|
};
|
|
42
42
|
slackName: string;
|
|
43
43
|
}): SetupStep[];
|
|
44
|
+
/**
|
|
45
|
+
* The open steps this viewer can finish: a secret needs secret write; a
|
|
46
|
+
* connector sign-in and Slack need connector write (the Slack install route
|
|
47
|
+
* checks `project.connector.write`). The home banner counts these.
|
|
48
|
+
*/
|
|
49
|
+
export declare function openStepsFor(steps: SetupStep[], can: {
|
|
50
|
+
connect: boolean;
|
|
51
|
+
setSecrets: boolean;
|
|
52
|
+
}): SetupStep[];
|
|
53
|
+
/**
|
|
54
|
+
* A dismissed banner stays hidden until a step opens that was not open when
|
|
55
|
+
* the viewer dismissed it, for example a connector a later setup added.
|
|
56
|
+
*/
|
|
57
|
+
export declare function setupBannerDismissed(open: SetupStep[], dismissedIds: readonly string[] | null): boolean;
|
|
@@ -36,3 +36,18 @@ export function setupSteps({ connectors, secrets, slack, slackName, }) {
|
|
|
36
36
|
steps.push({ kind: 'slack', id: 'slack', name: slackName, done: slack.installed });
|
|
37
37
|
return [...steps.filter((step) => !step.done), ...steps.filter((step) => step.done)];
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* The open steps this viewer can finish: a secret needs secret write; a
|
|
41
|
+
* connector sign-in and Slack need connector write (the Slack install route
|
|
42
|
+
* checks `project.connector.write`). The home banner counts these.
|
|
43
|
+
*/
|
|
44
|
+
export function openStepsFor(steps, can) {
|
|
45
|
+
return steps.filter((step) => !step.done && (step.kind === 'secret' ? can.setSecrets : can.connect));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A dismissed banner stays hidden until a step opens that was not open when
|
|
49
|
+
* the viewer dismissed it, for example a connector a later setup added.
|
|
50
|
+
*/
|
|
51
|
+
export function setupBannerDismissed(open, dismissedIds) {
|
|
52
|
+
return dismissedIds !== null && open.every((step) => dismissedIds.includes(step.id));
|
|
53
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type SetupStep } from './setup-steps.js';
|
|
2
|
+
/**
|
|
3
|
+
* A workspace's setup steps, read from the cache entries the Customize pages
|
|
4
|
+
* and the project shell's prefetch already fill. The setup page polls them
|
|
5
|
+
* (`pollMs`): the person may finish a step in another tab. The home banner
|
|
6
|
+
* reads them as they are.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useSetupSteps(projectId: string, { slackRequested, pollMs, enabled }?: {
|
|
9
|
+
slackRequested?: boolean;
|
|
10
|
+
pollMs?: number;
|
|
11
|
+
enabled?: boolean;
|
|
12
|
+
}): {
|
|
13
|
+
steps: SetupStep[];
|
|
14
|
+
usesSlack: boolean;
|
|
15
|
+
loading: boolean;
|
|
16
|
+
failed: boolean;
|
|
17
|
+
refresh: () => void;
|
|
18
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { getSlackInstallation, listConnectors, listProjectSecrets } from '@kortix/sdk';
|
|
3
|
+
import { contract, FRESHNESS, qk } from '@kortix/sdk/react';
|
|
4
|
+
import { useQuery } from '@tanstack/react-query';
|
|
5
|
+
import { buildRows } from '../../customize/sections/view/secrets-view.js';
|
|
6
|
+
import { useTranslations } from '../../i18n/index.js';
|
|
7
|
+
import { setupSteps, slackNeeded } from './setup-steps.js';
|
|
8
|
+
/**
|
|
9
|
+
* A workspace's setup steps, read from the cache entries the Customize pages
|
|
10
|
+
* and the project shell's prefetch already fill. The setup page polls them
|
|
11
|
+
* (`pollMs`): the person may finish a step in another tab. The home banner
|
|
12
|
+
* reads them as they are.
|
|
13
|
+
*/
|
|
14
|
+
export function useSetupSteps(projectId, { slackRequested = false, pollMs, enabled = true } = {}) {
|
|
15
|
+
const t = useTranslations('workspaceSetup');
|
|
16
|
+
const connectorsQuery = useQuery({
|
|
17
|
+
queryKey: qk.project.connectors(projectId),
|
|
18
|
+
queryFn: () => listConnectors(projectId, { includeSchemas: false }),
|
|
19
|
+
...contract(FRESHNESS.connectors),
|
|
20
|
+
enabled,
|
|
21
|
+
});
|
|
22
|
+
const secretsQuery = useQuery({
|
|
23
|
+
queryKey: qk.project.secrets(projectId),
|
|
24
|
+
queryFn: () => listProjectSecrets(projectId),
|
|
25
|
+
...contract('config'),
|
|
26
|
+
refetchOnWindowFocus: true,
|
|
27
|
+
refetchInterval: pollMs ?? false,
|
|
28
|
+
enabled,
|
|
29
|
+
});
|
|
30
|
+
const connectors = connectorsQuery.data?.connectors ?? [];
|
|
31
|
+
const usesSlack = slackNeeded(connectors, slackRequested);
|
|
32
|
+
// The same cache entry as the Channels page (`useSlackInstall`).
|
|
33
|
+
const slackInstallQuery = useQuery({
|
|
34
|
+
queryKey: ['channels', 'slack-install', projectId],
|
|
35
|
+
queryFn: () => getSlackInstallation(projectId),
|
|
36
|
+
enabled: enabled && usesSlack,
|
|
37
|
+
refetchOnWindowFocus: true,
|
|
38
|
+
refetchInterval: (query) => (pollMs && !query.state.data ? pollMs : false),
|
|
39
|
+
});
|
|
40
|
+
const loading = connectorsQuery.isLoading || secretsQuery.isLoading || (usesSlack && slackInstallQuery.isLoading);
|
|
41
|
+
const failed = connectorsQuery.isError || secretsQuery.isError;
|
|
42
|
+
const steps = !enabled || loading || failed
|
|
43
|
+
? []
|
|
44
|
+
: setupSteps({
|
|
45
|
+
connectors,
|
|
46
|
+
secrets: buildRows(secretsQuery.data),
|
|
47
|
+
slack: { needed: usesSlack, installed: Boolean(slackInstallQuery.data) },
|
|
48
|
+
slackName: t('slackName'),
|
|
49
|
+
});
|
|
50
|
+
const refresh = () => {
|
|
51
|
+
void connectorsQuery.refetch();
|
|
52
|
+
void secretsQuery.refetch();
|
|
53
|
+
if (usesSlack)
|
|
54
|
+
void slackInstallQuery.refetch();
|
|
55
|
+
};
|
|
56
|
+
return { steps, usesSlack, loading, failed, refresh };
|
|
57
|
+
}
|