@attraccess/plugin-matter 0.3.0-alpha.0 → 0.4.0-nightly.1161.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/index.js +4394 -1647
- package/dist/migrations.js +69 -0
- package/frontend/__federation_expose_Plugin-AcefbZx2.js +2105 -0
- package/frontend/remoteEntry.js +1 -1
- package/frontend/style.css +166 -0
- package/package.json +7 -5
- package/frontend/__federation_expose_Plugin-CDuGnCB9.js +0 -783
|
@@ -0,0 +1,2105 @@
|
|
|
1
|
+
import { r as importShared } from "./_virtual___federation_fn_import-BXODRNto.js";
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
4
|
+
var en_default = {
|
|
5
|
+
page: {
|
|
6
|
+
"title": "Matter",
|
|
7
|
+
"subtitle": "Connection to the Matter sidecar.",
|
|
8
|
+
"insecure": "Insecure connection",
|
|
9
|
+
"insecureText": "The sidecar is reached over plain http on a non-loopback address. The token travels unencrypted. Use https, or keep the sidecar on the same host."
|
|
10
|
+
},
|
|
11
|
+
status: {
|
|
12
|
+
"title": "Connection status",
|
|
13
|
+
"state": {
|
|
14
|
+
"not_configured": "Not configured",
|
|
15
|
+
"connecting": "Connecting",
|
|
16
|
+
"connected": "Connected",
|
|
17
|
+
"degraded": "Degraded"
|
|
18
|
+
},
|
|
19
|
+
"reason": {
|
|
20
|
+
"unavailable": "Unavailable",
|
|
21
|
+
"unauthorized": "Unauthorized",
|
|
22
|
+
"incompatible": "Incompatible",
|
|
23
|
+
"misconfigured": "Misconfigured"
|
|
24
|
+
},
|
|
25
|
+
"since": "Since",
|
|
26
|
+
"lastError": "Last error",
|
|
27
|
+
"correlationId": "Correlation ID",
|
|
28
|
+
"nextRetry": "Next attempt",
|
|
29
|
+
"sidecarVersion": "Sidecar",
|
|
30
|
+
"matterJsVersion": "matter.js",
|
|
31
|
+
"wireVersion": "Wire version",
|
|
32
|
+
"received": "Received",
|
|
33
|
+
"supported": "Supported combination",
|
|
34
|
+
"combination": "Attraccess {{attraccess}}, plugin {{plugin}}, sidecar {{sidecar}}, matter.js {{matterJs}}",
|
|
35
|
+
"loadError": "The status could not be loaded."
|
|
36
|
+
},
|
|
37
|
+
hint: {
|
|
38
|
+
"not_configured": "Enter the sidecar URL and token below to connect.",
|
|
39
|
+
"connecting": "Connecting to the Matter sidecar…",
|
|
40
|
+
"connected": "The plugin is connected to the Matter sidecar.",
|
|
41
|
+
"unavailable": "The sidecar cannot be reached. Check that it is running and that the URL, port and firewall are correct. Attraccess retries automatically.",
|
|
42
|
+
"unauthorized": "The sidecar rejected the token. Check the token (also after a rotation) and enter it again.",
|
|
43
|
+
"incompatible": "The versions do not match. Upgrade or downgrade Attraccess, the Matter plugin or the sidecar to the supported combination shown below.",
|
|
44
|
+
"misconfigured": "The URL, the CA certificate or the TLS setup is invalid. Check the URL and path prefix, and that the CA matches the sidecar certificate.",
|
|
45
|
+
"hostVersion": "This Attraccess version does not report its version. Upgrade Attraccess to {{attraccess}} or newer."
|
|
46
|
+
},
|
|
47
|
+
form: {
|
|
48
|
+
"title": "Connection settings",
|
|
49
|
+
"url": "Sidecar URL",
|
|
50
|
+
"urlPlaceholder": "http://127.0.0.1:8581",
|
|
51
|
+
"urlDescription": "Use https for anything but the same host. A path prefix for a reverse proxy is allowed.",
|
|
52
|
+
"credential": "Token",
|
|
53
|
+
"credentialDescription": "The shared service token configured on the sidecar. It is never shown again after saving.",
|
|
54
|
+
"credentialConfigured": "Configured (last changed {{time}})",
|
|
55
|
+
"replace": "Replace",
|
|
56
|
+
"cancelReplace": "Keep current token",
|
|
57
|
+
"ca": "CA certificate (optional)",
|
|
58
|
+
"caDescription": "PEM certificate(s) of a private CA. They are trusted in addition to Node.js's default root certificates, not instead of them.",
|
|
59
|
+
"caClear": "Clear CA certificate",
|
|
60
|
+
"caCleared": "The CA certificate will be removed when you save.",
|
|
61
|
+
"save": "Save",
|
|
62
|
+
"remove": "Remove configuration",
|
|
63
|
+
"saved": "Saved",
|
|
64
|
+
"savedText": "The connection settings were saved. The plugin reconnects now.",
|
|
65
|
+
"saveError": "Saving failed",
|
|
66
|
+
"removeTitle": "Remove the Matter connection?",
|
|
67
|
+
"removeText": "The URL and token are deleted and the plugin disconnects from the sidecar.",
|
|
68
|
+
"removeConfirm": "Remove",
|
|
69
|
+
"removeError": "Removing failed",
|
|
70
|
+
"loadError": "The connection settings could not be loaded."
|
|
71
|
+
},
|
|
72
|
+
fabric: /* @__PURE__ */ JSON.parse("{\"title\":\"Fabric & backup\",\"statusTitle\":\"Fabric\",\"loadError\":\"The fabric status could not be loaded.\",\"none\":\"-\",\"cancel\":\"Cancel\",\"close\":\"Close\",\"reason\":\"Reason\",\"loading\":\"Loading the fabric status\",\"error\":{\"key_required\":\"This backup was encrypted with a different recovery key. Enter that recovery key.\",\"wrong_key\":\"The recovery key is wrong. Check it and try again.\",\"corrupt\":\"The backup is corrupt or has been modified and cannot be used.\",\"truncated\":\"The backup is incomplete, probably because the file was cut off. Download it again.\",\"incompatible_format\":\"This file is not a backup in a supported format.\",\"incompatible_schema\":\"The backup uses a storage schema version that this installation cannot restore.\",\"incompatible_migration\":\"The backup was made with a different plugin database version. Install the plugin version that created it.\",\"incompatible_version\":\"The plugin version must match the version that created the backup. Install that version first.\",\"stage_failed\":\"The sidecar could not prepare the backup. Your installation was left unchanged.\",\"fabric_exists\":\"The sidecar already has a fabric.\",\"recovery_required\":\"The fabric needs recovery first. Restore a backup, accept the sidecar's fabric or start a new fabric.\",\"recovery_not_required\":\"The fabric does not need recovery any more.\",\"busy\":\"The Matter sidecar is busy with another backup or restore. Try again shortly.\",\"sidecar_unavailable\":\"The sidecar cannot be reached. Try again when it is connected.\",\"sidecar_error\":\"The Matter sidecar refused the request.\",\"sidecar_not_empty\":\"A new fabric can only be started while the sidecar has no fabric.\",\"sidecar_not_initialized\":\"The sidecar has no healthy fabric to accept.\",\"insecure_transport\":\"The connection to the sidecar is plain HTTP to another machine. Backups and restores carry fabric secrets, so they need https or a sidecar on this machine.\",\"recovery_key_exists\":\"A recovery key already exists.\",\"recovery_key_mismatch\":\"That is no longer the current recovery key. Reload the page.\",\"no_recovery_key\":\"There is no recovery key yet. Generate one first.\",\"not_found\":\"This backup no longer exists.\",\"file_unreadable\":\"The file could not be read. Choose it again.\",\"validation_expired\":\"This check has expired. Validate the backup again.\",\"preflight_changed\":\"The sidecar changed since the backup was checked. Validate the backup again.\",\"confirmation_required\":\"Type the fabric ID to confirm.\",\"pre_restore_backup_failed\":\"The backup of the current fabric failed, so nothing was restored. Your installation was left unchanged.\",\"restore_failed\":\"The Matter sidecar could not apply or verify the backup. Your installation was left unchanged.\",\"rolled_back\":\"The restore failed and was rolled back. Your installation was left unchanged.\",\"rollback_failed\":\"The restore failed and the Matter sidecar could not be rolled back automatically, so its state is unknown. Check the sidecar, then restore the backup again.\",\"http\":\"The request failed (HTTP {{status}}).\"},\"blocked\":{\"unreachable\":\"The sidecar is not reachable.\",\"recovery\":\"Not available while the fabric needs recovery.\",\"noFabric\":\"There is no fabric to back up yet.\",\"noKey\":\"Generate a recovery key first.\",\"insecure\":\"Needs https or a sidecar on this machine: the connection is plain HTTP to another machine.\"},\"state\":{\"initialized\":\"Initialized\",\"uninitialized\":\"No fabric yet\",\"recovery_required\":\"Recovery required\",\"unknown\":\"Unknown\"},\"unreachable\":\"Sidecar not reachable\",\"unreachableText\":\"The fabric state is unknown until the plugin is connected to the sidecar.\",\"recoveryRequired\":\"The fabric does not match this installation\",\"recorded\":\"What Attraccess recorded\",\"storageReason\":{\"storage_unreadable\":\"The sidecar cannot read its storage.\",\"storage_corrupt\":\"The sidecar's storage is damaged.\",\"storage_incomplete\":\"The sidecar's storage is incomplete.\",\"schema_mismatch\":\"The sidecar's storage has a different schema version.\",\"metadata_missing\":\"The sidecar's storage metadata is missing.\",\"metadata_orphaned\":\"The sidecar's storage metadata has no fabric data.\",\"restore_interrupted\":\"A restore was interrupted. The previous storage was kept; restore a backup.\"},\"mismatch\":{\"unknown\":\"The sidecar's fabric differs from what Attraccess recorded.\",\"sidecar_uninitialized\":\"Attraccess knows a fabric, but the sidecar has none. Its storage was probably lost or replaced.\",\"fabric_changed\":\"The sidecar runs a different fabric than the one Attraccess recorded.\",\"generation_behind\":\"The sidecar's fabric is older than what Attraccess recorded. Its storage was probably restored from an old copy.\",\"generation_ahead\":\"The sidecar's fabric is newer than what Attraccess recorded. The sidecar changed without Attraccess.\",\"storage_instance_changed\":\"The sidecar's storage is a different instance than the one Attraccess recorded.\",\"sidecar_recovery_required\":\"The sidecar reports that it needs recovery.\"},\"uninitializedText\":\"The sidecar has no fabric yet. Create it to start commissioning devices.\",\"create\":\"Create fabric\",\"createHint\":\"Creates the Matter fabric on the sidecar, a recovery key and the first backup.\",\"restoreInstead\":\"Do you already have a backup of a Matter fabric, for example after reinstalling? Restore it instead of creating a new fabric, so devices stay controllable.\",\"createError\":\"The fabric could not be created\",\"fabricId\":\"Fabric ID\",\"generationLabel\":\"Fabric generation\",\"generation\":\"generation {{generation}}\",\"fingerprint\":\"Root certificate fingerprint\",\"fingerprintShowFull\":\"Show full fingerprint\",\"fingerprintShowShort\":\"Shorten fingerprint\",\"storageInstance\":\"Storage instance\",\"trigger\":{\"manual\":\"Manual\",\"fabric_created\":\"Fabric created\",\"restore\":\"After restore\",\"daily\":\"Daily\",\"fabric_changed\":\"Fabric changed\",\"pre_restore\":\"Before restore\"},\"key\":{\"cardTitle\":\"Recovery key\",\"title\":\"Your recovery key\",\"warningTitle\":\"Shown only once\",\"warning\":\"This key decrypts your backups. Without it, a backup cannot be restored. Attraccess cannot show it again. Store it somewhere safe, apart from the backups.\",\"keyId\":\"Key ID\",\"created\":\"Created\",\"copy\":\"Copy\",\"copied\":\"Copied\",\"copyFailed\":\"Copying failed. Select the key and copy it manually.\",\"download\":\"Download as .txt\",\"fileHeader\":\"Attraccess Matter recovery key. Keep it secret and safe.\",\"acknowledge\":\"I have stored the recovery key in a safe place.\",\"done\":\"Done\",\"missing\":\"No recovery key\",\"missingText\":\"Backups are encrypted with a recovery key. Generate one to enable backups.\",\"generate\":\"Generate recovery key\",\"generateError\":\"The recovery key could not be generated\",\"unacknowledged\":\"Recovery key not confirmed\",\"unacknowledgedText\":\"A recovery key was generated, but you did not confirm that you stored it. It cannot be shown again. Rotate it to get a new one.\",\"rotate\":\"Rotate recovery key\",\"rotateTitle\":\"Rotate the recovery key?\",\"rotateText\":\"A new key encrypts future backups. Existing backups still need the old key, so keep it until they are replaced. The new key is shown once.\",\"rotateConfirm\":\"Rotate\",\"rotateError\":\"The recovery key could not be rotated\"},\"backups\":{\"title\":\"Backups\",\"lastSuccessful\":\"Last successful backup\",\"never\":\"Never\",\"lastAttempt\":\"Last attempt\",\"nextRun\":\"Next scheduled run\",\"outcome\":{\"succeeded\":\"succeeded\",\"failed\":\"failed\"},\"failed\":\"The last backup failed\",\"reason\":{\"inconsistent\":\"The sidecar and the plugin disagree about the fabric, so no consistent backup can be made.\",\"sidecar_unavailable\":\"The Matter sidecar could not be reached.\",\"sidecar_busy\":\"The Matter sidecar is busy with another backup or restore. Try again shortly.\",\"insecure_transport\":\"Backups are refused over a plain HTTP connection to a remote sidecar. Use https or a local connection.\",\"no_recovery_key\":\"There is no recovery key yet.\",\"recovery_key_unreadable\":\"The stored recovery key cannot be read by this installation.\",\"recovery_required\":\"The fabric needs recovery first. No backup is made in this state.\",\"no_fabric\":\"There is no fabric to back up.\",\"sidecar_error\":\"The Matter sidecar could not produce a snapshot.\",\"internal\":\"The backup failed because of an internal error.\"},\"noReason\":\"No reason was reported.\",\"now\":\"Back up now\",\"error\":\"The backup failed\",\"empty\":\"No backups stored yet.\",\"stored\":\"Stored backups\",\"download\":\"Download\",\"downloadError\":\"The backup could not be downloaded\",\"retention\":\"The latest {{count}} backups are kept. Backup files are encrypted and need the recovery key to restore.\",\"inconsistentMark\":\"taken during recovery\"},\"restore\":{\"open\":\"Restore from backup\",\"title\":\"Restore from backup\",\"intro\":\"Validate a backup first. Nothing changes until you confirm.\",\"source\":\"Backup source\",\"fromStored\":\"Stored backup\",\"fromUpload\":\"Upload a file\",\"file\":\"Backup file (.attraccess-matter-backup)\",\"recoveryKey\":\"Recovery key\",\"recoveryKeyHint\":\"The key this backup was encrypted with.\",\"validate\":\"Validate\",\"validationFailed\":\"The backup cannot be restored\",\"error\":{\"empty\":\"The file is empty. Choose the backup file you downloaded.\",\"tooLarge\":\"The file is too large to upload here (at most 7 MB). Restore from a stored backup instead.\"},\"kind\":{\"plain\":\"Restore\",\"rollback\":\"Roll back to an earlier state\",\"replacement\":\"Replaces the current fabric\"},\"backupCreated\":\"Backup created\",\"pluginVersion\":\"Plugin version\",\"sidecarVersion\":\"Sidecar version\",\"backupFabric\":\"Backup fabric ID\",\"currentFabric\":\"Current fabric ID\",\"previewHint\":\"The backup is valid. Restoring replaces the fabric and the plugin's Matter data with the backup.\",\"previewHintBackup\":\"A backup of the current state is taken first.\",\"overwriteTitle\":\"This overwrites a working fabric\",\"overwriteText\":\"The sidecar currently runs a healthy fabric. Restoring replaces it. Devices commissioned after the backup was made will be lost and must be commissioned again.\",\"typeFabricId\":\"Type the current fabric ID {{fabricId}} to confirm\",\"confirm\":\"Restore now\",\"running\":\"Restoring. Do not close this page.\",\"successTitle\":\"Restore completed\",\"successText\":\"The fabric and the plugin data were restored and verified.\",\"failedTitle\":\"The restore failed\",\"fromStoredHint\":\"One of the backups this installation keeps.\",\"fromUploadHint\":\"A backup file you downloaded, for example after reinstalling.\",\"retryTitle\":\"Validate the backup again\",\"rollbackFailedTitle\":\"The restore failed and could not be rolled back\",\"inconsistentTitle\":\"This backup was taken during recovery\",\"inconsistentText\":\"When it was taken, the plugin's data and the sidecar's fabric did not match. Restoring it brings that mismatch back, and you will have to settle the recovery again afterwards.\"},\"recovery\":{\"title\":\"Recovery\",\"blocked\":\"Fabric changes are blocked\",\"blockedText\":\"Until you choose how to recover, creating a fabric and other fabric changes are blocked. Nothing is changed automatically.\",\"restoreTitle\":\"Restore from a backup\",\"restoreText\":\"Bring back the fabric and data from a stored or uploaded backup.\",\"restoreAction\":\"Restore from backup\",\"acceptTitle\":\"Use the sidecar's current fabric\",\"acceptText\":\"Treat the fabric the sidecar runs now as the correct one.\",\"acceptUnavailable\":\"Only available while the sidecar runs a healthy fabric.\",\"acceptAction\":\"Accept sidecar's fabric\",\"acceptConfirmTitle\":\"Accept the sidecar's fabric?\",\"acceptConfirmText\":\"Attraccess will treat the sidecar's current fabric as authoritative and forget what it recorded before. Devices tied to the old fabric are no longer controllable.\",\"acceptConfirm\":\"Accept\",\"newTitle\":\"Start a new fabric\",\"newText\":\"Create a new, empty fabric.\",\"newUnavailable\":\"Only available while the sidecar has no fabric.\",\"newAction\":\"Start new fabric\",\"newConfirmTitle\":\"Start a new fabric?\",\"newConfirmText\":\"Every device commissioned before must be factory-reset and commissioned again, because it belongs to the old fabric. This cannot be undone.\",\"newConfirm\":\"Start new fabric\",\"error\":\"The recovery action failed\"}}")
|
|
73
|
+
};
|
|
74
|
+
var de_default = {
|
|
75
|
+
page: {
|
|
76
|
+
"title": "Matter",
|
|
77
|
+
"subtitle": "Verbindung zum Matter-Sidecar.",
|
|
78
|
+
"insecure": "Unsichere Verbindung",
|
|
79
|
+
"insecureText": "Der Sidecar wird über unverschlüsseltes http an einer Nicht-Loopback-Adresse erreicht. Das Token wird unverschlüsselt übertragen. Verwende https oder betreibe den Sidecar auf demselben Host."
|
|
80
|
+
},
|
|
81
|
+
status: {
|
|
82
|
+
"title": "Verbindungsstatus",
|
|
83
|
+
"state": {
|
|
84
|
+
"not_configured": "Nicht konfiguriert",
|
|
85
|
+
"connecting": "Verbindung wird aufgebaut",
|
|
86
|
+
"connected": "Verbunden",
|
|
87
|
+
"degraded": "Eingeschränkt"
|
|
88
|
+
},
|
|
89
|
+
"reason": {
|
|
90
|
+
"unavailable": "Nicht erreichbar",
|
|
91
|
+
"unauthorized": "Nicht autorisiert",
|
|
92
|
+
"incompatible": "Inkompatibel",
|
|
93
|
+
"misconfigured": "Falsch konfiguriert"
|
|
94
|
+
},
|
|
95
|
+
"since": "Seit",
|
|
96
|
+
"lastError": "Letzter Fehler",
|
|
97
|
+
"correlationId": "Korrelations-ID",
|
|
98
|
+
"nextRetry": "Nächster Versuch",
|
|
99
|
+
"sidecarVersion": "Sidecar",
|
|
100
|
+
"matterJsVersion": "matter.js",
|
|
101
|
+
"wireVersion": "Wire-Version",
|
|
102
|
+
"received": "Empfangen",
|
|
103
|
+
"supported": "Unterstützte Kombination",
|
|
104
|
+
"combination": "Attraccess {{attraccess}}, Plugin {{plugin}}, Sidecar {{sidecar}}, matter.js {{matterJs}}",
|
|
105
|
+
"loadError": "Der Status konnte nicht geladen werden."
|
|
106
|
+
},
|
|
107
|
+
hint: {
|
|
108
|
+
"not_configured": "Gib unten die Sidecar-URL und das Token ein, um die Verbindung herzustellen.",
|
|
109
|
+
"connecting": "Verbindung zum Matter-Sidecar wird aufgebaut…",
|
|
110
|
+
"connected": "Das Plugin ist mit dem Matter-Sidecar verbunden.",
|
|
111
|
+
"unavailable": "Der Sidecar ist nicht erreichbar. Prüfe, ob er läuft und ob URL, Port und Firewall stimmen. Attraccess versucht es automatisch erneut.",
|
|
112
|
+
"unauthorized": "Der Sidecar hat das Token abgelehnt. Prüfe das Token (auch nach einer Rotation) und gib es erneut ein.",
|
|
113
|
+
"incompatible": "Die Versionen passen nicht zusammen. Bringe Attraccess, das Matter-Plugin oder den Sidecar per Update oder Downgrade auf die unten gezeigte unterstützte Kombination.",
|
|
114
|
+
"misconfigured": "URL, CA-Zertifikat oder TLS-Einrichtung sind ungültig. Prüfe URL und Pfadpräfix sowie, ob die CA zum Sidecar-Zertifikat passt.",
|
|
115
|
+
"hostVersion": "Diese Attraccess-Version meldet ihre Version nicht. Aktualisiere Attraccess auf {{attraccess}} oder neuer."
|
|
116
|
+
},
|
|
117
|
+
form: {
|
|
118
|
+
"title": "Verbindungseinstellungen",
|
|
119
|
+
"url": "Sidecar-URL",
|
|
120
|
+
"urlPlaceholder": "http://127.0.0.1:8581",
|
|
121
|
+
"urlDescription": "Verwende https, außer der Sidecar läuft auf demselben Host. Ein Pfadpräfix für einen Reverse-Proxy ist erlaubt.",
|
|
122
|
+
"credential": "Token",
|
|
123
|
+
"credentialDescription": "Das gemeinsame Service-Token, das am Sidecar konfiguriert ist. Nach dem Speichern wird es nie wieder angezeigt.",
|
|
124
|
+
"credentialConfigured": "Konfiguriert (zuletzt geändert {{time}})",
|
|
125
|
+
"replace": "Ersetzen",
|
|
126
|
+
"cancelReplace": "Aktuelles Token behalten",
|
|
127
|
+
"ca": "CA-Zertifikat (optional)",
|
|
128
|
+
"caDescription": "PEM-Zertifikat(e) einer privaten CA. Node.js vertraut ihnen zusätzlich zu seinen Standard-Stammzertifikaten, nicht an deren Stelle.",
|
|
129
|
+
"caClear": "CA-Zertifikat löschen",
|
|
130
|
+
"caCleared": "Das CA-Zertifikat wird beim Speichern entfernt.",
|
|
131
|
+
"save": "Speichern",
|
|
132
|
+
"remove": "Konfiguration entfernen",
|
|
133
|
+
"saved": "Gespeichert",
|
|
134
|
+
"savedText": "Die Verbindungseinstellungen wurden gespeichert. Das Plugin verbindet sich jetzt neu.",
|
|
135
|
+
"saveError": "Speichern fehlgeschlagen",
|
|
136
|
+
"removeTitle": "Matter-Verbindung entfernen?",
|
|
137
|
+
"removeText": "URL und Token werden gelöscht und das Plugin trennt die Verbindung zum Sidecar.",
|
|
138
|
+
"removeConfirm": "Entfernen",
|
|
139
|
+
"removeError": "Entfernen fehlgeschlagen",
|
|
140
|
+
"loadError": "Die Verbindungseinstellungen konnten nicht geladen werden."
|
|
141
|
+
},
|
|
142
|
+
fabric: /* @__PURE__ */ JSON.parse("{\"title\":\"Fabric & Backup\",\"statusTitle\":\"Fabric\",\"loadError\":\"Der Fabric-Status konnte nicht geladen werden.\",\"none\":\"-\",\"cancel\":\"Abbrechen\",\"close\":\"Schließen\",\"reason\":\"Grund\",\"loading\":\"Fabric-Status wird geladen\",\"error\":{\"key_required\":\"Dieses Backup wurde mit einem anderen Wiederherstellungsschlüssel verschlüsselt. Gib diesen Schlüssel ein.\",\"wrong_key\":\"Der Wiederherstellungsschlüssel ist falsch. Prüfe ihn und versuche es erneut.\",\"corrupt\":\"Das Backup ist beschädigt oder wurde verändert und kann nicht verwendet werden.\",\"truncated\":\"Das Backup ist unvollständig, vermutlich wurde die Datei abgeschnitten. Lade es erneut herunter.\",\"incompatible_format\":\"Diese Datei ist kein Backup in einem unterstützten Format.\",\"incompatible_schema\":\"Das Backup nutzt eine Speicherschema-Version, die diese Installation nicht wiederherstellen kann.\",\"incompatible_migration\":\"Das Backup wurde mit einer anderen Plugin-Datenbankversion erstellt. Installiere die Plugin-Version, die es erstellt hat.\",\"incompatible_version\":\"Die Plugin-Version muss mit der Version übereinstimmen, die das Backup erstellt hat. Installiere zuerst diese Version.\",\"stage_failed\":\"Der Sidecar konnte das Backup nicht vorbereiten. Deine Installation blieb unverändert.\",\"fabric_exists\":\"Der Sidecar hat bereits eine Fabric.\",\"recovery_required\":\"Die Fabric muss zuerst wiederhergestellt werden. Stelle ein Backup wieder her, übernimm die Fabric des Sidecars oder starte eine neue Fabric.\",\"recovery_not_required\":\"Die Fabric muss nicht mehr wiederhergestellt werden.\",\"busy\":\"Der Matter-Sidecar ist mit einem anderen Backup oder einer Wiederherstellung beschäftigt. Versuche es gleich noch einmal.\",\"sidecar_unavailable\":\"Der Sidecar ist nicht erreichbar. Versuche es erneut, sobald er verbunden ist.\",\"sidecar_error\":\"Der Matter-Sidecar hat die Anfrage abgelehnt.\",\"sidecar_not_empty\":\"Eine neue Fabric kann nur gestartet werden, solange der Sidecar keine Fabric hat.\",\"sidecar_not_initialized\":\"Der Sidecar hat keine gesunde Fabric, die übernommen werden könnte.\",\"insecure_transport\":\"Die Verbindung zum Sidecar ist unverschlüsseltes HTTP zu einem anderen Rechner. Backups und Wiederherstellungen enthalten Fabric-Geheimnisse und brauchen daher https oder einen Sidecar auf diesem Rechner.\",\"recovery_key_exists\":\"Es gibt bereits einen Wiederherstellungsschlüssel.\",\"recovery_key_mismatch\":\"Das ist nicht mehr der aktuelle Wiederherstellungsschlüssel. Lade die Seite neu.\",\"no_recovery_key\":\"Es gibt noch keinen Wiederherstellungsschlüssel. Erzeuge zuerst einen.\",\"not_found\":\"Dieses Backup existiert nicht mehr.\",\"file_unreadable\":\"Die Datei konnte nicht gelesen werden. Wähle sie erneut aus.\",\"validation_expired\":\"Diese Prüfung ist abgelaufen. Prüfe das Backup erneut.\",\"preflight_changed\":\"Der Sidecar hat sich seit der Prüfung des Backups verändert. Prüfe das Backup erneut.\",\"confirmation_required\":\"Gib zur Bestätigung die Fabric-ID ein.\",\"pre_restore_backup_failed\":\"Das Backup der aktuellen Fabric ist fehlgeschlagen, daher wurde nichts wiederhergestellt. Deine Installation blieb unverändert.\",\"restore_failed\":\"Der Matter-Sidecar konnte das Backup nicht anwenden oder prüfen. Deine Installation blieb unverändert.\",\"rolled_back\":\"Die Wiederherstellung ist fehlgeschlagen und wurde zurückgerollt. Deine Installation blieb unverändert.\",\"rollback_failed\":\"Die Wiederherstellung ist fehlgeschlagen und der Matter-Sidecar konnte nicht automatisch zurückgerollt werden, sein Zustand ist daher unbekannt. Prüfe den Sidecar und stelle das Backup dann erneut wieder her.\",\"http\":\"Die Anfrage ist fehlgeschlagen (HTTP {{status}}).\"},\"blocked\":{\"unreachable\":\"Der Sidecar ist nicht erreichbar.\",\"recovery\":\"Nicht verfügbar, solange die Fabric wiederhergestellt werden muss.\",\"noFabric\":\"Es gibt noch keine Fabric, die gesichert werden könnte.\",\"noKey\":\"Erzeuge zuerst einen Wiederherstellungsschlüssel.\",\"insecure\":\"Braucht https oder einen Sidecar auf diesem Rechner: Die Verbindung ist unverschlüsseltes HTTP zu einem anderen Rechner.\"},\"state\":{\"initialized\":\"Initialisiert\",\"uninitialized\":\"Noch keine Fabric\",\"recovery_required\":\"Wiederherstellung erforderlich\",\"unknown\":\"Unbekannt\"},\"unreachable\":\"Sidecar nicht erreichbar\",\"unreachableText\":\"Der Fabric-Zustand ist unbekannt, bis das Plugin mit dem Sidecar verbunden ist.\",\"recoveryRequired\":\"Die Fabric passt nicht zu dieser Installation\",\"recorded\":\"Von Attraccess gespeichert\",\"storageReason\":{\"storage_unreadable\":\"Der Sidecar kann seinen Speicher nicht lesen.\",\"storage_corrupt\":\"Der Speicher des Sidecars ist beschädigt.\",\"storage_incomplete\":\"Der Speicher des Sidecars ist unvollständig.\",\"schema_mismatch\":\"Der Speicher des Sidecars hat eine andere Schemaversion.\",\"metadata_missing\":\"Die Metadaten im Speicher des Sidecars fehlen.\",\"metadata_orphaned\":\"Die Metadaten im Speicher des Sidecars haben keine Fabric-Daten.\",\"restore_interrupted\":\"Eine Wiederherstellung wurde unterbrochen. Der vorherige Speicher blieb erhalten; stelle ein Backup wieder her.\"},\"mismatch\":{\"unknown\":\"Die Fabric des Sidecars weicht von der in Attraccess gespeicherten ab.\",\"sidecar_uninitialized\":\"Attraccess kennt eine Fabric, der Sidecar hat aber keine. Sein Speicher ging vermutlich verloren oder wurde ersetzt.\",\"fabric_changed\":\"Der Sidecar betreibt eine andere Fabric als die in Attraccess gespeicherte.\",\"generation_behind\":\"Die Fabric des Sidecars ist älter als die in Attraccess gespeicherte. Sein Speicher wurde vermutlich aus einer alten Kopie wiederhergestellt.\",\"generation_ahead\":\"Die Fabric des Sidecars ist neuer als die in Attraccess gespeicherte. Der Sidecar wurde ohne Attraccess verändert.\",\"storage_instance_changed\":\"Der Speicher des Sidecars ist eine andere Instanz als die in Attraccess gespeicherte.\",\"sidecar_recovery_required\":\"Der Sidecar meldet, dass er wiederhergestellt werden muss.\"},\"uninitializedText\":\"Der Sidecar hat noch keine Fabric. Lege sie an, um Geräte einzubinden.\",\"create\":\"Fabric anlegen\",\"createHint\":\"Legt die Matter-Fabric auf dem Sidecar, einen Wiederherstellungsschlüssel und das erste Backup an.\",\"restoreInstead\":\"Hast du schon ein Backup einer Matter-Fabric, zum Beispiel nach einer Neuinstallation? Stelle es wieder her, statt eine neue Fabric anzulegen, damit die Geräte steuerbar bleiben.\",\"createError\":\"Die Fabric konnte nicht angelegt werden\",\"fabricId\":\"Fabric-ID\",\"generationLabel\":\"Fabric-Generation\",\"generation\":\"Generation {{generation}}\",\"fingerprint\":\"Fingerabdruck des Root-Zertifikats\",\"fingerprintShowFull\":\"Ganzen Fingerabdruck zeigen\",\"fingerprintShowShort\":\"Fingerabdruck kürzen\",\"storageInstance\":\"Speicher-Instanz\",\"trigger\":{\"manual\":\"Manuell\",\"fabric_created\":\"Fabric angelegt\",\"restore\":\"Nach Wiederherstellung\",\"daily\":\"Täglich\",\"fabric_changed\":\"Fabric geändert\",\"pre_restore\":\"Vor Wiederherstellung\"},\"key\":{\"cardTitle\":\"Wiederherstellungsschlüssel\",\"title\":\"Dein Wiederherstellungsschlüssel\",\"warningTitle\":\"Wird nur einmal angezeigt\",\"warning\":\"Dieser Schlüssel entschlüsselt deine Backups. Ohne ihn lässt sich kein Backup wiederherstellen. Attraccess kann ihn nicht erneut anzeigen. Bewahre ihn sicher und getrennt von den Backups auf.\",\"keyId\":\"Schlüssel-ID\",\"created\":\"Erstellt\",\"copy\":\"Kopieren\",\"copied\":\"Kopiert\",\"copyFailed\":\"Kopieren fehlgeschlagen. Markiere den Schlüssel und kopiere ihn manuell.\",\"download\":\"Als .txt herunterladen\",\"fileHeader\":\"Attraccess Matter Wiederherstellungsschlüssel. Geheim und sicher aufbewahren.\",\"acknowledge\":\"Ich habe den Wiederherstellungsschlüssel sicher aufbewahrt.\",\"done\":\"Fertig\",\"missing\":\"Kein Wiederherstellungsschlüssel\",\"missingText\":\"Backups werden mit einem Wiederherstellungsschlüssel verschlüsselt. Erzeuge einen, um Backups zu aktivieren.\",\"generate\":\"Wiederherstellungsschlüssel erzeugen\",\"generateError\":\"Der Wiederherstellungsschlüssel konnte nicht erzeugt werden\",\"unacknowledged\":\"Wiederherstellungsschlüssel nicht bestätigt\",\"unacknowledgedText\":\"Es wurde ein Wiederherstellungsschlüssel erzeugt, aber du hast nicht bestätigt, ihn gesichert zu haben. Er kann nicht erneut angezeigt werden. Rotiere ihn, um einen neuen zu erhalten.\",\"rotate\":\"Wiederherstellungsschlüssel rotieren\",\"rotateTitle\":\"Wiederherstellungsschlüssel rotieren?\",\"rotateText\":\"Ein neuer Schlüssel verschlüsselt künftige Backups. Bestehende Backups brauchen weiterhin den alten Schlüssel, bewahre ihn also auf, bis sie ersetzt sind. Der neue Schlüssel wird einmal angezeigt.\",\"rotateConfirm\":\"Rotieren\",\"rotateError\":\"Der Wiederherstellungsschlüssel konnte nicht rotiert werden\"},\"backups\":{\"title\":\"Backups\",\"lastSuccessful\":\"Letztes erfolgreiches Backup\",\"never\":\"Nie\",\"lastAttempt\":\"Letzter Versuch\",\"nextRun\":\"Nächster geplanter Lauf\",\"outcome\":{\"succeeded\":\"erfolgreich\",\"failed\":\"fehlgeschlagen\"},\"failed\":\"Das letzte Backup ist fehlgeschlagen\",\"reason\":{\"inconsistent\":\"Sidecar und Plugin sind sich über die Fabric nicht einig, daher ist kein konsistentes Backup möglich.\",\"sidecar_unavailable\":\"Der Matter-Sidecar ist nicht erreichbar.\",\"sidecar_busy\":\"Der Matter-Sidecar ist mit einem anderen Backup oder einer Wiederherstellung beschäftigt. Versuche es gleich noch einmal.\",\"insecure_transport\":\"Backups werden über eine unverschlüsselte HTTP-Verbindung zu einem entfernten Sidecar abgelehnt. Nutze https oder eine lokale Verbindung.\",\"no_recovery_key\":\"Es gibt noch keinen Wiederherstellungsschlüssel.\",\"recovery_key_unreadable\":\"Der gespeicherte Wiederherstellungsschlüssel kann von dieser Installation nicht gelesen werden.\",\"recovery_required\":\"Die Fabric muss zuerst wiederhergestellt werden. In diesem Zustand wird kein Backup erstellt.\",\"no_fabric\":\"Es gibt keine Fabric, die gesichert werden könnte.\",\"sidecar_error\":\"Der Matter-Sidecar konnte keinen Snapshot erstellen.\",\"internal\":\"Das Backup ist wegen eines internen Fehlers fehlgeschlagen.\"},\"noReason\":\"Es wurde kein Grund gemeldet.\",\"now\":\"Jetzt sichern\",\"error\":\"Das Backup ist fehlgeschlagen\",\"empty\":\"Noch keine Backups gespeichert.\",\"stored\":\"Gespeicherte Backups\",\"download\":\"Herunterladen\",\"downloadError\":\"Das Backup konnte nicht heruntergeladen werden\",\"retention\":\"Die letzten {{count}} Backups werden aufbewahrt. Backup-Dateien sind verschlüsselt und brauchen zur Wiederherstellung den Wiederherstellungsschlüssel.\",\"inconsistentMark\":\"während einer Wiederherstellung erstellt\"},\"restore\":{\"open\":\"Aus Backup wiederherstellen\",\"title\":\"Aus Backup wiederherstellen\",\"intro\":\"Prüfe zuerst ein Backup. Es ändert sich nichts, bevor du bestätigst.\",\"source\":\"Backup-Quelle\",\"fromStored\":\"Gespeichertes Backup\",\"fromUpload\":\"Datei hochladen\",\"file\":\"Backup-Datei (.attraccess-matter-backup)\",\"recoveryKey\":\"Wiederherstellungsschlüssel\",\"recoveryKeyHint\":\"Der Schlüssel, mit dem dieses Backup verschlüsselt wurde.\",\"validate\":\"Prüfen\",\"validationFailed\":\"Das Backup kann nicht wiederhergestellt werden\",\"error\":{\"empty\":\"Die Datei ist leer. Wähle die heruntergeladene Backup-Datei.\",\"tooLarge\":\"Die Datei ist zu groß für den Upload (höchstens 7 MB). Stelle stattdessen aus einem gespeicherten Backup wieder her.\"},\"kind\":{\"plain\":\"Wiederherstellung\",\"rollback\":\"Zurück auf einen früheren Stand\",\"replacement\":\"Ersetzt die aktuelle Fabric\"},\"backupCreated\":\"Backup erstellt\",\"pluginVersion\":\"Plugin-Version\",\"sidecarVersion\":\"Sidecar-Version\",\"backupFabric\":\"Fabric-ID im Backup\",\"currentFabric\":\"Aktuelle Fabric-ID\",\"previewHint\":\"Das Backup ist gültig. Die Wiederherstellung ersetzt die Fabric und die Matter-Daten des Plugins durch das Backup.\",\"previewHintBackup\":\"Vorher wird ein Backup des aktuellen Zustands erstellt.\",\"overwriteTitle\":\"Das überschreibt eine funktionierende Fabric\",\"overwriteText\":\"Der Sidecar betreibt aktuell eine gesunde Fabric. Die Wiederherstellung ersetzt sie. Geräte, die nach dem Backup eingebunden wurden, gehen verloren und müssen neu eingebunden werden.\",\"typeFabricId\":\"Gib zur Bestätigung die aktuelle Fabric-ID {{fabricId}} ein\",\"confirm\":\"Jetzt wiederherstellen\",\"running\":\"Wiederherstellung läuft. Schließe diese Seite nicht.\",\"successTitle\":\"Wiederherstellung abgeschlossen\",\"successText\":\"Die Fabric und die Plugin-Daten wurden wiederhergestellt und geprüft.\",\"failedTitle\":\"Die Wiederherstellung ist fehlgeschlagen\",\"fromStoredHint\":\"Eines der Backups, die diese Installation aufbewahrt.\",\"fromUploadHint\":\"Eine heruntergeladene Backup-Datei, zum Beispiel nach einer Neuinstallation.\",\"retryTitle\":\"Prüfe das Backup erneut\",\"rollbackFailedTitle\":\"Die Wiederherstellung ist fehlgeschlagen und konnte nicht zurückgerollt werden\",\"inconsistentTitle\":\"Dieses Backup wurde während einer Wiederherstellung erstellt\",\"inconsistentText\":\"Als es erstellt wurde, passten die Daten des Plugins und die Fabric des Sidecars nicht zusammen. Stellst du es wieder her, kehrt diese Abweichung zurück, und du musst die Wiederherstellung danach erneut abschließen.\"},\"recovery\":{\"title\":\"Wiederherstellung\",\"blocked\":\"Fabric-Änderungen sind gesperrt\",\"blockedText\":\"Bis du dich für einen Weg entscheidest, sind das Anlegen einer Fabric und andere Fabric-Änderungen gesperrt. Es wird nichts automatisch geändert.\",\"restoreTitle\":\"Aus einem Backup wiederherstellen\",\"restoreText\":\"Fabric und Daten aus einem gespeicherten oder hochgeladenen Backup zurückholen.\",\"restoreAction\":\"Aus Backup wiederherstellen\",\"acceptTitle\":\"Aktuelle Fabric des Sidecars verwenden\",\"acceptText\":\"Die Fabric, die der Sidecar jetzt betreibt, als korrekt übernehmen.\",\"acceptUnavailable\":\"Nur verfügbar, solange der Sidecar eine gesunde Fabric betreibt.\",\"acceptAction\":\"Fabric des Sidecars übernehmen\",\"acceptConfirmTitle\":\"Fabric des Sidecars übernehmen?\",\"acceptConfirmText\":\"Attraccess betrachtet die aktuelle Fabric des Sidecars als maßgeblich und verwirft den bisher gespeicherten Stand. Geräte der alten Fabric sind nicht mehr steuerbar.\",\"acceptConfirm\":\"Übernehmen\",\"newTitle\":\"Neue Fabric starten\",\"newText\":\"Eine neue, leere Fabric anlegen.\",\"newUnavailable\":\"Nur verfügbar, solange der Sidecar keine Fabric hat.\",\"newAction\":\"Neue Fabric starten\",\"newConfirmTitle\":\"Neue Fabric starten?\",\"newConfirmText\":\"Jedes zuvor eingebundene Gerät muss auf Werkseinstellungen zurückgesetzt und neu eingebunden werden, da es zur alten Fabric gehört. Das lässt sich nicht rückgängig machen.\",\"newConfirm\":\"Neue Fabric starten\",\"error\":\"Die Wiederherstellungsaktion ist fehlgeschlagen\"}}")
|
|
143
|
+
};
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region frontend/src/i18n.ts
|
|
146
|
+
var { useTranslations } = await importShared("@attraccess/plugins-frontend-ui");
|
|
147
|
+
var useMatterTranslations = () => useTranslations({
|
|
148
|
+
en: en_default,
|
|
149
|
+
de: de_default
|
|
150
|
+
}, { escapeValues: false });
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region ../../../libs/plugins-frontend-sdk/src/lib/frontend.api-client.ts
|
|
153
|
+
var BASE_URL_GLOBAL = "__ATTRACCESS_API_BASE_URL__";
|
|
154
|
+
/** The API origin the host is talking to. Falls back to the current origin. */
|
|
155
|
+
function getApiBaseUrl() {
|
|
156
|
+
return window[BASE_URL_GLOBAL] ?? window.location.origin;
|
|
157
|
+
}
|
|
158
|
+
/** Thrown for any non-2xx response, carrying the status for callers that branch on it. */
|
|
159
|
+
var PluginApiError = class extends Error {
|
|
160
|
+
constructor(message, status) {
|
|
161
|
+
super(message);
|
|
162
|
+
this.status = status;
|
|
163
|
+
this.name = "PluginApiError";
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
async function toError$1(res) {
|
|
167
|
+
try {
|
|
168
|
+
const body = await res.json();
|
|
169
|
+
const message = Array.isArray(body.message) ? body.message.join(", ") : body.message;
|
|
170
|
+
if (message) return new PluginApiError(message, res.status);
|
|
171
|
+
} catch {}
|
|
172
|
+
return new PluginApiError(`Request failed (HTTP ${res.status}).`, res.status);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Creates a client bound to `basePath`, which is resolved against the host's
|
|
176
|
+
* API origin. Plugin routes are mounted under `/api/<plugin-name>`, so that is
|
|
177
|
+
* the usual argument; pass nothing to address the host API directly.
|
|
178
|
+
*/
|
|
179
|
+
function createPluginApiClient(basePath = "") {
|
|
180
|
+
const url = (path, query) => {
|
|
181
|
+
const target = new URL(`${basePath}${path}`, getApiBaseUrl());
|
|
182
|
+
Object.entries(query ?? {}).forEach(([key, value]) => {
|
|
183
|
+
if (value !== void 0 && value !== null) target.searchParams.set(key, String(value));
|
|
184
|
+
});
|
|
185
|
+
return target.toString();
|
|
186
|
+
};
|
|
187
|
+
const doFetch = (path, init) => fetch(url(path), {
|
|
188
|
+
credentials: "include",
|
|
189
|
+
...init
|
|
190
|
+
});
|
|
191
|
+
return {
|
|
192
|
+
url,
|
|
193
|
+
fetch: doFetch,
|
|
194
|
+
async request(path, options = {}) {
|
|
195
|
+
const { body, query, headers, ...init } = options;
|
|
196
|
+
const res = await fetch(url(path, query), {
|
|
197
|
+
credentials: "include",
|
|
198
|
+
...init,
|
|
199
|
+
headers: body === void 0 ? headers : {
|
|
200
|
+
"Content-Type": "application/json",
|
|
201
|
+
...headers
|
|
202
|
+
},
|
|
203
|
+
body: body === void 0 ? void 0 : JSON.stringify(body)
|
|
204
|
+
});
|
|
205
|
+
if (!res.ok) throw await toError$1(res);
|
|
206
|
+
const text = await res.text();
|
|
207
|
+
return text.length > 0 ? JSON.parse(text) : null;
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region ../../../node_modules/.pnpm/react@19.2.8/node_modules/react/cjs/react-jsx-runtime.production.js
|
|
213
|
+
/**
|
|
214
|
+
* @license React
|
|
215
|
+
* react-jsx-runtime.production.js
|
|
216
|
+
*
|
|
217
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
218
|
+
*
|
|
219
|
+
* This source code is licensed under the MIT license found in the
|
|
220
|
+
* LICENSE file in the root directory of this source tree.
|
|
221
|
+
*/
|
|
222
|
+
var require_react_jsx_runtime_production = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
223
|
+
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element");
|
|
224
|
+
var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
225
|
+
function jsxProd(type, config, maybeKey) {
|
|
226
|
+
var key = null;
|
|
227
|
+
void 0 !== maybeKey && (key = "" + maybeKey);
|
|
228
|
+
void 0 !== config.key && (key = "" + config.key);
|
|
229
|
+
if ("key" in config) {
|
|
230
|
+
maybeKey = {};
|
|
231
|
+
for (var propName in config) "key" !== propName && (maybeKey[propName] = config[propName]);
|
|
232
|
+
} else maybeKey = config;
|
|
233
|
+
config = maybeKey.ref;
|
|
234
|
+
return {
|
|
235
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
236
|
+
type,
|
|
237
|
+
key,
|
|
238
|
+
ref: void 0 !== config ? config : null,
|
|
239
|
+
props: maybeKey
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
exports.Fragment = REACT_FRAGMENT_TYPE;
|
|
243
|
+
exports.jsx = jsxProd;
|
|
244
|
+
exports.jsxs = jsxProd;
|
|
245
|
+
}));
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region ../../../libs/plugins-frontend-sdk/src/lib/frontend.live-updates.tsx
|
|
248
|
+
var import_jsx_runtime = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
249
|
+
module.exports = require_react_jsx_runtime_production();
|
|
250
|
+
})))();
|
|
251
|
+
var { createContext, useCallback: useCallback$4, useContext, useEffect: useEffect$2, useRef: useRef$2 } = await importShared("react");
|
|
252
|
+
var contextKey = Symbol.for("attraccess.plugin.live-updates.context");
|
|
253
|
+
var contexts = globalThis;
|
|
254
|
+
contexts[contextKey] ??= createContext(null);
|
|
255
|
+
var identityKey = Symbol.for("attraccess.plugin.live-updates.identity");
|
|
256
|
+
var identities = globalThis;
|
|
257
|
+
identities[identityKey] ??= createContext(null);
|
|
258
|
+
//#endregion
|
|
259
|
+
//#region ../../../libs/plugins-frontend-sdk/src/lib/frontend.standard-drawer.tsx
|
|
260
|
+
var { StandardDrawer: SharedStandardDrawer } = await importShared("@attraccess/plugins-frontend-ui");
|
|
261
|
+
//#endregion
|
|
262
|
+
//#region ../../../libs/plugins-frontend-sdk/src/lib/frontend.standard-modal.tsx
|
|
263
|
+
var { StandardModal: SharedStandardModal } = await importShared("@attraccess/plugins-frontend-ui");
|
|
264
|
+
//#endregion
|
|
265
|
+
//#region frontend/src/fabric-backup/api.ts
|
|
266
|
+
/**
|
|
267
|
+
* An error response with the machine-readable `code` the backend sends next to its (English) message. The UI shows
|
|
268
|
+
* the translation of the code; the message is only a fallback and is empty when the response had none.
|
|
269
|
+
*/
|
|
270
|
+
var FabricApiError = class extends Error {
|
|
271
|
+
constructor(message, status, code) {
|
|
272
|
+
super(message);
|
|
273
|
+
this.status = status;
|
|
274
|
+
this.code = code;
|
|
275
|
+
this.name = "FabricApiError";
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
var client = createPluginApiClient("/api/matter");
|
|
279
|
+
async function toError(response) {
|
|
280
|
+
try {
|
|
281
|
+
const body = await response.json();
|
|
282
|
+
return new FabricApiError((Array.isArray(body.message) ? body.message.join(", ") : body.message) ?? "", response.status, body.code ?? null);
|
|
283
|
+
} catch {
|
|
284
|
+
return new FabricApiError("", response.status, null);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
async function call(path, method = "GET", body) {
|
|
288
|
+
const response = await client.fetch(path, {
|
|
289
|
+
method,
|
|
290
|
+
headers: body === void 0 ? void 0 : { "Content-Type": "application/json" },
|
|
291
|
+
body: body === void 0 ? void 0 : JSON.stringify(body)
|
|
292
|
+
});
|
|
293
|
+
if (!response.ok) throw await toError(response);
|
|
294
|
+
const text = await response.text();
|
|
295
|
+
return text.length > 0 ? JSON.parse(text) : null;
|
|
296
|
+
}
|
|
297
|
+
var getFabricStatus = () => call("/fabric");
|
|
298
|
+
var createFabric = () => call("/fabric/create", "POST", {});
|
|
299
|
+
var generateRecoveryKey = () => call("/fabric/recovery-key", "POST", {});
|
|
300
|
+
var acknowledgeRecoveryKey = (keyId) => call("/fabric/recovery-key/acknowledge", "POST", { keyId });
|
|
301
|
+
var rotateRecoveryKey = () => call("/fabric/recovery-key/rotate", "POST", { confirm: true });
|
|
302
|
+
var backUpNow = () => call("/backups", "POST", {});
|
|
303
|
+
var validateRestore = (source, recoveryKey) => call("/restore/validate", "POST", {
|
|
304
|
+
source,
|
|
305
|
+
...recoveryKey ? { recoveryKey } : {}
|
|
306
|
+
});
|
|
307
|
+
var confirmRestore = (validationId, confirmFabricId) => call("/restore/confirm", "POST", {
|
|
308
|
+
validationId,
|
|
309
|
+
...confirmFabricId ? { confirmFabricId } : {}
|
|
310
|
+
});
|
|
311
|
+
var cancelRestore = (validationId) => call(`/restore/${encodeURIComponent(validationId)}/cancel`, "POST", {});
|
|
312
|
+
var acceptSidecarFabric = () => call("/recovery/accept-sidecar", "POST", { confirm: true });
|
|
313
|
+
var startNewFabric = () => call("/recovery/start-new", "POST", { confirm: true });
|
|
314
|
+
/** Downloads the encrypted backup file through the authenticated session and hands it to the browser. */
|
|
315
|
+
async function downloadBackup(id) {
|
|
316
|
+
const response = await client.fetch(`/backups/${encodeURIComponent(id)}/download`);
|
|
317
|
+
if (!response.ok) throw await toError(response);
|
|
318
|
+
const disposition = response.headers.get("Content-Disposition") ?? "";
|
|
319
|
+
const filename = /filename="?([^";]+)"?/.exec(disposition)?.[1] ?? `attraccess-matter-${id}.attraccess-matter-backup`;
|
|
320
|
+
saveBlob(await response.blob(), filename);
|
|
321
|
+
}
|
|
322
|
+
function saveBlob(blob, filename) {
|
|
323
|
+
const url = URL.createObjectURL(blob);
|
|
324
|
+
const link = document.createElement("a");
|
|
325
|
+
link.href = url;
|
|
326
|
+
link.download = filename;
|
|
327
|
+
document.body.appendChild(link);
|
|
328
|
+
link.click();
|
|
329
|
+
link.remove();
|
|
330
|
+
URL.revokeObjectURL(url);
|
|
331
|
+
}
|
|
332
|
+
/** Reads a file as base64 (without the data-URL prefix). */
|
|
333
|
+
function readFileAsBase64(file) {
|
|
334
|
+
return new Promise((resolve, reject) => {
|
|
335
|
+
const reader = new FileReader();
|
|
336
|
+
reader.onerror = () => reject(new FabricApiError("", 0, "file_unreadable"));
|
|
337
|
+
reader.onload = () => {
|
|
338
|
+
const result = String(reader.result ?? "");
|
|
339
|
+
resolve(result.slice(result.indexOf(",") + 1));
|
|
340
|
+
};
|
|
341
|
+
reader.readAsDataURL(file);
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
//#endregion
|
|
345
|
+
//#region frontend/src/fabric-backup/blockers.ts
|
|
346
|
+
/**
|
|
347
|
+
* Why "Back up now" is disabled. The backend allows it for a reachable, initialized fabric outside recovery with a
|
|
348
|
+
* recovery key over a secure connection; the status does not carry the transport, so that is what remains.
|
|
349
|
+
*/
|
|
350
|
+
function backupBlocker({ actions, sidecar, recovery, recoveryKey }) {
|
|
351
|
+
if (actions.canBackup) return null;
|
|
352
|
+
if (!sidecar.reachable) return "unreachable";
|
|
353
|
+
if (recovery.required) return "recovery";
|
|
354
|
+
if (sidecar.state !== "initialized") return "noFabric";
|
|
355
|
+
return recoveryKey.present ? "insecure" : "noKey";
|
|
356
|
+
}
|
|
357
|
+
/** Why "Restore from backup" is disabled: the backend allows it whenever the sidecar is reachable over a secure link. */
|
|
358
|
+
function restoreBlocker({ actions, sidecar }) {
|
|
359
|
+
if (actions.canRestore) return null;
|
|
360
|
+
return sidecar.reachable ? "insecure" : "unreachable";
|
|
361
|
+
}
|
|
362
|
+
//#endregion
|
|
363
|
+
//#region frontend/src/fabric-backup/Field.tsx
|
|
364
|
+
/** One label/value pair of a `<dl>` in the fabric & backup section. */
|
|
365
|
+
function Field$1({ label, children }) {
|
|
366
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
367
|
+
className: "mt:flex mt:flex-col",
|
|
368
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", {
|
|
369
|
+
className: "mt:text-xs mt:text-muted",
|
|
370
|
+
children: label
|
|
371
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", {
|
|
372
|
+
className: "mt:break-all",
|
|
373
|
+
children
|
|
374
|
+
})]
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
//#endregion
|
|
378
|
+
//#region frontend/src/fabric-backup/useFormatSize.ts
|
|
379
|
+
var { useNumberFormatter } = await importShared("@attraccess/plugins-frontend-ui");
|
|
380
|
+
var { useCallback: useCallback$3 } = await importShared("react");
|
|
381
|
+
var ONE_DECIMAL = {
|
|
382
|
+
minimumFractionDigits: 1,
|
|
383
|
+
maximumFractionDigits: 1
|
|
384
|
+
};
|
|
385
|
+
var KIB = 1024;
|
|
386
|
+
var MIB = KIB * KIB;
|
|
387
|
+
/** A byte count in B, KiB or MiB, with the number formatted for the current language. */
|
|
388
|
+
function useFormatSize() {
|
|
389
|
+
const formatInteger = useNumberFormatter();
|
|
390
|
+
const formatDecimal = useNumberFormatter(ONE_DECIMAL);
|
|
391
|
+
return useCallback$3((bytes) => {
|
|
392
|
+
if (bytes < KIB) return `${formatInteger(bytes)} B`;
|
|
393
|
+
if (bytes < MIB) return `${formatDecimal(bytes / KIB)} KiB`;
|
|
394
|
+
return `${formatDecimal(bytes / MIB)} MiB`;
|
|
395
|
+
}, [formatInteger, formatDecimal]);
|
|
396
|
+
}
|
|
397
|
+
//#endregion
|
|
398
|
+
//#region frontend/src/fabric-backup/BackupsCard.tsx
|
|
399
|
+
var { Button: Button$6, StatusAlert: StatusAlert$9 } = await importShared("@attraccess/plugins-frontend-ui");
|
|
400
|
+
var { Card: Card$4 } = await importShared("@heroui/react");
|
|
401
|
+
var downloadAction = (item) => `download:${item.id}`;
|
|
402
|
+
function LastFailure({ reason }) {
|
|
403
|
+
const { t, tExists } = useMatterTranslations();
|
|
404
|
+
const key = `fabric.backups.reason.${reason}`;
|
|
405
|
+
let text = t("fabric.backups.noReason");
|
|
406
|
+
if (reason) text = tExists(key) ? t(key) : reason;
|
|
407
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$9, {
|
|
408
|
+
status: "danger",
|
|
409
|
+
title: t("fabric.backups.failed"),
|
|
410
|
+
"data-cy": "matter-backup-failed",
|
|
411
|
+
children: text
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
/** "Back up now" and "Restore from backup", each with the reason when the current state does not allow it. */
|
|
415
|
+
function BackupActions({ status, pending, onBackup, onRestore }) {
|
|
416
|
+
const { t } = useMatterTranslations();
|
|
417
|
+
const backupBlocked = backupBlocker(status);
|
|
418
|
+
const restoreBlocked = restoreBlocker(status);
|
|
419
|
+
const hints = [.../* @__PURE__ */ new Set([backupBlocked, status.recovery.required ? null : restoreBlocked])].filter((hint) => hint !== null);
|
|
420
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
421
|
+
className: "mt:flex mt:flex-col mt:gap-1",
|
|
422
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
423
|
+
className: "mt:flex mt:flex-wrap mt:gap-2",
|
|
424
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$6, {
|
|
425
|
+
isDisabled: pending !== null || backupBlocked !== null,
|
|
426
|
+
isPending: pending === "backup",
|
|
427
|
+
onPress: onBackup,
|
|
428
|
+
"data-cy": "matter-backup-now",
|
|
429
|
+
children: t("fabric.backups.now")
|
|
430
|
+
}), !status.recovery.required && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$6, {
|
|
431
|
+
variant: "secondary",
|
|
432
|
+
isDisabled: pending !== null || restoreBlocked !== null,
|
|
433
|
+
onPress: onRestore,
|
|
434
|
+
"data-cy": "matter-restore-open",
|
|
435
|
+
children: t("fabric.restore.open")
|
|
436
|
+
})]
|
|
437
|
+
}), hints.map((hint) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
438
|
+
className: "mt:text-sm mt:text-muted",
|
|
439
|
+
"data-cy": `matter-backup-blocked-${hint}`,
|
|
440
|
+
children: t(`fabric.blocked.${hint}`)
|
|
441
|
+
}, hint))]
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
function StoredList({ status, pending, onDownload, formatDateTime }) {
|
|
445
|
+
const { t } = useMatterTranslations();
|
|
446
|
+
const formatSize = useFormatSize();
|
|
447
|
+
const { stored } = status.backups;
|
|
448
|
+
if (stored.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
449
|
+
className: "mt:text-sm mt:text-muted",
|
|
450
|
+
"data-cy": "matter-backups-empty",
|
|
451
|
+
children: t("fabric.backups.empty")
|
|
452
|
+
});
|
|
453
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
|
|
454
|
+
className: "mt:flex mt:flex-col mt:divide-y mt:divide-separator",
|
|
455
|
+
"aria-label": t("fabric.backups.stored"),
|
|
456
|
+
children: stored.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
|
|
457
|
+
className: "mt:flex mt:flex-col mt:gap-2 mt:py-2 mt:sm:flex-row mt:sm:items-center mt:sm:justify-between",
|
|
458
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: formatDateTime(item.createdAt) }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
|
|
459
|
+
className: "mt:text-xs mt:text-muted",
|
|
460
|
+
children: [
|
|
461
|
+
t(`fabric.trigger.${item.trigger}`),
|
|
462
|
+
" · ",
|
|
463
|
+
t("fabric.generation", { generation: item.fabricGeneration }),
|
|
464
|
+
" ·",
|
|
465
|
+
" ",
|
|
466
|
+
formatSize(item.sizeBytes),
|
|
467
|
+
!item.consistent && ` · ${t("fabric.backups.inconsistentMark")}`
|
|
468
|
+
]
|
|
469
|
+
})] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$6, {
|
|
470
|
+
variant: "tertiary",
|
|
471
|
+
isDisabled: pending !== null,
|
|
472
|
+
isPending: pending === downloadAction(item),
|
|
473
|
+
onPress: () => onDownload(item),
|
|
474
|
+
"data-cy": `matter-backup-download-${item.id}`,
|
|
475
|
+
children: t("fabric.backups.download")
|
|
476
|
+
})]
|
|
477
|
+
}, item.id))
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
/** Backup status (last success, last attempt, next run), the actions and the stored backups. */
|
|
481
|
+
function BackupsCard(props) {
|
|
482
|
+
const { status, formatDateTime } = props;
|
|
483
|
+
const { t } = useMatterTranslations();
|
|
484
|
+
const { sidecar, backups } = status;
|
|
485
|
+
const { lastAttempt } = backups;
|
|
486
|
+
if (!(sidecar.reachable && sidecar.state === "initialized") && backups.stored.length === 0) return null;
|
|
487
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card$4, {
|
|
488
|
+
"data-cy": "matter-backups-card",
|
|
489
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card$4.Header, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card$4.Title, { children: t("fabric.backups.title") }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card$4.Content, {
|
|
490
|
+
className: "mt:flex mt:flex-col mt:gap-4",
|
|
491
|
+
children: [
|
|
492
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("dl", {
|
|
493
|
+
className: "mt:grid mt:grid-cols-1 mt:gap-3 mt:sm:grid-cols-3",
|
|
494
|
+
children: [
|
|
495
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
|
|
496
|
+
label: t("fabric.backups.lastSuccessful"),
|
|
497
|
+
children: backups.lastSuccessfulAt ? formatDateTime(backups.lastSuccessfulAt) : t("fabric.backups.never")
|
|
498
|
+
}),
|
|
499
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
|
|
500
|
+
label: t("fabric.backups.lastAttempt"),
|
|
501
|
+
children: lastAttempt ? `${formatDateTime(lastAttempt.at)} (${t(`fabric.backups.outcome.${lastAttempt.outcome}`)})` : t("fabric.none")
|
|
502
|
+
}),
|
|
503
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
|
|
504
|
+
label: t("fabric.backups.nextRun"),
|
|
505
|
+
children: backups.nextScheduledAt ? formatDateTime(backups.nextScheduledAt) : t("fabric.none")
|
|
506
|
+
})
|
|
507
|
+
]
|
|
508
|
+
}),
|
|
509
|
+
lastAttempt?.outcome === "failed" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LastFailure, { reason: lastAttempt.reason }),
|
|
510
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(BackupActions, { ...props }),
|
|
511
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(StoredList, { ...props }),
|
|
512
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
513
|
+
className: "mt:text-xs mt:text-muted",
|
|
514
|
+
children: t("fabric.backups.retention", { count: backups.retention })
|
|
515
|
+
})
|
|
516
|
+
]
|
|
517
|
+
})]
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
//#endregion
|
|
521
|
+
//#region frontend/src/fabric-backup/errors.ts
|
|
522
|
+
var { useCallback: useCallback$2 } = await importShared("react");
|
|
523
|
+
/** The machine-readable code of a failed fabric & backup request, if the backend sent one. */
|
|
524
|
+
var codeOf = (error) => error instanceof FabricApiError ? error.code : null;
|
|
525
|
+
/** "Back up now" reports the reasons of the backup status table; the backend sends `busy` for `sidecar_busy`. */
|
|
526
|
+
var backupReasonKey = (code) => `fabric.backups.reason.${code === "busy" ? "sidecar_busy" : code}`;
|
|
527
|
+
/**
|
|
528
|
+
* The administrator-facing text of a failed request: the translation of its backend `code`, else the message the
|
|
529
|
+
* error carries (a network error, or a code this release does not know yet), else the HTTP status.
|
|
530
|
+
*/
|
|
531
|
+
function useErrorText() {
|
|
532
|
+
const { t, tExists } = useMatterTranslations();
|
|
533
|
+
return useCallback$2((error, keyOf) => {
|
|
534
|
+
const code = codeOf(error);
|
|
535
|
+
const key = code ? [keyOf?.(code), `fabric.error.${code}`].find((item) => item && tExists(item)) : void 0;
|
|
536
|
+
if (key) return t(key);
|
|
537
|
+
if (error instanceof FabricApiError) return error.message || t("fabric.error.http", { status: error.status });
|
|
538
|
+
return error instanceof Error ? error.message : String(error);
|
|
539
|
+
}, [t, tExists]);
|
|
540
|
+
}
|
|
541
|
+
//#endregion
|
|
542
|
+
//#region frontend/src/fabric-backup/FabricStatusCard.tsx
|
|
543
|
+
var { Button: Button$5, StatusAlert: StatusAlert$8 } = await importShared("@attraccess/plugins-frontend-ui");
|
|
544
|
+
var { Card: Card$3, Chip: Chip$2 } = await importShared("@heroui/react");
|
|
545
|
+
var { useState: useState$7 } = await importShared("react");
|
|
546
|
+
/** The leading and trailing hex digits are enough to tell certificates apart; the whole value is one click away. */
|
|
547
|
+
var shortFingerprint = (value) => value.length > 28 ? `${value.slice(0, 16)}…${value.slice(-8)}` : value;
|
|
548
|
+
function stateChip(status) {
|
|
549
|
+
if (status.recovery.required) return {
|
|
550
|
+
color: "danger",
|
|
551
|
+
key: "recovery_required"
|
|
552
|
+
};
|
|
553
|
+
if (!status.sidecar.reachable) return {
|
|
554
|
+
color: "default",
|
|
555
|
+
key: "unknown"
|
|
556
|
+
};
|
|
557
|
+
if (status.sidecar.state === "initialized") return {
|
|
558
|
+
color: "success",
|
|
559
|
+
key: "initialized"
|
|
560
|
+
};
|
|
561
|
+
if (status.sidecar.state === "recovery_required") return {
|
|
562
|
+
color: "danger",
|
|
563
|
+
key: "recovery_required"
|
|
564
|
+
};
|
|
565
|
+
return {
|
|
566
|
+
color: "warning",
|
|
567
|
+
key: status.sidecar.state
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
/** The shortened fingerprint, with the whole value as tooltip and behind a toggle (keyboard and touch reachable). */
|
|
571
|
+
function Fingerprint({ value }) {
|
|
572
|
+
const { t } = useMatterTranslations();
|
|
573
|
+
const [full, setFull] = useState$7(false);
|
|
574
|
+
const short = shortFingerprint(value);
|
|
575
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
576
|
+
className: "mt:flex mt:flex-wrap mt:items-center mt:gap-2",
|
|
577
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
578
|
+
title: value,
|
|
579
|
+
className: "mt:font-mono",
|
|
580
|
+
"data-cy": "matter-fabric-fingerprint",
|
|
581
|
+
children: full ? value : short
|
|
582
|
+
}), short !== value && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$5, {
|
|
583
|
+
size: "sm",
|
|
584
|
+
variant: "tertiary",
|
|
585
|
+
"aria-expanded": full,
|
|
586
|
+
onPress: () => setFull(!full),
|
|
587
|
+
"data-cy": "matter-fabric-fingerprint-toggle",
|
|
588
|
+
children: full ? t("fabric.fingerprintShowShort") : t("fabric.fingerprintShowFull")
|
|
589
|
+
})]
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
function RecoveryAlert({ status }) {
|
|
593
|
+
const { t, tExists } = useMatterTranslations();
|
|
594
|
+
const { mismatch } = status.recovery;
|
|
595
|
+
const { reason } = status.sidecar;
|
|
596
|
+
const reasonKey = `fabric.storageReason.${reason}`;
|
|
597
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StatusAlert$8, {
|
|
598
|
+
status: "danger",
|
|
599
|
+
title: t("fabric.recoveryRequired"),
|
|
600
|
+
"data-cy": "matter-fabric-mismatch",
|
|
601
|
+
children: [t(`fabric.mismatch.${mismatch ?? "unknown"}`), reason && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
602
|
+
className: "mt:mt-1 mt:block mt:text-sm",
|
|
603
|
+
children: [
|
|
604
|
+
t("fabric.reason"),
|
|
605
|
+
": ",
|
|
606
|
+
tExists(reasonKey) ? t(reasonKey) : reason
|
|
607
|
+
]
|
|
608
|
+
})]
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
/** Create the fabric, or restore one instead, on a connected sidecar without a fabric. */
|
|
612
|
+
function CreateActions({ status, busy, creating, onCreate, onRestore }) {
|
|
613
|
+
const { t } = useMatterTranslations();
|
|
614
|
+
const blocker = restoreBlocker(status);
|
|
615
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
616
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
617
|
+
className: "mt:flex mt:flex-wrap mt:gap-2",
|
|
618
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$5, {
|
|
619
|
+
isDisabled: busy,
|
|
620
|
+
isPending: creating,
|
|
621
|
+
onPress: onCreate,
|
|
622
|
+
"data-cy": "matter-fabric-create",
|
|
623
|
+
children: t("fabric.create")
|
|
624
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$5, {
|
|
625
|
+
variant: "secondary",
|
|
626
|
+
isDisabled: busy || blocker !== null,
|
|
627
|
+
onPress: onRestore,
|
|
628
|
+
"data-cy": "matter-restore-open-empty",
|
|
629
|
+
children: t("fabric.restore.open")
|
|
630
|
+
})]
|
|
631
|
+
}),
|
|
632
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
633
|
+
className: "mt:mt-1 mt:text-sm mt:text-muted",
|
|
634
|
+
children: t("fabric.createHint")
|
|
635
|
+
}),
|
|
636
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
637
|
+
className: "mt:text-sm mt:text-muted",
|
|
638
|
+
children: blocker ? t(`fabric.blocked.${blocker}`) : t("fabric.restoreInstead")
|
|
639
|
+
})
|
|
640
|
+
] });
|
|
641
|
+
}
|
|
642
|
+
/** Fabric identity and state as the sidecar reports it, with what Attraccess recorded while they disagree. */
|
|
643
|
+
function FabricStatusCard(props) {
|
|
644
|
+
const { status } = props;
|
|
645
|
+
const { t } = useMatterTranslations();
|
|
646
|
+
const chip = stateChip(status);
|
|
647
|
+
const { sidecar, recovery, actions } = status;
|
|
648
|
+
const uninitialized = sidecar.reachable && sidecar.state === "uninitialized" && !recovery.required;
|
|
649
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card$3, {
|
|
650
|
+
"data-cy": "matter-fabric-card",
|
|
651
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card$3.Header, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card$3.Title, { children: t("fabric.statusTitle") }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card$3.Content, {
|
|
652
|
+
className: "mt:flex mt:flex-col mt:gap-4",
|
|
653
|
+
children: [
|
|
654
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
655
|
+
className: "mt:flex mt:flex-wrap mt:items-center mt:gap-2",
|
|
656
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Chip$2, {
|
|
657
|
+
color: chip.color,
|
|
658
|
+
variant: "soft",
|
|
659
|
+
"data-cy": "matter-fabric-state",
|
|
660
|
+
children: t(`fabric.state.${chip.key}`)
|
|
661
|
+
})
|
|
662
|
+
}),
|
|
663
|
+
!sidecar.reachable && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$8, {
|
|
664
|
+
status: "warning",
|
|
665
|
+
title: t("fabric.unreachable"),
|
|
666
|
+
children: t("fabric.unreachableText")
|
|
667
|
+
}),
|
|
668
|
+
recovery.required && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecoveryAlert, { status }),
|
|
669
|
+
uninitialized && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
670
|
+
"data-cy": "matter-fabric-uninitialized",
|
|
671
|
+
children: t("fabric.uninitializedText")
|
|
672
|
+
}),
|
|
673
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("dl", {
|
|
674
|
+
className: "mt:grid mt:grid-cols-1 mt:gap-3 mt:sm:grid-cols-2",
|
|
675
|
+
children: [
|
|
676
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
|
|
677
|
+
label: t("fabric.fabricId"),
|
|
678
|
+
children: sidecar.fabricId ?? t("fabric.none")
|
|
679
|
+
}),
|
|
680
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
|
|
681
|
+
label: t("fabric.generationLabel"),
|
|
682
|
+
children: sidecar.fabricGeneration ?? t("fabric.none")
|
|
683
|
+
}),
|
|
684
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
|
|
685
|
+
label: t("fabric.fingerprint"),
|
|
686
|
+
children: sidecar.rootCertFingerprint ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fingerprint, { value: sidecar.rootCertFingerprint }) : t("fabric.none")
|
|
687
|
+
}),
|
|
688
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
|
|
689
|
+
label: t("fabric.storageInstance"),
|
|
690
|
+
children: sidecar.storageInstanceId ?? t("fabric.none")
|
|
691
|
+
})
|
|
692
|
+
]
|
|
693
|
+
}),
|
|
694
|
+
recovery.required && status.recorded && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
695
|
+
"data-cy": "matter-fabric-recorded",
|
|
696
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
697
|
+
className: "mt:mb-1 mt:text-sm mt:font-medium",
|
|
698
|
+
children: t("fabric.recorded")
|
|
699
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("dl", {
|
|
700
|
+
className: "mt:grid mt:grid-cols-1 mt:gap-3 mt:sm:grid-cols-2",
|
|
701
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
|
|
702
|
+
label: t("fabric.fabricId"),
|
|
703
|
+
children: status.recorded.fabricId ?? t("fabric.none")
|
|
704
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
|
|
705
|
+
label: t("fabric.generationLabel"),
|
|
706
|
+
children: status.recorded.fabricGeneration ?? t("fabric.none")
|
|
707
|
+
})]
|
|
708
|
+
})]
|
|
709
|
+
}),
|
|
710
|
+
uninitialized && actions.canCreateFabric && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CreateActions, { ...props })
|
|
711
|
+
]
|
|
712
|
+
})]
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
//#endregion
|
|
716
|
+
//#region frontend/src/fabric-backup/KeyCard.tsx
|
|
717
|
+
var { Button: Button$4, StatusAlert: StatusAlert$7 } = await importShared("@attraccess/plugins-frontend-ui");
|
|
718
|
+
var { Card: Card$2 } = await importShared("@heroui/react");
|
|
719
|
+
/** The recovery key's ID and state (never the key itself), with generate or rotate. */
|
|
720
|
+
function KeyCard({ status, busy, generating, onGenerateKey, onRotate, formatDateTime }) {
|
|
721
|
+
const { t } = useMatterTranslations();
|
|
722
|
+
const { sidecar, recovery, recoveryKey } = status;
|
|
723
|
+
const initialized = sidecar.reachable && sidecar.state === "initialized";
|
|
724
|
+
if (!initialized && !recoveryKey.present) return null;
|
|
725
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card$2, {
|
|
726
|
+
"data-cy": "matter-key-card",
|
|
727
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card$2.Header, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card$2.Title, { children: t("fabric.key.cardTitle") }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card$2.Content, {
|
|
728
|
+
className: "mt:flex mt:flex-col mt:gap-3",
|
|
729
|
+
children: [
|
|
730
|
+
recoveryKey.present ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("dl", {
|
|
731
|
+
className: "mt:grid mt:grid-cols-1 mt:gap-3 mt:sm:grid-cols-2",
|
|
732
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
|
|
733
|
+
label: t("fabric.key.keyId"),
|
|
734
|
+
children: recoveryKey.keyId
|
|
735
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
|
|
736
|
+
label: t("fabric.key.created"),
|
|
737
|
+
children: formatDateTime(recoveryKey.createdAt)
|
|
738
|
+
})]
|
|
739
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$7, {
|
|
740
|
+
status: "warning",
|
|
741
|
+
title: t("fabric.key.missing"),
|
|
742
|
+
"data-cy": "matter-key-missing",
|
|
743
|
+
children: t("fabric.key.missingText")
|
|
744
|
+
}),
|
|
745
|
+
recoveryKey.present && !recoveryKey.acknowledged && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$7, {
|
|
746
|
+
status: "warning",
|
|
747
|
+
title: t("fabric.key.unacknowledged"),
|
|
748
|
+
"data-cy": "matter-key-unacknowledged",
|
|
749
|
+
children: t("fabric.key.unacknowledgedText")
|
|
750
|
+
}),
|
|
751
|
+
!recovery.required && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: recoveryKey.present ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$4, {
|
|
752
|
+
variant: "secondary",
|
|
753
|
+
isDisabled: busy || !initialized,
|
|
754
|
+
onPress: onRotate,
|
|
755
|
+
"data-cy": "matter-key-rotate",
|
|
756
|
+
children: t("fabric.key.rotate")
|
|
757
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$4, {
|
|
758
|
+
isDisabled: busy || !initialized,
|
|
759
|
+
isPending: generating,
|
|
760
|
+
onPress: onGenerateKey,
|
|
761
|
+
"data-cy": "matter-key-generate",
|
|
762
|
+
children: t("fabric.key.generate")
|
|
763
|
+
}) })
|
|
764
|
+
]
|
|
765
|
+
})]
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
//#endregion
|
|
769
|
+
//#region frontend/src/fabric-backup/RecoveryKeyModal.tsx
|
|
770
|
+
var { Button: Button$3, StandardModal: StandardModal$1, StatusAlert: StatusAlert$6 } = await importShared("@attraccess/plugins-frontend-ui");
|
|
771
|
+
var { Checkbox, ModalBody: ModalBody$1, ModalFooter: ModalFooter$1, ModalHeader: ModalHeader$1, ModalHeading: ModalHeading$1 } = await importShared("@heroui/react");
|
|
772
|
+
var { useState: useState$6 } = await importShared("react");
|
|
773
|
+
/**
|
|
774
|
+
* The one and only place the recovery key is visible. It cannot be dismissed (no close button, no Escape, no
|
|
775
|
+
* backdrop click) until the administrator confirms they stored the key; only then is the key forgotten.
|
|
776
|
+
*/
|
|
777
|
+
function RecoveryKeyModal({ reveal, onAcknowledge, onDone }) {
|
|
778
|
+
const { t } = useMatterTranslations();
|
|
779
|
+
const errorText = useErrorText();
|
|
780
|
+
const [confirmed, setConfirmed] = useState$6(false);
|
|
781
|
+
const [copied, setCopied] = useState$6(false);
|
|
782
|
+
const [busy, setBusy] = useState$6(false);
|
|
783
|
+
const [error, setError] = useState$6(null);
|
|
784
|
+
const copy = async () => {
|
|
785
|
+
try {
|
|
786
|
+
await navigator.clipboard.writeText(reveal.key);
|
|
787
|
+
setCopied(true);
|
|
788
|
+
} catch {
|
|
789
|
+
setCopied(false);
|
|
790
|
+
setError(t("fabric.key.copyFailed"));
|
|
791
|
+
}
|
|
792
|
+
};
|
|
793
|
+
const download = () => {
|
|
794
|
+
const text = `${t("fabric.key.fileHeader")}\n\n${t("fabric.key.keyId")}: ${reveal.keyId}\n${t("fabric.key.created")}: ${reveal.createdAt}\n\n${reveal.key}\n`;
|
|
795
|
+
saveBlob(new Blob([text], { type: "text/plain" }), `attraccess-matter-recovery-key-${reveal.keyId}.txt`);
|
|
796
|
+
};
|
|
797
|
+
const done = async () => {
|
|
798
|
+
setBusy(true);
|
|
799
|
+
setError(null);
|
|
800
|
+
try {
|
|
801
|
+
await onAcknowledge(reveal.keyId);
|
|
802
|
+
onDone();
|
|
803
|
+
} catch (caught) {
|
|
804
|
+
setError(errorText(caught));
|
|
805
|
+
} finally {
|
|
806
|
+
setBusy(false);
|
|
807
|
+
}
|
|
808
|
+
};
|
|
809
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StandardModal$1, {
|
|
810
|
+
isOpen: true,
|
|
811
|
+
"data-cy": "matter-key-modal",
|
|
812
|
+
onOpenChange: () => void 0,
|
|
813
|
+
size: "md",
|
|
814
|
+
backdropProps: {
|
|
815
|
+
isDismissable: false,
|
|
816
|
+
isKeyboardDismissDisabled: true
|
|
817
|
+
},
|
|
818
|
+
children: [
|
|
819
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalHeader$1, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalHeading$1, { children: t("fabric.key.title") }) }),
|
|
820
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ModalBody$1, {
|
|
821
|
+
className: "mt:flex mt:flex-col mt:gap-4",
|
|
822
|
+
children: [
|
|
823
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$6, {
|
|
824
|
+
status: "warning",
|
|
825
|
+
title: t("fabric.key.warningTitle"),
|
|
826
|
+
children: t("fabric.key.warning")
|
|
827
|
+
}),
|
|
828
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", {
|
|
829
|
+
className: "mt:block mt:break-all mt:rounded-lg mt:bg-surface-secondary mt:p-3 mt:text-center mt:font-mono mt:text-base mt:select-all",
|
|
830
|
+
"data-cy": "matter-key-value",
|
|
831
|
+
children: reveal.key
|
|
832
|
+
}),
|
|
833
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
|
|
834
|
+
className: "mt:text-xs mt:text-muted",
|
|
835
|
+
children: [
|
|
836
|
+
t("fabric.key.keyId"),
|
|
837
|
+
": ",
|
|
838
|
+
reveal.keyId
|
|
839
|
+
]
|
|
840
|
+
}),
|
|
841
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
842
|
+
className: "mt:flex mt:flex-wrap mt:gap-2",
|
|
843
|
+
children: [
|
|
844
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$3, {
|
|
845
|
+
variant: "secondary",
|
|
846
|
+
onPress: () => void copy(),
|
|
847
|
+
"data-cy": "matter-key-copy",
|
|
848
|
+
children: copied ? t("fabric.key.copied") : t("fabric.key.copy")
|
|
849
|
+
}),
|
|
850
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
851
|
+
role: "status",
|
|
852
|
+
"aria-live": "polite",
|
|
853
|
+
className: "mt:sr-only",
|
|
854
|
+
children: copied ? t("fabric.key.copied") : ""
|
|
855
|
+
}),
|
|
856
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$3, {
|
|
857
|
+
variant: "secondary",
|
|
858
|
+
onPress: download,
|
|
859
|
+
"data-cy": "matter-key-download",
|
|
860
|
+
children: t("fabric.key.download")
|
|
861
|
+
})
|
|
862
|
+
]
|
|
863
|
+
}),
|
|
864
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Checkbox, {
|
|
865
|
+
isSelected: confirmed,
|
|
866
|
+
onChange: setConfirmed,
|
|
867
|
+
"data-cy": "matter-key-ack",
|
|
868
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Checkbox.Content, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Checkbox.Control, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Checkbox.Indicator, {}) }), t("fabric.key.acknowledge")] })
|
|
869
|
+
}),
|
|
870
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$6, {
|
|
871
|
+
status: "danger",
|
|
872
|
+
children: error
|
|
873
|
+
})
|
|
874
|
+
]
|
|
875
|
+
}),
|
|
876
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalFooter$1, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$3, {
|
|
877
|
+
isDisabled: !confirmed,
|
|
878
|
+
isPending: busy,
|
|
879
|
+
onPress: () => void done(),
|
|
880
|
+
"data-cy": "matter-key-done",
|
|
881
|
+
children: t("fabric.key.done")
|
|
882
|
+
}) })
|
|
883
|
+
]
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
//#endregion
|
|
887
|
+
//#region frontend/src/fabric-backup/RecoveryPanel.tsx
|
|
888
|
+
var { Button: Button$2, StatusAlert: StatusAlert$5, StatusDialog: StatusDialog$2 } = await importShared("@attraccess/plugins-frontend-ui");
|
|
889
|
+
var { Card: Card$1 } = await importShared("@heroui/react");
|
|
890
|
+
var { useState: useState$5 } = await importShared("react");
|
|
891
|
+
/**
|
|
892
|
+
* Recovery options for a plugin in `recovery_required`. Each option is admin-confirmed; none runs automatically.
|
|
893
|
+
* An option the current sidecar state does not allow stays visible but disabled, with the reason.
|
|
894
|
+
*/
|
|
895
|
+
function RecoveryPanel({ status, pending, onRestore, onAcceptSidecar, onStartNew }) {
|
|
896
|
+
const { t } = useMatterTranslations();
|
|
897
|
+
const [confirm, setConfirm] = useState$5(null);
|
|
898
|
+
const canAccept = status.actions.canAcceptSidecar && status.sidecar.state === "initialized";
|
|
899
|
+
const canStartNew = status.actions.canStartNew && status.sidecar.state === "uninitialized";
|
|
900
|
+
const restoreBlocked = restoreBlocker(status);
|
|
901
|
+
const busy = pending !== null;
|
|
902
|
+
const run = async (action) => {
|
|
903
|
+
try {
|
|
904
|
+
await action();
|
|
905
|
+
} finally {
|
|
906
|
+
setConfirm(null);
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card$1, {
|
|
910
|
+
"data-cy": "matter-recovery-panel",
|
|
911
|
+
children: [
|
|
912
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card$1.Header, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card$1.Title, { children: t("fabric.recovery.title") }) }),
|
|
913
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card$1.Content, {
|
|
914
|
+
className: "mt:flex mt:flex-col mt:gap-4",
|
|
915
|
+
children: [
|
|
916
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$5, {
|
|
917
|
+
status: "danger",
|
|
918
|
+
title: t("fabric.recovery.blocked"),
|
|
919
|
+
children: t("fabric.recovery.blockedText")
|
|
920
|
+
}),
|
|
921
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Option, {
|
|
922
|
+
title: t("fabric.recovery.restoreTitle"),
|
|
923
|
+
text: restoreBlocked ? t(`fabric.blocked.${restoreBlocked}`) : t("fabric.recovery.restoreText"),
|
|
924
|
+
action: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$2, {
|
|
925
|
+
isDisabled: busy || restoreBlocked !== null,
|
|
926
|
+
onPress: onRestore,
|
|
927
|
+
"data-cy": "matter-recovery-restore",
|
|
928
|
+
children: t("fabric.recovery.restoreAction")
|
|
929
|
+
})
|
|
930
|
+
}),
|
|
931
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Option, {
|
|
932
|
+
title: t("fabric.recovery.acceptTitle"),
|
|
933
|
+
text: canAccept ? t("fabric.recovery.acceptText") : t("fabric.recovery.acceptUnavailable"),
|
|
934
|
+
action: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$2, {
|
|
935
|
+
variant: "secondary",
|
|
936
|
+
isDisabled: busy || !canAccept,
|
|
937
|
+
onPress: () => setConfirm("accept"),
|
|
938
|
+
"data-cy": "matter-recovery-accept",
|
|
939
|
+
children: t("fabric.recovery.acceptAction")
|
|
940
|
+
})
|
|
941
|
+
}),
|
|
942
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Option, {
|
|
943
|
+
title: t("fabric.recovery.newTitle"),
|
|
944
|
+
text: canStartNew ? t("fabric.recovery.newText") : t("fabric.recovery.newUnavailable"),
|
|
945
|
+
action: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$2, {
|
|
946
|
+
variant: "danger-soft",
|
|
947
|
+
isDisabled: busy || !canStartNew,
|
|
948
|
+
onPress: () => setConfirm("start-new"),
|
|
949
|
+
"data-cy": "matter-recovery-new",
|
|
950
|
+
children: t("fabric.recovery.newAction")
|
|
951
|
+
})
|
|
952
|
+
})
|
|
953
|
+
]
|
|
954
|
+
}),
|
|
955
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog$2, {
|
|
956
|
+
isOpen: confirm === "accept",
|
|
957
|
+
status: "warning",
|
|
958
|
+
title: t("fabric.recovery.acceptConfirmTitle"),
|
|
959
|
+
onClose: () => setConfirm(null),
|
|
960
|
+
action: {
|
|
961
|
+
label: t("fabric.recovery.acceptConfirm"),
|
|
962
|
+
isPending: pending === "accept",
|
|
963
|
+
onPress: () => run(onAcceptSidecar),
|
|
964
|
+
"data-cy": "matter-recovery-accept-confirm"
|
|
965
|
+
},
|
|
966
|
+
"data-cy": "matter-recovery-accept-dialog",
|
|
967
|
+
children: t("fabric.recovery.acceptConfirmText")
|
|
968
|
+
}),
|
|
969
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog$2, {
|
|
970
|
+
isOpen: confirm === "start-new",
|
|
971
|
+
status: "error",
|
|
972
|
+
title: t("fabric.recovery.newConfirmTitle"),
|
|
973
|
+
onClose: () => setConfirm(null),
|
|
974
|
+
action: {
|
|
975
|
+
label: t("fabric.recovery.newConfirm"),
|
|
976
|
+
isPending: pending === "startNew",
|
|
977
|
+
onPress: () => run(onStartNew),
|
|
978
|
+
"data-cy": "matter-recovery-new-confirm"
|
|
979
|
+
},
|
|
980
|
+
"data-cy": "matter-recovery-new-dialog",
|
|
981
|
+
children: t("fabric.recovery.newConfirmText")
|
|
982
|
+
})
|
|
983
|
+
]
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
function Option({ title, text, action }) {
|
|
987
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
988
|
+
className: "mt:flex mt:flex-col mt:gap-2 mt:sm:flex-row mt:sm:items-center mt:sm:justify-between",
|
|
989
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
990
|
+
className: "mt:font-medium",
|
|
991
|
+
children: title
|
|
992
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
993
|
+
className: "mt:text-sm mt:text-muted",
|
|
994
|
+
children: text
|
|
995
|
+
})] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
996
|
+
className: "mt:shrink-0",
|
|
997
|
+
children: action
|
|
998
|
+
})]
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
//#endregion
|
|
1002
|
+
//#region frontend/src/fabric-backup/RestoreSourceStep.tsx
|
|
1003
|
+
var { PasswordInput: PasswordInput$1, StatusAlert: StatusAlert$4, useDateTimeFormatter: useDateTimeFormatter$4 } = await importShared("@attraccess/plugins-frontend-ui");
|
|
1004
|
+
var { Description: Description$1, Label: Label$2, Radio, RadioGroup } = await importShared("@heroui/react");
|
|
1005
|
+
/** Codes after which the backup has to be validated again: the wizard returns here with source and key kept. */
|
|
1006
|
+
var RETRY_CODES = /* @__PURE__ */ new Set([
|
|
1007
|
+
"validation_expired",
|
|
1008
|
+
"preflight_changed",
|
|
1009
|
+
"busy"
|
|
1010
|
+
]);
|
|
1011
|
+
var KEY_CODES = /* @__PURE__ */ new Set(["key_required", "wrong_key"]);
|
|
1012
|
+
function RadioOption({ value, label, description, isDisabled }) {
|
|
1013
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Radio, {
|
|
1014
|
+
value,
|
|
1015
|
+
isDisabled,
|
|
1016
|
+
"data-cy": `matter-restore-option-${value}`,
|
|
1017
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Radio.Content, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Radio.Control, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Radio.Indicator, {}) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label$2, { children: label })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Description$1, { children: description })]
|
|
1018
|
+
});
|
|
1019
|
+
}
|
|
1020
|
+
function StoredBackups({ stored, backupId, onBackupId }) {
|
|
1021
|
+
const { t } = useMatterTranslations();
|
|
1022
|
+
const formatDateTime = useDateTimeFormatter$4({ showSeconds: true });
|
|
1023
|
+
const formatSize = useFormatSize();
|
|
1024
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(RadioGroup, {
|
|
1025
|
+
value: backupId ?? "",
|
|
1026
|
+
onChange: onBackupId,
|
|
1027
|
+
"data-cy": "matter-restore-stored",
|
|
1028
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label$2, { children: t("fabric.backups.stored") }), stored.map((backup) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioOption, {
|
|
1029
|
+
value: backup.id,
|
|
1030
|
+
label: formatDateTime(backup.createdAt),
|
|
1031
|
+
description: `${t(`fabric.trigger.${backup.trigger}`)} · ${t("fabric.generation", { generation: backup.fabricGeneration })} · ${formatSize(backup.sizeBytes)}`
|
|
1032
|
+
}, backup.id))]
|
|
1033
|
+
});
|
|
1034
|
+
}
|
|
1035
|
+
/** Pick a stored backup or upload a file, and give the recovery key when the backup needs another one. */
|
|
1036
|
+
function RestoreSourceStep(props) {
|
|
1037
|
+
const { stored, mode, error, recoveryKey } = props;
|
|
1038
|
+
const { t } = useMatterTranslations();
|
|
1039
|
+
const showKey = error?.code != null && KEY_CODES.has(error.code) || recoveryKey !== "";
|
|
1040
|
+
const retry = error?.code != null && RETRY_CODES.has(error.code);
|
|
1041
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
1042
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: t("fabric.restore.intro") }),
|
|
1043
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(RadioGroup, {
|
|
1044
|
+
value: mode,
|
|
1045
|
+
onChange: (value) => props.onMode(value),
|
|
1046
|
+
"data-cy": "matter-restore-source",
|
|
1047
|
+
children: [
|
|
1048
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label$2, { children: t("fabric.restore.source") }),
|
|
1049
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioOption, {
|
|
1050
|
+
value: "stored",
|
|
1051
|
+
label: t("fabric.restore.fromStored"),
|
|
1052
|
+
description: t("fabric.restore.fromStoredHint"),
|
|
1053
|
+
isDisabled: stored.length === 0
|
|
1054
|
+
}),
|
|
1055
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioOption, {
|
|
1056
|
+
value: "upload",
|
|
1057
|
+
label: t("fabric.restore.fromUpload"),
|
|
1058
|
+
description: t("fabric.restore.fromUploadHint")
|
|
1059
|
+
})
|
|
1060
|
+
]
|
|
1061
|
+
}),
|
|
1062
|
+
mode === "stored" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StoredBackups, {
|
|
1063
|
+
stored,
|
|
1064
|
+
backupId: props.backupId,
|
|
1065
|
+
onBackupId: props.onBackupId
|
|
1066
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
|
|
1067
|
+
className: "mt:flex mt:flex-col mt:gap-1 mt:text-sm",
|
|
1068
|
+
children: [t("fabric.restore.file"), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
1069
|
+
type: "file",
|
|
1070
|
+
accept: ".attraccess-matter-backup,application/octet-stream",
|
|
1071
|
+
className: "mt:block mt:w-full mt:cursor-pointer mt:text-sm mt:file:mr-3 mt:file:cursor-pointer mt:file:rounded-lg mt:file:border-0 mt:file:bg-default mt:file:px-3 mt:file:py-1.5 mt:file:text-sm mt:file:font-medium mt:file:text-foreground",
|
|
1072
|
+
onChange: (event) => props.onFile(event.target.files?.[0] ?? null),
|
|
1073
|
+
"data-cy": "matter-restore-file"
|
|
1074
|
+
})]
|
|
1075
|
+
}),
|
|
1076
|
+
showKey && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PasswordInput$1, {
|
|
1077
|
+
label: t("fabric.restore.recoveryKey"),
|
|
1078
|
+
description: t("fabric.restore.recoveryKeyHint"),
|
|
1079
|
+
autoComplete: "off",
|
|
1080
|
+
value: recoveryKey,
|
|
1081
|
+
onValueChange: props.onRecoveryKey,
|
|
1082
|
+
"data-cy": "matter-restore-key"
|
|
1083
|
+
}),
|
|
1084
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$4, {
|
|
1085
|
+
status: retry ? "warning" : "danger",
|
|
1086
|
+
title: retry ? t("fabric.restore.retryTitle") : t("fabric.restore.validationFailed"),
|
|
1087
|
+
"data-cy": "matter-restore-error",
|
|
1088
|
+
children: error.text
|
|
1089
|
+
})
|
|
1090
|
+
] });
|
|
1091
|
+
}
|
|
1092
|
+
//#endregion
|
|
1093
|
+
//#region frontend/src/fabric-backup/RestoreWizard.tsx
|
|
1094
|
+
var { Button: Button$1, StandardModal, StatusAlert: StatusAlert$3, useDateTimeFormatter: useDateTimeFormatter$3 } = await importShared("@attraccess/plugins-frontend-ui");
|
|
1095
|
+
var { Chip: Chip$1, Input: Input$1, Label: Label$1, ModalBody, ModalFooter, ModalHeader, ModalHeading, TextField: TextField$1 } = await importShared("@heroui/react");
|
|
1096
|
+
var { useState: useState$4 } = await importShared("react");
|
|
1097
|
+
/** The host reads the upload as JSON (base64, about a third larger) with a 10 MB body limit. */
|
|
1098
|
+
var MAX_UPLOAD_BYTES = 7340032;
|
|
1099
|
+
/** What is wrong with a file before it is sent, if anything. */
|
|
1100
|
+
function uploadProblem(file) {
|
|
1101
|
+
if (file.size === 0) return "empty";
|
|
1102
|
+
return file.size > MAX_UPLOAD_BYTES ? "tooLarge" : null;
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* Where a failed confirmation leaves the wizard: a missing typed confirmation stays on the preview, an expired or
|
|
1106
|
+
* outdated check (or a busy sidecar) goes back to validate again, anything else ends the wizard.
|
|
1107
|
+
*/
|
|
1108
|
+
function stepAfterFailure(code) {
|
|
1109
|
+
if (code === "confirmation_required") return "preview";
|
|
1110
|
+
return code !== null && RETRY_CODES.has(code) ? "select" : "failed";
|
|
1111
|
+
}
|
|
1112
|
+
/** What the validated backup would do to this installation, with the typed confirmation where it overwrites. */
|
|
1113
|
+
function PreviewStep({ validation, typed, onTyped, error }) {
|
|
1114
|
+
const { t } = useMatterTranslations();
|
|
1115
|
+
const formatDateTime = useDateTimeFormatter$3({ showSeconds: true });
|
|
1116
|
+
const { backup, preflight } = validation;
|
|
1117
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
1118
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1119
|
+
className: "mt:flex mt:flex-wrap mt:gap-2",
|
|
1120
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Chip$1, {
|
|
1121
|
+
variant: "soft",
|
|
1122
|
+
children: t(`fabric.restore.kind.${preflight.kind}`)
|
|
1123
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Chip$1, {
|
|
1124
|
+
variant: "soft",
|
|
1125
|
+
children: t(`fabric.state.${preflight.sidecarState}`)
|
|
1126
|
+
})]
|
|
1127
|
+
}),
|
|
1128
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("dl", {
|
|
1129
|
+
className: "mt:grid mt:grid-cols-1 mt:gap-3 mt:sm:grid-cols-2",
|
|
1130
|
+
"data-cy": "matter-restore-summary",
|
|
1131
|
+
children: [
|
|
1132
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
|
|
1133
|
+
label: t("fabric.restore.backupCreated"),
|
|
1134
|
+
children: formatDateTime(backup.createdAt)
|
|
1135
|
+
}),
|
|
1136
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
|
|
1137
|
+
label: t("fabric.restore.pluginVersion"),
|
|
1138
|
+
children: backup.pluginVersion
|
|
1139
|
+
}),
|
|
1140
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
|
|
1141
|
+
label: t("fabric.restore.sidecarVersion"),
|
|
1142
|
+
children: backup.sidecarVersion
|
|
1143
|
+
}),
|
|
1144
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
|
|
1145
|
+
label: t("fabric.generationLabel"),
|
|
1146
|
+
children: backup.fabricGeneration
|
|
1147
|
+
}),
|
|
1148
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
|
|
1149
|
+
label: t("fabric.restore.backupFabric"),
|
|
1150
|
+
children: backup.fabricId
|
|
1151
|
+
}),
|
|
1152
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field$1, {
|
|
1153
|
+
label: t("fabric.restore.currentFabric"),
|
|
1154
|
+
children: preflight.currentFabricId ?? t("fabric.none")
|
|
1155
|
+
})
|
|
1156
|
+
]
|
|
1157
|
+
}),
|
|
1158
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [t("fabric.restore.previewHint"), preflight.requiresTypedConfirmation && ` ${t("fabric.restore.previewHintBackup")}`] }),
|
|
1159
|
+
!backup.consistent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$3, {
|
|
1160
|
+
status: "warning",
|
|
1161
|
+
title: t("fabric.restore.inconsistentTitle"),
|
|
1162
|
+
"data-cy": "matter-restore-inconsistent",
|
|
1163
|
+
children: t("fabric.restore.inconsistentText")
|
|
1164
|
+
}),
|
|
1165
|
+
preflight.requiresTypedConfirmation && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$3, {
|
|
1166
|
+
status: "danger",
|
|
1167
|
+
title: t("fabric.restore.overwriteTitle"),
|
|
1168
|
+
"data-cy": "matter-restore-overwrite",
|
|
1169
|
+
children: t("fabric.restore.overwriteText")
|
|
1170
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TextField$1, {
|
|
1171
|
+
value: typed,
|
|
1172
|
+
onChange: onTyped,
|
|
1173
|
+
className: "mt:w-full",
|
|
1174
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label$1, { children: t("fabric.restore.typeFabricId", { fabricId: preflight.confirmationFabricId ?? "" }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input$1, {
|
|
1175
|
+
autoComplete: "off",
|
|
1176
|
+
spellCheck: false,
|
|
1177
|
+
"data-cy": "matter-restore-typed"
|
|
1178
|
+
})]
|
|
1179
|
+
})] }),
|
|
1180
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$3, {
|
|
1181
|
+
status: "danger",
|
|
1182
|
+
"data-cy": "matter-restore-confirm-error",
|
|
1183
|
+
children: error.text
|
|
1184
|
+
})
|
|
1185
|
+
] });
|
|
1186
|
+
}
|
|
1187
|
+
/** The end of a restore. A failed rollback is the one outcome that leaves the sidecar in an unknown state. */
|
|
1188
|
+
function ResultStep({ step, error }) {
|
|
1189
|
+
const { t } = useMatterTranslations();
|
|
1190
|
+
if (step === "success") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$3, {
|
|
1191
|
+
status: "success",
|
|
1192
|
+
title: t("fabric.restore.successTitle"),
|
|
1193
|
+
"data-cy": "matter-restore-success",
|
|
1194
|
+
children: t("fabric.restore.successText")
|
|
1195
|
+
});
|
|
1196
|
+
const rollbackFailed = error?.code === "rollback_failed";
|
|
1197
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$3, {
|
|
1198
|
+
status: "danger",
|
|
1199
|
+
title: rollbackFailed ? t("fabric.restore.rollbackFailedTitle") : t("fabric.restore.failedTitle"),
|
|
1200
|
+
"data-cy": rollbackFailed ? "matter-restore-rollback-failed" : "matter-restore-failed",
|
|
1201
|
+
children: error?.text
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1204
|
+
function WizardFooter({ step, busy, canValidate, canConfirm, danger, onClose, onValidate, onConfirm }) {
|
|
1205
|
+
const { t } = useMatterTranslations();
|
|
1206
|
+
if (step === "success" || step === "failed") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$1, {
|
|
1207
|
+
onPress: onClose,
|
|
1208
|
+
"data-cy": "matter-restore-close",
|
|
1209
|
+
children: t("fabric.close")
|
|
1210
|
+
});
|
|
1211
|
+
if (step === "running") return null;
|
|
1212
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$1, {
|
|
1213
|
+
variant: "tertiary",
|
|
1214
|
+
onPress: onClose,
|
|
1215
|
+
children: t("fabric.cancel")
|
|
1216
|
+
}), step === "select" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$1, {
|
|
1217
|
+
isDisabled: !canValidate,
|
|
1218
|
+
isPending: busy,
|
|
1219
|
+
onPress: onValidate,
|
|
1220
|
+
"data-cy": "matter-restore-validate",
|
|
1221
|
+
children: t("fabric.restore.validate")
|
|
1222
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$1, {
|
|
1223
|
+
variant: danger ? "danger" : "primary",
|
|
1224
|
+
isDisabled: !canConfirm,
|
|
1225
|
+
onPress: onConfirm,
|
|
1226
|
+
"data-cy": "matter-restore-confirm",
|
|
1227
|
+
children: t("fabric.restore.confirm")
|
|
1228
|
+
})] });
|
|
1229
|
+
}
|
|
1230
|
+
/**
|
|
1231
|
+
* Restore from a stored backup or an uploaded file: validate (no live change), review the preflight, then confirm.
|
|
1232
|
+
* A healthy fabric is only overwritten after typing its fabric ID. The recovery key typed here lives in this
|
|
1233
|
+
* component's state only and is gone when the wizard closes or the restore ended.
|
|
1234
|
+
*/
|
|
1235
|
+
function RestoreWizard({ stored, onClose, onRestored }) {
|
|
1236
|
+
const { t } = useMatterTranslations();
|
|
1237
|
+
const errorText = useErrorText();
|
|
1238
|
+
const [step, setStep] = useState$4("select");
|
|
1239
|
+
const [mode, setMode] = useState$4(stored.length > 0 ? "stored" : "upload");
|
|
1240
|
+
const [backupId, setBackupId] = useState$4(stored[0]?.id ?? null);
|
|
1241
|
+
const [file, setFile] = useState$4(null);
|
|
1242
|
+
const [recoveryKey, setRecoveryKey] = useState$4("");
|
|
1243
|
+
const [error, setError] = useState$4(null);
|
|
1244
|
+
const [validation, setValidation] = useState$4(null);
|
|
1245
|
+
const [typed, setTyped] = useState$4("");
|
|
1246
|
+
const [busy, setBusy] = useState$4(false);
|
|
1247
|
+
const preflight = validation?.preflight;
|
|
1248
|
+
const confirmed = !preflight?.requiresTypedConfirmation || typed.trim() === preflight.confirmationFabricId;
|
|
1249
|
+
const fail = (caught) => setError({
|
|
1250
|
+
code: codeOf(caught),
|
|
1251
|
+
text: errorText(caught)
|
|
1252
|
+
});
|
|
1253
|
+
const validate = async () => {
|
|
1254
|
+
setError(null);
|
|
1255
|
+
const problem = mode === "upload" && file ? uploadProblem(file) : null;
|
|
1256
|
+
if (problem) return setError({
|
|
1257
|
+
code: null,
|
|
1258
|
+
text: t(`fabric.restore.error.${problem}`)
|
|
1259
|
+
});
|
|
1260
|
+
setBusy(true);
|
|
1261
|
+
try {
|
|
1262
|
+
const source = mode === "stored" && backupId ? {
|
|
1263
|
+
type: "stored",
|
|
1264
|
+
backupId
|
|
1265
|
+
} : {
|
|
1266
|
+
type: "upload",
|
|
1267
|
+
contentBase64: await readFileAsBase64(file)
|
|
1268
|
+
};
|
|
1269
|
+
setValidation(await validateRestore(source, recoveryKey.trim() || void 0));
|
|
1270
|
+
setTyped("");
|
|
1271
|
+
setStep("preview");
|
|
1272
|
+
} catch (caught) {
|
|
1273
|
+
fail(caught);
|
|
1274
|
+
} finally {
|
|
1275
|
+
setBusy(false);
|
|
1276
|
+
}
|
|
1277
|
+
};
|
|
1278
|
+
const confirm = async () => {
|
|
1279
|
+
if (!validation) return;
|
|
1280
|
+
setError(null);
|
|
1281
|
+
setBusy(true);
|
|
1282
|
+
setStep("running");
|
|
1283
|
+
let next = "success";
|
|
1284
|
+
try {
|
|
1285
|
+
onRestored((await confirmRestore(validation.validationId, preflight?.requiresTypedConfirmation ? typed.trim() : void 0)).status);
|
|
1286
|
+
} catch (caught) {
|
|
1287
|
+
fail(caught);
|
|
1288
|
+
next = stepAfterFailure(codeOf(caught));
|
|
1289
|
+
} finally {
|
|
1290
|
+
setBusy(false);
|
|
1291
|
+
}
|
|
1292
|
+
if (next === "select") setValidation(null);
|
|
1293
|
+
if (next === "success" || next === "failed") setRecoveryKey("");
|
|
1294
|
+
setStep(next);
|
|
1295
|
+
};
|
|
1296
|
+
const close = () => {
|
|
1297
|
+
if (busy) return;
|
|
1298
|
+
if (step === "preview" && validation) cancelRestore(validation.validationId).catch(() => void 0);
|
|
1299
|
+
setRecoveryKey("");
|
|
1300
|
+
onClose();
|
|
1301
|
+
};
|
|
1302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StandardModal, {
|
|
1303
|
+
isOpen: true,
|
|
1304
|
+
"data-cy": "matter-restore-wizard",
|
|
1305
|
+
onOpenChange: (open) => !open && close(),
|
|
1306
|
+
size: "lg",
|
|
1307
|
+
backdropProps: { isDismissable: false },
|
|
1308
|
+
children: [
|
|
1309
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalHeading, { children: t("fabric.restore.title") }) }),
|
|
1310
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ModalBody, {
|
|
1311
|
+
className: "mt:flex mt:flex-col mt:gap-4",
|
|
1312
|
+
children: [
|
|
1313
|
+
step === "select" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RestoreSourceStep, {
|
|
1314
|
+
stored,
|
|
1315
|
+
mode,
|
|
1316
|
+
onMode: setMode,
|
|
1317
|
+
backupId,
|
|
1318
|
+
onBackupId: setBackupId,
|
|
1319
|
+
onFile: (next) => {
|
|
1320
|
+
setFile(next);
|
|
1321
|
+
setError(null);
|
|
1322
|
+
},
|
|
1323
|
+
recoveryKey,
|
|
1324
|
+
onRecoveryKey: setRecoveryKey,
|
|
1325
|
+
error
|
|
1326
|
+
}),
|
|
1327
|
+
step === "preview" && validation && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PreviewStep, {
|
|
1328
|
+
validation,
|
|
1329
|
+
typed,
|
|
1330
|
+
onTyped: setTyped,
|
|
1331
|
+
error
|
|
1332
|
+
}),
|
|
1333
|
+
step === "running" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
1334
|
+
role: "status",
|
|
1335
|
+
children: t("fabric.restore.running")
|
|
1336
|
+
}),
|
|
1337
|
+
(step === "success" || step === "failed") && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ResultStep, {
|
|
1338
|
+
step,
|
|
1339
|
+
error
|
|
1340
|
+
})
|
|
1341
|
+
]
|
|
1342
|
+
}),
|
|
1343
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalFooter, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(WizardFooter, {
|
|
1344
|
+
step,
|
|
1345
|
+
busy,
|
|
1346
|
+
canValidate: !busy && (mode === "stored" ? backupId !== null : file !== null),
|
|
1347
|
+
canConfirm: confirmed,
|
|
1348
|
+
danger: preflight?.requiresTypedConfirmation === true,
|
|
1349
|
+
onClose: close,
|
|
1350
|
+
onValidate: () => void validate(),
|
|
1351
|
+
onConfirm: () => void confirm()
|
|
1352
|
+
}) })
|
|
1353
|
+
]
|
|
1354
|
+
});
|
|
1355
|
+
}
|
|
1356
|
+
//#endregion
|
|
1357
|
+
//#region frontend/src/fabric-backup/useFabricBackup.ts
|
|
1358
|
+
var { useCallback: useCallback$1, useEffect: useEffect$1, useRef: useRef$1, useState: useState$3 } = await importShared("react");
|
|
1359
|
+
var FABRIC_POLL_MS = 1e4;
|
|
1360
|
+
/** The longest pause between polls while the status keeps failing. */
|
|
1361
|
+
var FABRIC_POLL_MAX_BACKOFF_MS = 3e5;
|
|
1362
|
+
var messageOf$2 = (error) => error instanceof Error ? error.message : String(error);
|
|
1363
|
+
/** How long to wait before the next poll after `failures` failed polls in a row: doubling, capped. */
|
|
1364
|
+
var pollBackoffMs = (failures) => failures === 0 ? 0 : Math.min(FABRIC_POLL_MS * 2 ** failures, FABRIC_POLL_MAX_BACKOFF_MS);
|
|
1365
|
+
/**
|
|
1366
|
+
* Loads and polls the fabric & backup status. It does not poll while the page is hidden (it refreshes as soon as
|
|
1367
|
+
* it is shown again) and backs off while the status keeps failing. The status never contains the recovery key (the
|
|
1368
|
+
* key only travels in the one-off reveal response, which callers keep in component state), so holding it is safe.
|
|
1369
|
+
*/
|
|
1370
|
+
function useFabricBackup() {
|
|
1371
|
+
const [status, setStatusState] = useState$3(null);
|
|
1372
|
+
const [error, setError] = useState$3(null);
|
|
1373
|
+
const [loading, setLoading] = useState$3(true);
|
|
1374
|
+
const mounted = useRef$1(true);
|
|
1375
|
+
const seq = useRef$1(0);
|
|
1376
|
+
/** Resolves to whether the status could be loaded. */
|
|
1377
|
+
const refresh = useCallback$1(async () => {
|
|
1378
|
+
const mine = ++seq.current;
|
|
1379
|
+
try {
|
|
1380
|
+
const next = await getFabricStatus();
|
|
1381
|
+
if (mounted.current && mine === seq.current) {
|
|
1382
|
+
setStatusState(next);
|
|
1383
|
+
setError(null);
|
|
1384
|
+
}
|
|
1385
|
+
return true;
|
|
1386
|
+
} catch (caught) {
|
|
1387
|
+
if (mounted.current && mine === seq.current) setError(messageOf$2(caught));
|
|
1388
|
+
return false;
|
|
1389
|
+
}
|
|
1390
|
+
}, []);
|
|
1391
|
+
/** Adopts a status that an action already returned. */
|
|
1392
|
+
const setStatus = useCallback$1((next) => {
|
|
1393
|
+
seq.current += 1;
|
|
1394
|
+
setStatusState(next);
|
|
1395
|
+
setError(null);
|
|
1396
|
+
}, []);
|
|
1397
|
+
useEffect$1(() => {
|
|
1398
|
+
mounted.current = true;
|
|
1399
|
+
let failures = 0;
|
|
1400
|
+
let notBefore = 0;
|
|
1401
|
+
const poll = async () => {
|
|
1402
|
+
failures = await refresh() ? 0 : failures + 1;
|
|
1403
|
+
notBefore = Date.now() + pollBackoffMs(failures);
|
|
1404
|
+
};
|
|
1405
|
+
const tick = () => {
|
|
1406
|
+
if (!document.hidden && Date.now() >= notBefore) poll();
|
|
1407
|
+
};
|
|
1408
|
+
const onVisibility = () => {
|
|
1409
|
+
if (!document.hidden) poll();
|
|
1410
|
+
};
|
|
1411
|
+
poll().finally(() => mounted.current && setLoading(false));
|
|
1412
|
+
const timer = setInterval(tick, FABRIC_POLL_MS);
|
|
1413
|
+
document.addEventListener("visibilitychange", onVisibility);
|
|
1414
|
+
return () => {
|
|
1415
|
+
mounted.current = false;
|
|
1416
|
+
clearInterval(timer);
|
|
1417
|
+
document.removeEventListener("visibilitychange", onVisibility);
|
|
1418
|
+
};
|
|
1419
|
+
}, [refresh]);
|
|
1420
|
+
return {
|
|
1421
|
+
status,
|
|
1422
|
+
error,
|
|
1423
|
+
loading,
|
|
1424
|
+
refresh,
|
|
1425
|
+
setStatus
|
|
1426
|
+
};
|
|
1427
|
+
}
|
|
1428
|
+
//#endregion
|
|
1429
|
+
//#region frontend/src/fabric-backup/FabricBackupSection.tsx
|
|
1430
|
+
var { StatusAlert: StatusAlert$2, StatusDialog: StatusDialog$1, useDateTimeFormatter: useDateTimeFormatter$2 } = await importShared("@attraccess/plugins-frontend-ui");
|
|
1431
|
+
var { Spinner: Spinner$1 } = await importShared("@heroui/react");
|
|
1432
|
+
var { useState: useState$2 } = await importShared("react");
|
|
1433
|
+
/**
|
|
1434
|
+
* Fabric identity, recovery key, backups and recovery of the Matter plugin. Self-contained on purpose (it only
|
|
1435
|
+
* needs `/api/matter/*` and the plugin's i18n), so it can move into the Infrastructure tab (ATT-997) unchanged.
|
|
1436
|
+
*
|
|
1437
|
+
* The recovery key lives only in `reveal` state while the reveal modal is open; it is never put into the status,
|
|
1438
|
+
* a cache or storage, and is dropped as soon as the administrator acknowledged it.
|
|
1439
|
+
*/
|
|
1440
|
+
function FabricBackupSection() {
|
|
1441
|
+
const { t } = useMatterTranslations();
|
|
1442
|
+
const errorText = useErrorText();
|
|
1443
|
+
const formatDateTime = useDateTimeFormatter$2({ showSeconds: true });
|
|
1444
|
+
const { status, error, loading, refresh, setStatus } = useFabricBackup();
|
|
1445
|
+
const [reveal, setReveal] = useState$2(null);
|
|
1446
|
+
/** The running action: every action button is disabled meanwhile, only this one spins. */
|
|
1447
|
+
const [pending, setPending] = useState$2(null);
|
|
1448
|
+
const [notice, setNotice] = useState$2(null);
|
|
1449
|
+
const [restoring, setRestoring] = useState$2(false);
|
|
1450
|
+
const [rotating, setRotating] = useState$2(false);
|
|
1451
|
+
const act = async (name, title, action, keyOf) => {
|
|
1452
|
+
setPending(name);
|
|
1453
|
+
try {
|
|
1454
|
+
await action();
|
|
1455
|
+
} catch (caught) {
|
|
1456
|
+
setNotice({
|
|
1457
|
+
title,
|
|
1458
|
+
message: errorText(caught, keyOf)
|
|
1459
|
+
});
|
|
1460
|
+
refresh();
|
|
1461
|
+
} finally {
|
|
1462
|
+
setPending(null);
|
|
1463
|
+
}
|
|
1464
|
+
};
|
|
1465
|
+
const showKey = (key) => key && setReveal(key);
|
|
1466
|
+
const adopt = (result) => {
|
|
1467
|
+
setStatus(result.status);
|
|
1468
|
+
showKey(result.recoveryKey);
|
|
1469
|
+
};
|
|
1470
|
+
const create = () => act("create", t("fabric.createError"), async () => adopt(await createFabric()));
|
|
1471
|
+
const generateKey = () => act("generateKey", t("fabric.key.generateError"), async () => {
|
|
1472
|
+
showKey(await generateRecoveryKey());
|
|
1473
|
+
await refresh();
|
|
1474
|
+
});
|
|
1475
|
+
const rotate = () => act("rotate", t("fabric.key.rotateError"), async () => {
|
|
1476
|
+
try {
|
|
1477
|
+
showKey(await rotateRecoveryKey());
|
|
1478
|
+
} finally {
|
|
1479
|
+
setRotating(false);
|
|
1480
|
+
}
|
|
1481
|
+
await refresh();
|
|
1482
|
+
});
|
|
1483
|
+
const backup = () => act("backup", t("fabric.backups.error"), async () => {
|
|
1484
|
+
await backUpNow();
|
|
1485
|
+
await refresh();
|
|
1486
|
+
}, backupReasonKey);
|
|
1487
|
+
const download = (item) => act(downloadAction(item), t("fabric.backups.downloadError"), () => downloadBackup(item.id));
|
|
1488
|
+
const acceptSidecar = () => act("accept", t("fabric.recovery.error"), async () => setStatus(await acceptSidecarFabric()));
|
|
1489
|
+
const startNew = () => act("startNew", t("fabric.recovery.error"), async () => adopt(await startNewFabric()));
|
|
1490
|
+
const acknowledge = async (keyId) => {
|
|
1491
|
+
setStatus(await acknowledgeRecoveryKey(keyId));
|
|
1492
|
+
};
|
|
1493
|
+
let body;
|
|
1494
|
+
if (loading) body = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner$1, { "aria-label": t("fabric.loading") });
|
|
1495
|
+
else if (status) {
|
|
1496
|
+
const busy = pending !== null;
|
|
1497
|
+
const openRestore = () => setRestoring(true);
|
|
1498
|
+
body = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
1499
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FabricStatusCard, {
|
|
1500
|
+
status,
|
|
1501
|
+
busy,
|
|
1502
|
+
creating: pending === "create",
|
|
1503
|
+
onCreate: () => void create(),
|
|
1504
|
+
onRestore: openRestore
|
|
1505
|
+
}),
|
|
1506
|
+
status.recovery.required && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecoveryPanel, {
|
|
1507
|
+
status,
|
|
1508
|
+
pending,
|
|
1509
|
+
onRestore: openRestore,
|
|
1510
|
+
onAcceptSidecar: acceptSidecar,
|
|
1511
|
+
onStartNew: startNew
|
|
1512
|
+
}),
|
|
1513
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(KeyCard, {
|
|
1514
|
+
status,
|
|
1515
|
+
busy,
|
|
1516
|
+
generating: pending === "generateKey",
|
|
1517
|
+
onGenerateKey: () => void generateKey(),
|
|
1518
|
+
onRotate: () => setRotating(true),
|
|
1519
|
+
formatDateTime
|
|
1520
|
+
}),
|
|
1521
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(BackupsCard, {
|
|
1522
|
+
status,
|
|
1523
|
+
pending,
|
|
1524
|
+
onBackup: () => void backup(),
|
|
1525
|
+
onDownload: (item) => void download(item),
|
|
1526
|
+
onRestore: openRestore,
|
|
1527
|
+
formatDateTime
|
|
1528
|
+
})
|
|
1529
|
+
] });
|
|
1530
|
+
} else body = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$2, {
|
|
1531
|
+
status: "danger",
|
|
1532
|
+
title: t("fabric.loadError"),
|
|
1533
|
+
"data-cy": "matter-fabric-load-error",
|
|
1534
|
+
children: error
|
|
1535
|
+
});
|
|
1536
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
|
|
1537
|
+
className: "mt:flex mt:flex-col mt:gap-4",
|
|
1538
|
+
"data-cy": "matter-fabric-section",
|
|
1539
|
+
children: [
|
|
1540
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {
|
|
1541
|
+
className: "mt:text-lg mt:font-semibold",
|
|
1542
|
+
children: t("fabric.title")
|
|
1543
|
+
}),
|
|
1544
|
+
body,
|
|
1545
|
+
reveal && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecoveryKeyModal, {
|
|
1546
|
+
reveal,
|
|
1547
|
+
onAcknowledge: acknowledge,
|
|
1548
|
+
onDone: () => setReveal(null)
|
|
1549
|
+
}),
|
|
1550
|
+
restoring && status && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RestoreWizard, {
|
|
1551
|
+
stored: status.backups.stored,
|
|
1552
|
+
onClose: () => {
|
|
1553
|
+
setRestoring(false);
|
|
1554
|
+
refresh();
|
|
1555
|
+
},
|
|
1556
|
+
onRestored: setStatus
|
|
1557
|
+
}),
|
|
1558
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog$1, {
|
|
1559
|
+
isOpen: rotating,
|
|
1560
|
+
status: "warning",
|
|
1561
|
+
title: t("fabric.key.rotateTitle"),
|
|
1562
|
+
onClose: () => setRotating(false),
|
|
1563
|
+
action: {
|
|
1564
|
+
label: t("fabric.key.rotateConfirm"),
|
|
1565
|
+
isPending: pending === "rotate",
|
|
1566
|
+
onPress: rotate,
|
|
1567
|
+
"data-cy": "matter-rotate-confirm"
|
|
1568
|
+
},
|
|
1569
|
+
"data-cy": "matter-rotate-dialog",
|
|
1570
|
+
children: t("fabric.key.rotateText")
|
|
1571
|
+
}),
|
|
1572
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog$1, {
|
|
1573
|
+
isOpen: notice !== null,
|
|
1574
|
+
status: "error",
|
|
1575
|
+
title: notice?.title ?? "",
|
|
1576
|
+
onClose: () => setNotice(null),
|
|
1577
|
+
"data-cy": "matter-fabric-error-dialog",
|
|
1578
|
+
children: notice?.message ?? ""
|
|
1579
|
+
})
|
|
1580
|
+
]
|
|
1581
|
+
});
|
|
1582
|
+
}
|
|
1583
|
+
//#endregion
|
|
1584
|
+
//#region frontend/src/SettingsForm.tsx
|
|
1585
|
+
var { Button, PasswordInput, StatusDialog, useDateTimeFormatter: useDateTimeFormatter$1 } = await importShared("@attraccess/plugins-frontend-ui");
|
|
1586
|
+
var { Description, Form, Input, Label, TextArea, TextField } = await importShared("@heroui/react");
|
|
1587
|
+
var { useState: useState$1 } = await importShared("react");
|
|
1588
|
+
var messageOf$1 = (error) => error instanceof Error ? error.message : String(error);
|
|
1589
|
+
/**
|
|
1590
|
+
* The token is write-only: once saved, the form only shows that one is configured and offers to replace it. The
|
|
1591
|
+
* backend never sends it back.
|
|
1592
|
+
*/
|
|
1593
|
+
function SettingsForm({ settings, onSave, onRemove }) {
|
|
1594
|
+
const { t } = useMatterTranslations();
|
|
1595
|
+
const formatDateTime = useDateTimeFormatter$1({});
|
|
1596
|
+
const [url, setUrl] = useState$1(settings.url ?? "");
|
|
1597
|
+
const [replacing, setReplacing] = useState$1(!settings.credentialConfigured);
|
|
1598
|
+
const [credential, setCredential] = useState$1("");
|
|
1599
|
+
const [ca, setCa] = useState$1(settings.caCertificate ?? "");
|
|
1600
|
+
const [caCleared, setCaCleared] = useState$1(false);
|
|
1601
|
+
const [busy, setBusy] = useState$1(false);
|
|
1602
|
+
const [notice, setNotice] = useState$1(null);
|
|
1603
|
+
const caChanged = caCleared || ca.trim() !== (settings.caCertificate ?? "").trim();
|
|
1604
|
+
const canSave = url.trim() !== "" && (!replacing || credential !== "") && !busy;
|
|
1605
|
+
const submit = async (event) => {
|
|
1606
|
+
event.preventDefault();
|
|
1607
|
+
const input = { url: url.trim() };
|
|
1608
|
+
if (replacing) input.credential = credential;
|
|
1609
|
+
if (caChanged) input.caCertificate = ca.trim() === "" || caCleared ? null : ca.trim();
|
|
1610
|
+
setBusy(true);
|
|
1611
|
+
try {
|
|
1612
|
+
const saved = await onSave(input);
|
|
1613
|
+
setUrl(saved.url ?? "");
|
|
1614
|
+
setCa(saved.caCertificate ?? "");
|
|
1615
|
+
setCaCleared(false);
|
|
1616
|
+
setCredential("");
|
|
1617
|
+
setReplacing(!saved.credentialConfigured);
|
|
1618
|
+
setNotice({ kind: "saved" });
|
|
1619
|
+
} catch (error) {
|
|
1620
|
+
setNotice({
|
|
1621
|
+
kind: "error",
|
|
1622
|
+
title: t("form.saveError"),
|
|
1623
|
+
message: messageOf$1(error)
|
|
1624
|
+
});
|
|
1625
|
+
} finally {
|
|
1626
|
+
setBusy(false);
|
|
1627
|
+
}
|
|
1628
|
+
};
|
|
1629
|
+
const remove = async () => {
|
|
1630
|
+
setBusy(true);
|
|
1631
|
+
try {
|
|
1632
|
+
await onRemove();
|
|
1633
|
+
setUrl("");
|
|
1634
|
+
setCa("");
|
|
1635
|
+
setCaCleared(false);
|
|
1636
|
+
setCredential("");
|
|
1637
|
+
setReplacing(true);
|
|
1638
|
+
setNotice(null);
|
|
1639
|
+
} catch (error) {
|
|
1640
|
+
setNotice({
|
|
1641
|
+
kind: "error",
|
|
1642
|
+
title: t("form.removeError"),
|
|
1643
|
+
message: messageOf$1(error)
|
|
1644
|
+
});
|
|
1645
|
+
} finally {
|
|
1646
|
+
setBusy(false);
|
|
1647
|
+
}
|
|
1648
|
+
};
|
|
1649
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
|
|
1650
|
+
className: "mt:flex mt:flex-col mt:gap-4",
|
|
1651
|
+
"data-cy": "matter-settings",
|
|
1652
|
+
children: [
|
|
1653
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {
|
|
1654
|
+
className: "mt:text-lg mt:font-semibold",
|
|
1655
|
+
children: t("form.title")
|
|
1656
|
+
}),
|
|
1657
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Form, {
|
|
1658
|
+
onSubmit: submit,
|
|
1659
|
+
className: "mt:flex mt:flex-col mt:gap-4",
|
|
1660
|
+
children: [
|
|
1661
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TextField, {
|
|
1662
|
+
value: url,
|
|
1663
|
+
onChange: setUrl,
|
|
1664
|
+
className: "mt:w-full",
|
|
1665
|
+
isRequired: true,
|
|
1666
|
+
children: [
|
|
1667
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label, { children: t("form.url") }),
|
|
1668
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
|
|
1669
|
+
placeholder: t("form.urlPlaceholder"),
|
|
1670
|
+
autoComplete: "off",
|
|
1671
|
+
"data-cy": "matter-url-input"
|
|
1672
|
+
}),
|
|
1673
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Description, { children: t("form.urlDescription") })
|
|
1674
|
+
]
|
|
1675
|
+
}),
|
|
1676
|
+
replacing ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1677
|
+
className: "mt:flex mt:flex-col mt:gap-2",
|
|
1678
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PasswordInput, {
|
|
1679
|
+
label: t("form.credential"),
|
|
1680
|
+
description: t("form.credentialDescription"),
|
|
1681
|
+
autoComplete: "new-password",
|
|
1682
|
+
value: credential,
|
|
1683
|
+
onValueChange: setCredential,
|
|
1684
|
+
"data-cy": "matter-credential-input"
|
|
1685
|
+
}), settings.credentialConfigured && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
|
|
1686
|
+
variant: "tertiary",
|
|
1687
|
+
onPress: () => setReplacing(false),
|
|
1688
|
+
"data-cy": "matter-keep-credential",
|
|
1689
|
+
children: t("form.cancelReplace")
|
|
1690
|
+
})]
|
|
1691
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1692
|
+
className: "mt:flex mt:flex-wrap mt:items-center mt:justify-between mt:gap-2",
|
|
1693
|
+
"data-cy": "matter-credential-configured",
|
|
1694
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
1695
|
+
t("form.credential"),
|
|
1696
|
+
":",
|
|
1697
|
+
" ",
|
|
1698
|
+
t("form.credentialConfigured", { time: formatDateTime(settings.credentialUpdatedAt) })
|
|
1699
|
+
] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
|
|
1700
|
+
variant: "secondary",
|
|
1701
|
+
onPress: () => setReplacing(true),
|
|
1702
|
+
"data-cy": "matter-replace-credential",
|
|
1703
|
+
children: t("form.replace")
|
|
1704
|
+
})]
|
|
1705
|
+
}),
|
|
1706
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TextField, {
|
|
1707
|
+
value: caCleared ? "" : ca,
|
|
1708
|
+
onChange: setCa,
|
|
1709
|
+
isDisabled: caCleared,
|
|
1710
|
+
className: "mt:w-full",
|
|
1711
|
+
children: [
|
|
1712
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label, { children: t("form.ca") }),
|
|
1713
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TextArea, {
|
|
1714
|
+
rows: 5,
|
|
1715
|
+
spellCheck: false,
|
|
1716
|
+
"data-cy": "matter-ca-input"
|
|
1717
|
+
}),
|
|
1718
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Description, { children: caCleared ? t("form.caCleared") : t("form.caDescription") })
|
|
1719
|
+
]
|
|
1720
|
+
}),
|
|
1721
|
+
settings.caCertificate && !caCleared && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
|
|
1722
|
+
variant: "tertiary",
|
|
1723
|
+
onPress: () => setCaCleared(true),
|
|
1724
|
+
"data-cy": "matter-clear-ca",
|
|
1725
|
+
children: t("form.caClear")
|
|
1726
|
+
}),
|
|
1727
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1728
|
+
className: "mt:flex mt:flex-wrap mt:gap-2",
|
|
1729
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
|
|
1730
|
+
type: "submit",
|
|
1731
|
+
isDisabled: !canSave,
|
|
1732
|
+
isPending: busy,
|
|
1733
|
+
"data-cy": "matter-save",
|
|
1734
|
+
children: t("form.save")
|
|
1735
|
+
}), settings.url !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
|
|
1736
|
+
variant: "danger-soft",
|
|
1737
|
+
isDisabled: busy,
|
|
1738
|
+
onPress: () => setNotice({ kind: "remove" }),
|
|
1739
|
+
"data-cy": "matter-remove",
|
|
1740
|
+
children: t("form.remove")
|
|
1741
|
+
})]
|
|
1742
|
+
})
|
|
1743
|
+
]
|
|
1744
|
+
}) }),
|
|
1745
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog, {
|
|
1746
|
+
isOpen: notice?.kind === "saved",
|
|
1747
|
+
status: "success",
|
|
1748
|
+
title: t("form.saved"),
|
|
1749
|
+
onClose: () => setNotice(null),
|
|
1750
|
+
"data-cy": "matter-saved-dialog",
|
|
1751
|
+
children: t("form.savedText")
|
|
1752
|
+
}),
|
|
1753
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog, {
|
|
1754
|
+
isOpen: notice?.kind === "error",
|
|
1755
|
+
status: "error",
|
|
1756
|
+
title: notice?.kind === "error" ? notice.title : "",
|
|
1757
|
+
onClose: () => setNotice(null),
|
|
1758
|
+
"data-cy": "matter-error-dialog",
|
|
1759
|
+
children: notice?.kind === "error" ? notice.message : ""
|
|
1760
|
+
}),
|
|
1761
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog, {
|
|
1762
|
+
isOpen: notice?.kind === "remove",
|
|
1763
|
+
status: "warning",
|
|
1764
|
+
title: t("form.removeTitle"),
|
|
1765
|
+
onClose: () => setNotice(null),
|
|
1766
|
+
action: {
|
|
1767
|
+
label: t("form.removeConfirm"),
|
|
1768
|
+
isPending: busy,
|
|
1769
|
+
onPress: async () => {
|
|
1770
|
+
setNotice(null);
|
|
1771
|
+
await remove();
|
|
1772
|
+
}
|
|
1773
|
+
},
|
|
1774
|
+
"data-cy": "matter-remove-dialog",
|
|
1775
|
+
children: t("form.removeText")
|
|
1776
|
+
})
|
|
1777
|
+
]
|
|
1778
|
+
});
|
|
1779
|
+
}
|
|
1780
|
+
//#endregion
|
|
1781
|
+
//#region frontend/src/StatusCard.tsx
|
|
1782
|
+
var { StatusAlert: StatusAlert$1, useDateTimeFormatter } = await importShared("@attraccess/plugins-frontend-ui");
|
|
1783
|
+
var { Card, Chip } = await importShared("@heroui/react");
|
|
1784
|
+
var STATE_COLOR = {
|
|
1785
|
+
not_configured: "default",
|
|
1786
|
+
connecting: "accent",
|
|
1787
|
+
connected: "success",
|
|
1788
|
+
degraded: "warning"
|
|
1789
|
+
};
|
|
1790
|
+
/** `unavailable` usually heals by itself; the other reasons need the administrator. */
|
|
1791
|
+
var REASON_COLOR = {
|
|
1792
|
+
unavailable: "warning",
|
|
1793
|
+
unauthorized: "danger",
|
|
1794
|
+
incompatible: "danger",
|
|
1795
|
+
misconfigured: "danger"
|
|
1796
|
+
};
|
|
1797
|
+
function Field({ label, children, dataCy }) {
|
|
1798
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1799
|
+
className: "mt:flex mt:flex-col",
|
|
1800
|
+
"data-cy": dataCy,
|
|
1801
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", {
|
|
1802
|
+
className: "mt:text-xs mt:text-muted",
|
|
1803
|
+
children: label
|
|
1804
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", {
|
|
1805
|
+
className: "mt:break-words",
|
|
1806
|
+
children
|
|
1807
|
+
})]
|
|
1808
|
+
});
|
|
1809
|
+
}
|
|
1810
|
+
/** What the administrator can do about the current state. */
|
|
1811
|
+
function hintKey(status) {
|
|
1812
|
+
if (status.state !== "degraded") return `hint.${status.state}`;
|
|
1813
|
+
if (status.reasonDetail === "host version unavailable") return "hint.hostVersion";
|
|
1814
|
+
return `hint.${status.reason ?? "unavailable"}`;
|
|
1815
|
+
}
|
|
1816
|
+
/** The lowest Attraccess version of the first supported combination, e.g. `1.11.0` for `^1.11.0`. */
|
|
1817
|
+
function minimumAttraccess(status) {
|
|
1818
|
+
const range = status.supported[0]?.attraccess ?? "";
|
|
1819
|
+
return range.match(/\d+\.\d+\.\d+/)?.[0] ?? range;
|
|
1820
|
+
}
|
|
1821
|
+
function Combination({ entry }) {
|
|
1822
|
+
const { t } = useMatterTranslations();
|
|
1823
|
+
const value = (key) => String(entry[key] ?? "?");
|
|
1824
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: t("status.combination", {
|
|
1825
|
+
attraccess: value("attraccess"),
|
|
1826
|
+
plugin: value("plugin"),
|
|
1827
|
+
sidecar: value("sidecar"),
|
|
1828
|
+
matterJs: value("matterJs")
|
|
1829
|
+
}) });
|
|
1830
|
+
}
|
|
1831
|
+
function StatusCard({ status }) {
|
|
1832
|
+
const { t } = useMatterTranslations();
|
|
1833
|
+
const formatDateTime = useDateTimeFormatter({ showSeconds: true });
|
|
1834
|
+
const error = status.lastError;
|
|
1835
|
+
const received = error?.details?.received;
|
|
1836
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card, {
|
|
1837
|
+
"data-cy": "matter-status-card",
|
|
1838
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card.Header, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card.Title, { children: t("status.title") }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card.Content, {
|
|
1839
|
+
className: "mt:flex mt:flex-col mt:gap-4",
|
|
1840
|
+
children: [
|
|
1841
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1842
|
+
className: "mt:flex mt:flex-wrap mt:items-center mt:gap-2",
|
|
1843
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Chip, {
|
|
1844
|
+
color: STATE_COLOR[status.state],
|
|
1845
|
+
variant: "soft",
|
|
1846
|
+
"data-cy": "matter-state-chip",
|
|
1847
|
+
children: t(`status.state.${status.state}`)
|
|
1848
|
+
}), status.reason && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Chip, {
|
|
1849
|
+
color: REASON_COLOR[status.reason],
|
|
1850
|
+
variant: "soft",
|
|
1851
|
+
"data-cy": "matter-reason-chip",
|
|
1852
|
+
children: t(`status.reason.${status.reason}`)
|
|
1853
|
+
})]
|
|
1854
|
+
}),
|
|
1855
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
1856
|
+
"data-cy": "matter-hint",
|
|
1857
|
+
children: t(hintKey(status), { attraccess: minimumAttraccess(status) })
|
|
1858
|
+
}),
|
|
1859
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("dl", {
|
|
1860
|
+
className: "mt:grid mt:grid-cols-1 mt:gap-3 mt:sm:grid-cols-2",
|
|
1861
|
+
children: [
|
|
1862
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
|
|
1863
|
+
label: t("status.since"),
|
|
1864
|
+
children: formatDateTime(status.since)
|
|
1865
|
+
}),
|
|
1866
|
+
status.nextRetryAt && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
|
|
1867
|
+
label: t("status.nextRetry"),
|
|
1868
|
+
dataCy: "matter-next-retry",
|
|
1869
|
+
children: formatDateTime(status.nextRetryAt)
|
|
1870
|
+
}),
|
|
1871
|
+
status.sidecar && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
|
|
1872
|
+
label: t("status.sidecarVersion"),
|
|
1873
|
+
children: status.sidecar.sidecar
|
|
1874
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
|
|
1875
|
+
label: t("status.matterJsVersion"),
|
|
1876
|
+
children: status.sidecar.matterJs
|
|
1877
|
+
})] }),
|
|
1878
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
|
|
1879
|
+
label: t("status.wireVersion"),
|
|
1880
|
+
children: status.wireVersion
|
|
1881
|
+
})
|
|
1882
|
+
]
|
|
1883
|
+
}),
|
|
1884
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StatusAlert$1, {
|
|
1885
|
+
status: "warning",
|
|
1886
|
+
title: t("status.lastError"),
|
|
1887
|
+
"data-cy": "matter-last-error",
|
|
1888
|
+
children: [error.message, error.correlationId && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
1889
|
+
className: "mt:block mt:text-xs",
|
|
1890
|
+
children: [
|
|
1891
|
+
t("status.correlationId"),
|
|
1892
|
+
": ",
|
|
1893
|
+
error.correlationId
|
|
1894
|
+
]
|
|
1895
|
+
})]
|
|
1896
|
+
}),
|
|
1897
|
+
status.reason === "incompatible" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1898
|
+
"data-cy": "matter-compatibility",
|
|
1899
|
+
children: [
|
|
1900
|
+
received && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
1901
|
+
className: "mt:font-medium",
|
|
1902
|
+
children: t("status.received")
|
|
1903
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
|
|
1904
|
+
className: "mt:list-disc mt:pl-5",
|
|
1905
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Combination, { entry: received })
|
|
1906
|
+
})] }),
|
|
1907
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
1908
|
+
className: "mt:font-medium",
|
|
1909
|
+
children: t("status.supported")
|
|
1910
|
+
}),
|
|
1911
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
|
|
1912
|
+
className: "mt:list-disc mt:pl-5",
|
|
1913
|
+
children: status.supported.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Combination, { entry }, `${entry.plugin}-${entry.sidecar}`))
|
|
1914
|
+
})
|
|
1915
|
+
]
|
|
1916
|
+
})
|
|
1917
|
+
]
|
|
1918
|
+
})]
|
|
1919
|
+
});
|
|
1920
|
+
}
|
|
1921
|
+
//#endregion
|
|
1922
|
+
//#region frontend/src/api.ts
|
|
1923
|
+
var api = createPluginApiClient("/api/matter/connection");
|
|
1924
|
+
var getSettings = () => api.request("");
|
|
1925
|
+
var getStatus = () => api.request("/status");
|
|
1926
|
+
var saveSettings = (input) => api.request("", {
|
|
1927
|
+
method: "PUT",
|
|
1928
|
+
body: input
|
|
1929
|
+
});
|
|
1930
|
+
var removeSettings = () => api.request("", { method: "DELETE" });
|
|
1931
|
+
//#endregion
|
|
1932
|
+
//#region frontend/src/useMatterPage.ts
|
|
1933
|
+
var { useCallback, useEffect, useRef, useState } = await importShared("react");
|
|
1934
|
+
/** How often the open page refreshes the connection status. */
|
|
1935
|
+
var STATUS_POLL_MS = 5e3;
|
|
1936
|
+
/** A request still pending after this long counts as failed, so one hung request cannot stop the polling. */
|
|
1937
|
+
var REQUEST_TIMEOUT_MS = 2 * STATUS_POLL_MS;
|
|
1938
|
+
var messageOf = (error) => error instanceof Error ? error.message : String(error);
|
|
1939
|
+
function withTimeout(request) {
|
|
1940
|
+
return new Promise((resolve, reject) => {
|
|
1941
|
+
const timer = setTimeout(() => reject(/* @__PURE__ */ new Error("The request timed out.")), REQUEST_TIMEOUT_MS);
|
|
1942
|
+
request.then(resolve, reject).finally(() => clearTimeout(timer));
|
|
1943
|
+
});
|
|
1944
|
+
}
|
|
1945
|
+
/**
|
|
1946
|
+
* Loads the settings and polls the status while the page is open. Saving and removing refresh both. If the first
|
|
1947
|
+
* settings load failed (API briefly down), the poll retries it so the form appears without a manual reload.
|
|
1948
|
+
*
|
|
1949
|
+
* A poll tick is skipped while an earlier request is still pending, so a hanging API does not pile up requests, and
|
|
1950
|
+
* only the newest status request may update the page, so a late answer never overwrites a newer one.
|
|
1951
|
+
*/
|
|
1952
|
+
function useMatterPage() {
|
|
1953
|
+
const [settings, setSettings] = useState(null);
|
|
1954
|
+
const [status, setStatus] = useState(null);
|
|
1955
|
+
const [statusError, setStatusError] = useState(null);
|
|
1956
|
+
const [settingsError, setSettingsError] = useState(null);
|
|
1957
|
+
const [loading, setLoading] = useState(true);
|
|
1958
|
+
const mounted = useRef(true);
|
|
1959
|
+
const settingsLoaded = useRef(false);
|
|
1960
|
+
const statusSeq = useRef(0);
|
|
1961
|
+
const statusPending = useRef(0);
|
|
1962
|
+
const settingsPending = useRef(false);
|
|
1963
|
+
const refreshStatus = useCallback(async () => {
|
|
1964
|
+
const seq = ++statusSeq.current;
|
|
1965
|
+
statusPending.current += 1;
|
|
1966
|
+
try {
|
|
1967
|
+
const next = await withTimeout(getStatus());
|
|
1968
|
+
if (!mounted.current || seq !== statusSeq.current) return;
|
|
1969
|
+
setStatus(next);
|
|
1970
|
+
setStatusError(null);
|
|
1971
|
+
} catch (error) {
|
|
1972
|
+
if (mounted.current && seq === statusSeq.current) setStatusError(messageOf(error));
|
|
1973
|
+
} finally {
|
|
1974
|
+
statusPending.current -= 1;
|
|
1975
|
+
}
|
|
1976
|
+
}, []);
|
|
1977
|
+
const refreshSettings = useCallback(async () => {
|
|
1978
|
+
settingsPending.current = true;
|
|
1979
|
+
try {
|
|
1980
|
+
const next = await withTimeout(getSettings());
|
|
1981
|
+
if (!mounted.current) return;
|
|
1982
|
+
settingsLoaded.current = true;
|
|
1983
|
+
setSettings(next);
|
|
1984
|
+
setSettingsError(null);
|
|
1985
|
+
} catch (error) {
|
|
1986
|
+
if (mounted.current) setSettingsError(messageOf(error));
|
|
1987
|
+
} finally {
|
|
1988
|
+
settingsPending.current = false;
|
|
1989
|
+
}
|
|
1990
|
+
}, []);
|
|
1991
|
+
useEffect(() => {
|
|
1992
|
+
mounted.current = true;
|
|
1993
|
+
Promise.all([refreshSettings(), refreshStatus()]).finally(() => mounted.current && setLoading(false));
|
|
1994
|
+
const timer = setInterval(() => {
|
|
1995
|
+
if (statusPending.current === 0) refreshStatus();
|
|
1996
|
+
if (!settingsLoaded.current && !settingsPending.current) refreshSettings();
|
|
1997
|
+
}, STATUS_POLL_MS);
|
|
1998
|
+
return () => {
|
|
1999
|
+
mounted.current = false;
|
|
2000
|
+
clearInterval(timer);
|
|
2001
|
+
};
|
|
2002
|
+
}, [refreshSettings, refreshStatus]);
|
|
2003
|
+
return {
|
|
2004
|
+
settings,
|
|
2005
|
+
settingsError,
|
|
2006
|
+
status,
|
|
2007
|
+
statusError,
|
|
2008
|
+
loading,
|
|
2009
|
+
save: useCallback(async (input) => {
|
|
2010
|
+
const saved = await saveSettings(input);
|
|
2011
|
+
if (mounted.current) {
|
|
2012
|
+
settingsLoaded.current = true;
|
|
2013
|
+
setSettings(saved);
|
|
2014
|
+
}
|
|
2015
|
+
await refreshStatus();
|
|
2016
|
+
return saved;
|
|
2017
|
+
}, [refreshStatus]),
|
|
2018
|
+
remove: useCallback(async () => {
|
|
2019
|
+
await removeSettings();
|
|
2020
|
+
await Promise.all([refreshSettings(), refreshStatus()]);
|
|
2021
|
+
}, [refreshSettings, refreshStatus])
|
|
2022
|
+
};
|
|
2023
|
+
}
|
|
2024
|
+
//#endregion
|
|
2025
|
+
//#region frontend/src/MatterPage.tsx
|
|
2026
|
+
var { PageHeader, StatusAlert } = await importShared("@attraccess/plugins-frontend-ui");
|
|
2027
|
+
var { Spinner } = await importShared("@heroui/react");
|
|
2028
|
+
var { CableIcon: CableIcon$1 } = await importShared("lucide-react");
|
|
2029
|
+
function MatterPage() {
|
|
2030
|
+
const { t } = useMatterTranslations();
|
|
2031
|
+
const { settings, settingsError, status, statusError, loading, save, remove } = useMatterPage();
|
|
2032
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
2033
|
+
className: "mt:mx-auto mt:flex mt:w-full mt:max-w-5xl mt:flex-col mt:gap-6 mt:p-4 mt:md:p-6",
|
|
2034
|
+
"data-cy": "matter-page",
|
|
2035
|
+
children: [
|
|
2036
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader, {
|
|
2037
|
+
noMargin: true,
|
|
2038
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CableIcon$1, { className: "mt:h-6 mt:w-6 mt:text-accent-soft-foreground" }),
|
|
2039
|
+
title: t("page.title"),
|
|
2040
|
+
subtitle: t("page.subtitle")
|
|
2041
|
+
}),
|
|
2042
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, {}),
|
|
2043
|
+
status?.insecureTransport && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert, {
|
|
2044
|
+
status: "warning",
|
|
2045
|
+
title: t("page.insecure"),
|
|
2046
|
+
"data-cy": "matter-insecure-warning",
|
|
2047
|
+
children: t("page.insecureText")
|
|
2048
|
+
}),
|
|
2049
|
+
statusError && !status && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert, {
|
|
2050
|
+
status: "danger",
|
|
2051
|
+
title: t("status.loadError"),
|
|
2052
|
+
"data-cy": "matter-load-error",
|
|
2053
|
+
children: statusError
|
|
2054
|
+
}),
|
|
2055
|
+
status && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusCard, { status }),
|
|
2056
|
+
settingsError && !settings && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert, {
|
|
2057
|
+
status: "danger",
|
|
2058
|
+
title: t("form.loadError"),
|
|
2059
|
+
"data-cy": "matter-settings-load-error",
|
|
2060
|
+
children: settingsError
|
|
2061
|
+
}),
|
|
2062
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FabricBackupSection, {}),
|
|
2063
|
+
settings && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SettingsForm, {
|
|
2064
|
+
settings,
|
|
2065
|
+
onSave: save,
|
|
2066
|
+
onRemove: remove
|
|
2067
|
+
})
|
|
2068
|
+
]
|
|
2069
|
+
});
|
|
2070
|
+
}
|
|
2071
|
+
//#endregion
|
|
2072
|
+
//#region frontend/src/plugin.tsx
|
|
2073
|
+
var { CableIcon } = await importShared("lucide-react");
|
|
2074
|
+
var MatterPlugin = class {
|
|
2075
|
+
getPluginName() {
|
|
2076
|
+
return "matter-plugin@0.4.0";
|
|
2077
|
+
}
|
|
2078
|
+
getDependencies() {
|
|
2079
|
+
return [];
|
|
2080
|
+
}
|
|
2081
|
+
init(store) {
|
|
2082
|
+
this.pluginStore = store;
|
|
2083
|
+
}
|
|
2084
|
+
activate() {}
|
|
2085
|
+
deactivate() {}
|
|
2086
|
+
onApiAuthStateChange(_authData) {}
|
|
2087
|
+
onApiEndpointChange(_endpoint) {}
|
|
2088
|
+
getRoutes() {
|
|
2089
|
+
return [{
|
|
2090
|
+
path: "/matter",
|
|
2091
|
+
authRequired: "system.plugins.manage",
|
|
2092
|
+
element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MatterPage, {})
|
|
2093
|
+
}];
|
|
2094
|
+
}
|
|
2095
|
+
getSidebarItems() {
|
|
2096
|
+
return [{
|
|
2097
|
+
label: "Matter",
|
|
2098
|
+
path: "/matter",
|
|
2099
|
+
group: "devices",
|
|
2100
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CableIcon, { className: "mt:w-5 mt:h-5" })
|
|
2101
|
+
}];
|
|
2102
|
+
}
|
|
2103
|
+
};
|
|
2104
|
+
//#endregion
|
|
2105
|
+
export { MatterPlugin as default };
|