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
8 changes: 8 additions & 0 deletions apps/server/src/issue/IssueService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,14 @@ describe("IssueService", () => {
}),
]);

// Narrowing to one host still names every tracker, so the client can switch between them.
const narrowed = yield* service.list({ state: "open", host: "github.com" });
expect(narrowed.entries.every((entry) => entry.host === "github.com")).toBe(true);
expect(narrowed.trackers.map((tracker) => tracker.host)).toEqual([
"github.com",
"gitlab.com",
]);

// A continuation only reads the scopes it names.
listed.length = 0;
const failed = yield* service.list({
Expand Down
6 changes: 5 additions & 1 deletion apps/server/src/issue/IssueService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,16 @@ const make = Effect.gen(function* () {
);

const list: IssueService["Service"]["list"] = Effect.fn("IssueService.list")(function* (input) {
const { supported, unimplemented } = yield* listProjects(input);
// Trackers name every host so a client narrowed to one can switch to another; only the
// narrowed host's scopes are read.
const { supported, unimplemented } = yield* listProjects({ projectId: input.projectId });
const host = input.host?.trim().toLowerCase();
const limit = input.limit ?? DEFAULT_LIST_LIMIT;
// Worktrees of one repository are separate projects, and every repository of an Azure
// DevOps project shares its work items; read each scope once.
const scopes = new Map<string, SupportedProject>();
for (const project of supported) {
if (host !== undefined && project.host !== host) continue;
const key = listCursorKey(project.host, project.scope);
if (!scopes.has(key)) scopes.set(key, project);
}
Expand Down
38 changes: 33 additions & 5 deletions apps/web/src/components/issue/IssuesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,16 @@ function getShortcutContext() {
};
}

function hostOptionsFor(groups: ReturnType<typeof groupIssues>, chosen: string | undefined) {
function hostOptionsFor(trackers: ReadonlyArray<IssueTrackerSummary>, chosen: string | undefined) {
const hosts = new Map<string, IssueTrackerSummary>();
for (const group of groups) hosts.set(group.tracker.host, group.tracker);
const ordered = [...trackers].sort((a, b) =>
issueTrackerKey(a).localeCompare(issueTrackerKey(b)),
);
for (const tracker of ordered) {
const existing = hosts.get(tracker.host);
if (existing === undefined || (!existing.configured && tracker.configured))
hosts.set(tracker.host, tracker);
}
return [
{ value: "", label: "All", Icon: Plug2Icon },
// A remembered host no project is on any more stays listed, so the filter can be taken off.
Expand Down Expand Up @@ -220,10 +227,31 @@ export function IssuesPage() {

// Rows grouped per tracker account, so a tracker that cannot be read says so where its rows
// would be, and each tracker's rows carry on from their own cursors.
const groups = groupIssues(held, debouncedQuery, projects, search.order ?? "updated");
const filterScopes = issueFilterScopes(held, projects);
// The server names every tracker so the menu can switch hosts, but reads only the chosen one.
const chosenHost = search.host?.toLowerCase();
const shown = chosenHost
? new Map(
[...held].map(([environmentId, page]) => [
environmentId,
{
...page,
answer: {
...page.answer,
trackers: page.answer.trackers.filter(
(tracker) => tracker.host.toLowerCase() === chosenHost,
),
},
},
]),
)
: held;
const groups = groupIssues(shown, debouncedQuery, projects, search.order ?? "updated");
const filterScopes = issueFilterScopes(shown, projects);

const hostOptions = hostOptionsFor(groups, search.host);
const hostOptions = hostOptionsFor(
[...held.values()].flatMap((page) => page.answer.trackers),
search.host,
);

const updateSearch = (patch: { [Key in keyof IssuesSearch]?: IssuesSearch[Key] | undefined }) => {
const merged = { ...search, ...patch };
Expand Down
Loading