Repository navigation
feat(web): Kanidm sign-in, sharing and person-grouped sidebar (fork) #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b842bc0
feat(web): sign in with Kanidm, share sessions and group them by person
caniko abeaa40
ci: typecheck and test the fork's web session-sharing code on stacked…
caniko f78f4bd
ci: run the fork's web tests even when an upstream server test fails
caniko 9b0ef9d
test(web): render the share dialog under the app atom registry
caniko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
apps/web/src/components/chat/ComposerSessionViewerBanner.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import type { ScopedThreadRef } from "@t3tools/contracts"; | ||
|
|
||
| import { useThreadAccessRole } from "../../state/sessionAccess"; | ||
| import { ComposerBanner } from "./ComposerBanner"; | ||
|
|
||
| /** Tells a viewer why the composer is off; its owner must make them a participant to let them send. */ | ||
| export function ComposerSessionViewerBanner({ | ||
| threadRef, | ||
| }: { | ||
| readonly threadRef: ScopedThreadRef | null; | ||
| }) { | ||
| if (useThreadAccessRole(threadRef) !== "viewer") return null; | ||
| return ( | ||
| <ComposerBanner.Attachment> | ||
| <ComposerBanner.Root variant="info"> | ||
| <ComposerBanner.Row> | ||
| <ComposerBanner.Icon /> | ||
| <ComposerBanner.Content> | ||
| <span className="min-w-0 flex-1 text-foreground/85"> | ||
| You can read this session. Ask its owner for participant access to send messages. | ||
| </span> | ||
| </ComposerBanner.Content> | ||
| </ComposerBanner.Row> | ||
| </ComposerBanner.Root> | ||
| </ComposerBanner.Attachment> | ||
| ); | ||
| } |
59 changes: 59 additions & 0 deletions
59
apps/web/src/components/chat/ShareThreadDialog.browser.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import { EnvironmentId, ThreadId } from "@t3tools/contracts"; | ||
| import { expect, it, vi } from "vite-plus/test"; | ||
| import { page, userEvent } from "vite-plus/test/browser"; | ||
|
|
||
| import { act, render } from "../../../test/render"; | ||
| import { AppAtomRegistryProvider } from "../../rpc/atomRegistry"; | ||
|
|
||
| const access = vi.hoisted(() => ({ mutate: vi.fn() })); | ||
|
|
||
| vi.mock(import("~/state/sessionAccess"), async (original) => ({ | ||
| ...(await original()), | ||
| useSessionAccess: (() => ({ principal: "can", snapshot: null, refresh: vi.fn() })) as never, | ||
| useSessionAccessMutation: (() => ({ canMutate: true, mutate: access.mutate })) as never, | ||
| })); | ||
| vi.mock(import("~/state/query"), async (original) => ({ | ||
| ...(await original()), | ||
| useEnvironmentQuery: (() => ({ | ||
| data: { shares: [{ principal: "dejana", role: "participant" }] }, | ||
| })) as never, | ||
| })); | ||
|
|
||
| import { ShareThreadDialogHost } from "./ShareThreadDialog"; | ||
| import { openShareThreadDialog } from "./shareThreadDialogState"; | ||
|
|
||
| const environmentId = EnvironmentId.make("env-1"); | ||
| const threadId = ThreadId.make("thread-1"); | ||
|
|
||
| it("shares a session with a person and removes an existing share", async () => { | ||
| access.mutate.mockReset().mockResolvedValue(true); | ||
| // The dialog needs no route. | ||
| await using _screen = await render( | ||
| <AppAtomRegistryProvider> | ||
| <ShareThreadDialogHost /> | ||
| </AppAtomRegistryProvider>, | ||
| { router: false }, | ||
| ); | ||
| await act(async () => openShareThreadDialog({ environmentId, threadId })); | ||
|
|
||
| const share = page.getByRole("button", { name: "Share", exact: true }); | ||
| await userEvent.type(page.getByLabelText("Person"), "Not A Name"); | ||
| await expect.element(share).toBeDisabled(); | ||
|
|
||
| await userEvent.clear(page.getByLabelText("Person")); | ||
| await userEvent.type(page.getByLabelText("Person"), "kemal"); | ||
| await userEvent.click(share); | ||
| expect(access.mutate).toHaveBeenCalledWith({ | ||
| type: "thread.share", | ||
| threadId, | ||
| principal: "kemal", | ||
| role: "viewer", | ||
| }); | ||
|
|
||
| await userEvent.click(page.getByRole("button", { name: "Remove dejana" })); | ||
| expect(access.mutate).toHaveBeenLastCalledWith({ | ||
| type: "thread.unshare", | ||
| threadId, | ||
| principal: "dejana", | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a recipient opens a viewer-shared thread in the mobile app, this role check applies only to web
ChatView. MobileThreadRouteScreenstill derivescanOperateThreadfrom the environment scope, which principal sessions have, soThreadComposerenables Send; the server then rejects the dispatch because viewers may only read. Apply the shared role check on mobile too, so viewers aren't shown an action that always fails.AGENTS.md reference: AGENTS.md:L69-L73
Useful? React with 👍 / 👎.