Refactor and regroup urlHelpers utils (#6462)

* fix: refactor urlHelpers

* fix: move to /plugins/slack/shared

* fix: remove .babelrc

* fix: remove Outline class

* fix: Slack -> SlackUtils

* fix: UrlHelper class
This commit is contained in:
Apoorv Mishra
2024-02-29 11:41:03 +05:30
committed by GitHub
parent 021cd253af
commit fd34a6d19c
20 changed files with 146 additions and 127 deletions

View File

@@ -17,6 +17,7 @@ import env from "~/env";
import useCurrentTeam from "~/hooks/useCurrentTeam";
import useQuery from "~/hooks/useQuery";
import useStores from "~/hooks/useStores";
import { SlackUtils } from "../shared/SlackUtils";
import SlackIcon from "./Icon";
import SlackButton from "./components/SlackButton";
import SlackListItem from "./components/SlackListItem";
@@ -104,7 +105,7 @@ function Slack() {
// "users:read",
// "users:read.email",
]}
redirectUri={`${env.URL}/auth/slack.commands`}
redirectUri={SlackUtils.commandsUrl()}
state={team.id}
icon={<SlackIcon />}
/>

View File

@@ -1,8 +1,7 @@
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";
import { SlackUtils } from "../../shared/SlackUtils";
type Props = {
scopes?: string[];
@@ -16,16 +15,7 @@ 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
);
window.location.href = SlackUtils.authUrl(state, scopes, redirectUri);
};
return (