Skip to content

Commit

Permalink
Merge branch 'main' into chore/remove-pages-router-settings-teams
Browse files Browse the repository at this point in the history
  • Loading branch information
hbjORbj authored Dec 4, 2024
2 parents fc2165f + 7e2b5b1 commit d52e6b1
Show file tree
Hide file tree
Showing 105 changed files with 6,326 additions and 388 deletions.
1 change: 1 addition & 0 deletions .github/workflows/e2e-api-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ env:
NEXTAUTH_URL: ${{ secrets.CI_NEXTAUTH_URL }}
NODE_OPTIONS: --max-old-space-size=29000
REDIS_URL: "redis://localhost:6379"
REPLEXICA_API_KEY: ${{ secrets.CI_REPLEXICA_API_KEY }}
STRIPE_PRIVATE_KEY: ${{ secrets.CI_STRIPE_PRIVATE_KEY }}
STRIPE_API_KEY: ${{ secrets.CI_STRIPE_PRIVATE_KEY }}
STRIPE_CLIENT_ID: ${{ secrets.CI_STRIPE_CLIENT_ID }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Unit
on:
workflow_call:
env:
REPLEXICA_API_KEY: ${{ secrets.CI_REPLEXICA_API_KEY }}
permissions:
contents: read
jobs:
Expand Down
6 changes: 0 additions & 6 deletions .husky/pre-commit

This file was deleted.

22 changes: 22 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

set -e

echo "Info: Running lint-staged"
yarn lint-staged

echo "Info: Running app-store:build"
yarn app-store:build && git add packages/app-store/*.generated.*

git stash -q --keep-index

# Check for new file changes after running the above commands
if ! git diff --cached --quiet; then
echo "Error: The build process modified files. Please commit the changes and try again."
git stash pop -q
exit 1
fi

# Restore stashed changes if nothing went wrong.
git stash pop -q
1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ git checkout HEAD~1 yarn.lock
git commit -m "Revert yarn.lock changes"
```

_NB_: You may have to bypass the pre-commit hook with by appending `--no-verify` to the git commit
If you've pushed the commit with the `yarn.lock`:

1. Correct the commit locally using the above method.
Expand Down
2 changes: 1 addition & 1 deletion apps/api/v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@axiomhq/winston": "^1.2.0",
"@calcom/platform-constants": "*",
"@calcom/platform-enums": "*",
"@calcom/platform-libraries": "npm:@calcom/[email protected].63",
"@calcom/platform-libraries": "npm:@calcom/[email protected].69",
"@calcom/platform-libraries-0.0.2": "npm:@calcom/[email protected]",
"@calcom/platform-types": "*",
"@calcom/platform-utils": "*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
OrganizerCancelledEmail,
AttendeeCancelledEmail,
OrganizerReassignedEmail,
AttendeeUpdatedEmail,
} from "@calcom/platform-libraries";
import {
CreateBookingInput_2024_08_13,
Expand Down Expand Up @@ -61,10 +62,12 @@ jest
jest
.spyOn(OrganizerCancelledEmail.prototype, "getHtml")
.mockImplementation(() => Promise.resolve("<p>email</p>"));

jest
.spyOn(OrganizerReassignedEmail.prototype, "getHtml")
.mockImplementation(() => Promise.resolve("<p>email</p>"));
jest
.spyOn(AttendeeUpdatedEmail.prototype, "getHtml")
.mockImplementation(() => Promise.resolve("<p>email</p>"));

type EmailSetup = {
team: Team;
Expand Down Expand Up @@ -681,6 +684,7 @@ describe("Bookings Endpoints 2024-08-13 team emails", () => {
expect(responseBody.data).toBeDefined();
expect(AttendeeCancelledEmail.prototype.getHtml).not.toHaveBeenCalled();
expect(OrganizerScheduledEmail.prototype.getHtml).not.toHaveBeenCalled();
expect(AttendeeUpdatedEmail.prototype.getHtml).not.toHaveBeenCalled();
emailsDisabledSetup.roundRobinEventType.currentHostId = reassignToId;
});
});
Expand All @@ -697,6 +701,7 @@ describe("Bookings Endpoints 2024-08-13 team emails", () => {
expect(AttendeeCancelledEmail.prototype.getHtml).not.toHaveBeenCalled();
expect(OrganizerScheduledEmail.prototype.getHtml).not.toHaveBeenCalled();
expect(OrganizerReassignedEmail.prototype.getHtml).not.toHaveBeenCalled();
expect(AttendeeUpdatedEmail.prototype.getHtml).not.toHaveBeenCalled();
});
});
});
Expand Down Expand Up @@ -898,6 +903,7 @@ describe("Bookings Endpoints 2024-08-13 team emails", () => {
expect(responseBody.data).toBeDefined();
expect(AttendeeCancelledEmail.prototype.getHtml).not.toHaveBeenCalled();
expect(OrganizerScheduledEmail.prototype.getHtml).toHaveBeenCalled();
expect(AttendeeUpdatedEmail.prototype.getHtml).toHaveBeenCalled();
emailsDisabledSetup.roundRobinEventType.currentHostId = reassignToId;
});
});
Expand All @@ -914,6 +920,7 @@ describe("Bookings Endpoints 2024-08-13 team emails", () => {
expect(AttendeeCancelledEmail.prototype.getHtml).not.toHaveBeenCalled();
expect(OrganizerScheduledEmail.prototype.getHtml).toHaveBeenCalled();
expect(OrganizerReassignedEmail.prototype.getHtml).toHaveBeenCalled();
expect(AttendeeUpdatedEmail.prototype.getHtml).toHaveBeenCalled();
});
});
});
Expand Down
39 changes: 29 additions & 10 deletions apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,17 @@ export class BookingsService_2024_08_13 {

async markAbsent(bookingUid: string, bookingOwnerId: number, body: MarkAbsentBookingInput_2024_08_13) {
const bodyTransformed = this.inputService.transformInputMarkAbsentBooking(body);
const bookingBefore = await this.bookingsRepository.getByUid(bookingUid);
const platformClientParams = bookingBefore?.eventTypeId
? await this.inputService.getOAuthClientParams(bookingBefore.eventTypeId)
: undefined;

await handleMarkNoShow({
bookingUid,
attendees: bodyTransformed.attendees,
noShowHost: bodyTransformed.noShowHost,
userId: bookingOwnerId,
platformClientParams,
});

const booking = await this.bookingsRepository.getByUidWithAttendeesAndUserAndEvent(bookingUid);
Expand Down Expand Up @@ -423,14 +428,19 @@ export class BookingsService_2024_08_13 {
throw new NotFoundException(`Booking with uid=${bookingUid} was not found in the database`);
}

const emailsEnabled = booking.eventTypeId ? await this.getEmailsEnabled(booking.eventTypeId) : true;
const platformClientParams = booking.eventTypeId
? await this.inputService.getOAuthClientParams(booking.eventTypeId)
: undefined;

const emailsEnabled = platformClientParams ? platformClientParams.arePlatformEmailsEnabled : true;

const profile = this.usersService.getUserMainProfile(requestUser);

await roundRobinReassignment({
bookingId: booking.id,
orgId: profile?.organizationId || null,
emailsEnabled,
platformClientParams,
});

const reassigned = await this.bookingsRepository.getByUidWithUser(bookingUid);
Expand All @@ -441,12 +451,6 @@ export class BookingsService_2024_08_13 {
return this.outputService.getOutputReassignedBooking(reassigned);
}

async getEmailsEnabled(eventTypeId: number) {
const oAuthParams = await this.inputService.getOAuthClientParams(eventTypeId);
const emailsEnabled = oAuthParams ? oAuthParams.arePlatformEmailsEnabled : true;
return emailsEnabled;
}

async reassignBookingToUser(
bookingUid: string,
newUserId: number,
Expand All @@ -463,7 +467,11 @@ export class BookingsService_2024_08_13 {
throw new NotFoundException(`User with id=${newUserId} was not found in the database`);
}

const emailsEnabled = booking.eventTypeId ? await this.getEmailsEnabled(booking.eventTypeId) : true;
const platformClientParams = booking.eventTypeId
? await this.inputService.getOAuthClientParams(booking.eventTypeId)
: undefined;

const emailsEnabled = platformClientParams ? platformClientParams.arePlatformEmailsEnabled : true;

const profile = this.usersService.getUserMainProfile(user);

Expand All @@ -474,6 +482,7 @@ export class BookingsService_2024_08_13 {
reassignReason: body.reason,
reassignedById,
emailsEnabled,
platformClientParams,
});

return this.outputService.getOutputReassignedBooking(reassigned);
Expand All @@ -485,7 +494,11 @@ export class BookingsService_2024_08_13 {
throw new NotFoundException(`Booking with uid=${bookingUid} was not found in the database`);
}

const emailsEnabled = booking.eventTypeId ? await this.getEmailsEnabled(booking.eventTypeId) : true;
const platformClientParams = booking.eventTypeId
? await this.inputService.getOAuthClientParams(booking.eventTypeId)
: undefined;

const emailsEnabled = platformClientParams ? platformClientParams.arePlatformEmailsEnabled : true;

await confirmBookingHandler({
ctx: {
Expand All @@ -496,6 +509,7 @@ export class BookingsService_2024_08_13 {
confirmed: true,
recurringEventId: booking.recurringEventId,
emailsEnabled,
platformClientParams,
},
});

Expand All @@ -508,7 +522,11 @@ export class BookingsService_2024_08_13 {
throw new NotFoundException(`Booking with uid=${bookingUid} was not found in the database`);
}

const emailsEnabled = booking.eventTypeId ? await this.getEmailsEnabled(booking.eventTypeId) : true;
const platformClientParams = booking.eventTypeId
? await this.inputService.getOAuthClientParams(booking.eventTypeId)
: undefined;

const emailsEnabled = platformClientParams ? platformClientParams.arePlatformEmailsEnabled : true;

await confirmBookingHandler({
ctx: {
Expand All @@ -520,6 +538,7 @@ export class BookingsService_2024_08_13 {
recurringEventId: booking.recurringEventId,
reason,
emailsEnabled,
platformClientParams,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import { withNextAuth } from "test/utils/withNextAuth";

import { PlatformOAuthClient, Team, Webhook } from "@calcom/prisma/client";

describe("EventTypes WebhooksController (e2e)", () => {
describe("OAuth client WebhooksController (e2e)", () => {
let app: INestApplication;
const userEmail = "event-types[email protected]";
const otherUserEmail = "other-event-types[email protected]";
const userEmail = "oauth-client[email protected]";
const otherUserEmail = "other-oauth-client[email protected]";
let user: UserWithProfile;
let otherUser: UserWithProfile;
let oAuthClient: PlatformOAuthClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class UpdateManagedUserInput {
name?: string;

@IsOptional()
@IsIn(["12", "24"])
@IsIn([12, 24])
@ApiProperty({ example: 12, enum: [12, 24], description: "Must be 12 or 24" })
timeFormat?: TimeFormat;

Expand Down
2 changes: 2 additions & 0 deletions apps/web/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export default async function RootLayout({ children }: { children: React.ReactNo
<script
nonce={nonce}
id="injected-head-scripts"
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{
__html: process.env.NEXT_PUBLIC_HEAD_SCRIPTS,
}}
Expand Down Expand Up @@ -105,6 +106,7 @@ export default async function RootLayout({ children }: { children: React.ReactNo
<script
nonce={nonce}
id="injected-head-scripts"
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{
__html: process.env.NEXT_PUBLIC_BODY_SCRIPTS,
}}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { getFixedT, _generateMetadata } from "app/_utils";

import { getServerSessionForAppDir } from "@calcom/feature-auth/lib/get-server-session-for-app-dir";
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
import { APP_NAME } from "@calcom/lib/constants";

import ApiKeysView, { NewApiKeyButton } from "~/settings/developer/api-keys-view";

export const generateMetadata = async () =>
await _generateMetadata(
(t) => t("api_keys"),
(t) => t("create_first_api_key_description", { appName: APP_NAME })
);

const Page = async () => {
// FIXME: Refactor me once next-auth endpoint is migrated to App Router
const session = await getServerSessionForAppDir();

const t = await getFixedT(session?.user.locale || "en");

return (
<SettingsHeader
title={t("api_keys")}
description={t("create_first_api_key_description", { appName: APP_NAME })}
CTA={<NewApiKeyButton />}
borderInShellHeader={true}>
<ApiKeysView />
</SettingsHeader>
);
};

export default Page;
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { PageProps } from "app/_types";
import { getFixedT, _generateMetadata } from "app/_utils";

import { getServerSessionForAppDir } from "@calcom/feature-auth/lib/get-server-session-for-app-dir";
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
import { EditWebhookView } from "@calcom/features/webhooks/pages/webhook-edit-view";
import { APP_NAME } from "@calcom/lib/constants";
import { WebhookRepository } from "@calcom/lib/server/repository/webhook";

export const generateMetadata = async () =>
await _generateMetadata(
(t) => t("webhooks"),
(t) => t("add_webhook_description", { appName: APP_NAME })
);

const Page = async ({ params }: PageProps) => {
const session = await getServerSessionForAppDir();

const t = await getFixedT(session?.user.locale || "en");
const id = typeof params?.id === "string" ? params.id : undefined;

const webhook = await WebhookRepository.findByWebhookId(id);

return (
<SettingsHeader
title={t("edit_webhook")}
description={t("add_webhook_description", { appName: APP_NAME })}
borderInShellHeader={true}
backButton>
<EditWebhookView webhook={webhook} />
</SettingsHeader>
);
};

export default Page;
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { getFixedT, _generateMetadata } from "app/_utils";

import { getServerSessionForAppDir } from "@calcom/feature-auth/lib/get-server-session-for-app-dir";
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
import { NewWebhookView } from "@calcom/features/webhooks/pages/webhook-new-view";
import { APP_NAME } from "@calcom/lib/constants";

export const generateMetadata = async () =>
await _generateMetadata(
(t) => t("webhooks"),
(t) => t("add_webhook_description", { appName: APP_NAME })
);

const Page = async () => {
const session = await getServerSessionForAppDir();

const t = await getFixedT(session?.user.locale || "en");

return (
<SettingsHeader
title={t("add_webhook")}
description={t("add_webhook_description", { appName: APP_NAME })}
borderInShellHeader={true}
backButton>
<NewWebhookView />
</SettingsHeader>
);
};

export default Page;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { _generateMetadata } from "app/_utils";

import WebhooksView from "@calcom/features/webhooks/pages/webhooks-view";
import { APP_NAME } from "@calcom/lib/constants";

export const generateMetadata = async () =>
await _generateMetadata(
(t) => t("webhooks"),
(t) => t("add_webhook_description", { appName: APP_NAME })
);

export default WebhooksView;
Loading

0 comments on commit d52e6b1

Please sign in to comment.