Skip to content

Commit

Permalink
Merge branch 'main' into hanpu/isom-1143-select-a-layout-for-page
Browse files Browse the repository at this point in the history
  • Loading branch information
hanpuliu-charles committed Jul 2, 2024
2 parents e5217e8 + a43ad30 commit 6c1262f
Show file tree
Hide file tree
Showing 71 changed files with 4,256 additions and 1,324 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/mergify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
pull_request_rules:
- name: Approve and merge non-major version dependabot upgrades
conditions:
- author~=^dependabot\[bot\]$
- -dependabot-update-type = version-update:semver-major
actions:
review:
type: APPROVE
merge:
method: squash

- name: Approve and merge Snyk.io upgrades
conditions:
- author=isomeradmin
- title~=^\[Snyk\]
- base = develop
actions:
review:
type: APPROVE
merge:
method: squash

- name: Automatically mark a PR as draft if [WIP] is in the title
conditions:
- title~=(?i)\[wip\]
actions:
edit:
draft: True

- name: Ping Isomer members for stale open PRs (>1 month since last activity)
conditions:
- updated-at<30 days ago
- -closed
actions:
request_reviews:
teams:
- "@isomerpages/iso-engineers"
comment:
message: This pull request has been stale for more than 30 days! Could someone please take a look at it @isomerpages/iso-engineers
9 changes: 5 additions & 4 deletions apps/studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@hello-pangea/dnd": "^16.6.0",
"@hookform/resolvers": "^3.3.4",
"@hookform/resolvers": "^3.6.0",
"@jsonforms/core": "^3.3.0",
"@jsonforms/material-renderers": "^3.3.0",
"@jsonforms/react": "^3.3.0",
Expand All @@ -65,7 +65,7 @@
"@sendgrid/mail": "^8.1.3",
"@storybook/jest": "0.2.3",
"@tanstack/react-query": "^4.36.1",
"@tanstack/react-query-devtools": "^5.45.1",
"@tanstack/react-query-devtools": "^4.36.1",
"@tiptap/extension-link": "2.1.15",
"@tiptap/extension-placeholder": "2.4.0",
"@tiptap/extension-subscript": "^2.4.0",
Expand Down Expand Up @@ -102,6 +102,7 @@
"react-error-boundary": "^4.0.12",
"react-hook-form": "^7.51.4",
"react-icons": "^5.2.0",
"sass": "^1.77.6",
"superjson": "^2.2.1",
"trpc-openapi": "^1.2.0",
"usehooks-ts": "^2.9.2",
Expand All @@ -112,7 +113,7 @@
"devDependencies": {
"@babel/plugin-transform-class-properties": "^7.24.7",
"@babel/plugin-transform-object-rest-spread": "^7.24.7",
"@babel/preset-env": "^7.23.8",
"@babel/preset-env": "^7.24.7",
"@babel/preset-typescript": "^7.24.7",
"@chakra-ui/cli": "^2.4.1",
"@playwright/test": "^1.40.1",
Expand All @@ -139,7 +140,7 @@
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.2",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-storybook": "0.8.0",
"k6-trpc": "^1.0.0",
"mockdate": "^3.0.5",
Expand Down
13 changes: 13 additions & 0 deletions apps/studio/prisma/generated/generatedTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ export type Blob = {
id: string
content: unknown
}
export type Footer = {
id: string
siteId: string
content: unknown
}
export type Navbar = {
id: string
siteId: string
content: unknown
}
export type Permission = {
id: string
resourceId: string
Expand All @@ -27,6 +37,7 @@ export type Resource = {
export type Site = {
id: string
name: string
config: unknown
}
export type SiteMember = {
userId: string
Expand All @@ -47,6 +58,8 @@ export type VerificationToken = {
}
export type DB = {
Blob: Blob
Footer: Footer
Navbar: Navbar
Permission: Permission
Resource: Resource
Site: Site
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
Warnings:
- Added the required column `Config` to the `Site` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "Site" ADD COLUMN "Config" JSONB NOT NULL;

-- CreateTable
CREATE TABLE "Navbar" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"url" TEXT NOT NULL,
"description" TEXT NOT NULL,
"siteId" TEXT NOT NULL,

CONSTRAINT "Navbar_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "NavbarItems" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"url" TEXT NOT NULL,
"description" TEXT NOT NULL,
"navbarId" TEXT NOT NULL,

CONSTRAINT "NavbarItems_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Footer" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"siteId" TEXT NOT NULL,
"contactUsLink" TEXT,
"feedbackFormLink" TEXT,
"privacyStatementLink" TEXT,
"termsOfUseLink" TEXT,

CONSTRAINT "Footer_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "Navbar_siteId_key" ON "Navbar"("siteId");

-- CreateIndex
CREATE UNIQUE INDEX "Footer_siteId_key" ON "Footer"("siteId");

-- AddForeignKey
ALTER TABLE "Navbar" ADD CONSTRAINT "Navbar_siteId_fkey" FOREIGN KEY ("siteId") REFERENCES "Site"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "NavbarItems" ADD CONSTRAINT "NavbarItems_navbarId_fkey" FOREIGN KEY ("navbarId") REFERENCES "Navbar"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Footer" ADD CONSTRAINT "Footer_siteId_fkey" FOREIGN KEY ("siteId") REFERENCES "Site"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
10 changes: 10 additions & 0 deletions apps/studio/prisma/migrations/20240621081908_casing/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
Warnings:
- You are about to drop the column `Config` on the `Site` table. All the data in the column will be lost.
- Added the required column `config` to the `Site` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "Site" DROP COLUMN "Config",
ADD COLUMN "config" JSONB NOT NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Warnings:
- You are about to drop the column `contactUsLink` on the `Footer` table. All the data in the column will be lost.
- You are about to drop the column `feedbackFormLink` on the `Footer` table. All the data in the column will be lost.
- You are about to drop the column `privacyStatementLink` on the `Footer` table. All the data in the column will be lost.
- You are about to drop the column `termsOfUseLink` on the `Footer` table. All the data in the column will be lost.
- You are about to drop the column `description` on the `Navbar` table. All the data in the column will be lost.
- You are about to drop the column `name` on the `Navbar` table. All the data in the column will be lost.
- You are about to drop the column `url` on the `Navbar` table. All the data in the column will be lost.
- You are about to drop the `NavbarItems` table. If the table is not empty, all the data it contains will be lost.
- Added the required column `content` to the `Footer` table without a default value. This is not possible if the table is not empty.
- Added the required column `content` to the `Navbar` table without a default value. This is not possible if the table is not empty.
*/
-- DropForeignKey
ALTER TABLE "NavbarItems" DROP CONSTRAINT "NavbarItems_navbarId_fkey";

-- AlterTable
ALTER TABLE "Footer" DROP COLUMN "contactUsLink",
DROP COLUMN "feedbackFormLink",
DROP COLUMN "privacyStatementLink",
DROP COLUMN "termsOfUseLink",
ADD COLUMN "content" JSONB NOT NULL;

-- AlterTable
ALTER TABLE "Navbar" DROP COLUMN "description",
DROP COLUMN "name",
DROP COLUMN "url",
ADD COLUMN "content" JSONB NOT NULL;

-- DropTable
DROP TABLE "NavbarItems";
8 changes: 8 additions & 0 deletions apps/studio/prisma/migrations/20240624130652_/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
Warnings:
- You are about to drop the column `name` on the `Footer` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "Footer" DROP COLUMN "name";
31 changes: 26 additions & 5 deletions apps/studio/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ model User {
phone String
preferredName String?
Permission Permission[]
SiteMembers SiteMember[]
permission Permission[]
siteMembers SiteMember[]
}

model Permission {
Expand All @@ -66,16 +66,37 @@ model Permission {
model Site {
id String @id @default(cuid())
name String @unique
Resources Resource[]
SiteMembers SiteMember[]
resources Resource[]
siteMembers SiteMember[]
// NOTE: This is `theme/isGovernment/sitemap`
// This is currently put as `Json` for ease of extensibility
// when we lock in what we actually want for site-wide config,
// we should put this in our db table.
config Json
navbar Navbar?
footer Footer?
}

model Navbar {
id String @id @default(cuid())
siteId String @unique
site Site @relation(fields: [siteId], references: [id])
content Json
}

model Footer {
id String @id @default(cuid())
siteId String @unique
site Site @relation(fields: [siteId], references: [id])
content Json
}

model Blob {
id String @id @default(cuid())
content Json
// Should the blob be deleted on deletion of the resource?
Resource Resource?
resource Resource?
}

model SiteMember {
Expand Down
90 changes: 89 additions & 1 deletion apps/studio/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,98 @@
*
* @link https://www.prisma.io/docs/guides/database/seed-database
*/
import { type SiteConfig } from '~/server/modules/site/site.types'
import {
type Navbar,
type Footer,
} from '~/server/modules/resource/resource.types'
import { db } from '../src/server/modules/database'

const NAV_BAR_ITEMS = [
{
name: 'Expandable nav item',
url: '/item-one',
items: [
{
name: "PA's network one",
url: '/item-one/pa-network-one',
description: 'Click here and brace yourself for mild disappointment.',
},
{
name: "PA's network two",
url: '/item-one/pa-network-two',
description: 'Click here and brace yourself for mild disappointment.',
},
{
name: "PA's network three",
url: '/item-one/pa-network-three',
},
{
name: "PA's network four",
url: '/item-one/pa-network-four',
description:
'Click here and brace yourself for mild disappointment. This one has a pretty long one',
},
{
name: "PA's network five",
url: '/item-one/pa-network-five',
description:
'Click here and brace yourself for mild disappointment. This one has a pretty long one',
},
{
name: "PA's network six",
url: '/item-one/pa-network-six',
description: 'Click here and brace yourself for mild disappointment.',
},
],
},
]

async function main() {
// Nothing
await db
.insertInto('Site')
.values({
id: '1',
name: 'Ministry of Trade and Industry',
config: {
theme: 'isomer-next',
sitemap: {
siblingTitles: [],
childrenTitles: [],
parentTitle: '',
},
isGovernment: true,
} satisfies SiteConfig,
})
.execute()

await db
.insertInto('Footer')
.values({
id: '1',
siteId: '1',
content: {
name: 'A foot',
contactUsLink: '/contact-us',
feedbackFormLink: 'https://www.form.gov.sg',
privacyStatementLink: '/privacy',
termsOfUseLink: '/terms-of-use',
} satisfies Footer,
})
.execute()

await db
.insertInto('Navbar')
.values({
id: '1',
siteId: '1',
content: {
name: 'navi',
url: 'www.isomer.gov.sg',
items: NAV_BAR_ITEMS,
} satisfies Navbar,
})
.execute()
}

main()
Expand Down
Loading

0 comments on commit 6c1262f

Please sign in to comment.