@plumile/backoffice-react 0.1.115 → 0.1.117
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/lib/esm/auth/authRefreshNotice.css.js +1 -0
- package/lib/esm/components/backoffice/billing/BackofficeBillingUsageChart.js +60 -0
- package/lib/esm/components/backoffice/billing/BackofficeBillingUsageChart.js.map +1 -0
- package/lib/esm/components/backoffice/billing/backofficeBillingUsageChart.css.js +7 -0
- package/lib/esm/components/backoffice/billing/backofficeBillingUsageChart.css.js.map +1 -0
- package/lib/esm/components/backoffice/columns/buildDataTableColumns.js +6 -6
- package/lib/esm/components/backoffice/detail/BackofficeDetailFlagTag.css.js +0 -1
- package/lib/esm/components/backoffice/layout/buildSidebarSections.js +154 -135
- package/lib/esm/components/backoffice/layout/buildSidebarSections.js.map +1 -1
- package/lib/esm/components/backoffice/layout/sidebarUtils.js +24 -21
- package/lib/esm/components/backoffice/layout/sidebarUtils.js.map +1 -1
- package/lib/esm/components/backoffice/links/resolveBackofficeLink.js +62 -54
- package/lib/esm/components/backoffice/links/resolveBackofficeLink.js.map +1 -1
- package/lib/esm/components/backoffice/links/resolveBackofficeTargetIcon.js +1 -1
- package/lib/esm/components/backoffice/links/resolveBackofficeTargetIcon.js.map +1 -1
- package/lib/esm/components/backoffice/scaffolds/BackofficeEntityListScaffold.js +271 -263
- package/lib/esm/components/backoffice/scaffolds/BackofficeEntityListScaffold.js.map +1 -1
- package/lib/esm/components/backoffice/scaffolds/backofficeEntityListScaffold.css.js +2 -2
- package/lib/esm/components/backoffice/scaffolds/backofficeEntityListScaffold.css.js.map +1 -1
- package/lib/esm/components/backoffice/scaffolds/backofficeListScrollMode.js +6 -0
- package/lib/esm/components/backoffice/scaffolds/backofficeListScrollMode.js.map +1 -0
- package/lib/esm/index.js +75 -74
- package/lib/esm/pages/BackofficeDashboardPage.helpers.js +1 -0
- package/lib/esm/pages/BackofficeDashboardPage.helpers.js.map +1 -1
- package/lib/esm/pages/BackofficeDashboardPage.js +181 -154
- package/lib/esm/pages/BackofficeDashboardPage.js.map +1 -1
- package/lib/esm/pages/BackofficeEntityDetailPage.js +12 -12
- package/lib/esm/pages/BackofficeLayoutPage.js +134 -129
- package/lib/esm/pages/BackofficeLayoutPage.js.map +1 -1
- package/lib/esm/provider/BackofficeConfigContext.js.map +1 -1
- package/lib/esm/provider/BackofficeProvider.js +126 -121
- package/lib/esm/provider/BackofficeProvider.js.map +1 -1
- package/lib/esm/provider/dashboardRegistrations.js +17 -0
- package/lib/esm/provider/dashboardRegistrations.js.map +1 -0
- package/lib/esm/router/createBackofficeRoutes.js +148 -131
- package/lib/esm/router/createBackofficeRoutes.js.map +1 -1
- package/lib/types/components/backoffice/billing/BackofficeBillingUsageChart.d.ts +25 -0
- package/lib/types/components/backoffice/billing/BackofficeBillingUsageChart.d.ts.map +1 -0
- package/lib/types/components/backoffice/billing/BackofficeBillingUsageChart.stories.d.ts +41 -0
- package/lib/types/components/backoffice/billing/BackofficeBillingUsageChart.stories.d.ts.map +1 -0
- package/lib/types/components/backoffice/billing/backofficeBillingUsageChart.css.d.ts +4 -0
- package/lib/types/components/backoffice/billing/backofficeBillingUsageChart.css.d.ts.map +1 -0
- package/lib/types/components/backoffice/layout/buildSidebarSections.d.ts +2 -1
- package/lib/types/components/backoffice/layout/buildSidebarSections.d.ts.map +1 -1
- package/lib/types/components/backoffice/layout/sidebarUtils.d.ts +1 -0
- package/lib/types/components/backoffice/layout/sidebarUtils.d.ts.map +1 -1
- package/lib/types/components/backoffice/links/resolveBackofficeLink.d.ts.map +1 -1
- package/lib/types/components/backoffice/links/types.d.ts +1 -0
- package/lib/types/components/backoffice/links/types.d.ts.map +1 -1
- package/lib/types/components/backoffice/scaffolds/BackofficeEntityListScaffold.d.ts.map +1 -1
- package/lib/types/components/backoffice/scaffolds/backofficeEntityListScaffold.css.d.ts +1 -0
- package/lib/types/components/backoffice/scaffolds/backofficeEntityListScaffold.css.d.ts.map +1 -1
- package/lib/types/components/backoffice/scaffolds/backofficeListScrollMode.d.ts +2 -0
- package/lib/types/components/backoffice/scaffolds/backofficeListScrollMode.d.ts.map +1 -0
- package/lib/types/index.d.ts +2 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/pages/BackofficeDashboardPage.d.ts +5 -1
- package/lib/types/pages/BackofficeDashboardPage.d.ts.map +1 -1
- package/lib/types/pages/BackofficeDashboardPage.helpers.d.ts.map +1 -1
- package/lib/types/pages/BackofficeDashboardPage.stories.d.ts +9 -0
- package/lib/types/pages/BackofficeDashboardPage.stories.d.ts.map +1 -0
- package/lib/types/pages/BackofficeLayoutPage.d.ts.map +1 -1
- package/lib/types/provider/BackofficeConfigContext.d.ts +2 -1
- package/lib/types/provider/BackofficeConfigContext.d.ts.map +1 -1
- package/lib/types/provider/BackofficeProvider.d.ts.map +1 -1
- package/lib/types/provider/dashboardRegistrations.d.ts +4 -0
- package/lib/types/provider/dashboardRegistrations.d.ts.map +1 -0
- package/lib/types/provider/types.d.ts +8 -1
- package/lib/types/provider/types.d.ts.map +1 -1
- package/lib/types/router/createBackofficeRoutes.d.ts +8 -2
- package/lib/types/router/createBackofficeRoutes.d.ts.map +1 -1
- package/package.json +13 -13
|
@@ -1,88 +1,89 @@
|
|
|
1
1
|
import { useBackofficeReactTranslation as e } from "../i18n/useBackofficeReactTranslation.js";
|
|
2
2
|
import { useBackofficeConfig as t } from "../provider/BackofficeConfigContext.js";
|
|
3
3
|
import { BackofficeErrorBoundary as n } from "../components/backoffice/errors/BackofficeErrorBoundary.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
4
|
+
import { BackofficeBillingUsageChart as r } from "../components/backoffice/billing/BackofficeBillingUsageChart.js";
|
|
5
|
+
import { buildDataTableColumns as i } from "../components/backoffice/columns/buildDataTableColumns.js";
|
|
6
|
+
import { BackofficeRightPageLayout as a } from "../components/backoffice/layout/breadcrumb/BackofficeRightPageLayout.js";
|
|
7
|
+
import { buildDashboardBreadcrumb as o } from "../components/backoffice/layout/breadcrumb/buildBreadcrumbs.js";
|
|
8
|
+
import { useBackofficeDashboardConfig as s } from "../provider/useBackofficeLazyValue.js";
|
|
9
|
+
import { getWidgetLabel as c, hasWidgetQuery as l, resolveLabel as u } from "./BackofficeDashboardPage.helpers.js";
|
|
10
|
+
import { DashboardMetricGroup as d } from "./dashboard/DashboardMetricGroup.js";
|
|
11
|
+
import { DashboardPanel as f } from "./dashboard/DashboardPanel.js";
|
|
12
|
+
import { DashboardQuickActions as p } from "./dashboard/DashboardQuickActions.js";
|
|
13
|
+
import { DashboardStatusList as m } from "./dashboard/DashboardStatusList.js";
|
|
14
|
+
import { loadingBody as h, tileBody as g, tileCount as _ } from "./backofficeDashboardPage.css.js";
|
|
15
|
+
import { Suspense as v } from "react";
|
|
16
|
+
import { jsx as y, jsxs as b } from "react/jsx-runtime";
|
|
17
|
+
import { useTranslation as x } from "react-i18next";
|
|
18
|
+
import * as S from "react-relay";
|
|
19
|
+
import { Spinner as C } from "@plumile/ui/backoffice/atoms/spinner/Spinner.js";
|
|
20
|
+
import { BackofficeEmptyState as w } from "@plumile/ui/backoffice/molecules/backoffice_empty_state/BackofficeEmptyState.js";
|
|
21
|
+
import { DetailPageTemplate as T } from "@plumile/ui/backoffice/templates/detail_page_template/DetailPageTemplate.js";
|
|
22
|
+
import { DataTable as E } from "@plumile/ui/components/data-table/DataTable.js";
|
|
23
|
+
import { DashboardGrid as D, DashboardGridItem as O } from "@plumile/ui/components/dashboard/dashboard_grid/DashboardGrid.js";
|
|
23
24
|
//#region src/pages/BackofficeDashboardPage.tsx
|
|
24
|
-
var { useLazyLoadQuery:
|
|
25
|
+
var { useLazyLoadQuery: k } = S, A = () => {
|
|
25
26
|
let { t } = e();
|
|
26
|
-
return /* @__PURE__ */
|
|
27
|
-
},
|
|
27
|
+
return /* @__PURE__ */ y(w, { title: t("common.notAvailable") });
|
|
28
|
+
}, j = () => {
|
|
28
29
|
let { t } = e();
|
|
29
|
-
return /* @__PURE__ */
|
|
30
|
-
className:
|
|
31
|
-
children: [/* @__PURE__ */
|
|
30
|
+
return /* @__PURE__ */ b("div", {
|
|
31
|
+
className: h,
|
|
32
|
+
children: [/* @__PURE__ */ y(C, { ariaLabel: t("common.loading") }), /* @__PURE__ */ y("span", { children: t("common.loading") })]
|
|
32
33
|
});
|
|
33
|
-
},
|
|
34
|
+
}, M = (e) => e ?? "m", N = (e) => {
|
|
34
35
|
if (e.layout?.span != null) return e.layout.span;
|
|
35
|
-
let t =
|
|
36
|
+
let t = M(e.size);
|
|
36
37
|
return t === "s" ? 3 : t === "m" ? 4 : t === "l" ? 6 : t === "xl" ? 8 : 12;
|
|
37
|
-
},
|
|
38
|
-
let { t:
|
|
39
|
-
if (n.kind === "textBlock") return /* @__PURE__ */
|
|
40
|
-
title:
|
|
41
|
-
subtitle:
|
|
42
|
-
children: /* @__PURE__ */
|
|
43
|
-
className:
|
|
44
|
-
children:
|
|
38
|
+
}, P = (e) => e.layout?.tabletSpan, F = ({ widget: n, globalData: a }) => {
|
|
39
|
+
let { t: o } = x(), { t: s } = e(), { entities: c } = t(), l = n.description == null ? void 0 : u(n.description, o), h = (e) => "resolve" in n && n.resolve != null ? n.resolve(e) : null;
|
|
40
|
+
if (n.kind === "textBlock") return /* @__PURE__ */ y(f, {
|
|
41
|
+
title: u(n.title, o),
|
|
42
|
+
subtitle: l,
|
|
43
|
+
children: /* @__PURE__ */ y("div", {
|
|
44
|
+
className: g,
|
|
45
|
+
children: u(n.body, o)
|
|
45
46
|
})
|
|
46
47
|
});
|
|
47
48
|
if (n.kind === "shortcut") {
|
|
48
|
-
let e =
|
|
49
|
-
return e == null ? /* @__PURE__ */
|
|
49
|
+
let e = c[n.entityId], t = u(n.label, o);
|
|
50
|
+
return e == null ? /* @__PURE__ */ y(f, {
|
|
50
51
|
title: t,
|
|
51
|
-
subtitle:
|
|
52
|
-
children: /* @__PURE__ */
|
|
53
|
-
}) : e.kind === "tool" ? /* @__PURE__ */
|
|
52
|
+
subtitle: l,
|
|
53
|
+
children: /* @__PURE__ */ y(A, {})
|
|
54
|
+
}) : e.kind === "tool" ? /* @__PURE__ */ y(f, {
|
|
54
55
|
title: t,
|
|
55
|
-
subtitle:
|
|
56
|
-
children: /* @__PURE__ */
|
|
56
|
+
subtitle: l,
|
|
57
|
+
children: /* @__PURE__ */ y(p, { actions: [{
|
|
57
58
|
id: e.id,
|
|
58
59
|
href: e.routes.list,
|
|
59
|
-
label:
|
|
60
|
+
label: s("dashboard.actions.openTool")
|
|
60
61
|
}] })
|
|
61
|
-
}) : /* @__PURE__ */
|
|
62
|
+
}) : /* @__PURE__ */ y(f, {
|
|
62
63
|
title: t,
|
|
63
|
-
subtitle:
|
|
64
|
-
children: /* @__PURE__ */
|
|
64
|
+
subtitle: l,
|
|
65
|
+
children: /* @__PURE__ */ y(p, { actions: [{
|
|
65
66
|
id: e.id,
|
|
66
67
|
href: e.routes.list,
|
|
67
|
-
label:
|
|
68
|
+
label: s("dashboard.actions.openList")
|
|
68
69
|
}] })
|
|
69
70
|
});
|
|
70
71
|
}
|
|
71
72
|
if (n.kind === "tablePreview") {
|
|
72
|
-
let e =
|
|
73
|
-
if (e == null) return /* @__PURE__ */
|
|
74
|
-
title:
|
|
75
|
-
subtitle:
|
|
76
|
-
children: /* @__PURE__ */
|
|
73
|
+
let e = h(a);
|
|
74
|
+
if (e == null) return /* @__PURE__ */ y(f, {
|
|
75
|
+
title: u(n.title, o),
|
|
76
|
+
subtitle: l,
|
|
77
|
+
children: /* @__PURE__ */ y(A, {})
|
|
77
78
|
});
|
|
78
|
-
let t =
|
|
79
|
-
tApp:
|
|
80
|
-
t:
|
|
79
|
+
let t = i(e.columns, {
|
|
80
|
+
tApp: o,
|
|
81
|
+
t: s
|
|
81
82
|
});
|
|
82
|
-
return /* @__PURE__ */
|
|
83
|
-
title:
|
|
84
|
-
subtitle:
|
|
85
|
-
children: /* @__PURE__ */
|
|
83
|
+
return /* @__PURE__ */ y(f, {
|
|
84
|
+
title: u(n.title, o),
|
|
85
|
+
subtitle: l,
|
|
86
|
+
children: /* @__PURE__ */ y(E, {
|
|
86
87
|
columns: t,
|
|
87
88
|
rows: e.rows,
|
|
88
89
|
getRowId: (e, t) => {
|
|
@@ -96,111 +97,137 @@ var { useLazyLoadQuery: O } = x, k = () => {
|
|
|
96
97
|
});
|
|
97
98
|
}
|
|
98
99
|
if (n.kind === "metricGroup") {
|
|
99
|
-
let e =
|
|
100
|
-
return e == null ? /* @__PURE__ */
|
|
101
|
-
emptyState: /* @__PURE__ */
|
|
100
|
+
let e = h(a);
|
|
101
|
+
return e == null ? /* @__PURE__ */ y(A, {}) : /* @__PURE__ */ y(d, {
|
|
102
|
+
emptyState: /* @__PURE__ */ y(A, {}),
|
|
102
103
|
metrics: e.map((e) => ({
|
|
103
104
|
id: e.id,
|
|
104
105
|
href: e.href,
|
|
105
|
-
label:
|
|
106
|
-
value: e.value ??
|
|
107
|
-
hint: e.meta == null ? void 0 :
|
|
106
|
+
label: u(e.label, o),
|
|
107
|
+
value: e.value ?? s("common.notAvailable"),
|
|
108
|
+
hint: e.meta == null ? void 0 : u(e.meta, o)
|
|
108
109
|
}))
|
|
109
110
|
});
|
|
110
111
|
}
|
|
111
|
-
if (n.kind === "
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
if (n.kind === "billingUsageChart") {
|
|
113
|
+
let e = h(a), t = u(n.title, o);
|
|
114
|
+
return e == null ? /* @__PURE__ */ y(f, {
|
|
115
|
+
title: t,
|
|
116
|
+
subtitle: l,
|
|
117
|
+
children: /* @__PURE__ */ y(A, {})
|
|
118
|
+
}) : /* @__PURE__ */ y(f, {
|
|
119
|
+
title: t,
|
|
120
|
+
subtitle: l,
|
|
121
|
+
children: /* @__PURE__ */ y(r, {
|
|
122
|
+
ariaLabel: u(n.ariaLabel, o),
|
|
123
|
+
buckets: e.buckets,
|
|
124
|
+
categories: n.categories.map((e) => ({
|
|
125
|
+
id: e.id,
|
|
126
|
+
label: u(e.label, o),
|
|
127
|
+
color: e.color
|
|
128
|
+
})),
|
|
129
|
+
currency: e.currency,
|
|
130
|
+
emptyLabel: u(n.emptyLabel, o),
|
|
131
|
+
from: e.from,
|
|
132
|
+
rangePrefix: u(n.rangePrefix, o),
|
|
133
|
+
to: e.to,
|
|
134
|
+
totalAmount: e.totalAmount
|
|
135
|
+
})
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
if (n.kind === "quickActions") return /* @__PURE__ */ y(f, {
|
|
139
|
+
title: n.title == null ? s("dashboard.actions.openTool") : u(n.title, o),
|
|
140
|
+
subtitle: l,
|
|
141
|
+
children: /* @__PURE__ */ y(p, {
|
|
115
142
|
layout: n.layout?.zone === "aside" ? "stack" : "grid",
|
|
116
|
-
emptyState: /* @__PURE__ */
|
|
143
|
+
emptyState: /* @__PURE__ */ y(A, {}),
|
|
117
144
|
actions: n.actions.map((e) => ({
|
|
118
145
|
id: e.id,
|
|
119
146
|
href: e.href,
|
|
120
|
-
label:
|
|
147
|
+
label: u(e.label, o)
|
|
121
148
|
}))
|
|
122
149
|
})
|
|
123
150
|
});
|
|
124
151
|
if (n.kind === "statusSummary") {
|
|
125
|
-
let e =
|
|
126
|
-
return e == null ? /* @__PURE__ */
|
|
127
|
-
title: n.title == null ? void 0 :
|
|
128
|
-
subtitle:
|
|
129
|
-
children: /* @__PURE__ */
|
|
130
|
-
}) : /* @__PURE__ */
|
|
131
|
-
title: n.title == null ? void 0 :
|
|
132
|
-
subtitle:
|
|
133
|
-
children: /* @__PURE__ */
|
|
134
|
-
emptyState: /* @__PURE__ */
|
|
152
|
+
let e = h(a);
|
|
153
|
+
return e == null ? /* @__PURE__ */ y(f, {
|
|
154
|
+
title: n.title == null ? void 0 : u(n.title, o),
|
|
155
|
+
subtitle: l,
|
|
156
|
+
children: /* @__PURE__ */ y(A, {})
|
|
157
|
+
}) : /* @__PURE__ */ y(f, {
|
|
158
|
+
title: n.title == null ? void 0 : u(n.title, o),
|
|
159
|
+
subtitle: l,
|
|
160
|
+
children: /* @__PURE__ */ y(m, {
|
|
161
|
+
emptyState: /* @__PURE__ */ y(A, {}),
|
|
135
162
|
items: e.map((e) => ({
|
|
136
163
|
id: e.id,
|
|
137
164
|
href: e.href,
|
|
138
|
-
label:
|
|
139
|
-
value: e.value ??
|
|
165
|
+
label: u(e.label, o),
|
|
166
|
+
value: e.value ?? s("common.notAvailable")
|
|
140
167
|
}))
|
|
141
168
|
})
|
|
142
169
|
});
|
|
143
170
|
}
|
|
144
|
-
if (n.kind === "recentItems") return /* @__PURE__ */
|
|
145
|
-
title: n.title == null ?
|
|
146
|
-
subtitle:
|
|
147
|
-
children: /* @__PURE__ */
|
|
171
|
+
if (n.kind === "recentItems") return /* @__PURE__ */ y(f, {
|
|
172
|
+
title: n.title == null ? s("dashboard.title") : u(n.title, o),
|
|
173
|
+
subtitle: l,
|
|
174
|
+
children: /* @__PURE__ */ y(A, {})
|
|
148
175
|
});
|
|
149
|
-
let
|
|
150
|
-
if (
|
|
151
|
-
title:
|
|
152
|
-
subtitle:
|
|
153
|
-
children: /* @__PURE__ */
|
|
176
|
+
let v = c[n.entityId];
|
|
177
|
+
if (v?.kind !== "list-detail") return /* @__PURE__ */ y(f, {
|
|
178
|
+
title: u(n.label, o),
|
|
179
|
+
subtitle: l,
|
|
180
|
+
children: /* @__PURE__ */ y(A, {})
|
|
154
181
|
});
|
|
155
|
-
let
|
|
156
|
-
return typeof
|
|
157
|
-
title:
|
|
158
|
-
subtitle:
|
|
159
|
-
children: /* @__PURE__ */
|
|
160
|
-
className:
|
|
161
|
-
children: [/* @__PURE__ */
|
|
162
|
-
className:
|
|
163
|
-
children:
|
|
164
|
-
}), /* @__PURE__ */
|
|
165
|
-
emptyState: /* @__PURE__ */
|
|
182
|
+
let S = h(a), C = s("common.notAvailable");
|
|
183
|
+
return typeof S?.count == "number" && (C = S.count), /* @__PURE__ */ y(f, {
|
|
184
|
+
title: u(n.label, o),
|
|
185
|
+
subtitle: l,
|
|
186
|
+
children: /* @__PURE__ */ b("div", {
|
|
187
|
+
className: g,
|
|
188
|
+
children: [/* @__PURE__ */ y("div", {
|
|
189
|
+
className: _,
|
|
190
|
+
children: C
|
|
191
|
+
}), /* @__PURE__ */ y(p, {
|
|
192
|
+
emptyState: /* @__PURE__ */ y(A, {}),
|
|
166
193
|
actions: [{
|
|
167
|
-
id:
|
|
168
|
-
href:
|
|
169
|
-
label:
|
|
194
|
+
id: v.id,
|
|
195
|
+
href: v.routes.list,
|
|
196
|
+
label: s("dashboard.actions.openList")
|
|
170
197
|
}]
|
|
171
198
|
})]
|
|
172
199
|
})
|
|
173
200
|
});
|
|
174
|
-
},
|
|
201
|
+
}, I = ({ widget: e }) => /* @__PURE__ */ y(F, {
|
|
175
202
|
widget: e,
|
|
176
|
-
globalData:
|
|
177
|
-
}),
|
|
178
|
-
let { t: i } =
|
|
179
|
-
return /* @__PURE__ */
|
|
203
|
+
globalData: k(e.query, {}, { fetchPolicy: "store-or-network" })
|
|
204
|
+
}), L = ({ config: t, globalData: r }) => {
|
|
205
|
+
let { t: i } = x(), { t: a } = e();
|
|
206
|
+
return /* @__PURE__ */ y(T, {
|
|
180
207
|
header: {
|
|
181
|
-
title:
|
|
182
|
-
subtitle: (t.subtitle == null ? void 0 :
|
|
208
|
+
title: u(t.title, i),
|
|
209
|
+
subtitle: (t.subtitle == null ? void 0 : u(t.subtitle, i)) ?? a("dashboard.subtitle")
|
|
183
210
|
},
|
|
184
|
-
children: /* @__PURE__ */
|
|
211
|
+
children: /* @__PURE__ */ y(D, {
|
|
185
212
|
columns: 12,
|
|
186
213
|
children: t.widgets.map((e) => {
|
|
187
|
-
let a =
|
|
214
|
+
let a = u(c(e, t), i), o = l(e) ? /* @__PURE__ */ y(I, { widget: e }) : /* @__PURE__ */ y(F, {
|
|
188
215
|
widget: e,
|
|
189
216
|
globalData: r
|
|
190
217
|
});
|
|
191
|
-
return /* @__PURE__ */
|
|
218
|
+
return /* @__PURE__ */ y(O, {
|
|
192
219
|
minHeight: e.minHeight ?? "auto",
|
|
193
|
-
span:
|
|
194
|
-
tabletSpan:
|
|
195
|
-
children: /* @__PURE__ */
|
|
196
|
-
fallback: () => /* @__PURE__ */
|
|
220
|
+
span: N(e),
|
|
221
|
+
tabletSpan: P(e),
|
|
222
|
+
children: /* @__PURE__ */ y(n, {
|
|
223
|
+
fallback: () => /* @__PURE__ */ y(f, {
|
|
197
224
|
title: a,
|
|
198
|
-
children: /* @__PURE__ */
|
|
225
|
+
children: /* @__PURE__ */ y(A, {})
|
|
199
226
|
}),
|
|
200
|
-
children: /* @__PURE__ */ v
|
|
201
|
-
fallback: /* @__PURE__ */
|
|
227
|
+
children: /* @__PURE__ */ y(v, {
|
|
228
|
+
fallback: /* @__PURE__ */ y(f, {
|
|
202
229
|
title: a,
|
|
203
|
-
children: /* @__PURE__ */
|
|
230
|
+
children: /* @__PURE__ */ y(j, {})
|
|
204
231
|
}),
|
|
205
232
|
children: o
|
|
206
233
|
})
|
|
@@ -209,38 +236,38 @@ var { useLazyLoadQuery: O } = x, k = () => {
|
|
|
209
236
|
})
|
|
210
237
|
})
|
|
211
238
|
});
|
|
212
|
-
},
|
|
239
|
+
}, R = ({ config: e }) => /* @__PURE__ */ y(L, {
|
|
213
240
|
config: e,
|
|
214
|
-
globalData:
|
|
215
|
-
}),
|
|
216
|
-
let { t:
|
|
217
|
-
if (
|
|
218
|
-
let e = Object.values(
|
|
241
|
+
globalData: k(e.query, {}, { fetchPolicy: "store-or-network" })
|
|
242
|
+
}), z = ({ prepared: n }) => {
|
|
243
|
+
let { t: r } = x(), { t: i } = e(), { entities: c } = t(), l = s(), d = n?.config ?? l, m = o(i);
|
|
244
|
+
if (d == null) {
|
|
245
|
+
let e = Object.values(c).filter((e) => e.kind === "list-detail" && e.hasList).map((e) => ({
|
|
219
246
|
config: e,
|
|
220
|
-
label:
|
|
247
|
+
label: u(e.label, r)
|
|
221
248
|
})).sort((e, t) => e.label.localeCompare(t.label));
|
|
222
|
-
return /* @__PURE__ */
|
|
223
|
-
breadcrumb:
|
|
224
|
-
children: /* @__PURE__ */
|
|
249
|
+
return /* @__PURE__ */ y(a, {
|
|
250
|
+
breadcrumb: m,
|
|
251
|
+
children: /* @__PURE__ */ y(T, {
|
|
225
252
|
header: {
|
|
226
|
-
title:
|
|
227
|
-
subtitle:
|
|
253
|
+
title: i("dashboard.title"),
|
|
254
|
+
subtitle: i("dashboard.subtitle")
|
|
228
255
|
},
|
|
229
|
-
children: /* @__PURE__ */
|
|
256
|
+
children: /* @__PURE__ */ y(D, {
|
|
230
257
|
columns: 12,
|
|
231
|
-
children: e.map(({ config: e, label: t }) => /* @__PURE__ */
|
|
258
|
+
children: e.map(({ config: e, label: t }) => /* @__PURE__ */ y(O, {
|
|
232
259
|
span: 4,
|
|
233
|
-
children: /* @__PURE__ */
|
|
260
|
+
children: /* @__PURE__ */ y(f, {
|
|
234
261
|
title: t,
|
|
235
|
-
children: /* @__PURE__ */
|
|
236
|
-
className:
|
|
237
|
-
children: [/* @__PURE__ */
|
|
238
|
-
className:
|
|
239
|
-
children:
|
|
240
|
-
}), /* @__PURE__ */
|
|
262
|
+
children: /* @__PURE__ */ b("div", {
|
|
263
|
+
className: g,
|
|
264
|
+
children: [/* @__PURE__ */ y("div", {
|
|
265
|
+
className: _,
|
|
266
|
+
children: i("common.notAvailable")
|
|
267
|
+
}), /* @__PURE__ */ y(p, { actions: [{
|
|
241
268
|
id: e.id,
|
|
242
269
|
href: e.routes.list,
|
|
243
|
-
label:
|
|
270
|
+
label: i("dashboard.actions.openList")
|
|
244
271
|
}] })]
|
|
245
272
|
})
|
|
246
273
|
})
|
|
@@ -249,18 +276,18 @@ var { useLazyLoadQuery: O } = x, k = () => {
|
|
|
249
276
|
})
|
|
250
277
|
});
|
|
251
278
|
}
|
|
252
|
-
return
|
|
253
|
-
breadcrumb:
|
|
254
|
-
children: /* @__PURE__ */
|
|
255
|
-
config:
|
|
279
|
+
return d.query == null ? /* @__PURE__ */ y(a, {
|
|
280
|
+
breadcrumb: m,
|
|
281
|
+
children: /* @__PURE__ */ y(L, {
|
|
282
|
+
config: d,
|
|
256
283
|
globalData: null
|
|
257
284
|
})
|
|
258
|
-
}) : /* @__PURE__ */
|
|
259
|
-
breadcrumb:
|
|
260
|
-
children: /* @__PURE__ */
|
|
285
|
+
}) : /* @__PURE__ */ y(a, {
|
|
286
|
+
breadcrumb: m,
|
|
287
|
+
children: /* @__PURE__ */ y(R, { config: d })
|
|
261
288
|
});
|
|
262
289
|
};
|
|
263
290
|
//#endregion
|
|
264
|
-
export {
|
|
291
|
+
export { z as BackofficeDashboardPage, z as default };
|
|
265
292
|
|
|
266
293
|
//# sourceMappingURL=BackofficeDashboardPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackofficeDashboardPage.js","names":[],"sources":["../../../src/pages/BackofficeDashboardPage.tsx"],"sourcesContent":["/* eslint-disable no-ternary */\nimport { type JSX, Suspense } from 'react';\nimport type {\n BackofficeDashboardConfig,\n BackofficeDashboardWidget,\n BackofficeDashboardWidgetSpan,\n BackofficeDashboardWidgetTabletSpan,\n BackofficeDashboardWidgetSize,\n I18nLabel,\n} from '@plumile/backoffice-core/types.js';\nimport { Spinner } from '@plumile/ui/backoffice/atoms/spinner/Spinner.js';\nimport { BackofficeEmptyState } from '@plumile/ui/backoffice/molecules/backoffice_empty_state/BackofficeEmptyState.js';\nimport { DetailPageTemplate } from '@plumile/ui/backoffice/templates/detail_page_template/DetailPageTemplate.js';\nimport {\n DashboardGrid,\n DashboardGridItem,\n} from '@plumile/ui/components/dashboard/dashboard_grid/DashboardGrid.js';\nimport { DataTable } from '@plumile/ui/components/data-table/DataTable.js';\nimport { useTranslation } from 'react-i18next';\nimport * as ReactRelay from 'react-relay';\nimport type { GraphQLTaggedNode, OperationType } from 'relay-runtime';\n\nimport { BackofficeErrorBoundary } from '../components/backoffice/errors/BackofficeErrorBoundary.js';\nimport { useBackofficeReactTranslation } from '../i18n/useBackofficeReactTranslation.js';\nimport { useBackofficeConfig } from '../provider/BackofficeConfigContext.js';\nimport { useBackofficeDashboardConfig } from '../provider/useBackofficeLazyValue.js';\nimport { buildDataTableColumns } from '../components/backoffice/columns/buildDataTableColumns.js';\nimport { BackofficeRightPageLayout } from '../components/backoffice/layout/breadcrumb/BackofficeRightPageLayout.js';\nimport { buildDashboardBreadcrumb } from '../components/backoffice/layout/breadcrumb/buildBreadcrumbs.js';\nimport {\n getWidgetLabel,\n hasWidgetQuery,\n resolveLabel,\n} from './BackofficeDashboardPage.helpers.js';\nimport { DashboardMetricGroup } from './dashboard/DashboardMetricGroup.js';\nimport { DashboardPanel } from './dashboard/DashboardPanel.js';\nimport { DashboardQuickActions } from './dashboard/DashboardQuickActions.js';\nimport { DashboardStatusList } from './dashboard/DashboardStatusList.js';\n\nimport * as styles from './backofficeDashboardPage.css.js';\n\nconst { useLazyLoadQuery } = ReactRelay;\n\ntype WidgetContentProps = {\n widget: BackofficeDashboardWidget;\n globalData: unknown;\n};\n\nconst DashboardUnavailableState = (): JSX.Element => {\n const { t } = useBackofficeReactTranslation();\n\n return <BackofficeEmptyState title={t('common.notAvailable')} />;\n};\n\nconst DashboardLoadingState = (): JSX.Element => {\n const { t } = useBackofficeReactTranslation();\n\n return (\n <div className={styles.loadingBody}>\n <Spinner ariaLabel={t('common.loading')} />\n <span>{t('common.loading')}</span>\n </div>\n );\n};\n\nconst resolveWidgetSize = (\n size: BackofficeDashboardWidgetSize | undefined,\n): BackofficeDashboardWidgetSize => {\n return size ?? 'm';\n};\n\nconst resolveWidgetSpan = (\n widget: BackofficeDashboardWidget,\n): BackofficeDashboardWidgetSpan => {\n if (widget.layout?.span != null) {\n return widget.layout.span;\n }\n\n const size = resolveWidgetSize(widget.size);\n if (size === 's') {\n return 3;\n }\n if (size === 'm') {\n return 4;\n }\n if (size === 'l') {\n return 6;\n }\n if (size === 'xl') {\n return 8;\n }\n return 12;\n};\n\nconst resolveWidgetTabletSpan = (\n widget: BackofficeDashboardWidget,\n): BackofficeDashboardWidgetTabletSpan | undefined => {\n return widget.layout?.tabletSpan;\n};\n\nconst WidgetContent = ({\n widget,\n globalData,\n}: WidgetContentProps): JSX.Element | null => {\n const { t: tApp } = useTranslation();\n const { t } = useBackofficeReactTranslation();\n const { entities } = useBackofficeConfig();\n const description =\n widget.description != null\n ? resolveLabel(widget.description, tApp)\n : undefined;\n\n const resolveData = (data: unknown): unknown => {\n if ('resolve' in widget && widget.resolve != null) {\n return widget.resolve(data);\n }\n return null;\n };\n\n if (widget.kind === 'textBlock') {\n const title = resolveLabel(widget.title, tApp);\n const body = resolveLabel(widget.body, tApp);\n return (\n <DashboardPanel title={title} subtitle={description}>\n <div className={styles.tileBody}>{body}</div>\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'shortcut') {\n const entity = entities[widget.entityId];\n const title = resolveLabel(widget.label, tApp);\n if (entity == null) {\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n if (entity.kind === 'tool') {\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardQuickActions\n actions={[\n {\n id: entity.id,\n href: entity.routes.list,\n label: t('dashboard.actions.openTool'),\n },\n ]}\n />\n </DashboardPanel>\n );\n }\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardQuickActions\n actions={[\n {\n id: entity.id,\n href: entity.routes.list,\n label: t('dashboard.actions.openList'),\n },\n ]}\n />\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'tablePreview') {\n const resolved = resolveData(globalData) as {\n columns: readonly unknown[];\n rows: readonly unknown[];\n } | null;\n if (resolved == null) {\n return (\n <DashboardPanel\n title={resolveLabel(widget.title, tApp)}\n subtitle={description}\n >\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n const columns = buildDataTableColumns(resolved.columns as never, {\n tApp,\n t,\n });\n const title = resolveLabel(widget.title, tApp);\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DataTable\n columns={columns}\n rows={resolved.rows}\n getRowId={(row, index) => {\n if (row != null && typeof row === 'object') {\n const record = row as Record<string, unknown>;\n const { id } = record;\n if (typeof id === 'string' && id.trim() !== '') {\n return id;\n }\n }\n return String(index);\n }}\n />\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'metricGroup') {\n const resolved = resolveData(globalData) as\n | readonly {\n id: string;\n label: I18nLabel;\n value: string | number | null;\n meta?: I18nLabel;\n href?: string;\n }[]\n | null;\n if (resolved == null) {\n return <DashboardUnavailableState />;\n }\n return (\n <DashboardMetricGroup\n emptyState={<DashboardUnavailableState />}\n metrics={resolved.map((metric) => {\n return {\n id: metric.id,\n href: metric.href,\n label: resolveLabel(metric.label, tApp),\n value: metric.value ?? t('common.notAvailable'),\n hint:\n metric.meta != null ? resolveLabel(metric.meta, tApp) : undefined,\n };\n })}\n />\n );\n }\n\n if (widget.kind === 'quickActions') {\n const title =\n widget.title != null\n ? resolveLabel(widget.title, tApp)\n : t('dashboard.actions.openTool');\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardQuickActions\n layout={widget.layout?.zone === 'aside' ? 'stack' : 'grid'}\n emptyState={<DashboardUnavailableState />}\n actions={widget.actions.map((action) => {\n return {\n id: action.id,\n href: action.href,\n label: resolveLabel(action.label, tApp),\n };\n })}\n />\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'statusSummary') {\n const resolved = resolveData(globalData) as\n | readonly {\n id: string;\n label: I18nLabel;\n value: string | number | null;\n href?: string;\n }[]\n | null;\n if (resolved == null) {\n const title =\n widget.title != null ? resolveLabel(widget.title, tApp) : undefined;\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n const title =\n widget.title != null ? resolveLabel(widget.title, tApp) : undefined;\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardStatusList\n emptyState={<DashboardUnavailableState />}\n items={resolved.map((item) => {\n return {\n id: item.id,\n href: item.href,\n label: resolveLabel(item.label, tApp),\n value: item.value ?? t('common.notAvailable'),\n };\n })}\n />\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'recentItems') {\n const title =\n widget.title != null\n ? resolveLabel(widget.title, tApp)\n : t('dashboard.title');\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n\n const entityManifest = entities[widget.entityId];\n if (entityManifest?.kind !== 'list-detail') {\n return (\n <DashboardPanel\n title={resolveLabel(widget.label, tApp)}\n subtitle={description}\n >\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n const resolved = resolveData(globalData) as { count: number | null } | null;\n let countLabel: number | string = t('common.notAvailable');\n if (typeof resolved?.count === 'number') {\n countLabel = resolved.count;\n }\n const title = resolveLabel(widget.label, tApp);\n return (\n <DashboardPanel title={title} subtitle={description}>\n <div className={styles.tileBody}>\n <div className={styles.tileCount}>{countLabel}</div>\n <DashboardQuickActions\n emptyState={<DashboardUnavailableState />}\n actions={[\n {\n id: entityManifest.id,\n href: entityManifest.routes.list,\n label: t('dashboard.actions.openList'),\n },\n ]}\n />\n </div>\n </DashboardPanel>\n );\n};\n\ntype WidgetWithQueryProps = {\n widget: BackofficeDashboardWidget & { query: GraphQLTaggedNode };\n};\n\nconst WidgetWithQuery = ({ widget }: WidgetWithQueryProps): JSX.Element => {\n const data = useLazyLoadQuery<OperationType>(\n widget.query,\n {},\n {\n fetchPolicy: 'store-or-network',\n },\n );\n\n return <WidgetContent widget={widget} globalData={data} />;\n};\n\ntype DashboardContentProps = {\n config: BackofficeDashboardConfig;\n globalData: unknown;\n};\n\nconst DashboardContent = ({\n config,\n globalData,\n}: DashboardContentProps): JSX.Element => {\n const { t: tApp } = useTranslation();\n const { t } = useBackofficeReactTranslation();\n\n const title = resolveLabel(config.title, tApp);\n const subtitle =\n config.subtitle != null ? resolveLabel(config.subtitle, tApp) : undefined;\n\n return (\n <DetailPageTemplate\n header={{\n title,\n subtitle: subtitle ?? t('dashboard.subtitle'),\n }}\n >\n <DashboardGrid columns={12}>\n {config.widgets.map((widget) => {\n const widgetTitle = resolveLabel(\n getWidgetLabel(widget, config),\n tApp,\n );\n const content = hasWidgetQuery(widget) ? (\n <WidgetWithQuery widget={widget} />\n ) : (\n <WidgetContent widget={widget} globalData={globalData} />\n );\n\n return (\n <DashboardGridItem\n key={widget.id}\n minHeight={widget.minHeight ?? 'auto'}\n span={resolveWidgetSpan(widget)}\n tabletSpan={resolveWidgetTabletSpan(widget)}\n >\n <BackofficeErrorBoundary\n fallback={() => {\n return (\n <DashboardPanel title={widgetTitle}>\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }}\n >\n <Suspense\n fallback={\n <DashboardPanel title={widgetTitle}>\n <DashboardLoadingState />\n </DashboardPanel>\n }\n >\n {content}\n </Suspense>\n </BackofficeErrorBoundary>\n </DashboardGridItem>\n );\n })}\n </DashboardGrid>\n </DetailPageTemplate>\n );\n};\n\ntype DashboardWithQueryProps = {\n config: BackofficeDashboardConfig;\n};\n\nconst DashboardWithQuery = ({\n config,\n}: DashboardWithQueryProps): JSX.Element => {\n const data = useLazyLoadQuery<OperationType>(\n config.query as never,\n {},\n { fetchPolicy: 'store-or-network' },\n );\n\n return <DashboardContent config={config} globalData={data} />;\n};\n\nexport const BackofficeDashboardPage = (): JSX.Element => {\n const { t: tApp } = useTranslation();\n const { t } = useBackofficeReactTranslation();\n const { entities } = useBackofficeConfig();\n const dashboard = useBackofficeDashboardConfig();\n const breadcrumb = buildDashboardBreadcrumb(t);\n\n if (dashboard == null) {\n const items = Object.values(entities)\n .filter((config) => {\n return config.kind === 'list-detail' && config.hasList;\n })\n .map((config) => {\n return {\n config,\n label: resolveLabel(config.label, tApp),\n };\n })\n .sort((left, right) => {\n return left.label.localeCompare(right.label);\n });\n\n return (\n <BackofficeRightPageLayout breadcrumb={breadcrumb}>\n <DetailPageTemplate\n header={{\n title: t('dashboard.title'),\n subtitle: t('dashboard.subtitle'),\n }}\n >\n <DashboardGrid columns={12}>\n {items.map(({ config, label }) => {\n return (\n <DashboardGridItem key={config.id} span={4}>\n <DashboardPanel title={label}>\n <div className={styles.tileBody}>\n <div className={styles.tileCount}>\n {t('common.notAvailable')}\n </div>\n <DashboardQuickActions\n actions={[\n {\n id: config.id,\n href: config.routes.list,\n label: t('dashboard.actions.openList'),\n },\n ]}\n />\n </div>\n </DashboardPanel>\n </DashboardGridItem>\n );\n })}\n </DashboardGrid>\n </DetailPageTemplate>\n </BackofficeRightPageLayout>\n );\n }\n\n if (dashboard.query != null) {\n return (\n <BackofficeRightPageLayout breadcrumb={breadcrumb}>\n <DashboardWithQuery config={dashboard} />\n </BackofficeRightPageLayout>\n );\n }\n\n return (\n <BackofficeRightPageLayout breadcrumb={breadcrumb}>\n <DashboardContent config={dashboard} globalData={null} />\n </BackofficeRightPageLayout>\n );\n};\n\nexport default BackofficeDashboardPage;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAM,EAAE,kBAAA,MAAqB,GAOvB,UAA+C;CACnD,IAAM,EAAE,MAAM,GAA+B;CAE7C,OAAO,kBAAC,GAAD,EAAsB,OAAO,EAAE,sBAAsB,EAAI,CAAA;GAG5D,UAA2C;CAC/C,IAAM,EAAE,MAAM,GAA+B;CAE7C,OACE,kBAAC,OAAD;EAAK,WAAW;YAAhB,CACE,kBAAC,GAAD,EAAS,WAAW,EAAE,iBAAiB,EAAI,CAAA,EAC3C,kBAAC,QAAD,EAAA,UAAO,EAAE,iBAAiB,EAAQ,CAAA,CAC9B;;GAIJ,KACJ,MAEO,KAAQ,KAGX,KACJ,MACkC;CACl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B,CAAA,GAT1B,kBAAC,GAAD;EAAuC;YACrC,kBAAC,GAAD,EAAoB,QAAQ,GAAa,CAAA;EACf,CAAA"}
|
|
1
|
+
{"version":3,"file":"BackofficeDashboardPage.js","names":[],"sources":["../../../src/pages/BackofficeDashboardPage.tsx"],"sourcesContent":["/* eslint-disable no-ternary */\nimport { type JSX, Suspense } from 'react';\nimport type {\n BackofficeDashboardConfig,\n BackofficeDashboardWidget,\n BackofficeDashboardWidgetSpan,\n BackofficeDashboardWidgetTabletSpan,\n BackofficeDashboardWidgetSize,\n I18nLabel,\n} from '@plumile/backoffice-core/types.js';\nimport { Spinner } from '@plumile/ui/backoffice/atoms/spinner/Spinner.js';\nimport { BackofficeEmptyState } from '@plumile/ui/backoffice/molecules/backoffice_empty_state/BackofficeEmptyState.js';\nimport { DetailPageTemplate } from '@plumile/ui/backoffice/templates/detail_page_template/DetailPageTemplate.js';\nimport {\n DashboardGrid,\n DashboardGridItem,\n} from '@plumile/ui/components/dashboard/dashboard_grid/DashboardGrid.js';\nimport { DataTable } from '@plumile/ui/components/data-table/DataTable.js';\nimport { useTranslation } from 'react-i18next';\nimport * as ReactRelay from 'react-relay';\nimport type { GraphQLTaggedNode, OperationType } from 'relay-runtime';\n\nimport { BackofficeErrorBoundary } from '../components/backoffice/errors/BackofficeErrorBoundary.js';\nimport { BackofficeBillingUsageChart } from '../components/backoffice/billing/BackofficeBillingUsageChart.js';\nimport { useBackofficeReactTranslation } from '../i18n/useBackofficeReactTranslation.js';\nimport { useBackofficeConfig } from '../provider/BackofficeConfigContext.js';\nimport { useBackofficeDashboardConfig } from '../provider/useBackofficeLazyValue.js';\nimport type { BackofficePreparedDashboardRoute } from '../router/createBackofficeRoutes.js';\nimport { buildDataTableColumns } from '../components/backoffice/columns/buildDataTableColumns.js';\nimport { BackofficeRightPageLayout } from '../components/backoffice/layout/breadcrumb/BackofficeRightPageLayout.js';\nimport { buildDashboardBreadcrumb } from '../components/backoffice/layout/breadcrumb/buildBreadcrumbs.js';\nimport {\n getWidgetLabel,\n hasWidgetQuery,\n resolveLabel,\n} from './BackofficeDashboardPage.helpers.js';\nimport { DashboardMetricGroup } from './dashboard/DashboardMetricGroup.js';\nimport { DashboardPanel } from './dashboard/DashboardPanel.js';\nimport { DashboardQuickActions } from './dashboard/DashboardQuickActions.js';\nimport { DashboardStatusList } from './dashboard/DashboardStatusList.js';\n\nimport * as styles from './backofficeDashboardPage.css.js';\n\nconst { useLazyLoadQuery } = ReactRelay;\n\ntype WidgetContentProps = {\n widget: BackofficeDashboardWidget;\n globalData: unknown;\n};\n\nconst DashboardUnavailableState = (): JSX.Element => {\n const { t } = useBackofficeReactTranslation();\n\n return <BackofficeEmptyState title={t('common.notAvailable')} />;\n};\n\nconst DashboardLoadingState = (): JSX.Element => {\n const { t } = useBackofficeReactTranslation();\n\n return (\n <div className={styles.loadingBody}>\n <Spinner ariaLabel={t('common.loading')} />\n <span>{t('common.loading')}</span>\n </div>\n );\n};\n\nconst resolveWidgetSize = (\n size: BackofficeDashboardWidgetSize | undefined,\n): BackofficeDashboardWidgetSize => {\n return size ?? 'm';\n};\n\nconst resolveWidgetSpan = (\n widget: BackofficeDashboardWidget,\n): BackofficeDashboardWidgetSpan => {\n if (widget.layout?.span != null) {\n return widget.layout.span;\n }\n\n const size = resolveWidgetSize(widget.size);\n if (size === 's') {\n return 3;\n }\n if (size === 'm') {\n return 4;\n }\n if (size === 'l') {\n return 6;\n }\n if (size === 'xl') {\n return 8;\n }\n return 12;\n};\n\nconst resolveWidgetTabletSpan = (\n widget: BackofficeDashboardWidget,\n): BackofficeDashboardWidgetTabletSpan | undefined => {\n return widget.layout?.tabletSpan;\n};\n\nconst WidgetContent = ({\n widget,\n globalData,\n}: WidgetContentProps): JSX.Element | null => {\n const { t: tApp } = useTranslation();\n const { t } = useBackofficeReactTranslation();\n const { entities } = useBackofficeConfig();\n const description =\n widget.description != null\n ? resolveLabel(widget.description, tApp)\n : undefined;\n\n const resolveData = (data: unknown): unknown => {\n if ('resolve' in widget && widget.resolve != null) {\n return widget.resolve(data);\n }\n return null;\n };\n\n if (widget.kind === 'textBlock') {\n const title = resolveLabel(widget.title, tApp);\n const body = resolveLabel(widget.body, tApp);\n return (\n <DashboardPanel title={title} subtitle={description}>\n <div className={styles.tileBody}>{body}</div>\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'shortcut') {\n const entity = entities[widget.entityId];\n const title = resolveLabel(widget.label, tApp);\n if (entity == null) {\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n if (entity.kind === 'tool') {\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardQuickActions\n actions={[\n {\n id: entity.id,\n href: entity.routes.list,\n label: t('dashboard.actions.openTool'),\n },\n ]}\n />\n </DashboardPanel>\n );\n }\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardQuickActions\n actions={[\n {\n id: entity.id,\n href: entity.routes.list,\n label: t('dashboard.actions.openList'),\n },\n ]}\n />\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'tablePreview') {\n const resolved = resolveData(globalData) as {\n columns: readonly unknown[];\n rows: readonly unknown[];\n } | null;\n if (resolved == null) {\n return (\n <DashboardPanel\n title={resolveLabel(widget.title, tApp)}\n subtitle={description}\n >\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n const columns = buildDataTableColumns(resolved.columns as never, {\n tApp,\n t,\n });\n const title = resolveLabel(widget.title, tApp);\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DataTable\n columns={columns}\n rows={resolved.rows}\n getRowId={(row, index) => {\n if (row != null && typeof row === 'object') {\n const record = row as Record<string, unknown>;\n const { id } = record;\n if (typeof id === 'string' && id.trim() !== '') {\n return id;\n }\n }\n return String(index);\n }}\n />\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'metricGroup') {\n const resolved = resolveData(globalData) as\n | readonly {\n id: string;\n label: I18nLabel;\n value: string | number | null;\n meta?: I18nLabel;\n href?: string;\n }[]\n | null;\n if (resolved == null) {\n return <DashboardUnavailableState />;\n }\n return (\n <DashboardMetricGroup\n emptyState={<DashboardUnavailableState />}\n metrics={resolved.map((metric) => {\n return {\n id: metric.id,\n href: metric.href,\n label: resolveLabel(metric.label, tApp),\n value: metric.value ?? t('common.notAvailable'),\n hint:\n metric.meta != null ? resolveLabel(metric.meta, tApp) : undefined,\n };\n })}\n />\n );\n }\n\n if (widget.kind === 'billingUsageChart') {\n const resolved = resolveData(globalData) as {\n currency: string;\n totalAmount: number;\n from: string | null;\n to: string | null;\n buckets: readonly {\n day: string;\n category: string;\n value: number;\n }[];\n } | null;\n const title = resolveLabel(widget.title, tApp);\n if (resolved == null) {\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n\n return (\n <DashboardPanel title={title} subtitle={description}>\n <BackofficeBillingUsageChart\n ariaLabel={resolveLabel(widget.ariaLabel, tApp)}\n buckets={resolved.buckets}\n categories={widget.categories.map((category) => {\n return {\n id: category.id,\n label: resolveLabel(category.label, tApp),\n color: category.color,\n };\n })}\n currency={resolved.currency}\n emptyLabel={resolveLabel(widget.emptyLabel, tApp)}\n from={resolved.from}\n rangePrefix={resolveLabel(widget.rangePrefix, tApp)}\n to={resolved.to}\n totalAmount={resolved.totalAmount}\n />\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'quickActions') {\n const title =\n widget.title != null\n ? resolveLabel(widget.title, tApp)\n : t('dashboard.actions.openTool');\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardQuickActions\n layout={widget.layout?.zone === 'aside' ? 'stack' : 'grid'}\n emptyState={<DashboardUnavailableState />}\n actions={widget.actions.map((action) => {\n return {\n id: action.id,\n href: action.href,\n label: resolveLabel(action.label, tApp),\n };\n })}\n />\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'statusSummary') {\n const resolved = resolveData(globalData) as\n | readonly {\n id: string;\n label: I18nLabel;\n value: string | number | null;\n href?: string;\n }[]\n | null;\n if (resolved == null) {\n const title =\n widget.title != null ? resolveLabel(widget.title, tApp) : undefined;\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n const title =\n widget.title != null ? resolveLabel(widget.title, tApp) : undefined;\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardStatusList\n emptyState={<DashboardUnavailableState />}\n items={resolved.map((item) => {\n return {\n id: item.id,\n href: item.href,\n label: resolveLabel(item.label, tApp),\n value: item.value ?? t('common.notAvailable'),\n };\n })}\n />\n </DashboardPanel>\n );\n }\n\n if (widget.kind === 'recentItems') {\n const title =\n widget.title != null\n ? resolveLabel(widget.title, tApp)\n : t('dashboard.title');\n return (\n <DashboardPanel title={title} subtitle={description}>\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n\n const entityManifest = entities[widget.entityId];\n if (entityManifest?.kind !== 'list-detail') {\n return (\n <DashboardPanel\n title={resolveLabel(widget.label, tApp)}\n subtitle={description}\n >\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }\n const resolved = resolveData(globalData) as { count: number | null } | null;\n let countLabel: number | string = t('common.notAvailable');\n if (typeof resolved?.count === 'number') {\n countLabel = resolved.count;\n }\n const title = resolveLabel(widget.label, tApp);\n return (\n <DashboardPanel title={title} subtitle={description}>\n <div className={styles.tileBody}>\n <div className={styles.tileCount}>{countLabel}</div>\n <DashboardQuickActions\n emptyState={<DashboardUnavailableState />}\n actions={[\n {\n id: entityManifest.id,\n href: entityManifest.routes.list,\n label: t('dashboard.actions.openList'),\n },\n ]}\n />\n </div>\n </DashboardPanel>\n );\n};\n\ntype WidgetWithQueryProps = {\n widget: BackofficeDashboardWidget & { query: GraphQLTaggedNode };\n};\n\nconst WidgetWithQuery = ({ widget }: WidgetWithQueryProps): JSX.Element => {\n const data = useLazyLoadQuery<OperationType>(\n widget.query,\n {},\n {\n fetchPolicy: 'store-or-network',\n },\n );\n\n return <WidgetContent widget={widget} globalData={data} />;\n};\n\ntype DashboardContentProps = {\n config: BackofficeDashboardConfig;\n globalData: unknown;\n};\n\nconst DashboardContent = ({\n config,\n globalData,\n}: DashboardContentProps): JSX.Element => {\n const { t: tApp } = useTranslation();\n const { t } = useBackofficeReactTranslation();\n\n const title = resolveLabel(config.title, tApp);\n const subtitle =\n config.subtitle != null ? resolveLabel(config.subtitle, tApp) : undefined;\n\n return (\n <DetailPageTemplate\n header={{\n title,\n subtitle: subtitle ?? t('dashboard.subtitle'),\n }}\n >\n <DashboardGrid columns={12}>\n {config.widgets.map((widget) => {\n const widgetTitle = resolveLabel(\n getWidgetLabel(widget, config),\n tApp,\n );\n const content = hasWidgetQuery(widget) ? (\n <WidgetWithQuery widget={widget} />\n ) : (\n <WidgetContent widget={widget} globalData={globalData} />\n );\n\n return (\n <DashboardGridItem\n key={widget.id}\n minHeight={widget.minHeight ?? 'auto'}\n span={resolveWidgetSpan(widget)}\n tabletSpan={resolveWidgetTabletSpan(widget)}\n >\n <BackofficeErrorBoundary\n fallback={() => {\n return (\n <DashboardPanel title={widgetTitle}>\n <DashboardUnavailableState />\n </DashboardPanel>\n );\n }}\n >\n <Suspense\n fallback={\n <DashboardPanel title={widgetTitle}>\n <DashboardLoadingState />\n </DashboardPanel>\n }\n >\n {content}\n </Suspense>\n </BackofficeErrorBoundary>\n </DashboardGridItem>\n );\n })}\n </DashboardGrid>\n </DetailPageTemplate>\n );\n};\n\ntype DashboardWithQueryProps = {\n config: BackofficeDashboardConfig;\n};\n\nconst DashboardWithQuery = ({\n config,\n}: DashboardWithQueryProps): JSX.Element => {\n const data = useLazyLoadQuery<OperationType>(\n config.query as never,\n {},\n { fetchPolicy: 'store-or-network' },\n );\n\n return <DashboardContent config={config} globalData={data} />;\n};\n\nexport type BackofficeDashboardPageProps = {\n prepared?: BackofficePreparedDashboardRoute | null;\n};\n\nexport const BackofficeDashboardPage = ({\n prepared,\n}: BackofficeDashboardPageProps): JSX.Element => {\n const { t: tApp } = useTranslation();\n const { t } = useBackofficeReactTranslation();\n const { entities } = useBackofficeConfig();\n const rootDashboard = useBackofficeDashboardConfig();\n const dashboard = prepared?.config ?? rootDashboard;\n const breadcrumb = buildDashboardBreadcrumb(t);\n\n if (dashboard == null) {\n const items = Object.values(entities)\n .filter((config) => {\n return config.kind === 'list-detail' && config.hasList;\n })\n .map((config) => {\n return {\n config,\n label: resolveLabel(config.label, tApp),\n };\n })\n .sort((left, right) => {\n return left.label.localeCompare(right.label);\n });\n\n return (\n <BackofficeRightPageLayout breadcrumb={breadcrumb}>\n <DetailPageTemplate\n header={{\n title: t('dashboard.title'),\n subtitle: t('dashboard.subtitle'),\n }}\n >\n <DashboardGrid columns={12}>\n {items.map(({ config, label }) => {\n return (\n <DashboardGridItem key={config.id} span={4}>\n <DashboardPanel title={label}>\n <div className={styles.tileBody}>\n <div className={styles.tileCount}>\n {t('common.notAvailable')}\n </div>\n <DashboardQuickActions\n actions={[\n {\n id: config.id,\n href: config.routes.list,\n label: t('dashboard.actions.openList'),\n },\n ]}\n />\n </div>\n </DashboardPanel>\n </DashboardGridItem>\n );\n })}\n </DashboardGrid>\n </DetailPageTemplate>\n </BackofficeRightPageLayout>\n );\n }\n\n if (dashboard.query != null) {\n return (\n <BackofficeRightPageLayout breadcrumb={breadcrumb}>\n <DashboardWithQuery config={dashboard} />\n </BackofficeRightPageLayout>\n );\n }\n\n return (\n <BackofficeRightPageLayout breadcrumb={breadcrumb}>\n <DashboardContent config={dashboard} globalData={null} />\n </BackofficeRightPageLayout>\n );\n};\n\nexport default BackofficeDashboardPage;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA2CA,IAAM,EAAE,kBAAA,MAAqB,GAOvB,UAA+C;CACnD,IAAM,EAAE,MAAM,GAA+B;CAE7C,OAAO,kBAAC,GAAD,EAAsB,OAAO,EAAE,sBAAsB,EAAI,CAAA;GAG5D,UAA2C;CAC/C,IAAM,EAAE,MAAM,GAA+B;CAE7C,OACE,kBAAC,OAAD;EAAK,WAA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S,iBAAiB,EAAO,QAC/C,CACD,KAAK,OACG;GACL;GACA,OAAO,EAAa,EAAO,OAAO,EAAK;GACxC,EACD,CACD,MAAM,GAAM,MACJ,EAAK,MAAM,cAAc,EAAM,MAAM,CAC5C;EAEJ,OACE,kBAAC,GAAD;GAAuC;aACrC,kBAAC,GAAD;IACE,QAAQ;KACN,OAAO,EAAE,kBAAkB;KAC3B,UAAU,EAAE,qBAAqB;KAClC;cAED,kBAAC,GAAD;KAAe,SAAS;eACrB,EAAM,KAAK,EAAE,WAAQ,eAElB,kBAAC,GAAD;MAAmC,MAAM;gBACvC,kBAAC,GAAD;OAAgB,OAAO;iBACrB,kBAAC,OAAD;QAAK,WAAW;kBAAhB,CACE,kBAAC,OAAD;SAAK,WAAW;mBACb,EAAE,sBAAsB;SACrB,CAAA,EACN,kBAAC,GAAD,EACE,SAAS,CACP;SACE,IAAI,EAAO;SACX,MAAM,EAAO,OAAO;SACpB,OAAO,EAAE,6BAA6B;SACvC,CACF,EACD,CAAA,CACE;;OACS,CAAA;MACC,EAjBI,EAAO,GAiBX,CAEtB;KACY,CAAA;IACG,CAAA;GACK,CAAA;;CAYhC,OARI,EAAU,SAAS,OASrB,kBAAC,GAAD;EAAuC;YACrC,kBAAC,GAAD;GAAkB,QAAQ;GAAW,YAAY;GAAQ,CAAA;EAC/B,CAAA,GAT1B,kBAAC,GAAD;EAAuC;YACrC,kBAAC,GAAD,EAAoB,QAAQ,GAAa,CAAA;EACf,CAAA"}
|
|
@@ -34,9 +34,9 @@ import { Button as w } from "@plumile/ui/atomic/atoms/button/Button.js";
|
|
|
34
34
|
import { commitMutation as Se, useFragment as T, usePreloadedQuery as E } from "react-relay";
|
|
35
35
|
import { useToast as D } from "@plumile/ui/atomic/molecules/toast/ToastProvider.js";
|
|
36
36
|
import O from "@plumile/router/routing/RoutingContext.js";
|
|
37
|
-
import {
|
|
38
|
-
import A from "@plumile/
|
|
39
|
-
import
|
|
37
|
+
import { FormattedDate as k } from "@plumile/ui/atomic/atoms/formatted-date/FormattedDate.js";
|
|
38
|
+
import { BACKOFFICE_DATE_TIME_OPTIONS as A } from "@plumile/backoffice-core/constants.js";
|
|
39
|
+
import j from "@plumile/router/routing/Link.js";
|
|
40
40
|
import { Tag as M } from "@plumile/ui/backoffice/atoms/tag/Tag.js";
|
|
41
41
|
import { buildBackofficeFallbackListHref as Ce, buildBackofficeListHref as we, buildBackofficeListLink as Te } from "@plumile/backoffice-core/state/buildListHref.js";
|
|
42
42
|
import { setWhereValue as Ee } from "@plumile/backoffice-core/filters/where.js";
|
|
@@ -193,13 +193,13 @@ var Me = (e) => {
|
|
|
193
193
|
tApp: L,
|
|
194
194
|
t: R,
|
|
195
195
|
resolveEntityHref: p,
|
|
196
|
-
renderLink: (e, t) => /* @__PURE__ */ S(
|
|
196
|
+
renderLink: (e, t) => /* @__PURE__ */ S(j, {
|
|
197
197
|
to: e,
|
|
198
198
|
children: t
|
|
199
199
|
}),
|
|
200
|
-
renderDate: (e, t) => /* @__PURE__ */ S(
|
|
200
|
+
renderDate: (e, t) => /* @__PURE__ */ S(k, {
|
|
201
201
|
value: e,
|
|
202
|
-
options:
|
|
202
|
+
options: A,
|
|
203
203
|
fallback: t
|
|
204
204
|
}),
|
|
205
205
|
renderTag: (e, t) => /* @__PURE__ */ S(M, {
|
|
@@ -326,9 +326,9 @@ var Me = (e) => {
|
|
|
326
326
|
children: t
|
|
327
327
|
}),
|
|
328
328
|
renderBadgeRow: (e) => /* @__PURE__ */ S(c, { items: e }),
|
|
329
|
-
renderDate: (e, t) => /* @__PURE__ */ S(
|
|
329
|
+
renderDate: (e, t) => /* @__PURE__ */ S(k, {
|
|
330
330
|
value: e,
|
|
331
|
-
options:
|
|
331
|
+
options: A,
|
|
332
332
|
fallback: t
|
|
333
333
|
}),
|
|
334
334
|
renderFlagTag: (e) => /* @__PURE__ */ S(l, {
|
|
@@ -336,7 +336,7 @@ var Me = (e) => {
|
|
|
336
336
|
icon: e.iconName == null ? void 0 : Me(e.iconName),
|
|
337
337
|
label: e.label
|
|
338
338
|
}),
|
|
339
|
-
renderLink: (e, t) => /* @__PURE__ */ S(
|
|
339
|
+
renderLink: (e, t) => /* @__PURE__ */ S(j, {
|
|
340
340
|
to: e,
|
|
341
341
|
children: t
|
|
342
342
|
}),
|
|
@@ -362,13 +362,13 @@ var Me = (e) => {
|
|
|
362
362
|
t: R,
|
|
363
363
|
resolveEntityHref: p,
|
|
364
364
|
keyPrefix: String(t),
|
|
365
|
-
renderLink: (e, t) => /* @__PURE__ */ S(
|
|
365
|
+
renderLink: (e, t) => /* @__PURE__ */ S(j, {
|
|
366
366
|
to: e,
|
|
367
367
|
children: t
|
|
368
368
|
}),
|
|
369
|
-
renderDate: (e, t) => /* @__PURE__ */ S(
|
|
369
|
+
renderDate: (e, t) => /* @__PURE__ */ S(k, {
|
|
370
370
|
value: e,
|
|
371
|
-
options:
|
|
371
|
+
options: A,
|
|
372
372
|
fallback: t
|
|
373
373
|
}),
|
|
374
374
|
renderTag: (e, t) => /* @__PURE__ */ S(M, {
|