Skip to content

Commit 429add5

Browse files
committed
Merge branch 'main' into int-187-create-recurring-events
2 parents 881c41a + 129b0ea commit 429add5

File tree

30 files changed

+408
-151
lines changed

30 files changed

+408
-151
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# NB: These are _not_ prefixed with NEXT_PUBLIC because we don't want their values to be sewn into the Docker image
22
# Base configuration
3-
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/calendar_2023"
3+
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/internal_site"
44
PUBLIC_URL=http://localhost:3000
55
SESSION_SECRET= # A random string, in production should be a secure secret e.g. `openssl rand -base64 32`
66

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ RUN apt-get update -y && apt-get install -y build-essential python3
88
WORKDIR /app
99
COPY ./.yarn/ .yarn/
1010
COPY . /app/
11-
RUN --mount=type=cache,id=calendar2023-yarn,target=.yarn/cache yarn install --immutable --inline-builds
11+
RUN --mount=type=cache,id=internal-site-yarn,target=.yarn/cache yarn install --immutable --inline-builds
1212

1313
ENV NODE_ENV=production
1414
ARG GIT_REV

Jenkinsfile

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pipeline {
55
agent {
66
node {
77
label 'docker && ramdisk'
8-
customWorkspace '/mnt/ramdisk/build/workspace/calendar'
8+
customWorkspace '/mnt/ramdisk/build/workspace/internal-site'
99
}
1010
}
1111

@@ -28,14 +28,14 @@ pipeline {
2828
}
2929
stage('Build Images') {
3030
environment {
31-
SENTRY_AUTH_TOKEN = credentials('calendar-sentry-auth-token')
31+
SENTRY_AUTH_TOKEN = credentials('internal-site-sentry-auth-token')
3232
}
3333
steps {
3434
sh """docker build \\
3535
--build-arg GIT_REV=${env.GIT_COMMIT} \\
3636
--build-arg VERSION=${env.TAG_NAME ?: 'v0.0.0'} \\
3737
--secret id=sentry-auth-token,env=SENTRY_AUTH_TOKEN \\
38-
-t registry.comp.ystv.co.uk/ystv/calendar2023:${imageTag}\\
38+
-t registry.comp.ystv.co.uk/ystv/internal-site:${imageTag}\\
3939
.
4040
"""
4141
}
@@ -50,7 +50,7 @@ pipeline {
5050
}
5151
}
5252
steps {
53-
dockerPush image: 'registry.comp.ystv.co.uk/ystv/calendar2023', tag: imageTag
53+
dockerPush image: 'registry.comp.ystv.co.uk/ystv/internal-site', tag: imageTag
5454
}
5555
}
5656

@@ -59,7 +59,7 @@ pipeline {
5959
changeRequest target: 'main'
6060
}
6161
steps {
62-
deployPreview action: 'deploy', job: 'calendar-preview', urlSuffix: 'internal.dev.ystv.co.uk'
62+
deployPreview action: 'deploy', job: 'internal-site-preview', urlSuffix: 'internal.dev.ystv.co.uk'
6363
}
6464
}
6565

@@ -69,12 +69,12 @@ pipeline {
6969
}
7070
steps {
7171
build job: 'Deploy Nomad Job', parameters: [
72-
string(name: 'JOB_FILE', value: 'calendar-dev.nomad'),
73-
text(name: 'TAG_REPLACEMENTS', value: "registry.comp.ystv.co.uk/ystv/calendar2023:${imageTag}")
72+
string(name: 'JOB_FILE', value: 'internal-site-dev.nomad'),
73+
text(name: 'TAG_REPLACEMENTS', value: "registry.comp.ystv.co.uk/ystv/internal-site:${imageTag}")
7474
], wait: true
7575
deployPreview action: 'cleanup'
7676
deployPreview action: 'cleanupMerge'
77-
sh "nomad alloc exec -task calendar-dev -job calendar-dev npx -y prisma migrate deploy --schema lib/db/schema.prisma"
77+
sh "nomad alloc exec -task internal-site-dev -job internal-site-dev npx -y prisma migrate deploy --schema lib/db/schema.prisma"
7878
}
7979
}
8080

@@ -85,10 +85,10 @@ pipeline {
8585
}
8686
steps {
8787
build job: 'Deploy Nomad Job', parameters: [
88-
string(name: 'JOB_FILE', value: 'calendar-prod.nomad'),
89-
text(name: 'TAG_REPLACEMENTS', value: "registry.comp.ystv.co.uk/ystv/calendar2023:${imageTag}")
88+
string(name: 'JOB_FILE', value: 'internal-site-prod.nomad'),
89+
text(name: 'TAG_REPLACEMENTS', value: "registry.comp.ystv.co.uk/ystv/internal-site:${imageTag}")
9090
], wait: true
91-
sh "nomad alloc exec -task calendar-prod -job calendar-prod npx -y prisma migrate deploy --schema lib/db/schema.prisma"
91+
sh "nomad alloc exec -task internal-site-prod -job internal-site-prod npx -y prisma migrate deploy --schema lib/db/schema.prisma"
9292
}
9393
}
9494
}

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# YSTV Calendar
1+
# YSTV Internal Site
22

33
This is the repo for https://internal.ystv.co.uk.
44
Formerly known as `experimental-hypothetical-new-internal-site-idea`.
55

66
## Getting Started
77

8-
To set up a local copy of the new calendar, you will need
8+
To set up a local copy of the new internal site, you will need
99

1010
- Node.js (18 or later) - https://nodejs.org/en/download
1111
- Yarn - once you have Node installed, run `corepack enable`
@@ -31,7 +31,7 @@ You will also need to set up the following:
3131

3232
### Postgres Database
3333

34-
Once you have PostgreSQL installed, run `createdb calendar_2023`.
34+
Once you have PostgreSQL installed, run `createdb internal_site`.
3535

3636
Now run `yarn prisma db push` to set up the database tables.
3737
If you get a permissions error, check your PostgreSQL authentication settings - you should have a `local all all peer` line in your pg_hba.conf.
@@ -95,6 +95,6 @@ Feature specific docs:
9595
- lib/ - low level utilities (auth, db, etc.)
9696
- server/ - custom server that handles socket.io communication
9797

98-
## Issue Tracking
98+
## Contributing
9999

100-
We use [Linear](https://linear.app/ystv) to track issues - to access it, sign in with your @ystv.co.uk Google account (ask a Computing Team member if you don't have one).
100+
Some documentation about how to contribute and some standards to follow is available [here](/docs/contributing.md)

app/(authenticated)/admin/positions/PositionView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import {
2525
import { useDisclosure } from "@mantine/hooks";
2626
import { SearchBar } from "@/components/SearchBar";
2727
import { CreatePositionForm, UpdatePositionForm } from "./form";
28-
import { useValidSearchParams } from "@/lib/searchParams/validate";
2928
import { getSearchParamsString } from "@/lib/searchParams/util";
3029
import { PositionCard } from "./PositionCard";
3130
import {
@@ -36,6 +35,7 @@ import {
3635
updatePositionAction,
3736
} from "./actions";
3837
import { useQuery } from "@tanstack/react-query";
38+
import { useValidSearchParams } from "@/lib/searchParams/validateHook";
3939

4040
export function PositionView(props: { initialPositions: TFetchPositions }) {
4141
const pathname = usePathname();

app/(authenticated)/admin/roles/RoleView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
} from "@/components/Pagination";
2323
import { useDisclosure } from "@mantine/hooks";
2424
import { SearchBar } from "@/components/SearchBar";
25-
import { useValidSearchParams } from "@/lib/searchParams/validate";
2625
import { getSearchParamsString } from "@/lib/searchParams/util";
2726
import { RoleCard } from "./RoleCard";
2827
import { CreateRoleForm, UpdateRoleForm } from "./form";
@@ -36,6 +35,7 @@ import {
3635
updateRoleAction,
3736
} from "./actions";
3837
import { useQuery } from "@tanstack/react-query";
38+
import { useValidSearchParams } from "@/lib/searchParams/validateHook";
3939

4040
export function RoleView(props: { initialRoles: TFetchRoles }) {
4141
const pathname = usePathname();

app/(authenticated)/admin/users/UserView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
PaginationProvider,
2020
} from "@/components/Pagination";
2121
import { SearchBar } from "@/components/SearchBar";
22-
import { useValidSearchParams } from "@/lib/searchParams/validate";
22+
import { useValidSearchParams } from "@/lib/searchParams/validateHook";
2323
import { getSearchParamsString } from "@/lib/searchParams/util";
2424
import { UserCard } from "./UserCard";
2525
import { useQuery } from "@tanstack/react-query";

app/(authenticated)/calendar/YSTVCalendar.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ import { z } from "zod";
3232
import { keepPreviousData, useQuery } from "@tanstack/react-query";
3333
import { fetchEvents } from "./actions";
3434
import { calendarEventsQueryKey } from "./helpers";
35+
import { EventColours } from "@/features/calendar/types";
36+
import { EventType } from "@/features/calendar/types";
3537

3638
dayjs.extend(weekOfYear);
3739

@@ -86,6 +88,12 @@ const HistoryStateSchema = z.object({
8688
filter: z.enum(["all", "mine", "vacant"]).optional(),
8789
});
8890

91+
const getEventColor = (evt: Event): string => {
92+
if (evt.is_cancelled) return "#B00020";
93+
if (evt.is_tentative) return "#8b8b8b";
94+
return EventColours[evt.event_type as EventType] || "#FFC0CB";
95+
};
96+
8997
export default function YSTVCalendar() {
9098
const currentDate = new Date();
9199

@@ -363,13 +371,13 @@ export default function YSTVCalendar() {
363371
end: evt.end_date,
364372
url: `/calendar/${evt.event_id}`,
365373
};
366-
if (evt.is_tentative) {
367-
eventObject.color = "#8b8b8b";
368-
}
374+
375+
eventObject.color = getEventColor(evt);
376+
369377
if (evt.is_cancelled) {
370-
eventObject.color = "#B00020";
371378
eventObject.className = "ystv-calendar-strike-through";
372379
}
380+
373381
if (evt.end_date.valueOf() < currentDate.valueOf()) {
374382
eventObject.className += " opacity-50";
375383
}
@@ -381,8 +389,6 @@ export default function YSTVCalendar() {
381389
);
382390
}
383391

384-
type EventType = "show" | "meeting" | "social" | "other";
385-
386392
interface Event {
387393
event_id: number;
388394
event_type: EventType | string;

app/(authenticated)/calendar/new/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default async function NewEventPage() {
5252
);
5353
if (permittedEventTypes.length === 0) {
5454
throw new Forbidden([
55-
"Calendar.Admin or Calendar.{Show,Meeting,Social}.{Creator,Admin}" as any,
55+
"Calendar.Admin or Calendar.{Show,Meeting,Workshop,Social}.{Creator,Admin}" as any,
5656
]);
5757
}
5858
const allMembers = await getAllUsers();

app/(authenticated)/calendar/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
} from "@tanstack/react-query";
1414
import { fetchEvents } from "./actions";
1515
import { calendarEventsQueryKey } from "./helpers";
16+
import EventColoursKey from "@/components/EventColoursKey";
1617

1718
export default async function CalendarPage() {
1819
await mustGetCurrentUser();
@@ -83,6 +84,7 @@ export default async function CalendarPage() {
8384
<br />
8485
</PermissionGate>
8586
<YSTVCalendar />
87+
<EventColoursKey />
8688
</HydrationBoundary>
8789
);
8890
}

0 commit comments

Comments
 (0)