mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-25 07:27:13 +01:00
feat(ui): show the Cloud Slack invitation in the workspace sidebar (#22702)
## Thinking Path > - Teams use Paperclip to manage agents and their work. > - Hosted teams can have a private Slack channel with the Paperclip team. > - A workspace member needs to know whether they can open the channel or still need the owner's invitation. > - Cloud supplies that information for the selected organization. > - This change puts a Slack button in the sidebar footer. It opens a dialog with the next action. ## Linked Issues or Issue Description **Subsystem affected** Workspace sidebar and the Cloud onboarding browser journey. **Problem or motivation** After setup, a user can lose track of the invitation to their organization's private feedback channel. **Proposed solution** Show the invitation status in a dialog. Offer a channel link when Cloud confirms the connection. **Roadmap alignment** This extends the existing hosted workspace navigation. The roadmap has no separate item for this shortcut. ## What Changed - Both sidebar variants use the existing portfolio request to show the Slack shortcut when Cloud supplies invitation details. - The icon uses grayscale at rest and brand colors on hover or keyboard focus. The button has an accessible name and a tooltip. - The Cloud onboarding journey selects Codex and confirms feedback intent when the first-account welcome appears. - Storybook covers pending and connected channels. ## Verification - The sidebar suite passed 36 tests. The Cloud onboarding journey suite passed 10 tests covering both the current and previous gateway layouts. - The Storybook catalog regenerated successfully. - In a local browser run, a fresh user completed signup, connected a test model, hired an agent, opened its chat, and opened and dismissed the Slack invitation. The test used a local Slack fixture. - The incremental verifier selected broad CI coverage for the runner journey change. All applicable checks passed on `ea9779abda`. A GitHub runner shut down during a server test shard. The shard and final verification gate passed on retry. [CI run](https://github.com/paperclipai/paperclip/actions/runs/45276376121/attempts/2) · [Greptile review (5/5)](https://github.com/paperclipai/paperclip/pull/22702#issuecomment-7115303606) ## Risks An older Cloud service can omit the optional feedback field. In that case, the sidebar keeps the existing layout. Cloud controls the channel destination and the invitation state. ## Model Used OpenAI GPT-6 in Codex, with repository tools and browser verification. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Scott Tong <1504818+scotttong@users.noreply.github.com> Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
11 files changed
+190
-57
No files matched your search
@@ -18,14 +18,15 @@ vi.mock("./onboarding-first-task.js", async () => {
|
||||
}) };
|
||||
});
|
||||
|
||||
type Entry = "first-run" | "portfolio" | "create-form";
|
||||
type Entry = "beta-welcome" | "first-run" | "portfolio" | "create-form";
|
||||
type Control = { role: string; name: string; scope?: string; fill?(value: string): void; click?(): void; select?(value: string): void };
|
||||
|
||||
/** Visible control contracts only; no browser, Cloud API, or provider is started. */
|
||||
function fixture(entry: Entry, options: { intentFailure?: boolean; qualificationFailure?: boolean; traceFailure?: boolean } = {}) {
|
||||
function fixture(entry: Entry, options: { legacyRunnerPicker?: boolean; intentFailure?: boolean; qualificationFailure?: boolean; traceFailure?: boolean } = {}) {
|
||||
let stage: string = entry, name = "", apiMode = false, source = false, advanced = false, runnerOpen = false;
|
||||
let modelsOpen = false, model = "", runner = "", saved = false, hired = false;
|
||||
const fields: Record<string, string> = {}, events: string[] = [];
|
||||
let hasCodex = false, intendsFeedback = false;
|
||||
const gateway = { baseUrl: "https://owned-gateway.example.test/v1", model: "gpt-5.4-mini", apiKey: "synthetic-test-key" };
|
||||
const connection = { id: "connection", name: "My owned-gateway.example.test", provider: "openai", method: "api_key", status: "connected" };
|
||||
const create = () => {
|
||||
@@ -34,6 +35,11 @@ function fixture(entry: Entry, options: { intentFailure?: boolean; qualification
|
||||
events.push("create:workspace"); stage = "agent";
|
||||
};
|
||||
const controls = (): Control[] => {
|
||||
if (stage === "beta-welcome") return [
|
||||
{ role: "checkbox", name: "OpenAI Codex", click() { hasCodex = true; } },
|
||||
{ role: "checkbox", name: "I intend to provide feedback on the Paperclip closed beta.", click() { intendsFeedback = true; } },
|
||||
{ role: "button", name: "Continue", click() { expect(hasCodex && intendsFeedback).toBe(true); stage = "first-run"; } },
|
||||
];
|
||||
if (stage === "portfolio") return [{ role: "link", name: "Create a new organization", click() { stage = "create-form"; } }];
|
||||
if (stage === "first-run" || stage === "create-form") return [
|
||||
{ role: "textbox", name: stage === "first-run" ? "Name" : "Organization name", fill(value) { name = value; } },
|
||||
@@ -50,7 +56,7 @@ function fixture(entry: Entry, options: { intentFailure?: boolean; qualification
|
||||
{ role: "button", name: apiMode ? "Use subscription instead" : "Use API key instead", click() { apiMode = !apiMode; } },
|
||||
{ role: "radio", name: apiMode ? "OpenAI API key" : "OpenAI Subscription", click() { source = true; } },
|
||||
];
|
||||
if (source && apiMode) result.push({ role: "button", name: "Use a custom gateway", click() { stage = "gateway"; } });
|
||||
if (source && apiMode && (advanced || options.legacyRunnerPicker)) result.push({ role: "button", name: "Use a custom gateway", click() { stage = "gateway"; } });
|
||||
if (stage === "gateway") {
|
||||
result.push({ role: "dialog", name: "Custom gateway connection" });
|
||||
for (const field of ["Provider URL", "API key", ...(modelsOpen ? ["Model IDs"] : [])]) result.push({
|
||||
@@ -64,9 +70,9 @@ function fixture(entry: Entry, options: { intentFailure?: boolean; qualification
|
||||
}
|
||||
if (saved) result.push({ role: "combobox", name: "Model", select(value) { expect(value).toBe(gateway.model); model = value; } });
|
||||
if (source) result.push({ role: "summary", name: "Advanced", click() { advanced = true; } });
|
||||
if (advanced) result.push({ role: "button", name: "Runner", click() { runnerOpen = true; } });
|
||||
if (advanced && options.legacyRunnerPicker) result.push({ role: "button", name: "Runner", click() { runnerOpen = true; } });
|
||||
if (runnerOpen) result.push({ role: "option", name: "Paperclip Runner (default)", click() { runner = "paperclip"; runnerOpen = false; } });
|
||||
if (saved && model && runner) result.push({ role: "button", name: "Connect", click() {
|
||||
if (saved && model && (!options.legacyRunnerPicker || runner)) result.push({ role: "button", name: "Connect", click() {
|
||||
expect(events).toContain("qualified"); events.push("paid:connect"); hired = true;
|
||||
} });
|
||||
return result;
|
||||
@@ -77,6 +83,7 @@ function fixture(entry: Entry, options: { intentFailure?: boolean; qualification
|
||||
or(other: { resolve(): Control[] }) { return locator(() => [...resolve(), ...other.resolve()]); },
|
||||
resolve,
|
||||
async isVisible() { return resolve().length > 0; },
|
||||
async check() { const control = resolve()[0]; if (control?.role !== "checkbox" || !control.click) throw new Error("No visible checkbox"); control.click(); },
|
||||
async fill(value: string) { const control = resolve()[0]; if (!control?.fill) throw new Error("No visible text field"); control.fill(value); },
|
||||
async click() { const control = resolve()[0]; if (!control?.click) throw new Error("No visible action"); events.push(`click:${control.name}`); control.click(); },
|
||||
async selectOption(value: string) { const control = resolve()[0]; if (!control?.select) throw new Error("No visible native model picker"); control.select(value); },
|
||||
@@ -134,7 +141,7 @@ describe("Cloud onboarding visible controls", () => {
|
||||
expect(f.input.evidence.checks.map(check => check.id)).toEqual(["fresh-workspace", "ui-connection-and-native-agent"]);
|
||||
expect(f.events).not.toContain("native:verified");
|
||||
});
|
||||
it.each(["first-run", "portfolio", "create-form"] as const)("creates from %s with intent before dispatch and qualification before paid Connect", async entry => {
|
||||
it.each(["beta-welcome", "first-run", "portfolio", "create-form"] as const)("creates from %s with intent before dispatch and qualification before paid Connect", async entry => {
|
||||
const f = fixture(entry);
|
||||
const result = await cloudOnboarding(f.input);
|
||||
expect(result.startingState).toBe("onboarding");
|
||||
@@ -143,6 +150,12 @@ describe("Cloud onboarding visible controls", () => {
|
||||
expect(f.events.indexOf("qualified")).toBeLessThan(f.events.indexOf("paid:connect"));
|
||||
expect(f.events).toContain("native:verified");
|
||||
});
|
||||
it("can still choose the native runner on tenants with a separate runner picker", async () => {
|
||||
const f = fixture("first-run", { legacyRunnerPicker: true });
|
||||
await cloudOnboarding(f.input);
|
||||
expect(f.events).toContain("click:Paperclip Runner (default)");
|
||||
expect(f.events).toContain("native:verified");
|
||||
});
|
||||
it("does not dispatch workspace creation without durable ownership", async () => {
|
||||
const f = fixture("first-run", { intentFailure: true });
|
||||
await expect(cloudOnboarding(f.input)).rejects.toThrow("ownership unavailable");
|
||||
|
||||
@@ -28,9 +28,16 @@ export async function cloudOnboarding(input: CloudOnboardingInput): Promise<Jour
|
||||
const firstRunName = page.getByLabel("Name", { exact: true });
|
||||
const organizationName = page.getByLabel("Organization name", { exact: true });
|
||||
const createLink = page.getByRole("link", { name: /^(Create (?:a new )?organization|\+ New organization)$/ }).first();
|
||||
const betaConnection = page.getByRole("checkbox", { name: "OpenAI Codex", exact: true });
|
||||
// The first organization uses the signup Name/Next form. Later organizations
|
||||
// use Organization name/Create organization, reached from the managed portfolio.
|
||||
await expect(firstRunName.or(organizationName).or(createLink).first()).toBeVisible();
|
||||
await expect(betaConnection.or(firstRunName).or(organizationName).or(createLink).first()).toBeVisible();
|
||||
if (await betaConnection.isVisible()) {
|
||||
await betaConnection.check();
|
||||
await page.getByRole("checkbox", { name: "I intend to provide feedback on the Paperclip closed beta.", exact: true }).check();
|
||||
await page.getByRole("button", { name: "Continue", exact: true }).click();
|
||||
await expect(firstRunName).toBeVisible();
|
||||
}
|
||||
if (!await firstRunName.isVisible() && !await organizationName.isVisible()) {
|
||||
await createLink.click();
|
||||
await expect(organizationName).toBeVisible();
|
||||
@@ -50,7 +57,13 @@ export async function cloudOnboarding(input: CloudOnboardingInput): Promise<Jour
|
||||
await page.getByRole("button", { name: "Next", exact: true }).click();
|
||||
await page.getByRole("button", { name: "Use API key instead", exact: true }).click();
|
||||
await page.getByRole("radio", { name: /OpenAI.*API/ }).click();
|
||||
await page.getByRole("button", { name: "Use a custom gateway", exact: true }).click();
|
||||
const gatewayButton = page.getByRole("button", { name: "Use a custom gateway", exact: true });
|
||||
const advanced = page.locator("summary").filter({ hasText: "Advanced" });
|
||||
await expect(gatewayButton.or(advanced).first()).toBeVisible();
|
||||
// Older tenants show the gateway inline and keep the runner picker in Advanced.
|
||||
const inlineGateway = await gatewayButton.isVisible();
|
||||
if (!inlineGateway) await advanced.click();
|
||||
await gatewayButton.click();
|
||||
const dialog = page.getByRole("dialog", { name: "Custom gateway connection", exact: true });
|
||||
await dialog.getByLabel("Provider URL", { exact: true }).fill(input.gateway.baseUrl);
|
||||
await dialog.getByLabel("API key", { exact: true }).fill(input.gateway.apiKey);
|
||||
@@ -65,9 +78,11 @@ export async function cloudOnboarding(input: CloudOnboardingInput): Promise<Jour
|
||||
if (!connection || connections.length !== 1) throw new JourneyError("failed", "onboarding_connection_not_saved");
|
||||
await input.own({ kind: "connection", name: connectionName, id: connection.id });
|
||||
await page.getByRole("combobox", { name: "Model", exact: true }).selectOption(input.gateway.model);
|
||||
await page.locator("summary").filter({ hasText: "Advanced" }).click();
|
||||
await page.getByRole("button", { name: "Runner", exact: true }).click();
|
||||
await page.getByRole("option", { name: /^Paperclip Runner/ }).click();
|
||||
if (inlineGateway) {
|
||||
await advanced.click();
|
||||
await page.getByRole("button", { name: "Runner", exact: true }).click();
|
||||
await page.getByRole("option", { name: /^Paperclip Runner/ }).click();
|
||||
}
|
||||
await input.qualify(context, connection.id);
|
||||
// Connect performs the production probe and agent creation. Never press Retry.
|
||||
const connect = await onboardingConnect({ page, origin: api.origin, companyId: company.id, deadlineAt: input.deadlineAt,
|
||||
|
||||
@@ -17,6 +17,8 @@ export type CloudStackSummary = {
|
||||
|
||||
export type CloudStackPortfolio = {
|
||||
stacks: CloudStackSummary[];
|
||||
/** Scoped to the calling tenant. Older deployments omit the shortcut. */
|
||||
slackFeedback?: { href: string } | { message: string };
|
||||
};
|
||||
|
||||
export const cloudApi = {
|
||||
|
||||
@@ -12,7 +12,8 @@ import { Link } from "@/lib/router";
|
||||
import { authApi } from "@/api/auth";
|
||||
import { queryKeys } from "@/lib/queryKeys";
|
||||
import { useCloudInstance } from "@/hooks/useCloudInstance";
|
||||
import { useCloudInviteUrl } from "@/hooks/useCloudInviteUrl";
|
||||
import { useCloudSidebarLinks } from "@/hooks/useCloudSidebarLinks";
|
||||
import { SidebarSlackFeedback } from "./SidebarSlackFeedback";
|
||||
import { useCanInviteCompanyMembers } from "@/hooks/useCompanyInviteAccess";
|
||||
import { useHiddenSettings } from "@/hooks/useHiddenSettings";
|
||||
import { useSignOut } from "@/hooks/useSignOut";
|
||||
@@ -129,7 +130,7 @@ export function SidebarAccountMenu({
|
||||
// On Cloud the shortcut exists only for the current stack's owner/admin and
|
||||
// only once the stack metadata is known; the in-app Invites tab is never a
|
||||
// fallback there because it drives a different invitation flow.
|
||||
const cloudInviteUrl = useCloudInviteUrl();
|
||||
const { inviteUrl: cloudInviteUrl, slackFeedback } = useCloudSidebarLinks(cloud);
|
||||
// Self-hosted invites need the `users:invite` grant. Offer the shortcut only
|
||||
// to boards with role-default access (company owner/admin/operator,
|
||||
// instance admins, local boards). The server checks the actual grants.
|
||||
@@ -275,6 +276,7 @@ export function SidebarAccountMenu({
|
||||
</div>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
{slackFeedback && <SidebarSlackFeedback feedback={slackFeedback} className="hover:bg-accent/50" />}
|
||||
{!isCloud ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
|
||||
@@ -128,6 +128,7 @@ describe("SidebarAccountMenu", () => {
|
||||
let container: HTMLDivElement;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.stubGlobal("ResizeObserver", class { observe() {} unobserve() {} disconnect() {} });
|
||||
container = document.createElement("div");
|
||||
document.body.appendChild(container);
|
||||
mockAuthApi.getSession.mockResolvedValue({
|
||||
@@ -472,7 +473,7 @@ describe("SidebarAccountMenu", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it.each([SidebarAccountMenu, ProductionSidebarAccountMenu])("hides cloud feedback and signs out through the harness (%#)", async (AccountMenu) => {
|
||||
it.each([SidebarAccountMenu, ProductionSidebarAccountMenu])("opens the current Cloud Slack channel and signs out through the harness (%#)", async (AccountMenu) => {
|
||||
const root = createRoot(container);
|
||||
const onOpenChange = vi.fn();
|
||||
const queryClient = new QueryClient({
|
||||
@@ -488,7 +489,8 @@ describe("SidebarAccountMenu", () => {
|
||||
cloudBaseUrl: "https://cloud.example.test",
|
||||
},
|
||||
});
|
||||
queryClient.setQueryData(queryKeys.cloud.stacks, cloudStacksPortfolio("owner"));
|
||||
const channelUrl = "https://slack.com/app_redirect?channel=CTEST";
|
||||
queryClient.setQueryData(queryKeys.cloud.stacks, { ...cloudStacksPortfolio("owner"), slackFeedback: { href: channelUrl } });
|
||||
|
||||
await act(async () => {
|
||||
root.render(
|
||||
@@ -506,6 +508,9 @@ describe("SidebarAccountMenu", () => {
|
||||
await flushReact();
|
||||
|
||||
expect(container.querySelector('a[aria-label="Share feedback"]')).toBeNull();
|
||||
const slack = container.querySelector<HTMLButtonElement>('button[aria-label="Slack the Paperclip team"]');
|
||||
expect(slack?.getAttribute("aria-haspopup")).toBe("dialog");
|
||||
expect(slack?.querySelector("img")?.getAttribute("src")).toBe("/brands/apps/slack.svg");
|
||||
|
||||
// Cloud manages invitations in the stack's People settings, reached with a
|
||||
// same-tab top-level navigation rather than the in-app router.
|
||||
@@ -534,6 +539,13 @@ describe("SidebarAccountMenu", () => {
|
||||
expect(mockNavigateTopLevel).toHaveBeenCalledWith("/cloud/logout");
|
||||
expect(onOpenChange).toHaveBeenCalledWith(false);
|
||||
|
||||
await act(() => slack!.click());
|
||||
const dialog = document.body.querySelector('[data-slot="dialog-content"]');
|
||||
expect(dialog?.textContent).toContain("inbox for the Slack invitation");
|
||||
const channel = dialog?.querySelector("a");
|
||||
expect(channel?.getAttribute("href")).toBe(channelUrl);
|
||||
expect(channel?.target).toBe("_blank");
|
||||
|
||||
await act(async () => {
|
||||
root.unmount();
|
||||
});
|
||||
@@ -557,7 +569,8 @@ describe("SidebarAccountMenu", () => {
|
||||
// Company roles can differ from Cloud roles; the Members page only offers
|
||||
// the Cloud invite link to the current stack's owner/admin, so the menu
|
||||
// must match rather than send a plain member to People settings.
|
||||
queryClient.setQueryData(queryKeys.cloud.stacks, cloudStacksPortfolio("member"));
|
||||
const message = "Open the invitation emailed to your organization’s owner.";
|
||||
queryClient.setQueryData(queryKeys.cloud.stacks, { ...cloudStacksPortfolio("member"), slackFeedback: { message } });
|
||||
|
||||
await act(async () => {
|
||||
root.render(
|
||||
@@ -576,6 +589,17 @@ describe("SidebarAccountMenu", () => {
|
||||
expect(popover?.querySelector('a[href="/company/settings/members?tab=invites"]')).toBeNull();
|
||||
expect(popover?.querySelector('a[aria-label="View profile"]')).not.toBeNull();
|
||||
|
||||
const slack = container.querySelector<HTMLButtonElement>('button[aria-label="Slack the Paperclip team"]');
|
||||
expect(slack).not.toBeNull();
|
||||
await act(() => slack!.click());
|
||||
await flushReact();
|
||||
const dialog = document.body.querySelector('[data-slot="dialog-content"]');
|
||||
expect(dialog?.querySelector('[data-slot="dialog-description"]')?.textContent).toBe(message);
|
||||
expect(dialog?.querySelector("a")).toBeNull();
|
||||
const done = Array.from(dialog!.querySelectorAll("button")).find((button) => button.textContent === "Got it");
|
||||
await act(() => done!.click());
|
||||
expect(document.body.querySelector('[data-slot="dialog-content"]')).toBeNull();
|
||||
|
||||
await act(async () => {
|
||||
root.unmount();
|
||||
});
|
||||
|
||||
@@ -13,7 +13,8 @@ import { Link } from "@/lib/router";
|
||||
import { authApi } from "@/api/auth";
|
||||
import { queryKeys } from "@/lib/queryKeys";
|
||||
import { useCloudInstance } from "@/hooks/useCloudInstance";
|
||||
import { useCloudInviteUrl } from "@/hooks/useCloudInviteUrl";
|
||||
import { useCloudSidebarLinks } from "@/hooks/useCloudSidebarLinks";
|
||||
import { SidebarSlackFeedback } from "./SidebarSlackFeedback";
|
||||
import { useCanInviteCompanyMembers } from "@/hooks/useCompanyInviteAccess";
|
||||
import { useHiddenSettings } from "@/hooks/useHiddenSettings";
|
||||
import { useSignOut } from "@/hooks/useSignOut";
|
||||
@@ -129,7 +130,7 @@ export function SidebarAccountMenu({
|
||||
// On Cloud the shortcut exists only for the current stack's owner/admin and
|
||||
// only once the stack metadata is known; the in-app Invites tab is never a
|
||||
// fallback there because it drives a different invitation flow.
|
||||
const cloudInviteUrl = useCloudInviteUrl();
|
||||
const { inviteUrl: cloudInviteUrl, slackFeedback } = useCloudSidebarLinks(cloud);
|
||||
// Self-hosted invites need the `users:invite` grant. Offer the shortcut only
|
||||
// to boards with role-default access (company owner/admin/operator,
|
||||
// instance admins, local boards). The server checks the actual grants.
|
||||
@@ -275,6 +276,7 @@ export function SidebarAccountMenu({
|
||||
</FlyoutOptions>
|
||||
</FlyoutContent>
|
||||
</Popover>
|
||||
{slackFeedback && <SidebarSlackFeedback feedback={slackFeedback} className="hover:bg-sidebar-accent" />}
|
||||
{!isCloud ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import type { CloudStackPortfolio } from "@/api/cloud";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Button } from "./ui/button";
|
||||
import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "./ui/dialog";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip";
|
||||
|
||||
const label = "Slack the Paperclip team";
|
||||
|
||||
export function SidebarSlackFeedback({ feedback, className }: {
|
||||
feedback: NonNullable<CloudStackPortfolio["slackFeedback"]>;
|
||||
className: string;
|
||||
}) {
|
||||
const triggerClass = cn("group flex size-8 shrink-0 items-center justify-center rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", className);
|
||||
const logo = <img src="/brands/apps/slack.svg" alt="" className="size-4 grayscale group-hover:grayscale-0 group-focus-visible:grayscale-0" />;
|
||||
return (
|
||||
<Dialog>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<DialogTrigger asChild>
|
||||
<button type="button" aria-label={label} className={triggerClass}>{logo}</button>
|
||||
</DialogTrigger>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="top">{label}</TooltipContent>
|
||||
</Tooltip>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Your private Slack channel</DialogTitle>
|
||||
<DialogDescription>
|
||||
{"message" in feedback ? feedback.message : "Open your shared channel to talk with the Paperclip team. If you still need to join, check your organization owner’s inbox for the Slack invitation."}
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogFooter>
|
||||
{"href" in feedback ? (
|
||||
<Button asChild><a href={feedback.href} target="_blank" rel="noreferrer">Open Slack channel</a></Button>
|
||||
) : (
|
||||
<DialogClose asChild><Button>Got it</Button></DialogClose>
|
||||
)}
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { cloudApi } from "@/api/cloud";
|
||||
import { queryKeys } from "@/lib/queryKeys";
|
||||
import { cloudStackInviteUrl } from "@/lib/cloudLinks";
|
||||
import { useCloudInstance } from "./useCloudInstance";
|
||||
|
||||
/**
|
||||
* Where the signed-in user invites people on a Paperclip Cloud instance, or
|
||||
* null when no Cloud invite link should be offered.
|
||||
*
|
||||
* Mirrors the Members page: Cloud manages human invitations in the current
|
||||
* stack's People settings, and only that stack's owner or admin may invite
|
||||
* (company roles can differ from Cloud roles, so the company membership is
|
||||
* not enough). Resolves to null on self-hosted instances, while the stack
|
||||
* portfolio is still loading or has failed, for every other stack role, and
|
||||
* when the stack slug or cloud base URL is unknown.
|
||||
*
|
||||
* Callers must not substitute the in-app Invites tab when this is null on a
|
||||
* Cloud instance: that tab drives in-app invitations, a different flow from
|
||||
* Cloud People settings. Offer no shortcut instead.
|
||||
*/
|
||||
export function useCloudInviteUrl(): string | null {
|
||||
const cloud = useCloudInstance();
|
||||
const isCloud = Boolean(cloud);
|
||||
const cloudStacksQuery = useQuery({
|
||||
queryKey: queryKeys.cloud.stacks,
|
||||
queryFn: () => cloudApi.listStacks(),
|
||||
enabled: isCloud,
|
||||
staleTime: 30_000,
|
||||
});
|
||||
if (!cloud) return null;
|
||||
// Read from data, not `isError`: a cached stack list stays answerable while
|
||||
// a transient refetch fails. A no-data failure leaves the current stack
|
||||
// unknown,which falls through to `null` for every role below.
|
||||
const currentStack = cloudStacksQuery.data?.stacks.find((stack) => stack.isCurrent);
|
||||
if (currentStack?.role !== "owner" && currentStack?.role !== "admin") return null;
|
||||
return cloudStackInviteUrl(cloud.cloudBaseUrl, currentStack.stackSlug);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { cloudApi } from "@/api/cloud";
|
||||
import type { CloudInstanceHealthStatus } from "@/api/health";
|
||||
import { queryKeys } from "@/lib/queryKeys";
|
||||
import { cloudStackInviteUrl } from "@/lib/cloudLinks";
|
||||
|
||||
/**
|
||||
* Resolve the current tenant's feedback and invitation shortcuts from one portfolio read.
|
||||
*
|
||||
* Cloud owns feedback availability. Its People settings link is limited to
|
||||
* stack owners and admins, matching the Members page's invitation shortcut.
|
||||
*/
|
||||
export function useCloudSidebarLinks(cloud: CloudInstanceHealthStatus | null) {
|
||||
const isCloud = Boolean(cloud);
|
||||
const cloudStacksQuery = useQuery({
|
||||
queryKey: queryKeys.cloud.stacks,
|
||||
queryFn: () => cloudApi.listStacks(),
|
||||
enabled: isCloud,
|
||||
staleTime: 30_000,
|
||||
});
|
||||
if (!cloud) return { inviteUrl: null, slackFeedback: undefined };
|
||||
// Read from data, not `isError`: a cached stack list stays answerable while
|
||||
// a transient refetch fails. A no-data failure leaves the current stack
|
||||
// unknown, so the invitation shortcut stays hidden.
|
||||
const currentStack = cloudStacksQuery.data?.stacks.find((stack) => stack.isCurrent);
|
||||
const inviteUrl = currentStack?.role === "owner" || currentStack?.role === "admin"
|
||||
? cloudStackInviteUrl(cloud.cloudBaseUrl, currentStack.stackSlug)
|
||||
: null;
|
||||
return { inviteUrl, slackFeedback: cloudStacksQuery.data?.slackFeedback };
|
||||
}
|
||||
@@ -35,7 +35,7 @@ export function canInviteCompanyMembers(
|
||||
* Whether the signed-in board may invite people to the selected company on a
|
||||
* self-hosted instance. Pass `enabled: false` on Cloud, where invitations live
|
||||
* in the stack's People settings and use a different rule
|
||||
* (see `useCloudInviteUrl`).
|
||||
* (see `useCloudSidebarLinks`).
|
||||
*/
|
||||
export function useCanInviteCompanyMembers(enabled = true): boolean {
|
||||
const company = useOptionalCompany();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useEffect, type ReactNode } from "react";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import type { Meta, StoryObj } from "@storybook/react-vite";
|
||||
import {
|
||||
Bot,
|
||||
@@ -34,6 +35,9 @@ import { Tabs } from "@/components/ui/tabs";
|
||||
import { BreadcrumbProvider, useBreadcrumbs, type Breadcrumb } from "@/context/BreadcrumbContext";
|
||||
import { useNavigate } from "@/lib/router";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { healthApi } from "@/api/health";
|
||||
import { queryKeys } from "@/lib/queryKeys";
|
||||
import { prepareFixtureApi } from "../../support/capability-gaps/api";
|
||||
import {
|
||||
storybookAgents,
|
||||
storybookIssues,
|
||||
@@ -369,6 +373,43 @@ type Story = StoryObj<typeof meta>;
|
||||
|
||||
export const BoardChromeMatrix: Story = {};
|
||||
|
||||
function CloudSidebar() {
|
||||
useQuery({ queryKey: queryKeys.health, queryFn: healthApi.get });
|
||||
return (
|
||||
<div className="flex h-dvh w-60 flex-col border-r border-border bg-background">
|
||||
<div className="min-h-0 flex-1 overflow-hidden"><Sidebar /></div>
|
||||
<SidebarAccountMenu deploymentMode="authenticated" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export const CloudSlackFeedback: Story = {
|
||||
render: () => <CloudSidebar />,
|
||||
beforeEach: ({ parameters }) => prepareFixtureApi([
|
||||
{ path: "/api/health", read: () => ({ status: "ok", deploymentMode: "authenticated", cloud: {
|
||||
managed: true, managedBy: "paperclip-cloud", stackSlug: "example", cloudBaseUrl: "https://cloud.example.test",
|
||||
} }) },
|
||||
{ path: "/api/cloud/stacks", read: () => ({
|
||||
stacks: [{ displayName: "Example", stackSlug: "example", primaryHost: "example.test", lifecycleState: "active", sleepState: "awake", role: "owner", isCurrent: true }],
|
||||
slackFeedback: parameters.invitePending
|
||||
? { message: "We emailed a Slack invitation to your organization’s owner. Check that inbox and accept the invitation to join your private channel with the Paperclip team." }
|
||||
: { href: "https://slack.com/app_redirect?channel=CEXAMPLE" },
|
||||
}) },
|
||||
]).cleanup,
|
||||
parameters: {
|
||||
layout: "fullscreen",
|
||||
paperclip: {
|
||||
capabilities: ["navigation-preferences/navigation"], implementation: "production", boundary: "fixtures",
|
||||
notes: "Mounts the workspace sidebar and account footer with a simulated Cloud portfolio. The Slack channel ID is a fixture.",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const CloudSlackInvitationPending: Story = {
|
||||
...CloudSlackFeedback,
|
||||
parameters: { ...CloudSlackFeedback.parameters, invitePending: true },
|
||||
};
|
||||
|
||||
// PAP-10676 verification harness: renders the real Sidebar at a fixed width so a
|
||||
// screenshot of the expanded state and a screenshot of the pinned-collapsed rail
|
||||
// can be overlaid. The icon column must be pixel-identical between the two — the
|
||||
|
||||
Reference in new issue
Block a user