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/every-geese-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"slack-connect-example": patch
---

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

Enable use of SlackKit with branches

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

NEXT_PUBLIC_KNOCK_BRANCH=<optional>
1 change: 1 addition & 0 deletions examples/slack-connect-example/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,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}
>
<KnockSlackProvider
knockSlackChannelId={process.env.NEXT_PUBLIC_KNOCK_SLACK_CHANNEL_ID!}
Expand Down
2 changes: 2 additions & 0 deletions packages/react-core/src/modules/slack/hooks/useSlackAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ function useSlackAuth(
channel_id: knockSlackChannelId,
public_key: knock.apiKey,
user_token: knock.userToken,
branch_slug: knock.branch,
}),
client_id: slackClientId,
scope: combinedScopes.join(","),
Expand All @@ -104,6 +105,7 @@ function useSlackAuth(
knockSlackChannelId,
knock.apiKey,
knock.userToken,
knock.branch,
slackClientId,
combinedScopes,
]);
Expand Down
4 changes: 4 additions & 0 deletions packages/react-core/test/slack/useSlackAuth.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { beforeEach, describe, expect, test, vi } from "vitest";

import useSlackAuth from "../../src/modules/slack/hooks/useSlackAuth";

const TEST_BRANCH_SLUG = "lorem-ipsum-branch";

const mockSetConnectionStatus = vi.fn();
const mockSetActionLabel = vi.fn();

Expand All @@ -24,6 +26,7 @@ vi.mock("../../src/modules/core", () => ({
slack: mockSlackClient,
apiKey: "test_api_key",
userToken: "test_user_token",
branch: TEST_BRANCH_SLUG,
}),
}));

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

Expand Down
Loading