@attraccess/plugin-reservations 0.1.0-nightly.1188.1 → 0.2.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.
@@ -1795,7 +1795,7 @@ function FeedSecretDialog(props) {
1795
1795
  });
1796
1796
  }
1797
1797
  // frontend/src/ical/IcalFeeds.tsx
1798
- var { Button: Button$8, EmptyState: EmptyState$1, StatusAlert: StatusAlert$7, StatusDialog: StatusDialog$6, TableDataLoadingIndicator: TableDataLoadingIndicator$2 } = await importShared("@attraccess/plugins-frontend-ui");
1798
+ var { Button: Button$8, ConfirmableButton, EmptyState: EmptyState$1, StatusAlert: StatusAlert$7, StatusDialog: StatusDialog$6, TableDataLoadingIndicator: TableDataLoadingIndicator$2 } = await importShared("@attraccess/plugins-frontend-ui");
1799
1799
  var { Chip: Chip$2 } = await importShared("@heroui/react");
1800
1800
  var { useMutation: useMutation$5 } = await importShared("@tanstack/react-query");
1801
1801
  var { PlusIcon: PlusIcon$1 } = await importShared("lucide-react");
@@ -1814,18 +1814,32 @@ function IcalFeeds() {
1814
1814
  const [formFeed, setFormFeed] = useState$9(null);
1815
1815
  const [formOpen, setFormOpen] = useState$9(false);
1816
1816
  const [secret, setSecret] = useState$9(null);
1817
- const [confirm, setConfirm] = useState$9(null);
1818
1817
  const [error, setError] = useState$9(null);
1819
1818
  const run = useMutation$5({
1820
1819
  mutationFn: async (current) => current.kind === "regenerate" ? regenerateFeed(current.feed.id) : (await revokeFeed(current.feed.id), null),
1821
1820
  onSuccess: async (result) => {
1822
- setConfirm(null);
1823
1821
  if (result) setSecret(result);
1824
1822
  await invalidate();
1825
1823
  },
1826
- onError: (failure) => {
1827
- setConfirm(null);
1828
- setError(describeError(failure, t));
1824
+ onError: (failure) => setError(describeError(failure, t))
1825
+ });
1826
+ const runAction = (current) => run.mutateAsync(current).catch(() => void 0);
1827
+ const confirmButton = (kind, feed) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConfirmableButton, {
1828
+ label: t(`feeds.${kind}.label`),
1829
+ status: kind === "revoke" ? "error" : "warning",
1830
+ buttonProps: {
1831
+ size: "sm",
1832
+ variant: "secondary"
1833
+ },
1834
+ onConfirm: () => runAction({
1835
+ kind,
1836
+ feed
1837
+ }),
1838
+ confirm: {
1839
+ title: t(`feeds.${kind}.title`, { name: feed.name }),
1840
+ message: t(`feeds.${kind}.body`),
1841
+ confirmLabel: t(`feeds.${kind}.confirm`),
1842
+ "data-cy": "reservations-feed-confirm"
1829
1843
  }
1830
1844
  });
1831
1845
  const describeSelection = (feed) => {
@@ -1917,24 +1931,8 @@ function IcalFeeds() {
1917
1931
  },
1918
1932
  children: t("common.edit")
1919
1933
  }),
1920
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$8, {
1921
- size: "sm",
1922
- variant: "secondary",
1923
- onPress: () => setConfirm({
1924
- kind: "regenerate",
1925
- feed
1926
- }),
1927
- children: t("feeds.regenerate.label")
1928
- }),
1929
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$8, {
1930
- size: "sm",
1931
- variant: "secondary",
1932
- onPress: () => setConfirm({
1933
- kind: "revoke",
1934
- feed
1935
- }),
1936
- children: t("feeds.revoke.label")
1937
- })
1934
+ confirmButton("regenerate", feed),
1935
+ confirmButton("revoke", feed)
1938
1936
  ]
1939
1937
  })]
1940
1938
  }, feed.id))
@@ -1952,19 +1950,6 @@ function IcalFeeds() {
1952
1950
  secret,
1953
1951
  onClose: () => setSecret(null)
1954
1952
  }),
1955
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog$6, {
1956
- isOpen: confirm !== null,
1957
- onClose: () => !run.isPending && setConfirm(null),
1958
- status: "warning",
1959
- title: confirm ? t(`feeds.${confirm.kind}.title`, { name: confirm.feed.name }) : "",
1960
- action: {
1961
- label: confirm ? t(`feeds.${confirm.kind}.confirm`) : "",
1962
- onPress: () => confirm && run.mutate(confirm),
1963
- isPending: run.isPending
1964
- },
1965
- "data-cy": "reservations-feed-confirm",
1966
- children: confirm ? t(`feeds.${confirm.kind}.body`) : ""
1967
- }),
1968
1953
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog$6, {
1969
1954
  isOpen: error !== null,
1970
1955
  onClose: () => setError(null),
@@ -3880,7 +3865,7 @@ var ReservationsPlugin = class {
3880
3865
  this.sidebarListeners = /* @__PURE__ */ new Set();
3881
3866
  }
3882
3867
  getPluginName() {
3883
- return "reservations-plugin@0.1.0";
3868
+ return "reservations-plugin@0.2.0";
3884
3869
  }
3885
3870
  getDependencies() {
3886
3871
  return [];
@@ -8,7 +8,7 @@ var exportSet = /* @__PURE__ */ new Set([
8
8
  ]);
9
9
  var moduleMap = { "./plugin": () => {
10
10
  dynamicLoadingCss(["style.css"], false, "./plugin");
11
- return __federation_import("./__federation_expose_Plugin-Bb9PSkup.js").then((module) => Object.keys(module).every((item) => exportSet.has(item)) ? () => module.default : () => module);
11
+ return __federation_import("./__federation_expose_Plugin-BDJ5Eff3.js").then((module) => Object.keys(module).every((item) => exportSet.has(item)) ? () => module.default : () => module);
12
12
  } };
13
13
  var seen = {};
14
14
  var dynamicLoadingCss = (cssFilePaths, dontAppendStylesToHead, exposeItemName) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@attraccess/plugin-reservations",
3
- "version": "0.1.0-nightly.1188.1",
3
+ "version": "0.2.0",
4
4
  "description": "Official Attraccess plugin to reserve resources for a specific time window.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "repository": {
@@ -23,17 +23,16 @@
23
23
  "access": "public"
24
24
  },
25
25
  "peerDependencies": {
26
- "@attraccess/plugins-backend-sdk": "^1.9.0",
27
- "@attraccess/plugins-frontend-sdk": "^1.9.0",
28
- "@attraccess/plugins-frontend-ui": "^1.11.0-0"
26
+ "@attraccess/plugins-backend-sdk": "^2.0.0-0",
27
+ "@attraccess/plugins-frontend-sdk": "^2.0.0-0",
28
+ "@attraccess/plugins-frontend-ui": "^2.0.0-0"
29
29
  },
30
30
  "attraccess": {
31
31
  "displayName": "Reservations",
32
32
  "description": "Reserve a resource for a specific time window.",
33
- "host": "^1.11.0-beta.3",
33
+ "host": "^2.0.0-0",
34
34
  "backend": "dist/index.js",
35
35
  "frontend": "frontend/remoteEntry.js",
36
- "migrations": "dist/migrations.js",
37
36
  "styles": "frontend/style.css",
38
37
  "dashboardPaths": [
39
38
  "/reservations",
@@ -43,13 +42,14 @@
43
42
  "reservations-upcoming"
44
43
  ],
45
44
  "permissions": [
46
- "DATABASE_ACCESS",
45
+ "PLUGIN_STORAGE",
47
46
  "ACCESS_HOOKS",
48
47
  "LISTEN_EVENTS",
49
48
  "ACCESS_RESOURCES",
50
49
  "READ_USERS",
51
50
  "READ_SETTINGS",
52
- "SEND_NOTIFICATIONS"
51
+ "SEND_NOTIFICATIONS",
52
+ "READER_UI"
53
53
  ],
54
54
  "license": {
55
55
  "required": true,
@@ -58,10 +58,10 @@
58
58
  ]
59
59
  },
60
60
  "sdk": {
61
- "backend": "^1.9.0",
62
- "frontend": "^1.9.0"
61
+ "backend": "^2.0.0-0",
62
+ "frontend": "^2.0.0-0"
63
63
  },
64
- "publishedCommit": "cd28283778a934e08258c3305ff4c07114226385"
64
+ "publishedCommit": "aba5a1a9b7e143c00bc771d59018684546f0f336"
65
65
  },
66
- "gitHead": "cd28283778a934e08258c3305ff4c07114226385"
66
+ "gitHead": "aba5a1a9b7e143c00bc771d59018684546f0f336"
67
67
  }
@@ -1,161 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
20
-
21
- // backend/migrations.ts
22
- var migrations_exports = {};
23
- __export(migrations_exports, {
24
- AddReservationStatusIndexes1790000000001: () => AddReservationStatusIndexes1790000000001,
25
- CreateReservations1790000000000: () => CreateReservations1790000000000
26
- });
27
- module.exports = __toCommonJS(migrations_exports);
28
-
29
- // backend/migrations/1790000000000-create-reservations.ts
30
- var CreateReservations1790000000000 = class {
31
- constructor() {
32
- __publicField(this, "name", "CreateReservations1790000000000");
33
- }
34
- async up(queryRunner) {
35
- await queryRunner.query(
36
- `CREATE TABLE IF NOT EXISTS "reservations_reservation" (
37
- "id" integer PRIMARY KEY AUTOINCREMENT NOT NULL,
38
- "resourceId" integer NOT NULL,
39
- "userId" integer NOT NULL,
40
- "startTime" datetime NOT NULL,
41
- "endTime" datetime NOT NULL,
42
- "bufferBeforeMinutes" integer NOT NULL DEFAULT (0),
43
- "bufferAfterMinutes" integer NOT NULL DEFAULT (0),
44
- "status" varchar NOT NULL,
45
- "note" varchar,
46
- "createdAt" datetime NOT NULL,
47
- "endedEarlyAt" datetime,
48
- "cancelledBy" integer,
49
- "cancelReason" varchar,
50
- "decidedBy" integer,
51
- "decisionReason" varchar,
52
- "decidedAt" datetime,
53
- "checkedInAt" datetime,
54
- "checkedInUsageId" integer,
55
- "keptAt" datetime,
56
- "confirmationSentAt" datetime,
57
- "stillNeededSentAt" datetime,
58
- "reminder24hSentAt" datetime,
59
- "handoverSentAt" datetime,
60
- "overrunSentAt" datetime,
61
- "noShowNotifiedAt" datetime,
62
- "expiredNotifiedAt" datetime
63
- )`
64
- );
65
- await queryRunner.query(
66
- `CREATE INDEX IF NOT EXISTS "IDX_reservations_reservation_slot" ON "reservations_reservation" ("resourceId", "status", "startTime", "endTime")`
67
- );
68
- await queryRunner.query(
69
- `CREATE INDEX IF NOT EXISTS "IDX_reservations_reservation_user" ON "reservations_reservation" ("userId", "status")`
70
- );
71
- await queryRunner.query(
72
- `CREATE TABLE IF NOT EXISTS "reservations_resource_settings" (
73
- "resourceId" integer PRIMARY KEY NOT NULL,
74
- "enabled" boolean NOT NULL DEFAULT (0),
75
- "approvalRequired" boolean NOT NULL DEFAULT (0),
76
- "timeStepMinutes" integer NOT NULL DEFAULT (15),
77
- "minDurationMinutes" integer NOT NULL DEFAULT (15),
78
- "maxDurationMinutes" integer NOT NULL DEFAULT (240),
79
- "maxAdvanceDays" integer NOT NULL DEFAULT (30),
80
- "minLeadMinutes" integer NOT NULL DEFAULT (0),
81
- "bufferBeforeMinutes" integer NOT NULL DEFAULT (0),
82
- "bufferAfterMinutes" integer NOT NULL DEFAULT (0),
83
- "maxActiveBookingsPerUser" integer NOT NULL DEFAULT (3),
84
- "whoCanBook" varchar NOT NULL DEFAULT ('can-start'),
85
- "confirmWindowMinutes" integer NOT NULL DEFAULT (60),
86
- "checkInEnabled" boolean NOT NULL DEFAULT (1),
87
- "checkInGraceMinutes" integer NOT NULL DEFAULT (15),
88
- "earlyCheckInMinutes" integer NOT NULL DEFAULT (15),
89
- "handoverReminderMinutes" integer NOT NULL DEFAULT (15),
90
- "bookableHours" text NOT NULL DEFAULT ('{}'),
91
- "updatedAt" datetime NOT NULL
92
- )`
93
- );
94
- await queryRunner.query(
95
- `CREATE TABLE IF NOT EXISTS "reservations_global_settings" (
96
- "key" varchar PRIMARY KEY NOT NULL,
97
- "value" text NOT NULL
98
- )`
99
- );
100
- await queryRunner.query(
101
- `CREATE TABLE IF NOT EXISTS "reservations_ical_feed" (
102
- "id" integer PRIMARY KEY AUTOINCREMENT NOT NULL,
103
- "userId" integer NOT NULL,
104
- "name" varchar NOT NULL,
105
- "tokenHash" varchar NOT NULL,
106
- "tokenPrefix" varchar,
107
- "selection" text NOT NULL,
108
- "createdAt" datetime NOT NULL,
109
- "revokedAt" datetime,
110
- "lastUsedAt" datetime,
111
- CONSTRAINT "UQ_reservations_ical_feed_token" UNIQUE ("tokenHash")
112
- )`
113
- );
114
- await queryRunner.query(
115
- `CREATE INDEX IF NOT EXISTS "IDX_reservations_ical_feed_user" ON "reservations_ical_feed" ("userId")`
116
- );
117
- await queryRunner.query(
118
- `CREATE TABLE IF NOT EXISTS "reservations_notice" (
119
- "id" integer PRIMARY KEY AUTOINCREMENT NOT NULL,
120
- "reservationId" integer NOT NULL,
121
- "kind" varchar NOT NULL,
122
- "refKey" varchar NOT NULL DEFAULT (''),
123
- "sentAt" datetime NOT NULL
124
- )`
125
- );
126
- await queryRunner.query(
127
- `CREATE UNIQUE INDEX IF NOT EXISTS "UQ_reservations_notice" ON "reservations_notice" ("reservationId", "kind", "refKey")`
128
- );
129
- }
130
- async down(queryRunner) {
131
- await queryRunner.query(`DROP TABLE IF EXISTS "reservations_notice"`);
132
- await queryRunner.query(`DROP TABLE IF EXISTS "reservations_ical_feed"`);
133
- await queryRunner.query(`DROP TABLE IF EXISTS "reservations_global_settings"`);
134
- await queryRunner.query(`DROP TABLE IF EXISTS "reservations_resource_settings"`);
135
- await queryRunner.query(`DROP TABLE IF EXISTS "reservations_reservation"`);
136
- }
137
- };
138
-
139
- // backend/migrations/1790000000001-add-reservation-status-indexes.ts
140
- var AddReservationStatusIndexes1790000000001 = class {
141
- constructor() {
142
- __publicField(this, "name", "AddReservationStatusIndexes1790000000001");
143
- }
144
- async up(queryRunner) {
145
- await queryRunner.query(
146
- `CREATE INDEX IF NOT EXISTS "IDX_reservations_reservation_status_start" ON "reservations_reservation" ("status", "startTime")`
147
- );
148
- await queryRunner.query(
149
- `CREATE INDEX IF NOT EXISTS "IDX_reservations_reservation_status_end" ON "reservations_reservation" ("status", "endTime")`
150
- );
151
- }
152
- async down(queryRunner) {
153
- await queryRunner.query(`DROP INDEX IF EXISTS "IDX_reservations_reservation_status_end"`);
154
- await queryRunner.query(`DROP INDEX IF EXISTS "IDX_reservations_reservation_status_start"`);
155
- }
156
- };
157
- // Annotate the CommonJS export names for ESM import in node:
158
- 0 && (module.exports = {
159
- AddReservationStatusIndexes1790000000001,
160
- CreateReservations1790000000000
161
- });