feat(site/src/pages/AgentsPage/components/ProjectPage): show organization avatar in project details (#31872)
Shows avatars next to the names in the **Project owner** and
**Organization** rows of a project's Details panel, and switches the
Details values (owner, created date, organization, skills) from mono to
the standard sans font.
Fixes DES-22249
- `ProjectDetailsPanelView` takes a new `organizationIconUrl` prop and
renders `Avatar size="xs"` before the name. An empty icon falls back to
the name's initial. When the organization can't be found (the "Unknown"
case), no avatar is shown.
- The owner's avatar comes from the current user ("You") or the ACL
owner, and falls back to their initials. No avatar is shown while the
owner loads or when it's unknown. Both rows share one small
`AvatarValue` component.
- Long owner and organization names stay on one line with an ellipsis,
and the full name shows on hover (`title`). The ellipsis is applied to
the text itself, not the whole value cell, so the focus rings on the
Created and Skills buttons don't get clipped.
- Stories: `WithOrganization` and `LongNames` now include an icon, and
`WithOrganizationNoIcon` covers the fallback. The owner stories pass
`ownerAvatar` (a photo for "You", initials for other owners, none for
unknown or loading).
<details>
<summary>Verification</summary>
- `biome check`, `tsc --noEmit`, and `ProjectDetailsPanel.test.tsx` (21
tests) pass.
- Checked in Storybook with DOM measurements: every row is a single 24px
line, long names truncate, and the 18px avatar is vertically centered,
and the font is Geist.
- Ran the `frontend-deep-review` checkpoints. The only finding was a
restating story comment, which is removed.
</details>
> Generated by Coder Agents on behalf of @tracyjohnsonux.
This commit is contained in:
3 files changed
+82
-8
No files matched your search
@@ -53,6 +53,14 @@ const ProjectDetailsPanelContent: React.FC<ProjectDetailsPanelProps> = ({
|
||||
: aclQuery.isError
|
||||
? "Unknown"
|
||||
: undefined;
|
||||
const ownerAvatar = isOwner
|
||||
? { src: me.avatar_url ?? "", fallback: me.name || me.username }
|
||||
: owner
|
||||
? {
|
||||
src: owner.avatar_url ?? "",
|
||||
fallback: owner.name || owner.username,
|
||||
}
|
||||
: undefined;
|
||||
const organization = organizations.find(
|
||||
(org) => org.id === project.organization_id,
|
||||
);
|
||||
@@ -104,8 +112,10 @@ const ProjectDetailsPanelContent: React.FC<ProjectDetailsPanelProps> = ({
|
||||
<>
|
||||
<ProjectDetailsPanelView
|
||||
ownerLabel={ownerLabel}
|
||||
ownerAvatar={ownerAvatar}
|
||||
createdAt={project.created_at}
|
||||
organizationLabel={organizationLabel}
|
||||
organizationIconUrl={showOrganizations ? organization?.icon : undefined}
|
||||
skillCount={skillsQuery.data?.length}
|
||||
disabledSkillCount={
|
||||
skillsQuery.data?.filter((skill) => !skill.enabled).length
|
||||
|
||||
+20
-2
@@ -7,8 +7,10 @@ import {
|
||||
MockChatProjectInstructions,
|
||||
MockEveryoneGroup,
|
||||
MockGroup,
|
||||
MockOrganization,
|
||||
MockUnsetChatProjectInstructions,
|
||||
MockUserMember,
|
||||
MockUserOwner,
|
||||
mockApiError,
|
||||
} from "#/testHelpers/entities";
|
||||
import { DATE_FORMAT, formatDateTime } from "#/utils/time";
|
||||
@@ -60,6 +62,10 @@ const meta: Meta<typeof ProjectDetailsPanelView> = {
|
||||
],
|
||||
args: {
|
||||
ownerLabel: "You",
|
||||
ownerAvatar: {
|
||||
src: MockUserOwner.avatar_url ?? "",
|
||||
fallback: MockUserOwner.username,
|
||||
},
|
||||
createdAt: MockChatProject.created_at,
|
||||
skillCount: 3,
|
||||
disabledSkillCount: 0,
|
||||
@@ -105,13 +111,21 @@ export const UnsetWithoutUpdatePermission: Story = {
|
||||
};
|
||||
|
||||
export const WithOrganization: Story = {
|
||||
args: { organizationLabel: "Coder" },
|
||||
args: {
|
||||
organizationLabel: MockOrganization.display_name,
|
||||
organizationIconUrl: MockOrganization.icon,
|
||||
},
|
||||
};
|
||||
|
||||
export const WithOrganizationNoIcon: Story = {
|
||||
args: { organizationLabel: "Coder", organizationIconUrl: "" },
|
||||
};
|
||||
|
||||
/** The ACL names the owner, so both load together. */
|
||||
export const OwnerLoading: Story = {
|
||||
args: {
|
||||
ownerLabel: undefined,
|
||||
ownerAvatar: undefined,
|
||||
members: { ...mockMembers, entries: undefined },
|
||||
},
|
||||
};
|
||||
@@ -119,6 +133,7 @@ export const OwnerLoading: Story = {
|
||||
export const OtherOwner: Story = {
|
||||
args: {
|
||||
ownerLabel: "Jane Doe",
|
||||
ownerAvatar: { src: "", fallback: "Jane Doe" },
|
||||
members: {
|
||||
...mockMembers,
|
||||
entries: buildAccessEntries({
|
||||
@@ -133,6 +148,7 @@ export const OtherOwner: Story = {
|
||||
export const OwnerUnknown: Story = {
|
||||
args: {
|
||||
ownerLabel: "Unknown",
|
||||
ownerAvatar: undefined,
|
||||
members: {
|
||||
...mockMembers,
|
||||
entries: undefined,
|
||||
@@ -141,11 +157,13 @@ export const OwnerUnknown: Story = {
|
||||
},
|
||||
};
|
||||
|
||||
/** Long owner and organization names wrap so they stay readable. */
|
||||
/** Long owner and organization names truncate to keep each row on one line. */
|
||||
export const LongNames: Story = {
|
||||
args: {
|
||||
ownerLabel: "bartholomewmontgomeryfitzgerald1",
|
||||
ownerAvatar: { src: "", fallback: "bartholomewmontgomeryfitzgerald1" },
|
||||
organizationLabel: "Platform-Infrastructure-Engineering-Europe",
|
||||
organizationIconUrl: MockOrganization.icon,
|
||||
members: {
|
||||
...mockMembers,
|
||||
entries: buildAccessEntries({
|
||||
|
||||
@@ -34,9 +34,20 @@ type MembersSectionProps = {
|
||||
type ProjectDetailsPanelViewProps = {
|
||||
/** The owner's display label. `undefined` while it loads. */
|
||||
readonly ownerLabel: string | undefined;
|
||||
/** Omit when the owner is unknown or still loading to hide the avatar. */
|
||||
readonly ownerAvatar?: {
|
||||
readonly src: string;
|
||||
/** The name whose initial shows when `src` is empty or fails to load. */
|
||||
readonly fallback: string;
|
||||
};
|
||||
readonly createdAt: string;
|
||||
/** Omit to hide the organization row. */
|
||||
readonly organizationLabel?: string;
|
||||
/**
|
||||
* The organization's icon URL. An empty string shows the name's initial.
|
||||
* Omit when the organization is unknown to hide the avatar.
|
||||
*/
|
||||
readonly organizationIconUrl?: string;
|
||||
/** `undefined` while the skills load or after loading fails. */
|
||||
readonly skillCount: number | undefined;
|
||||
/** `undefined` while the skills load or after loading fails. */
|
||||
@@ -58,8 +69,10 @@ export const ProjectDetailsPanelView: React.FC<
|
||||
ProjectDetailsPanelViewProps
|
||||
> = ({
|
||||
ownerLabel,
|
||||
ownerAvatar,
|
||||
createdAt,
|
||||
organizationLabel,
|
||||
organizationIconUrl,
|
||||
skillCount,
|
||||
disabledSkillCount,
|
||||
skillsError,
|
||||
@@ -105,7 +118,13 @@ export const ProjectDetailsPanelView: React.FC<
|
||||
<div className="rounded-lg border border-border">
|
||||
<dl className="m-0 flex flex-col gap-2 border-0 border-b border-solid border-border p-4 text-sm">
|
||||
<DetailRow label="Project owner">
|
||||
{ownerLabel ?? (
|
||||
{ownerLabel !== undefined ? (
|
||||
<AvatarValue
|
||||
label={ownerLabel}
|
||||
avatarSrc={ownerAvatar?.src}
|
||||
avatarFallback={ownerAvatar?.fallback}
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<Skeleton className="my-1 ml-auto h-3 w-12" />
|
||||
<span className="sr-only">Loading</span>
|
||||
@@ -129,7 +148,13 @@ export const ProjectDetailsPanelView: React.FC<
|
||||
</Tooltip>
|
||||
</DetailRow>
|
||||
{organizationLabel !== undefined && (
|
||||
<DetailRow label="Organization">{organizationLabel}</DetailRow>
|
||||
<DetailRow label="Organization">
|
||||
<AvatarValue
|
||||
label={organizationLabel}
|
||||
avatarSrc={organizationIconUrl}
|
||||
avatarFallback={organizationLabel}
|
||||
/>
|
||||
</DetailRow>
|
||||
)}
|
||||
<DetailRow label="Skills">
|
||||
{skillCount === undefined && !skillsError ? (
|
||||
@@ -386,16 +411,37 @@ const OverflowTile: React.FC<OverflowTileProps> = ({ entries }) => {
|
||||
);
|
||||
};
|
||||
|
||||
type AvatarValueProps = {
|
||||
readonly label: string;
|
||||
/** Omit to hide the avatar. An empty string shows the fallback's initial. */
|
||||
readonly avatarSrc: string | undefined;
|
||||
readonly avatarFallback: string | undefined;
|
||||
};
|
||||
|
||||
/** A detail value with an optional avatar, truncated to one line. */
|
||||
const AvatarValue: React.FC<AvatarValueProps> = ({
|
||||
label,
|
||||
avatarSrc,
|
||||
avatarFallback,
|
||||
}) => (
|
||||
<span className="flex items-center justify-end gap-1.5">
|
||||
{avatarSrc !== undefined && (
|
||||
<Avatar size="xs" src={avatarSrc} fallback={avatarFallback} />
|
||||
)}
|
||||
<span className="min-w-0 truncate" title={label}>
|
||||
{label}
|
||||
</span>
|
||||
</span>
|
||||
);
|
||||
|
||||
type DetailRowProps = {
|
||||
readonly label: string;
|
||||
readonly children: React.ReactNode;
|
||||
};
|
||||
|
||||
const DetailRow: React.FC<DetailRowProps> = ({ label, children }) => (
|
||||
<div className="flex items-start justify-between gap-4">
|
||||
<div className="flex items-center justify-between gap-4">
|
||||
<dt className="shrink-0 text-content-secondary">{label}</dt>
|
||||
<dd className="m-0 min-w-0 break-words text-right font-mono text-content-primary">
|
||||
{children}
|
||||
</dd>
|
||||
<dd className="m-0 min-w-0 text-right text-content-primary">{children}</dd>
|
||||
</div>
|
||||
);
|
||||
Reference in new issue
Block a user