Skip to content

Commit

Permalink
fix(create-site): update scripts for creating site + publishing (#991)
Browse files Browse the repository at this point in the history
* fix: update site name in script

* chore: remove siteName

* chore: updaet to use siteName

* chore: fix test
  • Loading branch information
seaerchin authored Jan 27, 2025
1 parent b8f909a commit d9682a0
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion apps/studio/prisma/scripts/createSite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export const createSite = async ({ siteName }: CreateSiteProps) => {
}),
config: jsonb({
theme: "isomer-next",
siteName: "MTI",
siteName,
logoUrl: "https://www.isomer.gov.sg/images/isomer-logo.svg",
search: undefined,
isGovernment: true,
Expand Down
2 changes: 1 addition & 1 deletion apps/studio/src/features/dashboard/SiteList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const SuspendableSiteList = (): JSX.Element => {
{sites.map((site) => (
<Site
siteId={site.id}
siteName={site.name}
siteName={site.config.siteName}
siteLogoUrl={generateAssetUrl(site.config.logoUrl)}
/>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ describe("site.router", async () => {
expect(result).toEqual([
{
id: site.id,
name: site.name,
config: site.config,
},
])
Expand All @@ -87,7 +86,6 @@ describe("site.router", async () => {
expect(result).toEqual([
{
id: site1.id,
name: site1.name,
config: site1.config,
},
])
Expand Down Expand Up @@ -123,7 +121,6 @@ describe("site.router", async () => {
expect(result).toEqual([
{
id: site1.id,
name: site1.name,
config: site1.config,
},
])
Expand Down
10 changes: 6 additions & 4 deletions apps/studio/src/server/modules/site/site.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export const siteRouter = router({
.innerJoin("ResourcePermission", "Site.id", "ResourcePermission.siteId")
.where("ResourcePermission.deletedAt", "is", null)
.where("ResourcePermission.userId", "=", ctx.user.id)
.select(["Site.id", "Site.name", "Site.config"])
.groupBy(["Site.id", "Site.name", "Site.config"])
.select(["Site.id", "Site.config"])
.groupBy(["Site.id", "Site.config"])
.execute()
}),
getSiteName: protectedProcedure
Expand All @@ -43,11 +43,13 @@ export const siteRouter = router({
action: "read",
})

return db
const { config } = await db
.selectFrom("Site")
.where("Site.id", "=", siteId)
.select("name")
.select("config")
.executeTakeFirstOrThrow()

return { name: config.siteName }
}),
getConfig: protectedProcedure
.input(getConfigSchema)
Expand Down
6 changes: 4 additions & 2 deletions apps/studio/tests/integration/helpers/seed/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,18 @@ export const setupSite = async (siteId?: number, fetch?: boolean) => {
return { site, navbar, footer }
})
}

const name = `Ministry of Testing and Development ${nanoid()}`
return await db.transaction().execute(async (tx) => {
const site = await tx
.insertInto("Site")
.values({
name: `Ministry of Testing and Development ${nanoid()}`,
name,
// @ts-expect-error not using the specific config for tests, no need to populate
config: {
theme: "isomer-next",
logoUrl: "",
siteName: "TST",
siteName: name,
isGovernment: true,
},
id: siteId,
Expand Down
1 change: 0 additions & 1 deletion tooling/build/scripts/publishing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,6 @@ async function fetchAndWriteSiteData(client: Client) {
const config = {
site: {
...configResult.rows[0].config,
siteName: configResult.rows[0].name,
},
...configResult.rows[0].theme,
}
Expand Down

0 comments on commit d9682a0

Please sign in to comment.