Skip to content

Commit bb4aff3

Browse files
committed
refactor: simplify political entity list component and reorder globals
ci: remove ft/docker-image branch from dev deployment trigger style: rename settings group to website in site settings refactor: remove hidden title field from home page config
1 parent cabd3f5 commit bb4aff3

File tree

6 files changed

+145
-154
lines changed

6 files changed

+145
-154
lines changed

.github/workflows/deploy-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Promise Tracker | Deploy | Dev
22

33
on:
44
push:
5-
branches: [main, "ft/docker-image"]
5+
branches: [main]
66

77
concurrency:
88
group: "${{ github.workflow }} @ ${{ github.ref }}"

src/collections/SiteSettings/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export const SiteSettings: CollectionConfig = {
1717
},
1818
admin: {
1919
group: {
20-
en: "Settings",
21-
fr: "Paramètres",
20+
en: "Website",
21+
fr: "Site web",
2222
},
2323
},
2424
fields: [

src/components/PoliticalEntityList.tsx

Lines changed: 97 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -43,108 +43,15 @@ export const PoliticalEntityList = async ({
4343
pageSlugs = [],
4444
extractionCounts = {},
4545
}: PoliticalEntityListProps) => {
46-
const hasEntities = politicalEntities.length > 0;
47-
4846
const payload = await getGlobalPayload();
4947

5048
const { entitySelector } = await payload.findGlobal({
5149
slug: "home-page",
5250
});
5351

54-
return (
55-
<Container component="section" sx={{ py: { xs: 6, md: 8 } }}>
56-
{hasEntities ? (
57-
<Card variant="outlined" sx={{ borderRadius: 2 }}>
58-
<CardContent sx={{ p: { xs: 2, md: 3 } }}>
59-
<List disablePadding sx={{ "& > * + *": { mt: 1 } }}>
60-
{politicalEntities.map(async (entity, index) => {
61-
const href = buildHref(entity, pageSlugs);
62-
const media = await resolveMedia(entity.image);
63-
const extractionCount = extractionCounts[entity.id] ?? 0;
64-
const initials = entity.name
65-
.split(" ")
66-
.slice(0, 2)
67-
.map((part) => part[0]?.toUpperCase())
68-
.join("");
69-
70-
return (
71-
<React.Fragment key={entity.id}>
72-
<ListItem disableGutters sx={{ alignItems: "stretch" }}>
73-
<ListItemButton
74-
component={NextLink}
75-
href={href}
76-
sx={{
77-
borderRadius: 2,
78-
"&:hover": {
79-
backgroundColor: "action.hover",
80-
},
81-
}}
82-
>
83-
<Stack
84-
direction="row"
85-
spacing={2}
86-
alignItems="center"
87-
sx={{ width: "100%" }}
88-
>
89-
<ListItemAvatar sx={{ minWidth: "auto" }}>
90-
<Avatar
91-
src={media?.url ?? undefined}
92-
alt={media?.alt ?? entity.name}
93-
sx={{ width: 56, height: 56 }}
94-
>
95-
{initials || "?"}
96-
</Avatar>
97-
</ListItemAvatar>
98-
<Box flexGrow={1} minWidth={0}>
99-
<Typography
100-
variant="subtitle2"
101-
sx={{
102-
fontWeight: 600,
103-
textTransform: "uppercase",
104-
}}
105-
>
106-
{entity.position}
107-
</Typography>
108-
<Typography
109-
variant="h6"
110-
sx={{ fontWeight: 700, lineHeight: 1.2, mt: 0.5 }}
111-
>
112-
{entity.name}
113-
</Typography>
114-
{entity.region ? (
115-
<Typography variant="body2">
116-
{entity.region}
117-
</Typography>
118-
) : null}
119-
</Box>
120-
<Chip
121-
label={`${extractionCount} promise${extractionCount === 1 ? "" : "s"}`}
122-
color={extractionCount > 0 ? "primary" : "default"}
123-
variant={
124-
extractionCount > 0 ? "filled" : "outlined"
125-
}
126-
/>
127-
</Stack>
128-
</ListItemButton>
129-
</ListItem>
130-
{index < politicalEntities.length - 1 ? (
131-
<Box
132-
component="hr"
133-
sx={{
134-
border: 0,
135-
borderBottom: 1,
136-
borderColor: "divider",
137-
my: 1,
138-
}}
139-
/>
140-
) : null}
141-
</React.Fragment>
142-
);
143-
})}
144-
</List>
145-
</CardContent>
146-
</Card>
147-
) : (
52+
if (!politicalEntities.length) {
53+
return (
54+
<Container component="section" sx={{ py: { xs: 6, md: 8 } }}>
14855
<Card variant="outlined">
14956
<CardContent>
15057
<Typography variant="h6" sx={{ fontWeight: 600 }}>
@@ -155,7 +62,100 @@ export const PoliticalEntityList = async ({
15562
</Typography>
15663
</CardContent>
15764
</Card>
158-
)}
65+
</Container>
66+
);
67+
}
68+
69+
return (
70+
<Container component="section" sx={{ py: { xs: 6, md: 8 } }}>
71+
<Card variant="outlined" sx={{ borderRadius: 2 }}>
72+
<CardContent sx={{ p: { xs: 2, md: 3 } }}>
73+
<List disablePadding sx={{ "& > * + *": { mt: 1 } }}>
74+
{politicalEntities.map(async (entity, index) => {
75+
const href = buildHref(entity, pageSlugs);
76+
const media = await resolveMedia(entity.image);
77+
const extractionCount = extractionCounts[entity.id] ?? 0;
78+
const initials = entity.name
79+
.split(" ")
80+
.slice(0, 2)
81+
.map((part) => part[0]?.toUpperCase())
82+
.join("");
83+
84+
return (
85+
<React.Fragment key={entity.id}>
86+
<ListItem disableGutters sx={{ alignItems: "stretch" }}>
87+
<ListItemButton
88+
component={NextLink}
89+
href={href}
90+
sx={{
91+
borderRadius: 2,
92+
"&:hover": {
93+
backgroundColor: "action.hover",
94+
},
95+
}}
96+
>
97+
<Stack
98+
direction="row"
99+
spacing={2}
100+
alignItems="center"
101+
sx={{ width: "100%" }}
102+
>
103+
<ListItemAvatar sx={{ minWidth: "auto" }}>
104+
<Avatar
105+
src={media?.url ?? undefined}
106+
alt={media?.alt ?? entity.name}
107+
sx={{ width: 56, height: 56 }}
108+
>
109+
{initials || "?"}
110+
</Avatar>
111+
</ListItemAvatar>
112+
<Box flexGrow={1} minWidth={0}>
113+
<Typography
114+
variant="subtitle2"
115+
sx={{
116+
fontWeight: 600,
117+
textTransform: "uppercase",
118+
}}
119+
>
120+
{entity.position}
121+
</Typography>
122+
<Typography
123+
variant="h6"
124+
sx={{ fontWeight: 700, lineHeight: 1.2, mt: 0.5 }}
125+
>
126+
{entity.name}
127+
</Typography>
128+
{entity.region ? (
129+
<Typography variant="body2">
130+
{entity.region}
131+
</Typography>
132+
) : null}
133+
</Box>
134+
<Chip
135+
label={`${extractionCount} promise${extractionCount === 1 ? "" : "s"}`}
136+
color={extractionCount > 0 ? "primary" : "default"}
137+
variant={extractionCount > 0 ? "filled" : "outlined"}
138+
/>
139+
</Stack>
140+
</ListItemButton>
141+
</ListItem>
142+
{index < politicalEntities.length - 1 ? (
143+
<Box
144+
component="hr"
145+
sx={{
146+
border: 0,
147+
borderBottom: 1,
148+
borderColor: "divider",
149+
my: 1,
150+
}}
151+
/>
152+
) : null}
153+
</React.Fragment>
154+
);
155+
})}
156+
</List>
157+
</CardContent>
158+
</Card>
159159
</Container>
160160
);
161161
};

src/globals/HomePage.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ export const HomePage: GlobalConfig = {
1313
},
1414
},
1515
fields: [
16-
{
17-
name: "title",
18-
type: "text",
19-
admin: {
20-
hidden: true,
21-
},
22-
},
2316
{
2417
type: "tabs",
2518
tabs: [

src/globals/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ import { GlobalConfig } from "payload";
22
import { Settings } from "./Settings";
33
import { HomePage } from "./HomePage";
44

5-
export const globals: GlobalConfig[] = [Settings, HomePage];
5+
export const globals: GlobalConfig[] = [HomePage, Settings];

src/payload-types.ts

Lines changed: 44 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ export interface Config {
103103
defaultIDType: string;
104104
};
105105
globals: {
106-
settings: Setting;
107106
'home-page': HomePage;
107+
settings: Setting;
108108
'payload-jobs-stats': PayloadJobsStat;
109109
};
110110
globalsSelect: {
111-
settings: SettingsSelect<false> | SettingsSelect<true>;
112111
'home-page': HomePageSelect<false> | HomePageSelect<true>;
112+
settings: SettingsSelect<false> | SettingsSelect<true>;
113113
'payload-jobs-stats': PayloadJobsStatsSelect<false> | PayloadJobsStatsSelect<true>;
114114
};
115115
locale: 'en' | 'fr';
@@ -1263,6 +1263,25 @@ export interface PayloadMigrationsSelect<T extends boolean = true> {
12631263
updatedAt?: T;
12641264
createdAt?: T;
12651265
}
1266+
/**
1267+
* This interface was referenced by `Config`'s JSON-Schema
1268+
* via the `definition` "home-page".
1269+
*/
1270+
export interface HomePage {
1271+
id: string;
1272+
tenantSelector: {
1273+
title: string;
1274+
subtitle: string;
1275+
ctaLabel: string;
1276+
emptyListLabel: string;
1277+
};
1278+
entitySelector: {
1279+
emptyTitle: string;
1280+
EmptySubtitle: string;
1281+
};
1282+
updatedAt?: string | null;
1283+
createdAt?: string | null;
1284+
}
12661285
/**
12671286
* This interface was referenced by `Config`'s JSON-Schema
12681287
* via the `definition` "settings".
@@ -1284,26 +1303,6 @@ export interface Setting {
12841303
updatedAt?: string | null;
12851304
createdAt?: string | null;
12861305
}
1287-
/**
1288-
* This interface was referenced by `Config`'s JSON-Schema
1289-
* via the `definition` "home-page".
1290-
*/
1291-
export interface HomePage {
1292-
id: string;
1293-
title?: string | null;
1294-
tenantSelector: {
1295-
title: string;
1296-
subtitle: string;
1297-
ctaLabel: string;
1298-
emptyListLabel: string;
1299-
};
1300-
entitySelector: {
1301-
emptyTitle: string;
1302-
EmptySubtitle: string;
1303-
};
1304-
updatedAt?: string | null;
1305-
createdAt?: string | null;
1306-
}
13071306
/**
13081307
* This interface was referenced by `Config`'s JSON-Schema
13091308
* via the `definition` "payload-jobs-stats".
@@ -1322,6 +1321,29 @@ export interface PayloadJobsStat {
13221321
updatedAt?: string | null;
13231322
createdAt?: string | null;
13241323
}
1324+
/**
1325+
* This interface was referenced by `Config`'s JSON-Schema
1326+
* via the `definition` "home-page_select".
1327+
*/
1328+
export interface HomePageSelect<T extends boolean = true> {
1329+
tenantSelector?:
1330+
| T
1331+
| {
1332+
title?: T;
1333+
subtitle?: T;
1334+
ctaLabel?: T;
1335+
emptyListLabel?: T;
1336+
};
1337+
entitySelector?:
1338+
| T
1339+
| {
1340+
emptyTitle?: T;
1341+
EmptySubtitle?: T;
1342+
};
1343+
updatedAt?: T;
1344+
createdAt?: T;
1345+
globalType?: T;
1346+
}
13251347
/**
13261348
* This interface was referenced by `Config`'s JSON-Schema
13271349
* via the `definition` "settings_select".
@@ -1349,30 +1371,6 @@ export interface SettingsSelect<T extends boolean = true> {
13491371
createdAt?: T;
13501372
globalType?: T;
13511373
}
1352-
/**
1353-
* This interface was referenced by `Config`'s JSON-Schema
1354-
* via the `definition` "home-page_select".
1355-
*/
1356-
export interface HomePageSelect<T extends boolean = true> {
1357-
title?: T;
1358-
tenantSelector?:
1359-
| T
1360-
| {
1361-
title?: T;
1362-
subtitle?: T;
1363-
ctaLabel?: T;
1364-
emptyListLabel?: T;
1365-
};
1366-
entitySelector?:
1367-
| T
1368-
| {
1369-
emptyTitle?: T;
1370-
EmptySubtitle?: T;
1371-
};
1372-
updatedAt?: T;
1373-
createdAt?: T;
1374-
globalType?: T;
1375-
}
13761374
/**
13771375
* This interface was referenced by `Config`'s JSON-Schema
13781376
* via the `definition` "payload-jobs-stats_select".

0 commit comments

Comments
 (0)