Skip to content

Commit f278892

Browse files
authored
feat(KNO-9332): enable use of branches with TeamsKit (#705)
1 parent 571abb1 commit f278892

File tree

6 files changed

+26
-0
lines changed

6 files changed

+26
-0
lines changed

.changeset/ready-swans-occur.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"ms-teams-connect-example": patch
3+
---
4+
5+
Add `NEXT_PUBLIC_KNOCK_BRANCH` env var for specifying branch

.changeset/some-bats-lick.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
"@knocklabs/react-core": patch
3+
"@knocklabs/react": patch
4+
---
5+
6+
Enable use of TeamsKit with branches
7+
8+
The `useMsTeamsAuth` hook exported by `@knocklabs/react-core` has been updated
9+
so that it works with branches. You can now use either this hook or the
10+
`<MsTeamsAuthButton>` component exported by `@knocklabs/react` to test
11+
connecting Microsoft Teams organizations to Knock tenants while working on a
12+
branch.

examples/ms-teams-connect-example/.env.sample

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ NEXT_PUBLIC_GRAPH_API_CLIENT_ID=<graph api client id>
1616
# the MS Teams channel you want to use and you'll find its ID on the page
1717
NEXT_PUBLIC_KNOCK_MS_TEAMS_CHANNEL_ID=<knock ms teams channel id>
1818
NEXT_PUBLIC_REDIRECT_URL=http://localhost:3000/
19+
20+
NEXT_PUBLIC_KNOCK_BRANCH=<optional>

examples/ms-teams-connect-example/pages/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export default function Home() {
4949
user={{ id: user.id }}
5050
host={process.env.NEXT_PUBLIC_KNOCK_API_URL}
5151
userToken={localStorage.getItem("knock-user-token")!}
52+
branch={process.env.NEXT_PUBLIC_KNOCK_BRANCH}
5253
>
5354
<KnockMsTeamsProvider
5455
knockMsTeamsChannelId={

packages/react-core/src/modules/ms-teams/hooks/useMsTeamsAuth.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ function useMsTeamsAuth(
4242
channel_id: knockMsTeamsChannelId,
4343
public_key: knock.apiKey,
4444
user_token: knock.userToken,
45+
branch_slug: knock.branch,
4546
}),
4647
client_id: graphApiClientId,
4748
redirect_uri: authRedirectUri,
@@ -53,6 +54,7 @@ function useMsTeamsAuth(
5354
knockMsTeamsChannelId,
5455
knock.apiKey,
5556
knock.userToken,
57+
knock.branch,
5658
graphApiClientId,
5759
authRedirectUri,
5860
]);

packages/react-core/test/ms-teams/useMsTeamsAuth.test.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
44
import type UseMsTeamsAuth from "../../src/modules/ms-teams/hooks/useMsTeamsAuth";
55
import { mockMsTeamsContext, mockTranslations } from "../test-utils/mocks";
66

7+
const TEST_BRANCH_SLUG = "lorem-ipsum-branch";
8+
79
// -----------------------------------------------------------------------------
810
// Stubs & Mocks
911
// -----------------------------------------------------------------------------
@@ -29,6 +31,7 @@ vi.mock("../../src/modules/core", () => ({
2931
apiKey: "test_api_key",
3032
userToken: "test_user_token",
3133
host: "https://example.com",
34+
branch: TEST_BRANCH_SLUG,
3235
}),
3336
}));
3437

@@ -75,6 +78,7 @@ describe("useMsTeamsAuth", () => {
7578
channel_id: "test_channel_id",
7679
public_key: "test_api_key",
7780
user_token: "test_user_token",
81+
branch_slug: TEST_BRANCH_SLUG,
7882
});
7983
});
8084

0 commit comments

Comments
 (0)