@dashadmin/dash-admin 1.3.42 → 1.3.45
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/components/serviceAccount/ApiKeyRevealDialog.js +110 -0
- package/dist/components/serviceAccount/ServiceAccountStatusSwitch.js +94 -0
- package/dist/default-theme/menu/AppMenuComponents/expanded/CollapsableSidebarMenu.js +5 -1
- package/dist/default-theme/menu/AppMenuComponents/submenuConstants.js +8 -3
- package/dist/hooks/axios.js +97 -5
- package/dist/providers/authProvider.js +5 -0
- package/dist/providers/i18n/en.js +75 -0
- package/dist/providers/i18n/es.js +75 -0
- package/dist/providers/i18n/languages.js +3 -1
- package/dist/providers/i18n/mergeTranslations.js +18 -0
- package/dist/templates/ResourceTemplateCreate.js +5 -2
- package/package.json +4 -1
- package/src/components/serviceAccount/ApiKeyRevealDialog.tsx +129 -0
- package/src/components/serviceAccount/ServiceAccountStatusSwitch.tsx +99 -0
- package/src/default-theme/menu/AppMaterialMenu.tsx +1 -0
- package/src/default-theme/menu/AppMenuComponents/expanded/CollapsableSidebarMenu.tsx +5 -1
- package/src/default-theme/menu/AppMenuComponents/submenuConstants.ts +8 -3
- package/src/default-theme/menu/AppSidebarMaterial.tsx +1 -1
- package/src/hooks/axios.tsx +105 -2
- package/src/providers/authProvider.tsx +8 -1
- package/src/providers/i18n/en.ts +80 -0
- package/src/providers/i18n/es.ts +80 -0
- package/src/providers/i18n/languages.tsx +3 -0
- package/src/providers/i18n/mergeTranslations.ts +53 -0
- package/src/templates/ResourceTemplateCreate.tsx +17 -2
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep-merge translation message trees.
|
|
3
|
+
*
|
|
4
|
+
* Apps compose their messages as `{ ...dashAdminEs, ...customSpanish }`. That
|
|
5
|
+
* spread is shallow, so any top-level key defined on BOTH sides is replaced
|
|
6
|
+
* wholesale by the app's version - every core key underneath it is silently
|
|
7
|
+
* dropped. Apps worked around this by hand-merging one extra level for
|
|
8
|
+
* `resource`, but that only moved the problem down a level: core's
|
|
9
|
+
* `resource.tenancy.*` is still erased by an app that defines any
|
|
10
|
+
* `resource.tenancy` key of its own.
|
|
11
|
+
*
|
|
12
|
+
* This merges recursively instead, so core can ship translations for a subtree
|
|
13
|
+
* an app also contributes to. App values still win on leaf collisions.
|
|
14
|
+
*
|
|
15
|
+
* Arrays are replaced, not concatenated - a translation array is a complete
|
|
16
|
+
* value (e.g. a list of month names), never something to append to.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* mergeTranslations(dashAdminEs, customSpanish)
|
|
20
|
+
* // core: resource.tenancy.serviceAccounts.label
|
|
21
|
+
* // app: resource.tenancy.tenants.label
|
|
22
|
+
* // -> both survive
|
|
23
|
+
*/
|
|
24
|
+
export type TranslationMessages = Record<string, any>;
|
|
25
|
+
|
|
26
|
+
const isPlainObject = (value: unknown): value is TranslationMessages =>
|
|
27
|
+
typeof value === 'object' &&
|
|
28
|
+
value !== null &&
|
|
29
|
+
!Array.isArray(value);
|
|
30
|
+
|
|
31
|
+
export const mergeTranslations = (
|
|
32
|
+
...sources: (TranslationMessages | undefined | null)[]
|
|
33
|
+
): TranslationMessages => {
|
|
34
|
+
const result: TranslationMessages = {};
|
|
35
|
+
|
|
36
|
+
for (const source of sources) {
|
|
37
|
+
if (!isPlainObject(source)) continue;
|
|
38
|
+
|
|
39
|
+
for (const key of Object.keys(source)) {
|
|
40
|
+
const incoming = source[key];
|
|
41
|
+
const existing = result[key];
|
|
42
|
+
|
|
43
|
+
result[key] =
|
|
44
|
+
isPlainObject(existing) && isPlainObject(incoming)
|
|
45
|
+
? mergeTranslations(existing, incoming)
|
|
46
|
+
: incoming;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return result;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default mergeTranslations;
|
|
@@ -45,10 +45,25 @@ export const ResourceTemplateCreate: FC<IResourceTemplate> = (props) => {
|
|
|
45
45
|
notify('dash.resource.created', { type: 'success' });
|
|
46
46
|
}
|
|
47
47
|
if (_showDialogAfterSubmit) {
|
|
48
|
+
// A resource may override the success dialog to surface values the
|
|
49
|
+
// API returns exactly once (e.g. a generated secret that is never
|
|
50
|
+
// recoverable afterwards).
|
|
51
|
+
const successOverride = resourceConfig?.createSuccessDialog?.(data);
|
|
52
|
+
|
|
53
|
+
// A string title is treated as a translation key (with itself as
|
|
54
|
+
// fallback), matching how labels and menu titles behave elsewhere.
|
|
55
|
+
// JSX titles are rendered as-is.
|
|
56
|
+
const overrideTitle =
|
|
57
|
+
typeof successOverride?.title === 'string'
|
|
58
|
+
? translate(successOverride.title, { _: successOverride.title })
|
|
59
|
+
: successOverride?.title;
|
|
60
|
+
|
|
48
61
|
dialog({
|
|
49
62
|
variant: 'info',
|
|
50
|
-
title: translate('dash.resource.created'),
|
|
51
|
-
content:
|
|
63
|
+
title: overrideTitle ?? translate('dash.resource.created'),
|
|
64
|
+
content:
|
|
65
|
+
successOverride?.content ??
|
|
66
|
+
translate('dash.resource.created_message', { label: translatedLabel }),
|
|
52
67
|
onConfirm: () => {
|
|
53
68
|
switch (resourceConfig?.redirectAfterCreate) {
|
|
54
69
|
case false:
|