Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { useAtomValue } from "@effect/atom-react";
import type { StaticScreenProps } from "@react-navigation/native";
import { issueTrackerSummary } from "@t3tools/client-runtime/state/issue-trackers";
import {
hasIssueTrackerTeams,
issueTrackerSummary,
} from "@t3tools/client-runtime/state/issue-trackers";
import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
import {
AuthSettingsWriteScope,
Expand Down Expand Up @@ -192,18 +195,20 @@ export function SettingsIssueTrackerRouteScreen({
disabled={disabled}
/>
</SettingsSection>
{usable && tracker.scopes.length > 0 ? (
{usable && hasIssueTrackerTeams(tracker, query.data?.bindings ?? {}) ? (
<SettingsSection
title={gt("Projects")}
footer={gt(
"Pick the {tracker} {scope} whose issues each project lists beside its repository's own.",
"Pick one or more {tracker} {scope}s for each project. Their issues list beside the repository's own, and agents file new issues in the first one.",
{ tracker: tracker.displayName, scope: tracker.scopeNoun },
)}
>
<IssueTrackerProjectRows
environmentId={environmentId}
tracker={tracker}
bindings={query.data?.bindings ?? {}}
refreshing={query.isPending}
refreshFailed={query.error !== null}
disabled={disabled}
/>
</SettingsSection>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { issueTrackerSummary } from "@t3tools/client-runtime/state/issue-trackers";
import {
boundIssueTrackerScopes,
issueTrackerBindingFor,
issueTrackerScopeOptions,
issueTrackerSummary,
} from "@t3tools/client-runtime/state/issue-trackers";
import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
import type {
EnvironmentId,
Expand Down Expand Up @@ -210,6 +215,8 @@ export function IssueTrackerProjectRows(props: {
readonly environmentId: EnvironmentId;
readonly tracker: IssueTrackerConnection;
readonly bindings: IssueTrackerConnectionList["bindings"];
readonly refreshing: boolean;
readonly refreshFailed: boolean;
readonly disabled: boolean;
}) {
const gt = useGT();
Expand All @@ -218,24 +225,37 @@ export function IssueTrackerProjectRows(props: {
label: `bind project to ${tracker.displayName}`,
});
const projects = useProjects().filter((project) => project.environmentId === environmentId);
const [binding, setBinding] = useState<ProjectId | null>(null);
const change = async (projectId: ProjectId, scope: string) => {
if (props.disabled || binding !== null) return;
setBinding(projectId);
await bind({
environmentId,
input: {
projectId,
binding: scope === UNBOUND ? null : { tracker: tracker.tracker, scope },
},
});
setBinding(null);
const [picks, setPicks] = useState<Partial<Record<ProjectId, ReadonlyArray<string>>>>({});
const [saving, setSaving] = useState(false);
const held = Object.values(picks).some((scopes) => scopes !== undefined);
if (held && !saving && !props.refreshing && !props.refreshFailed) setPicks({});
const busy = saving || (held && props.refreshing);
const bound = (projectId: ProjectId) =>
picks[projectId] ?? boundIssueTrackerScopes(tracker.tracker, props.bindings[projectId]);
const change = async (projectId: ProjectId, scopes: ReadonlyArray<string>) => {
if (props.disabled || busy) return;
const binding = issueTrackerBindingFor(tracker.tracker, bound(projectId), scopes);
const before = picks[projectId];
setSaving(true);
setPicks((current) => ({
...current,
[projectId]: boundIssueTrackerScopes(tracker.tracker, binding ?? undefined),
}));
const result = await bind({ environmentId, input: { projectId, binding } });
if (result._tag !== "Success") setPicks((current) => ({ ...current, [projectId]: before }));
setSaving(false);
};
return projects.map((project) => {
const bound = props.bindings[project.id];
// A project bound to another tracker keeps that binding; this row shows it unbound.
const value = bound?.tracker === tracker.tracker ? bound.scope : UNBOUND;
const locked = props.disabled || binding !== null;
const value = bound(project.id);
const options = issueTrackerScopeOptions(tracker, value);
const toggle = (key: string) =>
key === UNBOUND
? []
: value.includes(key)
? value.filter((scope) => scope !== key)
: [...value, key];
const locked = props.disabled || busy;
return (
<Menu
key={project.id}
Expand All @@ -248,26 +268,28 @@ export function IssueTrackerProjectRows(props: {
{
id: UNBOUND,
title: gt("Not bound"),
state: value === UNBOUND ? "on" : "off",
state: value.length === 0 ? "on" : "off",
attributes: { disabled: locked },
},
...tracker.scopes.map((scope) => ({
...options.map((scope) => ({
id: scope.key,
title: `${scope.name} (${scope.key})`,
state: scope.key === value ? ("on" as const) : ("off" as const),
attributes: { disabled: locked },
state: value.includes(scope.key) ? ("on" as const) : ("off" as const),
attributes: { disabled: locked || !scope.addable },
})),
]}
onPressAction={({ nativeEvent }) => void change(project.id, nativeEvent.event)}
onPressAction={({ nativeEvent }) => void change(project.id, toggle(nativeEvent.event))}
>
<SettingsRow
icon="folder"
label={project.title}
valuePosition="trailing"
value={
value === UNBOUND
value.length === 0
? gt("Not bound")
: (tracker.scopes.find((scope) => scope.key === value)?.name ?? value)
: value
.map((key) => tracker.scopes.find((scope) => scope.key === key)?.name ?? key)
.join(", ")
}
disabled={locked}
/>
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -3699,7 +3699,7 @@
"b725843fd45b74aa": "Anmeldedaten",
"b239ba3ce2899a3e": "Oder verwende deine eigenen Anmeldedaten",
"f0e6397ab4de588e": "Token",
"15ad0159a826b290": "Wähle das {scope} in {tracker}, dessen Issues jedes Projekt neben denen seines eigenen Repositorys auflistet.",
"295392927d5c8a84": "Wähle für jedes Projekt ein oder mehrere {scope}s in {tracker}. Ihre Issues erscheinen neben denen des Repositorys, und Agenten legen neue Issues im ersten an.",
"ce2136b36f87b655": "Verbinde diese Umgebung, um ihre Einstellungen zu ändern.",
"a90a441fd0e08de7": "Diese Umgebung",
"32fb83554cfd85b4": "Transkriptionsmodelle",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3700,7 +3700,7 @@
"b725843fd45b74aa": "Credentials",
"b239ba3ce2899a3e": "Or use your own credentials",
"f0e6397ab4de588e": "Token",
"15ad0159a826b290": "Pick the {tracker} {scope} whose issues each project lists beside its repository's own.",
"295392927d5c8a84": "Pick one or more {tracker} {scope}s for each project. Their issues list beside the repository's own, and agents file new issues in the first one.",
"ce2136b36f87b655": "Connect this environment to change its settings.",
"a90a441fd0e08de7": "This environment",
"32fb83554cfd85b4": "Transcription models",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -3694,7 +3694,7 @@
"b725843fd45b74aa": "Credenciales",
"b239ba3ce2899a3e": "O usa tus propias credenciales",
"f0e6397ab4de588e": "Token",
"15ad0159a826b290": "Elige el {scope} de {tracker} cuyas issues lista cada proyecto junto a las de su propio repositorio.",
"295392927d5c8a84": "Elige uno o más {scope}s de {tracker} para cada proyecto. Sus issues aparecen junto a las del repositorio, y los agentes crean issues nuevas en el primero.",
"ce2136b36f87b655": "Conecta este entorno para cambiar sus ajustes.",
"a90a441fd0e08de7": "Este entorno",
"32fb83554cfd85b4": "Modelos de transcripción",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -3694,7 +3694,7 @@
"b725843fd45b74aa": "Identifiants",
"b239ba3ce2899a3e": "Ou utilisez vos propres identifiants",
"f0e6397ab4de588e": "Jeton",
"15ad0159a826b290": "Choisissez le {scope} {tracker} dont chaque projet liste les tickets à côté de ceux de son propre dépôt.",
"295392927d5c8a84": "Choisissez un ou plusieurs {scope}s {tracker} pour chaque projet. Leurs tickets s'affichent à côté de ceux du dépôt, et les agents créent les nouveaux tickets dans le premier.",
"ce2136b36f87b655": "Connectez cet environnement pour modifier ses paramètres.",
"a90a441fd0e08de7": "Cet environnement",
"32fb83554cfd85b4": "Modèles de transcription",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -3691,7 +3691,7 @@
"b725843fd45b74aa": "資格情報",
"b239ba3ce2899a3e": "または自分の資格情報を使用",
"f0e6397ab4de588e": "トークン",
"15ad0159a826b290": "各プロジェクトがリポジトリ自身の Issue と並べて一覧表示する {tracker} の {scope} を選択します。",
"295392927d5c8a84": "各プロジェクトに {tracker} の {scope} を1つ以上選択します。その Issue はリポジトリ自身の Issue と並べて表示され、エージェントは最初の {scope} に新しい Issue を作成します。",
"ce2136b36f87b655": "設定を変更するには、この環境に接続してください。",
"a90a441fd0e08de7": "この環境",
"32fb83554cfd85b4": "文字起こしモデル",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -3695,7 +3695,7 @@
"b725843fd45b74aa": "자격 증명",
"b239ba3ce2899a3e": "또는 내 자격 증명 사용",
"f0e6397ab4de588e": "토큰",
"15ad0159a826b290": "각 프로젝트가 저장소 자체 이슈와 함께 표시할 이슈의 {tracker} {scope}을(를) 선택하세요.",
"295392927d5c8a84": "각 프로젝트에 {tracker} {scope}을(를) 하나 이상 선택하세요. 해당 이슈는 저장소 자체 이슈와 함께 표시되며, 에이전트는 첫 번째 {scope}에 새 이슈를 만듭니다.",
"ce2136b36f87b655": "설정을 변경하려면 이 환경에 연결하세요.",
"a90a441fd0e08de7": "이 환경",
"32fb83554cfd85b4": "받아쓰기 모델",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -3694,7 +3694,7 @@
"b725843fd45b74aa": "Credenciais",
"b239ba3ce2899a3e": "Ou use suas próprias credenciais",
"f0e6397ab4de588e": "Token",
"15ad0159a826b290": "Escolha o {scope} do {tracker} cujas issues cada projeto lista ao lado das do próprio repositório.",
"295392927d5c8a84": "Escolha um ou mais {scope}s do {tracker} para cada projeto. As issues deles aparecem ao lado das do repositório, e os agentes criam novas issues no primeiro.",
"ce2136b36f87b655": "Conecte este ambiente para alterar as configurações dele.",
"a90a441fd0e08de7": "Este ambiente",
"32fb83554cfd85b4": "Modelos de transcrição",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -3748,7 +3748,7 @@
"b725843fd45b74aa": "Учётные данные",
"b239ba3ce2899a3e": "Или используйте свои учётные данные",
"f0e6397ab4de588e": "Токен",
"15ad0159a826b290": "Выберите {scope} в {tracker}, issue которого каждый проект показывает рядом с issue своего репозитория.",
"295392927d5c8a84": "Выберите один или несколько {scope} в {tracker} для каждого проекта. Их issue показываются рядом с issue репозитория, а агенты создают новые issue в первом.",
"ce2136b36f87b655": "Подключите это окружение, чтобы изменить его настройки.",
"a90a441fd0e08de7": "Это окружение",
"32fb83554cfd85b4": "Модели расшифровки",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -3700,7 +3700,7 @@
"b725843fd45b74aa": "Autentiseringsuppgifter",
"b239ba3ce2899a3e": "Eller använd dina egna autentiseringsuppgifter",
"f0e6397ab4de588e": "Token",
"15ad0159a826b290": "Välj den {scope} i {tracker} vars ärenden varje projekt listar bredvid repots egna.",
"295392927d5c8a84": "Välj en eller flera {scope} i {tracker} för varje projekt. Deras ärenden listas bredvid repots egna, och agenter skapar nya ärenden i den första.",
"ce2136b36f87b655": "Anslut den här miljön för att ändra dess inställningar.",
"a90a441fd0e08de7": "Den här miljön",
"32fb83554cfd85b4": "Transkriberingsmodeller",
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/i18n/translations/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -3696,7 +3696,7 @@
"b725843fd45b74aa": "凭据",
"b239ba3ce2899a3e": "或使用你自己的凭据",
"f0e6397ab4de588e": "token",
"15ad0159a826b290": "选择 {tracker} {scope},每个项目会在其仓库自身的 issue 旁列出它的 issue。",
"295392927d5c8a84": "为每个项目选择一个或多个 {tracker} {scope}。它们的 issue 会列在仓库自身的 issue 旁,智能体会在第一个中创建新 issue。",
"ce2136b36f87b655": "连接此环境以更改其设置。",
"a90a441fd0e08de7": "此环境",
"32fb83554cfd85b4": "转写模型",
Expand Down
38 changes: 31 additions & 7 deletions apps/server/src/issue/IssueService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -598,40 +598,51 @@ describe("IssueService with a standalone tracker", () => {
}),
);

it.effect("lists a bound project's standalone scope beside its git host and serves both", () =>
it.effect("lists a bound project's standalone scopes beside its git host and serves them", () =>
Effect.gen(function* () {
const listed: string[] = [];
const record = (tracker: IssueTrackerKind): Partial<IssueTrackerApi> => ({
listIssues: (input) =>
Effect.sync(() => {
listed.push(`${tracker} ${input.host} ${input.scope}`);
return { items: [issue(tracker === LINEAR ? "ENG-1" : "1")], nextCursor: null };
return {
items: [issue(tracker === LINEAR ? `${input.scope}-1` : "1")],
nextCursor: null,
};
}),
});
const projects = [project({ id: "web", repository: "acme/web" }), project({ id: "notes" })];
const trackers = [fakeTracker(record(GITHUB)), fakeStandaloneTracker(record(LINEAR))];
const bound = yield* makeService({
projects: [...projects, project({ id: "api", repository: "acme/api" })],
trackers,
bindings: { ["web" as ProjectId]: { tracker: LINEAR, scope: "ENG" } },
bindings: {
["web" as ProjectId]: { tracker: LINEAR, scope: "ENG", additionalScopes: ["OPS"] },
},
});

const result = yield* bound.list({ state: "open" });
expect(listed.sort()).toEqual([
"github github.com acme/api",
"github github.com acme/web",
"linear linear.app ENG",
"linear linear.app OPS",
]);
expect(result.entries.map((entry) => [entry.tracker, entry.scope, entry.key]).sort()).toEqual(
[
["github", "acme/api", "1"],
["github", "acme/web", "1"],
["linear", "ENG", "ENG-1"],
["linear", "OPS", "OPS-1"],
],
);
expect(result.trackers.map((tracker) => [tracker.tracker, tracker.host]).sort()).toEqual([
["github", "github.com"],
["linear", "linear.app"],
expect(
result.trackers
.map((tracker) => [tracker.tracker, tracker.host, tracker.projectCount])
.sort(),
).toEqual([
["github", "github.com", 2],
["linear", "linear.app", 1],
]);
expect(result.scopes).toContainEqual({
projectId: "web",
Expand All @@ -642,9 +653,14 @@ describe("IssueService with a standalone tracker", () => {
// Narrowed to one project, both of its trackers are still read.
listed.length = 0;
const selected = yield* bound.list({ state: "open", projectId: "web" as ProjectId });
expect(listed.sort()).toEqual(["github github.com acme/web", "linear linear.app ENG"]);
expect(listed.sort()).toEqual([
"github github.com acme/web",
"linear linear.app ENG",
"linear linear.app OPS",
]);
expect(selected.entries.map((entry) => [entry.projectId, entry.scope]).sort()).toEqual([
["web", "ENG"],
["web", "OPS"],
["web", "acme/web"],
]);
listed.length = 0;
Expand All @@ -658,6 +674,14 @@ describe("IssueService with a standalone tracker", () => {
key: "ENG-1",
};
expect(yield* bound.detail(linearRef)).toMatchObject({ host: "linear.app", writable: true });
expect(yield* bound.detail({ ...linearRef, scope: "OPS", key: "OPS-1" })).toMatchObject({
writable: true,
});
expect(yield* bound.detail({ ...linearRef, scope: "QA", key: "QA-1" })).toMatchObject({
writable: false,
});
expect((yield* bound.projectScope("web" as ProjectId)).scope).toBe("ENG");
expect((yield* bound.projectScope("web" as ProjectId, "ops-12")).scope).toBe("OPS");
expect(
yield* bound.detail({
projectId: "web" as ProjectId,
Expand Down
Loading
Loading