mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-12-02 17:13:33 +01:00
fix(ui): steady list loading, picker footer, preview caption and plan-limited expiry
- My work keeps its tab bar and counts while a tab, search or filter
reloads: the first load holds the tab row with placeholders, a reload
dims the current rows and shows placeholder rows instead of a false
empty state. Admin repositories, users and conferences, the conference
page and the conferences list get the same placeholders and busy state.
- Repository picker: one footer row with the access link on the left and
a compact icon pager on the right; Previous only after page 1; a row's
name tooltip only when the name is cut short.
- Preview caption: the title stands alone, the redaction status is a chip
("Nothing redacted yet: add terms" focuses the Terms field). The
caption's Files toggle is gone: the tree is always shown from 992px and
the window's own file bar opens it below.
- Under a plan limit the expiry reads as text ("Apr 29, 2027 · in 5
months, the maximum on your plan") with the date input behind
"Advanced: pick an exact date"; validation still applies and a submit
opens the disclosure on an invalid date. Without a limit the picker
stays, and the echo no longer repeats "Expires".
- dev-mock: serves the dashboard summary API (with an optional delay
cookie), a 5-month free expiry and a long picker name.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0640d741f1
commit
94947ad0ec
16 files changed
+494
-105
No files matched your search
+34
-2
@@ -277,6 +277,38 @@ app.get("/api/user/quota", (req, res) => res.json(quota));
|
||||
app.get("/api/user/anonymized_repositories", (req, res) => res.json(repositories));
|
||||
app.get("/api/user/anonymized_pull_requests", (req, res) => res.json(pullRequests));
|
||||
app.get("/api/user/anonymized_gists", (req, res) => res.json(gists));
|
||||
// The dashboard summary API (src/server/routes/dashboard-summary.ts) over the
|
||||
// same fixtures: status keys, attention, type/status/search filters and sort.
|
||||
// A `mock_dashboard_delay=<ms>` cookie holds each answer, so the loading and
|
||||
// reloading states (first load, tab switch, search) can be checked.
|
||||
const summaryItems = () => [
|
||||
...repositories.map((r) => ({ ...r, _type: "repo", _id: r.repoId, _label: r.source?.fullName, _source: r.source?.fullName })),
|
||||
...pullRequests.map((p) => ({ ...p, _type: "pr", _id: p.pullRequestId || "", _label: `${p.source.repositoryFullName}#${p.source.pullRequestId}`, _source: `${p.source.repositoryFullName}#${p.source.pullRequestId}` })),
|
||||
...gists.map((g) => ({ ...g, _type: "gist", _id: g.gistId, _label: `Gist ${g.gistId}`, _source: g.source?.gistId })),
|
||||
].map((item) => {
|
||||
const expired = item.status === "ready" && item.options && item.options.expirationMode !== "never" && item.options.expirationDate && new Date(item.options.expirationDate) <= new Date();
|
||||
const status = expired ? "expired" : item.status;
|
||||
const key = ["ready", "error"].includes(status) ? status : ["expired", "expiring"].includes(status) ? "expired" : ["removed", "removing"].includes(status) ? "removed" : "progress";
|
||||
const since = item.anonymizeDate || item.lastView;
|
||||
const attention = status === "error" || !item._id || (key === "progress" && !!since && new Date(since) < new Date(Date.now() - 2 * 3600000));
|
||||
return { ...item, status, _statusKey: key, _attention: attention };
|
||||
});
|
||||
app.get("/api/user/dashboard", (req, res) => {
|
||||
const all = summaryItems();
|
||||
const statuses = String(req.query.statuses || "ready,progress,error,expired").split(",");
|
||||
const q = String(req.query.q || "").trim().toLowerCase();
|
||||
const sort = String(req.query.sort || "-anonymizeDate");
|
||||
const field = sort.replace(/^-/, ""), dir = sort.startsWith("-") ? -1 : 1;
|
||||
const value = (item) => field.split(".").reduce((o, k) => (o == null ? o : o[k]), item);
|
||||
const filtered = all.filter((item) => statuses.includes(item._statusKey)
|
||||
&& (!["repo", "pr", "gist"].includes(req.query.type) || item._type === req.query.type)
|
||||
&& (req.query.attention !== "true" || item._attention)
|
||||
&& (!q || [item._id, item._label, item._source, item.conference].some((v) => String(v || "").toLowerCase().includes(q))));
|
||||
filtered.sort((a, b) => { const x = value(a) ?? "", y = value(b) ?? ""; return (x > y ? 1 : x < y ? -1 : 0) * dir; });
|
||||
const items = filtered.map(({ _id, _source, _statusKey, _attention, ...item }) => item);
|
||||
const delayMs = Number((/(?:^|;\s*)mock_dashboard_delay=(\d+)/.exec(req.headers.cookie || "") || [])[1] || 0);
|
||||
global.setTimeout(() => res.json({ items, cursor: null, total: all.length, attention: all.filter((i) => i._attention).length, filtered: filtered.length }), delayMs);
|
||||
});
|
||||
// The landing picker: repositories the GitHub App can read.
|
||||
app.get("/api/user/all_repositories", (req, res) => res.json(["jsmith/robust-repair", "jsmith/thesis-code", "tdurieux/anonymous_github", "acme-lab/benchmarks"].map((fullName, i) => ({ id: "r" + i, fullName }))));
|
||||
app.get("/api/user/default", (req, res) =>
|
||||
@@ -297,7 +329,7 @@ app.get("/api/conferences/plans", (req, res) => res.json(billingOn(req)
|
||||
? conferenceTiers.map((t) => ({ id: t.id, name: t.name, pricePerRepo: 0, storagePerRepo: t.storage, repositories: t.repositories, description: `<li>Up to ${t.repositories} repositories</li><li>Up to 180 days</li><li>Prepaid at checkout</li>` }))
|
||||
: plans));
|
||||
app.get("/api/billing/", (req, res) => billingOn(req)
|
||||
? res.json({ enabled: true, csrf: "local-preview-only", checkoutEnabled: true, freeExpirationMonths: 12, grants: [], purchases: [], repositories: [], portal: false, allowance: null,
|
||||
? res.json({ enabled: true, csrf: "local-preview-only", checkoutEnabled: true, freeExpirationMonths: 5, grants: [], purchases: [], repositories: [], portal: false, allowance: null,
|
||||
plans: conferenceTiers.map((t) => ({ id: t.id, name: t.name, description: "", repositories: t.repositories, storage: t.storage, amount: t.amount, currency: "eur" })) })
|
||||
: res.status(404).json({ error: "not mocked: /api/billing/" }));
|
||||
app.get("/api/conferences/", (req, res) => res.json(conferences));
|
||||
@@ -999,7 +1031,7 @@ app.post("/api/admin/users/:username/:action", ok);
|
||||
app.get("/api/user/repository_picker", (req, res) => {
|
||||
const cursor = Number(req.query.cursor || 0);
|
||||
const query = String(req.query.q || "").toLowerCase();
|
||||
const repos = Array.from({ length: 63 }, (_, id) => ({ id, fullName: `research/project-${String(id + 1).padStart(2, "0")}` }));
|
||||
const repos = Array.from({ length: 63 }, (_, id) => ({ id, fullName: id === 2 ? "ASSERT-KTH/ci-hackathon-reproducible-builds-replication-package-2026" : `research/project-${String(id + 1).padStart(2, "0")}` }));
|
||||
const matches = repos.filter(repo => repo.fullName.toLowerCase().includes(query));
|
||||
res.json({ items: matches.slice(cursor, cursor + 20), nextCursor: cursor + 20 < matches.length ? cursor + 20 : null });
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user