Skip to content

Commit cfcba25

Browse files
committed
chore: use organization display name
1 parent f7128dc commit cfcba25

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

site/src/modules/templates/TemplateCard/TemplateCard.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const LongContentTemplate: Story = {
3131
template: {
3232
...MockTemplate,
3333
display_name: "Very Long Template Name",
34-
organization_name: "Very Long Organization Name",
34+
organization_display_name: "Very Long Organization Name",
3535
description:
3636
"This is a very long test description. This is a very long test description. This is a very long test description. This is a very long test description",
3737
active_user_count: 999,

site/src/modules/templates/TemplateCard/TemplateCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const TemplateCard: FC<TemplateCardProps> = ({
4343
? template.display_name
4444
: template.name
4545
}
46-
subtitle={template.organization_name}
46+
subtitle={template.organization_display_name}
4747
avatar={
4848
hasIcon && (
4949
<ExternalAvatar variant="square" fitImage src={template.icon} />

site/src/pages/TemplatesPage/MultiOrgTemplatePage/TemplatesPageView.tsx

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,27 @@ export interface TemplatesPageViewProps {
5656
error?: unknown;
5757
}
5858

59-
export type TemplatesByOrg = Record<string, number>;
59+
export type TemplatesByOrg = Record<
60+
string,
61+
{ displayName: string; count: number }
62+
>;
6063

6164
const getTemplatesByOrg = (templates: Template[]): TemplatesByOrg => {
6265
const orgs: TemplatesByOrg = {
63-
all: 0,
66+
all: { displayName: "All Organizations", count: 0 },
6467
};
6568

6669
templates.forEach((template) => {
6770
if (orgs[template.organization_name]) {
68-
orgs[template.organization_name] += 1;
71+
orgs[template.organization_name].count += 1;
6972
} else {
70-
orgs[template.organization_name] = 1;
73+
orgs[template.organization_name] = {
74+
displayName: template.organization_display_name,
75+
count: 1,
76+
};
7177
}
7278

73-
orgs.all += 1;
79+
orgs.all.count += 1;
7480
});
7581

7682
return orgs;
@@ -116,14 +122,13 @@ export const TemplatesPageView: FC<TemplatesPageViewProps> = ({
116122
<Stack direction="row" spacing={4} alignItems="flex-start">
117123
<Stack css={{ width: 208, flexShrink: 0, position: "sticky", top: 48 }}>
118124
<span css={styles.filterCaption}>ORGANIZATION</span>
119-
{Object.keys(templatesByOrg).map((org) => (
125+
{Object.entries(templatesByOrg).map(([key, value]) => (
120126
<Link
121-
key={org}
122-
to={org !== "all" ? `?filter=organization:${org}` : "?"}
123-
css={[styles.tagLink, org === activeOrg && styles.tagLinkActive]}
127+
key={key}
128+
to={key !== "all" ? `?filter=organization:${key}` : "?"}
129+
css={[styles.tagLink, key === activeOrg && styles.tagLinkActive]}
124130
>
125-
{org === "all" ? "All Organizations" : org} (
126-
{templatesByOrg[org] ?? 0})
131+
{value.displayName} ({value.count ?? 0})
127132
</Link>
128133
))}
129134
</Stack>

0 commit comments

Comments
 (0)