Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional fields for direct issuance projects #2410

Merged
merged 7 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/build_cms.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build Sanity CMS

on:
push:
paths:
- "carbon-projects/**"
branches: "*"
pull_request:
paths:
- "carbon-projects/**"
branches: "*"
jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

# Explicit caching instead of using setup-node's built-in cache
- name: Cache node modules
uses: actions/cache@v3
with:
path: carbon-projects/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('carbon-projects/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install dependencies
working-directory: ./carbon-projects
run: npm ci

- name: Build Sanity studio
working-directory: ./carbon-projects
run: npm run build
env:
CI: true

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: sanity-build
path: carbon-projects/dist
retention-days: 7
5 changes: 4 additions & 1 deletion .github/workflows/update_translations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ jobs:
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
# hard-coded to fix issue with this workflow
node-version: 20
# caches until package-lock.json in the root is changed
cache: "npm"

- name: Cache node_modules
uses: actions/cache@v4
Expand Down
3 changes: 3 additions & 0 deletions carbon-projects/lib/sectors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const sectors = [
{ title: "Waste handling and disposal", value: "waste-h-d" },
];
47 changes: 47 additions & 0 deletions carbon-projects/schemas/assessor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { defineType } from "sanity";

export default defineType({
name: "assessor",
title: "Assessor",
description: "Information about an organization that assesses projects",
description:
"A profile containing information about an entity including name, avatar, and link",
type: "document",
preview: {
select: {
name: "name",
},
prepare(selection) {
return {
title: selection.name || "",
};
},
},
fields: [
{
type: "string",
title: "Name",
name: "name",
validation: (r) => r.required(),
},
{
type: "string",
title: "Link",
name: "link",
},
{
type: "image",
title: "Avatar",
name: "avatar",
},
{
type: "array",
title: "Accreditations",
name: "accreditations",
of: [
{ type: "string", name: "name" },
{ type: "string", name: "link" },
],
},
],
});
44 changes: 44 additions & 0 deletions carbon-projects/schemas/developer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { defineType } from "sanity";

export default defineType({
name: "developer",
title: "Developer",
description: "Information about an organization that develops projects",
description:
"A profile containing information about an entity including name, avatar, and link",
type: "document",
preview: {
select: {
name: "name",
},
prepare(selection) {
return {
title: selection.name || "",
};
},
},
fields: [
{
type: "string",
title: "Name",
name: "name",
validation: (r) => r.required(),
},
{
type: "string",
title: "Link",
name: "link",
},
{
type: "image",
title: "Avatar",
name: "avatar",
},
{
type: "array",
title: "Carbonmark Handles",
name: "handles",
of: [{ type: "string" }],
},
],
});
8 changes: 8 additions & 0 deletions carbon-projects/schemas/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
import assessor from "./assessor";
import country from "./country";
import developer from "./developer";
import indexContent from "./indexContent";
import methodology from "./methodology";
import captionImage from "./objects/captionImage";
import externalFile from "./objects/externalFile";
import hostedFile from "./objects/hostedFile";
import project from "./project";
import projectContent from "./projectContent";
import standard from "./standard";
export const schemaTypes = [
project,
methodology,
projectContent,
externalFile,
hostedFile,
captionImage,
country,
indexContent,
assessor,
developer,
standard,
];
9 changes: 8 additions & 1 deletion carbon-projects/schemas/methodology.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { defineField, defineType } from "sanity";
import { categories } from "../lib/categories";
import { sectors } from "../lib/sectors";

export default defineType({
name: "methodology",
title: "Methodology",
description: "Methodology definition",
type: "document",
groups: [{ name: "location" }],
preview: {
select: {
slug: "id",
Expand Down Expand Up @@ -43,6 +43,13 @@ export default defineType({
},
validation: (r) => r.required(),
}),
defineField({
name: "sector",
type: "string",
options: {
list: sectors,
},
}),
defineField({
name: "link",
type: "string",
Expand Down
38 changes: 38 additions & 0 deletions carbon-projects/schemas/objects/hostedFile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { defineType } from "sanity";

export default defineType({
name: "hostedFile",
type: "file",
title: "Hosted file",
description:
"A file whose content is hosted directly in the Sanity CMS, with associated metadata",
fields: [
{
type: "string",
title: "File name",
name: "filename",
},
{
type: "string",
title: "Description or Caption",
name: "description",
},
{
type: "string",
title: "MIME Type (e.g. application/pdf)",
description:
"Reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types",
name: "mimetype",
},
{
type: "string",
title: "File category",
name: "category",
0xAurelius marked this conversation as resolved.
Show resolved Hide resolved
},
{
type: "number",
title: "File size (in bytes)",
name: "size",
},
],
});
Loading
Loading