Plugin architecture (#4861)
* wip * Refactor, tasks, processors, routes loading * Move Slack settings config to plugin * Fix translations in plugins * Move Slack auth to plugin * test * Move other slack-related files into plugin * Forgot to save * refactor
This commit is contained in:
38
plugins/slack/client/components/SlackButton.tsx
Normal file
38
plugins/slack/client/components/SlackButton.tsx
Normal file
@@ -0,0 +1,38 @@
|
||||
import * as React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { slackAuth } from "@shared/utils/urlHelpers";
|
||||
import Button from "~/components/Button";
|
||||
import env from "~/env";
|
||||
|
||||
type Props = {
|
||||
scopes?: string[];
|
||||
redirectUri: string;
|
||||
icon?: React.ReactNode;
|
||||
state?: string;
|
||||
label?: string;
|
||||
};
|
||||
|
||||
function SlackButton({ state = "", scopes, redirectUri, label, icon }: Props) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleClick = () => {
|
||||
if (!env.SLACK_CLIENT_ID) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.location.href = slackAuth(
|
||||
state,
|
||||
scopes,
|
||||
env.SLACK_CLIENT_ID,
|
||||
redirectUri
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<Button onClick={handleClick} icon={icon} neutral>
|
||||
{label || t("Add to Slack")}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
export default SlackButton;
|
||||
Reference in New Issue
Block a user