@parallelworks/tandem-web 0.184.0 → 0.186.0

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.
@@ -1,158 +1,214 @@
1
- import { docRef as e } from "../lib/docs.js";
2
- import { useFavorites as t } from "../lib/favorites.js";
3
- import { useNavigate as n } from "../lib/router.js";
4
- import { teamPath as r } from "../lib/teamPaths.js";
5
- import { DocIcon as i } from "./DocIcon.js";
6
- import { EntityIcon as a } from "./EntityIcon.js";
7
- import { CycleIcon as o, FileTextIcon as s, InboxIcon as c, LibraryIcon as l, ListViewIcon as u, ProjectIcon as d, StatusIcon as f, UserIcon as p } from "./icons.js";
8
- import { menuDivider as m, useOpenMenu as h } from "@parallelworks/ui";
9
- import { useState as g } from "react";
10
- import { useTranslations as _ } from "use-intl";
11
- import { jsx as v } from "react/jsx-runtime";
12
- import { MoreButton as y } from "@parallelworks/ui/list";
13
- import { AppFrameNavGroup as b, AppFrameNavItem as x } from "@parallelworks/ui/app-frame";
1
+ import { projectsQuery as e } from "../api/queries.js";
2
+ import { docRef as t } from "../lib/docs.js";
3
+ import { useFavorites as n } from "../lib/favorites.js";
4
+ import { projectLevel as r } from "../lib/projects.js";
5
+ import { useCan as i } from "../lib/roles.js";
6
+ import { useNavigate as a } from "../lib/router.js";
7
+ import { teamPath as o } from "../lib/teamPaths.js";
8
+ import { DocIcon as s } from "./DocIcon.js";
9
+ import { EntityIcon as c } from "./EntityIcon.js";
10
+ import { AreaIcon as l, ChartIcon as u, CycleIcon as d, FileTextIcon as f, InboxIcon as p, LibraryIcon as m, ListViewIcon as h, NotificationIcon as g, ProjectIcon as _, StatusIcon as v, TriageIcon as y, UserIcon as b } from "./icons.js";
11
+ import { NewProjectDialog as x } from "./NewProjectDialog.js";
12
+ import { menuDivider as S, useOpenMenu as C } from "@parallelworks/ui";
13
+ import { useState as w } from "react";
14
+ import { useTranslations as T } from "use-intl";
15
+ import { jsx as E, jsxs as D } from "react/jsx-runtime";
16
+ import { useQuery as O } from "@tanstack/react-query";
17
+ import { MoreButton as k } from "@parallelworks/ui/list";
18
+ import { AppFrameNavGroup as A, AppFrameNavItem as j } from "@parallelworks/ui/app-frame";
14
19
  // src/components/FavoritesNav.tsx
15
- var S = (...e) => e.filter(Boolean).join(" ");
16
- function C(t, n, m, h) {
17
- switch (t.kind) {
20
+ var M = (...e) => e.filter(Boolean).join(" ");
21
+ function N(e, n, r, i) {
22
+ switch (e.kind) {
18
23
  case "issue": return {
19
- href: `/${n}/issues/${t.issue?.identifier ?? ""}`,
20
- label: t.issue ? `${t.issue.identifier} ${t.issue.title}` : h("issue"),
21
- icon: t.issue ? /* @__PURE__ */ v(f, {
22
- category: t.issue.status.category,
23
- review: t.issue.status.review,
24
- step: t.issue.status.step
24
+ href: `/${n}/issues/${e.issue?.identifier ?? ""}`,
25
+ label: e.issue ? `${e.issue.identifier} ${e.issue.title}` : i("issue"),
26
+ icon: e.issue ? /* @__PURE__ */ E(v, {
27
+ category: e.issue.status.category,
28
+ review: e.issue.status.review,
29
+ step: e.issue.status.step
25
30
  }) : null
26
31
  };
27
32
  case "team": return {
28
- href: r(n, t.team?.key ?? "", "issues"),
29
- label: t.team?.name ?? h("team"),
30
- icon: t.team ? /* @__PURE__ */ v(a, {
31
- icon: t.team.icon,
32
- color: t.team.color,
33
- name: t.team.name
33
+ href: o(n, e.team?.key ?? "", "issues"),
34
+ label: e.team?.name ?? i("team"),
35
+ icon: e.team ? /* @__PURE__ */ E(c, {
36
+ icon: e.team.icon,
37
+ color: e.team.color,
38
+ name: e.team.name
34
39
  }) : null
35
40
  };
36
41
  case "doc": return {
37
- href: `/${n}/docs/${t.doc ? e(t.doc) : ""}`,
38
- label: t.doc?.title ?? h("doc"),
39
- icon: /* @__PURE__ */ v(i, {
40
- icon: t.doc?.icon,
42
+ href: `/${n}/docs/${e.doc ? t(e.doc) : ""}`,
43
+ label: e.doc?.title ?? i("doc"),
44
+ icon: /* @__PURE__ */ E(s, {
45
+ icon: e.doc?.icon,
41
46
  className: "size-4"
42
47
  })
43
48
  };
44
49
  case "project": return {
45
- href: `/${n}/projects/${t.plan?.ref ?? t.target}`,
46
- label: t.plan?.name ?? h("project"),
47
- icon: t.plan?.icon || t.plan?.color ? /* @__PURE__ */ v(a, {
48
- icon: t.plan.icon ?? "",
49
- color: t.plan.color ?? "",
50
- name: t.plan.name
51
- }) : /* @__PURE__ */ v(d, { className: "size-4" })
50
+ href: `/${n}/projects/${e.plan?.ref ?? e.target}`,
51
+ label: e.plan?.name ?? i("project"),
52
+ icon: e.plan?.icon || e.plan?.color ? /* @__PURE__ */ E(c, {
53
+ icon: e.plan.icon ?? "",
54
+ color: e.plan.color ?? "",
55
+ name: e.plan.name
56
+ }) : /* @__PURE__ */ E(_, { className: "size-4" })
52
57
  };
53
58
  case "cycle": return {
54
- href: `${r(n, t.team?.key ?? "", "cycles")}/${t.plan?.ref ?? ""}`,
55
- label: t.plan ? t.plan.name || h("cycleOf", {
56
- team: t.team?.key ?? "",
57
- number: t.plan.ref
58
- }) : h("cycle"),
59
- icon: /* @__PURE__ */ v(o, { className: "size-4" })
59
+ href: `${o(n, e.team?.key ?? "", "cycles")}/${e.plan?.ref ?? ""}`,
60
+ label: e.plan ? e.plan.name || i("cycleOf", {
61
+ team: e.team?.key ?? "",
62
+ number: e.plan.ref
63
+ }) : i("cycle"),
64
+ icon: /* @__PURE__ */ E(d, { className: "size-4" })
60
65
  };
61
66
  case "view": return {
62
- href: t.target,
63
- label: t.label || h("view"),
64
- icon: /* @__PURE__ */ v(u, { className: "size-4" })
67
+ href: e.target,
68
+ label: e.label || i("view"),
69
+ icon: /* @__PURE__ */ E(h, { className: "size-4" })
65
70
  };
66
- case "page": return t.target === "decisions" ? {
67
- href: `/${n}/decisions`,
68
- label: h("decisions"),
69
- icon: /* @__PURE__ */ v(c, { className: "size-4" })
70
- } : t.target === "agents" ? {
71
- href: `/${n}/agents`,
72
- label: h("agents"),
73
- icon: /* @__PURE__ */ v(p, { className: "size-4" })
74
- } : t.target === "projects" ? {
75
- href: `/${n}/projects`,
76
- label: h("projects"),
77
- icon: /* @__PURE__ */ v(d, { className: "size-4" })
78
- } : t.target === "knowledge" ? {
79
- href: `/${n}/knowledge`,
80
- label: h("knowledge"),
81
- icon: /* @__PURE__ */ v(l, { className: "size-4" })
82
- } : t.target === "docs" ? {
83
- href: `/${n}/docs`,
84
- label: h("docs"),
85
- icon: /* @__PURE__ */ v(s, { className: "size-4" })
86
- } : t.target === "my-issues" ? {
87
- href: `/${n}/issues?assignee=${m}`,
88
- label: h("myIssues"),
89
- icon: /* @__PURE__ */ v(p, { className: "size-4" })
90
- } : {
71
+ case "page": return {
72
+ decisions: {
73
+ href: `/${n}/decisions`,
74
+ label: i("decisions"),
75
+ icon: /* @__PURE__ */ E(p, { className: "size-4" })
76
+ },
77
+ agents: {
78
+ href: `/${n}/agents`,
79
+ label: i("agents"),
80
+ icon: /* @__PURE__ */ E(b, { className: "size-4" })
81
+ },
82
+ projects: {
83
+ href: `/${n}/projects`,
84
+ label: i("projects"),
85
+ icon: /* @__PURE__ */ E(_, { className: "size-4" })
86
+ },
87
+ knowledge: {
88
+ href: `/${n}/knowledge`,
89
+ label: i("knowledge"),
90
+ icon: /* @__PURE__ */ E(m, { className: "size-4" })
91
+ },
92
+ docs: {
93
+ href: `/${n}/docs`,
94
+ label: i("docs"),
95
+ icon: /* @__PURE__ */ E(f, { className: "size-4" })
96
+ },
97
+ "my-issues": {
98
+ href: `/${n}/issues?assignee=${r}`,
99
+ label: i("myIssues"),
100
+ icon: /* @__PURE__ */ E(b, { className: "size-4" })
101
+ },
102
+ notifications: {
103
+ href: `/${n}/notifications`,
104
+ label: i("notifications"),
105
+ icon: /* @__PURE__ */ E(g, { className: "size-4" })
106
+ },
107
+ dashboards: {
108
+ href: `/${n}/dashboards`,
109
+ label: i("dashboards"),
110
+ icon: /* @__PURE__ */ E(u, { className: "size-4" })
111
+ },
112
+ areas: {
113
+ href: `/${n}/areas`,
114
+ label: i("areas"),
115
+ icon: /* @__PURE__ */ E(l, { className: "size-4" })
116
+ },
117
+ triage: {
118
+ href: `/${n}/triage`,
119
+ label: i("triage"),
120
+ icon: /* @__PURE__ */ E(y, { className: "size-4" })
121
+ },
122
+ graph: {
123
+ href: `/${n}/graph`,
124
+ label: i("graph"),
125
+ icon: /* @__PURE__ */ E(m, { className: "size-4" })
126
+ },
127
+ measures: {
128
+ href: `/${n}/measures`,
129
+ label: i("measures"),
130
+ icon: /* @__PURE__ */ E(h, { className: "size-4" })
131
+ }
132
+ }[e.target] ?? {
91
133
  href: `/${n}/issues`,
92
- label: h("issues"),
93
- icon: /* @__PURE__ */ v(u, { className: "size-4" })
134
+ label: i("issues"),
135
+ icon: /* @__PURE__ */ E(h, { className: "size-4" })
94
136
  };
95
137
  }
96
138
  }
97
- function w({ workspace: e, myUsername: r, currentHref: i }) {
98
- let { favorites: a, remove: o, move: s } = t(e), c = h(), l = _("favorites"), u = _("common"), d = n(), [f, p] = g(null), [w, T] = g(null);
99
- if (a.length === 0) return null;
100
- let E = (e, t) => [
139
+ function P({ workspace: t, myUsername: o, currentHref: s }) {
140
+ let { favorites: c, remove: l, move: u } = n(t), d = C(), f = T("favorites"), p = T("common"), m = T("planning"), h = a(), [g, _] = w(null), [v, y] = w(null), [b, P] = w(null), F = i(t, "manage_projects"), { data: I = [] } = O({
141
+ ...e(t),
142
+ enabled: F && c.some((e) => e.kind === "project")
143
+ });
144
+ if (c.length === 0) return null;
145
+ let L = (e) => e.kind === "project" ? I.find((t) => t.id === e.target) : void 0, R = (e) => {
146
+ let t = L(e);
147
+ return F && !!t && !t.template && r(I, t.id) < 5;
148
+ }, z = (e, t) => [
101
149
  {
102
- label: u("open"),
103
- onClick: () => d({ href: t })
150
+ label: p("open"),
151
+ onClick: () => h({ href: t })
104
152
  },
153
+ ...R(e) ? [{
154
+ label: m("newSubProject"),
155
+ onClick: () => P(e.target)
156
+ }] : [],
105
157
  {
106
- label: u("openInNewTab"),
158
+ label: p("openInNewTab"),
107
159
  href: t,
108
160
  target: "_blank"
109
161
  },
110
- m,
162
+ S,
111
163
  {
112
- label: l("remove"),
113
- onClick: () => o(e.id)
164
+ label: f("remove"),
165
+ onClick: () => l(e.id)
114
166
  }
115
- ], D = (e) => {
116
- if (!f || f === e) return;
117
- let t = a.filter((e) => e.id !== f), n = t.findIndex((t) => t.id === e), [r, i] = a.findIndex((e) => e.id === f) < a.findIndex((t) => t.id === e) ? [t[n], t[n + 1]] : [t[n - 1], t[n]];
118
- s({
119
- id: f,
167
+ ], B = (e) => {
168
+ if (!g || g === e) return;
169
+ let t = c.filter((e) => e.id !== g), n = t.findIndex((t) => t.id === e), [r, i] = c.findIndex((e) => e.id === g) < c.findIndex((t) => t.id === e) ? [t[n], t[n + 1]] : [t[n - 1], t[n]];
170
+ u({
171
+ id: g,
120
172
  ...r && { after: r.id },
121
173
  ...i && { before: i.id }
122
174
  });
123
175
  };
124
- return /* @__PURE__ */ v(b, {
125
- label: l("title"),
176
+ return /* @__PURE__ */ D(A, {
177
+ label: f("title"),
126
178
  collapsible: !1,
127
- children: a.map((t) => {
128
- let n = C(t, e, r, l);
129
- return /* @__PURE__ */ v(x, {
179
+ children: [c.map((e) => {
180
+ let n = N(e, t, o, f);
181
+ return /* @__PURE__ */ E(j, {
130
182
  label: n.label,
131
183
  icon: n.icon,
132
184
  href: n.href,
133
- selected: n.href === i,
185
+ selected: n.href === s,
134
186
  draggable: !0,
135
- onDragStart: (e) => {
136
- p(t.id), e.dataTransfer.effectAllowed = "move";
187
+ onDragStart: (t) => {
188
+ _(e.id), t.dataTransfer.effectAllowed = "move";
137
189
  },
138
- onDragOver: (e) => {
139
- e.preventDefault(), T(t.id);
190
+ onDragOver: (t) => {
191
+ t.preventDefault(), y(e.id);
140
192
  },
141
- onDragLeave: () => T((e) => e === t.id ? null : e),
142
- onDrop: (e) => {
143
- e.preventDefault(), D(t.id), p(null), T(null);
193
+ onDragLeave: () => y((t) => t === e.id ? null : t),
194
+ onDrop: (t) => {
195
+ t.preventDefault(), B(e.id), _(null), y(null);
144
196
  },
145
197
  onDragEnd: () => {
146
- p(null), T(null);
198
+ _(null), y(null);
147
199
  },
148
- onContextMenu: (e) => c(e, E(t, n.href)),
149
- className: S(f === t.id && "opacity-40", w === t.id && f !== t.id && "ring-1 ring-primary/60"),
150
- action: /* @__PURE__ */ v(y, {
151
- items: () => E(t, n.href),
152
- label: u("moreActionsFor", { name: n.label })
200
+ onContextMenu: (t) => d(t, z(e, n.href)),
201
+ className: M(g === e.id && "opacity-40", v === e.id && g !== e.id && "ring-1 ring-primary/60"),
202
+ action: /* @__PURE__ */ E(k, {
203
+ items: () => z(e, n.href),
204
+ label: p("moreActionsFor", { name: n.label })
153
205
  })
154
- }, t.id);
155
- })
206
+ }, e.id);
207
+ }), b && /* @__PURE__ */ E(x, {
208
+ workspace: t,
209
+ parentId: b,
210
+ onClose: () => P(null)
211
+ })]
156
212
  });
157
213
  }
158
- export { w as FavoritesNav };
214
+ export { P as FavoritesNav };