@burdenoff/microfe-timecampus 2026.1102.2 → 2026.1107.1
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/dist/generated/global-types.d.ts +713 -244
- package/dist/generated/global-types.d.ts.map +1 -1
- package/dist/generated/wspace-operations.d.ts +300 -0
- package/dist/generated/wspace-operations.d.ts.map +1 -1
- package/dist/generated/wspace-operations.js +1035 -903
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +17396 -467
- package/dist/generated/wspace-types.d.ts.map +1 -1
- package/dist/generated/wspace-types.js +5 -1
- package/dist/generated/wspace-types.js.map +1 -1
- package/dist/index.js +7 -7
- package/dist/timecampus/TimeCampusRoutes.d.ts.map +1 -1
- package/dist/timecampus/TimeCampusRoutes.js +10 -6
- package/dist/timecampus/TimeCampusRoutes.js.map +1 -1
- package/dist/timecampus/index.js +7 -7
- package/dist/timecampus/pages/extend/TimeTriggersPage.d.ts +2 -0
- package/dist/timecampus/pages/extend/TimeTriggersPage.d.ts.map +1 -0
- package/dist/timecampus/pages/extend/TimeTriggersPage.js +606 -0
- package/dist/timecampus/pages/extend/TimeTriggersPage.js.map +1 -0
- package/dist/timecampus/pages/extend/extendHelpers.d.ts.map +1 -1
- package/dist/timecampus/pages/extend/extendHelpers.js +43 -42
- package/dist/timecampus/pages/extend/extendHelpers.js.map +1 -1
- package/dist/timecampus/pages/extend/triggerHelpers.d.ts +50 -0
- package/dist/timecampus/pages/extend/triggerHelpers.d.ts.map +1 -0
- package/dist/timecampus/pages/extend/triggerHelpers.js +114 -0
- package/dist/timecampus/pages/extend/triggerHelpers.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,606 @@
|
|
|
1
|
+
import { useTimeCampus as e } from "../../providers/TimeCampusProvider.js";
|
|
2
|
+
import { formatDate as t } from "../../utils/helpers.js";
|
|
3
|
+
import { LoadingSkeleton as n } from "../../components/LoadingSkeleton.js";
|
|
4
|
+
import { EmptyState as r } from "../../components/EmptyState.js";
|
|
5
|
+
import { ListMyTimeTriggersDocument as i, useCreateTimeTriggerMutation as a, useDeleteTimeTriggerMutation as o, useListMyTimeTriggersQuery as s, useRunTimeTriggerMutation as ee, useUpdateTimeTriggerMutation as te } from "../../../generated/wspace-operations.js";
|
|
6
|
+
import { PageLayout as ne } from "../../components/PageLayout.js";
|
|
7
|
+
import { StatusBadge as c } from "../../components/StatusBadge.js";
|
|
8
|
+
import { Modal as l } from "../../components/Modal.js";
|
|
9
|
+
import { ToastContainer as u, useToast as d } from "../../components/Toast.js";
|
|
10
|
+
import { ToggleSwitch as f } from "../../components/ToggleSwitch.js";
|
|
11
|
+
import { TimeCampusTriggerComparator as p, TimeCampusTriggerMetric as m } from "../../../generated/wspace-types.js";
|
|
12
|
+
import { useOpenRoute as re } from "./useOpenRoute.js";
|
|
13
|
+
import { TRIGGER_METRIC_KEYS as h, TRIGGER_PRESETS as ie, browserTimezone as g, describeRule as _, formatHour as v, formatMetric as y, isTriggerComparatorKey as b, isTriggerMetricKey as x, metricMeta as S, validateTriggerForm as ae } from "./triggerHelpers.js";
|
|
14
|
+
import { useMemo as C, useState as w } from "react";
|
|
15
|
+
import { BellRing as T, Pencil as E, Play as D, Plus as O, Store as oe, Trash2 as k, Workflow as se } from "lucide-react";
|
|
16
|
+
import { jsx as A, jsxs as j } from "react/jsx-runtime";
|
|
17
|
+
import { GlassCard as M } from "@burdenoff/fe-libs/ui";
|
|
18
|
+
//#region src/timecampus/pages/extend/TimeTriggersPage.tsx
|
|
19
|
+
var N = [{ query: i }], P = "inline-flex items-center justify-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-1.5 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-50", F = "inline-flex items-center justify-center gap-1.5 rounded-md border border-border-subtle bg-bg-surface px-3 py-1.5 text-sm font-medium text-text-primary hover:bg-bg-surface-hover disabled:opacity-50", I = "w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-1.5 text-sm text-text-primary", L = Array.from({ length: 24 }, (e, t) => t), ce = {
|
|
20
|
+
TRACKED_HOURS: m.TrackedHours,
|
|
21
|
+
FOCUS_PERCENT: m.FocusPercent,
|
|
22
|
+
CONTEXT_SWITCHES: m.ContextSwitches,
|
|
23
|
+
LONGEST_FOCUS_MINUTES: m.LongestFocusMinutes
|
|
24
|
+
}, le = {
|
|
25
|
+
BELOW: p.Below,
|
|
26
|
+
ABOVE: p.Above
|
|
27
|
+
}, R = {
|
|
28
|
+
name: "",
|
|
29
|
+
metric: "TRACKED_HOURS",
|
|
30
|
+
comparator: "BELOW",
|
|
31
|
+
threshold: "6",
|
|
32
|
+
checkHour: 17,
|
|
33
|
+
message: ""
|
|
34
|
+
};
|
|
35
|
+
function z(e) {
|
|
36
|
+
return e instanceof Error && e.message ? e.message : "Something went wrong";
|
|
37
|
+
}
|
|
38
|
+
function B(e) {
|
|
39
|
+
let { metric: t, comparator: n } = e;
|
|
40
|
+
return !x(t) || !b(n) ? null : {
|
|
41
|
+
name: e.name,
|
|
42
|
+
metric: t,
|
|
43
|
+
comparator: n,
|
|
44
|
+
threshold: String(e.threshold),
|
|
45
|
+
checkHour: e.checkHour,
|
|
46
|
+
message: e.message ?? ""
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function V({ form: e, onChange: t }) {
|
|
50
|
+
let n = S(e.metric);
|
|
51
|
+
return /* @__PURE__ */ j("div", {
|
|
52
|
+
className: "flex flex-col gap-4",
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ j("label", {
|
|
55
|
+
className: "flex flex-col gap-1 text-sm",
|
|
56
|
+
children: [/* @__PURE__ */ A("span", {
|
|
57
|
+
className: "font-medium text-text-primary",
|
|
58
|
+
children: "Name"
|
|
59
|
+
}), /* @__PURE__ */ A("input", {
|
|
60
|
+
className: I,
|
|
61
|
+
value: e.name,
|
|
62
|
+
maxLength: 80,
|
|
63
|
+
onChange: (n) => t({
|
|
64
|
+
...e,
|
|
65
|
+
name: n.target.value
|
|
66
|
+
}),
|
|
67
|
+
placeholder: "Short day",
|
|
68
|
+
"aria-label": "Trigger name"
|
|
69
|
+
})]
|
|
70
|
+
}),
|
|
71
|
+
/* @__PURE__ */ j("div", {
|
|
72
|
+
className: "grid grid-cols-1 gap-3 sm:grid-cols-3",
|
|
73
|
+
children: [
|
|
74
|
+
/* @__PURE__ */ j("label", {
|
|
75
|
+
className: "flex flex-col gap-1 text-sm sm:col-span-1",
|
|
76
|
+
children: [/* @__PURE__ */ A("span", {
|
|
77
|
+
className: "font-medium text-text-primary",
|
|
78
|
+
children: "When"
|
|
79
|
+
}), /* @__PURE__ */ A("select", {
|
|
80
|
+
className: I,
|
|
81
|
+
value: e.metric,
|
|
82
|
+
"aria-label": "Metric",
|
|
83
|
+
onChange: (n) => t({
|
|
84
|
+
...e,
|
|
85
|
+
metric: n.target.value
|
|
86
|
+
}),
|
|
87
|
+
children: h.map((e) => /* @__PURE__ */ A("option", {
|
|
88
|
+
value: e,
|
|
89
|
+
children: S(e).label
|
|
90
|
+
}, e))
|
|
91
|
+
})]
|
|
92
|
+
}),
|
|
93
|
+
/* @__PURE__ */ j("label", {
|
|
94
|
+
className: "flex flex-col gap-1 text-sm",
|
|
95
|
+
children: [/* @__PURE__ */ A("span", {
|
|
96
|
+
className: "font-medium text-text-primary",
|
|
97
|
+
children: "is"
|
|
98
|
+
}), /* @__PURE__ */ j("select", {
|
|
99
|
+
className: I,
|
|
100
|
+
value: e.comparator,
|
|
101
|
+
"aria-label": "Comparator",
|
|
102
|
+
onChange: (n) => t({
|
|
103
|
+
...e,
|
|
104
|
+
comparator: n.target.value
|
|
105
|
+
}),
|
|
106
|
+
children: [/* @__PURE__ */ A("option", {
|
|
107
|
+
value: "BELOW",
|
|
108
|
+
children: "below"
|
|
109
|
+
}), /* @__PURE__ */ A("option", {
|
|
110
|
+
value: "ABOVE",
|
|
111
|
+
children: "above"
|
|
112
|
+
})]
|
|
113
|
+
})]
|
|
114
|
+
}),
|
|
115
|
+
/* @__PURE__ */ j("label", {
|
|
116
|
+
className: "flex flex-col gap-1 text-sm",
|
|
117
|
+
children: [/* @__PURE__ */ j("span", {
|
|
118
|
+
className: "font-medium text-text-primary",
|
|
119
|
+
children: ["Threshold", n.unit ? ` (${n.unit})` : ""]
|
|
120
|
+
}), /* @__PURE__ */ A("input", {
|
|
121
|
+
className: I,
|
|
122
|
+
type: "number",
|
|
123
|
+
min: 0,
|
|
124
|
+
max: n.max,
|
|
125
|
+
step: n.step,
|
|
126
|
+
value: e.threshold,
|
|
127
|
+
"aria-label": "Threshold",
|
|
128
|
+
onChange: (n) => t({
|
|
129
|
+
...e,
|
|
130
|
+
threshold: n.target.value
|
|
131
|
+
})
|
|
132
|
+
})]
|
|
133
|
+
})
|
|
134
|
+
]
|
|
135
|
+
}),
|
|
136
|
+
/* @__PURE__ */ A("p", {
|
|
137
|
+
className: "text-xs text-text-tertiary",
|
|
138
|
+
children: n.hint
|
|
139
|
+
}),
|
|
140
|
+
/* @__PURE__ */ j("label", {
|
|
141
|
+
className: "flex flex-col gap-1 text-sm",
|
|
142
|
+
children: [
|
|
143
|
+
/* @__PURE__ */ A("span", {
|
|
144
|
+
className: "font-medium text-text-primary",
|
|
145
|
+
children: "Check from"
|
|
146
|
+
}),
|
|
147
|
+
/* @__PURE__ */ A("select", {
|
|
148
|
+
className: I,
|
|
149
|
+
value: e.checkHour,
|
|
150
|
+
"aria-label": "Check from",
|
|
151
|
+
onChange: (n) => t({
|
|
152
|
+
...e,
|
|
153
|
+
checkHour: Number(n.target.value)
|
|
154
|
+
}),
|
|
155
|
+
children: L.map((e) => /* @__PURE__ */ A("option", {
|
|
156
|
+
value: e,
|
|
157
|
+
children: e === 0 ? "Any time of day" : `${v(e)} onwards`
|
|
158
|
+
}, e))
|
|
159
|
+
}),
|
|
160
|
+
/* @__PURE__ */ j("span", {
|
|
161
|
+
className: "text-xs text-text-tertiary",
|
|
162
|
+
children: [
|
|
163
|
+
"Your day runs in ",
|
|
164
|
+
g(),
|
|
165
|
+
". Rules about falling short (for example below 6 h) work best with a late check hour."
|
|
166
|
+
]
|
|
167
|
+
})
|
|
168
|
+
]
|
|
169
|
+
}),
|
|
170
|
+
/* @__PURE__ */ j("label", {
|
|
171
|
+
className: "flex flex-col gap-1 text-sm",
|
|
172
|
+
children: [/* @__PURE__ */ A("span", {
|
|
173
|
+
className: "font-medium text-text-primary",
|
|
174
|
+
children: "Note in the nudge (optional)"
|
|
175
|
+
}), /* @__PURE__ */ A("textarea", {
|
|
176
|
+
className: I,
|
|
177
|
+
rows: 2,
|
|
178
|
+
maxLength: 280,
|
|
179
|
+
value: e.message,
|
|
180
|
+
"aria-label": "Nudge note",
|
|
181
|
+
onChange: (n) => t({
|
|
182
|
+
...e,
|
|
183
|
+
message: n.target.value
|
|
184
|
+
}),
|
|
185
|
+
placeholder: "Log anything you missed before you wrap up."
|
|
186
|
+
})]
|
|
187
|
+
}),
|
|
188
|
+
/* @__PURE__ */ j("p", {
|
|
189
|
+
className: "rounded-md bg-bg-sunken px-3 py-2 text-sm text-text-secondary",
|
|
190
|
+
children: [_({
|
|
191
|
+
metric: e.metric,
|
|
192
|
+
comparator: e.comparator,
|
|
193
|
+
threshold: Number(e.threshold) || 0,
|
|
194
|
+
checkHour: e.checkHour
|
|
195
|
+
}), ", nudge me (at most once a day)."]
|
|
196
|
+
})
|
|
197
|
+
]
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
function H({ trigger: e, busy: n, onToggle: r, onRun: i, onEdit: a, onDelete: o }) {
|
|
201
|
+
return /* @__PURE__ */ j(M, {
|
|
202
|
+
treatment: "glass",
|
|
203
|
+
className: "flex h-full flex-col gap-3 p-5",
|
|
204
|
+
"data-testid": `time-trigger-${e.id}`,
|
|
205
|
+
children: [
|
|
206
|
+
/* @__PURE__ */ j("div", {
|
|
207
|
+
className: "flex items-start gap-3",
|
|
208
|
+
children: [
|
|
209
|
+
/* @__PURE__ */ A("div", {
|
|
210
|
+
className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-action-primary-bg/10 text-primary",
|
|
211
|
+
children: /* @__PURE__ */ A(T, {
|
|
212
|
+
className: "h-5 w-5",
|
|
213
|
+
"aria-hidden": "true"
|
|
214
|
+
})
|
|
215
|
+
}),
|
|
216
|
+
/* @__PURE__ */ j("div", {
|
|
217
|
+
className: "min-w-0 flex-1",
|
|
218
|
+
children: [/* @__PURE__ */ A("h3", {
|
|
219
|
+
className: "truncate text-base font-semibold text-text-primary",
|
|
220
|
+
children: e.name
|
|
221
|
+
}), /* @__PURE__ */ A("p", {
|
|
222
|
+
className: "text-sm text-text-secondary",
|
|
223
|
+
children: _(e)
|
|
224
|
+
})]
|
|
225
|
+
}),
|
|
226
|
+
/* @__PURE__ */ A(f, {
|
|
227
|
+
checked: e.enabled,
|
|
228
|
+
disabled: n,
|
|
229
|
+
onChange: r,
|
|
230
|
+
ariaLabel: `${e.enabled ? "Pause" : "Enable"} ${e.name}`
|
|
231
|
+
})
|
|
232
|
+
]
|
|
233
|
+
}),
|
|
234
|
+
e.message && /* @__PURE__ */ j("p", {
|
|
235
|
+
className: "text-sm italic text-text-tertiary",
|
|
236
|
+
children: [
|
|
237
|
+
"“",
|
|
238
|
+
e.message,
|
|
239
|
+
"”"
|
|
240
|
+
]
|
|
241
|
+
}),
|
|
242
|
+
/* @__PURE__ */ j("dl", {
|
|
243
|
+
className: "grid grid-cols-2 gap-2 text-xs text-text-tertiary",
|
|
244
|
+
children: [/* @__PURE__ */ j("div", { children: [/* @__PURE__ */ A("dt", { children: "Today so far" }), /* @__PURE__ */ A("dd", {
|
|
245
|
+
className: "text-sm font-medium text-text-primary",
|
|
246
|
+
children: e.lastValue == null ? "Not checked yet" : y(e.metric, e.lastValue)
|
|
247
|
+
})] }), /* @__PURE__ */ j("div", { children: [/* @__PURE__ */ A("dt", { children: "Last fired" }), /* @__PURE__ */ j("dd", {
|
|
248
|
+
className: "text-sm font-medium text-text-primary",
|
|
249
|
+
children: [e.lastFiredAt ? t(e.lastFiredAt) : "Never", e.fireCount > 0 ? ` · ${e.fireCount}×` : ""]
|
|
250
|
+
})] })]
|
|
251
|
+
}),
|
|
252
|
+
/* @__PURE__ */ j("div", {
|
|
253
|
+
className: "mt-auto flex flex-wrap gap-2",
|
|
254
|
+
children: [
|
|
255
|
+
/* @__PURE__ */ j("button", {
|
|
256
|
+
type: "button",
|
|
257
|
+
className: P,
|
|
258
|
+
onClick: i,
|
|
259
|
+
disabled: n,
|
|
260
|
+
"aria-label": `Check ${e.name} now`,
|
|
261
|
+
children: [/* @__PURE__ */ A(D, {
|
|
262
|
+
className: "h-4 w-4",
|
|
263
|
+
"aria-hidden": "true"
|
|
264
|
+
}), "Check now"]
|
|
265
|
+
}),
|
|
266
|
+
/* @__PURE__ */ j("button", {
|
|
267
|
+
type: "button",
|
|
268
|
+
className: F,
|
|
269
|
+
onClick: a,
|
|
270
|
+
disabled: n,
|
|
271
|
+
"aria-label": `Edit ${e.name}`,
|
|
272
|
+
children: [/* @__PURE__ */ A(E, {
|
|
273
|
+
className: "h-4 w-4",
|
|
274
|
+
"aria-hidden": "true"
|
|
275
|
+
}), "Edit"]
|
|
276
|
+
}),
|
|
277
|
+
/* @__PURE__ */ j("button", {
|
|
278
|
+
type: "button",
|
|
279
|
+
className: F,
|
|
280
|
+
onClick: o,
|
|
281
|
+
disabled: n,
|
|
282
|
+
"aria-label": `Delete ${e.name}`,
|
|
283
|
+
children: [/* @__PURE__ */ A(k, {
|
|
284
|
+
className: "h-4 w-4",
|
|
285
|
+
"aria-hidden": "true"
|
|
286
|
+
}), "Delete"]
|
|
287
|
+
})
|
|
288
|
+
]
|
|
289
|
+
})
|
|
290
|
+
]
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
function U() {
|
|
294
|
+
let { workspaceId: t = "" } = e(), { toasts: i, addToast: f, dismissToast: p } = d(), m = re(), [h, v] = w(null), [b, x] = w(!1), [S, T] = w(R), [E, D] = w(null), [M, I] = w(/* @__PURE__ */ new Set()), [L, U] = w(null), [W, G] = w(!1), { data: K, loading: ue, error: q } = s({ skip: !t }), [de] = a({ refetchQueries: N }), [J] = te({ refetchQueries: N }), [fe] = o({ refetchQueries: N }), [pe] = ee({ refetchQueries: N }), Y = C(() => K?.timeCampusMyTimeTriggers ?? [], [K]), X = K?.timeCampusMyTimeTriggerFirings ?? [], me = C(() => new Map(Y.map((e) => [e.id, e.name])), [Y]), Z = K?.timeCampusApplet.installed ?? !1, Q = (e) => {
|
|
295
|
+
v(null), T(e ?? R), D(null), x(!0);
|
|
296
|
+
}, he = (e) => {
|
|
297
|
+
let t = B(e);
|
|
298
|
+
if (!t) {
|
|
299
|
+
f({
|
|
300
|
+
title: `${e.name} cannot be edited here`,
|
|
301
|
+
description: "It uses a rule this version of TimeCampus does not support yet. Reload the page to get the latest version.",
|
|
302
|
+
variant: "error"
|
|
303
|
+
});
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
v(e), T(t), D(null), x(!0);
|
|
307
|
+
}, ge = async () => {
|
|
308
|
+
let e = ae(S);
|
|
309
|
+
if (e) {
|
|
310
|
+
D(e);
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
G(!0);
|
|
314
|
+
let t = {
|
|
315
|
+
name: S.name.trim(),
|
|
316
|
+
metric: ce[S.metric],
|
|
317
|
+
comparator: le[S.comparator],
|
|
318
|
+
threshold: Number(S.threshold),
|
|
319
|
+
checkHour: S.checkHour,
|
|
320
|
+
timezone: g(),
|
|
321
|
+
message: S.message.trim()
|
|
322
|
+
};
|
|
323
|
+
try {
|
|
324
|
+
h ? (await J({ variables: {
|
|
325
|
+
id: h.id,
|
|
326
|
+
input: t
|
|
327
|
+
} }), f({
|
|
328
|
+
title: `${t.name} saved`,
|
|
329
|
+
variant: "success"
|
|
330
|
+
})) : (await de({ variables: { input: {
|
|
331
|
+
...t,
|
|
332
|
+
message: t.message || null
|
|
333
|
+
} } }), f({
|
|
334
|
+
title: `${t.name} created`,
|
|
335
|
+
variant: "success"
|
|
336
|
+
})), x(!1);
|
|
337
|
+
} catch (e) {
|
|
338
|
+
D(z(e));
|
|
339
|
+
} finally {
|
|
340
|
+
G(!1);
|
|
341
|
+
}
|
|
342
|
+
}, $ = async (e, t) => {
|
|
343
|
+
if (!M.has(e)) {
|
|
344
|
+
I((t) => new Set(t).add(e));
|
|
345
|
+
try {
|
|
346
|
+
await t();
|
|
347
|
+
} catch (e) {
|
|
348
|
+
f({
|
|
349
|
+
title: z(e),
|
|
350
|
+
variant: "error"
|
|
351
|
+
});
|
|
352
|
+
} finally {
|
|
353
|
+
I((t) => {
|
|
354
|
+
let n = new Set(t);
|
|
355
|
+
return n.delete(e), n;
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}, _e = (e, t) => $(e.id, async () => {
|
|
360
|
+
await J({ variables: {
|
|
361
|
+
id: e.id,
|
|
362
|
+
input: { enabled: t }
|
|
363
|
+
} }), f({
|
|
364
|
+
title: `${e.name} ${t ? "enabled" : "paused"}`,
|
|
365
|
+
variant: "success"
|
|
366
|
+
});
|
|
367
|
+
}), ve = (e) => $(e.id, async () => {
|
|
368
|
+
let t = (await pe({ variables: { id: e.id } })).data?.runTimeCampusTimeTrigger;
|
|
369
|
+
if (!t) return;
|
|
370
|
+
let n = y(e.metric, t.value);
|
|
371
|
+
t.fired ? f({
|
|
372
|
+
title: `${e.name} fired`,
|
|
373
|
+
description: `Today is at ${n}. ${t.notified ? "A nudge is on its way." : "The nudge could not be delivered."}`,
|
|
374
|
+
variant: "success"
|
|
375
|
+
}) : t.alreadyFiredToday ? f({
|
|
376
|
+
title: `${e.name} already fired today`,
|
|
377
|
+
description: `Today is at ${n}. It fires at most once a day.`,
|
|
378
|
+
variant: "info"
|
|
379
|
+
}) : t.insufficientData ? f({
|
|
380
|
+
title: "Not enough tracked yet",
|
|
381
|
+
description: "Focus share is checked once 30 minutes are tracked today.",
|
|
382
|
+
variant: "info"
|
|
383
|
+
}) : f({
|
|
384
|
+
title: `${e.name} did not fire`,
|
|
385
|
+
description: `Today is at ${n}, so the condition does not hold.`,
|
|
386
|
+
variant: "info"
|
|
387
|
+
});
|
|
388
|
+
}), ye = (e) => (U(null), $(e.id, async () => {
|
|
389
|
+
await fe({ variables: { id: e.id } }), f({
|
|
390
|
+
title: `${e.name} deleted`,
|
|
391
|
+
variant: "success"
|
|
392
|
+
});
|
|
393
|
+
}));
|
|
394
|
+
return /* @__PURE__ */ j(ne, {
|
|
395
|
+
title: "Time Triggers",
|
|
396
|
+
description: "Nudges from your own time data",
|
|
397
|
+
purpose: "Write a rule over today's tracked time, focus or context switches. TimeCampus checks it through the day and nudges you once when it holds. Each firing is also published to FluidGrids, so a workflow can take it further.",
|
|
398
|
+
actions: Z ? /* @__PURE__ */ j("button", {
|
|
399
|
+
type: "button",
|
|
400
|
+
className: P,
|
|
401
|
+
onClick: () => Q(),
|
|
402
|
+
children: [/* @__PURE__ */ A(O, {
|
|
403
|
+
className: "h-4 w-4",
|
|
404
|
+
"aria-hidden": "true"
|
|
405
|
+
}), "New trigger"]
|
|
406
|
+
}) : void 0,
|
|
407
|
+
children: [
|
|
408
|
+
/* @__PURE__ */ A(u, {
|
|
409
|
+
toasts: i,
|
|
410
|
+
onDismiss: p
|
|
411
|
+
}),
|
|
412
|
+
ue && !K ? /* @__PURE__ */ A(n, {
|
|
413
|
+
variant: "card",
|
|
414
|
+
count: 3
|
|
415
|
+
}) : q ? /* @__PURE__ */ A(r, {
|
|
416
|
+
title: "Couldn't load your time triggers",
|
|
417
|
+
description: q.message,
|
|
418
|
+
illustration: "error-state"
|
|
419
|
+
}) : Z ? Y.length === 0 ? /* @__PURE__ */ j("div", {
|
|
420
|
+
className: "flex flex-col gap-4",
|
|
421
|
+
children: [/* @__PURE__ */ A(r, {
|
|
422
|
+
title: "No time triggers yet",
|
|
423
|
+
description: "Start from one of these, or write your own.",
|
|
424
|
+
action: /* @__PURE__ */ j("button", {
|
|
425
|
+
type: "button",
|
|
426
|
+
className: P,
|
|
427
|
+
onClick: () => Q(),
|
|
428
|
+
children: [/* @__PURE__ */ A(O, {
|
|
429
|
+
className: "h-4 w-4",
|
|
430
|
+
"aria-hidden": "true"
|
|
431
|
+
}), "New trigger"]
|
|
432
|
+
})
|
|
433
|
+
}), /* @__PURE__ */ A("div", {
|
|
434
|
+
className: "grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-4",
|
|
435
|
+
children: ie.map((e) => /* @__PURE__ */ j("button", {
|
|
436
|
+
type: "button",
|
|
437
|
+
onClick: () => Q(e),
|
|
438
|
+
className: "rounded-lg border border-border-subtle bg-bg-surface p-4 text-left hover:bg-bg-surface-hover",
|
|
439
|
+
children: [/* @__PURE__ */ A("p", {
|
|
440
|
+
className: "font-medium text-text-primary",
|
|
441
|
+
children: e.name
|
|
442
|
+
}), /* @__PURE__ */ A("p", {
|
|
443
|
+
className: "mt-1 text-sm text-text-secondary",
|
|
444
|
+
children: _({
|
|
445
|
+
...e,
|
|
446
|
+
threshold: Number(e.threshold)
|
|
447
|
+
})
|
|
448
|
+
})]
|
|
449
|
+
}, e.name))
|
|
450
|
+
})]
|
|
451
|
+
}) : /* @__PURE__ */ A("div", {
|
|
452
|
+
className: "grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-3",
|
|
453
|
+
children: Y.map((e) => /* @__PURE__ */ A(H, {
|
|
454
|
+
trigger: e,
|
|
455
|
+
busy: M.has(e.id),
|
|
456
|
+
onToggle: (t) => _e(e, t),
|
|
457
|
+
onRun: () => ve(e),
|
|
458
|
+
onEdit: () => he(e),
|
|
459
|
+
onDelete: () => U(e)
|
|
460
|
+
}, e.id))
|
|
461
|
+
}) : /* @__PURE__ */ A(r, {
|
|
462
|
+
title: "Install the Time Triggers applet",
|
|
463
|
+
description: "Time triggers are an applet. A workspace admin can install it from the applet store; your triggers start running as soon as it is installed.",
|
|
464
|
+
action: /* @__PURE__ */ j("button", {
|
|
465
|
+
type: "button",
|
|
466
|
+
className: P,
|
|
467
|
+
onClick: () => m("/timecampus/applets"),
|
|
468
|
+
children: [/* @__PURE__ */ A(oe, {
|
|
469
|
+
className: "h-4 w-4",
|
|
470
|
+
"aria-hidden": "true"
|
|
471
|
+
}), "Open the applet store"]
|
|
472
|
+
})
|
|
473
|
+
}),
|
|
474
|
+
Z && /* @__PURE__ */ j("section", {
|
|
475
|
+
className: "mt-8",
|
|
476
|
+
"aria-labelledby": "trigger-history-heading",
|
|
477
|
+
children: [/* @__PURE__ */ j("div", {
|
|
478
|
+
className: "mb-3 flex flex-wrap items-center justify-between gap-2",
|
|
479
|
+
children: [/* @__PURE__ */ A("h2", {
|
|
480
|
+
id: "trigger-history-heading",
|
|
481
|
+
className: "text-base font-semibold text-text-primary",
|
|
482
|
+
children: "Recent firings"
|
|
483
|
+
}), /* @__PURE__ */ j("button", {
|
|
484
|
+
type: "button",
|
|
485
|
+
className: F,
|
|
486
|
+
onClick: () => m("/workflows/list"),
|
|
487
|
+
children: [/* @__PURE__ */ A(se, {
|
|
488
|
+
className: "h-4 w-4",
|
|
489
|
+
"aria-hidden": "true"
|
|
490
|
+
}), "Automate with FluidGrids"]
|
|
491
|
+
})]
|
|
492
|
+
}), X.length === 0 ? /* @__PURE__ */ A("p", {
|
|
493
|
+
className: "text-sm text-text-tertiary",
|
|
494
|
+
children: "Nothing has fired yet."
|
|
495
|
+
}) : /* @__PURE__ */ A("ul", {
|
|
496
|
+
className: "divide-y divide-border-subtle rounded-lg border border-border-subtle bg-bg-surface",
|
|
497
|
+
children: X.map((e) => /* @__PURE__ */ j("li", {
|
|
498
|
+
className: "flex flex-wrap items-center justify-between gap-2 px-4 py-3 text-sm",
|
|
499
|
+
children: [
|
|
500
|
+
/* @__PURE__ */ A("span", {
|
|
501
|
+
className: "font-medium text-text-primary",
|
|
502
|
+
children: me.get(e.triggerId) ?? "Deleted trigger"
|
|
503
|
+
}),
|
|
504
|
+
/* @__PURE__ */ j("span", {
|
|
505
|
+
className: "text-text-secondary",
|
|
506
|
+
children: [
|
|
507
|
+
y(e.metric, e.value),
|
|
508
|
+
" (",
|
|
509
|
+
e.comparator === "BELOW" ? "below" : "above",
|
|
510
|
+
" ",
|
|
511
|
+
y(e.metric, e.threshold),
|
|
512
|
+
")"
|
|
513
|
+
]
|
|
514
|
+
}),
|
|
515
|
+
/* @__PURE__ */ j("span", {
|
|
516
|
+
className: "flex items-center gap-2 text-text-tertiary",
|
|
517
|
+
children: [
|
|
518
|
+
e.day,
|
|
519
|
+
/* @__PURE__ */ A(c, {
|
|
520
|
+
label: e.source === "MANUAL" ? "Manual" : "Scheduled",
|
|
521
|
+
variant: "info"
|
|
522
|
+
}),
|
|
523
|
+
!e.notified && /* @__PURE__ */ A(c, {
|
|
524
|
+
label: "Not delivered",
|
|
525
|
+
variant: "warning"
|
|
526
|
+
})
|
|
527
|
+
]
|
|
528
|
+
})
|
|
529
|
+
]
|
|
530
|
+
}, e.id))
|
|
531
|
+
})]
|
|
532
|
+
}),
|
|
533
|
+
/* @__PURE__ */ j(l, {
|
|
534
|
+
open: b,
|
|
535
|
+
onClose: () => x(!1),
|
|
536
|
+
title: h ? `Edit ${h.name}` : "New time trigger",
|
|
537
|
+
description: "Fires at most once a day, from the hour you choose.",
|
|
538
|
+
size: "lg",
|
|
539
|
+
footer: /* @__PURE__ */ j("div", {
|
|
540
|
+
className: "flex justify-end gap-2",
|
|
541
|
+
children: [/* @__PURE__ */ A("button", {
|
|
542
|
+
type: "button",
|
|
543
|
+
className: F,
|
|
544
|
+
onClick: () => x(!1),
|
|
545
|
+
children: "Cancel"
|
|
546
|
+
}), /* @__PURE__ */ A("button", {
|
|
547
|
+
type: "button",
|
|
548
|
+
className: P,
|
|
549
|
+
onClick: () => void ge(),
|
|
550
|
+
disabled: W,
|
|
551
|
+
children: W ? "Saving…" : h ? "Save" : "Create trigger"
|
|
552
|
+
})]
|
|
553
|
+
}),
|
|
554
|
+
children: [/* @__PURE__ */ A(V, {
|
|
555
|
+
form: S,
|
|
556
|
+
onChange: T
|
|
557
|
+
}), E && /* @__PURE__ */ A("p", {
|
|
558
|
+
role: "alert",
|
|
559
|
+
className: "mt-3 text-sm text-status-error-text",
|
|
560
|
+
children: E
|
|
561
|
+
})]
|
|
562
|
+
}),
|
|
563
|
+
/* @__PURE__ */ A(l, {
|
|
564
|
+
open: L !== null,
|
|
565
|
+
onClose: () => U(null),
|
|
566
|
+
title: "Delete time trigger",
|
|
567
|
+
description: "This cannot be undone.",
|
|
568
|
+
footer: /* @__PURE__ */ j("div", {
|
|
569
|
+
className: "flex justify-end gap-2",
|
|
570
|
+
children: [/* @__PURE__ */ A("button", {
|
|
571
|
+
type: "button",
|
|
572
|
+
className: F,
|
|
573
|
+
onClick: () => U(null),
|
|
574
|
+
children: "Cancel"
|
|
575
|
+
}), /* @__PURE__ */ j("button", {
|
|
576
|
+
type: "button",
|
|
577
|
+
className: "inline-flex items-center justify-center gap-1.5 rounded-md bg-status-error-bg px-3 py-1.5 text-sm font-medium text-status-error-text hover:bg-status-error-bg/80 disabled:opacity-50",
|
|
578
|
+
onClick: () => {
|
|
579
|
+
L && ye(L);
|
|
580
|
+
},
|
|
581
|
+
children: [/* @__PURE__ */ A(k, {
|
|
582
|
+
className: "h-4 w-4",
|
|
583
|
+
"aria-hidden": "true"
|
|
584
|
+
}), "Delete"]
|
|
585
|
+
})]
|
|
586
|
+
}),
|
|
587
|
+
children: /* @__PURE__ */ j("p", {
|
|
588
|
+
className: "text-sm text-text-secondary",
|
|
589
|
+
children: [
|
|
590
|
+
"Delete",
|
|
591
|
+
" ",
|
|
592
|
+
/* @__PURE__ */ A("span", {
|
|
593
|
+
className: "font-medium text-text-primary",
|
|
594
|
+
children: L?.name
|
|
595
|
+
}),
|
|
596
|
+
"? It stops checking your time and will no longer nudge you."
|
|
597
|
+
]
|
|
598
|
+
})
|
|
599
|
+
})
|
|
600
|
+
]
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
//#endregion
|
|
604
|
+
export { U as TimeTriggersPage };
|
|
605
|
+
|
|
606
|
+
//# sourceMappingURL=TimeTriggersPage.js.map
|