mirror of
https://github.com/outline/outline.git
synced 2026-11-25 07:04:37 +03:00
* mention issue works * pr and loading works * error node * tweak mention display * handle multiple creation error * tidy * store unfurl in mention attrs * simplify mention code creation * test fix * base feedback * update node when pos is available * delete local UnfurlsStore * use unfurl from store * Optimize lodash isMatch import statement * fix: Copy/paste of issue mentions fix: Icon alignment fix: Error and loading mentions are unselectable * Switch order in paste menu --------- Co-authored-by: Tom Moor <tom@getoutline.com>
59 lines
1.2 KiB
TypeScript
59 lines
1.2 KiB
TypeScript
import {
|
|
IntegrationService,
|
|
IntegrationSettings,
|
|
IntegrationType,
|
|
MentionType,
|
|
} from "@shared/types";
|
|
import Integration from "~/models/Integration";
|
|
|
|
export const isURLMentionable = ({
|
|
url,
|
|
integration,
|
|
}: {
|
|
url: URL;
|
|
integration: Integration;
|
|
}): boolean => {
|
|
const { hostname, pathname } = url;
|
|
const pathParts = pathname.split("/");
|
|
|
|
switch (integration.service) {
|
|
case IntegrationService.GitHub: {
|
|
const settings =
|
|
integration.settings as IntegrationSettings<IntegrationType.Embed>;
|
|
|
|
return (
|
|
hostname === "github.com" &&
|
|
settings.github?.installation.account.name === pathParts[1] // ensure installed org/account name matches with the provided url.
|
|
);
|
|
}
|
|
|
|
default:
|
|
return false;
|
|
}
|
|
};
|
|
|
|
export const determineMentionType = ({
|
|
url,
|
|
integration,
|
|
}: {
|
|
url: URL;
|
|
integration: Integration;
|
|
}): MentionType | undefined => {
|
|
const { pathname } = url;
|
|
const pathParts = pathname.split("/");
|
|
|
|
switch (integration.service) {
|
|
case IntegrationService.GitHub: {
|
|
const type = pathParts[3];
|
|
return type === "pull"
|
|
? MentionType.PullRequest
|
|
: type === "issues"
|
|
? MentionType.Issue
|
|
: undefined;
|
|
}
|
|
|
|
default:
|
|
return;
|
|
}
|
|
};
|