Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
104 changes: 80 additions & 24 deletions apps/mobile/src/features/settings/components/IssueTrackerSection.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { issueTrackerSummary } from "@t3tools/client-runtime/state/issue-trackers";
import {
issueTrackerFieldsToken,
issueTrackerSummary,
} from "@t3tools/client-runtime/state/issue-trackers";
import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
import type {
EnvironmentId,
Expand All @@ -23,6 +26,7 @@ import { useProjects } from "../../../state/entities";
import { issueTrackerEnvironment } from "../../../state/issueTrackers";
import { useEnvironmentQuery } from "../../../state/query";
import { useAtomCommand } from "../../../state/use-atom-command";
import { ConnectionFormField } from "../../connection/ConnectionFormField";
import type { SettingsTarget } from "../settings-environment-filter";
import { SettingsProviderRow } from "./SettingsProviderRow";
import { SettingsRow } from "./SettingsRow";
Expand All @@ -33,9 +37,25 @@ const ThemedSvg = withUniwind(Svg);
const ICON_SIZE = Platform.OS === "android" ? 20 : 18;

/** Art per tracker kind; the server supplies everything else about a tracker. */
const TRACKER_MARKS: Partial<Record<string, string>> = {
linear:
"M1.225 61.523c-.222-.949.908-1.546 1.597-.857l36.512 36.512c.69.69.092 1.82-.857 1.597C20.15 94.612 5.388 79.85 1.225 61.523ZM.002 46.889a.99.99 0 0 0 .29.76l52.062 52.061a.99.99 0 0 0 .76.29c2.765-.169 5.47-.559 8.1-1.152.75-.169 1.014-1.084.47-1.63L2.784 38.32c-.545-.545-1.46-.28-1.63.47A50.229 50.229 0 0 0 .002 46.89ZM4.472 29.34a.99.99 0 0 0 .208 1.104l64.878 64.877a.99.99 0 0 0 1.104.208 50.293 50.293 0 0 0 5.807-3.132.99.99 0 0 0 .154-1.53L9.135 23.38a.99.99 0 0 0-1.53.154 50.29 50.29 0 0 0-3.132 5.807ZM12.293 18.229c-.309-.309-.334-.803-.045-1.13C21.376 6.626 34.637 0 49.45 0 76.869 0 99.1 22.231 99.1 49.65c0 14.813-6.626 28.074-17.099 37.202-.327.29-.821.264-1.13-.045L12.293 18.23Z",
const TRACKER_MARKS: Partial<
Record<string, { readonly viewBox: string; readonly stroke?: true; readonly paths: string[] }>
> = {
// Tabler's `brand-jira` mark (MIT).
jira: {
viewBox: "0 0 24 24",
stroke: true,
paths: [
"M20 4h-9v1.5a2.5 2.5 0 0 0 2.5 2.5h1.5a1 1 0 0 1 1 1v1.5a2.5 2.5 0 0 0 2.5 2.5h1.5v-9",
"M15 8h-8v1.5a2.5 2.5 0 0 0 2.5 2.5h1.5a1 1 0 0 1 1 1v1.5a2.5 2.5 0 0 0 2.5 2.5h1.5v-8a1 1 0 0 0 -1 -1",
"M11 12h-8v1.5a2.5 2.5 0 0 0 2.5 2.5h1.5a1 1 0 0 1 1 1v1.5a2.5 2.5 0 0 0 2.5 2.5h1.5v-8a1 1 0 0 0 -1 -1",
],
},
linear: {
viewBox: "0 0 100 100",
paths: [
"M1.225 61.523c-.222-.949.908-1.546 1.597-.857l36.512 36.512c.69.69.092 1.82-.857 1.597C20.15 94.612 5.388 79.85 1.225 61.523ZM.002 46.889a.99.99 0 0 0 .29.76l52.062 52.061a.99.99 0 0 0 .76.29c2.765-.169 5.47-.559 8.1-1.152.75-.169 1.014-1.084.47-1.63L2.784 38.32c-.545-.545-1.46-.28-1.63.47A50.229 50.229 0 0 0 .002 46.89ZM4.472 29.34a.99.99 0 0 0 .208 1.104l64.878 64.877a.99.99 0 0 0 1.104.208 50.293 50.293 0 0 0 5.807-3.132.99.99 0 0 0 .154-1.53L9.135 23.38a.99.99 0 0 0-1.53.154 50.29 50.29 0 0 0-3.132 5.807ZM12.293 18.229c-.309-.309-.334-.803-.045-1.13C21.376 6.626 34.637 0 49.45 0 76.869 0 99.1 22.231 99.1 49.65c0 14.813-6.626 28.074-17.099 37.202-.327.29-.821.264-1.13-.045L12.293 18.23Z",
],
},
};

/**
Expand Down Expand Up @@ -112,10 +132,24 @@ export function IssueTrackerMark(props: { readonly tracker: string }) {
<ThemedSvg
width={ICON_SIZE}
height={ICON_SIZE}
viewBox="0 0 100 100"
viewBox={mark.viewBox}
colorClassName="accent-icon"
>
<Path fill="currentColor" d={mark} />
{mark.paths.map((d) =>
mark.stroke ? (
<Path
key={d}
d={d}
fill="none"
stroke="currentColor"
strokeWidth={2}
strokeLinecap="round"
strokeLinejoin="round"
/>
) : (
<Path key={d} fill="currentColor" d={d} />
),
)}
</ThemedSvg>
) : (
<SymbolView name="circle.dashed" size={ICON_SIZE} tintColorClassName="accent-icon" />
Expand All @@ -131,7 +165,7 @@ export function IssueTrackerCredentialForm(props: {
const gt = useGT();
const { environmentId, tracker } = props;
const connect = useAtomCommand(issueTrackerEnvironment.connect, { reportFailure: false });
const [draft, setDraft] = useState("");
const [drafts, setDrafts] = useState<Readonly<Record<string, string>>>({});
const [busy, setBusy] = useState(false);
const [failure, setFailure] = useState<string | null>(null);
const submit = async (token: string | null) => {
Expand All @@ -140,30 +174,52 @@ export function IssueTrackerCredentialForm(props: {
const result = await connect({ environmentId, input: { tracker: tracker.tracker, token } });
setBusy(false);
if (!AsyncResult.isFailure(result)) {
setDraft("");
setDrafts({});
return;
}
const error = squashAtomCommandFailure(result);
setFailure(error instanceof Error ? error.message : gt("The request failed."));
};
const helpUrl = tracker.credential.helpUrl;
const locked = props.disabled || busy;
// A single-part credential is the one secret field, keyed by nothing.
const fields = tracker.credential.fields ?? [
{ key: "", label: tracker.credential.label, secret: true },
];
const token = tracker.credential.fields
? issueTrackerFieldsToken(tracker.credential.fields, drafts)
: drafts[""]?.trim() || null;
const send = () => {
if (token !== null) void submit(token);
};
return (
<View className="gap-3 p-4">
<SecretTextInput
accessibilityLabel={tracker.credential.label}
placeholder={
tracker.connected
? gt("Saved. Enter a new value to replace it")
: tracker.credential.label
}
value={draft}
onChangeText={setDraft}
onSubmitEditing={(value) => {
if (value.trim()) void submit(value.trim());
}}
editable={!locked}
/>
{fields.map((field) =>
field.secret ? (
<SecretTextInput
key={field.key}
accessibilityLabel={field.label}
placeholder={
tracker.connected ? gt("Saved. Enter a new value to replace it") : field.label
}
value={drafts[field.key] ?? ""}
onChangeText={(value) => setDrafts({ ...drafts, [field.key]: value })}
onSubmitEditing={send}
editable={!locked}
/>
) : (
<ConnectionFormField
key={field.key}
label={field.label}
autoCapitalize="none"
autoCorrect={false}
value={drafts[field.key] ?? ""}
onChangeText={(value) => setDrafts({ ...drafts, [field.key]: value })}
onSubmitEditing={send}
editable={!locked}
/>
),
)}
{failure ? (
<Text selectable className="text-xs text-danger-foreground">
{failure}
Expand Down Expand Up @@ -196,8 +252,8 @@ export function IssueTrackerCredentialForm(props: {
tone="primary"
size="compact"
loading={busy}
disabled={locked || !draft.trim()}
onPress={() => void submit(draft.trim())}
disabled={locked || token === null}
onPress={send}
/>
</View>
</View>
Expand Down
1 change: 1 addition & 0 deletions apps/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"@ff-labs/fff-node": "0.11.0",
"@muse-code/sdk": "1.4.6",
"@napi-rs/keyring": "^1.3.0",
"@t3tools/issue-tracker-jira": "workspace:*",
"@t3tools/issue-tracker-linear": "workspace:*",
"@t3tools/provider-acp": "workspace:*",
"@t3tools/provider-acp-registry": "workspace:*",
Expand Down
3 changes: 2 additions & 1 deletion apps/server/src/issue/IssueTrackerRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as Context from "effect/Context";
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
import type { IssueTrackerKind } from "@t3tools/contracts";
import * as JiraDriver from "@t3tools/issue-tracker-jira/server/driver";
import * as LinearDriver from "@t3tools/issue-tracker-linear/server/driver";
import {
isStandaloneIssueTracker,
Expand Down Expand Up @@ -36,7 +37,7 @@ export function fromTrackers(
}

/** Trackers that are not a git host's own. Each signs requests with a credential from Settings. */
const STANDALONE_TRACKERS = [LinearDriver.make];
const STANDALONE_TRACKERS = [LinearDriver.make, JiraDriver.make];

const make = Effect.gen(function* () {
const drivers = yield* BuiltInDrivers.SourceControlDrivers;
Expand Down
17 changes: 17 additions & 0 deletions apps/web/src/components/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,23 @@ export const LinearIcon: Icon = (props) => (
</svg>
);

/** Tabler's `brand-jira` mark (MIT). */
export const JiraIcon: Icon = (props) => (
<svg
{...props}
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth={2}
strokeLinecap="round"
strokeLinejoin="round"
>
<path d="M20 4h-9v1.5a2.5 2.5 0 0 0 2.5 2.5h1.5a1 1 0 0 1 1 1v1.5a2.5 2.5 0 0 0 2.5 2.5h1.5v-9" />
<path d="M15 8h-8v1.5a2.5 2.5 0 0 0 2.5 2.5h1.5a1 1 0 0 1 1 1v1.5a2.5 2.5 0 0 0 2.5 2.5h1.5v-8a1 1 0 0 0 -1 -1" />
<path d="M11 12h-8v1.5a2.5 2.5 0 0 0 2.5 2.5h1.5a1 1 0 0 1 1 1v1.5a2.5 2.5 0 0 0 2.5 2.5h1.5v-8a1 1 0 0 0 -1 -1" />
</svg>
);

export const CursorIcon: Icon = ({ className, ...props }) => (
<svg
{...props}
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/components/issue/issuePresentation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { sourceControlClients } from "@t3tools/client-runtime/source-control-cli
import { CircleCheckIcon, CircleDotIcon, CircleSlashIcon, TicketIcon } from "lucide-react";

import { cn } from "~/lib/utils";
import { LinearIcon, type Icon } from "~/components/Icons";
import { JiraIcon, LinearIcon, type Icon } from "~/components/Icons";
import { getSourceControlPresentationForKind } from "~/sourceControlPresentation";

import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
Expand All @@ -13,6 +13,7 @@ export const IssueGlyph = { issue: CircleDotIcon } as const;

/** Name and mark per standalone tracker kind; one missing here falls back to its kind and a ticket. */
const STANDALONE_TRACKERS: Partial<Record<string, { providerName: string; Icon: Icon }>> = {
jira: { providerName: "Jira", Icon: JiraIcon },
linear: { providerName: "Linear", Icon: LinearIcon },
};

Expand Down
92 changes: 79 additions & 13 deletions apps/web/src/components/settings/IssueTrackerSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { useAtomValue } from "@effect/atom-react";
import { issueTrackerSummary } from "@t3tools/client-runtime/state/issue-trackers";
import {
issueTrackerFieldsToken,
issueTrackerSummary,
} from "@t3tools/client-runtime/state/issue-trackers";
import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
import { T, useGT, useMessages } from "gt-react";
import { ChevronDownIcon, ExternalLinkIcon, XIcon } from "lucide-react";
Expand All @@ -15,12 +18,13 @@ import { useEnvironmentQuery } from "../../state/query";
import { issueTrackerEnvironment } from "../../state/issueTrackers";
import { useProjects } from "../../state/entities";
import { useAtomCommand } from "../../state/use-atom-command";
import { LinearIcon } from "../Icons";
import { JiraIcon, LinearIcon } from "../Icons";
import { cn } from "~/lib/utils";

import { Badge } from "../ui/badge";
import { Button, InlineButton } from "../ui/button";
import { Collapsible, CollapsibleContent } from "../ui/collapsible";
import { Input } from "../ui/input";
import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select";
import { Skeleton } from "../ui/skeleton";
import { SecretInput } from "./SecretInput";
Expand All @@ -31,6 +35,7 @@ type TrackerIcon = ElementType<{ className?: string }>;

/** Web art per tracker kind; the server supplies everything else about a tracker. */
const TRACKER_ICONS: Partial<Record<string, TrackerIcon>> = {
jira: JiraIcon,
linear: LinearIcon,
};

Expand Down Expand Up @@ -118,9 +123,10 @@ function TrackerRow({
input: { tracker: tracker.tracker, token },
});
setBusy(false);
if (result._tag === "Success") return;
if (result._tag === "Success") return true;
const error = squashAtomCommandFailure(result);
setFailure(error instanceof Error ? error.message : gt("The request failed."));
return false;
};

const inputId = `issue-tracker-${tracker.tracker}-${environmentId}`;
Expand Down Expand Up @@ -197,16 +203,25 @@ function TrackerRow({
}
control={
<div className="flex w-full min-w-0 items-center gap-2 @min-[32rem]/settings-row:w-56">
<SecretInput
id={inputId}
size="sm"
className="min-w-0 flex-1"
configured={tracker.connected}
value=""
onCommit={(next) => {
if (next.trim()) void submit(next.trim());
}}
/>
{tracker.credential.fields ? (
<CredentialFields
id={inputId}
fields={tracker.credential.fields}
connected={tracker.connected}
onSubmit={submit}
/>
) : (
<SecretInput
id={inputId}
size="sm"
className="min-w-0 flex-1"
configured={tracker.connected}
value=""
onCommit={(next) => {
if (next.trim()) void submit(next.trim());
}}
/>
)}
{tracker.connected ? (
<Button
type="button"
Expand Down Expand Up @@ -236,6 +251,57 @@ function TrackerRow({
);
}

/** One input per part of the credential; the parts are sent together once all are filled. */
function CredentialFields({
id,
fields,
connected,
onSubmit,
}: {
readonly id: string;
readonly fields: NonNullable<IssueTrackerConnection["credential"]["fields"]>;
readonly connected: boolean;
readonly onSubmit: (token: string) => Promise<boolean>;
}) {
const gt = useGT();
const [drafts, setDrafts] = useState<Readonly<Record<string, string>>>({});
const token = issueTrackerFieldsToken(fields, drafts);
return (
<form
className="grid min-w-0 flex-1 gap-2"
onSubmit={(event) => {
event.preventDefault();
if (token === null) return;
void onSubmit(token).then((connected) => {
if (connected) setDrafts({});
});
}}
>
{fields.map((field) => (
<Input
key={field.key}
id={field.secret ? id : undefined}
size="sm"
type={field.secret ? "password" : "text"}
autoComplete="off"
spellCheck={false}
aria-label={field.label}
placeholder={
connected && field.secret
? gt("Stored secret, enter a new value to replace")
: field.label
}
value={drafts[field.key] ?? ""}
onChange={(event) => setDrafts({ ...drafts, [field.key]: event.target.value })}
/>
))}
<Button type="submit" size="xs" variant="outline" disabled={token === null}>
{connected ? <T>Replace</T> : <T>Connect</T>}
</Button>
</form>
);
}

/** One picker per project of this environment: which of the tracker's scopes it reads, if any. */
function ProjectBindings({
environmentId,
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/i18n/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -8440,6 +8440,7 @@
"a2d95d39d3398bda": "Anmeldedaten abgelehnt",
"9eae463720500113": "Auf dem Server gespeichert.",
"b6e27ab2537ef874": "Erstellen",
"b7088cd1c566d9c9": "Ersetzen",
"e63611bd62fad8d8": "Nicht zugeordnet",
"13ef526271b0f5d4": "Alle Bedingungen löschen",
"d1938a629f039515": "Bedingung entfernen",
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -8448,6 +8448,7 @@
"a2d95d39d3398bda": "Credential rejected",
"9eae463720500113": "Stored on the server.",
"b6e27ab2537ef874": "Create one",
"b7088cd1c566d9c9": "Replace",
"e63611bd62fad8d8": "Not bound",
"13ef526271b0f5d4": "Clear all conditions",
"d1938a629f039515": "Remove condition",
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/i18n/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -8438,6 +8438,7 @@
"a2d95d39d3398bda": "Credencial rechazada",
"9eae463720500113": "Guardado en el servidor.",
"b6e27ab2537ef874": "Crear uno",
"b7088cd1c566d9c9": "Reemplazar",
"e63611bd62fad8d8": "Sin vincular",
"13ef526271b0f5d4": "Borrar todas las condiciones",
"d1938a629f039515": "Quitar condición",
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/i18n/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -8439,6 +8439,7 @@
"a2d95d39d3398bda": "Identifiant refusé",
"9eae463720500113": "Stocké sur le serveur.",
"b6e27ab2537ef874": "En créer un",
"b7088cd1c566d9c9": "Remplacer",
"e63611bd62fad8d8": "Non lié",
"13ef526271b0f5d4": "Effacer toutes les conditions",
"d1938a629f039515": "Supprimer la condition",
Expand Down
Loading
Loading