Skip to content
Open
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
5 changes: 5 additions & 0 deletions .changeset/ready-swans-occur.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ms-teams-connect-example": patch
---

Add `NEXT_PUBLIC_KNOCK_BRANCH` env var for specifying branch
12 changes: 12 additions & 0 deletions .changeset/some-bats-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@knocklabs/react-core": patch
"@knocklabs/react": patch
---

Enable use of TeamsKit with branches

The `useMsTeamsAuth` hook exported by `@knocklabs/react-core` has been updated
so that it works with branches. You can now use either this hook or the
`<MsTeamsAuthButton>` component exported by `@knocklabs/react` to test
connecting Microsoft Teams organizations to Knock tenants while working on a
branch.
2 changes: 2 additions & 0 deletions examples/ms-teams-connect-example/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ NEXT_PUBLIC_GRAPH_API_CLIENT_ID=<graph api client id>
# the MS Teams channel you want to use and you'll find its ID on the page
NEXT_PUBLIC_KNOCK_MS_TEAMS_CHANNEL_ID=<knock ms teams channel id>
NEXT_PUBLIC_REDIRECT_URL=http://localhost:3000/

NEXT_PUBLIC_KNOCK_BRANCH=<optional>
1 change: 1 addition & 0 deletions examples/ms-teams-connect-example/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default function Home() {
user={{ id: user.id }}
host={process.env.NEXT_PUBLIC_KNOCK_API_URL}
userToken={localStorage.getItem("knock-user-token")!}
branch={process.env.NEXT_PUBLIC_KNOCK_BRANCH}
>
<KnockMsTeamsProvider
knockMsTeamsChannelId={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function useMsTeamsAuth(
channel_id: knockMsTeamsChannelId,
public_key: knock.apiKey,
user_token: knock.userToken,
branch_slug: knock.branch,
}),
client_id: graphApiClientId,
redirect_uri: authRedirectUri,
Expand All @@ -53,6 +54,7 @@ function useMsTeamsAuth(
knockMsTeamsChannelId,
knock.apiKey,
knock.userToken,
knock.branch,
graphApiClientId,
authRedirectUri,
]);
Expand Down
4 changes: 4 additions & 0 deletions packages/react-core/test/ms-teams/useMsTeamsAuth.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
import type UseMsTeamsAuth from "../../src/modules/ms-teams/hooks/useMsTeamsAuth";
import { mockMsTeamsContext, mockTranslations } from "../test-utils/mocks";

const TEST_BRANCH_SLUG = "lorem-ipsum-branch";

// -----------------------------------------------------------------------------
// Stubs & Mocks
// -----------------------------------------------------------------------------
Expand All @@ -29,6 +31,7 @@ vi.mock("../../src/modules/core", () => ({
apiKey: "test_api_key",
userToken: "test_user_token",
host: "https://example.com",
branch: TEST_BRANCH_SLUG,
}),
}));

Expand Down Expand Up @@ -75,6 +78,7 @@ describe("useMsTeamsAuth", () => {
channel_id: "test_channel_id",
public_key: "test_api_key",
user_token: "test_user_token",
branch_slug: TEST_BRANCH_SLUG,
});
});

Expand Down
Loading