mirror of
https://github.com/outline/outline.git
synced 2026-11-21 05:24:03 +03:00
* feat: Add Gitea integration for issue, pull request, and repository previews * fix: Gitea repository previews and request deadlines Refresh the token before repository discovery, keep repository previews when the issue tracker is disabled, and keep the request timeout active while the response body is read. * chore: Use the shared fetch timeout for Gitea requests * chore: Mention Forgejo in Gitea copy and reuse the callback URL helper * Remove service specific getters in IntegrationsStore
152 lines
5.0 KiB
TypeScript
152 lines
5.0 KiB
TypeScript
import { observer } from "mobx-react";
|
|
import { PlusIcon } from "outline-icons";
|
|
import * as React from "react";
|
|
import { useTranslation, Trans } from "react-i18next";
|
|
import { IntegrationService } from "@shared/types";
|
|
import { ConnectedButton } from "~/scenes/Settings/components/ConnectedButton";
|
|
import { IntegrationScene } from "~/scenes/Settings/components/IntegrationScene";
|
|
import { AvatarSize } from "~/components/Avatar";
|
|
import Flex from "~/components/Flex";
|
|
import Heading from "~/components/Heading";
|
|
import List from "~/components/List";
|
|
import ListItem from "~/components/List/Item";
|
|
import Notice from "~/components/Notice";
|
|
import PlaceholderText from "~/components/PlaceholderText";
|
|
import TeamLogo from "~/components/TeamLogo";
|
|
import Text from "~/components/Text";
|
|
import Time from "~/components/Time";
|
|
import env from "~/env";
|
|
import useQuery from "~/hooks/useQuery";
|
|
import useStores from "~/hooks/useStores";
|
|
import LinearIcon from "./Icon";
|
|
import { LinearConnectButton } from "./components/LinearButton";
|
|
|
|
function Linear() {
|
|
const { integrations } = useStores();
|
|
const { t } = useTranslation();
|
|
const linearIntegrations = integrations.filterByService(
|
|
IntegrationService.Linear
|
|
);
|
|
const query = useQuery();
|
|
const error = query.get("error");
|
|
const appName = env.APP_NAME;
|
|
|
|
React.useEffect(() => {
|
|
void integrations.fetchAllIfNeeded({
|
|
service: IntegrationService.Linear,
|
|
withRelations: true,
|
|
});
|
|
}, [integrations]);
|
|
|
|
return (
|
|
<IntegrationScene title="Linear" icon={<LinearIcon />}>
|
|
<Heading>Linear</Heading>
|
|
|
|
{error === "access_denied" && (
|
|
<Notice>
|
|
<Trans>
|
|
Whoops, you need to accept the permissions in Linear to connect{" "}
|
|
{{ appName }} to your workspace. Try again?
|
|
</Trans>
|
|
</Notice>
|
|
)}
|
|
{error === "unauthenticated" && (
|
|
<Notice>
|
|
<Trans>
|
|
Something went wrong while authenticating your request. Please try
|
|
logging in again.
|
|
</Trans>
|
|
</Notice>
|
|
)}
|
|
{error === "unknown" && (
|
|
<Notice>
|
|
<Trans>
|
|
Something went wrong while processing your request. Please try
|
|
again.
|
|
</Trans>
|
|
</Notice>
|
|
)}
|
|
{env.LINEAR_CLIENT_ID ? (
|
|
<>
|
|
<Text as="p">
|
|
<Trans>
|
|
Enable previews of Linear issues in documents by connecting a
|
|
Linear workspace to {{ appName }}.
|
|
</Trans>
|
|
</Text>
|
|
{linearIntegrations.length ? (
|
|
<>
|
|
<Heading as="h2">
|
|
<Flex justify="space-between" auto>
|
|
{t("Connected")}
|
|
<LinearConnectButton icon={<PlusIcon />} />
|
|
</Flex>
|
|
</Heading>
|
|
<List>
|
|
{linearIntegrations.map((integration) => {
|
|
const linearWorkspace =
|
|
integration.settings?.linear?.workspace;
|
|
const integrationCreatedBy = integration.user
|
|
? integration.user.name
|
|
: undefined;
|
|
|
|
return (
|
|
<ListItem
|
|
key={linearWorkspace?.id}
|
|
small
|
|
title={linearWorkspace?.name}
|
|
subtitle={
|
|
integrationCreatedBy ? (
|
|
<>
|
|
<Trans>Enabled by {{ integrationCreatedBy }}</Trans>{" "}
|
|
·{" "}
|
|
<Time
|
|
dateTime={integration.createdAt}
|
|
relative={false}
|
|
format={{ en_US: "MMMM d, y" }}
|
|
/>
|
|
</>
|
|
) : (
|
|
<PlaceholderText />
|
|
)
|
|
}
|
|
image={
|
|
<TeamLogo
|
|
src={linearWorkspace?.logoUrl}
|
|
size={AvatarSize.Large}
|
|
/>
|
|
}
|
|
actions={
|
|
<ConnectedButton
|
|
onClick={integration.delete}
|
|
confirmationMessage={t(
|
|
"Disconnecting will prevent previewing Linear links from this workspace in documents. Are you sure?"
|
|
)}
|
|
/>
|
|
}
|
|
/>
|
|
);
|
|
})}
|
|
</List>
|
|
</>
|
|
) : (
|
|
<p>
|
|
<LinearConnectButton icon={<LinearIcon />} />
|
|
</p>
|
|
)}
|
|
</>
|
|
) : (
|
|
<Notice>
|
|
<Trans>
|
|
The Linear integration is currently disabled. Please set the
|
|
associated environment variables and restart the server to enable
|
|
the integration.
|
|
</Trans>
|
|
</Notice>
|
|
)}
|
|
</IntegrationScene>
|
|
);
|
|
}
|
|
|
|
export default observer(Linear);
|