mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-12-02 10:09:02 +01:00
Identify the exact organization on access invitations (#3961)
Keep the name and ID visible at Accept and Decline so same-named organizations remain distinguishable. Label each decision by its invitation, wrap long identities, and preserve the existing role, inviter, date and read-only controls. Record comparable desktop/phone browser proof and regression coverage without changing grants or transport. --- Fleet candidate `20261105T115146Z-web-product` from the `web-product` lane. Reviewed tip `68e78e1ea1d1057702eaa84bc1d783f2d8feb84b` on `main`. [How Pulse handles triage](https://github.com/rcourtman/Pulse/blob/main/docs/AI_TRANSPARENCY.md)
This commit is contained in:
@@ -15,6 +15,27 @@
|
||||
|
||||
## Purpose
|
||||
|
||||
### Invitation decisions identify the exact organization
|
||||
|
||||
Your Invitations shows each organization's display name **and** ID beside its
|
||||
existing role, inviter, date and Accept/Decline controls. A missing name or one
|
||||
equal to the ID shows the ID once. Same-named organizations therefore remain
|
||||
distinguishable without a tooltip or disclosure. Each invitation is an accessible
|
||||
group, and both actions name its organization and ID. Long names, IDs and inviter
|
||||
identities wrap instead of escaping the card at narrow or desktop widths.
|
||||
`getOrganizationInvitationPresentation` owns that visible and accessible copy
|
||||
in the existing organization presentation helper, with its registered unit proof.
|
||||
|
||||
The existing current-reader, session/CSRF and no-automatic-retry transport is
|
||||
unchanged: the action uses the invitation ID, not the display name or active
|
||||
organization. Read-only sessions keep those decisions disabled. No membership
|
||||
or permission is added by presentation alone. `OrganizationAccessPanel.test.tsx`
|
||||
covers same-named decisions, exact dispatch/readback, ID fallbacks and read-only
|
||||
controls. Comparable actual-panel desktop/narrow browser fixtures exercise the
|
||||
real state, API and HTTP client with synthetic invitations, including keyboard
|
||||
acceptance/decline, long identities and dark theme. This does not establish
|
||||
original-account recovery or installed service acceptance.
|
||||
|
||||
### Sharing requests require an explicitly chosen recipient
|
||||
|
||||
A fresh Organization Sharing draft starts at **Select organization**. Neither
|
||||
|
||||
47
frontend-modern/browser-verification/d150cd0d6da13b6e.json
Normal file
47
frontend-modern/browser-verification/d150cd0d6da13b6e.json
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"version": 1,
|
||||
"result": "passed",
|
||||
"base_sha": "5528d505717e3a480c4addee7a4f9d6caaa88b53",
|
||||
"changed_paths": [
|
||||
"frontend-modern/src/components/Settings/OrganizationAccessInvitationsSection.tsx",
|
||||
"frontend-modern/src/utils/organizationSettingsPresentation.ts"
|
||||
],
|
||||
"content_sha256": {
|
||||
"frontend-modern/src/components/Settings/OrganizationAccessInvitationsSection.tsx": "07c08add5d926471d511e7501234de9cda8291f8d11793ddb7f781125f875723",
|
||||
"frontend-modern/src/utils/organizationSettingsPresentation.ts": "9fd38b96c93c6308cb5f97186626f61f97d9331f684ce08a4488a890099aebce"
|
||||
},
|
||||
"routes": [
|
||||
"Settings / Organization Access / Your Invitations (actual panel, state, OrgsAPI and HTTP client, synthetic HTTP responses)"
|
||||
],
|
||||
"states": [
|
||||
"Two same-named organizations, distinct IDs and roles",
|
||||
"Keyboard acceptance of client-east leaves client-west pending",
|
||||
"Read-only session with disabled decisions",
|
||||
"Long organization name, ID and inviter, without hiding date or actions",
|
||||
"Missing display name uses the ID once",
|
||||
"Light desktop and phone; dark phone"
|
||||
],
|
||||
"interactions": [
|
||||
"Keyboard Enter sends one CSRF/session-bound POST for client-east, never an API-token write, then explicit fresh readback",
|
||||
"Keyboard Enter sends one DELETE for client-west, never a second acceptance, with active org-a unchanged",
|
||||
"Read-only decisions remain disabled and a dispatched click sends no write",
|
||||
"Each action is named with the organization identity and grouped with its own invitation",
|
||||
"All 22 final captures opened through native view_image and compared: roles, inviter, date and controls remain visible; no collapse, aggregation or hover-only data"
|
||||
],
|
||||
"viewports": [
|
||||
{
|
||||
"width": 1440,
|
||||
"height": 1000
|
||||
},
|
||||
{
|
||||
"width": 390,
|
||||
"height": 844
|
||||
}
|
||||
],
|
||||
"verified_at": "2026-11-05T12:07:05Z",
|
||||
"browser": {
|
||||
"client": "1.56.1",
|
||||
"browser": "141.0.7390.37"
|
||||
},
|
||||
"notes": "11 comparable pairs with identical HTTP fixture data, viewport, theme, UTC locale and interaction state. Final checks use the verified launch graph e2185308. Before loads the exact assigned base panel and presentation-helper bytes through a Vite pre-load plugin; all consumers and client code are real. Final code only identifies and wraps existing invitation data; no server authorization, original-account, installed or release acceptance is claimed."
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Component, For, Show } from 'solid-js';
|
||||
import { Button } from '@/components/shared/Button';
|
||||
import { OrganizationRoleBadge } from '@/components/shared/OrganizationBadges';
|
||||
import { getOrganizationInvitationPresentation } from '@/utils/organizationSettingsPresentation';
|
||||
import { formatOrgDate } from '@/utils/orgUtils';
|
||||
import type { useOrganizationAccessPanelState } from './useOrganizationAccessPanelState';
|
||||
|
||||
@@ -20,40 +21,50 @@ export const OrganizationAccessInvitationsSection: Component<
|
||||
</div>
|
||||
<div class="space-y-3">
|
||||
<For each={props.state.myInvitations()}>
|
||||
{(invitation) => (
|
||||
<div class="rounded-md border border-border bg-surface px-3 py-3">
|
||||
<div class="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div class="space-y-1">
|
||||
<div class="text-sm font-medium text-base-content">
|
||||
{invitation.orgDisplayName || invitation.orgId}
|
||||
</div>
|
||||
<div class="text-xs text-muted">
|
||||
Invited by {invitation.invitedBy || 'an admin'} on{' '}
|
||||
{formatOrgDate(invitation.invitedAt)}
|
||||
{(invitation) => {
|
||||
const presentation = () =>
|
||||
getOrganizationInvitationPresentation(invitation.orgId, invitation.orgDisplayName);
|
||||
return (
|
||||
<div
|
||||
role="group"
|
||||
aria-label={presentation().groupLabel}
|
||||
class="rounded-md border border-border bg-surface px-3 py-3"
|
||||
>
|
||||
<div class="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div class="min-w-0 space-y-1 [overflow-wrap:anywhere]">
|
||||
<div class="text-sm font-medium text-base-content">
|
||||
{presentation().organization}
|
||||
</div>
|
||||
<div class="text-xs text-muted">
|
||||
Invited by {invitation.invitedBy || 'an admin'} on{' '}
|
||||
{formatOrgDate(invitation.invitedAt)}
|
||||
</div>
|
||||
</div>
|
||||
<OrganizationRoleBadge role={invitation.role} />
|
||||
</div>
|
||||
<div class="mt-3 flex gap-2">
|
||||
<Button
|
||||
variant="primary"
|
||||
size="mdCompact"
|
||||
aria-label={presentation().acceptLabel}
|
||||
onClick={() => void props.state.acceptInvitation(invitation.orgId)}
|
||||
disabled={!props.state.canChangeAccess()}
|
||||
>
|
||||
Accept
|
||||
</Button>
|
||||
<Button
|
||||
variant="dangerOutline"
|
||||
size="mdCompact"
|
||||
aria-label={presentation().declineLabel}
|
||||
onClick={() => void props.state.declineInvitation(invitation.orgId)}
|
||||
disabled={!props.state.canChangeAccess()}
|
||||
>
|
||||
Decline
|
||||
</Button>
|
||||
</div>
|
||||
<OrganizationRoleBadge role={invitation.role} />
|
||||
</div>
|
||||
<div class="mt-3 flex gap-2">
|
||||
<Button
|
||||
variant="primary"
|
||||
size="mdCompact"
|
||||
onClick={() => void props.state.acceptInvitation(invitation.orgId)}
|
||||
disabled={!props.state.canChangeAccess()}
|
||||
>
|
||||
Accept
|
||||
</Button>
|
||||
<Button
|
||||
variant="dangerOutline"
|
||||
size="mdCompact"
|
||||
onClick={() => void props.state.declineInvitation(invitation.orgId)}
|
||||
disabled={!props.state.canChangeAccess()}
|
||||
>
|
||||
Decline
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -2,7 +2,7 @@ import { createSignal } from 'solid-js';
|
||||
import { useOrganizationAccessPanelState } from '../useOrganizationAccessPanelState';
|
||||
import type { OrganizationMember } from '@/api/orgs';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { cleanup, fireEvent, render, screen, waitFor } from '@solidjs/testing-library';
|
||||
import { cleanup, fireEvent, render, screen, waitFor, within } from '@solidjs/testing-library';
|
||||
import { OrganizationAccessPanel } from '../OrganizationAccessPanel';
|
||||
|
||||
const orgGetMock = vi.fn();
|
||||
@@ -169,6 +169,90 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
describe('OrganizationAccessPanel', () => {
|
||||
const sameNamedInvitations = () =>
|
||||
['client-east', 'client-west'].map((orgId) => ({
|
||||
orgId,
|
||||
orgDisplayName: 'Operations',
|
||||
userId: 'user-1',
|
||||
role: 'viewer',
|
||||
invitedBy: 'admin@example.test',
|
||||
invitedAt: '2026-11-01T10:00:00Z',
|
||||
}));
|
||||
|
||||
it('distinguishes same-named invitations with visible organization IDs and named actions', async () => {
|
||||
listMyInvitationsMock.mockResolvedValue(sameNamedInvitations());
|
||||
renderPanel();
|
||||
|
||||
for (const orgId of ['client-east', 'client-west']) {
|
||||
const invitation = await screen.findByRole('group', {
|
||||
name: `Invitation to Operations (${orgId})`,
|
||||
});
|
||||
expect(within(invitation).getByText(`Operations (${orgId})`)).toBeVisible();
|
||||
expect(invitation).toHaveTextContent('admin@example.test');
|
||||
expect(invitation).toHaveTextContent('viewer');
|
||||
for (const action of ['Accept', 'Decline']) {
|
||||
expect(
|
||||
within(invitation).getByRole('button', {
|
||||
name: `${action} invitation to Operations (${orgId})`,
|
||||
}),
|
||||
).toBeEnabled();
|
||||
}
|
||||
}
|
||||
expectNoWrites();
|
||||
});
|
||||
|
||||
it.each(['Accept', 'Decline'])(
|
||||
'%s sends only the named invitation ID and refreshes without changing the active organization',
|
||||
async (action) => {
|
||||
let invitations = sameNamedInvitations();
|
||||
listMyInvitationsMock.mockImplementation(async () => invitations);
|
||||
const request = action === 'Accept' ? acceptMyInvitationMock : declineMyInvitationMock;
|
||||
request.mockImplementation(async (orgId) => {
|
||||
invitations = invitations.filter((invitation) => invitation.orgId !== orgId);
|
||||
return { kind: 'member' };
|
||||
});
|
||||
renderPanel();
|
||||
|
||||
fireEvent.click(
|
||||
await screen.findByRole('button', {
|
||||
name: `${action} invitation to Operations (client-west)`,
|
||||
}),
|
||||
);
|
||||
await waitFor(() => expect(request).toHaveBeenCalledTimes(1));
|
||||
expect(request).toHaveBeenCalledWith(
|
||||
'client-west',
|
||||
expect.objectContaining({ expectedOrgID: 'org-a', retry: false }),
|
||||
);
|
||||
expect(
|
||||
action === 'Accept' ? declineMyInvitationMock : acceptMyInvitationMock,
|
||||
).not.toHaveBeenCalled();
|
||||
expect(
|
||||
await screen.findByRole('group', { name: 'Invitation to Operations (client-east)' }),
|
||||
).toBeVisible();
|
||||
expect(
|
||||
screen.queryByRole('group', { name: 'Invitation to Operations (client-west)' }),
|
||||
).not.toBeInTheDocument();
|
||||
expect(getOrgIDMock()).toBe('org-a');
|
||||
expect(inviteMemberMock).not.toHaveBeenCalled();
|
||||
expect(updateMemberRoleMock).not.toHaveBeenCalled();
|
||||
},
|
||||
);
|
||||
|
||||
it.each(['', 'client-east'])(
|
||||
'shows the ID once when the display name is %j',
|
||||
async (orgDisplayName) => {
|
||||
listMyInvitationsMock.mockResolvedValue([{ ...sameNamedInvitations()[0], orgDisplayName }]);
|
||||
renderPanel();
|
||||
const invitation = await screen.findByRole('group', { name: 'Invitation to client-east' });
|
||||
expect(within(invitation).getByText('client-east')).toBeVisible();
|
||||
expect(
|
||||
within(invitation).getByRole('button', { name: 'Accept invitation to client-east' }),
|
||||
).toBeEnabled();
|
||||
expect(invitation).not.toHaveTextContent('client-east (client-east)');
|
||||
expectNoWrites();
|
||||
},
|
||||
);
|
||||
|
||||
it('renders loading skeleton first, then loaded content', async () => {
|
||||
const orgDeferred = deferred<typeof baseOrg>();
|
||||
orgGetMock.mockReturnValueOnce(orgDeferred.promise);
|
||||
@@ -722,8 +806,16 @@ describe('Organization Access change safety', () => {
|
||||
setReadOnly(true);
|
||||
renderPanel();
|
||||
await screen.findByText('Organization access is read-only for this session.');
|
||||
expect(screen.getByRole('button', { name: 'Accept' })).toBeDisabled();
|
||||
expect(screen.getByRole('button', { name: 'Decline' })).toBeDisabled();
|
||||
expect(
|
||||
screen.getByRole('button', {
|
||||
name: 'Accept invitation to Inviting Organization (inviting-org)',
|
||||
}),
|
||||
).toBeDisabled();
|
||||
expect(
|
||||
screen.getByRole('button', {
|
||||
name: 'Decline invitation to Inviting Organization (inviting-org)',
|
||||
}),
|
||||
).toBeDisabled();
|
||||
expect(screen.queryByRole('textbox', { name: 'Invite user ID' })).not.toBeInTheDocument();
|
||||
expect(
|
||||
screen.queryByText('Admin or owner role required to manage organization access.'),
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
getOrganizationAccessMemberAddedMessage,
|
||||
getOrganizationAccessMemberRemovedMessage,
|
||||
getOrganizationAccessRoleUpdatedMessage,
|
||||
getOrganizationInvitationPresentation,
|
||||
getOrganizationAddMemberErrorMessage,
|
||||
getOrganizationDisplayNameRequiredMessage,
|
||||
getOrganizationDisplayNameUpdateErrorMessage,
|
||||
@@ -40,6 +41,29 @@ import {
|
||||
} from '@/utils/organizationSettingsPresentation';
|
||||
|
||||
describe('organizationSettingsPresentation', () => {
|
||||
it('keeps same-named invitation identities distinct in visible and accessible copy', () => {
|
||||
for (const id of ['client-east', 'client-west']) {
|
||||
expect(getOrganizationInvitationPresentation(id, 'Operations')).toEqual({
|
||||
organization: `Operations (${id})`,
|
||||
groupLabel: `Invitation to Operations (${id})`,
|
||||
acceptLabel: `Accept invitation to Operations (${id})`,
|
||||
declineLabel: `Decline invitation to Operations (${id})`,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
it.each([undefined, '', 'client-east'])(
|
||||
'uses the invitation ID once for display name %j',
|
||||
(displayName) => {
|
||||
expect(getOrganizationInvitationPresentation('client-east', displayName)).toEqual({
|
||||
organization: 'client-east',
|
||||
groupLabel: 'Invitation to client-east',
|
||||
acceptLabel: 'Accept invitation to client-east',
|
||||
declineLabel: 'Decline invitation to client-east',
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it('returns canonical multi-tenant fallback presentation', () => {
|
||||
expect(ORGANIZATION_SETTINGS_UNAVAILABLE_MESSAGE).toBe(
|
||||
'Organization settings are not available on this server.',
|
||||
|
||||
@@ -12,6 +12,16 @@ export function getOrganizationAccessReloadMessage(orgId: string): string {
|
||||
return `Reload checks saved members and invitations for ${orgId}. It does not repeat an access change.`;
|
||||
}
|
||||
|
||||
export function getOrganizationInvitationPresentation(orgId: string, displayName?: string) {
|
||||
const organization = displayName && displayName !== orgId ? `${displayName} (${orgId})` : orgId;
|
||||
return {
|
||||
organization,
|
||||
groupLabel: `Invitation to ${organization}`,
|
||||
acceptLabel: `Accept invitation to ${organization}`,
|
||||
declineLabel: `Decline invitation to ${organization}`,
|
||||
};
|
||||
}
|
||||
|
||||
export const ORGANIZATION_SHARING_UNCONFIRMED_CHANGE_MESSAGE =
|
||||
'The last sharing change could not be confirmed. Reload saved sharing before making another change.';
|
||||
export const ORGANIZATION_SHARING_RELOAD_LABEL = 'Reload sharing';
|
||||
|
||||
Reference in New Issue
Block a user