@rebasepro/app 0.16.0 → 0.16.1-canary.g0d7af95
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/auth/api.d.ts +8 -21
- package/dist/auth/index.d.ts +4 -4
- package/dist/auth/types.d.ts +1 -1
- package/dist/auth/useRebaseAuthController.d.ts +1 -1
- package/dist/collections/index.d.ts +13 -13
- package/dist/collections/title-property.d.ts +1 -1
- package/dist/components/Debug/collection-views/index.d.ts +3 -3
- package/dist/components/LoginView/LoginView.d.ts +2 -2
- package/dist/components/LoginView/index.d.ts +2 -2
- package/dist/components/common/index.d.ts +6 -6
- package/dist/components/common/useDataTableController.d.ts +1 -1
- package/dist/components/index.d.ts +18 -18
- package/dist/contexts/AdminModeController.d.ts +1 -1
- package/dist/contexts/ModeController.d.ts +1 -1
- package/dist/contexts/index.d.ts +18 -18
- package/dist/core/Rebase.d.ts +1 -1
- package/dist/core/index.d.ts +4 -4
- package/dist/hooks/index.d.ts +36 -36
- package/dist/hooks/useBridgeRegistration.d.ts +1 -1
- package/dist/hooks/useBuildAdminModeController.d.ts +1 -1
- package/dist/hooks/useBuildModeController.d.ts +1 -1
- package/dist/hooks/useUnsavedChangesDialog.d.ts +1 -1
- package/dist/index.d.ts +19 -19
- package/dist/index.es.js +129 -79
- package/dist/index.es.js.map +1 -1
- package/dist/util/index.d.ts +9 -8
- package/dist/util/local_storage.d.ts +31 -0
- package/package.json +9 -9
- package/src/auth/api.ts +8 -21
- package/src/auth/useRebaseAuthController.ts +6 -3
- package/src/collections/entity-display.ts +6 -34
- package/src/collections/form-layout.ts +2 -1
- package/src/collections/title-property.ts +1 -1
- package/src/components/Debug/UIReferenceView.tsx +53 -16
- package/src/components/LoginView/LoginView.tsx +3 -3
- package/src/components/common/useDataTableController.tsx +20 -1
- package/src/core/Rebase.tsx +3 -24
- package/src/hooks/useBuildAdminModeController.tsx +3 -4
- package/src/hooks/useBuildEffectiveRoleController.tsx +6 -7
- package/src/hooks/useBuildModeController.tsx +8 -6
- package/src/i18n/RebaseI18nProvider.tsx +5 -6
- package/src/locales/de.ts +0 -1
- package/src/locales/en.ts +0 -1
- package/src/locales/es.ts +0 -1
- package/src/locales/fr.ts +0 -1
- package/src/locales/hi.ts +0 -1
- package/src/locales/it.ts +0 -1
- package/src/locales/pt.ts +0 -1
- package/src/util/index.ts +1 -0
- package/src/util/local_storage.ts +66 -0
|
@@ -9,6 +9,7 @@ import { it } from "../locales/it";
|
|
|
9
9
|
import { hi } from "../locales/hi";
|
|
10
10
|
import { pt } from "../locales/pt";
|
|
11
11
|
import { RebaseTranslations } from "@rebasepro/admin-types";
|
|
12
|
+
import { readStoredString, writeStoredString } from "../util/local_storage";
|
|
12
13
|
|
|
13
14
|
const REBASE_NS = "rebase_core";
|
|
14
15
|
|
|
@@ -59,10 +60,8 @@ export function RebaseI18nProvider({
|
|
|
59
60
|
const resources = buildResources(translations);
|
|
60
61
|
|
|
61
62
|
let initialLocale = locale;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (stored) initialLocale = stored;
|
|
65
|
-
}
|
|
63
|
+
const stored = readStoredString(REBASE_LOCALE_STORAGE_KEY);
|
|
64
|
+
if (stored) initialLocale = stored;
|
|
66
65
|
|
|
67
66
|
instance
|
|
68
67
|
.use(initReactI18next)
|
|
@@ -82,7 +81,7 @@ export function RebaseI18nProvider({
|
|
|
82
81
|
|
|
83
82
|
instance.on("languageChanged", (lng) => {
|
|
84
83
|
if (typeof window !== "undefined") {
|
|
85
|
-
|
|
84
|
+
writeStoredString(REBASE_LOCALE_STORAGE_KEY, lng);
|
|
86
85
|
}
|
|
87
86
|
});
|
|
88
87
|
|
|
@@ -93,7 +92,7 @@ export function RebaseI18nProvider({
|
|
|
93
92
|
// ONLY if the user hasn't explicitly set a preference
|
|
94
93
|
useEffect(() => {
|
|
95
94
|
if (i18nRef.current && i18nRef.current.language !== locale) {
|
|
96
|
-
const hasUserPreference =
|
|
95
|
+
const hasUserPreference = Boolean(readStoredString(REBASE_LOCALE_STORAGE_KEY));
|
|
97
96
|
if (!hasUserPreference) {
|
|
98
97
|
i18nRef.current.changeLanguage(locale);
|
|
99
98
|
}
|
package/src/locales/de.ts
CHANGED
|
@@ -523,7 +523,6 @@ export const de: RebaseTranslations = {
|
|
|
523
523
|
add_your: "Fügen Sie Ihre",
|
|
524
524
|
database_collections: "Datenbanksammlungen",
|
|
525
525
|
no_unmapped_collections: "Keine nicht zugeordneten Sammlungen",
|
|
526
|
-
query_and_update_with_datatalk: "Fragen Sie Ihre Daten in natürlicher Sprache ab und aktualisieren Sie sie mit DATATALK",
|
|
527
526
|
welcome_to_rebase: "Willkommen bei Rebase",
|
|
528
527
|
admin_panel_ready_bring_data: "Ihr Admin-Panel ist bereit. Bringen Sie Ihre Daten ein.",
|
|
529
528
|
admin_panel_ready_get_started: "Ihr Admin-Panel ist bereit. So können Sie loslegen.",
|
package/src/locales/en.ts
CHANGED
|
@@ -637,7 +637,6 @@ export const en: RebaseTranslations = {
|
|
|
637
637
|
add_your: "Add your",
|
|
638
638
|
database_collections: "database collections",
|
|
639
639
|
no_unmapped_collections: "No unmapped collections in the database",
|
|
640
|
-
query_and_update_with_datatalk: "Query and update your data in natural language with",
|
|
641
640
|
|
|
642
641
|
welcome_to_rebase: "Welcome to Rebase Cloud",
|
|
643
642
|
admin_panel_ready_bring_data: "Your admin panel is ready. Let's bring in your data.",
|
package/src/locales/es.ts
CHANGED
|
@@ -533,7 +533,6 @@ export const es: RebaseTranslations = {
|
|
|
533
533
|
add_your: "Añade tus",
|
|
534
534
|
database_collections: "colecciones de base de datos",
|
|
535
535
|
no_unmapped_collections: "No hay colecciones sin mapear en la base de datos",
|
|
536
|
-
query_and_update_with_datatalk: "Consulta y actualiza tus datos en lenguaje natural con",
|
|
537
536
|
|
|
538
537
|
welcome_to_rebase: "Bienvenido a Rebase Cloud",
|
|
539
538
|
admin_panel_ready_bring_data: "Tu panel de administración está listo. Traigamos tus datos.",
|
package/src/locales/fr.ts
CHANGED
|
@@ -523,7 +523,6 @@ export const fr: RebaseTranslations = {
|
|
|
523
523
|
add_your: "Ajoutez vos",
|
|
524
524
|
database_collections: "collections de base de données",
|
|
525
525
|
no_unmapped_collections: "Aucune collection non mappée",
|
|
526
|
-
query_and_update_with_datatalk: "Interrogez et mettez à jour vos données en langage naturel avec",
|
|
527
526
|
welcome_to_rebase: "Bienvenue sur Rebase Cloud",
|
|
528
527
|
admin_panel_ready_bring_data: "Votre panneau d'administration est prêt. Ajoutons vos données.",
|
|
529
528
|
admin_panel_ready_get_started: "Votre panneau d'administration est prêt. Voici comment démarrer.",
|
package/src/locales/hi.ts
CHANGED
|
@@ -523,7 +523,6 @@ export const hi: RebaseTranslations = {
|
|
|
523
523
|
add_your: "अपने",
|
|
524
524
|
database_collections: "डेटाबेस संग्रह",
|
|
525
525
|
no_unmapped_collections: "कोई असंबद्ध संग्रह नहीं",
|
|
526
|
-
query_and_update_with_datatalk: "DATATALK के साथ प्राकृतिक भाषा में अपना डेटा क्वेरी और अपडेट करें",
|
|
527
526
|
welcome_to_rebase: "Rebase में आपका स्वागत है",
|
|
528
527
|
admin_panel_ready_bring_data: "आपका पैनल तैयार है। अपना डेटा जोड़कर शुरू करें।",
|
|
529
528
|
admin_panel_ready_get_started: "शुरू करें",
|
package/src/locales/it.ts
CHANGED
|
@@ -523,7 +523,6 @@ export const it: RebaseTranslations = {
|
|
|
523
523
|
add_your: "Aggiungi le tue",
|
|
524
524
|
database_collections: "collezioni del database",
|
|
525
525
|
no_unmapped_collections: "Nessuna collezione non mappata",
|
|
526
|
-
query_and_update_with_datatalk: "Interroga e aggiorna i tuoi dati in linguaggio naturale con DATATALK",
|
|
527
526
|
welcome_to_rebase: "Benvenuto in Rebase Cloud",
|
|
528
527
|
admin_panel_ready_bring_data: "Il tuo pannello è pronto. Inizia aggiungendo i tuoi dati.",
|
|
529
528
|
admin_panel_ready_get_started: "Il tuo pannello è pronto. Ecco come iniziare.",
|
package/src/locales/pt.ts
CHANGED
|
@@ -530,7 +530,6 @@ export const pt: RebaseTranslations = {
|
|
|
530
530
|
add_your: "Adicione as suas",
|
|
531
531
|
database_collections: "coleções da base de dados",
|
|
532
532
|
no_unmapped_collections: "Sem coleções não mapeadas na base de dados",
|
|
533
|
-
query_and_update_with_datatalk: "Consulte e atualize os seus dados em linguagem natural com",
|
|
534
533
|
|
|
535
534
|
welcome_to_rebase: "Bem-vindo ao Rebase Cloud",
|
|
536
535
|
admin_panel_ready_bring_data: "O seu painel de administração está pronto. Vamos importar os seus dados.",
|
package/src/util/index.ts
CHANGED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* localStorage that tolerates not being there.
|
|
3
|
+
*
|
|
4
|
+
* `typeof window !== "undefined"` was the guard these call sites used, and it
|
|
5
|
+
* answers the wrong question: it says "am I in a browser", not "can I read
|
|
6
|
+
* storage". Three things make that distinction real rather than theoretical:
|
|
7
|
+
*
|
|
8
|
+
* - A browser can have storage **disabled**. Safari in private mode, a blocked
|
|
9
|
+
* third-party cookie policy, and a sandboxed iframe all give you a `window`
|
|
10
|
+
* whose `localStorage` property *throws on access* — a SecurityError raised
|
|
11
|
+
* before any method is called, which no amount of null-checking the result
|
|
12
|
+
* catches.
|
|
13
|
+
* - A test environment can be **half torn down**. jsdom is disposed at the end
|
|
14
|
+
* of a file while React is still finishing a concurrent render, so `window`
|
|
15
|
+
* survives as a husk and `localStorage.getItem` is no longer a function.
|
|
16
|
+
* That is how this was found: `TypeError: localStorage.getItem is not a
|
|
17
|
+
* function`, thrown out of a render, failing a suite in which every one of
|
|
18
|
+
* 709 tests passed.
|
|
19
|
+
* - Server rendering has no `window` at all, which is the only case the old
|
|
20
|
+
* guard actually covered.
|
|
21
|
+
*
|
|
22
|
+
* Reading a UI preference is never worth a crash. Every function here fails to
|
|
23
|
+
* `null` / no-op, so a user with storage switched off gets the default
|
|
24
|
+
* appearance instead of a blank page.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/** The Storage object, or null when it is absent, blocked, or not usable. */
|
|
28
|
+
function usableStorage(): Storage | null {
|
|
29
|
+
try {
|
|
30
|
+
if (typeof window === "undefined") return null;
|
|
31
|
+
const candidate = window.localStorage;
|
|
32
|
+
// Not `!= null`: a torn-down jsdom leaves an object behind whose
|
|
33
|
+
// methods are gone, which is exactly the shape that threw.
|
|
34
|
+
return typeof candidate?.getItem === "function" ? candidate : null;
|
|
35
|
+
} catch {
|
|
36
|
+
// Access itself throws when storage is blocked by policy.
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The stored string for `key`, or null if it is unset or unreadable. */
|
|
42
|
+
export function readStoredString(key: string): string | null {
|
|
43
|
+
try {
|
|
44
|
+
return usableStorage()?.getItem(key) ?? null;
|
|
45
|
+
} catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Persist `value` under `key`. A no-op when storage is unavailable. */
|
|
51
|
+
export function writeStoredString(key: string, value: string): void {
|
|
52
|
+
try {
|
|
53
|
+
usableStorage()?.setItem(key, value);
|
|
54
|
+
} catch {
|
|
55
|
+
// Also the quota path: a full store throws on write but reads fine.
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Remove `key`. A no-op when storage is unavailable. */
|
|
60
|
+
export function removeStoredString(key: string): void {
|
|
61
|
+
try {
|
|
62
|
+
usableStorage()?.removeItem(key);
|
|
63
|
+
} catch {
|
|
64
|
+
/* nothing to undo */
|
|
65
|
+
}
|
|
66
|
+
}
|