@dashadmin/dash-admin 1.3.44 → 1.3.46

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.
Files changed (53) hide show
  1. package/dist/components/i18n/BridgedLocalesMenuButton.js +1 -2
  2. package/dist/components/menu/DarkToggleMode.js +1 -1
  3. package/dist/components/serviceAccount/ApiKeyRevealDialog.js +110 -0
  4. package/dist/components/serviceAccount/ServiceAccountStatusSwitch.js +94 -0
  5. package/dist/components/subscription/PlanPricesSettings.js +4 -2
  6. package/dist/components/tenancy/GlobalTenantWrapper.js +64 -0
  7. package/dist/components/tenancy/TenantSwitcher.js +389 -0
  8. package/dist/contexts/com/components/EchoNotificationsCenter.js +40 -0
  9. package/dist/default-theme/menu/AppMenuComponents/expanded/SidebarItem.js +1 -0
  10. package/dist/index.js +60 -40
  11. package/dist/pages/Profile.js +32 -38
  12. package/dist/providers/i18n/en.js +108 -0
  13. package/dist/providers/i18n/es.js +108 -0
  14. package/dist/providers/i18n/languages.js +3 -1
  15. package/dist/providers/i18n/mergeTranslations.js +18 -0
  16. package/dist/resources/User/components/AvatarUploadField.js +61 -0
  17. package/dist/resources/User/components/PasswordFields.js +67 -0
  18. package/dist/resources/User/getProfileMenu.js +36 -0
  19. package/dist/resources/User/profileResource.js +33 -0
  20. package/dist/resources/User/userLayout.js +58 -0
  21. package/dist/resources/User/userResource.js +90 -0
  22. package/dist/resources/User/userSchema.js +206 -0
  23. package/dist/resources/User/usersFilters.js +22 -0
  24. package/dist/systemResources.js +30 -19
  25. package/dist/templates/ResourceTemplateCreate.js +5 -2
  26. package/package.json +4 -1
  27. package/src/components/i18n/BridgedLocalesMenuButton.tsx +1 -2
  28. package/src/components/menu/DarkToggleMode.tsx +1 -1
  29. package/src/components/serviceAccount/ApiKeyRevealDialog.tsx +129 -0
  30. package/src/components/serviceAccount/ServiceAccountStatusSwitch.tsx +99 -0
  31. package/src/components/subscription/PlanPricesSettings.tsx +2 -2
  32. package/src/components/tenancy/GlobalTenantWrapper.tsx +84 -0
  33. package/src/components/tenancy/TenantSwitcher.tsx +485 -0
  34. package/src/contexts/com/components/EchoNotificationsCenter.tsx +65 -0
  35. package/src/default-theme/menu/AppMaterialMenu.tsx +1 -1
  36. package/src/default-theme/menu/AppMenuComponents/expanded/SidebarItem.tsx +1 -0
  37. package/src/default-theme/menu/SidebarActions.tsx +1 -1
  38. package/src/index.tsx +15 -0
  39. package/src/pages/Profile.tsx +69 -107
  40. package/src/providers/i18n/en.ts +113 -0
  41. package/src/providers/i18n/es.ts +113 -0
  42. package/src/providers/i18n/languages.tsx +3 -0
  43. package/src/providers/i18n/mergeTranslations.ts +53 -0
  44. package/src/resources/User/components/AvatarUploadField.tsx +57 -0
  45. package/src/resources/User/components/PasswordFields.tsx +73 -0
  46. package/src/resources/User/getProfileMenu.ts +57 -0
  47. package/src/resources/User/profileResource.tsx +51 -0
  48. package/src/resources/User/userLayout.tsx +62 -0
  49. package/src/resources/User/userResource.tsx +111 -0
  50. package/src/resources/User/userSchema.tsx +213 -0
  51. package/src/resources/User/usersFilters.tsx +21 -0
  52. package/src/systemResources.tsx +31 -20
  53. package/src/templates/ResourceTemplateCreate.tsx +17 -2
@@ -77,8 +77,7 @@ const BridgedLocalesMenuButton = ({
77
77
  IconButton,
78
78
  {
79
79
  onClick: handleClick,
80
- color: "inherit",
81
- size: "small",
80
+ className: "dash-icon-button-color dash-icon-button-bg",
82
81
  "aria-label": "change language",
83
82
  "aria-controls": open ? "locale-menu" : void 0,
84
83
  "aria-haspopup": "true",
@@ -26,7 +26,7 @@ const DarkToggleMode = () => {
26
26
  setMode(storedTheme);
27
27
  }
28
28
  }, []);
29
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", { onClick, children: /* @__PURE__ */ jsx(DashThemeHelperProvider, { children: /* @__PURE__ */ jsx(
29
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", { className: "dash-theme-mode-switcher", onClick, children: /* @__PURE__ */ jsx(DashThemeHelperProvider, { children: /* @__PURE__ */ jsx(
30
30
  Avatar,
31
31
  {
32
32
  sizes: "small",
@@ -0,0 +1,110 @@
1
+ var __async = (__this, __arguments, generator) => {
2
+ return new Promise((resolve, reject) => {
3
+ var fulfilled = (value) => {
4
+ try {
5
+ step(generator.next(value));
6
+ } catch (e) {
7
+ reject(e);
8
+ }
9
+ };
10
+ var rejected = (value) => {
11
+ try {
12
+ step(generator.throw(value));
13
+ } catch (e) {
14
+ reject(e);
15
+ }
16
+ };
17
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
+ step((generator = generator.apply(__this, __arguments)).next());
19
+ });
20
+ };
21
+ import { jsx, jsxs } from "react/jsx-runtime";
22
+ import React, { useState } from "react";
23
+ import Alert from "@mui/material/Alert";
24
+ import Box from "@mui/material/Box";
25
+ import IconButton from "@mui/material/IconButton";
26
+ import Tooltip from "@mui/material/Tooltip";
27
+ import Typography from "@mui/material/Typography";
28
+ import ContentCopyIcon from "@mui/icons-material/ContentCopy";
29
+ import CheckIcon from "@mui/icons-material/Check";
30
+ import { useI18nBridge } from "../../contexts/I18nBridgeContext";
31
+ const ApiKeyRevealContent = ({ token, name }) => {
32
+ const { i18nProvider, locale } = useI18nBridge();
33
+ const [copied, setCopied] = useState(false);
34
+ const translate = React.useCallback(
35
+ (key, options) => {
36
+ var _a, _b;
37
+ if (i18nProvider == null ? void 0 : i18nProvider.translate) {
38
+ try {
39
+ return i18nProvider.translate(key, options);
40
+ } catch (e) {
41
+ return (_a = options == null ? void 0 : options._) != null ? _a : key;
42
+ }
43
+ }
44
+ return (_b = options == null ? void 0 : options._) != null ? _b : key;
45
+ },
46
+ // locale is a dependency so the text re-renders on a language switch.
47
+ [i18nProvider, locale]
48
+ );
49
+ const handleCopy = () => __async(null, null, function* () {
50
+ try {
51
+ yield navigator.clipboard.writeText(token);
52
+ setCopied(true);
53
+ setTimeout(() => setCopied(false), 2e3);
54
+ } catch (e) {
55
+ setCopied(false);
56
+ }
57
+ });
58
+ return /* @__PURE__ */ jsxs(Box, { children: [
59
+ /* @__PURE__ */ jsx(Alert, { severity: "warning", sx: { mb: 2 }, children: translate("serviceAccount.reveal.warning", {
60
+ _: "This is the only time this key will be shown. It cannot be recovered later \u2014 if you lose it, you will have to issue a new one."
61
+ }) }),
62
+ name ? /* @__PURE__ */ jsxs(Typography, { variant: "body2", sx: { mb: 1 }, children: [
63
+ translate("serviceAccount.reveal.forKey", { _: "Key" }),
64
+ ": ",
65
+ /* @__PURE__ */ jsx("strong", { children: name })
66
+ ] }) : null,
67
+ /* @__PURE__ */ jsxs(
68
+ Box,
69
+ {
70
+ sx: {
71
+ display: "flex",
72
+ alignItems: "center",
73
+ gap: 1,
74
+ p: 1.5,
75
+ borderRadius: 1,
76
+ border: (theme) => `1px solid ${theme.palette.divider}`,
77
+ bgcolor: (theme) => theme.palette.mode === "dark" ? "rgba(255,255,255,0.04)" : "rgba(0,0,0,0.04)"
78
+ },
79
+ children: [
80
+ /* @__PURE__ */ jsx(
81
+ Box,
82
+ {
83
+ component: "code",
84
+ sx: {
85
+ flex: 1,
86
+ fontFamily: "monospace",
87
+ fontSize: "0.875rem",
88
+ wordBreak: "break-all",
89
+ userSelect: "all"
90
+ },
91
+ children: token
92
+ }
93
+ ),
94
+ /* @__PURE__ */ jsx(
95
+ Tooltip,
96
+ {
97
+ title: copied ? translate("serviceAccount.reveal.copied", { _: "Copied" }) : translate("serviceAccount.reveal.copy", { _: "Copy" }),
98
+ children: /* @__PURE__ */ jsx(IconButton, { onClick: handleCopy, size: "small", "aria-label": "copy api key", children: copied ? /* @__PURE__ */ jsx(CheckIcon, { color: "success", fontSize: "small" }) : /* @__PURE__ */ jsx(ContentCopyIcon, { fontSize: "small" }) })
99
+ }
100
+ )
101
+ ]
102
+ }
103
+ )
104
+ ] });
105
+ };
106
+ var ApiKeyRevealDialog_default = ApiKeyRevealContent;
107
+ export {
108
+ ApiKeyRevealContent,
109
+ ApiKeyRevealDialog_default as default
110
+ };
@@ -0,0 +1,94 @@
1
+ var __async = (__this, __arguments, generator) => {
2
+ return new Promise((resolve, reject) => {
3
+ var fulfilled = (value) => {
4
+ try {
5
+ step(generator.next(value));
6
+ } catch (e) {
7
+ reject(e);
8
+ }
9
+ };
10
+ var rejected = (value) => {
11
+ try {
12
+ step(generator.throw(value));
13
+ } catch (e) {
14
+ reject(e);
15
+ }
16
+ };
17
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
+ step((generator = generator.apply(__this, __arguments)).next());
19
+ });
20
+ };
21
+ import { jsx, jsxs } from "react/jsx-runtime";
22
+ import React, { useState } from "react";
23
+ import { useRecordContext, useNotify, useRefresh } from "react-admin";
24
+ import { useAxios } from "dash-axios-hook";
25
+ import Box from "@mui/material/Box";
26
+ import Switch from "@mui/material/Switch";
27
+ import FormControlLabel from "@mui/material/FormControlLabel";
28
+ import CircularProgress from "@mui/material/CircularProgress";
29
+ import { useI18nBridge } from "../../contexts/I18nBridgeContext";
30
+ const ServiceAccountStatusSwitch = ({
31
+ resourceConfig
32
+ }) => {
33
+ const record = useRecordContext();
34
+ const notify = useNotify();
35
+ const refresh = useRefresh();
36
+ const axios = useAxios();
37
+ const { i18nProvider } = useI18nBridge();
38
+ const [loading, setLoading] = useState(false);
39
+ const translate = React.useCallback(
40
+ (key, fallback) => {
41
+ var _a;
42
+ try {
43
+ return (_a = i18nProvider == null ? void 0 : i18nProvider.translate(key, { _: fallback })) != null ? _a : fallback;
44
+ } catch (e) {
45
+ return fallback;
46
+ }
47
+ },
48
+ [i18nProvider]
49
+ );
50
+ if (!record) return null;
51
+ const isActive = record.status === "active";
52
+ const handleToggle = () => __async(null, null, function* () {
53
+ setLoading(true);
54
+ try {
55
+ const action = isActive ? "disable" : "enable";
56
+ yield axios.post(`${resourceConfig.model}/${record.id}/${action}`);
57
+ notify(
58
+ isActive ? translate("serviceAccount.notify.disabled", "API key disabled") : translate("serviceAccount.notify.enabled", "API key enabled"),
59
+ { type: "success" }
60
+ );
61
+ refresh();
62
+ } catch (error) {
63
+ console.error("ServiceAccountStatusSwitch: toggle failed", error);
64
+ notify(
65
+ translate("serviceAccount.notify.toggle_error", "Could not change the key status"),
66
+ { type: "error" }
67
+ );
68
+ } finally {
69
+ setLoading(false);
70
+ }
71
+ });
72
+ return /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 1, my: 1 }, children: [
73
+ /* @__PURE__ */ jsx(
74
+ FormControlLabel,
75
+ {
76
+ control: /* @__PURE__ */ jsx(
77
+ Switch,
78
+ {
79
+ checked: isActive,
80
+ onChange: handleToggle,
81
+ disabled: loading,
82
+ color: "success"
83
+ }
84
+ ),
85
+ label: isActive ? translate("serviceAccount.status.active", "Active") : translate("serviceAccount.status.disabled", "Disabled")
86
+ }
87
+ ),
88
+ loading ? /* @__PURE__ */ jsx(CircularProgress, { size: 16 }) : null
89
+ ] });
90
+ };
91
+ var ServiceAccountStatusSwitch_default = ServiceAccountStatusSwitch;
92
+ export {
93
+ ServiceAccountStatusSwitch_default as default
94
+ };
@@ -40,7 +40,8 @@ const PlanPricesView = () => {
40
40
  const plan = useRecordContext();
41
41
  const prices = plan == null ? void 0 : plan.prices;
42
42
  const { data: currencies, isLoading } = useGetList(
43
- "ecommerce/currency",
43
+ "system/currency",
44
+ // core "shared master data" — works for every domain, unlike ecommerce/currency (kitchntabs-backend-domain only)
44
45
  {
45
46
  pagination: { page: 1, perPage: 100 },
46
47
  sort: { field: "code", order: "ASC" },
@@ -118,7 +119,8 @@ const PlanPricesEdit = ({ method }) => {
118
119
  const formContext = useFormContext();
119
120
  const { register, setValue, watch } = formContext;
120
121
  const { data: currencies, isLoading, error } = useGetList(
121
- "ecommerce/currency",
122
+ "system/currency",
123
+ // core "shared master data" — works for every domain, unlike ecommerce/currency (kitchntabs-backend-domain only)
122
124
  {
123
125
  pagination: { page: 1, perPage: 100 },
124
126
  sort: { field: "code", order: "ASC" },
@@ -0,0 +1,64 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ import { Fragment, jsx } from "react/jsx-runtime";
18
+ import { AuthPersistenceService } from "dash-auth";
19
+ import { DASH_REDUX_ACTIONS } from "dash-admin-state";
20
+ import { useDispatch } from "react-redux";
21
+ import DashThemeContext from "../../default-theme/DashThemeContext";
22
+ import React, { useEffect } from "react";
23
+ const GlobalTenantWrapper = (props) => {
24
+ const {
25
+ tenantData = null,
26
+ children
27
+ } = props;
28
+ const dispatch = useDispatch();
29
+ const themeContext = React.useContext(DashThemeContext);
30
+ const recreateTheme = themeContext == null ? void 0 : themeContext.recreateTheme;
31
+ useEffect(() => {
32
+ var _a, _b, _c;
33
+ if (!tenantData) {
34
+ return;
35
+ }
36
+ if (tenantData.tenantImages) {
37
+ const logos = __spreadValues(__spreadValues(__spreadValues({}, ((_a = tenantData.tenantImages.horizontal_logo) == null ? void 0 : _a.original) && {
38
+ horizontalLogo: tenantData.tenantImages.horizontal_logo.original
39
+ }), ((_b = tenantData.tenantImages.squared_logo) == null ? void 0 : _b.original) && {
40
+ squaredLogo: tenantData.tenantImages.squared_logo.original
41
+ }), ((_c = tenantData.tenantImages.banner) == null ? void 0 : _c.original) && {
42
+ loginBackground: tenantData.tenantImages.banner.original
43
+ });
44
+ dispatch(DASH_REDUX_ACTIONS.setPanelSettings(logos));
45
+ }
46
+ if (tenantData.tenantSettings && recreateTheme) {
47
+ recreateTheme(tenantData.tenantSettings);
48
+ }
49
+ const publicAuthData = {
50
+ auth: {
51
+ tenantImages: tenantData.tenantImages,
52
+ tenantSettings: tenantData.tenantSettings,
53
+ tenant: tenantData.tenant
54
+ },
55
+ systemValues: tenantData.systemValues
56
+ };
57
+ AuthPersistenceService.saveAuth(publicAuthData);
58
+ }, [tenantData]);
59
+ return /* @__PURE__ */ jsx(Fragment, {});
60
+ };
61
+ var GlobalTenantWrapper_default = GlobalTenantWrapper;
62
+ export {
63
+ GlobalTenantWrapper_default as default
64
+ };