Skip to content

Commit bd34bfd

Browse files
authored
Merge pull request #1175 from CodeForAfrica/chore/trustlab_improve_payload
@/trustlab payload improvements
2 parents d5b0768 + 4ed5c88 commit bd34bfd

File tree

16 files changed

+46
-26
lines changed

16 files changed

+46
-26
lines changed

.github/workflows/build-docker-image.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232

3333
# Add support for more platforms with QEMU (optional)
3434
- name: Set up QEMU
35-
uses: docker/setup-qemu-action@v
35+
uses: docker/setup-qemu-action@v3
3636

3737
- name: Set up Docker Buildx
3838
uses: docker/setup-buildx-action@v3

.github/workflows/trustlab-deploy-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636

3737
# Add support for more platforms with QEMU (optional)
3838
- name: Set up QEMU
39-
uses: docker/setup-qemu-action@v
39+
uses: docker/setup-qemu-action@v3
4040

4141
- name: Set up Docker Buildx
4242
uses: docker/setup-buildx-action@v3

.github/workflows/twoopstracker-deploy-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939

4040
# Add support for more platforms with QEMU (optional)
4141
- name: Set up QEMU
42-
uses: docker/setup-qemu-action@v
42+
uses: docker/setup-qemu-action@v3
4343

4444
- name: Set up Docker Buildx
4545
uses: docker/setup-buildx-action@v3

apps/trustlab/src/next-seo.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ const config = {
99
openGraph: {
1010
type: "website",
1111
locale: "en_GB",
12-
url: site.environmentUrl,
12+
url: site.url,
1313
site_name: site.name,
1414
images: [
1515
{
16-
url: `${site.environmentUrl}image.jpg`,
16+
url: `${site.url}image.jpg`,
1717
width: 1600,
1818
height: 800,
1919
alt: site.name,

apps/trustlab/src/payload/access/abilities.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ export const canManageContent = (user) => {
2121
export const canManagePages = (user) =>
2222
checkRole([ROLE_ADMIN, ROLE_EDITOR], user);
2323

24-
export const canManageSiteSettings = (user) => checkRole([ROLE_ADMIN], user);
24+
export const canManageSiteSettings = ({ req: { user } }) =>
25+
checkRole([ROLE_ADMIN], user);
2526

2627
// TODO(@kelvinkipruto): what happens on delete? cascade or not?
2728
export const canManageUsers = (user) => {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from "./anyone";
2+
export * from "./loggedIn";

apps/trustlab/src/payload/collections/Media.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { createdBy } from "@commons-ui/payload";
55

66
import { canManageContent } from "@/trustlab/payload/access/abilities";
77
import { anyone } from "@/trustlab/payload/access/anyone";
8+
import { hideAPIURL } from "@/trustlab/payload/utils";
89

910
const filename = fileURLToPath(import.meta.url);
1011
const dirname = path.dirname(filename);
@@ -19,7 +20,7 @@ const Media = {
1920
},
2021
admin: {
2122
group: "Publication",
22-
hideAPIURL: true,
23+
hideAPIURL,
2324
},
2425
fields: [
2526
{

apps/trustlab/src/payload/collections/Pages.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { slug, fullTitle } from "@commons-ui/payload";
33
import { canManagePages } from "@/trustlab/payload/access/abilities";
44
import { anyone } from "@/trustlab/payload/access/anyone";
55
import TestBlock from "@/trustlab/payload/blocks/TestBlock";
6+
import { hideAPIURL } from "@/trustlab/payload/utils";
67

78
const Pages = {
89
slug: "pages",
@@ -16,7 +17,7 @@ const Pages = {
1617
defaultColumns: ["fullTitle", "updatedAt", "_status"],
1718
group: "Publication",
1819
useAsTitle: "title",
19-
hideAPIURL: true,
20+
hideAPIURL,
2021
preview: ({ slug: pageSlug }) => {
2122
const encodedParams = new URLSearchParams({
2223
slug: pageSlug,
@@ -47,7 +48,9 @@ const Pages = {
4748
},
4849
],
4950
versions: {
50-
drafts: true,
51+
drafts: {
52+
autosave: true,
53+
},
5154
},
5255
};
5356

apps/trustlab/src/payload/collections/Posts.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { slug, createdBy } from "@commons-ui/payload";
22

33
import { canManageContent } from "@/trustlab/payload/access/abilities";
44
import { anyone } from "@/trustlab/payload/access/anyone";
5+
import { hideAPIURL } from "@/trustlab/payload/utils";
56

67
const Posts = {
78
slug: "posts",
@@ -15,7 +16,7 @@ const Posts = {
1516
defaultColumns: ["title", "createdBy", "updatedAt", "_status"],
1617
group: "Publication",
1718
useAsTitle: "title",
18-
hideAPIURL: true,
19+
hideAPIURL,
1920
preview: ({ slug: pageSlug }) => {
2021
const encodedParams = new URLSearchParams({
2122
slug: pageSlug,

apps/trustlab/src/payload/globals/index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,22 @@ import EngagementTab from "./tabs/EngagementTab";
22
import GeneralTab from "./tabs/GeneralTab";
33
import NavigationTab from "./tabs/NavigationTab";
44

5+
import { loggedIn } from "@/trustlab/payload/access";
56
import { canManageSiteSettings } from "@/trustlab/payload/access/abilities";
6-
import { anyone } from "@/trustlab/payload/access/anyone";
7+
import { hideAPIURL } from "@/trustlab/payload/utils";
78

89
const SiteSettings = {
910
slug: "site-settings",
1011
label: "Site",
1112
admin: {
1213
group: "Settings",
13-
hideAPIURL: true,
14+
hideAPIURL,
1415
},
1516
access: {
16-
read: anyone,
17-
update: ({ req: { user } }) => canManageSiteSettings(user),
17+
// Since we're using Local APIs, we should still be able to pull data server-side
18+
// See: note in https://payloadcms.com/docs/local-api/overview#transactions
19+
read: loggedIn,
20+
update: canManageSiteSettings,
1821
},
1922
fields: [
2023
{

0 commit comments

Comments
 (0)