Реверснутый zcode с своими фишками и плагинами · VibeGit
Реверснутый zcode с своими фишками и плагинами Реверснутая ade zcode без z ai, с массовой загрузкой ключей, умным апи роутингом, плагином для командной разработки
reversnutyy-zcode-s-svoimi-fishkami-i-plaginami / fork / team / assets / core.js 449 строк · изменён 13 нояб., 21:19
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
import { h } from 'preact' ;
import { useEffect, useState, useRef, useCallback } from 'preact/hooks' ;
import htm from 'htm' ;
export const html = htm. bind ( h) ;
export const svc = {
state : null ,
csrf : '' ,
} ;
export class RpcError extends Error
message
status
body
authListeners
authListeners fn authListeners fn
res
res res res
svc res
svc svc
svc
res
svc
patch
res res
svc
patch svc svc patch svc patch
svc svc patch
uiSaveTimer
uiPending
uiPending uiPending patch
svc svc svc patch
uiSaveTimer
uiSaveTimer
ui svc ui uiPending
uiPending
ui
msg err message err
re ru re msg ru
msg
rpcLog
rpcLog method params
rpcLog rpcLog
res
res
svc
method params
e
data
data res
res data ok
err data error res res data body
res method method method
fn authListeners err
res err
method params
err
data result
r method params
ok ok r ok
r
e
quiet
e
e e
e
value initial
subs
value
next
value next value next
s subs value
subs fn subs fn
v setV store
store
store setV
store
v
cache
e cache key
e
e
cache key e
e
s e e e e
e key
fetcher e fetcher
e e
e e e
e
e
e
data e
e data
e
e
err
e err
e
e
e
e e key
e
e
e
e key
e fn e fn
e
cache key data
key e cache
prefixes key p key p
e e key
e
e cache e e e e
fRef fetcher
fRef fetcher
snap setSnap
e key cache key
e data e error e loading key e data
key
e key
e fRef
e setSnap
e e e e
e e key
e setSnap
key
reload key key key
snap reload
toasts
toastSeq
message kind action timeout
id toastSeq
toasts list id message kind action timeout
id
toasts list t id t t
toasts list t id
role min
s s
p p
name
parts name
parts
parts parts
parts parts
id fallback
fallback fallback
x
ch id x x ch
x
shortId id id
a n
b a
a a many
b b few
b one
many
iso
t iso
t
s now t
fut s
a s
txt
a fut
a m a txt
a hh a txt
a d a d fut txt
iso
fut txt txt
iso
d iso
d
y withYear d
iso
d iso
d
iso status
d iso
today
today
d today
iso
d iso
d
v n
v v
v v v
v v
v
url
url url
text label
text
ta
ta text
ta
ta
ta
ta
ta
label
t
t t a ms
busy setBusy
spin setSpin
t
run
t
t
t
busy spin run
set
i x ms i ms
d a
t a d
s
a
ch d d
ch
ch ch ch
ch
ch ch
ch
ch
ch
d
d
a
{
constructor
(
message, status, body
)
{
super
(
)
;
this
.
status
=
;
this
.
body
=
;
}
}
const
=
new
Set
(
)
;
export
function
onAuthLost
(
fn
)
{
.
add
(
)
;
return
(
)
=>
.
delete
(
)
;
}
export
async
function
loadState
(
)
{
const
=
await
fetch
(
'/state'
,
{
cache
:
'no-store'
}
)
;
if
(
!
.
ok
)
throw
new
RpcError
(
'Сервис недоступен (HTTP '
+
.
status
+
')'
,
.
status
)
;
.
state
=
await
.
json
(
)
;
.
csrf
=
.
state
.
csrfToken
||
''
;
return
.
state
;
}
export
async
function
saveSettings
(
patch
)
{
const
=
await
fetch
(
'/settings'
,
{
method
:
'POST'
,
headers
:
{
'Content-Type'
:
'application/json'
,
'X-ZTeam-CSRF'
:
.
csrf
}
,
body
:
JSON
.
stringify
(
)
,
}
)
;
if
(
!
.
ok
)
throw
new
RpcError
(
'Не удалось сохранить настройки'
,
.
status
)
;
if
(
.
state
)
{
if
(
.
ui
)
.
state
=
{
...
.
state
,
...
,
ui
:
{
...
(
.
state
.
ui
||
{
}
)
,
...
.
ui
}
}
;
else
.
state
=
{
...
.
state
,
...
}
;
}
return
true
;
}
let
=
null
;
let
=
{
}
;
export
function
saveUi
(
patch
)
{
=
{
...
,
...
}
;
if
(
.
state
)
.
state
.
ui
=
{
...
(
.
state
.
ui
||
{
}
)
,
...
}
;
clearTimeout
(
)
;
=
setTimeout
(
(
)
=>
{
const
=
{
...
(
.
state
?.
||
{
}
)
,
...
}
;
=
{
}
;
saveSettings
(
{
}
)
.
catch
(
(
)
=>
{
}
)
;
}
,
400
)
;
}
const
ERR_RU
=
[
[
/ invalid ( email or ) ? password| invalid credentials| wrong password / i
,
'Неверный email или пароль'
]
,
[
/ already ( registered| exists) | email. * taken / i
,
'Этот email уже зарегистрирован'
]
,
[
/ not signed in| unauthorized / i
,
'Требуется вход'
]
,
[
/ forbidden| insufficient| not allowed| permission / i
,
'Недостаточно прав'
]
,
[
/ not found / i
,
'Не найдено'
]
,
[
/ fetch failed| network| ECONNREFUSED| ENOTFOUND / i
,
'Нет связи с сервером'
]
,
[
/ too many| rate limit / i
,
'Слишком много запросов, попробуйте позже'
]
,
[
/ invalid. * code| expired / i
,
'Код недействителен или истёк'
]
,
]
;
export
function
humanError
(
err
)
{
const
=
String
(
?.
||
||
'Ошибка'
)
;
for
(
const
[
,
]
of
ERR_RU
)
if
(
.
test
(
)
)
return
;
return
;
}
export
const
=
[
]
;
export
async
function
rpc
(
method, params = { }
)
{
.
push
(
{
,
,
at
:
Date
.
now
(
)
}
)
;
if
(
.
length
>
400
)
.
shift
(
)
;
let
;
try
{
=
await
fetch
(
'/rpc'
,
{
method
:
'POST'
,
headers
:
{
'Content-Type'
:
'application/json'
,
'X-ZTeam-CSRF'
:
.
csrf
}
,
body
:
JSON
.
stringify
(
{
,
}
)
,
}
)
;
}
catch
(
)
{
throw
new
RpcError
(
'Локальный сервис недоступен'
,
0
)
;
}
let
=
null
;
try
{
=
await
.
json
(
)
;
}
catch
{
}
if
(
!
.
ok
||
?.
===
false
)
{
const
=
new
RpcError
(
?.
||
'HTTP '
+
.
status
,
.
status
,
?.
)
;
if
(
.
status
===
401
&&
!==
'login'
&&
!==
'devicePoll'
&&
!==
'changePassword'
)
{
for
(
const
of
)
fn
(
)
;
}
if
(
.
status
===
403
&&
/ csrf / i
.
test
(
.
message
)
)
{
await
loadState
(
)
.
catch
(
(
)
=>
{
}
)
;
return
rpc
(
,
)
;
}
throw
;
}
return
?.
;
}
export
async
function
act
(
method, params, { ok, quiet } = { }
)
{
try
{
const
=
await
rpc
(
,
)
;
if
(
)
toast
(
typeof
===
'function'
?
ok
(
)
:
,
{
kind
:
'ok'
}
)
;
return
[
,
null
]
;
}
catch
(
)
{
if
(
!
)
{
if
(
.
status
===
403
)
toast
(
'Недостаточно прав'
,
{
kind
:
'err'
}
)
;
else
if
(
.
status
!==
401
)
toast
(
humanError
(
)
,
{
kind
:
'err'
}
)
;
}
return
[
null
,
]
;
}
}
export
function
createStore
(
initial
)
{
let
=
;
const
=
new
Set
(
)
;
return
{
get
:
(
)
=>
,
set
(
)
{
=
typeof
===
'function'
?
next
(
)
:
;
for
(
const
of
)
s
(
)
;
}
,
sub
(
fn
)
{
.
add
(
)
;
return
(
)
=>
.
delete
(
)
;
}
,
}
;
}
export
function
useStore
(
store
)
{
const
[
,
]
=
useState
(
.
get
(
)
)
;
useEffect
(
(
)
=>
{
setV
(
.
get
(
)
)
;
return
.
sub
(
)
;
}
,
[
]
)
;
return
;
}
const
=
new
Map
(
)
;
function
entry
(
key
)
{
let
=
.
get
(
)
;
if
(
!
)
{
=
{
data
:
undefined
,
error
:
null
,
loading
:
false
,
at
:
0
,
fetcher
:
null
,
subs
:
new
Set
(
)
,
promise
:
null
,
stale
:
true
}
;
.
set
(
,
)
;
}
return
;
}
function
emit
(
e
)
{
for
(
const
of
.
subs
)
s
(
{
data
:
.
data
,
error
:
.
error
,
loading
:
.
loading
}
)
;
}
export
function
fetchRes
(
key, fetcher
)
{
const
=
entry
(
)
;
if
(
)
.
fetcher
=
;
if
(
!
.
fetcher
)
return
Promise
.
resolve
(
.
data
)
;
if
(
.
promise
)
{
.
again
=
true
;
return
.
promise
;
}
.
loading
=
true
;
.
stale
=
false
;
emit
(
)
;
const
run
=
async
(
)
=>
{
try
{
const
=
await
.
fetcher
(
)
;
.
data
=
;
.
error
=
null
;
.
at
=
Date
.
now
(
)
;
}
catch
(
)
{
.
error
=
;
}
finally
{
.
loading
=
false
;
.
promise
=
null
;
emit
(
)
;
if
(
.
again
)
{
.
again
=
false
;
fetchRes
(
)
;
}
}
return
.
data
;
}
;
.
promise
=
run
(
)
;
return
.
promise
;
}
export
function
mutateRes
(
key, fn
)
{
const
=
entry
(
)
;
.
data
=
typeof
===
'function'
?
fn
(
.
data
)
:
;
emit
(
)
;
}
export
function
peekRes
(
key
)
{
return
.
get
(
)
?.
;
}
export
function
invalidate
(
... prefixes
)
{
for
(
const
[
,
]
of
)
{
if
(
!
.
some
(
(
p
)
=>
===
||
.
startsWith
(
+
':'
)
)
)
continue
;
if
(
.
subs
.
size
&&
.
fetcher
)
fetchRes
(
)
;
else
.
stale
=
true
;
}
}
export
function
clearCache
(
)
{
for
(
const
[
,
]
of
)
{
.
data
=
undefined
;
.
error
=
null
;
.
stale
=
true
;
emit
(
)
;
}
}
export
function
useRes
(
key, fetcher
)
{
const
=
useRef
(
)
;
.
current
=
;
const
[
,
]
=
useState
(
(
)
=>
{
const
=
?
.
get
(
)
:
null
;
return
{
data
:
?.
,
error
:
?.
??
null
,
loading
:
!
!
?.
||
(
!=
null
&&
?.
===
undefined
)
}
;
}
)
;
useEffect
(
(
)
=>
{
if
(
!
)
{
setSnap
(
{
data
:
undefined
,
error
:
null
,
loading
:
false
}
)
;
return
;
}
const
=
entry
(
)
;
.
fetcher
=
(
)
=>
.
current
(
)
;
.
subs
.
add
(
)
;
setSnap
(
{
data
:
.
data
,
error
:
.
error
,
loading
:
.
loading
||
.
data
===
undefined
}
)
;
if
(
.
stale
||
.
data
===
undefined
)
fetchRes
(
)
;
return
(
)
=>
.
subs
.
delete
(
)
;
}
,
[
]
)
;
const
=
useCallback
(
(
)
=>
(
?
fetchRes
(
)
:
Promise
.
resolve
(
)
)
,
[
]
)
;
return
{
...
,
}
;
}
export
const
=
createStore
(
[
]
)
;
let
=
0
;
export
function
toast
(
,
{
=
'info'
,
,
=
3500
}
=
{
}
)
{
const
=
++
;
.
set
(
(
list
)
=>
[
...
.
slice
(
-
3
)
,
{
,
,
,
,
}
]
)
;
return
;
}
export
function
dismissToast
(
id
)
{
.
set
(
(
list
)
=>
.
map
(
(
t
)
=>
(
.
id
===
?
{
...
,
leaving
:
true
}
:
)
)
)
;
setTimeout
(
(
)
=>
.
set
(
(
list
)
=>
.
filter
(
(
t
)
=>
.
id
!==
)
)
,
180
)
;
}
export
const
ROLE_RANK
=
{
viewer
:
0
,
dev
:
1
,
maintainer
:
2
,
owner
:
3
}
;
export
const
ROLE_RU
=
{
owner
:
'Владелец'
,
maintainer
:
'Мейнтейнер'
,
dev
:
'Разработчик'
,
viewer
:
'Наблюдатель'
}
;
export
const
roleAtLeast
=
(
role, min
)
=>
(
ROLE_RANK
[
]
??
-
1
)
>=
ROLE_RANK
[
]
;
export
const
STATUS_RU
=
{
''
:
'Не задан'
,
online
:
'В сети'
,
away
:
'Отошёл'
,
busy
:
'Занят'
,
dnd
:
'Не беспокоить'
}
;
export
const
TASK_STATUSES
=
[
{
id
:
'todo'
,
label
:
'К выполнению'
}
,
{
id
:
'doing'
,
label
:
'В работе'
}
,
{
id
:
'review'
,
label
:
'Проверка'
}
,
{
id
:
'done'
,
label
:
'Готово'
}
,
]
;
export
const
STATUS_LABEL
=
Object
.
fromEntries
(
TASK_STATUSES
.
map
(
(
s
)
=>
[
.
id
,
.
label
]
)
)
;
export
const
PRIORITIES
=
[
{
id
:
'urgent'
,
label
:
'Срочно'
}
,
{
id
:
'high'
,
label
:
'Высокий'
}
,
{
id
:
'normal'
,
label
:
'Обычный'
}
,
{
id
:
'low'
,
label
:
'Низкий'
}
,
]
;
export
const
PRIORITY_LABEL
=
Object
.
fromEntries
(
PRIORITIES
.
map
(
(
p
)
=>
[
.
id
,
.
label
]
)
)
;
export
const
AVATAR_COLORS
=
[
'#ef4444'
,
'#f97316'
,
'#eab308'
,
'#22c55e'
,
'#14b8a6'
,
'#0ea5e9'
,
'#6366f1'
,
'#a855f7'
,
'#ec4899'
,
'#64748b'
]
;
export
function
initials
(
=
''
)
{
const
=
String
(
)
.
trim
(
)
.
split
(
/ [ \s ._@-] + /
)
.
filter
(
Boolean
)
;
if
(
!
.
length
)
return
'?'
;
if
(
.
length
===
1
)
return
[
0
]
.
slice
(
0
,
2
)
.
toUpperCase
(
)
;
return
(
[
0
]
[
0
]
+
[
1
]
[
0
]
)
.
toUpperCase
(
)
;
}
export
function
colorFor
(
=
''
,
)
{
if
(
)
return
;
let
=
0
;
for
(
const
of
String
(
)
)
=
(
*
31
+
.
charCodeAt
(
0
)
)
>>>
0
;
return
AVATAR_COLORS
[
%
AVATAR_COLORS
.
length
]
;
}
export
const
=
(
=
''
)
=>
String
(
)
.
replace
(
/ - / g
,
''
)
.
slice
(
0
,
8
)
;
export
function
plural
(
n, one, few, many
)
{
const
=
Math
.
abs
(
)
%
100
;
const
=
%
10
;
if
(
>
10
&&
<
20
)
return
;
if
(
>
1
&&
<
5
)
return
;
if
(
===
1
)
return
;
return
;
}
export
function
relTime
(
iso, now = Date . now ( )
)
{
if
(
!
)
return
''
;
const
=
new
Date
(
)
.
getTime
(
)
;
if
(
!
Number
.
isFinite
(
)
)
return
''
;
const
=
Math
.
round
(
(
-
)
/
1000
)
;
const
=
<
0
;
const
=
Math
.
abs
(
)
;
let
;
if
(
<
45
)
return
?
'через минуту'
:
'только что'
;
if
(
<
3600
)
{
const
=
Math
.
max
(
1
,
Math
.
round
(
/
60
)
)
;
=
` ${ m} мин `
;
}
else
if
(
<
86400
)
{
const
=
Math
.
round
(
/
3600
)
;
=
` ${ hh} ч `
;
}
else
if
(
<
86400
*
7
)
{
const
=
Math
.
round
(
/
86400
)
;
if
(
===
1
&&
!
)
return
'вчера'
;
=
` ${ d} ${ plural ( d, 'день' , 'дня' , 'дней' ) } `
;
}
else
return
fmtDate
(
)
;
return
?
'через '
+
:
+
' назад'
;
}
const
MONTHS
=
[
'янв'
,
'фев'
,
'мар'
,
'апр'
,
'мая'
,
'июн'
,
'июл'
,
'авг'
,
'сен'
,
'окт'
,
'ноя'
,
'дек'
]
;
export
function
fmtDate
(
iso, withYear
)
{
if
(
!
)
return
''
;
const
=
new
Date
(
)
;
if
(
!
Number
.
isFinite
(
.
getTime
(
)
)
)
return
''
;
const
=
??
.
getFullYear
(
)
!==
new
Date
(
)
.
getFullYear
(
)
;
return
` ${ d. getDate ( ) } ${ MONTHS [ d. getMonth ( ) ] } ${ y ? ' ' + d. getFullYear ( ) : '' } `
;
}
export
function
fmtDateTime
(
iso
)
{
if
(
!
)
return
''
;
const
=
new
Date
(
)
;
if
(
!
Number
.
isFinite
(
.
getTime
(
)
)
)
return
''
;
return
` ${ fmtDate ( iso) } , ${ String ( d. getHours ( ) ) . padStart ( 2 , '0' ) } : ${ String ( d. getMinutes ( ) ) . padStart ( 2 , '0' ) } `
;
}
export
function
isOverdue
(
iso, status
)
{
if
(
!
||
===
'done'
)
return
false
;
const
=
new
Date
(
)
;
const
=
new
Date
(
)
;
.
setHours
(
0
,
0
,
0
,
0
)
;
return
.
getTime
(
)
<
.
getTime
(
)
;
}
export
function
toDateInput
(
iso
)
{
if
(
!
)
return
''
;
const
=
new
Date
(
)
;
if
(
!
Number
.
isFinite
(
.
getTime
(
)
)
)
return
''
;
return
` ${ d. getFullYear ( ) } - ${ String ( d. getMonth ( ) + 1 ) . padStart ( 2 , '0' ) } - ${ String ( d. getDate ( ) ) . padStart ( 2 , '0' ) } `
;
}
export
function
humanBytes
(
n
)
{
const
=
Number
(
)
||
0
;
if
(
>=
1024
**
3
)
return
(
/
1024
**
3
)
.
toFixed
(
1
)
.
replace
(
'.'
,
','
)
+
' ГБ'
;
if
(
>=
1024
**
2
)
return
(
/
1024
**
2
)
.
toFixed
(
>=
10
*
1024
**
2
?
0
:
1
)
.
replace
(
'.'
,
','
)
+
' МБ'
;
if
(
>=
1024
)
return
Math
.
round
(
/
1024
)
+
' КБ'
;
return
+
' Б'
;
}
export
function
hostOf
(
url
)
{
if
(
!
)
return
''
;
try
{
return
new
URL
(
)
.
host
;
}
catch
{
return
String
(
)
.
replace
(
/ ^ https? :\/ \/ /
,
''
)
.
split
(
'/'
)
[
0
]
;
}
}
export
async
function
copyText
(
,
=
'Скопировано'
)
{
try
{
await
navigator
.
clipboard
.
writeText
(
)
;
}
catch
{
const
=
document
.
createElement
(
'textarea'
)
;
.
value
=
;
.
style
.
position
=
'fixed'
;
.
style
.
opacity
=
'0'
;
document
.
body
.
append
(
)
;
.
select
(
)
;
try
{
document
.
execCommand
(
'copy'
)
;
}
catch
{
}
.
remove
(
)
;
}
toast
(
,
{
kind
:
'ok'
,
timeout
:
2000
}
)
;
}
export
const
reducedMotion
=
(
)
=>
window
.
matchMedia
?.
(
'(prefers-reduced-motion: reduce)'
)
.
matches
;
export
function
debounce
(
fn, ms
)
{
let
;
return
(
... a
)
=>
{
clearTimeout
(
)
;
=
setTimeout
(
(
)
=>
fn
(
...
)
,
)
;
}
;
}
export
function
useBusy
(
)
{
const
[
,
]
=
useState
(
false
)
;
const
[
,
]
=
useState
(
false
)
;
const
=
useRef
(
0
)
;
const
=
useCallback
(
async
(
fn
)
=>
{
setBusy
(
true
)
;
clearTimeout
(
.
current
)
;
.
current
=
setTimeout
(
(
)
=>
setSpin
(
true
)
,
300
)
;
try
{
return
await
fn
(
)
;
}
finally
{
clearTimeout
(
.
current
)
;
setBusy
(
false
)
;
setSpin
(
false
)
;
}
}
,
[
]
)
;
return
[
,
,
]
;
}
export
function
useTick
(
ms = 30000
)
{
const
[
,
]
=
useState
(
0
)
;
useEffect
(
(
)
=>
{
const
=
setInterval
(
(
)
=>
set
(
(
x
)
=>
+
1
)
,
)
;
return
(
)
=>
clearInterval
(
)
;
}
,
[
]
)
;
}
export
function
describeAction
(
a
)
{
const
=
.
details
||
{
}
;
const
=
.
taskTitle
||
.
title
||
''
;
const
q
=
(
s
)
=>
(
?
` « ${ s} » `
:
''
)
;
switch
(
.
action
)
{
case
'task.create'
:
return
` создал(а) задачу ${ q ( t) } `
;
case
'task.update'
:
{
const
=
.
changes
||
;
if
(
.
status
)
return
` перевёл(а) ${ q ( t) } в « ${ STATUS_LABEL [ ch. status ] || ch. status } » `
;
if
(
'assigneeId'
in
||
.
assigneeName
)
return
.
assigneeName
?
` назначил(а) ${ q ( t) } на ${ ch. assigneeName } `
:
` снял(а) исполнителя с ${ q ( t) } `
;
if
(
.
priority
)
return
` изменил(а) приоритет ${ q ( t) } на « ${ PRIORITY_LABEL [ ch. priority ] || ch. priority } » `
;
if
(
'dueAt'
in
)
return
.
dueAt
?
` назначил(а) срок ${ q ( t) } на ${ fmtDate ( ch. dueAt ) } `
:
` убрал(а) срок у ${ q ( t) } `
;
if
(
.
title
)
return
` переименовал(а) задачу в ${ q ( ch. title ) } `
;
if
(
.
labels
)
return
` изменил(а) метки ${ q ( t) } `
;
if
(
'description'
in
)
return
` обновил(а) описание ${ q ( t) } `
;
return
` обновил(а) задачу ${ q ( t) } `
;
}
case
'task.delete'
:
return
` удалил(а) задачу ${ q ( t) } `
;
case
'task.restore'
:
return
` восстановил(а) задачу ${ q ( t) } `
;
case
'task.reorder'
:
return
.
status
?
` переместил(а) задачи в « ${ STATUS_LABEL [ d. status ] || d. status } » `
:
'изменил(а) порядок задач'
;
case
'task.commit_link'
:
return
` привязал(а) коммит ${ String ( d. hash || '' ) . slice ( 0 , 7 ) } к ${ q ( t) } `
;
case
'team.create'
:
return
` создал(а) команду ${ q ( d. name ) } `
;
case
'team.rename'
:
return
` переименовал(а) команду в ${ q ( d. name ) } `
;
case
'invite.create'
:
return
'создал(а) код приглашения'
;
case
'invite.revoke'
:
return
'отозвал(а) приглашение'
;
case
'invite.accept'
:
return
'вступил(а) в команду'
;
case
'member.add'
:
return
` добавил(а) ${ d. displayName || 'участника' } в команду `
;
case
'membership.role'
:
return
` сменил(а) роль ${ d. displayName ? ' ' + d. displayName : '' } на « ${ ROLE_RU [ d. role ] || d. role } » `
;
case
'membership.remove'
:
return
` исключил(а) ${ d. displayName || 'участника' } `
;
case
'membership.leave'
:
return
'покинул(а) команду'
;
case
'member.quota'
:
return
.
dailyRequests
==
null
?
'снял(а) лимит запросов'
:
` установил(а) лимит ${ d. dailyRequests } запросов/день `
;
case
'api_key.create'
:
return
` добавил(а) ключ ${ q ( d. label || d. provider ) } `
;
case
'api_key.update'
:
return
` изменил(а) ключ ${ q ( d. label ) } `
;
case
'api_key.delete'
:
return
` удалил(а) ключ ${ q ( d. label ) } `
;
case
'api_key.disable'
:
return
` отключил(а) ключ ${ q ( d. label ) } `
;
case
'api_key.enable'
:
return
` включил(а) ключ ${ q ( d. label ) } `
;
case
'api_key.reveal'
:
return
` просмотрел(а) ключ ${ q ( d. label ) } `
;
case
'api_key.ping'
:
return
` проверил(а) ключ ${ q ( d. label ) } `
;
case
'api_key.check_all'
:
return
'проверил(а) все ключи'
;
case
'file.upload'
:
return
` отправил(а) файл ${ q ( d. name ) } `
;
case
'file.delete'
:
return
` удалил(а) файл ${ q ( d. name ) } `
;
case
'archive.upload'
:
return
` загрузил(а) архив ${ q ( d. projectName || d. name ) } `
;
case
'archive.delete'
:
return
'удалил(а) архив'
;
case
'project.create'
:
return
` создал(а) проект ${ q ( d. name ) } `
;
case
'proxy_token.create'
:
return
'выпустил(а) токен доступа'
;
case
'proxy_token.revoke'
:
return
'отозвал(а) токен доступа'
;
case
'activity.delete'
:
return
'удалил(а) событие ленты'
;
default
:
return
.
action
;
}
}