@frigear-nu/crew 0.1.3 → 0.1.5

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/module.d.mts CHANGED
@@ -20,8 +20,10 @@ type CrewStatusEmail = {
20
20
  type CrewStatusEmails = Partial<Record<CrewStatus, CrewStatusEmail>>;
21
21
  /** A role mapping preset: everyone matching `match` (a global role, or an active subscription to a plan) holds `teamRole`. */
22
22
  type CrewRolePreset = {
23
+ /** A global role (`except` leaves out the holders of other roles, inheritance included) or a subscription plan. */
23
24
  match: {
24
25
  role: string;
26
+ except?: string[];
25
27
  } | {
26
28
  plan: string;
27
29
  };
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@frigear-nu/crew",
3
3
  "configKey": "crew",
4
- "version": "0.1.3",
4
+ "version": "0.1.5",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.4",
7
7
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -3,8 +3,8 @@ import { registerModule, registerTailwindSource, registerLocales, resolveDashboa
3
3
  import { registerAccess, addPolicies, guardPages } from '@frigear-nu/auth/utils';
4
4
  import { crewAccess } from '../dist/runtime/access.js';
5
5
  import { resolveCrewHomePath, CREW_DEFAULT_PAGES, CREW_HOME_TABS, CREW_HOME_TAB, crewHomeTab } from '../dist/runtime/utils/links.js';
6
- import { extendDashboard } from '@frigear-nu/dashboard/utils';
7
- import { CREW_DASHBOARD, crewDashboardItems } from '../dist/runtime/dashboard.js';
6
+ import { extendDashboard, extendHubDashboard } from '@frigear-nu/dashboard/utils';
7
+ import { crewDashboardItems, CREW_DASHBOARD } from '../dist/runtime/dashboard.js';
8
8
  import { extendNotificationTopics } from '@frigear-nu/notify/utils';
9
9
  import { crewNotificationTopics } from '../dist/runtime/notifications.js';
10
10
 
@@ -174,7 +174,9 @@ const module$1 = defineNuxtModule({
174
174
  extendMobileTabs(nuxt, mobileTab);
175
175
  }
176
176
  extendNotificationTopics(nuxt, crewNotificationTopics);
177
- extendDashboard(nuxt, CREW_DASHBOARD, crewDashboardItems((path) => resolver.resolve(path)));
177
+ const dashboardItems = crewDashboardItems((path) => resolver.resolve(path));
178
+ extendDashboard(nuxt, CREW_DASHBOARD, dashboardItems);
179
+ extendHubDashboard(nuxt, dashboardItems, { except: CREW_DASHBOARD });
178
180
  addOptionalMenuSource(nuxt, { file: resolver.resolve("./runtime/menus"), menu: "dashboard" });
179
181
  }
180
182
  });
@@ -65,12 +65,12 @@ async function save(event) {
65
65
  :ui="{ trailing: 'pe-1' }"
66
66
  >
67
67
  <template #trailing>
68
- <UButton
68
+ <TooltipButton
69
69
  icon="i-lucide-copy"
70
70
  color="neutral"
71
71
  variant="link"
72
72
  size="sm"
73
- :aria-label="t('admin.copyLink', 'Copy link')"
73
+ :tooltip="t('admin.copyLinkHint', 'Copy the invite link to your clipboard')"
74
74
  @click="copy(link)"
75
75
  />
76
76
  </template>
@@ -218,7 +218,7 @@ async function createInvite() {
218
218
  }
219
219
  const NONE = "__none";
220
220
  const form = reactive({
221
- formId: NONE,
221
+ formId: void 0,
222
222
  defaultTeamId: NONE,
223
223
  capacity: void 0,
224
224
  waitlist: true,
@@ -231,7 +231,7 @@ const form = reactive({
231
231
  const emailsOpen = ref(false);
232
232
  function fillForm(value) {
233
233
  if (!value) return;
234
- form.formId = value.formId ?? NONE;
234
+ form.formId = value.formId ?? void 0;
235
235
  form.defaultTeamId = value.defaultTeamId ?? NONE;
236
236
  form.capacity = value.capacity ?? void 0;
237
237
  form.waitlist = value.waitlist;
@@ -246,12 +246,6 @@ function fillForm(value) {
246
246
  }]));
247
247
  }
248
248
  watch(settings, fillForm, { immediate: true });
249
- const formOptions = computed(() => {
250
- const items = (eligibleForms.value ?? []).map((item) => ({ label: item.name, value: item.id }));
251
- const current = settings.value?.formId;
252
- if (current && !items.some((item) => item.value === current)) items.push({ label: current, value: current });
253
- return [{ label: t("admin.noForm", "No form (applications closed)"), value: NONE }, ...items];
254
- });
255
249
  const teamSettingOptions = computed(() => [
256
250
  { label: t("admin.automaticTeam", "Automatic (the first team)"), value: NONE },
257
251
  ...teams.value.map((team) => ({ label: tr(team.name), value: team.id }))
@@ -275,7 +269,7 @@ async function saveSettings() {
275
269
  () => $fetch(crewApi.admin.settings(operationId.value), {
276
270
  method: "PUT",
277
271
  body: {
278
- formId: form.formId === NONE ? null : form.formId,
272
+ formId: form.formId || null,
279
273
  defaultTeamId: form.defaultTeamId === NONE ? null : form.defaultTeamId,
280
274
  capacity: form.capacity ?? null,
281
275
  waitlist: form.waitlist,
@@ -357,16 +351,17 @@ function jumpToSettings() {
357
351
  :refreshing="refreshing"
358
352
  >
359
353
  <template #actions>
360
- <UButton
354
+ <TooltipButton
361
355
  v-if="selectedIds.length"
362
356
  icon="i-lucide-user-check"
363
357
  size="sm"
364
358
  color="neutral"
365
359
  variant="outline"
366
360
  :label="t('admin.approveSelected', 'Approve {count} selected', { count: selectedIds.length })"
361
+ :tooltip="t('admin.approveSelectedHint', 'Approve them right away; anyone who cannot be is skipped')"
367
362
  @click="approveSelected"
368
363
  />
369
- <UButton
364
+ <TooltipButton
370
365
  v-if="pii"
371
366
  icon="i-lucide-camera-off"
372
367
  size="sm"
@@ -376,13 +371,14 @@ function jumpToSettings() {
376
371
  external
377
372
  download
378
373
  :label="t('admin.exportMediaOptOuts', 'Export photo opt-outs')"
379
- :title="t('admin.exportMediaOptOutsHelp', 'A spreadsheet of everyone taking part who does not want to be photographed or tagged.')"
374
+ :tooltip="t('admin.exportMediaOptOutsHelp', 'A spreadsheet of everyone taking part who does not want to be photographed or tagged.')"
380
375
  data-crew-export-media
381
376
  />
382
- <UButton
377
+ <TooltipButton
383
378
  icon="i-lucide-user-plus"
384
379
  size="sm"
385
380
  :label="t('admin.addMember', 'Add crew member')"
381
+ :tooltip="t('admin.addMemberHint', 'Put someone on the crew, approved, without an application')"
386
382
  data-crew-add-member
387
383
  @click="addMember"
388
384
  />
@@ -439,10 +435,11 @@ function jumpToSettings() {
439
435
  :loading="invitesStatus === 'pending' && !invites.length"
440
436
  >
441
437
  <template #actions>
442
- <UButton
438
+ <TooltipButton
443
439
  icon="i-lucide-plus"
444
440
  size="sm"
445
441
  :label="t('admin.createInvite', 'Create invite')"
442
+ :tooltip="teams.length ? t('admin.createInviteHint', 'Make a link that puts whoever opens it on a team') : t('admin.noInviteTeams', 'Save the settings once to create the first team.')"
446
443
  :disabled="!teams.length"
447
444
  @click="createInvite"
448
445
  />
@@ -479,9 +476,10 @@ function jumpToSettings() {
479
476
  :label="t('admin.form', 'Application form')"
480
477
  :description="t('admin.formHelp', 'It must ask people to sign in and store its submissions. An operation uses its own form.')"
481
478
  >
482
- <USelect
479
+ <FormSelectField
483
480
  v-model="form.formId"
484
- :items="formOptions"
481
+ :items="eligibleForms ?? []"
482
+ :placeholder="t('admin.noForm', 'No form (applications closed)')"
485
483
  class="w-full sm:max-w-sm"
486
484
  />
487
485
  </FormRow>
@@ -22,12 +22,13 @@ async function addToCrew() {
22
22
  </script>
23
23
 
24
24
  <template>
25
- <UButton
25
+ <TooltipButton
26
26
  color="neutral"
27
27
  variant="outline"
28
28
  size="sm"
29
29
  icon="i-lucide-hand-heart"
30
30
  :label="t('admin.addToCrew', 'Add to crew')"
31
+ :tooltip="t('admin.addToCrewHint', 'Put this person straight onto an operation crew, approved')"
31
32
  data-crew-add-to-crew
32
33
  @click="addToCrew"
33
34
  />
@@ -1,8 +1,11 @@
1
1
  import type { DashboardItem } from '@frigear-nu/dashboard/types';
2
- /** The dashboard crew adds its items to, and renders in the Overview tab of its home page (`/dashboard/crew`). */
2
+ /**
3
+ * The dashboard crew adds its items to, and renders in the Overview tab of its home page (`/dashboard/crew`). The items
4
+ * go on the signed-in hub's dashboard too (`extendHubDashboard`).
5
+ */
3
6
  export declare const CREW_DASHBOARD = "crew.home";
4
7
  /**
5
- * The items crew adds to `crew.home`. `resolve` turns a path relative to `module.ts` into an absolute one. Kept apart
8
+ * The items crew adds to `crew.home` and the hub. `resolve` turns a path relative to `module.ts` into an absolute one. Kept apart
6
9
  * from the module so a test can register them without a Nuxt build.
7
10
  */
8
11
  export declare function crewDashboardItems(resolve: (path: string) => string): DashboardItem[];
@@ -8,6 +8,8 @@ export function crewDashboardItems(resolve) {
8
8
  title: "My crew status",
9
9
  titleKey: "crew.dashboard.status",
10
10
  order: 10,
11
+ // A short list of operations with a status badge each.
12
+ size: { cols: 2, minCols: 1 },
11
13
  permission: crewAccess.permissions.read
12
14
  }
13
15
  ];
@@ -2,10 +2,12 @@
2
2
  "crew": {
3
3
  "admin": {
4
4
  "addMember": "Tilføj crewmedlem",
5
+ "addMemberHint": "Sæt en person på crewet, godkendt, uden ansøgning",
5
6
  "addMemberAction": "Tilføj crewmedlem",
6
7
  "addMemberDescription": "Personen kommer på crewet som godkendt og får besked på e-mail eller push.",
7
8
  "addMemberFailed": "Personen kunne ikke tilføjes",
8
9
  "addToCrew": "Tilføj til crew",
10
+ "addToCrewHint": "Sæt personen direkte på et crew, godkendt",
9
11
  "allStatuses": "Alle statusser",
10
12
  "allTeams": "Alle teams",
11
13
  "alreadyInCrew": "{name} er allerede på dette crew ({status}). Find personen i listen for at ændre status.",
@@ -17,6 +19,7 @@
17
19
  "approveAction": "Godkend ansøgning",
18
20
  "approveFailed": "Personen kunne ikke godkendes",
19
21
  "approveSelected": "Godkend {count} valgte",
22
+ "approveSelectedHint": "Godkend dem med det samme; dem, der ikke kan godkendes, springes over",
20
23
  "approved": "Godkendte {name}",
21
24
  "approvedMany": "Godkendte {count} personer",
22
25
  "automaticTeam": "Automatisk (det første team)",
@@ -27,8 +30,9 @@
27
30
  "closesAt": "Lukker",
28
31
  "closesAtHelp": "Lad stå tomt for at holde ansøgningerne åbne.",
29
32
  "copyApplyLink": "Kopiér ansøgningslink",
30
- "copyLink": "Kopiér link",
33
+ "copyLinkHint": "Kopiér invitationslinket til udklipsholderen",
31
34
  "createInvite": "Opret invitation",
35
+ "createInviteHint": "Lav et link, der sætter den, der åbner det, på et team",
32
36
  "createInviteAction": "Opret invitation",
33
37
  "createUserAction": "Opret bruger",
34
38
  "customizeEmails": "Tilpas e-mails",
@@ -2,10 +2,12 @@
2
2
  "crew": {
3
3
  "admin": {
4
4
  "addMember": "Add crew member",
5
+ "addMemberHint": "Put someone on the crew, approved, without an application",
5
6
  "addMemberAction": "Add crew member",
6
7
  "addMemberDescription": "The person joins the crew approved, and is told by email or push.",
7
8
  "addMemberFailed": "The person could not be added",
8
9
  "addToCrew": "Add to crew",
10
+ "addToCrewHint": "Put this person straight onto an operation crew, approved",
9
11
  "allStatuses": "All statuses",
10
12
  "allTeams": "All teams",
11
13
  "alreadyInCrew": "{name} is in this crew already ({status}). Find them in the list to change their status.",
@@ -17,6 +19,7 @@
17
19
  "approveAction": "Approve application",
18
20
  "approveFailed": "Could not approve the person",
19
21
  "approveSelected": "Approve {count} selected",
22
+ "approveSelectedHint": "Approve them right away; anyone who cannot be is skipped",
20
23
  "approved": "Approved {name}",
21
24
  "approvedMany": "Approved {count} people",
22
25
  "automaticTeam": "Automatic (the first team)",
@@ -27,8 +30,9 @@
27
30
  "closesAt": "Closes",
28
31
  "closesAtHelp": "Leave empty to keep applications open.",
29
32
  "copyApplyLink": "Copy apply link",
30
- "copyLink": "Copy link",
33
+ "copyLinkHint": "Copy the invite link to your clipboard",
31
34
  "createInvite": "Create invite",
35
+ "createInviteHint": "Make a link that puts whoever opens it on a team",
32
36
  "createInviteAction": "Create invite",
33
37
  "createUserAction": "Create user",
34
38
  "customizeEmails": "Customize emails",
@@ -18,5 +18,5 @@ export default defineEventHandler(async (event) => {
18
18
  "content-disposition": `attachment; filename="photo-opt-outs-${operation.slug.replace(/[^\w-]/g, "_")}.csv"`,
19
19
  "cache-control": "no-store"
20
20
  });
21
- return crewMediaOptOutsCsv(rows);
21
+ return crewMediaOptOutsCsv(rows, { origin: getRequestURL(event).origin });
22
22
  });
@@ -6,5 +6,10 @@ export declare const CREW_MEDIA_OPT_OUT_COLUMNS: readonly ["name", "nickname", "
6
6
  * photos or of tagging, one row per person (their teams joined), by name. For the people who take photos and post.
7
7
  */
8
8
  export declare function crewMediaOptOuts(operationId: string, locale?: string): Promise<CrewMediaOptOutRow[]>;
9
- /** The opt-outs as CSV (a header row, then one row per person, CRLF line ends), with a BOM so spreadsheets read UTF-8. */
10
- export declare function crewMediaOptOutsCsv(rows: CrewMediaOptOutRow[]): string;
9
+ /**
10
+ * The opt-outs as CSV (a header row, then one row per person, CRLF line ends), with a BOM so spreadsheets read UTF-8.
11
+ * `origin` is the app's public origin: an avatar uploaded to the app (a path on it) becomes an absolute URL there.
12
+ */
13
+ export declare function crewMediaOptOutsCsv(rows: CrewMediaOptOutRow[], options?: {
14
+ origin?: string;
15
+ }): string;
@@ -1,5 +1,6 @@
1
1
  import { db, schema } from "@nuxthub/db";
2
2
  import { and, asc, eq, or } from "drizzle-orm";
3
+ import { absoluteUserAvatarUrl } from "@frigear-nu/users/api";
3
4
  import { translate } from "../../utils/index.js";
4
5
  import { crewTakesPart } from "./crew.js";
5
6
  export const CREW_MEDIA_OPT_OUT_COLUMNS = ["name", "nickname", "email", "avatar_url", "photo_opt_out", "tag_opt_out", "team"];
@@ -45,10 +46,10 @@ const crewCsvCell = (value) => {
45
46
  const safe = /^[=+\-@\t\r]/.test(text) ? `'${text}` : text;
46
47
  return /[",\r\n]/.test(safe) ? `"${safe.replace(/"/g, '""')}"` : safe;
47
48
  };
48
- export function crewMediaOptOutsCsv(rows) {
49
+ export function crewMediaOptOutsCsv(rows, options = {}) {
49
50
  const lines = [
50
51
  CREW_MEDIA_OPT_OUT_COLUMNS.join(","),
51
- ...rows.map((row) => [row.name, row.nickname, row.email, row.avatar, row.photoOptOut, row.tagOptOut, row.teams.join("; ")].map(crewCsvCell).join(","))
52
+ ...rows.map((row) => [row.name, row.nickname, row.email, absoluteUserAvatarUrl(row.avatar, options.origin), row.photoOptOut, row.tagOptOut, row.teams.join("; ")].map(crewCsvCell).join(","))
52
53
  ];
53
54
  return `\uFEFF${lines.join("\r\n")}\r
54
55
  `;
@@ -46,10 +46,10 @@ export async function crewEnsurePresets(event, operationId) {
46
46
  const presets = useRuntimeConfig(event).crew?.rolePresets ?? [];
47
47
  const owner = { ownerType: "operation", ownerId: operationId };
48
48
  const existing = await db.select().from(schema.teamRoleMappings).where(and(eq(schema.teamRoleMappings.ownerType, owner.ownerType), eq(schema.teamRoleMappings.ownerId, operationId), isNull(schema.teamRoleMappings.teamId)));
49
- const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
49
+ const key = (match) => "role" in match ? `role:${match.role}` : `plan:${match.plan}`;
50
50
  for (const preset of presets) {
51
51
  const match = normalizeTeamRoleMatch(preset.match);
52
- if (existing.some((row) => same(normalizeTeamRoleMatch(row.match), match))) continue;
52
+ if (existing.some((row) => key(row.match) === key(match))) continue;
53
53
  try {
54
54
  await assertTeamMappingTarget(event, { ...owner, teamId: null, teamRole: preset.teamRole });
55
55
  } catch {
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "@frigear-nu/crew",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Crew for the frigear ecosystem: applications, approvals and invites that turn people into an operation's crew, built on teams.",
5
+ "keywords": [
6
+ "frigear-module",
7
+ "nuxt-module"
8
+ ],
5
9
  "homepage": "https://docs.frigear.dev/modules/volunteering/crew",
6
10
  "repository": {
7
11
  "type": "git",
@@ -35,15 +39,15 @@
35
39
  "playground"
36
40
  ],
37
41
  "dependencies": {
38
- "@frigear-nu/auth": "^0.6.8",
39
- "@frigear-nu/dashboard": "^0.1.3",
40
- "@frigear-nu/forms": "^0.5.5",
41
- "@frigear-nu/module-kit": "^1.3.12",
42
- "@frigear-nu/notify": "^0.3.1",
43
- "@frigear-nu/operations": "^0.1.2",
44
- "@frigear-nu/teams": "^0.1.3",
45
- "@frigear-nu/ui": "^0.2.11",
46
- "@frigear-nu/users": "^3.1.5",
42
+ "@frigear-nu/auth": "^0.6.10",
43
+ "@frigear-nu/dashboard": "^0.1.4",
44
+ "@frigear-nu/forms": "^0.5.7",
45
+ "@frigear-nu/module-kit": "^1.3.13",
46
+ "@frigear-nu/notify": "^0.3.3",
47
+ "@frigear-nu/operations": "^0.1.4",
48
+ "@frigear-nu/teams": "^0.1.5",
49
+ "@frigear-nu/ui": "^0.2.12",
50
+ "@frigear-nu/users": "^3.1.6",
47
51
  "@libsql/client": "^0.18.0",
48
52
  "@nuxt/kit": "^4.6.4",
49
53
  "@vueuse/core": "^15.0.0",
@@ -53,11 +57,11 @@
53
57
  "zod": "^4.6.7"
54
58
  },
55
59
  "peerDependencies": {
56
- "@frigear-nu/admin": "^0.5.2",
57
- "@frigear-nu/email-templates": "^0.1.5",
58
- "@frigear-nu/menu": "^0.4.1",
59
- "@frigear-nu/mobile": "^0.6.4",
60
- "@frigear-nu/widget": "^0.4.3",
60
+ "@frigear-nu/admin": "^0.5.3",
61
+ "@frigear-nu/email-templates": "^0.1.6",
62
+ "@frigear-nu/menu": "^0.4.2",
63
+ "@frigear-nu/mobile": "^0.6.6",
64
+ "@frigear-nu/widget": "^0.4.4",
61
65
  "@nuxt/ui": "^4.12.0",
62
66
  "@nuxthub/core": "^0.10.12"
63
67
  },
@@ -79,11 +83,11 @@
79
83
  }
80
84
  },
81
85
  "devDependencies": {
82
- "@frigear-nu/admin": "^0.5.2",
83
- "@frigear-nu/email-templates": "^0.1.5",
84
- "@frigear-nu/menu": "^0.4.1",
85
- "@frigear-nu/mobile": "^0.6.4",
86
- "@frigear-nu/widget": "^0.4.3",
86
+ "@frigear-nu/admin": "^0.5.3",
87
+ "@frigear-nu/email-templates": "^0.1.6",
88
+ "@frigear-nu/menu": "^0.4.2",
89
+ "@frigear-nu/mobile": "^0.6.6",
90
+ "@frigear-nu/widget": "^0.4.4",
87
91
  "@nuxt/devtools": "^4.2.0",
88
92
  "@nuxt/eslint-config": "^1.17.0",
89
93
  "@nuxt/module-builder": "^1.0.4",