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 all 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
6 changes: 6 additions & 0 deletions carbon-projects/lib/fileCategories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const fileCategories = [
{ title: "Methodology", value: "methodology" },
{ title: "Project Description Document (PDD)", value: "pdd" },
{ title: "Verifications", value: "verifications" },
{ title: "Supporting Documentation", value: "supporting-documentation" },
];
65 changes: 65 additions & 0 deletions carbon-projects/lib/sectors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
export const sectors = [
{
title: "Afforestation and reforestation",
value: "afforestation-and-reforestation",
},
{
title: "Energy industries (renewable/non-renewable sources)",
value: "energy-industries-renewable-non-renewable-sources",
},
{ title: "Energy demand", value: "energy-demand" },
{
title: "Agriculture; forestry and fishing",
value: "agriculture-forestry-and-fishing",
},
{
title: "Waste handling and disposal",
value: "waste-handling-and-disposal",
},
{
title: "Livestock, enteric fermentation, and manure management",
value: "livestock-enteric-fermentation-and-manure-management",
},
{ title: "Technical Removal", value: "technical-removal" },
{ title: "Afforestation", value: "afforestation" },
{ title: "Transport", value: "transport" },
{
title: "Landfill Gas Capture/Combustion",
value: "landfill-gas-capture-combustion",
},
{ title: "Forestry", value: "forestry" },
{ title: "Energy Distribution", value: "energy-distribution" },
{
title:
"Water supply; sewerage, waste management and remediation activities",
value: "water-supply-sewerage-waste-management-and-remediation-activities",
},
{
title: "Electricity; gas, steam and air conditioning supply",
value: "electricity-gas-steam-and-air-conditioning-supply",
},
{ title: "Manufacturing", value: "manufacturing" },
{ title: "Transportation and storage", value: "transportation-and-storage" },
{
title: "Fugitive emissions from fuel (solid, oil and gas)",
value: "fugitive-emissions-from-fuel-solid-oil-and-gas",
},
{ title: "Manufacturing industries", value: "manufacturing-industries" },
{ title: "Chemical industries", value: "chemical-industries" },
{ title: "Energy distribution", value: "energy-distribution" },
{
title:
"Fugitive emissions from production and consumption of halocarbons and sulphur hexafluoride",
value:
"fugitive-emissions-from-production-and-consumption-of-halocarbons-and-sulphur-hexafluoride",
},
{ title: "Metal production", value: "metal-production" },
{ title: "Agriculture", value: "agriculture" },
{ title: "Mining/mineral production", value: "mining-mineral-production" },
{ title: "Construction", value: "construction" },
{ title: "Mining and quarrying", value: "mining-and-quarrying" },
{
title: "Metal production (metallurgy)",
value: "metal-production-metallurgy",
},
];
36 changes: 36 additions & 0 deletions carbon-projects/schemas/accreditation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { defineType } from "sanity";

export default defineType({
name: "accreditation",
title: "Accreditation",
description: "Information about an accreditation that applies to assessors",
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: "Logo",
name: "logo",
},
],
});
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",
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: "reference",
to: [{ type: "accreditation" }],
},
],
},
],
});
42 changes: 42 additions & 0 deletions carbon-projects/schemas/developer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { defineType } from "sanity";

export default defineType({
name: "developer",
title: "Developer",
description: "Information about an organization that develops projects",
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" }],
},
],
});
10 changes: 10 additions & 0 deletions carbon-projects/schemas/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import accreditation from "./accreditation";
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,
accreditation,
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
42 changes: 42 additions & 0 deletions carbon-projects/schemas/objects/hostedFile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { defineType } from "sanity";
import { fileCategories } from "../../lib/fileCategories";

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
options: {
list: fileCategories,
},
},
{
type: "number",
title: "File size (in bytes)",
name: "size",
},
],
});
Loading
Loading