create-heresay 0.2.31 → 0.2.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/release/VERSION +1 -1
- package/release/functions/lib/core/agent.js +9 -0
- package/release/functions/lib/core/chat.js +36 -1
- package/release/functions/lib/core/handler.js +26 -0
- package/release/functions/lib/core/types.js +1 -1
- package/release/functions/lib/core/version.js +1 -1
- package/release/functions/lib/core/withdraw.js +29 -0
- package/release/public/dashboard.css +3 -0
- package/release/public/dashboard.js +5 -3
- package/release/public/sdk.js +53 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-heresay",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.32",
|
|
4
4
|
"description": "Set up your own Heresay: in-app feedback that every report gets a hearing. Creates a Firebase project in your Google account and deploys the dashboard, API and SDK to it.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/release/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.32
|
|
@@ -7,6 +7,7 @@ import { createHash, randomBytes, timingSafeEqual } from 'node:crypto';
|
|
|
7
7
|
import { CLAIM_TTL_MS, LIMITS, PLATFORMS, REPORT_TYPES, isPlatform, isReportType, toReporterView, } from './types.js';
|
|
8
8
|
import { notify } from './notifications.js';
|
|
9
9
|
import { parseFixRef, stampFix } from './duplicates.js';
|
|
10
|
+
import { withdraw } from './withdraw.js';
|
|
10
11
|
const json = (status, body) => ({ status, body });
|
|
11
12
|
const str = (v, max) => {
|
|
12
13
|
if (typeof v !== 'string')
|
|
@@ -370,6 +371,14 @@ async function findings(p, req, deps, body, token, repoName, apps, now) {
|
|
|
370
371
|
out.sort((a, b) => b.created_at.localeCompare(a.created_at));
|
|
371
372
|
return json(200, { repo: repoName, findings: out.slice(0, 100) });
|
|
372
373
|
}
|
|
374
|
+
if (p.length === 3 && p[2] === 'withdraw' && req.method === 'POST') {
|
|
375
|
+
for (const app of apps) {
|
|
376
|
+
if (!(await deps.store.getReport(app.id, p[1])))
|
|
377
|
+
continue;
|
|
378
|
+
return withdraw(app, p[1], { kind: 'agent', by: repoName }, body.reason, (d) => d === device, deps);
|
|
379
|
+
}
|
|
380
|
+
return json(404, { error: 'no such finding from this repo' });
|
|
381
|
+
}
|
|
373
382
|
if (p.length !== 1 || req.method !== 'POST')
|
|
374
383
|
return json(404, { error: 'not found' });
|
|
375
384
|
const want = str(body.app, 100);
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { createHash } from 'node:crypto';
|
|
14
14
|
import { OPEN_CORS, baseUrl, chatCaller, signInFirst } from './oauth.js';
|
|
15
15
|
import { notify } from './notifications.js';
|
|
16
|
+
import { withdraw } from './withdraw.js';
|
|
16
17
|
import { LIMITS, REPORT_TYPES, isReportType } from './types.js';
|
|
17
18
|
const PROTOCOLS = ['2025-06-18', '2025-03-26', '2024-11-05'];
|
|
18
19
|
const json = (status, body, headers) => ({ status, body, headers: { ...OPEN_CORS, ...headers } });
|
|
@@ -80,6 +81,21 @@ const TOOLS = [
|
|
|
80
81
|
},
|
|
81
82
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
82
83
|
},
|
|
84
|
+
{
|
|
85
|
+
name: 'withdraw_request',
|
|
86
|
+
title: 'Take back a Heresay request',
|
|
87
|
+
description: 'Withdraws a request this team member sent, while it is still open. It isn\'t deleted: the team sees it under Withdrawn, with the reason. Accepted requests can\'t be withdrawn.',
|
|
88
|
+
inputSchema: {
|
|
89
|
+
type: 'object',
|
|
90
|
+
properties: {
|
|
91
|
+
id: { type: 'string', description: 'The request id, from my_requests' },
|
|
92
|
+
reason: { type: 'string', maxLength: LIMITS.reasonMax, description: 'Why, in a sentence. Optional.' },
|
|
93
|
+
},
|
|
94
|
+
required: ['id'],
|
|
95
|
+
additionalProperties: false,
|
|
96
|
+
},
|
|
97
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
98
|
+
},
|
|
83
99
|
{
|
|
84
100
|
name: 'my_requests',
|
|
85
101
|
title: 'My Heresay requests',
|
|
@@ -160,6 +176,8 @@ async function one(m, member, via, req, deps) {
|
|
|
160
176
|
return rpcResult(msg.id, await draftRequest(args, member, via, deps));
|
|
161
177
|
if (name === 'send_draft')
|
|
162
178
|
return rpcResult(msg.id, await sendDraft(args, member, req, deps));
|
|
179
|
+
if (name === 'withdraw_request')
|
|
180
|
+
return rpcResult(msg.id, await withdrawRequest(args, member, deps));
|
|
163
181
|
if (name === 'my_requests')
|
|
164
182
|
return rpcResult(msg.id, await myRequests(args, member, req, deps));
|
|
165
183
|
return rpcError(msg.id, -32602, `Unknown tool: ${String(name)}`);
|
|
@@ -285,8 +303,25 @@ async function myRequests(a, member, req, deps) {
|
|
|
285
303
|
}
|
|
286
304
|
}
|
|
287
305
|
rows.sort((x, y) => String(y.sent_at).localeCompare(String(x.sent_at)));
|
|
288
|
-
const line = (r) => `- ${r.app} · ${r.type} · ${r.status}${r.status === 'declined' && r.decline_reason ? ` (why: ${r.decline_reason})` : ''}`
|
|
306
|
+
const line = (r) => `- ${r.id} · ${r.app} · ${r.type} · ${r.status}${r.status === 'declined' && r.decline_reason ? ` (why: ${r.decline_reason})` : ''}`
|
|
289
307
|
+ `${r.status === 'fixed' && r.fix_note ? ` (${r.fix_note})` : ''}: ${String(r.text).slice(0, 140)}`;
|
|
290
308
|
return result(rows.length ? rows.slice(0, 50).map(line).join('\n') : 'Nothing sent from a chat app yet.', { requests: rows.slice(0, 50) });
|
|
291
309
|
}
|
|
310
|
+
/** Find one of this member's requests across the apps and take it back. */
|
|
311
|
+
async function withdrawRequest(a, member, deps) {
|
|
312
|
+
const id = str(a.id, 64);
|
|
313
|
+
if (!id)
|
|
314
|
+
throw new ToolError('Say which request: its id, from my_requests.');
|
|
315
|
+
const device = chatDevice(member.email);
|
|
316
|
+
for (const p of await deps.store.listProjects()) {
|
|
317
|
+
const r = await deps.store.getReport(p.id, id);
|
|
318
|
+
if (!r)
|
|
319
|
+
continue;
|
|
320
|
+
const res = await withdraw(p, id, { kind: 'member', by: member.email }, a.reason, (d) => d === device, deps);
|
|
321
|
+
if (res.status !== 200)
|
|
322
|
+
throw new ToolError(String(res.body.error ?? 'Couldn\'t withdraw it.'));
|
|
323
|
+
return result(`Withdrawn from ${p.name}. It stays on the team's dashboard under Withdrawn${a.reason ? ', with your reason' : ''}.`, { id, app: p.name, status: 'withdrawn' });
|
|
324
|
+
}
|
|
325
|
+
throw new ToolError('No request with that id was sent by you.');
|
|
326
|
+
}
|
|
292
327
|
//# sourceMappingURL=chat.js.map
|
|
@@ -3,6 +3,7 @@ import { agent, normaliseRepo, reposFor, tokens } from './agent.js';
|
|
|
3
3
|
import { parseTrail, trailLines } from './trail.js';
|
|
4
4
|
import { OPEN_CORS, approve, authorizationServer, authorize, connections, describeAsk, protectedResource, register, token } from './oauth.js';
|
|
5
5
|
import { mcp } from './chat.js';
|
|
6
|
+
import { withdraw } from './withdraw.js';
|
|
6
7
|
import { alsoReported, duplicatesOf, follow, merge, parseFixRef, stampFix, unmerge } from './duplicates.js';
|
|
7
8
|
import { notificationSettings, notify } from './notifications.js';
|
|
8
9
|
import { LIMITS, PLATFORMS, REPORT_ORDER, REPORT_TYPES, isFramework, isPlatform, isReportType, isSignIn, toReporterView, } from './types.js';
|
|
@@ -186,6 +187,8 @@ async function route(req, deps) {
|
|
|
186
187
|
return submit(req, deps);
|
|
187
188
|
if (p[0] === 'reports' && p[1] === 'mine' && req.method === 'POST')
|
|
188
189
|
return mine(req, deps);
|
|
190
|
+
if (p[0] === 'reports' && p[1] === 'withdraw' && req.method === 'POST')
|
|
191
|
+
return withdrawMine(req, deps);
|
|
189
192
|
if (p[0] === 'reports' && req.method === 'OPTIONS')
|
|
190
193
|
return preflight(req);
|
|
191
194
|
// Chat apps (ChatGPT and other MCP clients): OAuth with the member's own sign-in, then MCP.
|
|
@@ -456,6 +459,29 @@ async function mine(req, deps) {
|
|
|
456
459
|
rs.sort((a, b) => b.created_at.localeCompare(a.created_at));
|
|
457
460
|
return json(200, { reports: rs.map(toReporterView) }, headers);
|
|
458
461
|
}
|
|
462
|
+
/**
|
|
463
|
+
* POST /v1/reports/withdraw { key, device_id, report_id, reason? }: the reporter takes back one of
|
|
464
|
+
* their own open reports. Origin-checked like every SDK call, limited like reading them, and the
|
|
465
|
+
* device id must be the one that sent it.
|
|
466
|
+
*/
|
|
467
|
+
async function withdrawMine(req, deps) {
|
|
468
|
+
const body = parseBody(req.body);
|
|
469
|
+
const got = await publicProject(req, body.key, deps);
|
|
470
|
+
if ('status' in got)
|
|
471
|
+
return got;
|
|
472
|
+
const { project, headers } = got;
|
|
473
|
+
if (!validDeviceId(body.device_id))
|
|
474
|
+
return json(400, { error: 'bad device_id' }, headers);
|
|
475
|
+
const now = deps.now();
|
|
476
|
+
const start = Math.floor(now / MINE_LIMIT.windowMs) * MINE_LIMIT.windowMs;
|
|
477
|
+
if (!(await deps.store.hit(`mine:${sha(req.ip)}:${start}`, MINE_LIMIT.limit, start + MINE_LIMIT.windowMs))) {
|
|
478
|
+
return json(429, { error: 'too many requests, try again later' }, headers);
|
|
479
|
+
}
|
|
480
|
+
const device = body.device_id;
|
|
481
|
+
const res = await withdraw(project, String(body.report_id ?? ''), { kind: 'reporter', by: 'the reporter' }, body.reason, (d) => d === device, deps);
|
|
482
|
+
const r = res.body.report;
|
|
483
|
+
return { ...res, body: r ? { report: toReporterView(r) } : res.body, headers };
|
|
484
|
+
}
|
|
459
485
|
/** The SDK posts text/plain to avoid a preflight, so the body may arrive as a string. */
|
|
460
486
|
function parseBody(b) {
|
|
461
487
|
if (typeof b === 'string') {
|
|
@@ -16,7 +16,7 @@ export const isSignIn = (v) => v === 'yes' || v === 'no';
|
|
|
16
16
|
/** A claim nobody has touched for this long is dropped, so a crashed agent can't block a brief. */
|
|
17
17
|
export const CLAIM_TTL_MS = 24 * 3600_000;
|
|
18
18
|
export const toReporterView = (r) => ({
|
|
19
|
-
id: r.id, type: r.type, text: r.text, status: r.status,
|
|
19
|
+
id: r.id, type: r.type, text: r.text, status: r.status, withdrawn_reason: r.withdrawal?.reason ?? null,
|
|
20
20
|
decline_reason: r.decline_reason, fix_note: r.fix_note ?? null, fix_version: r.fix_ref?.version ?? null,
|
|
21
21
|
created_at: r.created_at, updated_at: r.updated_at,
|
|
22
22
|
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { duplicatesOf } from './duplicates.js';
|
|
2
|
+
import { LIMITS } from './types.js';
|
|
3
|
+
const json = (status, body) => ({ status, body });
|
|
4
|
+
export async function withdraw(project, id, by, reason, owns, deps) {
|
|
5
|
+
const r = await deps.store.getReport(project.id, id);
|
|
6
|
+
// Not yours and not there look the same, so a device can't probe other reports.
|
|
7
|
+
if (!r || !owns(r.device_id))
|
|
8
|
+
return json(404, { error: 'no such report' });
|
|
9
|
+
if (r.status === 'withdrawn')
|
|
10
|
+
return json(200, { report: r, already: true });
|
|
11
|
+
if (r.status !== 'open') {
|
|
12
|
+
return json(409, { error: r.status === 'accepted'
|
|
13
|
+
? 'This has been accepted and work may have started, so it can\'t be taken back now. Tell the team instead.'
|
|
14
|
+
: `This is already ${r.status}.`, status: r.status });
|
|
15
|
+
}
|
|
16
|
+
const at = new Date(deps.now()).toISOString();
|
|
17
|
+
const why = typeof reason === 'string' && reason.trim() ? reason.trim().slice(0, LIMITS.reasonMax) : null;
|
|
18
|
+
const t = await deps.store.move(project.id, id, 'open', 'withdrawn', { triaged_by: by.by, updated_at: at });
|
|
19
|
+
if (!t.ok)
|
|
20
|
+
return json(409, { error: 'it changed just now; look again' });
|
|
21
|
+
const withdrawal = { ...by, at, reason: why };
|
|
22
|
+
await deps.store.updateReport(project.id, id, { withdrawal });
|
|
23
|
+
// Reports merged into it stand on their own again: their reporters still want an answer.
|
|
24
|
+
for (const d of await duplicatesOf(project, id, deps))
|
|
25
|
+
await deps.store.updateReport(d.project_id, d.id, { duplicate_of: null });
|
|
26
|
+
deps.log('api.report_withdrawn', { project_id: project.id, report_id: id, kind: by.kind });
|
|
27
|
+
return json(200, { report: { ...t.report, withdrawal } });
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=withdraw.js.map
|
|
@@ -493,3 +493,6 @@ a.platform:hover { border-color:var(--acc); box-shadow:0 0 0 3px var(--mist); }
|
|
|
493
493
|
.report .fix-line .link { border:0; background:none; padding:0; font:inherit; color:var(--deep, #0b5e57); text-decoration:underline; cursor:pointer; }
|
|
494
494
|
.pill.version-pill { background:#dcfce7; color:#166534; }
|
|
495
495
|
.fix-ref input { flex:1; min-width:160px; }
|
|
496
|
+
|
|
497
|
+
.status.s-withdrawn { background:rgba(127,127,127,.14); color:var(--mute); }
|
|
498
|
+
.report .reason.withdrawn { color:var(--mute); }
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
var $ = function (id) { return document.getElementById(id); };
|
|
9
9
|
var TYPE_LABEL = { broken: 'Broken', confusing: 'Confusing', improvement: 'Could be better', idea: 'Idea' };
|
|
10
|
-
var STATUS_LABEL = { open: 'Open', accepted: 'Accepted', fixed: 'Fixed', declined: 'Declined' };
|
|
10
|
+
var STATUS_LABEL = { open: 'Open', accepted: 'Accepted', fixed: 'Fixed', declined: 'Declined', withdrawn: 'Withdrawn' };
|
|
11
11
|
var SDK_URL = location.origin + '/sdk/v1.js';
|
|
12
12
|
var me = null, projects = [], timer = null;
|
|
13
13
|
|
|
@@ -1374,7 +1374,7 @@
|
|
|
1374
1374
|
function drawFilters(here) {
|
|
1375
1375
|
here = here || reports.filter(function (r) { return where === 'all' || r.project_id === where; });
|
|
1376
1376
|
filters.textContent = '';
|
|
1377
|
-
['open', 'accepted', 'fixed', 'declined', 'all'].forEach(function (f) {
|
|
1377
|
+
['open', 'accepted', 'fixed', 'declined', 'withdrawn', 'all'].forEach(function (f) {
|
|
1378
1378
|
var n = f === 'all' ? here.length : here.filter(function (r) { return r.status === f; }).length;
|
|
1379
1379
|
filters.appendChild(el('button', {
|
|
1380
1380
|
'aria-pressed': String(filter === f),
|
|
@@ -1721,6 +1721,8 @@
|
|
|
1721
1721
|
suggest,
|
|
1722
1722
|
trailView(r.trail),
|
|
1723
1723
|
r.decline_reason ? el('div', { class: 'reason', text: 'Declined: ' + r.decline_reason }) : null,
|
|
1724
|
+
r.withdrawal ? el('div', { class: 'reason withdrawn', text: 'Withdrawn by ' + ({ reporter: 'the person who sent it', member: r.withdrawal.by, agent: 'the agent in ' + r.withdrawal.by }[r.withdrawal.kind] || r.withdrawal.by)
|
|
1725
|
+
+ ' on ' + new Date(r.withdrawal.at).toLocaleString() + (r.withdrawal.reason ? ': ' + r.withdrawal.reason : '') }) : null,
|
|
1724
1726
|
r.fix_note ? el('div', { class: 'reason', text: 'Told them: ' + r.fix_note }) : null,
|
|
1725
1727
|
r.status === 'fixed' ? fixRefLine() : null,
|
|
1726
1728
|
r.status === 'accepted' && brief ? el('div', { class: 'brief-line' }, [
|
|
@@ -1728,7 +1730,7 @@
|
|
|
1728
1730
|
]) : null,
|
|
1729
1731
|
brief && brief.notes.length ? el('details', { class: 'notes' }, [el('summary', { text: brief.notes.length + (brief.notes.length === 1 ? ' note' : ' notes') + ' from agents' })]
|
|
1730
1732
|
.concat(brief.notes.map(function (n) { return el('p', {}, [el('span', { class: 'mute', text: n.by.replace(/^agent:/, '') + ' · ' + new Date(n.at).toLocaleString() + ': ' }), n.text]); }))) : null,
|
|
1731
|
-
r.status === 'fixed' || r.status === 'declined' ? null : actions,
|
|
1733
|
+
r.status === 'fixed' || r.status === 'declined' || r.status === 'withdrawn' ? null : actions,
|
|
1732
1734
|
]);
|
|
1733
1735
|
return card;
|
|
1734
1736
|
}
|
package/release/public/sdk.js
CHANGED
|
@@ -97,7 +97,8 @@
|
|
|
97
97
|
improvement: ['Could be better', 'It works, but it could be better'],
|
|
98
98
|
idea: ['Idea', 'Something that does not exist yet'],
|
|
99
99
|
},
|
|
100
|
-
status: { open: 'Waiting for the developer', accepted: 'Accepted, being worked on', fixed: 'Fixed', declined: 'Declined' },
|
|
100
|
+
status: { open: 'Waiting for the developer', accepted: 'Accepted, being worked on', fixed: 'Fixed', declined: 'Declined', withdrawn: 'You took this back' },
|
|
101
|
+
takeBack: 'Take back', takeBackAsk: 'Take this back? It isn’t deleted: the team sees you withdrew it.', takeBackWhy: 'Why? (optional)', takeBackYes: 'Take it back', keep: 'Keep it', yourWhy: 'Your reason: ',
|
|
101
102
|
optional: '(optional)', yourName: 'Your name', email: 'Email',
|
|
102
103
|
emailHint: 'Only if you are happy for the team to reply to you.',
|
|
103
104
|
setup: 'About your setup', setupHint: 'Sent with every report, so you only say it once.',
|
|
@@ -136,7 +137,8 @@
|
|
|
136
137
|
improvement: ['Pourrait être mieux', 'Ça marche, mais ça pourrait être mieux'],
|
|
137
138
|
idea: ['Idée', 'Quelque chose qui n’existe pas encore'],
|
|
138
139
|
},
|
|
139
|
-
status: { open: 'En attente de l’équipe', accepted: 'Accepté, en cours', fixed: 'Corrigé', declined: 'Refusé' },
|
|
140
|
+
status: { open: 'En attente de l’équipe', accepted: 'Accepté, en cours', fixed: 'Corrigé', declined: 'Refusé', withdrawn: 'Vous l’avez retiré' },
|
|
141
|
+
takeBack: 'Retirer', takeBackAsk: 'Retirer ce signalement ? Il n’est pas supprimé : l’équipe voit que vous l’avez retiré.', takeBackWhy: 'Pourquoi ? (facultatif)', takeBackYes: 'Le retirer', keep: 'Le garder', yourWhy: 'Votre raison : ',
|
|
140
142
|
optional: '(facultatif)', yourName: 'Votre nom', email: 'E-mail',
|
|
141
143
|
emailHint: 'Seulement si vous acceptez que l’équipe vous réponde.',
|
|
142
144
|
setup: 'Votre configuration', setupHint: 'Envoyé avec chaque signalement, pour ne le dire qu’une fois.',
|
|
@@ -175,7 +177,8 @@
|
|
|
175
177
|
improvement: ['இன்னும் சிறப்பாக்கலாம்', 'வேலை செய்கிறது, ஆனால் மேம்படுத்தலாம்'],
|
|
176
178
|
idea: ['யோசனை', 'இன்னும் இல்லாத ஒன்று'],
|
|
177
179
|
},
|
|
178
|
-
status: { open: 'டெவலப்பருக்காகக் காத்திருக்கிறது', accepted: 'ஏற்கப்பட்டது, வேலை நடக்கிறது', fixed: 'சரிசெய்யப்பட்டது', declined: 'நிராகரிக்கப்பட்டது' },
|
|
180
|
+
status: { open: 'டெவலப்பருக்காகக் காத்திருக்கிறது', accepted: 'ஏற்கப்பட்டது, வேலை நடக்கிறது', fixed: 'சரிசெய்யப்பட்டது', declined: 'நிராகரிக்கப்பட்டது', withdrawn: 'நீங்கள் திரும்பப் பெற்றீர்கள்' },
|
|
181
|
+
takeBack: 'திரும்பப் பெறு', takeBackAsk: 'இதைத் திரும்பப் பெறவா? இது நீக்கப்படாது: நீங்கள் திரும்பப் பெற்றதைக் குழு பார்க்கும்.', takeBackWhy: 'ஏன்? (விருப்பத்தேர்வு)', takeBackYes: 'திரும்பப் பெறு', keep: 'வைத்திரு', yourWhy: 'உங்கள் காரணம்: ',
|
|
179
182
|
optional: '(விருப்பத்தேர்வு)', yourName: 'உங்கள் பெயர்', email: 'மின்னஞ்சல்',
|
|
180
183
|
emailHint: 'குழு உங்களுக்குப் பதில் அனுப்பலாம் என்றால் மட்டும்.',
|
|
181
184
|
setup: 'உங்கள் அமைப்பு பற்றி', setupHint: 'ஒவ்வொரு புகாருடனும் அனுப்பப்படும், எனவே ஒருமுறை சொன்னால் போதும்.',
|
|
@@ -214,7 +217,8 @@
|
|
|
214
217
|
improvement: ['बेहतर हो सकता है', 'काम करता है, पर बेहतर हो सकता है'],
|
|
215
218
|
idea: ['सुझाव', 'कुछ ऐसा जो अभी नहीं है'],
|
|
216
219
|
},
|
|
217
|
-
status: { open: 'डेवलपर का इंतज़ार', accepted: 'स्वीकार, इस पर काम चल रहा है', fixed: 'ठीक हो गया', declined: 'अस्वीकार' },
|
|
220
|
+
status: { open: 'डेवलपर का इंतज़ार', accepted: 'स्वीकार, इस पर काम चल रहा है', fixed: 'ठीक हो गया', declined: 'अस्वीकार', withdrawn: 'आपने इसे वापस ले लिया' },
|
|
221
|
+
takeBack: 'वापस लें', takeBackAsk: 'इसे वापस लें? यह हटाया नहीं जाएगा: टीम देखेगी कि आपने इसे वापस लिया।', takeBackWhy: 'क्यों? (वैकल्पिक)', takeBackYes: 'वापस लें', keep: 'रहने दें', yourWhy: 'आपकी वजह: ',
|
|
218
222
|
optional: '(वैकल्पिक)', yourName: 'आपका नाम', email: 'ईमेल',
|
|
219
223
|
emailHint: 'सिर्फ़ तब, जब आप चाहते हैं कि टीम आपको जवाब दे।',
|
|
220
224
|
setup: 'आपके सेटअप के बारे में', setupHint: 'हर रिपोर्ट के साथ भेजा जाता है, ताकि आपको एक ही बार बताना पड़े।',
|
|
@@ -334,7 +338,7 @@
|
|
|
334
338
|
}
|
|
335
339
|
function unseen() {
|
|
336
340
|
var s = seen();
|
|
337
|
-
return state.reports.filter(function (r) { return r.status !== 'open' && s[r.id] !== mark(r); }).length;
|
|
341
|
+
return state.reports.filter(function (r) { return r.status !== 'open' && r.status !== 'withdrawn' && s[r.id] !== mark(r); }).length;
|
|
338
342
|
}
|
|
339
343
|
/** a < b for versions like 1.4, 1.10.2, 2.0 (build suffixes ignored). Unknown: false. */
|
|
340
344
|
function older(a, b) {
|
|
@@ -1022,6 +1026,15 @@
|
|
|
1022
1026
|
}).then(body);
|
|
1023
1027
|
}
|
|
1024
1028
|
|
|
1029
|
+
function withdrawReport(id, reason) {
|
|
1030
|
+
if (PREVIEW) return Promise.resolve({ report: Object.assign({}, state.reports.filter(function (x) { return x.id === id; })[0], { status: 'withdrawn', withdrawn_reason: reason || null }) });
|
|
1031
|
+
return fetch(API + '/reports/withdraw', {
|
|
1032
|
+
method: 'POST',
|
|
1033
|
+
headers: { 'content-type': 'text/plain;charset=UTF-8' },
|
|
1034
|
+
body: JSON.stringify({ key: KEY, device_id: deviceId(), report_id: id, reason: reason || null }),
|
|
1035
|
+
}).then(body);
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1025
1038
|
function refresh() {
|
|
1026
1039
|
if (PREVIEW) return Promise.resolve();
|
|
1027
1040
|
return fetch(API + '/reports/mine', {
|
|
@@ -1155,6 +1168,8 @@
|
|
|
1155
1168
|
'.thanks{padding:10px 12px;margin:0 0 8px;border-radius:10px;background:var(--fb-line)}',
|
|
1156
1169
|
'.item{border-top:1px solid var(--fb-line);padding:10px 0}',
|
|
1157
1170
|
'.item:first-child{border-top:0}',
|
|
1171
|
+
'.take-back{margin-top:6px}.take-back input{width:100%;padding:7px 9px;border:1px solid var(--fb-line);border-radius:8px;background:none;margin:4px 0}',
|
|
1172
|
+
'.take-back .row{margin-top:4px;justify-content:flex-end}',
|
|
1158
1173
|
'.status{font-size:12px;font-weight:600}',
|
|
1159
1174
|
'.status.fixed,.status.accepted{color:var(--fb-fg)}',
|
|
1160
1175
|
'.reason{margin-top:4px;padding:8px;border-radius:8px;background:var(--fb-line);font-size:13px}',
|
|
@@ -1503,7 +1518,7 @@
|
|
|
1503
1518
|
var s = seen();
|
|
1504
1519
|
state.reports.forEach(function (r) {
|
|
1505
1520
|
var label = (TYPES.filter(function (t) { return t.id === r.type; })[0] || {}).label || r.type;
|
|
1506
|
-
var fresh = r.status !== 'open' && s[r.id] !== mark(r);
|
|
1521
|
+
var fresh = r.status !== 'open' && r.status !== 'withdrawn' && s[r.id] !== mark(r);
|
|
1507
1522
|
listBox.appendChild(el('div', { class: 'item' }, [
|
|
1508
1523
|
el('div', { class: 'status ' + r.status, text: (fresh ? '● ' : '') + (S.status[r.status] || r.status) }),
|
|
1509
1524
|
el('div', { class: 'text', text: r.text }),
|
|
@@ -1514,10 +1529,42 @@
|
|
|
1514
1529
|
? el('div', { class: 'reason', text: r.fix_note }) : null,
|
|
1515
1530
|
r.status === 'fixed' && r.fix_version
|
|
1516
1531
|
? el('div', { class: 'small', text: fmt(S.fixedIn, { v: r.fix_version }) + (older(state.version, r.fix_version) ? ' ' + fmt(S.updateTo, { v: r.fix_version }) : '') }) : null,
|
|
1532
|
+
r.status === 'withdrawn' && r.withdrawn_reason ? el('div', { class: 'small', text: S.yourWhy + r.withdrawn_reason }) : null,
|
|
1533
|
+
r.status === 'open' ? takeBack(r) : null,
|
|
1517
1534
|
]));
|
|
1518
1535
|
});
|
|
1519
1536
|
}
|
|
1520
1537
|
|
|
1538
|
+
/** "Take back": a report they sent and the team hasn't accepted. Kept as withdrawn, not deleted. */
|
|
1539
|
+
function takeBack(r) {
|
|
1540
|
+
var box = el('div', { class: 'take-back' });
|
|
1541
|
+
function ask() {
|
|
1542
|
+
box.textContent = '';
|
|
1543
|
+
var why = el('input', { type: 'text', maxlength: '500', placeholder: S.takeBackWhy, 'aria-label': S.takeBackWhy });
|
|
1544
|
+
var err = el('div', { class: 'err', role: 'alert' });
|
|
1545
|
+
box.appendChild(el('p', { class: 'small', text: S.takeBackAsk }));
|
|
1546
|
+
box.appendChild(why);
|
|
1547
|
+
box.appendChild(el('div', { class: 'row' }, [
|
|
1548
|
+
el('button', { class: 'link', type: 'button', text: S.keep, onclick: idle }),
|
|
1549
|
+
el('button', { class: 'send', type: 'button', text: S.takeBackYes, onclick: function () {
|
|
1550
|
+
withdrawReport(r.id, why.value.trim()).then(function (b) {
|
|
1551
|
+
state.reports = state.reports.map(function (x) { return x.id === r.id ? b.report : x; });
|
|
1552
|
+
markSeen();
|
|
1553
|
+
renderList();
|
|
1554
|
+
}).catch(function (x) { err.textContent = x.message || S.cantSend; });
|
|
1555
|
+
} }),
|
|
1556
|
+
]));
|
|
1557
|
+
box.appendChild(err);
|
|
1558
|
+
why.focus();
|
|
1559
|
+
}
|
|
1560
|
+
function idle() {
|
|
1561
|
+
box.textContent = '';
|
|
1562
|
+
box.appendChild(el('button', { class: 'link', type: 'button', text: S.takeBack, onclick: ask }));
|
|
1563
|
+
}
|
|
1564
|
+
idle();
|
|
1565
|
+
return box;
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1521
1568
|
// ---- introduction ----------------------------------------------------------------------
|
|
1522
1569
|
|
|
1523
1570
|
// People can't use a button they never noticed. Once per device and app, a bubble says what it
|